From d2bb672e732fd6a9d77fa30e1a81bf67c11dd625 Mon Sep 17 00:00:00 2001 From: AdventureT Date: Sun, 1 Sep 2024 18:32:29 +0200 Subject: [PATCH] Implemented more PProperty functions to work with AOptions Fix debug build --- OpenJPOG/Source/AOptions.cpp | 59 +++++++++++++++++++ OpenJPOG/Source/AOptions.h | 38 ++++++++++++ OpenJPOG/Source/Tasks/ARootTask.cpp | 21 +++++++ OpenJPOG/Source/Tasks/ARootTask.h | 33 +++++++++-- Toshi/Include/TKernel/TDebug.h | 8 +-- Toshi/Include/TKernel/TSingleton.h | 1 + .../PPropertyParser/PPropertyReader.cpp | 4 +- Toshi/Source/TKernel/TVector3.cpp | 1 + Toshi/vendor/libogg/libogg.vcxproj | 24 +++----- Toshi/vendor/libtheora/libtheora.vcxproj | 24 +++----- Toshi/vendor/libvorbis/libvorbis.vcxproj | 24 +++----- 11 files changed, 181 insertions(+), 56 deletions(-) create mode 100644 Toshi/Include/TKernel/TSingleton.h create mode 100644 Toshi/Source/TKernel/TVector3.cpp diff --git a/OpenJPOG/Source/AOptions.cpp b/OpenJPOG/Source/AOptions.cpp index cb49b7a..ad66807 100644 --- a/OpenJPOG/Source/AOptions.cpp +++ b/OpenJPOG/Source/AOptions.cpp @@ -1,8 +1,33 @@ #include "AOptions.h" #include "PPropertyParser/PPropertyReader.h" +TOSHI_NAMESPACE_USING + TPCCHAR AOptions::sm_szOptionsDir = TNULL; TPCCHAR AOptions::sm_szOptionsName = "Options"; +AOptions *AOptions::ms_pSingleton = TNULL; + +AOptions::AOptions() +{ + m_iAutoSaveState = 1; + ms_pSingleton = this; + PProperties *props = new PProperties(); + m_pUnkProps = props; + m_pCurProps = props; +} + +TBOOL AOptions::GetOption(TPCCHAR a_szProp, TINT &a_iValue) +{ + const PPropertyValue *value = m_pCurProps->GetProperty(TSystem::GetCStringPool()->Get(a_szProp)); + if (!value) { + return TFALSE; + } + if (!value->CanBeType(PPropertyValue::TYPE_INT)) { + return TFALSE; + } + a_iValue = value->GetInteger(); + return TTRUE; +} AOptions::Result AOptions::LoadOptions() { @@ -30,3 +55,37 @@ AOptions::Result AOptions::LoadOptions(TINT a_int, TINT a_int2, const Toshi::TCS m_pCurProps = props; return RESULT_OK; } + +AOptionsLogic::AScreenRes AOptionsLogic::m_oScreenRes = AOptionsLogic::AScreenRes(640, 480, 32, 0); + +AOptionsLogic::AOptionsLogic() +{ + +} + +TBOOL AOptionsLogic::GetOption(OPTION a_eOption, AScreenRes &a_rScreenRes) +{ + AOptionSetting setting; + setting.m_eOption = a_eOption; + OptionGet(setting); + a_rScreenRes = *(AScreenRes *)(&setting + 1); + return setting.m_bFetched; +} + +TBOOL AOptionsLogic::SetOption(OPTION a_eOption, AScreenRes &a_rScreenRes) +{ + return TBOOL(); +} + +void AOptionsLogic::OptionGet(AOptionSetting &a_rSetting) +{ + // GetShaders + AScreenRes *screenRes = (AScreenRes *)(&a_rSetting + 1); + switch (a_rSetting.m_eOption) { + case OPTION_SCREENRES: + screenRes = &m_oScreenRes; + break; + default: + break; + } +} diff --git a/OpenJPOG/Source/AOptions.h b/OpenJPOG/Source/AOptions.h index 474c783..ebe3223 100644 --- a/OpenJPOG/Source/AOptions.h +++ b/OpenJPOG/Source/AOptions.h @@ -2,15 +2,51 @@ #include "Toshi/Defines.h" #include "PPropertyParser/PProperties.h" +class AOptionsLogic +{ +public: + enum OPTION + { + OPTION_SCREENRES + }; + + struct AOptionSetting + { + OPTION m_eOption; + TBOOL m_bFetched; + }; + + struct AScreenRes + { + TINT m_iScreenWidth; + TINT m_iScreenHeight; + TINT m_iScreenDepth; + TINT m_iScreenUnk; + }; +public: + AOptionsLogic(); + + TBOOL GetOption(OPTION a_eOption, AScreenRes &a_rScreenRes); + TBOOL SetOption(OPTION a_eOption, AScreenRes &a_rScreenRes); + void OptionGet(AOptionSetting &a_rSetting); + +private: + static AScreenRes m_oScreenRes; +}; + class AOptions { public: + AOptions(); + enum Result { RESULT_OK = 0, RESULT_ERROR = 3 }; + TBOOL GetOption(TPCCHAR a_szProp, TINT &a_iValue); + Result LoadOptions(); Result LoadOptions(TINT a_int, TINT a_int2, const Toshi::TCString &a_szOptionsDir, const Toshi::TCString &a_szOptionsName); @@ -25,6 +61,8 @@ class AOptions static const TINT sm_iSlot = -1; static const TINT sm_iPort = -1; + static AOptions *ms_pSingleton; + TINT m_iAutoSaveState; // 0x1C PProperties *m_pUnkProps; // 0x20 PProperties *m_pCurProps; // 0x24 diff --git a/OpenJPOG/Source/Tasks/ARootTask.cpp b/OpenJPOG/Source/Tasks/ARootTask.cpp index 5ceac02..273c771 100644 --- a/OpenJPOG/Source/Tasks/ARootTask.cpp +++ b/OpenJPOG/Source/Tasks/ARootTask.cpp @@ -9,6 +9,7 @@ IMPLEMENT_DYNCREATE(ARootTask, TTask); ARootTask::ARootTask() { + m_pOptions = TNULL; m_pGUISystem = TNULL; m_pInputTask = TNULL; m_pRenderInterface = TNULL; @@ -16,6 +17,7 @@ ARootTask::ARootTask() m_pGameStateController = TNULL; m_pVibrationTask = TNULL; m_pMoviePlayer = TNULL; + m_pOptions = new AOptions(); AllocateARenderer(); AllocateRenderInterface(); AllocateGameStateController(); @@ -28,6 +30,8 @@ TBOOL ARootTask::OnCreate() if (!CreateRenderInterface()) { return TFALSE; } + m_pOptions->LoadOptions(); + DeserialiseOptions(); CreateARenderer(); CreateGameStateController(); GetRootStateController()->TransferControl(new AFrontEndSplashState()); @@ -121,6 +125,23 @@ void ARootTask::CreateGameStateController() GetRootStateController()->Create(); } +void ARootTask::DeserialiseOptions() +{ + TRenderInterface *renderer = g_oTheApp.GetRootTask()->m_pRenderInterface; + renderer->GetCurrentDisplayParams(); + AOptions *options = g_oTheApp.GetRootTask()->GetOptions(); + AOptionsLogic logic; + TINT screenWidth; + TINT screenHeight; + TINT screenDepth; + if (options->GetOption("ScreenWidth", screenWidth) && + options->GetOption("ScreenHeight", screenHeight) && + options->GetOption("ScreenDepth", screenDepth)) { + AOptionsLogic::AScreenRes screenRes; + logic.GetOption(AOptionsLogic::OPTION_SCREENRES, screenRes); + } +} + const TRenderAdapter::Mode::Device* ARootTask::CreateDisplayDevice(TRenderInterface::DisplayParams& a_rDisplayParams, bool a_bReverseOrder) { TRenderInterface* pRenderer = TRenderInterface::GetRenderer(); diff --git a/OpenJPOG/Source/Tasks/ARootTask.h b/OpenJPOG/Source/Tasks/ARootTask.h index 03a80f1..c66b11f 100644 --- a/OpenJPOG/Source/Tasks/ARootTask.h +++ b/OpenJPOG/Source/Tasks/ARootTask.h @@ -10,6 +10,7 @@ #include "ARootStateController.h" #include "ARenderer.h" #include "Tasks/AFrontEndController.h" +#include "AOptions.h" class ARootTask : public Toshi::TTask { @@ -28,17 +29,38 @@ class ARootTask : public Toshi::TTask void LoadFrontEndController(); void UnloadFrontEndController(); + static void DeserialiseOptions(); + void SetName(TPCHAR a_szName) { m_szName = a_szName; } + AOptions *GetOptions() + { + return m_pOptions; + } //Toshi::TManagedPtr!!! - Toshi::TRenderInterface* GetRenderInterface() { return m_pRenderInterface; } - AGUISystem* GetGUISystem() { return m_pGUISystem; } - Toshi::AMoviePlayer* GetMoviePlayer() { return m_pMoviePlayer; } - ARootStateController* GetRootStateController() const { return m_pGameStateController; } - Toshi::ARenderer* GetARenderer() { return m_pRenderer; } + Toshi::TRenderInterface* GetRenderInterface() + { + return m_pRenderInterface; + } + AGUISystem* GetGUISystem() + { + return m_pGUISystem; + } + Toshi::AMoviePlayer* GetMoviePlayer() + { + return m_pMoviePlayer; + } + ARootStateController* GetRootStateController() const + { + return m_pGameStateController; + } + Toshi::ARenderer* GetARenderer() + { + return m_pRenderer; + } private: void AllocateARenderer(); @@ -56,6 +78,7 @@ class ARootTask : public Toshi::TTask private: Toshi::TCString m_szName; + AOptions *m_pOptions; // 0x24 AFrontEndController* m_pFrontEndController; // 0x28 AGUISystem* m_pGUISystem; // 0x34 Toshi::TTask* m_pInputTask; // 0x38 diff --git a/Toshi/Include/TKernel/TDebug.h b/Toshi/Include/TKernel/TDebug.h index 7782e75..2bd8638 100644 --- a/Toshi/Include/TKernel/TDebug.h +++ b/Toshi/Include/TKernel/TDebug.h @@ -17,10 +17,10 @@ } \ } -#define TDPRINTF(format, ...) TDebug_Printf(format, __VA_ARGS__) -#define TWARNING(format, ...) TDebug_PrintWarning(format, __VA_ARGS__) -#define TERROR(format, ...) TDebug_PrintError(format, __VA_ARGS__) -#define TVALIDADDRESS(expression) TASSERT(TDebug::IsValidAddress(expression)) +#define TDPRINTF(format, ...) Toshi::TDebug_Printf(format, __VA_ARGS__) +#define TWARNING(format, ...) Toshi::TDebug_PrintWarning(format, __VA_ARGS__) +#define TERROR(format, ...) Toshi::TDebug_PrintError(format, __VA_ARGS__) +#define TVALIDADDRESS(expression) TASSERT(Toshi::TDebug::IsValidAddress(expression)) TOSHI_NAMESPACE_BEGIN diff --git a/Toshi/Include/TKernel/TSingleton.h b/Toshi/Include/TKernel/TSingleton.h new file mode 100644 index 0000000..6f70f09 --- /dev/null +++ b/Toshi/Include/TKernel/TSingleton.h @@ -0,0 +1 @@ +#pragma once diff --git a/Toshi/Plugins/Source/PPropertyParser/PPropertyReader.cpp b/Toshi/Plugins/Source/PPropertyParser/PPropertyReader.cpp index 28a09d4..27d5c34 100644 --- a/Toshi/Plugins/Source/PPropertyParser/PPropertyReader.cpp +++ b/Toshi/Plugins/Source/PPropertyParser/PPropertyReader.cpp @@ -22,7 +22,7 @@ void PPropertyReader::Close() void PPropertyReader::Error(const Toshi::TCString& a_sMsg) { - TDPRINTF("%s : error: %s\n", m_szFileName, a_sMsg); + TDPRINTF("%s : error: %s\n", m_szFileName.GetString(), a_sMsg.GetString()); if (m_bAssertOnError) { TASSERT(!"PPropertyReader::Error()"); } @@ -159,5 +159,5 @@ TBOOL PPropertyReader::Open(const Toshi::TCString& a_rFileName) void PPropertyReader::Warning(const Toshi::TCString& a_sMsg) { - TDPRINTF("%s : warning: %s\n", m_szFileName, a_sMsg); + TDPRINTF("%s : warning: %s\n", m_szFileName.GetString(), a_sMsg.GetString()); } diff --git a/Toshi/Source/TKernel/TVector3.cpp b/Toshi/Source/TKernel/TVector3.cpp new file mode 100644 index 0000000..9b28616 --- /dev/null +++ b/Toshi/Source/TKernel/TVector3.cpp @@ -0,0 +1 @@ +#include "TVector3.h" \ No newline at end of file diff --git a/Toshi/vendor/libogg/libogg.vcxproj b/Toshi/vendor/libogg/libogg.vcxproj index 580aeff..7e31a84 100644 --- a/Toshi/vendor/libogg/libogg.vcxproj +++ b/Toshi/vendor/libogg/libogg.vcxproj @@ -9,8 +9,8 @@ Release Windows Win32 - - Dist Windows + + Final Windows Win32 @@ -33,7 +33,7 @@ Unicode v143 - + StaticLibrary false Unicode @@ -48,7 +48,7 @@ - + @@ -64,9 +64,9 @@ libogg .lib - - ..\..\..\bin\Dist_Windows_x86\libogg\ - ..\..\..\bin-int\Dist_Windows_x86\libogg\ + + ..\..\..\bin\Final_Windows_x86\libogg\ + ..\..\..\bin-int\Final_Windows_x86\libogg\ libogg .lib @@ -104,23 +104,17 @@ true - + NotUsing Level3 4996;%(DisableSpecificWarnings) include;%(AdditionalIncludeDirectories) - Full - true - true - false - true + Disabled MultiThreaded Windows - true - true diff --git a/Toshi/vendor/libtheora/libtheora.vcxproj b/Toshi/vendor/libtheora/libtheora.vcxproj index 9fc2e54..f4477f5 100644 --- a/Toshi/vendor/libtheora/libtheora.vcxproj +++ b/Toshi/vendor/libtheora/libtheora.vcxproj @@ -9,8 +9,8 @@ Release Windows Win32 - - Dist Windows + + Final Windows Win32 @@ -33,7 +33,7 @@ Unicode v143 - + StaticLibrary false Unicode @@ -48,7 +48,7 @@ - + @@ -64,9 +64,9 @@ libtheora .lib - - ..\..\..\bin\Dist_Windows_x86\libtheora\ - ..\..\..\bin-int\Dist_Windows_x86\libtheora\ + + ..\..\..\bin\Final_Windows_x86\libtheora\ + ..\..\..\bin-int\Final_Windows_x86\libtheora\ libtheora .lib @@ -104,23 +104,17 @@ true - + NotUsing Level3 4996;%(DisableSpecificWarnings) include;..\libogg\include;..\libvorbis\include;%(AdditionalIncludeDirectories) - Full - true - true - false - true + Disabled MultiThreaded Windows - true - true diff --git a/Toshi/vendor/libvorbis/libvorbis.vcxproj b/Toshi/vendor/libvorbis/libvorbis.vcxproj index 2c48c52..a61b0c1 100644 --- a/Toshi/vendor/libvorbis/libvorbis.vcxproj +++ b/Toshi/vendor/libvorbis/libvorbis.vcxproj @@ -9,8 +9,8 @@ Release Windows Win32 - - Dist Windows + + Final Windows Win32 @@ -33,7 +33,7 @@ Unicode v143 - + StaticLibrary false Unicode @@ -48,7 +48,7 @@ - + @@ -64,9 +64,9 @@ libvorbis .lib - - ..\..\..\bin\Dist_Windows_x86\libvorbis\ - ..\..\..\bin-int\Dist_Windows_x86\libvorbis\ + + ..\..\..\bin\Final_Windows_x86\libvorbis\ + ..\..\..\bin-int\Final_Windows_x86\libvorbis\ libvorbis .lib @@ -104,23 +104,17 @@ true - + NotUsing Level3 4996;%(DisableSpecificWarnings) include;..\libogg\include;%(AdditionalIncludeDirectories) - Full - true - true - false - true + Disabled MultiThreaded Windows - true - true