mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-10-26 13:56:05 +03:00
feat(ui): implement script methods for character creation screen
This commit is contained in:
parent
77cb9ed966
commit
b4ff9994e2
@ -423,6 +423,10 @@ bool ClientServices::LoadCDKey() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ClientServices::GetExpansionLevel() {
|
||||||
|
return ClientServices::Connection()->GetExpansionLevel();
|
||||||
|
}
|
||||||
|
|
||||||
void ClientServices::InitLoginServerCVars(int32_t overwrite, const char* locale) {
|
void ClientServices::InitLoginServerCVars(int32_t overwrite, const char* locale) {
|
||||||
if ((ClientServices::s_realmListBNVar == nullptr || ClientServices::s_realmListVar == nullptr) || overwrite != 0 ) {
|
if ((ClientServices::s_realmListBNVar == nullptr || ClientServices::s_realmListVar == nullptr) || overwrite != 0 ) {
|
||||||
ClientServices::s_decorateAccountName = CVar::Register(
|
ClientServices::s_decorateAccountName = CVar::Register(
|
||||||
|
|||||||
@ -56,6 +56,7 @@ class ClientServices : public LoginResponse {
|
|||||||
static const char* GetDefaultRealmlistString();
|
static const char* GetDefaultRealmlistString();
|
||||||
static const char* GetDefaultPatchListString();
|
static const char* GetDefaultPatchListString();
|
||||||
static bool LoadCDKey();
|
static bool LoadCDKey();
|
||||||
|
static int32_t GetExpansionLevel();
|
||||||
|
|
||||||
// Virtual member functions
|
// Virtual member functions
|
||||||
virtual int32_t GetLoginServerType();
|
virtual int32_t GetLoginServerType();
|
||||||
|
|||||||
@ -183,3 +183,15 @@ void CCharacterCreation::RandomizeCharFeatures() {
|
|||||||
CCharacterCreation::m_prevHairStyleIndex = info.hairStyleID;
|
CCharacterCreation::m_prevHairStyleIndex = info.hairStyleID;
|
||||||
CCharacterCreation::m_prevFacialFeatureIndex = info.facialFeatureID;
|
CCharacterCreation::m_prevFacialFeatureIndex = info.facialFeatureID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCharacterCreation::SetSelectedRace(int32_t raceID) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCharacterCreation::SetSelectedSex(int32_t sexID) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void CCharacterCreation::SetSelectedClass(int32_t classID) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|||||||
@ -38,6 +38,9 @@ class CCharacterCreation {
|
|||||||
static void CalcClasses(uint32_t raceID);
|
static void CalcClasses(uint32_t raceID);
|
||||||
static void InitCharacterComponent(ComponentData* data, int32_t randomize);
|
static void InitCharacterComponent(ComponentData* data, int32_t randomize);
|
||||||
static void RandomizeCharFeatures();
|
static void RandomizeCharFeatures();
|
||||||
|
static void SetSelectedRace(int32_t raceID);
|
||||||
|
static void SetSelectedSex(int32_t sexID);
|
||||||
|
static void SetSelectedClass(int32_t classID);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GLUE_C_CHARACTER_CREATION_HPP
|
#endif // GLUE_C_CHARACTER_CREATION_HPP
|
||||||
|
|||||||
@ -297,3 +297,7 @@ void RealmConnection::RequestCharacterLogin(uint64_t id) {
|
|||||||
msg.Finalize();
|
msg.Finalize();
|
||||||
this->Send(&msg);
|
this->Send(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t RealmConnection::GetExpansionLevel() const {
|
||||||
|
return this->m_accountExpansion;
|
||||||
|
}
|
||||||
|
|||||||
@ -45,6 +45,7 @@ class RealmConnection : public NetClient {
|
|||||||
void SetSelectedRealm(uint32_t a2, uint32_t a3, uint32_t a4);
|
void SetSelectedRealm(uint32_t a2, uint32_t a3, uint32_t a4);
|
||||||
void RequestCharacterEnum();
|
void RequestCharacterEnum();
|
||||||
void RequestCharacterLogin(uint64_t id);
|
void RequestCharacterLogin(uint64_t id);
|
||||||
|
int32_t GetExpansionLevel() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
const char* g_glueScriptEvents[41];
|
const char* g_glueScriptEvents[41];
|
||||||
const char* g_scriptEvents[722];
|
const char* g_scriptEvents[722];
|
||||||
|
int32_t g_glueFrameScriptGenders[3] = { 2, 3, 1 };
|
||||||
|
|
||||||
void* FrameScript::s_mempool;
|
void* FrameScript::s_mempool;
|
||||||
lua_State* FrameScript::s_context;
|
lua_State* FrameScript::s_context;
|
||||||
|
|||||||
@ -42,6 +42,7 @@ class FrameScript_EventObject : public TSHashObject<FrameScript_EventObject, HAS
|
|||||||
|
|
||||||
extern const char* g_glueScriptEvents[41];
|
extern const char* g_glueScriptEvents[41];
|
||||||
extern const char* g_scriptEvents[722];
|
extern const char* g_scriptEvents[722];
|
||||||
|
extern int32_t g_glueFrameScriptGenders[3];
|
||||||
|
|
||||||
namespace FrameScript {
|
namespace FrameScript {
|
||||||
extern void* s_mempool;
|
extern void* s_mempool;
|
||||||
|
|||||||
@ -1,12 +1,15 @@
|
|||||||
#include "ui/ScriptFunctions.hpp"
|
#include "ui/ScriptFunctions.hpp"
|
||||||
#include "ui/CSimpleModelFFX.hpp"
|
#include "ui/CSimpleModelFFX.hpp"
|
||||||
|
#include "ui/FrameScript.hpp"
|
||||||
#include "ui/Types.hpp"
|
#include "ui/Types.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
|
#include "util/SFile.hpp"
|
||||||
#include "db/Db.hpp"
|
#include "db/Db.hpp"
|
||||||
#include "clientobject/Unit_C.hpp"
|
#include "clientobject/Unit_C.hpp"
|
||||||
#include "glue/CCharacterCreation.hpp"
|
#include "glue/CCharacterCreation.hpp"
|
||||||
#include "glue/CCharacterComponent.hpp"
|
#include "glue/CCharacterComponent.hpp"
|
||||||
|
#include "client/ClientServices.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
int32_t Script_SetCharCustomizeFrame(lua_State* L) {
|
int32_t Script_SetCharCustomizeFrame(lua_State* L) {
|
||||||
@ -93,31 +96,37 @@ int32_t Script_GetFactionForRace(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_GetAvailableRaces(lua_State* L) {
|
int32_t Script_GetAvailableRaces(lua_State* L) {
|
||||||
|
auto sexID = CCharacterCreation::m_character->m_data.m_info.sexID;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < CCharacterCreation::m_races.Count(); ++i) {
|
for (uint32_t i = 0; i < CCharacterCreation::m_races.Count(); ++i) {
|
||||||
auto raceRecord = g_chrRacesDB.GetRecord(CCharacterCreation::m_races[i]);
|
auto raceRecord = g_chrRacesDB.GetRecord(CCharacterCreation::m_races[i]);
|
||||||
auto raceName = CGUnit_C::GetDisplayRaceNameFromRecord(
|
auto raceName = CGUnit_C::GetDisplayRaceNameFromRecord(raceRecord, sexID);
|
||||||
raceRecord,
|
|
||||||
CCharacterCreation::m_character->m_data.m_info.sexID);
|
|
||||||
|
|
||||||
lua_pushstring(L, raceName);
|
lua_pushstring(L, raceName);
|
||||||
lua_pushstring(L, raceRecord ? raceRecord->m_clientFileString : nullptr);
|
if (raceRecord) {
|
||||||
// TODO: Expansion Check
|
lua_pushstring(L, raceRecord->m_clientFileString);
|
||||||
lua_pushnumber(L, 1.0);
|
bool available = ClientServices::GetExpansionLevel() >= raceRecord->m_requiredExpansion;
|
||||||
|
lua_pushnumber(L, available ? 1.0 : 0.0);
|
||||||
|
} else {
|
||||||
|
lua_pushstring(L, nullptr);
|
||||||
|
lua_pushnumber(L, 0.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return CCharacterCreation::m_races.Count() * 3;
|
return CCharacterCreation::m_races.Count() * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_GetAvailableClasses(lua_State* L) {
|
int32_t Script_GetAvailableClasses(lua_State* L) {
|
||||||
|
auto sexID = CCharacterCreation::m_character->m_data.m_info.sexID;
|
||||||
|
|
||||||
for (int32_t i = 0; i < g_chrClassesDB.GetNumRecords(); ++i) {
|
for (int32_t i = 0; i < g_chrClassesDB.GetNumRecords(); ++i) {
|
||||||
auto record = g_chrClassesDB.GetRecordByIndex(i);
|
auto record = g_chrClassesDB.GetRecordByIndex(i);
|
||||||
auto className = CGUnit_C::GetDisplayClassNameFromRecord(
|
auto className = CGUnit_C::GetDisplayClassNameFromRecord(record, sexID);
|
||||||
record,
|
|
||||||
CCharacterCreation::m_character->m_data.m_info.sexID);
|
|
||||||
if (className) {
|
if (className) {
|
||||||
lua_pushstring(L, className);
|
lua_pushstring(L, className);
|
||||||
lua_pushstring(L, record->m_filename);
|
lua_pushstring(L, record->m_filename);
|
||||||
// TODO: Expansion Check
|
bool available = ClientServices::GetExpansionLevel() >= record->m_requiredExpansion;
|
||||||
lua_pushnumber(L, 1.0);
|
lua_pushnumber(L, available ? 1.0 : 0.0);
|
||||||
} else {
|
} else {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
@ -128,16 +137,17 @@ int32_t Script_GetAvailableClasses(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_GetClassesForRace(lua_State* L) {
|
int32_t Script_GetClassesForRace(lua_State* L) {
|
||||||
|
auto sexID = CCharacterCreation::m_character->m_data.m_info.sexID;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < CCharacterCreation::m_classes.Count(); ++i) {
|
for (uint32_t i = 0; i < CCharacterCreation::m_classes.Count(); ++i) {
|
||||||
auto record = CCharacterCreation::m_classes[i];
|
auto record = CCharacterCreation::m_classes[i];
|
||||||
auto className = CGUnit_C::GetDisplayClassNameFromRecord(
|
auto className = CGUnit_C::GetDisplayClassNameFromRecord(record, sexID);
|
||||||
record,
|
|
||||||
CCharacterCreation::m_character->m_data.m_info.sexID);
|
|
||||||
if (className) {
|
if (className) {
|
||||||
lua_pushstring(L, className);
|
lua_pushstring(L, className);
|
||||||
lua_pushstring(L, record->m_filename);
|
lua_pushstring(L, record->m_filename);
|
||||||
// TODO: Expansion Check
|
bool available = ClientServices::GetExpansionLevel() >= record->m_requiredExpansion;
|
||||||
lua_pushnumber(L, 1.0);
|
lua_pushnumber(L, available ? 1.0 : 0.0);
|
||||||
} else {
|
} else {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
@ -182,8 +192,8 @@ int32_t Script_GetSelectedRace(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_GetSelectedSex(lua_State* L) {
|
int32_t Script_GetSelectedSex(lua_State* L) {
|
||||||
// TODO: g_glueFrameScriptGenders[CCharacterCreation::m_character->m_data.m_info.sexID]
|
auto sexID = CCharacterCreation::m_character->m_data.m_info.sexID;
|
||||||
lua_pushnumber(L, 2.0);
|
lua_pushnumber(L, g_glueFrameScriptGenders[sexID]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,15 +228,40 @@ int32_t Script_GetSelectedClass(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_SetSelectedRace(lua_State* L) {
|
int32_t Script_SetSelectedRace(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
if (!lua_isnumber(L, 1)) {
|
||||||
|
return luaL_error(L, "Usage: SetSelectedRace(index)");
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t raceID = static_cast<int32_t>(lua_tonumber(L, 1)) - 1;
|
||||||
|
CCharacterCreation::SetSelectedRace(raceID);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_SetSelectedSex(lua_State* L) {
|
int32_t Script_SetSelectedSex(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
if (!lua_isnumber(L, 1)) {
|
||||||
|
return luaL_error(L, "Usage: SetSelectedSex(index)");
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t sexID = static_cast<int32_t>(lua_tonumber(L, 1));
|
||||||
|
for (int32_t i = 0; i < 3; ++i) {
|
||||||
|
if (g_glueFrameScriptGenders[i] == sexID) {
|
||||||
|
CCharacterCreation::SetSelectedSex(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_SetSelectedClass(lua_State* L) {
|
int32_t Script_SetSelectedClass(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
if (!lua_isnumber(L, 1)) {
|
||||||
|
return luaL_error(L, "Usage: SetSelectedSex(index)");
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t index = static_cast<int32_t>(lua_tonumber(L, 1)) - 1;
|
||||||
|
|
||||||
|
// NOTICE: Original client has access violation issue in this method
|
||||||
|
auto record = g_chrClassesDB.GetRecordByIndex(index);
|
||||||
|
CCharacterCreation::SetSelectedClass(record ? record->m_ID : 0);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_UpdateCustomizationBackground(lua_State* L) {
|
int32_t Script_UpdateCustomizationBackground(lua_State* L) {
|
||||||
@ -290,8 +325,7 @@ int32_t Script_IsRaceClassRestricted(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_GetCreateBackgroundModel(lua_State* L) {
|
int32_t Script_GetCreateBackgroundModel(lua_State* L) {
|
||||||
// TODO
|
if (SFile::IsTrial()) {
|
||||||
if (false /* SFile::IsTrial() */) {
|
|
||||||
lua_pushstring(L, "CharacterSelect");
|
lua_pushstring(L, "CharacterSelect");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -307,3 +307,8 @@ int32_t SFile::RebuildHash() {
|
|||||||
// TODO
|
// TODO
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t SFile::IsTrial() {
|
||||||
|
// TODO
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@ -41,6 +41,7 @@ class SFile {
|
|||||||
static int32_t GetDataPath(char* path, size_t capacity);
|
static int32_t GetDataPath(char* path, size_t capacity);
|
||||||
static int32_t SetDataPathAlternate(const char* path);
|
static int32_t SetDataPathAlternate(const char* path);
|
||||||
static int32_t RebuildHash();
|
static int32_t RebuildHash();
|
||||||
|
static int32_t IsTrial();
|
||||||
|
|
||||||
// Member variables
|
// Member variables
|
||||||
SFILE_TYPE m_type;
|
SFILE_TYPE m_type;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user