Refactor color cursor loading

This commit is contained in:
elasota
2020-01-05 04:13:00 -05:00
parent 700c31b9e4
commit 1fba6f9e85
4 changed files with 21 additions and 94 deletions

View File

@@ -89,33 +89,6 @@ CursHandle GetCursor(int cursorID)
return GetResource('CURS', cursorID).ReinterpretCast<Cursor>();
}
CCrsrHandle GetCCursor(int cursorID)
{
PortabilityLayer::HostDisplayDriver *driver = PortabilityLayer::HostDisplayDriver::GetInstance();
IGpColorCursor *hwCursor = driver->LoadColorCursor(cursorID);
if (!hwCursor)
return nullptr;
CCrsrHandle hdl = PortabilityLayer::MemoryManager::GetInstance()->NewHandle<CCursor>();
if (!hdl)
{
hwCursor->Destroy();
return nullptr;
}
CCursor *ccursor = *hdl;
ccursor->hwCursor = hwCursor;
return hdl;
}
void SetCCursor(CCrsrHandle handle)
{
assert(handle);
PortabilityLayer::HostDisplayDriver::GetInstance()->SetColorCursor((*handle)->hwCursor);
}
void HideCursor()
{
PortabilityLayer::HostDisplayDriver::GetInstance()->SetStandardCursor(EGpStandardCursors::kHidden);
@@ -131,13 +104,6 @@ void SetBuiltinCursor(int builtinCursor)
PL_NotYetImplemented();
}
void DisposeCCursor(CCrsrHandle handle)
{
(*handle)->hwCursor->Destroy();
PortabilityLayer::MemoryManager::GetInstance()->ReleaseHandle(handle.MMBlock());
}
void Delay(int ticks, UInt32 *endTickCount)
{
PLSysCalls::Sleep(ticks);

View File

@@ -96,11 +96,6 @@ struct Cursor
{
};
struct CCursor
{
IGpColorCursor *hwCursor;
};
struct Window
{
Window();
@@ -186,13 +181,11 @@ struct EventRecord
typedef Window *WindowPtr;
typedef Cursor *CursPtr;
typedef CCursor *CCrsrPtr;
typedef Menu *MenuPtr;
typedef CInfoPBRec *CInfoPBPtr;
typedef VersionRecord *VersRecPtr;
typedef THandle<Cursor> CursHandle;
typedef THandle<CCursor> CCrsrHandle;
typedef THandle<Menu> MenuHandle;
typedef THandle<VersionRecord> VersRecHndl;
@@ -262,15 +255,11 @@ static const int nullEvent = 0;
void InitCursor();
CursHandle GetCursor(int cursorID);
CCrsrHandle GetCCursor(int cursorID);
void SetCCursor(CCrsrHandle handle);
void HideCursor();
void SetCursor(CursPtr cursor);
void SetBuiltinCursor(int builtinCursor);
void DisposeCCursor(CCrsrHandle handle);
void Delay(int ticks, UInt32 *endTickCount);
short Alert(int dialogID, void *unknown);