Level editor and resource loader fixups and refactors

This commit is contained in:
elasota
2020-01-23 01:19:12 -05:00
parent 27a1f89c15
commit 5a3cedaa95
43 changed files with 310 additions and 367 deletions

View File

@@ -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;