mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-24 07:06:36 +00:00
Level editor and resource loader fixups and refactors
This commit is contained in:
@@ -404,7 +404,7 @@ namespace PortabilityLayer
|
||||
{
|
||||
ResourceManager *rm = ResourceManager::GetInstance();
|
||||
|
||||
THandle<uint8_t> dlogH = rm->GetResource('DLOG', resID).StaticCast<uint8_t>();
|
||||
THandle<uint8_t> dlogH = rm->GetAppResource('DLOG', resID).StaticCast<uint8_t>();
|
||||
const uint8_t *dlogData = *dlogH;
|
||||
const uint8_t *dlogDataEnd = dlogData + dlogH.MMBlock()->m_size;
|
||||
|
||||
@@ -434,7 +434,7 @@ namespace PortabilityLayer
|
||||
|
||||
WindowManager *wm = PortabilityLayer::WindowManager::GetInstance();
|
||||
|
||||
WindowDef wdef = WindowDef::Create(rect, 0, header.m_visible != 0, header.m_hasCloseBox != 0, header.m_referenceConstant, positionSpec, PLPasStr(titlePStr));
|
||||
WindowDef wdef = WindowDef::Create(rect, WindowStyleFlags::kAlert, header.m_visible != 0, header.m_hasCloseBox != 0, header.m_referenceConstant, positionSpec, PLPasStr(titlePStr));
|
||||
Window *window = wm->CreateWindow(wdef);
|
||||
if (!window)
|
||||
{
|
||||
@@ -499,7 +499,7 @@ namespace PortabilityLayer
|
||||
{
|
||||
ResourceManager *rm = ResourceManager::GetInstance();
|
||||
|
||||
THandle<uint8_t> dtemplateH = rm->GetResource('DITL', resID).StaticCast<uint8_t>();
|
||||
THandle<uint8_t> dtemplateH = rm->GetAppResource('DITL', resID).StaticCast<uint8_t>();
|
||||
|
||||
if (!dtemplateH)
|
||||
return nullptr;
|
||||
|
@@ -56,7 +56,7 @@ namespace PortabilityLayer
|
||||
|
||||
bool IconLoaderImpl::LoadColorIcon(const int16_t id, THandle<PixMapImpl> &outColorImage, THandle<PixMapImpl> &outBWImage, THandle<PixMapImpl> &outMaskImage)
|
||||
{
|
||||
THandle<const uint8_t> data = PortabilityLayer::ResourceManager::GetInstance()->GetResource('cicn', id).StaticCast<const uint8_t>();
|
||||
THandle<const uint8_t> data = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('cicn', id).StaticCast<const uint8_t>();
|
||||
|
||||
if (!data)
|
||||
return false;
|
||||
|
@@ -595,8 +595,8 @@ namespace PortabilityLayer
|
||||
{
|
||||
ResourceManager *resManager = ResourceManager::GetInstance();
|
||||
|
||||
Handle icsHandle = GetResource('ics#', kIconResID);
|
||||
Handle ics8Handle = GetResource('ics8', kIconResID);
|
||||
Handle icsHandle = resManager->GetAppResource('ics#', kIconResID);
|
||||
Handle ics8Handle = resManager->GetAppResource('ics8', kIconResID);
|
||||
|
||||
if (icsHandle && ics8Handle)
|
||||
{
|
||||
|
@@ -87,7 +87,7 @@ Rect BERect::ToRect() const
|
||||
|
||||
CursHandle GetCursor(int cursorID)
|
||||
{
|
||||
return GetResource('CURS', cursorID).ReinterpretCast<Cursor>();
|
||||
return PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('CURS', cursorID).ReinterpretCast<Cursor>();
|
||||
}
|
||||
|
||||
void HideCursor()
|
||||
@@ -119,17 +119,6 @@ short Alert(int dialogID, void *unknown)
|
||||
return 0;
|
||||
}
|
||||
|
||||
Handle GetResource(int32_t resType, int id)
|
||||
{
|
||||
return PortabilityLayer::ResourceManager::GetInstance()->GetResource(PortabilityLayer::ResTypeID(resType), id);
|
||||
}
|
||||
|
||||
Handle GetResource(const char(&resTypeLiteral)[5], int id)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
short FindWindow(Point point, WindowPtr *window)
|
||||
{
|
||||
short part = 0;
|
||||
@@ -198,7 +187,7 @@ void GetWindowBounds(WindowPtr window, WindowRegionType windowRegion, Rect *rect
|
||||
|
||||
WindowPtr GetNewCWindow(int resID, void *storage, WindowPtr behind)
|
||||
{
|
||||
Handle windowResource = GetResource('WIND', resID);
|
||||
Handle windowResource = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('WIND', resID);
|
||||
|
||||
if (!windowResource)
|
||||
return nullptr;
|
||||
@@ -361,7 +350,7 @@ void GetIndString(unsigned char *str, int stringsID, int fnameIndex)
|
||||
if (fnameIndex < 1)
|
||||
return;
|
||||
|
||||
THandle<uint8_t> istrRes = PortabilityLayer::ResourceManager::GetInstance()->GetResource('STR#', stringsID).StaticCast<uint8_t>();
|
||||
THandle<uint8_t> istrRes = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('STR#', stringsID).StaticCast<uint8_t>();
|
||||
if (istrRes && *istrRes)
|
||||
{
|
||||
const uint8_t *contentsBytes = *istrRes;
|
||||
@@ -626,7 +615,7 @@ void *NewPtrClear(Size size)
|
||||
|
||||
void DisposePtr(void *ptr)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
PortabilityLayer::MemoryManager::GetInstance()->Release(ptr);
|
||||
}
|
||||
|
||||
void BlockMove(const void *src, void *dest, Size size)
|
||||
|
@@ -222,11 +222,6 @@ enum EventCode
|
||||
kHighLevelEvent,
|
||||
};
|
||||
|
||||
enum BuiltinWDEFs
|
||||
{
|
||||
noGrowDocProc = 4, // Movable, not resizable
|
||||
};
|
||||
|
||||
static const int everyEvent = -1;
|
||||
|
||||
static const int iBeamCursor = 1;
|
||||
@@ -251,9 +246,6 @@ void SetBuiltinCursor(int builtinCursor);
|
||||
void Delay(int ticks, UInt32 *endTickCount);
|
||||
short Alert(int dialogID, void *unknown);
|
||||
|
||||
Handle GetResource(int32_t resType, int id);
|
||||
Handle GetResource(const char(&resTypeLiteral)[5], int id);
|
||||
|
||||
short FindWindow(Point point, WindowPtr *window); // Translates global coordinates to window coordinates, returns a region ID
|
||||
void DragWindow(WindowPtr window, Point start, Rect *bounds); // Drags the window (probably not implemented)
|
||||
void SendBehind(WindowPtr window, WindowPtr behind);
|
||||
|
@@ -15,7 +15,7 @@ namespace PortabilityLayer
|
||||
|
||||
bool ImageWidget::Init(const WidgetBasicState &state)
|
||||
{
|
||||
m_pict = PortabilityLayer::ResourceManager::GetInstance()->GetResource('PICT', state.m_resID).StaticCast<BitmapImage>();
|
||||
m_pict = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PICT', state.m_resID).StaticCast<BitmapImage>();
|
||||
|
||||
if (!m_pict)
|
||||
return false;
|
||||
|
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "MenuManager.h"
|
||||
#include "QDManager.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
// Menu resource structure:
|
||||
// uint16 menu ID
|
||||
@@ -21,7 +22,7 @@
|
||||
|
||||
MenuHandle GetMenu(int resID)
|
||||
{
|
||||
Handle menuRes = GetResource('MENU', resID);
|
||||
Handle menuRes = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('MENU', resID);
|
||||
|
||||
if (!menuRes)
|
||||
return nullptr;
|
||||
|
@@ -36,11 +36,6 @@ PixMapHandle GetGWorldPixMap(DrawSurface *gworld)
|
||||
return gworld->m_port.GetPixMap();
|
||||
}
|
||||
|
||||
THandle<BitmapImage> GetPicture(short resID)
|
||||
{
|
||||
return PortabilityLayer::ResourceManager::GetInstance()->GetResource('PICT', resID).StaticCast<BitmapImage>();
|
||||
}
|
||||
|
||||
void OffsetRect(Rect *rect, int right, int down)
|
||||
{
|
||||
rect->left += right;
|
||||
|
@@ -22,8 +22,6 @@ void DisposeGWorld(DrawSurface *gworld);
|
||||
|
||||
PixMapHandle GetGWorldPixMap(DrawSurface *gworld);
|
||||
|
||||
THandle<BitmapImage> GetPicture(short resID);
|
||||
|
||||
void OffsetRect(Rect *rect, int right, int down);
|
||||
|
||||
DrawSurface *GetGraphicsPort();
|
||||
|
@@ -1382,7 +1382,7 @@ void GetIndPattern(Pattern *pattern, int patListID, int index)
|
||||
if (index < 1)
|
||||
return;
|
||||
|
||||
THandle<uint8_t> patternList = PortabilityLayer::ResourceManager::GetInstance()->GetResource('PAT#', patListID).StaticCast<uint8_t>();
|
||||
THandle<uint8_t> patternList = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('PAT#', patListID).StaticCast<uint8_t>();
|
||||
const uint8_t *patternRes = *patternList;
|
||||
|
||||
int numPatterns = (patternRes[0] << 8) | patternRes[1];
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include "ZipFileProxy.h"
|
||||
#include "ZipFile.h"
|
||||
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace ResourceValidationRules
|
||||
{
|
||||
@@ -104,75 +104,42 @@ namespace PortabilityLayer
|
||||
|
||||
void Init() override;
|
||||
void Shutdown() override;
|
||||
|
||||
void SetResLoad(bool load) override;
|
||||
|
||||
THandle<void> GetAppResource(const ResTypeID &resTypeID, int16_t resID) const override;
|
||||
ResourceArchive *GetAppResourceArchive() const override;
|
||||
|
||||
ResourceArchive *LoadResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) const override;
|
||||
short OpenResFork(VirtualDirectory_t virtualDir, const PLPasStr &filename) override;
|
||||
void CloseResFile(short ref) override;
|
||||
PLError_t CreateBlankResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) override;
|
||||
|
||||
THandle<void> GetResource(const ResTypeID &resType, int id) override;
|
||||
|
||||
short GetCurrentResFile() const override;
|
||||
void SetCurrentResFile(short ref) override;
|
||||
|
||||
void DissociateHandle(MMHandleBlock *hdl) const override;
|
||||
const ResourceArchiveRef *ResourceForHandle(MMHandleBlock *hdl) const override;
|
||||
|
||||
static ResourceManagerImpl *GetInstance();
|
||||
|
||||
private:
|
||||
struct ResFileSlot
|
||||
{
|
||||
short m_prevFile;
|
||||
short m_nextFile;
|
||||
ResourceArchive *m_resourceArchive;
|
||||
};
|
||||
|
||||
void UnloadAndDestroyResourceFile(ResourceArchive *rf);
|
||||
|
||||
std::vector<ResFileSlot> m_resFiles;
|
||||
short m_firstResFile;
|
||||
short m_lastResFile;
|
||||
short m_currentResFile;
|
||||
bool m_load;
|
||||
ResourceArchive *m_appResArchive;
|
||||
|
||||
static ResourceManagerImpl ms_instance;
|
||||
};
|
||||
|
||||
ResourceManagerImpl::ResourceManagerImpl()
|
||||
: m_currentResFile(-1)
|
||||
, m_firstResFile(-1)
|
||||
, m_lastResFile(-1)
|
||||
, m_load(true)
|
||||
: m_appResArchive(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void ResourceManagerImpl::Init()
|
||||
{
|
||||
m_currentResFile = OpenResFork(VirtualDirectories::kApplicationData, PSTR("ApplicationResources"));
|
||||
m_appResArchive = LoadResFile(VirtualDirectories::kApplicationData, PSTR("ApplicationResources"));
|
||||
}
|
||||
|
||||
void ResourceManagerImpl::Shutdown()
|
||||
{
|
||||
for (std::vector<ResFileSlot>::iterator it = m_resFiles.begin(), itEnd = m_resFiles.end(); it != itEnd; ++it)
|
||||
{
|
||||
if (it->m_resourceArchive)
|
||||
UnloadAndDestroyResourceFile(it->m_resourceArchive);
|
||||
}
|
||||
if (m_appResArchive)
|
||||
m_appResArchive->Destroy();
|
||||
|
||||
m_resFiles.clear();
|
||||
}
|
||||
|
||||
short ResourceManagerImpl::GetCurrentResFile() const
|
||||
{
|
||||
return m_currentResFile;
|
||||
}
|
||||
|
||||
void ResourceManagerImpl::SetCurrentResFile(short ref)
|
||||
{
|
||||
m_currentResFile = ref;
|
||||
m_appResArchive = nullptr;
|
||||
}
|
||||
|
||||
void ResourceManagerImpl::DissociateHandle(MMHandleBlock *hdl) const
|
||||
@@ -198,11 +165,6 @@ namespace PortabilityLayer
|
||||
return &ms_instance;
|
||||
}
|
||||
|
||||
void ResourceManagerImpl::SetResLoad(bool load)
|
||||
{
|
||||
m_load = load;
|
||||
}
|
||||
|
||||
ResourceArchive *ResourceManagerImpl::LoadResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) const
|
||||
{
|
||||
IOStream *fStream = nullptr;
|
||||
@@ -227,82 +189,6 @@ namespace PortabilityLayer
|
||||
return archive;
|
||||
}
|
||||
|
||||
short ResourceManagerImpl::OpenResFork(VirtualDirectory_t virtualDir, const PLPasStr &filename)
|
||||
{
|
||||
const size_t numSlots = m_resFiles.size();
|
||||
size_t resFileIndex = numSlots;
|
||||
|
||||
for (size_t i = 0; i < numSlots; i++)
|
||||
{
|
||||
if (m_resFiles[i].m_resourceArchive == nullptr)
|
||||
{
|
||||
resFileIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (resFileIndex == 0x7fff)
|
||||
return -1;
|
||||
|
||||
|
||||
ResourceArchive *resFile = LoadResFile(virtualDir, filename);
|
||||
|
||||
if (!resFile)
|
||||
return -1;
|
||||
|
||||
ResFileSlot slot;
|
||||
slot.m_resourceArchive = resFile;
|
||||
slot.m_prevFile = m_lastResFile;
|
||||
slot.m_nextFile = -1;
|
||||
|
||||
if (resFileIndex == numSlots)
|
||||
m_resFiles.push_back(slot);
|
||||
else
|
||||
m_resFiles[resFileIndex] = slot;
|
||||
|
||||
const short rfid = static_cast<short>(resFileIndex);
|
||||
|
||||
if (m_firstResFile < 0)
|
||||
m_firstResFile = rfid;
|
||||
|
||||
if (m_lastResFile >= 0)
|
||||
m_resFiles[m_lastResFile].m_nextFile = rfid;
|
||||
|
||||
m_lastResFile = rfid;
|
||||
m_currentResFile = rfid; // Resource Manager is supposed to reset the search stack on new file open
|
||||
|
||||
return rfid;
|
||||
}
|
||||
|
||||
void ResourceManagerImpl::CloseResFile(short ref)
|
||||
{
|
||||
ResFileSlot &slot = m_resFiles[ref];
|
||||
|
||||
assert(slot.m_resourceArchive != nullptr);
|
||||
|
||||
slot.m_resourceArchive->Destroy();
|
||||
slot.m_resourceArchive = nullptr;
|
||||
|
||||
if (m_lastResFile == ref)
|
||||
m_lastResFile = slot.m_prevFile;
|
||||
|
||||
if (slot.m_prevFile >= 0)
|
||||
{
|
||||
ResFileSlot &prevFileSlot = m_resFiles[slot.m_prevFile];
|
||||
prevFileSlot.m_nextFile = slot.m_nextFile;
|
||||
}
|
||||
|
||||
if (slot.m_nextFile >= 0)
|
||||
{
|
||||
ResFileSlot &nextFileSlot = m_resFiles[slot.m_nextFile];
|
||||
nextFileSlot.m_prevFile = slot.m_prevFile;
|
||||
}
|
||||
|
||||
slot.m_nextFile = slot.m_prevFile = -1;
|
||||
|
||||
m_currentResFile = m_lastResFile;
|
||||
}
|
||||
|
||||
PLError_t ResourceManagerImpl::CreateBlankResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename)
|
||||
{
|
||||
PortabilityLayer::IOStream *stream = nullptr;
|
||||
@@ -331,22 +217,17 @@ namespace PortabilityLayer
|
||||
return PLErrors::kNone;
|
||||
}
|
||||
|
||||
THandle<void> ResourceManagerImpl::GetResource(const ResTypeID &resType, int id)
|
||||
THandle<void> ResourceManagerImpl::GetAppResource(const ResTypeID &resType, int16_t resID) const
|
||||
{
|
||||
short searchIndex = m_currentResFile;
|
||||
while (searchIndex >= 0)
|
||||
{
|
||||
const ResFileSlot& slot = m_resFiles[searchIndex];
|
||||
assert(slot.m_resourceArchive);
|
||||
if (!m_appResArchive)
|
||||
return THandle<void>();
|
||||
|
||||
THandle<void> resHdl = slot.m_resourceArchive->GetResource(resType, id, m_load);
|
||||
if (resHdl != nullptr)
|
||||
return resHdl;
|
||||
return m_appResArchive->LoadResource(resType, resID);
|
||||
}
|
||||
|
||||
searchIndex = slot.m_prevFile;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
ResourceArchive *ResourceManagerImpl::GetAppResourceArchive() const
|
||||
{
|
||||
return m_appResArchive;
|
||||
}
|
||||
|
||||
ResourceManagerImpl ResourceManagerImpl::ms_instance;
|
||||
@@ -395,6 +276,23 @@ namespace PortabilityLayer
|
||||
PortabilityLayer::MemoryManager::GetInstance()->Release(this);
|
||||
}
|
||||
|
||||
THandle<void> ResourceArchive::LoadResource(const ResTypeID &resTypeID, int id)
|
||||
{
|
||||
return GetResource(resTypeID, id, true);
|
||||
}
|
||||
|
||||
bool ResourceArchive::GetResourceSize(const ResTypeID &resTypeID, int id, size_t &outSize)
|
||||
{
|
||||
THandle<void> hdl = GetResource(resTypeID, id, false);
|
||||
if (const PortabilityLayer::MMHandleBlock *hdlBlock = hdl.MMBlock())
|
||||
{
|
||||
outSize = hdlBlock->m_rmSelfRef->m_size;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
THandle<void> ResourceArchive::GetResource(const ResTypeID &resTypeID, int id, bool load)
|
||||
{
|
||||
const char *extension = ".bin";
|
||||
|
@@ -9,46 +9,6 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
struct PLOpenedResFile
|
||||
{
|
||||
bool m_isOpen;
|
||||
};
|
||||
|
||||
static const unsigned int kPLMaxOpenedResFiles = 64;
|
||||
static PLOpenedResFile gs_resFiles[kPLMaxOpenedResFiles];
|
||||
|
||||
short CurResFile()
|
||||
{
|
||||
return PortabilityLayer::ResourceManager::GetInstance()->GetCurrentResFile();
|
||||
}
|
||||
|
||||
void UseResFile(short fid)
|
||||
{
|
||||
PortabilityLayer::ResourceManager::GetInstance()->SetCurrentResFile(fid);
|
||||
}
|
||||
|
||||
Handle Get1Resource(UInt32 resID, int index)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Handle Get1IndResource(UInt32 resID, int index)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int Count1Resources(UInt32 resType)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SetResLoad(Boolean load)
|
||||
{
|
||||
PortabilityLayer::ResourceManager::GetInstance()->SetResLoad(load != 0);
|
||||
}
|
||||
|
||||
long GetMaxResourceSize(Handle res)
|
||||
{
|
||||
@@ -56,9 +16,3 @@ long GetMaxResourceSize(Handle res)
|
||||
const PortabilityLayer::ResourceArchiveRef *resRef = hBlock->m_rmSelfRef;
|
||||
return resRef->m_size;
|
||||
}
|
||||
|
||||
short HOpenResFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &name, int permissions)
|
||||
{
|
||||
PL_NotYetImplemented();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,24 +1,8 @@
|
||||
#pragma once
|
||||
#ifndef __PL_RESOURCES_H__
|
||||
#define __PL_RESOURCES_H__
|
||||
|
||||
#include "PLCore.h"
|
||||
|
||||
|
||||
class PLPasStr;
|
||||
|
||||
short CurResFile();
|
||||
void UseResFile(short fid);
|
||||
Handle Get1Resource(UInt32 resID, int index);
|
||||
Handle Get1IndResource(UInt32 resID, int index);
|
||||
int Count1Resources(UInt32 resType);
|
||||
|
||||
void SetResLoad(Boolean load); // Sets whether resources should be loaded when requested
|
||||
|
||||
long GetMaxResourceSize(Handle res);
|
||||
|
||||
// This should return -1 on error?
|
||||
short HOpenResFile(PortabilityLayer::VirtualDirectory_t dirID, const PLPasStr &name, int permissions);
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -30,12 +30,15 @@ namespace PortabilityLayer
|
||||
static ResourceArchive *Create(ZipFileProxy *zipFileProxy, IOStream *stream);
|
||||
void Destroy();
|
||||
|
||||
THandle<void> GetResource(const ResTypeID &resTypeID, int id, bool load);
|
||||
THandle<void> LoadResource(const ResTypeID &resTypeID, int id);
|
||||
bool GetResourceSize(const ResTypeID &resTypeID, int id, size_t &outSize);
|
||||
|
||||
private:
|
||||
ResourceArchive(ZipFileProxy *zipFileProxy, IOStream *stream, ResourceArchiveRef *resourceHandles);
|
||||
~ResourceArchive();
|
||||
|
||||
THandle<void> GetResource(const ResTypeID &resTypeID, int id, bool load);
|
||||
|
||||
ZipFileProxy *m_zipFileProxy;
|
||||
IOStream *m_stream;
|
||||
ResourceArchiveRef *m_resourceHandles;
|
||||
@@ -47,18 +50,12 @@ namespace PortabilityLayer
|
||||
virtual void Init() = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
virtual void SetResLoad(bool load) = 0;
|
||||
virtual THandle<void> GetAppResource(const ResTypeID &resTypeID, int16_t resID) const = 0;
|
||||
virtual ResourceArchive *GetAppResourceArchive() const = 0;
|
||||
|
||||
virtual ResourceArchive *LoadResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) const = 0;
|
||||
virtual short OpenResFork(VirtualDirectory_t virtualDir, const PLPasStr &filename) = 0;
|
||||
virtual void CloseResFile(short ref) = 0;
|
||||
virtual PLError_t CreateBlankResFile(VirtualDirectory_t virtualDir, const PLPasStr &filename) = 0;
|
||||
|
||||
virtual THandle<void> GetResource(const ResTypeID &resType, int id) = 0;
|
||||
|
||||
virtual short GetCurrentResFile() const = 0;
|
||||
virtual void SetCurrentResFile(short ref) = 0;
|
||||
|
||||
virtual void DissociateHandle(MMHandleBlock *hdl) const = 0;
|
||||
virtual const ResourceArchiveRef *ResourceForHandle(MMHandleBlock *hdl) const = 0;
|
||||
|
||||
|
@@ -19,6 +19,34 @@ namespace PortabilityLayer
|
||||
uint8_t m_titleLength;
|
||||
};
|
||||
|
||||
enum WDefPositionSpecs
|
||||
{
|
||||
kPosSpec_CommonBits = 0x200a,
|
||||
|
||||
kPosSpec_LocationMask = 0x1800,
|
||||
kPosSpec_Location_Center = 0x0800,
|
||||
kPosSpec_Location_AlertPosition = 0x1000,
|
||||
kPosSpec_Location_Stagger = 0x1800,
|
||||
|
||||
kPosSpec_SubsetMask = 0xc000,
|
||||
kPosSpec_Subset_MainScreen = 0x0000,
|
||||
kPosSpec_Subset_ParentWindow = 0x8000,
|
||||
kPosSpec_Subset_ParentWindowsScreen = 0x4000,
|
||||
};
|
||||
|
||||
enum Styles
|
||||
{
|
||||
kStyle_BarResizable = 0,
|
||||
kStyle_Bar = 4,
|
||||
kStyle_BarResizableExpandable = 8,
|
||||
kStyle_BarExpandable = 12,
|
||||
kStyle_Box = 2,
|
||||
kStyle_BoxShadow = 3,
|
||||
kStyle_BarCloseBoxBlack = 16,
|
||||
kStyle_Alert = 1,
|
||||
kStyle_BarNoMinimize = 5,
|
||||
};
|
||||
|
||||
GP_STATIC_ASSERT(sizeof(WindowDefPart1) == 19);
|
||||
|
||||
WindowDefPart1 wdefPart1;
|
||||
@@ -26,8 +54,23 @@ namespace PortabilityLayer
|
||||
if (stream->Read(&wdefPart1, sizeof(wdefPart1)) != sizeof(wdefPart1))
|
||||
return false;
|
||||
|
||||
uint16_t styleFlags = 0;
|
||||
|
||||
switch (static_cast<int>(wdefPart1.m_wdefResID))
|
||||
{
|
||||
case kStyle_Bar:
|
||||
case kStyle_BarNoMinimize:
|
||||
styleFlags = WindowStyleFlags::kTitleBar;
|
||||
break;
|
||||
case kStyle_Box:
|
||||
styleFlags = 0;
|
||||
break;
|
||||
default:
|
||||
return false; // Unsupported window style
|
||||
}
|
||||
|
||||
m_initialRect = wdefPart1.m_initialRect.ToRect();
|
||||
m_wdefResID = wdefPart1.m_wdefResID;
|
||||
m_styleFlags = styleFlags;
|
||||
m_visibilityStatus = wdefPart1.m_visibilityStatus;
|
||||
m_hasCloseBox = wdefPart1.m_hasCloseBox;
|
||||
m_referenceConstant = wdefPart1.m_referenceConstant;
|
||||
@@ -44,11 +87,11 @@ namespace PortabilityLayer
|
||||
return true;
|
||||
}
|
||||
|
||||
WindowDef WindowDef::Create(const Rect &initialRect, int16_t wdefID, bool isVisible, bool hasCloseBox, uint32_t refConstant, uint16_t positionSpec, const PLPasStr &title)
|
||||
WindowDef WindowDef::Create(const Rect &initialRect, uint16_t styleFlags, bool isVisible, bool hasCloseBox, uint32_t refConstant, uint16_t positionSpec, const PLPasStr &title)
|
||||
{
|
||||
WindowDef wdef;
|
||||
wdef.m_initialRect = initialRect;
|
||||
wdef.m_wdefResID = wdefID;
|
||||
wdef.m_styleFlags = styleFlags;
|
||||
wdef.m_visibilityStatus = isVisible ? 1 : 0;
|
||||
wdef.m_hasCloseBox = hasCloseBox ? 1 : 0;
|
||||
wdef.m_referenceConstant = refConstant;
|
||||
|
@@ -9,10 +9,22 @@ namespace PortabilityLayer
|
||||
{
|
||||
class IOStream;
|
||||
|
||||
namespace WindowStyleFlags
|
||||
{
|
||||
enum WindowStyleFlag
|
||||
{
|
||||
kTitleBar = 1,
|
||||
kBorderless = 2,
|
||||
kResizable = 4,
|
||||
kMiniBar = 8,
|
||||
kAlert = 16,
|
||||
};
|
||||
}
|
||||
|
||||
struct WindowDef
|
||||
{
|
||||
Rect m_initialRect;
|
||||
int16_t m_wdefResID;
|
||||
uint16_t m_styleFlags;
|
||||
uint16_t m_visibilityStatus;
|
||||
uint16_t m_hasCloseBox;
|
||||
uint32_t m_referenceConstant;
|
||||
@@ -21,6 +33,6 @@ namespace PortabilityLayer
|
||||
|
||||
bool Deserialize(IOStream *stream);
|
||||
|
||||
static WindowDef Create(const Rect &initialRect, int16_t wdefID, bool isVisible, bool hasCloseBox, uint32_t refConstant, uint16_t positionSpec, const PLPasStr &title);
|
||||
static WindowDef Create(const Rect &initialRect, uint16_t styleFlags, bool isVisible, bool hasCloseBox, uint32_t refConstant, uint16_t positionSpec, const PLPasStr &title);
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user