mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-12 11:12:29 +00:00
chore: initial commit
This commit is contained in:
commit
70b00c5c38
965 changed files with 264882 additions and 0 deletions
25
src/client/CMakeLists.txt
Normal file
25
src/client/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
file(GLOB PRIVATE_SOURCES "*.cpp")
|
||||
|
||||
add_library(client STATIC
|
||||
${PRIVATE_SOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(client
|
||||
PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
)
|
||||
|
||||
target_link_libraries(client
|
||||
PRIVATE
|
||||
async
|
||||
event
|
||||
gx
|
||||
model
|
||||
net
|
||||
ui
|
||||
util
|
||||
world
|
||||
PUBLIC
|
||||
common
|
||||
storm
|
||||
)
|
||||
437
src/client/Client.cpp
Normal file
437
src/client/Client.cpp
Normal file
|
|
@ -0,0 +1,437 @@
|
|||
#include "client/Client.hpp"
|
||||
#include "client/ClientServices.hpp"
|
||||
#include "client/Console.hpp"
|
||||
#include "async/AsyncFile.hpp"
|
||||
#include "glue/CGlueMgr.hpp"
|
||||
#include "gx/Device.hpp"
|
||||
#include "gx/Screen.hpp"
|
||||
#include "gx/Texture.hpp"
|
||||
#include "model/Model2.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
#include "ui/FrameXML.hpp"
|
||||
#include "util/BlizzardCore.hpp"
|
||||
#include "util/CVar.hpp"
|
||||
#include "world/World.hpp"
|
||||
#include <cstring>
|
||||
#include <common/Prop.hpp>
|
||||
#include <storm/Error.hpp>
|
||||
|
||||
CVar* Client::g_accountListVar;
|
||||
HEVENTCONTEXT Client::g_clientEventContext;
|
||||
|
||||
void AsyncFileInitialize() {
|
||||
// TODO
|
||||
AsyncFileReadInitialize(0, 100);
|
||||
}
|
||||
|
||||
void BaseInitializeGlobal() {
|
||||
PropInitialize();
|
||||
}
|
||||
|
||||
void ClientMiscInitialize() {
|
||||
// TODO
|
||||
|
||||
Client::g_accountListVar = CVar::Register(
|
||||
"accountList",
|
||||
"List of wow accounts for saved Blizzard account",
|
||||
0,
|
||||
"",
|
||||
nullptr,
|
||||
4,
|
||||
false,
|
||||
nullptr,
|
||||
false
|
||||
);
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
void ClientPostClose(int32_t a1) {
|
||||
// TODO s_finalDialog = a1;
|
||||
EventPostCloseEx(nullptr);
|
||||
}
|
||||
|
||||
int32_t DestroyEngineCallback(const void* a1, void* a2) {
|
||||
// TODO
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t InitializeEngineCallback(const void* a1, void* a2) {
|
||||
// TODO
|
||||
// sub_4D2A30();
|
||||
|
||||
AsyncFileInitialize();
|
||||
TextureInitialize();
|
||||
|
||||
// ModelBlobLoad("world\\model.blob");
|
||||
|
||||
// if (SFile::IsStreamingMode()) {
|
||||
// TextureLoadBlob("world\\liquid.tex");
|
||||
// }
|
||||
|
||||
ScrnInitialize(0);
|
||||
// ConsoleScreenInitialize(a2);
|
||||
|
||||
// s_cvarTextureFilteringMode = CVar::Register(
|
||||
// "textureFilteringMode",
|
||||
// "Texture filtering mode",
|
||||
// 1,
|
||||
// "1",
|
||||
// &TextureFilteringCallback,
|
||||
// 1,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0
|
||||
// );
|
||||
|
||||
// s_cvarUIFaster = CVar::Register(
|
||||
// "UIFaster",
|
||||
// "UI acceleration option",
|
||||
// 0,
|
||||
// "3",
|
||||
// &UIFasterCalllback,
|
||||
// 1,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0
|
||||
// );
|
||||
|
||||
// s_cvarTextureCacheSize = CVar::Register(
|
||||
// "textureCacheSize",
|
||||
// "Texture cache size in bytes",
|
||||
// 1,
|
||||
// "32",
|
||||
// &TextureCacheSizeCallback,
|
||||
// 1,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0
|
||||
// );
|
||||
|
||||
// sub_4B6580(*(_DWORD *)(dword_B2F9FC + 48) << 20);
|
||||
|
||||
// AddConsoleDeviceDefaultCallback(SetDefaults);
|
||||
|
||||
// if (ConsoleDeviceHardwareChanged()) {
|
||||
// v3 = 0;
|
||||
|
||||
// do {
|
||||
// SetDefaults(v3++);
|
||||
// } while (v3 < 3);
|
||||
// }
|
||||
|
||||
auto m2Flags = M2RegisterCVars();
|
||||
M2Initialize(m2Flags, 0);
|
||||
|
||||
// v4 = *(_DWORD *)(dword_B2FA00 + 48);
|
||||
// sub_4B61C0(dword_AB6128[v4]);
|
||||
// sub_4B6230(dword_AB6140[v4]);
|
||||
|
||||
WowClientInit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t InitializeGlobal() {
|
||||
// TODO
|
||||
|
||||
// SCmdRegisterArgList(&ProcessCommandLine(void)::s_wowArgList, 17u);
|
||||
|
||||
// CmdLineProcess();
|
||||
|
||||
// sub_403600("WoW.mfil");
|
||||
|
||||
// if (dword_B2FA10 != 2) {
|
||||
// sub_403560();
|
||||
// }
|
||||
|
||||
// LOBYTE(v24) = 0;
|
||||
|
||||
// if (sub_422140()) {
|
||||
// LOBYTE(v24) = OsDirectoryExists((int)"WTF/Account") == 0;
|
||||
// }
|
||||
|
||||
// ClientServices::LoadCDKey();
|
||||
|
||||
ConsoleInitializeClientCommand();
|
||||
|
||||
ConsoleInitializeClientCVar("Config.wtf");
|
||||
|
||||
// sub_7663F0();
|
||||
|
||||
// v18 = 0;
|
||||
// v19 = 0;
|
||||
// ptr = 0;
|
||||
// v21 = 0;
|
||||
|
||||
// sub_406740(&v18, &CVar::Load);
|
||||
|
||||
// if (ptr) {
|
||||
// SMemFree(ptr, a_pad, -2, 0);
|
||||
// }
|
||||
|
||||
// CVar::Register("dbCompress", "Database compression", 0, "-1", 0, 5, 0, 0, 0);
|
||||
|
||||
// v2 = CVar::Register("locale", "Set the game locale", 0, "****", &LocaleChangedCallback, 5, 0, 0, 0);
|
||||
|
||||
// if (!SStrCmp(v2->m_stringValue.m_str, "****", 0x7FFFFFFFu)) {
|
||||
// CVar::Set(v2, "enUS", 1, 0, 0, 1);
|
||||
// }
|
||||
|
||||
// CVar::Register("useEnglishAudio", "override the locale and use English audio", 0, "0", 0, 5, 0, 0, 0);
|
||||
|
||||
// if (sub_422140()) {
|
||||
// sub_4036B0(v24, 0, a2, (int)v2, (char)v24);
|
||||
// }
|
||||
|
||||
// SStrCopy(&a1a, v2->m_stringValue.m_str, 5);
|
||||
|
||||
// sub_402D50(&a1a);
|
||||
|
||||
// CVar::Set(v2, &a1a, 1, 0, 0, 1);
|
||||
|
||||
// SStrPrintf(dest, 260, "%s%s", *(_DWORD *)off_AB6158, v2->m_stringValue.m_str);
|
||||
|
||||
// sub_421B50(dest);
|
||||
|
||||
// sub_423D70();
|
||||
|
||||
// sub_405DD0();
|
||||
|
||||
// CVar* v3 = CVar::Register(
|
||||
// "processAffinityMask",
|
||||
// "Sets which core(s) WoW may execute on - changes require restart to take effect",
|
||||
// 2,
|
||||
// "0",
|
||||
// &sub_4022E0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0
|
||||
// );
|
||||
|
||||
// CVar* v4 = CVar::Lookup("videoOptionsVersion");
|
||||
|
||||
// if (!v4 || v4->m_intValue < 3) {
|
||||
// SStrPrintf(v23, 8, "%u", 0);
|
||||
// CVar::Set(v3, v23, 1, 0, 0, 1);
|
||||
// CVar::Update((int)v3);
|
||||
// }
|
||||
|
||||
// v5 = v3->m_intValue;
|
||||
|
||||
// if (v5) {
|
||||
// SSetCurrentProcessAffinityMask(v5);
|
||||
// }
|
||||
|
||||
BaseInitializeGlobal();
|
||||
|
||||
EventInitialize(1, 0);
|
||||
|
||||
// CVar* v6 = CVar::Register(
|
||||
// "timingTestError",
|
||||
// "Error reported by the timing validation system",
|
||||
// 6,
|
||||
// "0",
|
||||
// 0,
|
||||
// 5,
|
||||
// 0,
|
||||
// 0,
|
||||
// 0
|
||||
// );
|
||||
// v7 = v6;
|
||||
|
||||
// CVar* v8 = CVar::Register(
|
||||
// "timingMethod",
|
||||
// "Desired method for game timing",
|
||||
// 2,
|
||||
// "0",
|
||||
// &sub_403200,
|
||||
// 5,
|
||||
// 0,
|
||||
// v6,
|
||||
// 0
|
||||
// );
|
||||
|
||||
// sub_86D430(v8->m_intValue);
|
||||
|
||||
// ConsoleCommandRegister("timingInfo", (int)sub_4032A0, 0, 0);
|
||||
|
||||
// v9 = sub_86AD50();
|
||||
|
||||
// v10 = v9 == v7->m_intValue;
|
||||
|
||||
// dword_B2F9D8 = v9;
|
||||
|
||||
// if (!v10) {
|
||||
// sprintf(&v17, "%d", v9);
|
||||
// CVar::SetReadOnly((int)v7, 0);
|
||||
// CVar::Set(v7, &v17, 1, 0, 0, 1);
|
||||
// CVar::Update((int)v7);
|
||||
// CVar::SetReadOnly((int)v7, 1);
|
||||
// ConsolePrintf("Timing test error: %d", (int)v7);
|
||||
// }
|
||||
|
||||
// WowClientDB<Startup_StringsRec>::Load(&g_Startup_StringsDB, 0, ".\\Client.cpp", 0x12E3u);
|
||||
// Startup_StringsRec* v11 = g_Startup_StringsDB.GetRecordByIndex(1);
|
||||
// const char* v12;
|
||||
|
||||
// if (v11) {
|
||||
// v12 = v11->m_text;
|
||||
// } else {
|
||||
// v12 = "World of Warcraft";
|
||||
// }
|
||||
|
||||
// TODO
|
||||
// - replace with above logic for loading from Startup_Strings.dbc
|
||||
const char* v12 = "World of Warcraft";
|
||||
|
||||
char v15[260];
|
||||
|
||||
SStrCopy(v15, v12, 0x7FFFFFFF);
|
||||
|
||||
ConsoleDeviceInitialize(v15);
|
||||
|
||||
// OsIMEInitialize();
|
||||
|
||||
// uint32_t v13 = OsGetAsyncTimeMs();
|
||||
// g_rndSeed.SetSeed(v13);
|
||||
|
||||
Client::g_clientEventContext = EventCreateContextEx(
|
||||
1,
|
||||
&InitializeEngineCallback,
|
||||
&DestroyEngineCallback,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void CommonMain() {
|
||||
StormInitialize();
|
||||
|
||||
// TODO
|
||||
// - error log setup
|
||||
// - misc other setup
|
||||
|
||||
if (InitializeGlobal()) {
|
||||
EventDoMessageLoop();
|
||||
|
||||
// TODO
|
||||
// sub_406B70();
|
||||
}
|
||||
|
||||
// TODO
|
||||
// - misc cleanup
|
||||
}
|
||||
|
||||
void BlizzardAssertCallback(const char* a1, const char* a2, const char* a3, uint32_t a4) {
|
||||
if (*a2) {
|
||||
SErrDisplayError(0, a3, a4, a2, 0, 1, 0x11111111);
|
||||
} else {
|
||||
SErrDisplayError(0, a3, a4, a1, 0, 1, 0x11111111);
|
||||
}
|
||||
}
|
||||
|
||||
void StormInitialize() {
|
||||
// TODO
|
||||
// SStrInitialize();
|
||||
// SErrInitialize();
|
||||
// SLogInitialize();
|
||||
// SFile::Initialize();
|
||||
|
||||
Blizzard::Debug::SetAssertHandler(BlizzardAssertCallback);
|
||||
}
|
||||
|
||||
void WowClientInit() {
|
||||
// TODO
|
||||
// EventRegister(EVENT_ID_5, (int)sub_4020E0);
|
||||
// _cfltcvt_init_0();
|
||||
|
||||
ClientMiscInitialize();
|
||||
|
||||
// sub_401B60();
|
||||
// ClientDBInitialize();
|
||||
// LoadingScreenInitialize();
|
||||
|
||||
FrameScript_Initialize(0);
|
||||
|
||||
// TODO
|
||||
// SI2::Init(0);
|
||||
// sub_6F66B0();
|
||||
|
||||
FrameXML_RegisterDefault();
|
||||
GlueScriptEventsInitialize();
|
||||
ScriptEventsInitialize();
|
||||
|
||||
// TODO
|
||||
// sub_6F75E0();
|
||||
// sub_401FF0();
|
||||
|
||||
ClientServices::Initialize();
|
||||
// TODO ClientServices::SetMessageHandler(SMSG_TUTORIAL_FLAGS, (int)sub_530920, 0);
|
||||
|
||||
// TODO
|
||||
// v2 = CVar::Lookup("EnableVoiceChat");
|
||||
// if (v2 && *(_DWORD *)(v2 + 48)) {
|
||||
// ComSatClient_Init();
|
||||
// }
|
||||
|
||||
// TODO
|
||||
// DBCache_RegisterHandlers();
|
||||
// DBCache_Initialize(a1);
|
||||
|
||||
// TODO
|
||||
// sub_78E400();
|
||||
|
||||
CWorld::Initialize();
|
||||
|
||||
// TODO
|
||||
// ShadowInit();
|
||||
// GxuLightInitialize();
|
||||
// GxuLightBucketSizeSet(16.665001);
|
||||
// InputControlInitialize();
|
||||
|
||||
CGlueMgr::Initialize();
|
||||
|
||||
// TODO
|
||||
// if (GetConsoleMessage()) {
|
||||
// v3 = (const char *)GetConsoleMessage();
|
||||
// CGlueMgr::AddChangedOptionWarning(v3);
|
||||
// SetConsoleMessage(0);
|
||||
// }
|
||||
|
||||
// TODO
|
||||
// if (sub_422140()) {
|
||||
// sub_421630();
|
||||
// }
|
||||
|
||||
// TODO
|
||||
// if (byte_B2F9E1 != 1) {
|
||||
// if ((g_playIntroMovie + 48) == 1) {
|
||||
// CVar::Set(g_playIntroMovie, "0", 1, 0, 0, 1);
|
||||
// CGlueMgr::SetScreen("movie");
|
||||
// } else {
|
||||
// CGlueMgr::SetScreen("login");
|
||||
// }
|
||||
// } else {
|
||||
// if ((dword_B2F980 + 48) == 1) {
|
||||
// CVar::Set(dword_B2F980, "0", 1, 0, 0, 1);
|
||||
// CVar::Set(g_playIntroMovie, "0", 1, 0, 0, 1);
|
||||
// CGlueMgr::SetScreen("movie");
|
||||
// } else {
|
||||
// CGlueMgr::SetScreen("login");
|
||||
// }
|
||||
// }
|
||||
|
||||
// TODO
|
||||
// - temporary until above logic is implemented
|
||||
CGlueMgr::SetScreen("login");
|
||||
|
||||
// TODO
|
||||
// CGlueMgr::m_pendingTimerAlert = dword_B2F9D8;
|
||||
// sub_7FC5A0();
|
||||
// EventRegister(EVENT_ID_POLL, &PollNet);
|
||||
}
|
||||
22
src/client/Client.hpp
Normal file
22
src/client/Client.hpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef CLIENT_CLIENT_HPP
|
||||
#define CLIENT_CLIENT_HPP
|
||||
|
||||
#include "event/Event.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
class CVar;
|
||||
|
||||
namespace Client {
|
||||
extern CVar* g_accountListVar;
|
||||
extern HEVENTCONTEXT g_clientEventContext;
|
||||
}
|
||||
|
||||
void ClientPostClose(int32_t);
|
||||
|
||||
void CommonMain(void);
|
||||
|
||||
void StormInitialize(void);
|
||||
|
||||
void WowClientInit(void);
|
||||
|
||||
#endif
|
||||
10
src/client/ClientRealmResponseAdapter.hpp
Normal file
10
src/client/ClientRealmResponseAdapter.hpp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef CLIENT_CLIENT_REALM_RESPONSE_ADAPTER_HPP
|
||||
#define CLIENT_CLIENT_REALM_RESPONSE_ADAPTER_HPP
|
||||
|
||||
#include "net/Connection.hpp"
|
||||
|
||||
class ClientRealmResponseAdapter : public RealmResponse {
|
||||
public:
|
||||
};
|
||||
|
||||
#endif
|
||||
92
src/client/ClientServices.cpp
Normal file
92
src/client/ClientServices.cpp
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
#include "client/ClientServices.hpp"
|
||||
#include "client/ClientRealmResponseAdapter.hpp"
|
||||
#include "net/Connection.hpp"
|
||||
#include "net/Login.hpp"
|
||||
#include <storm/Memory.hpp>
|
||||
#include <storm/String.hpp>
|
||||
#include <new>
|
||||
|
||||
ClientConnection* g_clientConnection;
|
||||
|
||||
RealmResponse* ClientServices::s_clientRealmResponse;
|
||||
ClientConnection* ClientServices::s_currentConnection;
|
||||
ClientServices* ClientServices::s_instance;
|
||||
Login* ClientServices::s_loginObj;
|
||||
bool ClientServices::s_newLogin;
|
||||
|
||||
ClientConnection* ClientServices::Connection() {
|
||||
// TODO assertion?
|
||||
|
||||
return ClientServices::s_currentConnection;
|
||||
}
|
||||
|
||||
ClientServices* ClientServices::GetInstance() {
|
||||
if (ClientServices::s_instance) {
|
||||
return ClientServices::s_instance;
|
||||
}
|
||||
|
||||
auto instanceMem = SMemAlloc(sizeof(ClientServices), __FILE__, __LINE__, 0x0);
|
||||
auto instance = new (instanceMem) ClientServices();
|
||||
ClientServices::s_instance = instance;
|
||||
|
||||
return ClientServices::s_instance;
|
||||
}
|
||||
|
||||
void ClientServices::Initialize() {
|
||||
if (!g_clientConnection) {
|
||||
auto adapterMem = SMemAlloc(sizeof(ClientRealmResponseAdapter), __FILE__, __LINE__, 0x0);
|
||||
auto clientRealmResponse = new (adapterMem) ClientRealmResponseAdapter();
|
||||
ClientServices::s_clientRealmResponse = clientRealmResponse;
|
||||
|
||||
auto connectionMem = SMemAlloc(sizeof(ClientConnection), __FILE__, __LINE__, 0x0);
|
||||
auto clientConnection = new (connectionMem) ClientConnection(ClientServices::s_clientRealmResponse);
|
||||
g_clientConnection = clientConnection;
|
||||
}
|
||||
|
||||
ClientServices::s_currentConnection = g_clientConnection;
|
||||
|
||||
// TODO ConsoleCommandRegister("logout", &Sub6B2030, 5, nullptr);
|
||||
}
|
||||
|
||||
Login* ClientServices::LoginConnection() {
|
||||
return ClientServices::s_loginObj;
|
||||
}
|
||||
|
||||
void ClientServices::Logon(const char* accountName, const char* password) {
|
||||
if (ClientServices::s_newLogin) {
|
||||
if (ClientServices::s_loginObj) {
|
||||
// TODO
|
||||
// ClientServices::s_loginObj->Vfunc48(1);
|
||||
|
||||
ClientServices::s_loginObj = nullptr;
|
||||
}
|
||||
|
||||
ClientServices::s_newLogin = false;
|
||||
}
|
||||
|
||||
auto useBattlenet = SStrChr(accountName, '@') != 0;
|
||||
|
||||
Login* loginObj;
|
||||
|
||||
if (useBattlenet) {
|
||||
// TODO
|
||||
} else {
|
||||
auto loginMem = SMemAlloc(sizeof(GruntLogin), __FILE__, __LINE__, 0x0);
|
||||
loginObj = new (loginMem) GruntLogin();
|
||||
}
|
||||
|
||||
ClientServices::s_loginObj = loginObj;
|
||||
ClientServices::s_loginObj->Init(ClientServices::GetInstance());
|
||||
|
||||
// TODO
|
||||
|
||||
ClientServices::s_loginObj->SetLogonCreds(accountName, password);
|
||||
|
||||
// TODO
|
||||
|
||||
ClientServices::s_loginObj->Logon(nullptr, nullptr);
|
||||
}
|
||||
|
||||
void ClientServices::LoginServerStatus(LOGIN_STATE state, LOGIN_RESULT result, const char* addrStr, const char* stateStr, const char* resultStr, uint16_t a7) {
|
||||
// TODO
|
||||
}
|
||||
30
src/client/ClientServices.hpp
Normal file
30
src/client/ClientServices.hpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef CLIENT_CLIENT_SERVICES_HPP
|
||||
#define CLIENT_CLIENT_SERVICES_HPP
|
||||
|
||||
#include "net/login/LoginResponse.hpp"
|
||||
|
||||
class ClientConnection;
|
||||
class Login;
|
||||
class RealmResponse;
|
||||
|
||||
class ClientServices : public LoginResponse {
|
||||
public:
|
||||
// Static variables
|
||||
static RealmResponse* s_clientRealmResponse;
|
||||
static ClientConnection* s_currentConnection;
|
||||
static ClientServices* s_instance;
|
||||
static Login* s_loginObj;
|
||||
static bool s_newLogin;
|
||||
|
||||
// Static functions
|
||||
static ClientConnection* Connection();
|
||||
static ClientServices* GetInstance();
|
||||
static void Initialize();
|
||||
static Login* LoginConnection();
|
||||
static void Logon(const char* accountName, const char* password);
|
||||
|
||||
// Virtual member functions
|
||||
virtual void LoginServerStatus(LOGIN_STATE state, LOGIN_RESULT result, const char* addrStr, const char* stateStr, const char* resultStr, uint16_t a7);
|
||||
};
|
||||
|
||||
#endif
|
||||
191
src/client/Console.cpp
Normal file
191
src/client/Console.cpp
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
#include "client/Console.hpp"
|
||||
#include "gx/Device.hpp"
|
||||
#include "util/CVar.hpp"
|
||||
#include <cstring>
|
||||
|
||||
CVar* s_cvGxMaximize;
|
||||
CVar* s_cvGxResolution;
|
||||
CVar* s_cvGxWidescreen;
|
||||
CVar* s_cvGxWindow;
|
||||
DefaultSettings s_defaults;
|
||||
bool s_hwDetect;
|
||||
bool s_hwChanged;
|
||||
CGxFormat s_requestedFormat;
|
||||
|
||||
bool CVGxMaximizeCallback(CVar*, const char*, const char*, void*) {
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CVGxResolutionCallback(CVar*, const char*, const char*, void*) {
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CVGxWindowCallback(CVar*, const char*, const char*, void*) {
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
void RegisterGxCVars() {
|
||||
auto& format = s_defaults.format;
|
||||
|
||||
// TODO CURRENT_LANGUAGE check?
|
||||
auto v1 = true;
|
||||
|
||||
s_cvGxWidescreen = CVar::Register(
|
||||
"widescreen",
|
||||
"Allow widescreen support",
|
||||
0x0,
|
||||
"1",
|
||||
nullptr,
|
||||
1,
|
||||
false,
|
||||
nullptr,
|
||||
false
|
||||
);
|
||||
|
||||
s_cvGxWindow = CVar::Register(
|
||||
"gxWindow",
|
||||
"toggle fullscreen/window",
|
||||
0x1 | 0x2,
|
||||
v1 ? "1" : "0",
|
||||
&CVGxWindowCallback,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
s_cvGxMaximize = CVar::Register(
|
||||
"gxMaximize",
|
||||
"maximize game window",
|
||||
0x1 | 0x2,
|
||||
v1 ? "1" : "0",
|
||||
&CVGxMaximizeCallback,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
);
|
||||
|
||||
// TODO s_cvGxColorBits
|
||||
// TODO s_cvGxDepthBits
|
||||
|
||||
char resolution[260];
|
||||
SStrPrintf(resolution, 260, "%dx%d", format.size.x, format.size.y);
|
||||
s_cvGxResolution = CVar::Register(
|
||||
"gxResolution",
|
||||
"resolution",
|
||||
0x1 | 0x2,
|
||||
resolution,
|
||||
&CVGxResolutionCallback,
|
||||
1,
|
||||
false,
|
||||
nullptr,
|
||||
false
|
||||
);
|
||||
|
||||
// TODO s_cvGxRefresh
|
||||
// TODO s_cvGxTripleBuffer
|
||||
// TODO s_cvGxApi
|
||||
// TODO s_cvGxVSync
|
||||
// TODO s_cvGxAspect
|
||||
// TODO s_cvGxCursor
|
||||
// TODO s_cvGxMultisample
|
||||
// TODO s_cvGxFixLag
|
||||
// TODO s_cvGxStereoEnabled
|
||||
// TODO s_cvGxOverride
|
||||
// TODO s_cvGxAspect
|
||||
// TODO s_cvGxMaxFPS
|
||||
// TODO s_cvGxMaxFPSBk
|
||||
// TODO s_cvWindowResizeLock
|
||||
// TODO s_cvFixedFunction
|
||||
}
|
||||
|
||||
void UpdateGxCVars() {
|
||||
// TODO others
|
||||
|
||||
s_cvGxWindow->Update();
|
||||
s_cvGxResolution->Update();
|
||||
|
||||
// TODO others
|
||||
|
||||
s_cvGxMaximize->Update();
|
||||
|
||||
// TODO others
|
||||
}
|
||||
|
||||
void SetGxCVars(const CGxFormat& format) {
|
||||
char value[1024];
|
||||
|
||||
// TODO s_cvGxColorBits
|
||||
// TODO s_cvGxDepthBits
|
||||
|
||||
SStrPrintf(value, sizeof(value), "%d", format.window);
|
||||
s_cvGxWindow->Set(value, true, false, false, true);
|
||||
|
||||
SStrPrintf(value, sizeof(value), "%dx%d", format.size.x, format.size.y);
|
||||
s_cvGxResolution->Set(value, true, false, false, true);
|
||||
|
||||
// TODO s_cvGxRefresh
|
||||
// TODO others
|
||||
|
||||
SStrPrintf(value, sizeof(value), "%d", format.maximize);
|
||||
s_cvGxMaximize->Set(value, true, false, false, true);
|
||||
|
||||
// TODO others
|
||||
|
||||
UpdateGxCVars();
|
||||
}
|
||||
|
||||
void ConsoleInitializeClientCommand() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void ConsoleInitializeClientCVar(const char* a1) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void ConsoleDeviceInitialize(const char* title) {
|
||||
// TODO
|
||||
|
||||
// TODO proper logic
|
||||
s_hwDetect = true;
|
||||
|
||||
// TODO
|
||||
|
||||
RegisterGxCVars();
|
||||
|
||||
// TODO ConsoleCommandRegister("gxRestart", &CCGxRestart, 1, nullptr);
|
||||
|
||||
// TODO
|
||||
|
||||
// TODO
|
||||
// - source the size values correctly
|
||||
s_requestedFormat.size.x = 1024;
|
||||
s_requestedFormat.size.y = 768;
|
||||
s_requestedFormat.colorFormat = CGxFormat::Fmt_Argb8888;
|
||||
s_requestedFormat.depthFormat = CGxFormat::Fmt_Ds248;
|
||||
|
||||
if (s_hwDetect || s_hwChanged) {
|
||||
// TODO Sub76B3F0(&UnkCABAF0, &UnkCABB38);
|
||||
// TODO s_cvFixedFunction->Set("0", 1, 0, 0, 1);
|
||||
// TODO memcpy(&s_requestedFormat, &s_defaults.format, sizeof(s_requestedFormat));
|
||||
|
||||
s_requestedFormat.window = s_cvGxWindow->GetInt() != 0;
|
||||
s_requestedFormat.maximize = s_cvGxMaximize->GetInt() != 0;
|
||||
|
||||
// TODO temporary override
|
||||
s_requestedFormat.maximize = 0;
|
||||
|
||||
SetGxCVars(s_requestedFormat);
|
||||
}
|
||||
|
||||
CGxFormat format;
|
||||
memcpy(&format, &s_requestedFormat, sizeof(s_requestedFormat));
|
||||
|
||||
CGxDevice* device = GxDevCreate(GxApi_GLL, nullptr, format);
|
||||
|
||||
// TODO
|
||||
}
|
||||
16
src/client/Console.hpp
Normal file
16
src/client/Console.hpp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef CLIENT_CONSOLE_HPP
|
||||
#define CLIENT_CONSOLE_HPP
|
||||
|
||||
#include "gx/CGxFormat.hpp"
|
||||
|
||||
struct DefaultSettings {
|
||||
CGxFormat format;
|
||||
};
|
||||
|
||||
void ConsoleInitializeClientCommand();
|
||||
|
||||
void ConsoleInitializeClientCVar(const char* a1);
|
||||
|
||||
void ConsoleDeviceInitialize(const char* title);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue