mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 16:22:45 +03:00
feat(glue): implement CCharacterCreation::SetSelectedSex
This commit is contained in:
parent
6c3998b3b0
commit
3d41f0cf26
@ -114,6 +114,10 @@ void CCharacterCreation::GetRandomRaceAndSex(ComponentData* data) {
|
|||||||
data->sexID = UNITSEX_MALE;
|
data->sexID = UNITSEX_MALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t CCharacterCreation::GetSelectedRaceID() {
|
||||||
|
return CCharacterCreation::s_races[CCharacterCreation::s_raceIndex];
|
||||||
|
}
|
||||||
|
|
||||||
void CCharacterCreation::Initialize() {
|
void CCharacterCreation::Initialize() {
|
||||||
CCharacterCreation::s_charFacing = 0.0f;
|
CCharacterCreation::s_charFacing = 0.0f;
|
||||||
CCharacterCreation::s_charCustomizeFrame = nullptr;
|
CCharacterCreation::s_charCustomizeFrame = nullptr;
|
||||||
@ -382,5 +386,64 @@ void CCharacterCreation::SetSelectedRace(int32_t raceIndex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CCharacterCreation::SetSelectedSex(int32_t sexID) {
|
void CCharacterCreation::SetSelectedSex(int32_t sexID) {
|
||||||
// TODO
|
if (sexID >= UNITSEX_LAST) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto currentRaceID = CCharacterCreation::s_character->m_data.raceID;
|
||||||
|
auto currentSexID = CCharacterCreation::s_character->m_data.sexID;
|
||||||
|
auto currentClassID = CCharacterCreation::s_selectedClassID;
|
||||||
|
|
||||||
|
if (sexID == currentSexID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
CCharacterCreation::SavePreferences();
|
||||||
|
|
||||||
|
ComponentData data = {};
|
||||||
|
data.raceID = currentRaceID;
|
||||||
|
data.sexID = sexID;
|
||||||
|
data.classID = currentClassID;
|
||||||
|
|
||||||
|
auto existingCharacter = CCharacterCreation::s_existingCharacterIndex >= 0
|
||||||
|
? CCharacterSelection::GetCharacterDisplay(CCharacterCreation::s_existingCharacterIndex)
|
||||||
|
: nullptr;
|
||||||
|
|
||||||
|
auto preferences = CCharacterCreation::s_charPreferences[CCharacterCreation::GetSelectedRaceID()][sexID];
|
||||||
|
|
||||||
|
bool useExistingCharacter = existingCharacter
|
||||||
|
&& existingCharacter->m_info.sexID == sexID
|
||||||
|
&& existingCharacter->m_info.customizeFlags & 0x1;
|
||||||
|
|
||||||
|
bool usePreferences = !useExistingCharacter && preferences;
|
||||||
|
|
||||||
|
if (useExistingCharacter) {
|
||||||
|
data.raceID = existingCharacter->m_info.raceID;
|
||||||
|
data.sexID = existingCharacter->m_info.sexID;
|
||||||
|
data.classID = existingCharacter->m_info.classID;
|
||||||
|
data.skinColorID = existingCharacter->m_info.skinColorID;
|
||||||
|
data.hairStyleID = existingCharacter->m_info.hairStyleID;
|
||||||
|
data.hairColorID = existingCharacter->m_info.hairColorID;
|
||||||
|
data.facialHairStyleID = existingCharacter->m_info.facialHairStyleID;
|
||||||
|
data.faceID = existingCharacter->m_info.faceID;
|
||||||
|
|
||||||
|
CCharacterCreation::CreateComponent(&data, false);
|
||||||
|
} else if (usePreferences) {
|
||||||
|
data.SetPreferences(preferences);
|
||||||
|
data.classID = currentClassID;
|
||||||
|
|
||||||
|
// TODO CCharacterComponent::ValidateComponentData(&data, 0);
|
||||||
|
|
||||||
|
CCharacterCreation::CreateComponent(&data, false);
|
||||||
|
} else {
|
||||||
|
data.raceID = currentRaceID;
|
||||||
|
data.sexID = sexID;
|
||||||
|
data.classID = currentClassID;
|
||||||
|
|
||||||
|
CCharacterCreation::CreateComponent(&data, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO name gen stuff
|
||||||
|
|
||||||
|
CGlueLoading::StartLoad(CCharacterCreation::s_character, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@ class CCharacterCreation {
|
|||||||
static void Dress();
|
static void Dress();
|
||||||
static int32_t GetRandomClassID();
|
static int32_t GetRandomClassID();
|
||||||
static void GetRandomRaceAndSex(ComponentData* data);
|
static void GetRandomRaceAndSex(ComponentData* data);
|
||||||
|
static int32_t GetSelectedRaceID();
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
static bool IsClassValid(int32_t classID);
|
static bool IsClassValid(int32_t classID);
|
||||||
static bool IsRaceClassValid(int32_t raceID, int32_t classID);
|
static bool IsRaceClassValid(int32_t raceID, int32_t classID);
|
||||||
|
|||||||
@ -249,7 +249,20 @@ int32_t Script_SetSelectedRace(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_SetSelectedSex(lua_State* L) {
|
int32_t Script_SetSelectedSex(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
if (!lua_isnumber(L, 1)) {
|
||||||
|
luaL_error(L, "Usage: SetSelectedSex(index)");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto sexIndex = lua_tointeger(L, 1);
|
||||||
|
|
||||||
|
for (int32_t sexID = 0; sexID < UNITSEX_LAST; sexID++) {
|
||||||
|
if (sexIndex == g_glueFrameScriptGenders[sexID]) {
|
||||||
|
CCharacterCreation::SetSelectedSex(sexID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_SetSelectedClass(lua_State* L) {
|
int32_t Script_SetSelectedClass(lua_State* L) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user