From 546f01cbfe2f1d7ed7f3e69f967ad84c10e7b10b Mon Sep 17 00:00:00 2001 From: Nicholas Estelami Date: Sat, 29 Apr 2023 21:19:27 -0400 Subject: Added setting for ZBackground screen width/height (#278) --- ZAPD/Declaration.h | 2 +- ZAPD/GameConfig.cpp | 1 + ZAPD/GameConfig.h | 1 + ZAPD/ZBackground.cpp | 9 +++++++-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ZAPD/Declaration.h b/ZAPD/Declaration.h index 4a743b5..c2fe410 100644 --- a/ZAPD/Declaration.h +++ b/ZAPD/Declaration.h @@ -42,7 +42,7 @@ public: bool isArray = false; bool forceArrayCnt = false; size_t arrayItemCnt = 0; - std::string arrayItemCntStr = ""; + std::string arrayItemCntStr = ""; // Can be used to put a specific string inside an array declaration's brackets std::vector references; bool isUnaccounted = false; bool isPlaceholder = false; diff --git a/ZAPD/GameConfig.cpp b/ZAPD/GameConfig.cpp index 777cf9d..b27e816 100644 --- a/ZAPD/GameConfig.cpp +++ b/ZAPD/GameConfig.cpp @@ -124,6 +124,7 @@ void GameConfig::ConfigFunc_BGConfig(const tinyxml2::XMLElement& element) { bgScreenWidth = element.IntAttribute("ScreenWidth", 320); bgScreenHeight = element.IntAttribute("ScreenHeight", 240); + useScreenWidthHeightConstants = element.BoolAttribute("UseScreenWidthHeightConstants", true); } void GameConfig::ConfigFunc_ExternalXMLFolder(const tinyxml2::XMLElement& element) diff --git a/ZAPD/GameConfig.h b/ZAPD/GameConfig.h index 2a783d1..25b94cb 100644 --- a/ZAPD/GameConfig.h +++ b/ZAPD/GameConfig.h @@ -37,6 +37,7 @@ public: // ZBackground uint32_t bgScreenWidth = 320, bgScreenHeight = 240; + bool useScreenWidthHeightConstants = true; // If true, ZBackground's will be declared with SCREEN_WIDTH * SCREEN_HEIGHT in the C file // ExternalFile fs::path externalXmlFolder; diff --git a/ZAPD/ZBackground.cpp b/ZAPD/ZBackground.cpp index 0ed1eb7..fc72563 100644 --- a/ZAPD/ZBackground.cpp +++ b/ZAPD/ZBackground.cpp @@ -132,8 +132,13 @@ Declaration* ZBackground::DeclareVar(const std::string& prefix, Declaration* decl = parent->AddDeclarationIncludeArray(rawDataIndex, incStr, GetRawDataSize(), GetSourceTypeName(), auxName, 0); - decl->arrayItemCntStr = "SCREEN_WIDTH * SCREEN_HEIGHT / 4"; - decl->forceArrayCnt = true; + + if (Globals::Instance->cfg.useScreenWidthHeightConstants) + { + decl->arrayItemCntStr = "SCREEN_WIDTH * SCREEN_HEIGHT / 4"; + decl->forceArrayCnt = true; + } + decl->staticConf = staticConf; return decl; } -- cgit v1.2.3