feat(component): implement CCharacterComponent::ReplaceHairTexture

This commit is contained in:
fallenoak 2025-10-27 21:15:46 -05:00
parent e794580ea8
commit dd318480f1
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 31 additions and 1 deletions

View File

@ -7,6 +7,7 @@
#include "gx/Texture.hpp"
#include "model/CM2Model.hpp"
#include "object/Types.hpp"
#include "util/CStatus.hpp"
#include <storm/Memory.hpp>
#include <storm/String.hpp>
@ -70,6 +71,7 @@ int32_t s_itemPriority[NUM_ITEM_SLOT][NUM_COMPONENT_SECTIONS] = {
int32_t s_bInRenderPrep = 0;
char* s_pathEnd;
char s_path[STORM_MAX_PATH];
CStatus s_status;
#define TEXTURE_INDEX(section, texture) (3 * section + texture)
@ -78,6 +80,11 @@ CCharacterComponent* CCharacterComponent::AllocComponent() {
return STORM_NEW(CCharacterComponent);
}
HTEXTURE CCharacterComponent::CreateTexture(const char* fileName, CStatus* status) {
auto texFlags = CGxTexFlags(GxTex_LinearMipNearest, 0, 0, 0, 0, 0, 1);
return TextureCreate(fileName, texFlags, status, 0);
}
void CCharacterComponent::Initialize() {
// TODO
@ -841,7 +848,29 @@ void CCharacterComponent::ReplaceExtraSkinTexture(const char* a2) {
}
void CCharacterComponent::ReplaceHairTexture(int32_t hairStyleID, const char* a3) {
// TODO
if (!ComponentValidateBase(
CCharacterComponent::s_chrVarArray,
this->m_data.raceID,
this->m_data.sexID,
VARIATION_HAIR,
hairStyleID,
this->m_data.hairColorID
)) {
return;
}
auto sectionsRec = this->GetSectionsRecord(VARIATION_HAIR, hairStyleID, this->m_data.hairColorID, nullptr);
if (!*sectionsRec->m_textureName[0]) {
return;
}
SStrCopy(s_pathEnd, sectionsRec->m_textureName[0]);
auto hairTexture = CCharacterComponent::CreateTexture(s_path, &s_status);
if (hairTexture) {
this->m_data.model->ReplaceTexture(6, hairTexture);
HandleClose(hairTexture);
}
}
void CCharacterComponent::SetFace(int32_t faceID, bool a3, const char* a4) {

View File

@ -43,6 +43,7 @@ class CCharacterComponent {
// Static functions
static CCharacterComponent* AllocComponent();
static HTEXTURE CreateTexture(const char* fileName, CStatus* status);
static void Initialize();
static void Initialize(EGxTexFormat textureFormat, uint32_t textureLevel, int32_t thread, int32_t compress);
static void InitDbData();