From a6fdfc02085797110d486a790bbc0ca7778c1061 Mon Sep 17 00:00:00 2001 From: AdventureT Date: Wed, 3 Jan 2024 18:01:47 +0100 Subject: [PATCH] Stuff --- OpenJPOG/Source/ABINKMoviePlayer.h | 71 ---------------- OpenJPOG/Source/AGUIGameHUD.h | 5 -- OpenJPOG/Source/ARootState.cpp | 5 -- OpenJPOG/Source/ARootState.h | 19 ----- OpenJPOG/Source/{ => GUI}/AGUIGameHUD.cpp | 0 OpenJPOG/Source/GUI/AGUIGameHUD.h | 36 ++++++++ OpenJPOG/Source/GUI/AGUISystem.cpp | 7 ++ OpenJPOG/Source/GUI/AGUISystem.h | 9 ++ .../Source/{ => Movie}/ABINKMoviePlayer.cpp | 82 +++++++++++++++++- OpenJPOG/Source/Movie/ABINKMoviePlayer.h | 85 +++++++++++++++++++ OpenJPOG/Source/{ => Movie}/AMoviePlayer.cpp | 0 OpenJPOG/Source/{ => Movie}/AMoviePlayer.h | 2 +- .../Source/States/AFrontEndSplashState.cpp | 31 +++++++ OpenJPOG/Source/States/AFrontEndSplashState.h | 17 ++++ OpenJPOG/Source/States/AFrontEndState.cpp | 32 +++++++ OpenJPOG/Source/States/AFrontEndState.h | 18 ++++ OpenJPOG/Source/States/AGameState.cpp | 5 ++ OpenJPOG/Source/States/AGameState.h | 9 ++ OpenJPOG/Source/States/ARootState.cpp | 75 ++++++++++++++++ OpenJPOG/Source/States/ARootState.h | 43 ++++++++++ OpenJPOG/Source/{ => Tasks}/ADummyTask.cpp | 0 OpenJPOG/Source/{ => Tasks}/ADummyTask.h | 0 .../Source/Tasks/ARootStateController.cpp | 15 ++++ OpenJPOG/Source/Tasks/ARootStateController.h | 22 +++++ OpenJPOG/Source/{ => Tasks}/ARootTask.cpp | 10 +++ OpenJPOG/Source/{ => Tasks}/ARootTask.h | 19 +++-- OpenJPOG/Source/main.cpp | 2 - OpenJPOG/Source/main.h | 4 +- OpenJPOG/premake5.lua | 1 + Toshi/Include/TKernel/TLString.h | 4 + Toshi/Include/TRender/TTextureFactory.h | 2 +- Toshi/Include/TRenderD3D/TTextureFactoryD3D.h | 2 +- Toshi/Source/TRender/TTextureFactory.cpp | 2 +- .../Source/TRenderD3D/TTextureFactoryD3D.cpp | 4 +- 34 files changed, 521 insertions(+), 117 deletions(-) delete mode 100644 OpenJPOG/Source/ABINKMoviePlayer.h delete mode 100644 OpenJPOG/Source/AGUIGameHUD.h delete mode 100644 OpenJPOG/Source/ARootState.cpp delete mode 100644 OpenJPOG/Source/ARootState.h rename OpenJPOG/Source/{ => GUI}/AGUIGameHUD.cpp (100%) create mode 100644 OpenJPOG/Source/GUI/AGUIGameHUD.h create mode 100644 OpenJPOG/Source/GUI/AGUISystem.cpp create mode 100644 OpenJPOG/Source/GUI/AGUISystem.h rename OpenJPOG/Source/{ => Movie}/ABINKMoviePlayer.cpp (71%) create mode 100644 OpenJPOG/Source/Movie/ABINKMoviePlayer.h rename OpenJPOG/Source/{ => Movie}/AMoviePlayer.cpp (100%) rename OpenJPOG/Source/{ => Movie}/AMoviePlayer.h (98%) create mode 100644 OpenJPOG/Source/States/AFrontEndSplashState.cpp create mode 100644 OpenJPOG/Source/States/AFrontEndSplashState.h create mode 100644 OpenJPOG/Source/States/AFrontEndState.cpp create mode 100644 OpenJPOG/Source/States/AFrontEndState.h create mode 100644 OpenJPOG/Source/States/AGameState.cpp create mode 100644 OpenJPOG/Source/States/AGameState.h create mode 100644 OpenJPOG/Source/States/ARootState.cpp create mode 100644 OpenJPOG/Source/States/ARootState.h rename OpenJPOG/Source/{ => Tasks}/ADummyTask.cpp (100%) rename OpenJPOG/Source/{ => Tasks}/ADummyTask.h (100%) create mode 100644 OpenJPOG/Source/Tasks/ARootStateController.cpp create mode 100644 OpenJPOG/Source/Tasks/ARootStateController.h rename OpenJPOG/Source/{ => Tasks}/ARootTask.cpp (77%) rename OpenJPOG/Source/{ => Tasks}/ARootTask.h (51%) diff --git a/OpenJPOG/Source/ABINKMoviePlayer.h b/OpenJPOG/Source/ABINKMoviePlayer.h deleted file mode 100644 index 109dcea..0000000 --- a/OpenJPOG/Source/ABINKMoviePlayer.h +++ /dev/null @@ -1,71 +0,0 @@ -#pragma once - -#include "AMoviePlayer.h" -#include -#include "BINK.H" -#include "RAD.H" -#include -#include "TKernel/TMemory.h" - -TOSHI_NAMESPACE_BEGIN - -class ABINKMoviePlayer : public AMoviePlayer -{ -public: - ABINKMoviePlayer(); - - virtual TBOOL InitializeMoviePlayer(); - - virtual TBOOL ShutdownMoviePlayer(); - - virtual TBOOL StartMovie(TPCHAR a_szMovieName, TBOOL a_bUnk1, TPCHAR a_szUnk2, TBOOL a_bUnk3); - - virtual TBOOL Update(TFLOAT a_fDeltaTime); - - virtual TBOOL RenderToTexture(TTextureResource *a_pTexture); - - virtual TBOOL RenderToFrameBuffer(); - virtual TBOOL RenderToFrameBuffer(TPBYTE a_pDest, TINT a_iSourceHeigth, TINT a_iDestHeigth, TINT a_iDestPitch, TINT a_iDestX, INT a_iDestY, INT a_iSrcX, INT a_iSrcY); - - virtual TBOOL InitializeVideoResource(); - virtual TBOOL InitializeAudioResource(); - - virtual TBOOL FreeVideoResource(); - - virtual TBOOL FreeAudioResource() - { - delete m_pDirectSound; - return TTRUE; - } - - void BinkSleep(TINT a_iMicroseconds); - TBOOL RenderToTiles(); - -private: - - static void PTR4* RADLINK RADMEMALLOC(U32 bytes) - { - return tmalloc(bytes, TNULL, -1); - } - - static void RADLINK RADMEMFREE(void PTR4* ptr) - { - tfree(ptr); - } - -private: - TBOOL m_bHasMovieStopped; // 0x210 - TBOOL m_bIsBINKInitialized; // 0x211 - TBOOL m_bDrawingFrame; // 0x213 - TBOOL m_bRenderingTiles; // 0x214 - HBINK m_hBink; // 0x218 - TINT m_iFrameCount; // 0x220 - TINT m_iFrameBufferWidth; // 0x224 - TINT m_iFrameBufferHeight; // 0x228 - TINT m_iWidth; // 0x22C - TINT m_iHeight; // 0x230 - TPBYTE m_pFrameBufferBits; // 0x234 - LPDIRECTSOUND m_pDirectSound; // 0x278 -}; - -TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/OpenJPOG/Source/AGUIGameHUD.h b/OpenJPOG/Source/AGUIGameHUD.h deleted file mode 100644 index 1d80c63..0000000 --- a/OpenJPOG/Source/AGUIGameHUD.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once -class AGUIGameHUD -{ -}; - diff --git a/OpenJPOG/Source/ARootState.cpp b/OpenJPOG/Source/ARootState.cpp deleted file mode 100644 index 7298687..0000000 --- a/OpenJPOG/Source/ARootState.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "ARootState.h" - -TOSHI_NAMESPACE_USING - -IMPLEMENT_DYNCREATE(ARootState, TObject) \ No newline at end of file diff --git a/OpenJPOG/Source/ARootState.h b/OpenJPOG/Source/ARootState.h deleted file mode 100644 index 5541f21..0000000 --- a/OpenJPOG/Source/ARootState.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once -#include "TKernel/TObject.h" -#include "AGUIGameHUD.h" - -class ARootState : public Toshi::TObject -{ - DECLARE_DYNAMIC(ARootState) - - -public: - - AGUIGameHUD& GetHUDState() { return m_oHUDState; } - -private: - ARootState* m_pParent; // 0x4 - ARootState* m_pNext; // 0x8 - AGUIGameHUD m_oHUDState; // 0x10 -}; - diff --git a/OpenJPOG/Source/AGUIGameHUD.cpp b/OpenJPOG/Source/GUI/AGUIGameHUD.cpp similarity index 100% rename from OpenJPOG/Source/AGUIGameHUD.cpp rename to OpenJPOG/Source/GUI/AGUIGameHUD.cpp diff --git a/OpenJPOG/Source/GUI/AGUIGameHUD.h b/OpenJPOG/Source/GUI/AGUIGameHUD.h new file mode 100644 index 0000000..908ee44 --- /dev/null +++ b/OpenJPOG/Source/GUI/AGUIGameHUD.h @@ -0,0 +1,36 @@ +#pragma once + +#include "TKernel/TCString.h" +#include "TKernel/TLString.h" +#include "TKernel/TManagedPointer.h" + +class AGUIGameHUD +{ +public: + + enum HUDComponents + { + + }; + + Toshi::TLString GetHintMessage() + { + return *m_LSHintMessage.m_pObject; + } + + HUDComponents GetHUD() + { + return m_eHUDComponents; + } + + void SetBackgroundMatLib(TPCCHAR a_szBKGMatLib) + { + m_szBKGMatLib = a_szBKGMatLib; + } + +private: + Toshi::TManagedPtr m_LSHintMessage; // 0x4 + HUDComponents m_eHUDComponents; // 0x8 + Toshi::TCString m_szBKGMatLib; // 0x2C +}; + diff --git a/OpenJPOG/Source/GUI/AGUISystem.cpp b/OpenJPOG/Source/GUI/AGUISystem.cpp new file mode 100644 index 0000000..1a7848f --- /dev/null +++ b/OpenJPOG/Source/GUI/AGUISystem.cpp @@ -0,0 +1,7 @@ +#include "AGUISystem.h" +#include "main.h" + +AGUISystem* TOSHI_API AGUISystem::GetGUISystem() +{ + return g_oTheApp.GetRootTask()->GetGUISystem(); +} diff --git a/OpenJPOG/Source/GUI/AGUISystem.h b/OpenJPOG/Source/GUI/AGUISystem.h new file mode 100644 index 0000000..80e7658 --- /dev/null +++ b/OpenJPOG/Source/GUI/AGUISystem.h @@ -0,0 +1,9 @@ +#pragma once +#include "TKernel/TCString.h" + +class AGUISystem +{ +public: + static AGUISystem* TOSHI_API GetGUISystem(); +}; + diff --git a/OpenJPOG/Source/ABINKMoviePlayer.cpp b/OpenJPOG/Source/Movie/ABINKMoviePlayer.cpp similarity index 71% rename from OpenJPOG/Source/ABINKMoviePlayer.cpp rename to OpenJPOG/Source/Movie/ABINKMoviePlayer.cpp index c3aac2c..a8b3194 100644 --- a/OpenJPOG/Source/ABINKMoviePlayer.cpp +++ b/OpenJPOG/Source/Movie/ABINKMoviePlayer.cpp @@ -1,7 +1,6 @@ #include "ABINKMoviePlayer.h" #include "main.h" #include "TKernel/TManagedPointer.h" -#include "TRender/TTextureFactory.h" #include "TRenderD3D/TRenderD3DInterface.h" TOSHI_NAMESPACE_USING @@ -17,6 +16,15 @@ ABINKMoviePlayer::ABINKMoviePlayer() m_iFrameBufferWidth = 0; m_pFrameBufferBits = TNULL; RADSetMemory(RADMEMALLOC, RADMEMFREE); + m_pTextures[0] = TNULL; + m_pTextures[1] = TNULL; + m_pTextures[2] = TNULL; + m_pTextures[3] = TNULL; + m_pTextures[4] = TNULL; + m_pTextures[5] = TNULL; + m_pTextures[6] = TNULL; + m_pTextures[7] = TNULL; + m_iCurrentTextureIndex = 0; SetFrameReady(TFALSE); } @@ -41,10 +49,73 @@ TBOOL ABINKMoviePlayer::ShutdownMoviePlayer() return TFALSE; } -TBOOL ABINKMoviePlayer::StartMovie(TPCHAR a_szMovieName, TBOOL a_bUnk1, TPCHAR a_szUnk2, TBOOL a_bUnk3) +TBOOL ABINKMoviePlayer::StartMovie(TPCHAR a_szMovieName, TBOOL a_bUnk1, TPCHAR a_szUnk2, TBOOL a_bUseLocale) { TManagedPtr renderer = g_oTheApp.GetRootTask()->GetRenderInterface(); + if (a_szMovieName) { + Toshi::TSystem::StringCopy(m_szMovieFileName, a_szMovieName, -1); + } + else { + Toshi::TSystem::MemSet(m_szMovieFileName, 0, sizeof(m_szMovieFileName)); + } + + if (a_szUnk2) { + Toshi::TSystem::StringCopy(m_szMovieName, a_szUnk2, -1); + } + else { + Toshi::TSystem::MemSet(m_szMovieName, 0, sizeof(m_szMovieName)); + } + + TCHAR buffer3[256]; + if (a_bUseLocale) { + SetLocaleInfoA(buffer3); + } + else { + sprintf(buffer3, "Data\\Movies\\%s.bik", m_szMovieFileName); + } + + m_bDrawingFrame = TTRUE; + SetFrameReady(TFALSE); + m_iFrameCount = 0; + + if (m_bDoAudio) { + m_hBink = BinkOpen(buffer3, 0); + } + else { + BinkSetSoundTrack(0, NULL); + m_hBink = BinkOpen(buffer3, BINKSNDTRACK); + } + if (!m_hBink) { + return TFALSE; + } + + InitializeMoviePlayer(); + m_iWidth = m_hBink->Width; + m_iHeight = m_hBink->Height; + + TTextureResource* pTexture = GetCurrentTexture(); + if (!pTexture) { + TTextureFactory* pTextureFactory = (TTextureFactory*)renderer->GetSystemResource(TRenderInterface::SYSRESOURCE_TEXTUREFACTORY); + TPVOID pData = tmalloc(0x200000, TNULL, -1); + TSystem::MemSet(pData, 0xFF, 0x200000); + pTexture = pTextureFactory->CreateEx(pData, 0x200000, 1024, 512, 1, TTEXTURERESOURCEFORMAT::R8G8B8A8, 32); + if (pTexture) { + pTexture->Validate(); + m_iFrameBufferWidth = 1024; + m_iFrameBufferHeight = 512; + SetCurrentTexture(pTexture); + } + tfree(pData); + } + + if (!m_bDoAudio) { + BinkSetSoundOnOff(m_hBink, 0); + } + RenderMovie(TTRUE); + m_bHasMovieStopped = TFALSE; + return TTRUE; + return TBOOL(); } @@ -164,6 +235,13 @@ TBOOL ABINKMoviePlayer::FreeVideoResource() return TTRUE; } +void ABINKMoviePlayer::SetLocaleInfoA(TPCHAR a_szBuffer) +{ + //Toshi::TSystem::GetCStringPool(); + //Toshi::TSystem::GetLocale(); + sprintf(a_szBuffer, "Data\\Movies\\%s.bik", m_szMovieFileName); +} + void ABINKMoviePlayer::BinkSleep(TINT a_iMicroseconds) { static S32 s_iTotalSleep = 0; diff --git a/OpenJPOG/Source/Movie/ABINKMoviePlayer.h b/OpenJPOG/Source/Movie/ABINKMoviePlayer.h new file mode 100644 index 0000000..4e1f08d --- /dev/null +++ b/OpenJPOG/Source/Movie/ABINKMoviePlayer.h @@ -0,0 +1,85 @@ +#pragma once + +#include "AMoviePlayer.h" +#include +#include "BINK.H" +#include "RAD.H" +#include +#include "TKernel/TMemory.h" +#include "TRender/TTextureFactory.h" + +TOSHI_NAMESPACE_BEGIN + +class ABINKMoviePlayer : public AMoviePlayer +{ +public: + ABINKMoviePlayer(); + + virtual TBOOL InitializeMoviePlayer(); + + virtual TBOOL ShutdownMoviePlayer(); + + virtual TBOOL StartMovie(TPCHAR a_szMovieName, TBOOL a_bUnk1, TPCHAR a_szUnk2, TBOOL a_bUseLocale); + + virtual TBOOL Update(TFLOAT a_fDeltaTime); + + virtual TBOOL RenderToTexture(TTextureResource *a_pTexture); + + virtual TBOOL RenderToFrameBuffer(); + virtual TBOOL RenderToFrameBuffer(TPBYTE a_pDest, TINT a_iSourceHeigth, TINT a_iDestHeigth, TINT a_iDestPitch, TINT a_iDestX, INT a_iDestY, INT a_iSrcX, INT a_iSrcY); + + virtual TBOOL InitializeVideoResource(); + virtual TBOOL InitializeAudioResource(); + + virtual TBOOL FreeVideoResource(); + + virtual TBOOL FreeAudioResource() + { + delete m_pDirectSound; + return TTRUE; + } + virtual void SetLocaleInfoA(TPCHAR a_szBuffer); + virtual TTextureResource* GetTexture() { return m_pTextures[m_iCurrentTextureIndex]; } + + void BinkSleep(TINT a_iMicroseconds); + TBOOL RenderToTiles(); + TTextureResource* GetCurrentTexture() { return m_pTextures[m_iCurrentTextureIndex]; } + void SetCurrentTexture(TTextureResource* a_pTexture) + { + if (!m_pTextures[m_iCurrentTextureIndex]) { + m_pTextures[m_iCurrentTextureIndex] = a_pTexture; + } + } + +private: + + static void PTR4* RADLINK RADMEMALLOC(U32 bytes) + { + return tmalloc(bytes, TNULL, -1); + } + + static void RADLINK RADMEMFREE(void PTR4* ptr) + { + tfree(ptr); + } + +private: + TCHAR m_szMovieFileName[256]; // 0x10 + TCHAR m_szMovieName[256]; // 0x110 + TBOOL m_bHasMovieStopped; // 0x210 + TBOOL m_bIsBINKInitialized; // 0x211 + TBOOL m_bDrawingFrame; // 0x213 + TBOOL m_bRenderingTiles; // 0x214 + HBINK m_hBink; // 0x218 + TINT m_iFrameCount; // 0x220 + TINT m_iFrameBufferWidth; // 0x224 + TINT m_iFrameBufferHeight; // 0x228 + TINT m_iWidth; // 0x22C + TINT m_iHeight; // 0x230 + Toshi::TTextureResource* m_pTextures[8]; // 0x240 + TPBYTE m_pFrameBufferBits; // 0x234 + LPDIRECTSOUND m_pDirectSound; // 0x278 + TINT m_iCurrentTextureIndex; // 0x27C +}; + +TOSHI_NAMESPACE_END \ No newline at end of file diff --git a/OpenJPOG/Source/AMoviePlayer.cpp b/OpenJPOG/Source/Movie/AMoviePlayer.cpp similarity index 100% rename from OpenJPOG/Source/AMoviePlayer.cpp rename to OpenJPOG/Source/Movie/AMoviePlayer.cpp diff --git a/OpenJPOG/Source/AMoviePlayer.h b/OpenJPOG/Source/Movie/AMoviePlayer.h similarity index 98% rename from OpenJPOG/Source/AMoviePlayer.h rename to OpenJPOG/Source/Movie/AMoviePlayer.h index b87aaca..28dfeb7 100644 --- a/OpenJPOG/Source/AMoviePlayer.h +++ b/OpenJPOG/Source/Movie/AMoviePlayer.h @@ -42,7 +42,7 @@ class AMoviePlayer return TFALSE; } - virtual TBOOL StartMovie(TPCHAR a_szMovieName, TBOOL a_bUnk1, TPCHAR a_szUnk2, TBOOL a_bUnk3) + virtual TBOOL StartMovie(TPCHAR a_szMovieName, TBOOL a_bUnk1, TPCHAR a_szUnk2, TBOOL a_bUseLocale) { return TFALSE; } diff --git a/OpenJPOG/Source/States/AFrontEndSplashState.cpp b/OpenJPOG/Source/States/AFrontEndSplashState.cpp new file mode 100644 index 0000000..309406f --- /dev/null +++ b/OpenJPOG/Source/States/AFrontEndSplashState.cpp @@ -0,0 +1,31 @@ +#include "AFrontEndSplashState.h" +#include "GUI/AGUISystem.h" +#include "main.h" + +TOSHI_NAMESPACE_USING + +IMPLEMENT_DYNCREATE(AFrontEndSplashState, ARootState) + +void AFrontEndSplashState::OnActivate() +{ + ARootState::OnActivate(); + AMoviePlayer* pMoviePlayer = g_oTheApp.GetRootTask()->GetMoviePlayer(); + pMoviePlayer->SetDoAudio(TTRUE); + pMoviePlayer->InitializeMoviePlayer(); +} + +TBOOL AFrontEndSplashState::OnUpdate(TFLOAT a_fDeltaTime) +{ + static TBOOL s_StartMovie = TTRUE; + + AMoviePlayer* pMoviePlayer = g_oTheApp.GetRootTask()->GetMoviePlayer(); + + if (s_StartMovie) { + s_StartMovie = TFALSE; + if (pMoviePlayer && !pMoviePlayer->IsMoviePlaying()) { + pMoviePlayer->StartMovie((TPCHAR)"Intro", TFALSE, (TPCHAR)"Intro", TTRUE); + } + } + + return TBOOL(); +} diff --git a/OpenJPOG/Source/States/AFrontEndSplashState.h b/OpenJPOG/Source/States/AFrontEndSplashState.h new file mode 100644 index 0000000..2e956e5 --- /dev/null +++ b/OpenJPOG/Source/States/AFrontEndSplashState.h @@ -0,0 +1,17 @@ +#pragma once + +#include "AFrontEndState.h" + +class AFrontEndSplashState : public AFrontendState +{ + DECLARE_DYNAMIC(AFrontEndSplashState) + +public: + + virtual void OnActivate() override; + virtual TBOOL OnUpdate(TFLOAT a_fDeltaTime) override; + +private: + static inline Toshi::TCString* sm_asLogoScreens = TNULL; +}; + diff --git a/OpenJPOG/Source/States/AFrontEndState.cpp b/OpenJPOG/Source/States/AFrontEndState.cpp new file mode 100644 index 0000000..2298e57 --- /dev/null +++ b/OpenJPOG/Source/States/AFrontEndState.cpp @@ -0,0 +1,32 @@ +#include "AFrontEndState.h" +#include "main.h" +#include "AGameState.h" + +TOSHI_NAMESPACE_USING + +IMPLEMENT_DYNAMIC(AFrontendState, ARootState) + +void AFrontendState::OnInsertion() +{ + ARootState::OnInsertion(); + if (sm_iFERefCount != 0) { + sm_iFERefCount++; + return; + } + g_oTheApp.GetRootTask()->LoadFrontEndController(); + sm_iFERefCount = 1; +} + +void AFrontendState::OnRemoval() +{ + sm_iFERefCount--; + if (sm_iFERefCount == 0) { + g_oTheApp.GetRootTask()->UnloadFrontEndController(); + } + ARootState::OnRemoval(); +} + +TBOOL AFrontendState::ParentAllowed(ARootState& a_rParent) +{ + return !a_rParent.IsA(TGetClass(AGameState)); +} diff --git a/OpenJPOG/Source/States/AFrontEndState.h b/OpenJPOG/Source/States/AFrontEndState.h new file mode 100644 index 0000000..8e16d6f --- /dev/null +++ b/OpenJPOG/Source/States/AFrontEndState.h @@ -0,0 +1,18 @@ +#pragma once + +#include "ARootState.h" + +class AFrontendState : public ARootState +{ + DECLARE_DYNAMIC(AFrontendState) + +public: + virtual ~AFrontendState() = default; + virtual void OnInsertion() override; + virtual void OnRemoval() override; + virtual TBOOL ParentAllowed(ARootState& a_rParent) override; + +protected: + static inline int sm_iFERefCount = 0; +}; + diff --git a/OpenJPOG/Source/States/AGameState.cpp b/OpenJPOG/Source/States/AGameState.cpp new file mode 100644 index 0000000..e81bf10 --- /dev/null +++ b/OpenJPOG/Source/States/AGameState.cpp @@ -0,0 +1,5 @@ +#include "AGameState.h" + +TOSHI_NAMESPACE_USING + +IMPLEMENT_DYNCREATE(AGameState, ARootState) \ No newline at end of file diff --git a/OpenJPOG/Source/States/AGameState.h b/OpenJPOG/Source/States/AGameState.h new file mode 100644 index 0000000..67ad538 --- /dev/null +++ b/OpenJPOG/Source/States/AGameState.h @@ -0,0 +1,9 @@ +#pragma once + +#include "ARootState.h" + +class AGameState : public ARootState +{ + DECLARE_DYNAMIC(AGameState) +}; + diff --git a/OpenJPOG/Source/States/ARootState.cpp b/OpenJPOG/Source/States/ARootState.cpp new file mode 100644 index 0000000..5c4bc46 --- /dev/null +++ b/OpenJPOG/Source/States/ARootState.cpp @@ -0,0 +1,75 @@ +#include "ARootState.h" + +TOSHI_NAMESPACE_USING + +IMPLEMENT_DYNAMIC(ARootState, TObject) + +void ARootState::OnActivate() +{ +} + +void ARootState::OnDeactivate() +{ +} + +void ARootState::TransferControlTemporary(ARootState* a_pState) +{ + m_pChild = a_pState; + a_pState->m_bHasControl = TTRUE; + m_pChild->m_pParent = this; + m_pChild->OnInsertion(); + m_pChild->OnActivate(); +} + +void ARootState::TransferControl(ARootState* a_pState) +{ +} + +void ARootState::RemoveSelf() +{ +} + +ARootState* ARootState::ReturnToState(const TClass& a_rStateClass) +{ + ARootState* pCurrent; + for (pCurrent = m_pParent; !pCurrent->IsA(a_rStateClass); pCurrent = pCurrent->m_pParent); + pCurrent->RemoveChild(); + return pCurrent; +} + +ARootState* ARootState::ReturnToExactState(const Toshi::TClass& a_rStateClass) +{ + ARootState* pCurrent; + for (pCurrent = m_pParent; !pCurrent->IsExactly(a_rStateClass); pCurrent = pCurrent->m_pParent); + pCurrent->RemoveChild(); + return pCurrent; +} + +TBOOL ARootState::AddChild(ARootState& a_rState) +{ + if (m_pChild) { + return TFALSE; + } + OnDeactivate(); + m_pChild = &a_rState; + m_pParent = this; + m_pChild->OnInsertion(); + m_pChild->OnActivate(); + return TTRUE; +} + +TBOOL ARootState::RemoveChild() +{ + return TBOOL(); +} + +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; +} diff --git a/OpenJPOG/Source/States/ARootState.h b/OpenJPOG/Source/States/ARootState.h new file mode 100644 index 0000000..11aa860 --- /dev/null +++ b/OpenJPOG/Source/States/ARootState.h @@ -0,0 +1,43 @@ +#pragma once +#include "TKernel/TObject.h" +#include "GUI/AGUIGameHUD.h" + +class ARootState : public Toshi::TObject +{ + DECLARE_DYNAMIC(ARootState) + + +public: + + virtual ~ARootState() = default; + //virtual void ProcessControllerLoss(); + //virtual void ProcessLostInput(); + //virtual void ProcessInput(); + //virtual void ProcessCommand(); + virtual TBOOL OnUpdate(TFLOAT a_fDeltaTime) { return TTRUE; } + virtual void OnInsertion() {}; + virtual void OnRemoval() {}; + virtual void OnActivate(); + virtual void OnDeactivate(); + virtual void Render() {}; + virtual void TransferControlTemporary(ARootState* a_pState); + virtual void TransferControl(ARootState* a_pState); + virtual void RemoveSelf(); + virtual ARootState* ReturnToState(const Toshi::TClass& a_rStateClass); + virtual ARootState* ReturnToExactState(const Toshi::TClass& a_rStateClass); + virtual TBOOL ParentAllowed(ARootState& a_rParent) { return TTRUE; } + virtual void FlushUnitProxy() {}; + + TBOOL AddChild(ARootState& a_rState); + TBOOL RemoveChild(); + ARootState& GetCurrent(); + + AGUIGameHUD& GetHUDState() { return m_oHUDState; } + +private: + ARootState* m_pParent; // 0x4 + ARootState* m_pChild; // 0x8 + TBOOL m_bHasControl; // 0xE + AGUIGameHUD m_oHUDState; // 0x10 +}; + diff --git a/OpenJPOG/Source/ADummyTask.cpp b/OpenJPOG/Source/Tasks/ADummyTask.cpp similarity index 100% rename from OpenJPOG/Source/ADummyTask.cpp rename to OpenJPOG/Source/Tasks/ADummyTask.cpp diff --git a/OpenJPOG/Source/ADummyTask.h b/OpenJPOG/Source/Tasks/ADummyTask.h similarity index 100% rename from OpenJPOG/Source/ADummyTask.h rename to OpenJPOG/Source/Tasks/ADummyTask.h diff --git a/OpenJPOG/Source/Tasks/ARootStateController.cpp b/OpenJPOG/Source/Tasks/ARootStateController.cpp new file mode 100644 index 0000000..ed75cd0 --- /dev/null +++ b/OpenJPOG/Source/Tasks/ARootStateController.cpp @@ -0,0 +1,15 @@ +#include "ARootStateController.h" + +TOSHI_NAMESPACE_USING + +IMPLEMENT_DYNCREATE(ARootStateController, TTask); + +ARootStateController::ARootStateController() +{ + s_pCurrentStateController = this; + m_pBaseAppState = TNULL; +} + +void ARootStateController::TransferController(ARootState* a_pState) +{ +} diff --git a/OpenJPOG/Source/Tasks/ARootStateController.h b/OpenJPOG/Source/Tasks/ARootStateController.h new file mode 100644 index 0000000..2ed78e2 --- /dev/null +++ b/OpenJPOG/Source/Tasks/ARootStateController.h @@ -0,0 +1,22 @@ +#pragma once + +#include "TKernel/TTask.h" +#include "States/ARootState.h" + +class ARootStateController : public Toshi::TTask +{ + DECLARE_DYNAMIC(ARootTask); + +public: + ARootStateController(); + + void TransferController(ARootState* a_pState); + +public: + ARootState* GetBaseAppState() { return m_pBaseAppState; } + +private: + ARootState* m_pBaseAppState; // 0x24 +}; + +static inline ARootStateController* s_pCurrentStateController = TNULL; diff --git a/OpenJPOG/Source/ARootTask.cpp b/OpenJPOG/Source/Tasks/ARootTask.cpp similarity index 77% rename from OpenJPOG/Source/ARootTask.cpp rename to OpenJPOG/Source/Tasks/ARootTask.cpp index a9eb67d..74d4db7 100644 --- a/OpenJPOG/Source/ARootTask.cpp +++ b/OpenJPOG/Source/Tasks/ARootTask.cpp @@ -1,5 +1,7 @@ #include "ARootTask.h" +#include "Movie/ABINKMoviePlayer.h" #include "main.h" +#include "States/AFrontEndSplashState.h" TOSHI_NAMESPACE_USING @@ -16,6 +18,14 @@ TBOOL ARootTask::OnCreate() return TTask::OnCreate(); } +void ARootTask::LoadFrontEndController() +{ +} + +void ARootTask::UnloadFrontEndController() +{ +} + void ARootTask::AllocateInputSystem() { TScheduler* pScheduler = g_oTheApp.GetKernel()->GetScheduler(); diff --git a/OpenJPOG/Source/ARootTask.h b/OpenJPOG/Source/Tasks/ARootTask.h similarity index 51% rename from OpenJPOG/Source/ARootTask.h rename to OpenJPOG/Source/Tasks/ARootTask.h index 04d0bd6..c59f239 100644 --- a/OpenJPOG/Source/ARootTask.h +++ b/OpenJPOG/Source/Tasks/ARootTask.h @@ -3,9 +3,11 @@ #include "TKernel/TTask.h" #include "TKernel/TCString.h" #include "AVibrationManager.h" -#include "ABINKMoviePlayer.h" +#include "Movie/AMoviePlayer.h" #include "TRender/TRenderInterface.h" #include "TKernel/TManagedPointer.h" +#include "GUI/AGUISystem.h" +#include "ARootStateController.h" class ARootTask : public Toshi::TTask { @@ -17,20 +19,27 @@ class ARootTask : public Toshi::TTask virtual TBOOL OnCreate() override; virtual TBOOL OnUpdate(TFLOAT a_fDeltaTime) override { return TTRUE; } + void LoadFrontEndController(); + void UnloadFrontEndController(); + void SetName(TPCHAR a_szName) { m_szName = a_szName; } Toshi::TManagedPtr GetRenderInterface() { return m_pRenderInterface; } + AGUISystem* GetGUISystem() { return m_pGUISystem; } + Toshi::AMoviePlayer* GetMoviePlayer() { return m_pMoviePlayer; } private: void AllocateInputSystem(); private: Toshi::TCString m_szName; - Toshi::TTask* m_pInputTask; // 0x38 - Toshi::TRenderInterface* m_pRenderInterface;// 0xD0 - AVibrationManager* m_pVibrationTask; // 0xE8 - Toshi::ABINKMoviePlayer* m_pMoviePlayer; // 0xF0 + AGUISystem* m_pGUISystem; // 0x34 + Toshi::TTask* m_pInputTask; // 0x38 + Toshi::TRenderInterface* m_pRenderInterface; // 0xD0 + ARootStateController* m_pGameStateController; // 0xD8 + AVibrationManager* m_pVibrationTask; // 0xE8 + Toshi::AMoviePlayer* m_pMoviePlayer; // 0xF0 }; \ No newline at end of file diff --git a/OpenJPOG/Source/main.cpp b/OpenJPOG/Source/main.cpp index b128ca9..ec481fc 100644 --- a/OpenJPOG/Source/main.cpp +++ b/OpenJPOG/Source/main.cpp @@ -5,8 +5,6 @@ AApplication g_oTheApp; TBOOL AApplication::OnCreate(TINT argc, TPCHAR* const argv) { - Toshi::TResource test; - test.SetName("ff"); m_pInputTask = (ADummyTask*)g_oTheApp.GetKernel()->GetScheduler()->CreateTask(TGetClass(ADummyTask), TNULL); m_pInputTask->Create(); m_pInputTask->Activate(TTRUE); diff --git a/OpenJPOG/Source/main.h b/OpenJPOG/Source/main.h index f9dcb31..dd4fad2 100644 --- a/OpenJPOG/Source/main.h +++ b/OpenJPOG/Source/main.h @@ -1,8 +1,8 @@ #pragma once #include "TApplication/TApplication.h" #include "TKernel/TMemory.h" -#include "ADummyTask.h" -#include "ARootTask.h" +#include "Tasks/ADummyTask.h" +#include "Tasks/ARootTask.h" class AApplication : public Toshi::TApplication { diff --git a/OpenJPOG/premake5.lua b/OpenJPOG/premake5.lua index b2b23f4..1d9200b 100644 --- a/OpenJPOG/premake5.lua +++ b/OpenJPOG/premake5.lua @@ -32,6 +32,7 @@ project ("OpenJPOG") includedirs { "%{wks.location}/Toshi/Include", + "Source", "%{IncludeDir.fmod}", "%{IncludeDir.bink}" } diff --git a/Toshi/Include/TKernel/TLString.h b/Toshi/Include/TKernel/TLString.h index 020f96e..afb795b 100644 --- a/Toshi/Include/TKernel/TLString.h +++ b/Toshi/Include/TKernel/TLString.h @@ -5,6 +5,10 @@ TOSHI_NAMESPACE_BEGIN +class TKERNELINTERFACE_EXPORTS TLString +{ +}; + class TKERNELINTERFACE_EXPORTS TLocale { public: diff --git a/Toshi/Include/TRender/TTextureFactory.h b/Toshi/Include/TRender/TTextureFactory.h index e80bbbc..0379616 100644 --- a/Toshi/Include/TRender/TTextureFactory.h +++ b/Toshi/Include/TRender/TTextureFactory.h @@ -61,7 +61,7 @@ class TRENDERINTERFACE_EXPORTS TTextureFactory : public TResource virtual TTextureResource* CreateTextureFromFile(TPCCHAR a_szFileName, TUINT a_eTextureFlags) = 0; virtual TTextureResource* CreateTextureFromMemory(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiMipLevels) = 0; - virtual TTextureResource* CreateEx(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiMipLevels, TTEXTURERESOURCEFORMAT a_eFormat, TUINT a_bNoMipLevels) = 0; + virtual TTextureResource* CreateEx(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiMipLevels, TTEXTURERESOURCEFORMAT a_eFormat, TUINT a_uiFormatBits) = 0; static TTextureFactory* TOSHI_API CreateHAL(TRenderInterface* a_pRenderer, TPCCHAR a_szName, TResource* a_pResource); diff --git a/Toshi/Include/TRenderD3D/TTextureFactoryD3D.h b/Toshi/Include/TRenderD3D/TTextureFactoryD3D.h index eb84bc5..8bc4da2 100644 --- a/Toshi/Include/TRenderD3D/TTextureFactoryD3D.h +++ b/Toshi/Include/TRenderD3D/TTextureFactoryD3D.h @@ -13,7 +13,7 @@ class TRENDERINTERFACED3D_EXPORTS TTextureFactoryHAL : public TTextureFactory virtual TTextureResource* CreateTextureFromFile(TPCCHAR a_szFileName, TUINT a_eTextureFlags) override; virtual TTextureResource* CreateTextureFromMemory(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiMipLevels) override; - virtual TTextureResource* CreateEx(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiMipLevels, TTEXTURERESOURCEFORMAT a_eFormat, TUINT a_bNoMipLevels) override; + virtual TTextureResource* CreateEx(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiMipLevels, TTEXTURERESOURCEFORMAT a_eFormat, TUINT a_uiFormatBits) override; }; diff --git a/Toshi/Source/TRender/TTextureFactory.cpp b/Toshi/Source/TRender/TTextureFactory.cpp index c58005b..4bb760c 100644 --- a/Toshi/Source/TRender/TTextureFactory.cpp +++ b/Toshi/Source/TRender/TTextureFactory.cpp @@ -17,7 +17,7 @@ TTextureResource* TTextureFactory::CreateTextureFromMemory(TPVOID a_pData, TUINT return TNULL; } -TTextureResource* TTextureFactory::CreateEx(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiMipLevels, TTEXTURERESOURCEFORMAT a_eFormat, TUINT a_bNoMipLevels) +TTextureResource* TTextureFactory::CreateEx(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiMipLevels, TTEXTURERESOURCEFORMAT a_eFormat, TUINT a_uiFormatBits) { return TNULL; } diff --git a/Toshi/Source/TRenderD3D/TTextureFactoryD3D.cpp b/Toshi/Source/TRenderD3D/TTextureFactoryD3D.cpp index 14e39a6..d509731 100644 --- a/Toshi/Source/TRenderD3D/TTextureFactoryD3D.cpp +++ b/Toshi/Source/TRenderD3D/TTextureFactoryD3D.cpp @@ -55,7 +55,7 @@ TTextureResource* TTextureFactoryHAL::CreateTextureFromMemory(TPVOID a_pData, TU return pTexture; } -TTextureResource* TTextureFactoryHAL::CreateEx(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiMipLevels, TTEXTURERESOURCEFORMAT a_eFormat, TUINT a_bNoMipLevels) +TTextureResource* TTextureFactoryHAL::CreateEx(TPVOID a_pData, TUINT a_uiDataSize, TUINT a_uiWidth, TUINT a_uiHeight, TUINT a_uiMipLevels, TTEXTURERESOURCEFORMAT a_eFormat, TUINT a_uiFormatBits) { static TUINT s_iNumMemTextures = 0; static char s_szName[32]; @@ -76,7 +76,7 @@ TTextureResource* TTextureFactoryHAL::CreateEx(TPVOID a_pData, TUINT a_uiDataSiz ) ); - pTexture->CreateEx(a_pData, a_uiDataSize, a_uiWidth, a_uiHeight, a_uiMipLevels, a_eFormat, a_bNoMipLevels); + pTexture->CreateEx(a_pData, a_uiDataSize, a_uiWidth, a_uiHeight, a_uiMipLevels, a_eFormat, a_uiFormatBits); RegisterTexture(s_szName, pTexture); return pTexture;