Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: false
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLoopsOnASingleLine: true
AllowShortBlocksOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: No
BinPackArguments: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: MultiLine
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 0
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IndentCaseLabels: true
IndentGotoLabels: true
IndentPPDirectives: AfterHash
PPIndentWidth: 2
InsertNewlineAtEOF: true
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 10000
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Right
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Latest
TabWidth: 4
UseTab: AlignWithSpaces
BreakInheritanceList: BeforeComma
BreakConstructorInitializers: BeforeComma
SpaceAfterCStyleCast: false
5 changes: 5 additions & 0 deletions Format-Code.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off
set clang_format=%cd%\vendor\clang-format.exe
set directories=(OpenJPOG\Source, OpenJPOG\Include, Toshi\Source, Toshi\Include, Toshi\Plugins\Source, Toshi\Plugins\Include)

for %%P in %directories% do (for %%G in (.cpp, .hpp, .h) do forfiles /p .\%%P\ /s /m *%%G /c "cmd /c %clang_format% -i @path")
103 changes: 51 additions & 52 deletions OpenJPOG/Source/AOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,89 +3,88 @@

TOSHI_NAMESPACE_USING

TPCCHAR AOptions::sm_szOptionsDir = TNULL;
TPCCHAR AOptions::sm_szOptionsName = "Options";
AOptions *AOptions::ms_pSingleton = TNULL;
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;
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;
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()
{
AOptions::Result result = LoadOptions(-1, -1, sm_szOptionsDir, sm_szOptionsName);
return result;
AOptions::Result result = LoadOptions(-1, -1, sm_szOptionsDir, sm_szOptionsName);
return result;
}

AOptions::Result AOptions::LoadOptions(TINT a_int, TINT a_int2, const Toshi::TCString &a_szOptionsDir, const Toshi::TCString &a_szOptionsName)
{
PPropertyReader reader = PPropertyReader();
Toshi::TCString filepath = Toshi::TCString().Format("%s/%s.ini", a_szOptionsDir.GetString(), a_szOptionsName.GetString());
TBOOL res = reader.Open("Options.ini");
if (!res) {
return RESULT_ERROR;
}
PProperties *props = new PProperties();
res = reader.LoadPropertyBlock(*props);
if (!res) {
return RESULT_ERROR;
}
if (m_pUnkProps) {
delete m_pUnkProps;
}
m_pUnkProps = props;
m_pCurProps = props;
return RESULT_OK;
PPropertyReader reader = PPropertyReader();
Toshi::TCString filepath = Toshi::TCString().Format("%s/%s.ini", a_szOptionsDir.GetString(), a_szOptionsName.GetString());
TBOOL res = reader.Open("Options.ini");
if (!res) {
return RESULT_ERROR;
}
PProperties *props = new PProperties();
res = reader.LoadPropertyBlock(*props);
if (!res) {
return RESULT_ERROR;
}
if (m_pUnkProps) {
delete m_pUnkProps;
}
m_pUnkProps = props;
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;
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();
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;
}
// GetShaders
AScreenRes *screenRes = (AScreenRes *)(&a_rSetting + 1);
switch (a_rSetting.m_eOption) {
case OPTION_SCREENRES:
screenRes = &m_oScreenRes;
break;
default:
break;
}
}
18 changes: 9 additions & 9 deletions OpenJPOG/Source/AOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AOptionsLogic
struct AOptionSetting
{
OPTION m_eOption;
TBOOL m_bFetched;
TBOOL m_bFetched;
};

struct AScreenRes
Expand All @@ -23,12 +23,13 @@ class AOptionsLogic
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);
void OptionGet(AOptionSetting &a_rSetting);

private:
static AScreenRes m_oScreenRes;
Expand All @@ -41,7 +42,7 @@ class AOptions

enum Result
{
RESULT_OK = 0,
RESULT_OK = 0,
RESULT_ERROR = 3
};

Expand All @@ -56,15 +57,14 @@ class AOptions
}

private:
static TPCCHAR sm_szOptionsName;
static TPCCHAR sm_szOptionsDir;
static TPCCHAR sm_szOptionsName;
static TPCCHAR sm_szOptionsDir;
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
TINT m_iAutoSaveState; // 0x1C
PProperties *m_pUnkProps; // 0x20
PProperties *m_pCurProps; // 0x24
};

Loading