mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-02 00:32:45 +03:00
feat(component): partially implement CCharacterComponent::LoadBaseVariation
This commit is contained in:
parent
bdc76b2b79
commit
421accf989
@ -1,14 +1,20 @@
|
|||||||
#include "component/CCharacterComponent.hpp"
|
#include "component/CCharacterComponent.hpp"
|
||||||
|
#include "component/Texture.hpp"
|
||||||
#include "component/Util.hpp"
|
#include "component/Util.hpp"
|
||||||
#include "db/Db.hpp"
|
#include "db/Db.hpp"
|
||||||
#include "model/CM2Model.hpp"
|
#include "model/CM2Model.hpp"
|
||||||
#include "object/Types.hpp"
|
#include "object/Types.hpp"
|
||||||
#include <storm/Memory.hpp>
|
#include <storm/Memory.hpp>
|
||||||
|
#include <storm/String.hpp>
|
||||||
|
|
||||||
st_race* CCharacterComponent::s_chrVarArray;
|
st_race* CCharacterComponent::s_chrVarArray;
|
||||||
uint32_t CCharacterComponent::s_chrVarArrayLength;
|
uint32_t CCharacterComponent::s_chrVarArrayLength;
|
||||||
|
|
||||||
int32_t s_bInRenderPrep = 0;
|
int32_t s_bInRenderPrep = 0;
|
||||||
|
char* s_pathEnd;
|
||||||
|
char s_path[STORM_MAX_PATH];
|
||||||
|
|
||||||
|
#define TEXTURE_INDEX(section, texture) (3 * section + texture)
|
||||||
|
|
||||||
CCharacterComponent* CCharacterComponent::AllocComponent() {
|
CCharacterComponent* CCharacterComponent::AllocComponent() {
|
||||||
// TODO ObjectAlloc
|
// TODO ObjectAlloc
|
||||||
@ -96,7 +102,38 @@ int32_t CCharacterComponent::ItemsLoaded(int32_t a2) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CCharacterComponent::LoadBaseVariation(COMPONENT_VARIATIONS sectionIndex, int32_t textureIndex, int32_t variationIndex, int32_t colorIndex, COMPONENT_SECTIONS section, const char* a7) {
|
void CCharacterComponent::LoadBaseVariation(COMPONENT_VARIATIONS sectionIndex, int32_t textureIndex, int32_t variationIndex, int32_t colorIndex, COMPONENT_SECTIONS section, const char* a7) {
|
||||||
|
int32_t index = TEXTURE_INDEX(sectionIndex, textureIndex);
|
||||||
|
|
||||||
|
if (this->m_texture[index]) {
|
||||||
|
TextureCacheDestroyTexture(this->m_texture[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto valid = ComponentValidateBase(
|
||||||
|
CCharacterComponent::s_chrVarArray,
|
||||||
|
this->m_data.raceID,
|
||||||
|
this->m_data.sexID,
|
||||||
|
sectionIndex,
|
||||||
|
variationIndex,
|
||||||
|
colorIndex
|
||||||
|
);
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto sectionsRec = this->GetSectionsRecord(sectionIndex, variationIndex, colorIndex, nullptr);
|
||||||
|
|
||||||
|
auto textureName = sectionsRec->m_textureName[textureIndex];
|
||||||
|
|
||||||
|
if (*textureName) {
|
||||||
|
SStrCopy(s_pathEnd, textureName);
|
||||||
|
this->m_texture[index] = TextureCacheCreateTexture(s_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
this->m_sections |= 1 << section;
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
this->m_flags &= ~0x8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCharacterComponent::PrepSections() {
|
void CCharacterComponent::PrepSections() {
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
#include "gx/Texture.hpp"
|
#include "gx/Texture.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
class CACHEENTRY;
|
||||||
class CharSectionsRec;
|
class CharSectionsRec;
|
||||||
class CM2Model;
|
class CM2Model;
|
||||||
|
|
||||||
@ -60,8 +61,10 @@ class CCharacterComponent {
|
|||||||
|
|
||||||
// Member variables
|
// Member variables
|
||||||
uint32_t m_flags = 0x1 | 0x2 | 0x4;
|
uint32_t m_flags = 0x1 | 0x2 | 0x4;
|
||||||
|
uint32_t m_sections = 0xFFFFFFFF;
|
||||||
ComponentData m_data;
|
ComponentData m_data;
|
||||||
HTEXTURE m_baseTexture = nullptr;
|
HTEXTURE m_baseTexture = nullptr;
|
||||||
|
CACHEENTRY* m_texture[NUM_COMPONENT_VARIATIONS * 3] = {};
|
||||||
|
|
||||||
// Member functions
|
// Member functions
|
||||||
void CreateBaseTexture();
|
void CreateBaseTexture();
|
||||||
|
|||||||
9
src/component/Texture.cpp
Normal file
9
src/component/Texture.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#include "component/Texture.hpp"
|
||||||
|
|
||||||
|
CACHEENTRY* TextureCacheCreateTexture(const char* fileName) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextureCacheDestroyTexture(void* texture) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
22
src/component/Texture.hpp
Normal file
22
src/component/Texture.hpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef COMPONENT_TEXTURE_HPP
|
||||||
|
#define COMPONENT_TEXTURE_HPP
|
||||||
|
|
||||||
|
#include <storm/Hash.hpp>
|
||||||
|
|
||||||
|
class CAsyncObject;
|
||||||
|
|
||||||
|
class CACHEENTRY : public TSHashObject<CACHEENTRY, HASHKEY_NONE> {
|
||||||
|
public:
|
||||||
|
// Member variables
|
||||||
|
CAsyncObject* m_asyncObject = nullptr;
|
||||||
|
char m_fileName[128];
|
||||||
|
uint32_t m_refCount = 0;
|
||||||
|
void* m_memHandle = nullptr;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
CACHEENTRY* TextureCacheCreateTexture(const char* fileName);
|
||||||
|
|
||||||
|
void TextureCacheDestroyTexture(void* texture);
|
||||||
|
|
||||||
|
#endif
|
||||||
Loading…
Reference in New Issue
Block a user