Skip to content

Commit

Permalink
Implemented more PProperty functions to work with AOptions
Browse files Browse the repository at this point in the history
Fix debug build
  • Loading branch information
AdventureT committed Sep 1, 2024
1 parent 643c368 commit d2bb672
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 56 deletions.
59 changes: 59 additions & 0 deletions OpenJPOG/Source/AOptions.cpp
Original file line number Diff line number Diff line change
@@ -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()
{
Expand Down Expand Up @@ -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;
}
}
38 changes: 38 additions & 0 deletions OpenJPOG/Source/AOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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
Expand Down
21 changes: 21 additions & 0 deletions OpenJPOG/Source/Tasks/ARootTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ IMPLEMENT_DYNCREATE(ARootTask, TTask);

ARootTask::ARootTask()
{
m_pOptions = TNULL;
m_pGUISystem = TNULL;
m_pInputTask = TNULL;
m_pRenderInterface = TNULL;
m_pRenderer = TNULL;
m_pGameStateController = TNULL;
m_pVibrationTask = TNULL;
m_pMoviePlayer = TNULL;
m_pOptions = new AOptions();
AllocateARenderer();
AllocateRenderInterface();
AllocateGameStateController();
Expand All @@ -28,6 +30,8 @@ TBOOL ARootTask::OnCreate()
if (!CreateRenderInterface()) {
return TFALSE;
}
m_pOptions->LoadOptions();
DeserialiseOptions();
CreateARenderer();
CreateGameStateController();
GetRootStateController()->TransferControl(new AFrontEndSplashState());
Expand Down Expand Up @@ -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();
Expand Down
33 changes: 28 additions & 5 deletions OpenJPOG/Source/Tasks/ARootTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "ARootStateController.h"
#include "ARenderer.h"
#include "Tasks/AFrontEndController.h"
#include "AOptions.h"

class ARootTask : public Toshi::TTask
{
Expand All @@ -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>!!!
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();
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Toshi/Include/TKernel/TDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions Toshi/Include/TKernel/TSingleton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#pragma once
4 changes: 2 additions & 2 deletions Toshi/Plugins/Source/PPropertyParser/PPropertyReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()");
}
Expand Down Expand Up @@ -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());
}
1 change: 1 addition & 0 deletions Toshi/Source/TKernel/TVector3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "TVector3.h"
24 changes: 9 additions & 15 deletions Toshi/vendor/libogg/libogg.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<Configuration>Release Windows</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Dist Windows|Win32">
<Configuration>Dist Windows</Configuration>
<ProjectConfiguration Include="Final Windows|Win32">
<Configuration>Final Windows</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
Expand All @@ -33,7 +33,7 @@
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Dist Windows|Win32'" Label="Configuration">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Final Windows|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
Expand All @@ -48,7 +48,7 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release Windows|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Dist Windows|Win32'">
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Final Windows|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
Expand All @@ -64,9 +64,9 @@
<TargetName>libogg</TargetName>
<TargetExt>.lib</TargetExt>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Dist Windows|Win32'">
<OutDir>..\..\..\bin\Dist_Windows_x86\libogg\</OutDir>
<IntDir>..\..\..\bin-int\Dist_Windows_x86\libogg\</IntDir>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Final Windows|Win32'">
<OutDir>..\..\..\bin\Final_Windows_x86\libogg\</OutDir>
<IntDir>..\..\..\bin-int\Final_Windows_x86\libogg\</IntDir>
<TargetName>libogg</TargetName>
<TargetExt>.lib</TargetExt>
</PropertyGroup>
Expand Down Expand Up @@ -104,23 +104,17 @@
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Dist Windows|Win32'">
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Final Windows|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<AdditionalIncludeDirectories>include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<Optimization>Full</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<MinimalRebuild>false</MinimalRebuild>
<StringPooling>true</StringPooling>
<Optimization>Disabled</Optimization>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
Loading

0 comments on commit d2bb672

Please sign in to comment.