diff --git a/OpenJPOG/Source/States/AFrontEndState.h b/OpenJPOG/Source/States/AFrontEndState.h index 8e16d6f..80837a4 100644 --- a/OpenJPOG/Source/States/AFrontEndState.h +++ b/OpenJPOG/Source/States/AFrontEndState.h @@ -14,5 +14,4 @@ class AFrontendState : public ARootState protected: static inline int sm_iFERefCount = 0; -}; - +}; \ No newline at end of file diff --git a/OpenJPOG/Source/States/ARootState.cpp b/OpenJPOG/Source/States/ARootState.cpp index f9c52d4..a1c4813 100644 --- a/OpenJPOG/Source/States/ARootState.cpp +++ b/OpenJPOG/Source/States/ARootState.cpp @@ -4,6 +4,14 @@ TOSHI_NAMESPACE_USING IMPLEMENT_DYNAMIC(ARootState, TObject) +ARootState::ARootState() +{ + m_pParent = TNULL; + m_pChild = TNULL; + m_bAllowExit = TTRUE; + m_bHasControl = TFALSE; +} + void ARootState::OnActivate() { } @@ -32,7 +40,7 @@ void ARootState::TransferControl(ARootState* a_pState) OnDeactivate(); } else { - ExplicitDelete(); + m_pChild->ExplicitDelete(); } m_pChild = a_pState; a_pState->m_pParent = this; @@ -42,6 +50,15 @@ void ARootState::TransferControl(ARootState* a_pState) void ARootState::RemoveSelf() { + ExplicitDelete(); + if (m_pParent) { + m_pParent->m_pChild = TNULL; + if (!m_bHasControl) { + m_pParent->OnActivate(); + return; + } + TWARNING("Not implemented: AGUIGameHUD::OnActivate(&this->m_pParent->m_oGameHUD);"); + } } ARootState* ARootState::ReturnToState(const TClass& a_rStateClass) @@ -75,32 +92,41 @@ TBOOL ARootState::AddChild(ARootState& a_rState) TBOOL ARootState::RemoveChild() { - return TBOOL(); + if (m_pChild) { + m_pChild = TNULL; + ExplicitDelete(); + if (!m_bHasControl) { + OnActivate(); + } + else { + TWARNING("Not implemented: AGUIGameHUD::OnActivate(&this->m_oGameHUD);"); + } + return TTRUE; + } + return TFALSE; } ARootState& ARootState::GetCurrent() { - ARootState* i; - for (i = this; i->m_pChild != TNULL; i = i->m_pChild) { - if (i->m_pChild == TNULL) { - return *i; - } - } - return *i; + ARootState* current; + for (current = this; current->m_pChild != TNULL; current = current->m_pChild); + return *current; } void ARootState::ExplicitDelete() { - ARootState* i; - for (i = this; i->m_pChild != TNULL; i = i->m_pChild); - i->OnDeactivate(); + ARootState* parent = m_pParent; + + ARootState* current; + for (current = this; current->m_pChild != TNULL; current = current->m_pChild); + current->OnDeactivate(); - for (ARootState* j = i; j != m_pParent; j = j->m_pParent) { + ARootState* j; + while (j = current, j != parent) { + current = j->m_pParent; j->OnRemoval(); j->m_pParent = TNULL; j->m_pChild = TNULL; - if (j) { - delete j; - } + delete j; } } diff --git a/OpenJPOG/Source/States/ARootState.h b/OpenJPOG/Source/States/ARootState.h index a9b13da..1f43531 100644 --- a/OpenJPOG/Source/States/ARootState.h +++ b/OpenJPOG/Source/States/ARootState.h @@ -9,6 +9,8 @@ class ARootState : public Toshi::TObject public: + ARootState(); + virtual ~ARootState() = default; //virtual void ProcessControllerLoss(); //virtual void ProcessLostInput(); @@ -42,6 +44,7 @@ class ARootState : public Toshi::TObject private: ARootState* m_pParent; // 0x4 ARootState* m_pChild; // 0x8 + TBOOL m_bAllowExit; // 0xC TBOOL m_bHasControl; // 0xE AGUIGameHUD m_oHUDState; // 0x10 }; diff --git a/OpenJPOG/Source/Tasks/AFrontEndController.cpp b/OpenJPOG/Source/Tasks/AFrontEndController.cpp new file mode 100644 index 0000000..9cab201 --- /dev/null +++ b/OpenJPOG/Source/Tasks/AFrontEndController.cpp @@ -0,0 +1,3 @@ +#include "AFrontEndController.h" + +IMPLEMENT_DYNCREATE(AFrontEndController, Toshi::TTask) \ No newline at end of file diff --git a/OpenJPOG/Source/Tasks/AFrontEndController.h b/OpenJPOG/Source/Tasks/AFrontEndController.h new file mode 100644 index 0000000..cf5e321 --- /dev/null +++ b/OpenJPOG/Source/Tasks/AFrontEndController.h @@ -0,0 +1,7 @@ +#pragma once +#include "TKernel/TTask.h" + +class AFrontEndController : public Toshi::TTask +{ + DECLARE_DYNAMIC(AFrontEndController) +}; \ No newline at end of file diff --git a/OpenJPOG/Source/Tasks/ARootStateController.cpp b/OpenJPOG/Source/Tasks/ARootStateController.cpp index 6158547..254fdc1 100644 --- a/OpenJPOG/Source/Tasks/ARootStateController.cpp +++ b/OpenJPOG/Source/Tasks/ARootStateController.cpp @@ -21,7 +21,8 @@ TBOOL ARootStateController::OnCreate() TBOOL ARootStateController::OnUpdate(TFLOAT a_fDeltaTime) { if (m_pBaseAppState) { - + ARootState currentState = m_pBaseAppState->GetCurrent(); + currentState.OnUpdate(a_fDeltaTime); } return TTRUE; } diff --git a/OpenJPOG/Source/Tasks/ARootStateController.h b/OpenJPOG/Source/Tasks/ARootStateController.h index 96bbebb..2b1435e 100644 --- a/OpenJPOG/Source/Tasks/ARootStateController.h +++ b/OpenJPOG/Source/Tasks/ARootStateController.h @@ -9,7 +9,7 @@ static inline ARootStateController* s_pCurrentStateController = TNULL; class ARootStateController : public Toshi::TTask { - DECLARE_DYNAMIC(ARootTask); + DECLARE_DYNAMIC(ARootStateController); public: ARootStateController(); diff --git a/OpenJPOG/Source/Tasks/ARootTask.cpp b/OpenJPOG/Source/Tasks/ARootTask.cpp index 7df0ba4..5ceac02 100644 --- a/OpenJPOG/Source/Tasks/ARootTask.cpp +++ b/OpenJPOG/Source/Tasks/ARootTask.cpp @@ -58,6 +58,11 @@ void ARootTask::OnDeactivate() void ARootTask::LoadFrontEndController() { + m_pFrontEndController = (AFrontEndController*)g_oTheApp.GetKernel()->GetScheduler()->CreateTask(TGetClass(AFrontEndController), this); + m_pFrontEndController->Create(); + LoadMaterialLibrary(1); + LoadMaterialLibrary(25); + g_oTheApp.GetKernel()->GetSystemTimer()->Reset(); } void ARootTask::UnloadFrontEndController() @@ -183,3 +188,7 @@ const TRenderAdapter::Mode::Device* ARootTask::CreateDisplayDevice(TRenderInterf return pDevice; } + +void ARootTask::LoadMaterialLibrary(TINT a_iIndex) +{ +} diff --git a/OpenJPOG/Source/Tasks/ARootTask.h b/OpenJPOG/Source/Tasks/ARootTask.h index fb7f47f..03a80f1 100644 --- a/OpenJPOG/Source/Tasks/ARootTask.h +++ b/OpenJPOG/Source/Tasks/ARootTask.h @@ -9,7 +9,7 @@ #include "GUI/AGUISystem.h" #include "ARootStateController.h" #include "ARenderer.h" - +#include "Tasks/AFrontEndController.h" class ARootTask : public Toshi::TTask { @@ -52,8 +52,11 @@ class ARootTask : public Toshi::TTask const Toshi::TRenderAdapter::Mode::Device* CreateDisplayDevice(Toshi::TRenderInterface::DisplayParams& a_rDisplayParams, bool a_bReverseOrder); + void LoadMaterialLibrary(TINT a_iIndex); + private: Toshi::TCString m_szName; + AFrontEndController* m_pFrontEndController; // 0x28 AGUISystem* m_pGUISystem; // 0x34 Toshi::TTask* m_pInputTask; // 0x38 Toshi::TRenderInterface* m_pRenderInterface; // 0xD0 diff --git a/Toshi/Include/TKernel/TDebug.h b/Toshi/Include/TKernel/TDebug.h index c10ce64..7782e75 100644 --- a/Toshi/Include/TKernel/TDebug.h +++ b/Toshi/Include/TKernel/TDebug.h @@ -12,7 +12,7 @@ #define TASSERT(expression) \ TFIREFLAG_CREATE(__LINE__); \ if (!(expression)) { \ - if (TDebug::AssertHandler(const_cast(#expression), const_cast(__FILE__), __LINE__, TFIREFLAG(__LINE__))) { \ + if (Toshi::TDebug::AssertHandler(const_cast(#expression), const_cast(__FILE__), __LINE__, TFIREFLAG(__LINE__))) { \ __debugbreak(); \ } \ } diff --git a/Toshi/Plugins/Include/PPropertyParser/PPropertyReader.h b/Toshi/Plugins/Include/PPropertyParser/PPropertyReader.h new file mode 100644 index 0000000..29bd326 --- /dev/null +++ b/Toshi/Plugins/Include/PPropertyParser/PPropertyReader.h @@ -0,0 +1,27 @@ +#pragma once +#include "TObject.h" +#include "TFile.h" +#include "TFileLexerUTF8.h" + +class PPropertyReader : public Toshi::TObject +{ +public: + PPropertyReader(); + + void Close(); + + void Error(const Toshi::TCString& a_sMsg); + + virtual ~PPropertyReader() { Close(); } + virtual TBOOL Open(const Toshi::TCString& a_rFileName, Toshi::TFile* a_pFile); + virtual TBOOL Open(const Toshi::TCString& a_rFileName); + + void Warning(const Toshi::TCString& a_sMsg); + +private: + Toshi::TCString m_szFileName; // 0x4 + Toshi::TFile* m_pFile; // 0xC + Toshi::TFileLexerUTF8* m_pLexer; // 0x10 + TBOOL m_bLoadComments; // 0x24 + TBOOL m_bAssertOnError; // 0x25 +}; \ No newline at end of file diff --git a/Toshi/Plugins/Source/PPropertyParser/PPropertyReader.cpp b/Toshi/Plugins/Source/PPropertyParser/PPropertyReader.cpp new file mode 100644 index 0000000..0b0f0ae --- /dev/null +++ b/Toshi/Plugins/Source/PPropertyParser/PPropertyReader.cpp @@ -0,0 +1,57 @@ +#include "PPropertyParser/PPropertyReader.h" + +PPropertyReader::PPropertyReader() +{ + m_pFile = TNULL; + m_pLexer = TNULL; + m_bLoadComments = TFALSE; + m_bAssertOnError = TTRUE; +} + +void PPropertyReader::Close() +{ + if (m_pFile) { + m_pFile->Destroy(); + m_pFile = TNULL; + } + if (m_pLexer) { + delete m_pLexer; + m_pLexer = TNULL; + } +} + +void PPropertyReader::Error(const Toshi::TCString& a_sMsg) +{ + TDPRINTF("%s : error: %s\n", m_szFileName, a_sMsg); + if (m_bAssertOnError) { + TASSERT(!"PPropertyReader::Error()"); + } +} + +TBOOL PPropertyReader::Open(const Toshi::TCString& a_rFileName, Toshi::TFile* a_pFile) +{ + m_szFileName = a_rFileName; + Close(); + m_pFile = a_pFile; + m_pLexer = new Toshi::TFileLexerUTF8(m_pFile, 2); + m_pLexer->SetOutputComments(m_bLoadComments); +} + +TBOOL PPropertyReader::Open(const Toshi::TCString& a_rFileName) +{ + m_szFileName = a_rFileName; + Close(); + m_pFile = Toshi::TFile::Create(m_szFileName, Toshi::TMODE_READONLY); + if (!m_pFile) { + Warning("Can't open file"); + return TFALSE; + } + m_pLexer = new Toshi::TFileLexerUTF8(m_pFile, 2); + m_pLexer->SetOutputComments(m_bLoadComments); + return TTRUE; +} + +void PPropertyReader::Warning(const Toshi::TCString& a_sMsg) +{ + TDPRINTF("%s : warning: %s\n", m_szFileName, a_sMsg); +} \ No newline at end of file