mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-10-26 22:06:06 +03:00
feat(glue): update CCharacterSelection
This commit is contained in:
parent
c98a41a761
commit
57980ba822
@ -148,7 +148,7 @@ void CCharacterCreation::InitCharacterComponent(ComponentData* data, int32_t ran
|
||||
if (CCharacterCreation::m_character) {
|
||||
auto model = CCharacterCreation::m_character->m_data.m_model;
|
||||
if (model->m_attachParent) {
|
||||
// TODO: model->DetachFromParent();
|
||||
model->DetachFromParent();
|
||||
}
|
||||
CCharacterComponent::FreeComponent(CCharacterCreation::m_character);
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "net/Connection.hpp"
|
||||
#include "clientobject/Player_C.hpp"
|
||||
#include "db/Db.hpp"
|
||||
#include "glue/CGlueMgr.hpp"
|
||||
#include "glue/CCharacterComponent.hpp"
|
||||
|
||||
CSimpleModelFFX* CCharacterSelection::m_modelFrame = nullptr;
|
||||
@ -143,6 +144,36 @@ void CCharacterSelection::ShowCharacter() {
|
||||
// Handle hand items
|
||||
|
||||
++CCharacterSelection::m_characterCount;
|
||||
|
||||
// DUPLICATE (goto in the OG)
|
||||
if (character.m_component) {
|
||||
// TODO: info = DayNightGetInfo();
|
||||
float v42;
|
||||
if (character.m_characterInfo.flags & 0x2000) {
|
||||
// FFX::SetEffect(CGlueMgr__m_deathEffect);
|
||||
v42 = 0.15f;
|
||||
} else {
|
||||
// FFX::SetEffect(CGlueMgr__m_glowEffect);
|
||||
v42 = 0.4f;
|
||||
}
|
||||
// *((float *)info + 75) = v42;
|
||||
|
||||
if (CCharacterSelection::m_modelFrame->m_model) {
|
||||
character.m_component->m_data.m_model->AttachToParent(
|
||||
CCharacterSelection::m_modelFrame->m_model,
|
||||
0,
|
||||
nullptr,
|
||||
0);
|
||||
|
||||
if (character.m_petModel) {
|
||||
character.m_petModel->AttachToParent(
|
||||
CCharacterSelection::m_modelFrame->m_model, 1, nullptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: sub_4E6AE0((int)s_charList.m_data[selectionIndex2].m_component, v5);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CCharacterSelection::SetCharFacing(float facing) {
|
||||
@ -164,6 +195,25 @@ void CCharacterSelection::SetCharFacing(float facing) {
|
||||
}
|
||||
|
||||
void CCharacterSelection::ClearCharacterList() {
|
||||
CCharacterSelection::s_characterList.Clear();
|
||||
if (CCharacterSelection::m_modelFrame) {
|
||||
auto model = CCharacterSelection::m_modelFrame->m_model;
|
||||
if (model) {
|
||||
model->DetachAllChildrenById(0);
|
||||
model->DetachAllChildrenById(1);
|
||||
}
|
||||
}
|
||||
|
||||
CCharacterSelection::m_selectionIndex = 0;
|
||||
CCharacterSelection::ShowCharacter();
|
||||
|
||||
FrameScript_SignalEvent(8, "%d", CCharacterSelection::m_selectionIndex + 1);
|
||||
|
||||
if (CCharacterSelection::m_modelFrame) {
|
||||
CCharacterSelection::m_modelFrame->SetCameraByIndex(0);
|
||||
}
|
||||
|
||||
FrameScript_SignalEvent(7, nullptr);
|
||||
}
|
||||
|
||||
void CCharacterSelection::UpdateCharacterList() {
|
||||
@ -200,14 +250,32 @@ void CCharacterSelection::UpdateCharacterList() {
|
||||
} else {
|
||||
CCharacterSelection::m_selectionIndex = 0;
|
||||
CCharacterSelection::ShowCharacter();
|
||||
|
||||
FrameScript_SignalEvent(8, "%d", CCharacterSelection::m_selectionIndex + 1);
|
||||
|
||||
if (CCharacterSelection::m_modelFrame) {
|
||||
// TODO
|
||||
auto model = CCharacterSelection::m_modelFrame->m_model;
|
||||
if (model) {
|
||||
model->DetachAllChildrenById(0);
|
||||
model->DetachAllChildrenById(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
FrameScript_SignalEvent(7, nullptr);
|
||||
}
|
||||
|
||||
void CCharacterSelection::OnGetCharacterList() {
|
||||
CCharacterSelection::s_characterList.Clear();
|
||||
if (CCharacterSelection::m_modelFrame) {
|
||||
auto model = CCharacterSelection::m_modelFrame->m_model;
|
||||
if (model) {
|
||||
model->DetachAllChildrenById(0);
|
||||
model->DetachAllChildrenById(1);
|
||||
}
|
||||
}
|
||||
CGlueMgr::GetCharacterList();
|
||||
}
|
||||
|
||||
uint32_t CCharacterSelection::GetNumCharacters() {
|
||||
return CCharacterSelection::s_characterList.Count();
|
||||
}
|
||||
|
||||
@ -44,6 +44,7 @@ class CCharacterSelection {
|
||||
static void SetCharFacing(float facing);
|
||||
static void ClearCharacterList();
|
||||
static void UpdateCharacterList();
|
||||
static void OnGetCharacterList();
|
||||
static uint32_t GetNumCharacters();
|
||||
};
|
||||
|
||||
|
||||
@ -994,7 +994,7 @@ void CGlueMgr::StatusDialogClick() {
|
||||
case IDLE_ACCOUNT_LOGIN:
|
||||
case IDLE_CHARACTER_LIST: {
|
||||
ClientServices::Connection()->Cancel(2);
|
||||
|
||||
CCharacterSelection::ClearCharacterList();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -479,7 +479,7 @@ void CM2Model::AnimateMT(const C44Matrix* view, const C3Vector& a3, const C3Vect
|
||||
}
|
||||
}
|
||||
|
||||
if (this->m_attachmentBase) {
|
||||
if (this->m_attachList) {
|
||||
this->AnimateAttachmentsMT();
|
||||
}
|
||||
|
||||
@ -493,7 +493,7 @@ void CM2Model::AnimateMTSimple(const C44Matrix* view, const C3Vector& a3, const
|
||||
void CM2Model::AnimateAttachmentsMT() {
|
||||
// TODO: Proper implementation
|
||||
|
||||
for (auto child = this->m_attachmentBase; child; child = child->m_attachmentNext) {
|
||||
for (auto child = this->m_attachList; child; child = child->m_attachNext) {
|
||||
child->m_flag80 = 1;
|
||||
child->m_flag8 = 1;
|
||||
|
||||
@ -586,7 +586,7 @@ void CM2Model::AnimateST() {
|
||||
|
||||
// TODO
|
||||
|
||||
for (auto child = this->m_attachmentBase; child; child = child->m_attachmentNext) {
|
||||
for (auto child = this->m_attachList; child; child = child->m_attachNext) {
|
||||
// TODO: v43
|
||||
child->AnimateST();
|
||||
}
|
||||
@ -647,12 +647,12 @@ uint16_t CM2Model::AttachToParent(CM2Model* parent, uint32_t attachmentId, const
|
||||
this->f_flags = this->f_flags ^ (this->f_flags ^ 0) & 0x40000 | 0x20080;
|
||||
}
|
||||
|
||||
this->m_attachmentPrev = &parent->m_attachmentBase;
|
||||
this->m_attachmentNext = parent->m_attachmentBase;
|
||||
if (parent->m_attachmentBase) {
|
||||
parent->m_attachmentBase->m_attachmentPrev = &this->m_attachmentNext;
|
||||
this->m_attachPrev = &parent->m_attachList;
|
||||
this->m_attachNext = parent->m_attachList;
|
||||
if (parent->m_attachList) {
|
||||
parent->m_attachList->m_attachPrev = &this->m_attachNext;
|
||||
}
|
||||
parent->m_attachmentBase = this;
|
||||
parent->m_attachList = this;
|
||||
|
||||
if (!this->m_loaded || !this->m_flag100) {
|
||||
auto model = parent;
|
||||
@ -700,17 +700,17 @@ void CM2Model::DetachFromScene() {
|
||||
}
|
||||
|
||||
void CM2Model::DetachFromParent() {
|
||||
if (this->m_attachmentPrev) {
|
||||
*this->m_attachmentPrev = this->m_attachmentNext;
|
||||
if (this->m_attachPrev) {
|
||||
*this->m_attachPrev = this->m_attachNext;
|
||||
}
|
||||
|
||||
if (this->m_attachmentNext) {
|
||||
this->m_attachmentNext->m_attachmentPrev = this->m_attachmentPrev;
|
||||
if (this->m_attachNext) {
|
||||
this->m_attachNext->m_attachPrev = this->m_attachPrev;
|
||||
}
|
||||
|
||||
this->f_flags &= ~0x40000u;
|
||||
this->m_attachmentPrev = nullptr;
|
||||
this->m_attachmentNext = nullptr;
|
||||
this->m_attachPrev = nullptr;
|
||||
this->m_attachNext = nullptr;
|
||||
this->m_attachParent = nullptr;
|
||||
this->m_attachmentId = static_cast<uint32_t>(-1);
|
||||
// this->dword174 = 0;
|
||||
@ -723,24 +723,24 @@ void CM2Model::DetachFromParent() {
|
||||
void CM2Model::DetachAllChildrenById(uint32_t id) {
|
||||
CM2Model* attachmentNext = nullptr;
|
||||
|
||||
auto attachmentBase = this->m_attachmentBase;
|
||||
auto attachmentBase = this->m_attachList;
|
||||
if (attachmentBase) {
|
||||
do {
|
||||
attachmentNext = attachmentBase->m_attachmentNext;
|
||||
attachmentNext = attachmentBase->m_attachNext;
|
||||
auto v8 = attachmentNext;
|
||||
if (attachmentBase->m_attachmentId == id) {
|
||||
auto attachmentPrev = attachmentBase->m_attachmentPrev;
|
||||
auto attachmentPrev = attachmentBase->m_attachPrev;
|
||||
if (attachmentPrev) {
|
||||
*attachmentPrev = attachmentBase->m_attachmentNext;
|
||||
*attachmentPrev = attachmentBase->m_attachNext;
|
||||
}
|
||||
auto v5 = attachmentBase->m_attachmentNext;
|
||||
auto v5 = attachmentBase->m_attachNext;
|
||||
if (v5) {
|
||||
v5->m_attachmentPrev = attachmentBase->m_attachmentPrev;
|
||||
v5->m_attachPrev = attachmentBase->m_attachPrev;
|
||||
}
|
||||
attachmentBase->f_flags &= ~0x40000u;
|
||||
attachmentBase->m_attachmentPrev = 0;
|
||||
attachmentBase->m_attachmentNext = 0;
|
||||
attachmentBase->m_attachParent = 0;
|
||||
attachmentBase->m_attachPrev = nullptr;
|
||||
attachmentBase->m_attachNext = nullptr;
|
||||
attachmentBase->m_attachParent = nullptr;
|
||||
attachmentBase->m_attachmentId = -1;
|
||||
// attachmentBase->dword174 = 0;
|
||||
if (--attachmentBase->m_refCount == 0) {
|
||||
@ -1641,7 +1641,7 @@ void CM2Model::SetupLighting() {
|
||||
this->m_lighting.CameraSpace();
|
||||
}
|
||||
|
||||
for (auto model = this->m_attachmentBase; model; model = model->m_attachmentNext) {
|
||||
for (auto model = this->m_attachList; model; model = model->m_attachNext) {
|
||||
model->SetupLighting();
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,9 +89,9 @@ class CM2Model {
|
||||
CM2Model* m_attachParent = nullptr;
|
||||
uint32_t m_attachmentId;
|
||||
uint16_t m_attachmentIndex;
|
||||
CM2Model* m_attachmentBase = nullptr;
|
||||
CM2Model** m_attachmentPrev = nullptr;
|
||||
CM2Model* m_attachmentNext = nullptr;
|
||||
CM2Model* m_attachList = nullptr;
|
||||
CM2Model** m_attachPrev = nullptr;
|
||||
CM2Model* m_attachNext = nullptr;
|
||||
uint32_t m_time = 0;
|
||||
CM2Model** m_drawPrev = nullptr;
|
||||
CM2Model* m_drawNext = nullptr;
|
||||
|
||||
@ -37,15 +37,12 @@ int32_t Script_SetCharSelectBackground(lua_State* L) {
|
||||
}
|
||||
|
||||
int32_t Script_GetCharacterListUpdate(lua_State* L) {
|
||||
// TODO: CCharSelectInfo::ClearCharacterModel();
|
||||
// TODO: CCharSelectInfo::ClearPetModel();
|
||||
CGlueMgr::GetCharacterList();
|
||||
CCharacterSelection::OnGetCharacterList();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t Script_GetNumCharacters(lua_State* L) {
|
||||
lua_pushnumber(L, CCharacterSelection::GetNumCharacters());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user