mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 16:22:45 +03:00
chore(glue): move component creation into CharacterSelectionDisplay
This commit is contained in:
parent
666e52fb16
commit
e3073868de
@ -8,7 +8,6 @@
|
|||||||
#include "glue/Types.hpp"
|
#include "glue/Types.hpp"
|
||||||
#include "model/CM2Shared.hpp"
|
#include "model/CM2Shared.hpp"
|
||||||
#include "net/Connection.hpp"
|
#include "net/Connection.hpp"
|
||||||
#include "object/client/Player_C.hpp"
|
|
||||||
#include "ui/CSimpleModelFFX.hpp"
|
#include "ui/CSimpleModelFFX.hpp"
|
||||||
|
|
||||||
int32_t CCharacterSelection::s_characterCount;
|
int32_t CCharacterSelection::s_characterCount;
|
||||||
@ -62,7 +61,7 @@ void CCharacterSelection::ClearCharacterModel() {
|
|||||||
|
|
||||||
void CCharacterSelection::EnumerateCharactersCallback(const CHARACTER_INFO& info, void* param) {
|
void CCharacterSelection::EnumerateCharactersCallback(const CHARACTER_INFO& info, void* param) {
|
||||||
auto display = CCharacterSelection::s_characterList.New();
|
auto display = CCharacterSelection::s_characterList.New();
|
||||||
display->info = info;
|
display->m_info = info;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
@ -97,7 +96,7 @@ void CCharacterSelection::RenderPrep() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto component = character->component;
|
auto component = character->m_component;
|
||||||
if (!component) {
|
if (!component) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -141,7 +140,7 @@ void CCharacterSelection::SetFacing(float facing) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto component = CCharacterSelection::s_characterList[CCharacterSelection::s_selectionIndex].component;
|
auto component = CCharacterSelection::s_characterList[CCharacterSelection::s_selectionIndex].m_component;
|
||||||
auto model = component->m_data.model;
|
auto model = component->m_data.model;
|
||||||
|
|
||||||
if (!model) {
|
if (!model) {
|
||||||
@ -163,71 +162,37 @@ void CCharacterSelection::ShowCharacter() {
|
|||||||
|
|
||||||
auto character = &CCharacterSelection::s_characterList[CCharacterSelection::s_selectionIndex];
|
auto character = &CCharacterSelection::s_characterList[CCharacterSelection::s_selectionIndex];
|
||||||
|
|
||||||
if (character->component) {
|
// Create character component and pet model
|
||||||
auto parent = CCharacterSelection::s_modelFrame->m_model;
|
|
||||||
|
|
||||||
if (!parent) {
|
if (!character->m_component) {
|
||||||
return;
|
character->CreateModelData();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto characterModel = character->component->m_data.model;
|
|
||||||
auto petModel = character->petModel;
|
|
||||||
|
|
||||||
characterModel->AttachToParent(parent, 0, nullptr, 0);
|
|
||||||
|
|
||||||
CCharacterSelection::SetFacing(0.0f);
|
|
||||||
|
|
||||||
if (petModel) {
|
|
||||||
petModel->AttachToParent(parent, 1, nullptr, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO a2 may be 1 in some circumstances
|
|
||||||
CGlueLoading::StartLoad(character->component, 0);
|
|
||||||
|
|
||||||
|
if (!character->m_component) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto modelData = Player_C_GetModelName(character->info.raceID, character->info.sexID);
|
// Attach character display to model frame
|
||||||
if (!modelData || !modelData->m_modelName) {
|
|
||||||
|
auto parent = CCharacterSelection::s_modelFrame->m_model;
|
||||||
|
|
||||||
|
if (!parent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
character->component = CCharacterComponent::AllocComponent();
|
auto characterModel = character->m_component->m_data.model;
|
||||||
|
auto petModel = character->m_petModel;
|
||||||
|
|
||||||
ComponentData componentData = {};
|
characterModel->AttachToParent(parent, 0, nullptr, 0);
|
||||||
componentData.raceID = character->info.raceID;
|
|
||||||
componentData.sexID = character->info.sexID;
|
|
||||||
componentData.skinColorID = character->info.skinColorID;
|
|
||||||
componentData.faceID = character->info.faceID;
|
|
||||||
componentData.hairStyleID = character->info.hairStyleID;
|
|
||||||
componentData.hairColorID = character->info.hairColorID;
|
|
||||||
componentData.facialHairStyleID = character->info.facialHairStyleID;
|
|
||||||
|
|
||||||
auto scene = CCharacterSelection::s_modelFrame->GetScene();
|
CCharacterSelection::SetFacing(0.0f);
|
||||||
auto model = scene->CreateModel(modelData->m_modelName, 0);
|
|
||||||
|
|
||||||
componentData.flags |= 0x2;
|
if (petModel) {
|
||||||
componentData.model = model;
|
petModel->AttachToParent(parent, 1, nullptr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
character->component->Init(&componentData, nullptr);
|
// TODO a2 may be 1 in some circumstances
|
||||||
|
CGlueLoading::StartLoad(character->m_component, 0);
|
||||||
// TODO lighting callback/arg
|
|
||||||
|
|
||||||
character->component->m_data.model->SetBoneSequence(
|
|
||||||
0xFFFFFFFF,
|
|
||||||
0,
|
|
||||||
0xFFFFFFFF,
|
|
||||||
0,
|
|
||||||
1.0f,
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
);
|
|
||||||
|
|
||||||
// TODO load pet model
|
|
||||||
|
|
||||||
CCharacterSelection::s_characterCount++;
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCharacterSelection::UpdateCharacterList() {
|
void CCharacterSelection::UpdateCharacterList() {
|
||||||
|
|||||||
@ -1,20 +1,12 @@
|
|||||||
#ifndef GLUE_C_CHARACTER_SELECTION_HPP
|
#ifndef GLUE_C_CHARACTER_SELECTION_HPP
|
||||||
#define GLUE_C_CHARACTER_SELECTION_HPP
|
#define GLUE_C_CHARACTER_SELECTION_HPP
|
||||||
|
|
||||||
|
#include "glue/CharacterSelectionDisplay.hpp"
|
||||||
#include "net/Types.hpp"
|
#include "net/Types.hpp"
|
||||||
#include <storm/Array.hpp>
|
#include <storm/Array.hpp>
|
||||||
|
|
||||||
class CCharacterComponent;
|
|
||||||
class CM2Model;
|
|
||||||
class CSimpleModelFFX;
|
class CSimpleModelFFX;
|
||||||
|
|
||||||
struct CharacterSelectionDisplay {
|
|
||||||
CHARACTER_INFO info;
|
|
||||||
CCharacterComponent* component = nullptr;
|
|
||||||
CM2Model* petModel = nullptr;
|
|
||||||
// TODO
|
|
||||||
};
|
|
||||||
|
|
||||||
class CCharacterSelection {
|
class CCharacterSelection {
|
||||||
public:
|
public:
|
||||||
// Static variables
|
// Static variables
|
||||||
|
|||||||
@ -148,7 +148,7 @@ void CGlueMgr::EnterWorld() {
|
|||||||
|
|
||||||
// Validate character flags
|
// Validate character flags
|
||||||
|
|
||||||
auto flags = CGlueMgr::m_characterInfo->info.flags;
|
auto flags = CGlueMgr::m_characterInfo->m_info.flags;
|
||||||
|
|
||||||
if (flags & 0x4) {
|
if (flags & 0x4) {
|
||||||
auto errorToken = ClientServices::GetErrorToken(84);
|
auto errorToken = ClientServices::GetErrorToken(84);
|
||||||
@ -173,7 +173,7 @@ void CGlueMgr::EnterWorld() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & 0x2000000)) {
|
if (!(flags & 0x2000000)) {
|
||||||
if (NameNeedsDeclension(CURRENT_LANGUAGE, CGlueMgr::m_characterInfo->info.name)) {
|
if (NameNeedsDeclension(CURRENT_LANGUAGE, CGlueMgr::m_characterInfo->m_info.name)) {
|
||||||
FrameScript_SignalEvent(24, nullptr);
|
FrameScript_SignalEvent(24, nullptr);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -182,8 +182,8 @@ void CGlueMgr::EnterWorld() {
|
|||||||
|
|
||||||
// Validate expansion
|
// Validate expansion
|
||||||
|
|
||||||
auto raceRec = g_chrRacesDB.GetRecord(character->info.raceID);
|
auto raceRec = g_chrRacesDB.GetRecord(character->m_info.raceID);
|
||||||
auto classRec = g_chrClassesDB.GetRecord(character->info.classID);
|
auto classRec = g_chrClassesDB.GetRecord(character->m_info.classID);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!raceRec
|
!raceRec
|
||||||
@ -203,7 +203,7 @@ void CGlueMgr::EnterWorld() {
|
|||||||
// TODO g_lastCharacterIndex->Set(indexStr, 1, 0, 0, 1);
|
// TODO g_lastCharacterIndex->Set(indexStr, 1, 0, 0, 1);
|
||||||
|
|
||||||
ClientServices::SetAccountName(CGlueMgr::m_accountName);
|
ClientServices::SetAccountName(CGlueMgr::m_accountName);
|
||||||
ClientServices::SetCharacterInfo(&CGlueMgr::m_characterInfo->info);
|
ClientServices::SetCharacterInfo(&CGlueMgr::m_characterInfo->m_info);
|
||||||
|
|
||||||
// TODO game tip
|
// TODO game tip
|
||||||
// TODO loading screen
|
// TODO loading screen
|
||||||
@ -724,13 +724,13 @@ void CGlueMgr::PollEnterWorld() {
|
|||||||
// TODO SI Logic
|
// TODO SI Logic
|
||||||
|
|
||||||
// TODO TLS shenanigans with guid
|
// TODO TLS shenanigans with guid
|
||||||
ClientServices::Connection()->CharacterLogin(CGlueMgr::m_characterInfo->info.guid, 0);
|
ClientServices::Connection()->CharacterLogin(CGlueMgr::m_characterInfo->m_info.guid, 0);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t mapId = CGlueMgr::m_characterInfo->info.mapID;
|
uint32_t mapId = CGlueMgr::m_characterInfo->m_info.mapID;
|
||||||
C3Vector position = CGlueMgr::m_characterInfo->info.position;
|
C3Vector position = CGlueMgr::m_characterInfo->m_info.position;
|
||||||
|
|
||||||
// TODO TLS shenanigans with guid
|
// TODO TLS shenanigans with guid
|
||||||
// TODO first login logic (play intro M2?)
|
// TODO first login logic (play intro M2?)
|
||||||
|
|||||||
49
src/glue/CharacterSelectionDisplay.cpp
Normal file
49
src/glue/CharacterSelectionDisplay.cpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#include "glue/CharacterSelectionDisplay.hpp"
|
||||||
|
#include "db/Db.hpp"
|
||||||
|
#include "glue/CCharacterSelection.hpp"
|
||||||
|
#include "component/CCharacterComponent.hpp"
|
||||||
|
#include "object/client/Player_C.hpp"
|
||||||
|
#include "ui/CSimpleModelFFX.hpp"
|
||||||
|
|
||||||
|
void CharacterSelectionDisplay::CreateModelData() {
|
||||||
|
auto modelData = Player_C_GetModelName(this->m_info.raceID, this->m_info.sexID);
|
||||||
|
|
||||||
|
if (!modelData || !modelData->m_modelName) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_component = CCharacterComponent::AllocComponent();
|
||||||
|
|
||||||
|
ComponentData componentData = {};
|
||||||
|
componentData.raceID = this->m_info.raceID;
|
||||||
|
componentData.sexID = this->m_info.sexID;
|
||||||
|
componentData.skinColorID = this->m_info.skinColorID;
|
||||||
|
componentData.faceID = this->m_info.faceID;
|
||||||
|
componentData.hairStyleID = this->m_info.hairStyleID;
|
||||||
|
componentData.hairColorID = this->m_info.hairColorID;
|
||||||
|
componentData.facialHairStyleID = this->m_info.facialHairStyleID;
|
||||||
|
|
||||||
|
auto scene = CCharacterSelection::s_modelFrame->GetScene();
|
||||||
|
auto model = scene->CreateModel(modelData->m_modelName, 0);
|
||||||
|
|
||||||
|
componentData.flags |= 0x2;
|
||||||
|
componentData.model = model;
|
||||||
|
|
||||||
|
this->m_component->Init(&componentData, nullptr);
|
||||||
|
|
||||||
|
// TODO lighting callback/arg
|
||||||
|
|
||||||
|
this->m_component->m_data.model->SetBoneSequence(
|
||||||
|
0xFFFFFFFF,
|
||||||
|
0,
|
||||||
|
0xFFFFFFFF,
|
||||||
|
0,
|
||||||
|
1.0f,
|
||||||
|
1,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
|
// TODO load pet model
|
||||||
|
|
||||||
|
CCharacterSelection::s_characterCount++;
|
||||||
|
}
|
||||||
21
src/glue/CharacterSelectionDisplay.hpp
Normal file
21
src/glue/CharacterSelectionDisplay.hpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef GLUE_CHARACTER_SELECTION_DISPLAY_HPP
|
||||||
|
#define GLUE_CHARACTER_SELECTION_DISPLAY_HPP
|
||||||
|
|
||||||
|
#include "net/Types.hpp"
|
||||||
|
|
||||||
|
class CCharacterComponent;
|
||||||
|
class CM2Model;
|
||||||
|
|
||||||
|
class CharacterSelectionDisplay {
|
||||||
|
public:
|
||||||
|
// Member variables
|
||||||
|
CHARACTER_INFO m_info;
|
||||||
|
CCharacterComponent* m_component = nullptr;
|
||||||
|
CM2Model* m_petModel = nullptr;
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
// Member functions
|
||||||
|
void CreateModelData();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -93,26 +93,26 @@ int32_t Script_GetCharacterInfo(lua_State* L) {
|
|||||||
// Character exists at index
|
// Character exists at index
|
||||||
|
|
||||||
auto& display = CCharacterSelection::s_characterList[index];
|
auto& display = CCharacterSelection::s_characterList[index];
|
||||||
auto sex = static_cast<UNIT_SEX>(display.info.sexID);
|
auto sex = static_cast<UNIT_SEX>(display.m_info.sexID);
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
lua_pushstring(L, display.info.name);
|
lua_pushstring(L, display.m_info.name);
|
||||||
|
|
||||||
// Race
|
// Race
|
||||||
auto raceRec = g_chrRacesDB.GetRecord(display.info.raceID);
|
auto raceRec = g_chrRacesDB.GetRecord(display.m_info.raceID);
|
||||||
auto raceName = CGUnit_C::GetDisplayRaceNameFromRecord(raceRec, sex, nullptr);
|
auto raceName = CGUnit_C::GetDisplayRaceNameFromRecord(raceRec, sex, nullptr);
|
||||||
lua_pushstring(L, raceName ? raceName : "");
|
lua_pushstring(L, raceName ? raceName : "");
|
||||||
|
|
||||||
// Class
|
// Class
|
||||||
auto classRec = g_chrClassesDB.GetRecord(display.info.classID);
|
auto classRec = g_chrClassesDB.GetRecord(display.m_info.classID);
|
||||||
auto className = CGUnit_C::GetDisplayClassNameFromRecord(classRec, sex, nullptr);
|
auto className = CGUnit_C::GetDisplayClassNameFromRecord(classRec, sex, nullptr);
|
||||||
lua_pushstring(L, className ? className : "");
|
lua_pushstring(L, className ? className : "");
|
||||||
|
|
||||||
// Level
|
// Level
|
||||||
lua_pushnumber(L, display.info.experienceLevel);
|
lua_pushnumber(L, display.m_info.experienceLevel);
|
||||||
|
|
||||||
// Zone
|
// Zone
|
||||||
auto areaRec = g_areaTableDB.GetRecord(display.info.zoneID);
|
auto areaRec = g_areaTableDB.GetRecord(display.m_info.zoneID);
|
||||||
if (areaRec) {
|
if (areaRec) {
|
||||||
lua_pushstring(L, areaRec->m_areaName);
|
lua_pushstring(L, areaRec->m_areaName);
|
||||||
} else {
|
} else {
|
||||||
@ -120,19 +120,19 @@ int32_t Script_GetCharacterInfo(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sex
|
// Sex
|
||||||
lua_pushnumber(L, g_glueFrameScriptGenders[display.info.sexID]);
|
lua_pushnumber(L, g_glueFrameScriptGenders[display.m_info.sexID]);
|
||||||
|
|
||||||
// Ghost
|
// Ghost
|
||||||
lua_pushboolean(L, display.info.flags & 0x2000);
|
lua_pushboolean(L, display.m_info.flags & 0x2000);
|
||||||
|
|
||||||
// Paid class change
|
// Paid class change
|
||||||
lua_pushboolean(L, display.info.customizeFlags & 0x1);
|
lua_pushboolean(L, display.m_info.customizeFlags & 0x1);
|
||||||
|
|
||||||
// Paid race change
|
// Paid race change
|
||||||
lua_pushboolean(L, display.info.customizeFlags & 0x100000);
|
lua_pushboolean(L, display.m_info.customizeFlags & 0x100000);
|
||||||
|
|
||||||
// Paid faction change
|
// Paid faction change
|
||||||
lua_pushboolean(L, display.info.customizeFlags & 0x10000);
|
lua_pushboolean(L, display.m_info.customizeFlags & 0x10000);
|
||||||
|
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
@ -224,10 +224,10 @@ int32_t Script_GetSelectBackgroundModel(lua_State* L) {
|
|||||||
|
|
||||||
// Class background
|
// Class background
|
||||||
|
|
||||||
auto classID = character->info.classID;
|
auto classID = character->m_info.classID;
|
||||||
|
|
||||||
if (classID == 6) {
|
if (classID == 6) {
|
||||||
auto classRec = g_chrClassesDB.GetRecord(character->info.classID);
|
auto classRec = g_chrClassesDB.GetRecord(character->m_info.classID);
|
||||||
|
|
||||||
if (classRec) {
|
if (classRec) {
|
||||||
lua_pushstring(L, classRec->m_filename);
|
lua_pushstring(L, classRec->m_filename);
|
||||||
@ -240,7 +240,7 @@ int32_t Script_GetSelectBackgroundModel(lua_State* L) {
|
|||||||
|
|
||||||
// Race background
|
// Race background
|
||||||
|
|
||||||
auto raceID = character->info.raceID;
|
auto raceID = character->m_info.raceID;
|
||||||
|
|
||||||
if (raceID == 7) {
|
if (raceID == 7) {
|
||||||
raceID = 3;
|
raceID = 3;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user