feat(glue): update Character Selection screen to support switching

This commit is contained in:
VDm 2025-04-05 01:42:43 +04:00
parent bf734b5b20
commit 0c39457ed1
10 changed files with 117 additions and 24 deletions

View file

@ -2,33 +2,48 @@
#include "model/CM2Shared.hpp"
#include "ui/CSimpleModelFFX.hpp"
#include "client/ClientServices.hpp"
#include "client/Client.hpp"
#include "console/CVar.hpp"
#include "net/Connection.hpp"
CSimpleModelFFX* CCharacterSelection::m_modelFrame = nullptr;
uint32_t CCharacterSelection::m_characterCount = 0;
float CCharacterSelection::m_charFacing = 0.0f;
uint32_t CCharacterSelection::m_restrictHuman = 0;
uint32_t CCharacterSelection::m_restrictDwarf = 0;
uint32_t CCharacterSelection::m_restrictGnome = 0;
uint32_t CCharacterSelection::m_restrictNightElf = 0;
uint32_t CCharacterSelection::m_restrictDraenei = 0;
uint32_t CCharacterSelection::m_restrictOrc = 0;
uint32_t CCharacterSelection::m_restrictTroll = 0;
uint32_t CCharacterSelection::m_restrictTauren = 0;
uint32_t CCharacterSelection::m_restrictUndead = 0;
uint32_t CCharacterSelection::m_restrictBloodElf = 0;
TSGrowableArray<CharacterSelectionDisplay> CCharacterSelection::s_characterList;
CSimpleModelFFX* CCharacterSelection::s_modelFrame;
float CCharacterSelection::s_charFacing = 0.0f;
int32_t CCharacterSelection::m_selectionIndex = 0;
void CCharacterSelection::RenderPrep() {
// TODO
}
void CCharacterSelection::SetBackgroundModel(const char* modelPath) {
if (!CCharacterSelection::s_modelFrame || !modelPath || !*modelPath) {
if (!CCharacterSelection::m_modelFrame || !modelPath || !*modelPath) {
return;
}
auto model = CCharacterSelection::s_modelFrame->m_model;
auto model = CCharacterSelection::m_modelFrame->m_model;
// Check if already set
if (model && !SStrCmpI(modelPath, model->m_shared->m_filePath, STORM_MAX_STR)) {
return;
}
CCharacterSelection::s_modelFrame->SetModel(modelPath);
CCharacterSelection::m_modelFrame->SetModel(modelPath);
// TODO BYTE1(CCharacterSelection::m_modelFrame->simplemodelffx_dword510[3]) = 1;
model = CCharacterSelection::s_modelFrame->m_model;
model = CCharacterSelection::m_modelFrame->m_model;
if (model) {
// TODO lighting callback + arg
@ -37,8 +52,18 @@ void CCharacterSelection::SetBackgroundModel(const char* modelPath) {
}
}
void CCharacterSelection::EnumerateCharactersCallback(CHARACTER_INFO& info, void* param) {
auto character = CCharacterSelection::s_characterList.New();
character->m_characterInfo = info;
// TODO: LoadAddOnEnableState(a1 + 8);
}
void CCharacterSelection::ShowCharacter() {
// TODO
}
void CCharacterSelection::SetCharFacing(float facing) {
// TODO:
// TODO
}
void CCharacterSelection::ClearCharacterList() {
@ -46,20 +71,42 @@ void CCharacterSelection::ClearCharacterList() {
void CCharacterSelection::UpdateCharacterList() {
// TODO: ClearAddOnEnableState(0);
// TODO: Proper implementation
auto& received = ClientServices::Connection()->m_characterList;
CCharacterSelection::s_characterList.SetCount(received.Count());
for (uint32_t i = 0; i < received.Count(); ++i) {
CCharacterSelection::s_characterList[i].m_characterInfo = received[i];
}
CCharacterSelection::s_characterList.SetCount(0);
if (CCharacterSelection::GetNumCharacters()) {
int32_t currentIndex = 0;
FrameScript_SignalEvent(8, "%d", currentIndex + 1);
CCharacterSelection::m_restrictHuman = 0;
CCharacterSelection::m_restrictDwarf = 0;
CCharacterSelection::m_restrictGnome = 0;
CCharacterSelection::m_restrictNightElf = 0;
CCharacterSelection::m_restrictDraenei = 0;
CCharacterSelection::m_restrictOrc = 0;
CCharacterSelection::m_restrictTroll = 0;
CCharacterSelection::m_restrictTauren = 0;
CCharacterSelection::m_restrictUndead = 0;
CCharacterSelection::m_restrictBloodElf = 0;
ClientServices::EnumerateCharacters(&CCharacterSelection::EnumerateCharactersCallback, nullptr);
if (CCharacterSelection::s_characterList.Count()) {
// TODO: Apply restrictions (m_restrictHuman, etc)
// TODO: CRealmList::m_preferredCategory = 0;
int32_t selectionIndex = Client::g_lastCharacterIndex->GetInt();
if (selectionIndex < 0 || selectionIndex >= CCharacterSelection::s_characterList.Count()) {
selectionIndex = 0;
}
CCharacterSelection::m_selectionIndex = selectionIndex;
CCharacterSelection::ShowCharacter();
FrameScript_SignalEvent(8, "%d", CCharacterSelection::m_selectionIndex + 1);
} else {
int32_t currentIndex = 0;
FrameScript_SignalEvent(8, "%d", currentIndex + 1);
CCharacterSelection::m_selectionIndex = 0;
CCharacterSelection::ShowCharacter();
FrameScript_SignalEvent(8, "%d", CCharacterSelection::m_selectionIndex + 1);
if (CCharacterSelection::m_modelFrame) {
// TODO
}
}
FrameScript_SignalEvent(7, nullptr);
}

View file

@ -13,13 +13,27 @@ struct CharacterSelectionDisplay {
class CCharacterSelection {
public:
// Static variables
static CSimpleModelFFX* m_modelFrame;
static uint32_t m_characterCount;
static float m_charFacing;
static uint32_t m_restrictHuman;
static uint32_t m_restrictDwarf;
static uint32_t m_restrictGnome;
static uint32_t m_restrictNightElf;
static uint32_t m_restrictDraenei;
static uint32_t m_restrictOrc;
static uint32_t m_restrictTroll;
static uint32_t m_restrictTauren;
static uint32_t m_restrictUndead;
static uint32_t m_restrictBloodElf;
static TSGrowableArray<CharacterSelectionDisplay> s_characterList;
static CSimpleModelFFX* s_modelFrame;
static float s_charFacing;
static int32_t m_selectionIndex;
// Static functions
static void RenderPrep();
static void SetBackgroundModel(const char* modelPath);
static void EnumerateCharactersCallback(CHARACTER_INFO& info, void* param);
static void ShowCharacter();
static void SetCharFacing(float facing);
static void ClearCharacterList();
static void UpdateCharacterList();