mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 00:14:22 +00:00
Implement LegoTexturePresenter::Read and Store (#641)
* LegoTexturePresenter::Read * Implement LegoTexturePresenter::Store * Rename * Fix naming
This commit is contained in:

committed by
GitHub

parent
fb800db862
commit
9e2f37e7ca
@@ -1,8 +1,8 @@
|
||||
#ifndef ACT1STATE_H
|
||||
#define ACT1STATE_H
|
||||
|
||||
#include "legonamedtexture.h"
|
||||
#include "legostate.h"
|
||||
#include "legoutil.h"
|
||||
#include "roi/legoroi.h"
|
||||
|
||||
// VTABLE: LEGO1 0x100d7028
|
||||
@@ -84,39 +84,39 @@ public:
|
||||
protected:
|
||||
MxS32* m_unk0x008; // 0x008
|
||||
// FIXME: count for m_unk0x008
|
||||
MxS16 m_unk0x00c; // 0x00c
|
||||
undefined2 m_unk0x00e; // 0x00e
|
||||
undefined2 m_unk0x010; // 0x010
|
||||
undefined m_unk0x012; // 0x012
|
||||
MxS32 m_unk0x014; // 0x014
|
||||
MxU32 m_unk0x018; // 0x018
|
||||
MxU16 m_unk0x01c; // 0x01c
|
||||
undefined m_unk0x01e; // 0x01e
|
||||
undefined m_unk0x01f; // 0x01f
|
||||
undefined m_unk0x020; // 0x020
|
||||
undefined m_unk0x021; // 0x021
|
||||
undefined m_unk0x022; // 0x022
|
||||
undefined m_unk0x023; // 0x023
|
||||
NamedPlane m_unk0x024; // 0x024
|
||||
NamedPlane m_unk0x070; // 0x070
|
||||
NamedPlane m_unk0x0bc; // 0x0bc
|
||||
NamedPlane m_unk0x108; // 0x108
|
||||
NamedTexture* m_unk0x154; // 0x154
|
||||
NamedTexture* m_unk0x158; // 0x158
|
||||
NamedTexture* m_unk0x15c; // 0x15c
|
||||
MxCore* m_unk0x160; // 0x160
|
||||
NamedPlane m_unk0x164; // 0x164
|
||||
NamedTexture* m_unk0x1b0; // 0x1b0
|
||||
NamedTexture* m_unk0x1b4; // 0x1b4
|
||||
MxCore* m_unk0x1b8; // 0x1b8
|
||||
NamedPlane m_unk0x1bc; // 0x1bc
|
||||
NamedTexture* m_unk0x208; // 0x208
|
||||
MxCore* m_unk0x20c; // 0x20c
|
||||
NamedPlane m_unk0x210; // 0x210
|
||||
NamedTexture* m_unk0x25c; // 0x25c
|
||||
NamedTexture* m_unk0x260; // 0x260
|
||||
NamedTexture* m_unk0x264; // 0x264
|
||||
MxCore* m_unk0x268; // 0x268
|
||||
MxS16 m_unk0x00c; // 0x00c
|
||||
undefined2 m_unk0x00e; // 0x00e
|
||||
undefined2 m_unk0x010; // 0x010
|
||||
undefined m_unk0x012; // 0x012
|
||||
MxS32 m_unk0x014; // 0x014
|
||||
MxU32 m_unk0x018; // 0x018
|
||||
MxU16 m_unk0x01c; // 0x01c
|
||||
undefined m_unk0x01e; // 0x01e
|
||||
undefined m_unk0x01f; // 0x01f
|
||||
undefined m_unk0x020; // 0x020
|
||||
undefined m_unk0x021; // 0x021
|
||||
undefined m_unk0x022; // 0x022
|
||||
undefined m_unk0x023; // 0x023
|
||||
NamedPlane m_unk0x024; // 0x024
|
||||
NamedPlane m_unk0x070; // 0x070
|
||||
NamedPlane m_unk0x0bc; // 0x0bc
|
||||
NamedPlane m_unk0x108; // 0x108
|
||||
LegoNamedTexture* m_unk0x154; // 0x154
|
||||
LegoNamedTexture* m_unk0x158; // 0x158
|
||||
LegoNamedTexture* m_unk0x15c; // 0x15c
|
||||
MxCore* m_unk0x160; // 0x160
|
||||
NamedPlane m_unk0x164; // 0x164
|
||||
LegoNamedTexture* m_unk0x1b0; // 0x1b0
|
||||
LegoNamedTexture* m_unk0x1b4; // 0x1b4
|
||||
MxCore* m_unk0x1b8; // 0x1b8
|
||||
NamedPlane m_unk0x1bc; // 0x1bc
|
||||
LegoNamedTexture* m_unk0x208; // 0x208
|
||||
MxCore* m_unk0x20c; // 0x20c
|
||||
NamedPlane m_unk0x210; // 0x210
|
||||
LegoNamedTexture* m_unk0x25c; // 0x25c
|
||||
LegoNamedTexture* m_unk0x260; // 0x260
|
||||
LegoNamedTexture* m_unk0x264; // 0x264
|
||||
MxCore* m_unk0x268; // 0x268
|
||||
};
|
||||
|
||||
// FUNCTION: LEGO1 0x10033a70
|
||||
|
27
LEGO1/lego/legoomni/include/legonamedtexture.h
Normal file
27
LEGO1/lego/legoomni/include/legonamedtexture.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef LEGONAMEDTEXTURE_H
|
||||
#define LEGONAMEDTEXTURE_H
|
||||
|
||||
#include "misc/legotexture.h"
|
||||
#include "mxstring.h"
|
||||
|
||||
// SIZE 0x14
|
||||
class LegoNamedTexture {
|
||||
public:
|
||||
LegoNamedTexture(const char* p_name, LegoTexture* p_texture)
|
||||
{
|
||||
m_name = p_name;
|
||||
m_texture = p_texture;
|
||||
}
|
||||
~LegoNamedTexture() { delete m_texture; }
|
||||
|
||||
// FUNCTION: LEGO1 0x1003f920
|
||||
const MxString* GetName() const { return &m_name; }
|
||||
|
||||
LegoTexture* GetTexture() { return m_texture; }
|
||||
|
||||
private:
|
||||
MxString m_name; // 0x00
|
||||
LegoTexture* m_texture; // 0x04
|
||||
};
|
||||
|
||||
#endif // LEGONAMEDTEXTURE_H
|
84
LEGO1/lego/legoomni/include/legonamedtexturelist.h
Normal file
84
LEGO1/lego/legoomni/include/legonamedtexturelist.h
Normal file
@@ -0,0 +1,84 @@
|
||||
#ifndef LEGONAMEDTEXTURELIST_H
|
||||
#define LEGONAMEDTEXTURELIST_H
|
||||
|
||||
#include "legonamedtexture.h"
|
||||
#include "mxlist.h"
|
||||
|
||||
// VTABLE: LEGO1 0x100d8110
|
||||
// class MxCollection<LegoNamedTexture *>
|
||||
|
||||
// VTABLE: LEGO1 0x100d8128
|
||||
// class MxList<LegoNamedTexture *>
|
||||
|
||||
// VTABLE: LEGO1 0x100d8140
|
||||
// class MxPtrList<LegoNamedTexture>
|
||||
|
||||
// VTABLE: LEGO1 0x100d8158
|
||||
// SIZE 0x18
|
||||
class LegoNamedTextureList : public MxPtrList<LegoNamedTexture> {
|
||||
public:
|
||||
LegoNamedTextureList() : MxPtrList<LegoNamedTexture>(TRUE) {}
|
||||
|
||||
// SYNTHETIC: LEGO1 0x1004f040
|
||||
// LegoNamedTextureList::`scalar deleting destructor'
|
||||
};
|
||||
|
||||
// VTABLE: LEGO1 0x100d8170
|
||||
// class MxListCursor<LegoNamedTexture *>
|
||||
|
||||
// VTABLE: LEGO1 0x100d8188
|
||||
// class MxPtrListCursor<LegoNamedTexture>
|
||||
|
||||
// VTABLE: LEGO1 0x100d81a0
|
||||
// SIZE 0x10
|
||||
class LegoNamedTextureListCursor : public MxPtrListCursor<LegoNamedTexture> {
|
||||
public:
|
||||
LegoNamedTextureListCursor(LegoNamedTextureList* p_list) : MxPtrListCursor<LegoNamedTexture>(p_list) {}
|
||||
};
|
||||
|
||||
// SYNTHETIC: LEGO1 0x1004f500
|
||||
// LegoNamedTextureListCursor::`scalar deleting destructor'
|
||||
|
||||
// FUNCTION: LEGO1 0x1004f570
|
||||
// MxPtrListCursor<LegoNamedTexture>::~MxPtrListCursor<LegoNamedTexture>
|
||||
|
||||
// SYNTHETIC: LEGO1 0x1004f5c0
|
||||
// MxListCursor<LegoNamedTexture *>::`scalar deleting destructor'
|
||||
|
||||
// SYNTHETIC: LEGO1 0x1004f630
|
||||
// MxPtrListCursor<LegoNamedTexture>::`scalar deleting destructor'
|
||||
|
||||
// FUNCTION: LEGO1 0x1004f6a0
|
||||
// MxListCursor<LegoNamedTexture *>::~MxListCursor<LegoNamedTexture *>
|
||||
|
||||
// FUNCTION: LEGO1 0x1004f6f0
|
||||
// LegoNamedTextureListCursor::~LegoNamedTextureListCursor
|
||||
|
||||
// TEMPLATE: LEGO1 0x1004eec0
|
||||
// MxCollection<LegoNamedTexture *>::Compare
|
||||
|
||||
// TEMPLATE: LEGO1 0x1004eed0
|
||||
// MxCollection<LegoNamedTexture *>::~MxCollection<LegoNamedTexture *>
|
||||
|
||||
// TEMPLATE: LEGO1 0x1004ef20
|
||||
// MxCollection<LegoNamedTexture *>::Destroy
|
||||
|
||||
// TEMPLATE: LEGO1 0x1004ef30
|
||||
// MxList<LegoNamedTexture *>::~MxList<LegoNamedTexture *>
|
||||
|
||||
// TEMPLATE: LEGO1 0x1004efc0
|
||||
// MxPtrList<LegoNamedTexture>::Destroy
|
||||
|
||||
// TEMPLATE: LEGO1 0x1004f0b0
|
||||
// MxPtrList<LegoNamedTexture>::~MxPtrList<LegoNamedTexture>
|
||||
|
||||
// SYNTHETIC: LEGO1 0x1004f100
|
||||
// MxCollection<LegoNamedTexture *>::`scalar deleting destructor'
|
||||
|
||||
// SYNTHETIC: LEGO1 0x1004f170
|
||||
// MxList<LegoNamedTexture *>::`scalar deleting destructor'
|
||||
|
||||
// SYNTHETIC: LEGO1 0x1004f220
|
||||
// MxPtrList<LegoNamedTexture>::`scalar deleting destructor'
|
||||
|
||||
#endif // LEGONAMEDTEXTURELIST_H
|
@@ -1,19 +1,26 @@
|
||||
#ifndef LEGOTEXTUREINFO_H
|
||||
#define LEGOTEXTUREINFO_H
|
||||
|
||||
#include "misc/legotypes.h"
|
||||
#include "tgl/tgl.h"
|
||||
|
||||
#include <d3drmobj.h>
|
||||
#include <ddraw.h>
|
||||
|
||||
class LegoTexture;
|
||||
|
||||
// SIZE 0x10
|
||||
struct LegoTextureInfo {
|
||||
class LegoTextureInfo {
|
||||
public:
|
||||
LegoTextureInfo();
|
||||
~LegoTextureInfo();
|
||||
|
||||
static LegoTextureInfo* Create(const char* p_name, LegoTexture* p_texture);
|
||||
static BOOL SetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo* p_textureInfo);
|
||||
|
||||
LegoResult FUN_10066010(LegoU8* p_bits);
|
||||
|
||||
// private:
|
||||
char* m_name; // 0x00
|
||||
LPDIRECTDRAWSURFACE m_surface; // 0x04
|
||||
LPDIRECTDRAWPALETTE m_palette; // 0x08
|
||||
|
@@ -1,13 +1,14 @@
|
||||
#ifndef LEGOTEXTUREPRESENTER_H
|
||||
#define LEGOTEXTUREPRESENTER_H
|
||||
|
||||
#include "legonamedtexturelist.h"
|
||||
#include "mxmediapresenter.h"
|
||||
|
||||
// VTABLE: LEGO1 0x100d4d90
|
||||
// SIZE 0x54 (from inlined construction at 0x10009bb5)
|
||||
class LegoTexturePresenter : public MxMediaPresenter {
|
||||
public:
|
||||
LegoTexturePresenter() : m_textureData(NULL) {}
|
||||
LegoTexturePresenter() : m_textures(NULL) {}
|
||||
~LegoTexturePresenter() override;
|
||||
|
||||
// FUNCTION: LEGO1 0x1000ce50
|
||||
@@ -31,10 +32,10 @@ public:
|
||||
// LegoTexturePresenter::`scalar deleting destructor'
|
||||
|
||||
MxResult Read(MxDSChunk& p_chunk);
|
||||
void FUN_1004f290();
|
||||
MxResult Store();
|
||||
|
||||
private:
|
||||
MxDSChunk* m_textureData; // 0x54
|
||||
LegoNamedTextureList* m_textures; // 0x50
|
||||
};
|
||||
|
||||
#endif // LEGOTEXTUREPRESENTER_H
|
||||
|
@@ -13,23 +13,7 @@
|
||||
class MxAtomId;
|
||||
class LegoEntity;
|
||||
class LegoAnimPresenter;
|
||||
|
||||
class LegoTexture;
|
||||
|
||||
// SIZE 0x14
|
||||
class NamedTexture {
|
||||
public:
|
||||
~NamedTexture() { delete m_texture; }
|
||||
|
||||
// FUNCTION: LEGO1 0x1003f920
|
||||
const MxString* GetName() const { return &m_name; }
|
||||
|
||||
LegoTexture* GetTexture() { return m_texture; }
|
||||
|
||||
private:
|
||||
MxString m_name; // 0x00
|
||||
LegoTexture* m_texture; // 0x04
|
||||
};
|
||||
class LegoNamedTexture;
|
||||
|
||||
void FUN_1003e050(LegoAnimPresenter* p_presenter);
|
||||
Extra::ActionType MatchActionString(const char*);
|
||||
@@ -42,9 +26,9 @@ void SetAppCursor(WPARAM p_wparam);
|
||||
MxBool FUN_1003ef60();
|
||||
MxBool RemoveFromWorld(MxAtomId& p_atomId1, MxS32 p_id1, MxAtomId& p_atomId2, MxS32 p_id2);
|
||||
void SetLightPosition(MxU32);
|
||||
NamedTexture* ReadNamedTexture(LegoFile* p_file);
|
||||
LegoNamedTexture* ReadNamedTexture(LegoFile* p_file);
|
||||
void FUN_1003f540(LegoFile* p_file, const char* p_filename);
|
||||
void WriteNamedTexture(LegoFile* p_file, NamedTexture* p_texture);
|
||||
void WriteNamedTexture(LegoFile* p_file, LegoNamedTexture* p_texture);
|
||||
|
||||
// SYNTHETIC: LEGO1 0x10034b40
|
||||
// LegoTexture::`scalar deleting destructor'
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#include "act1state.h"
|
||||
|
||||
#include "legoutil.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(Act1State, 0x26c)
|
||||
DECOMP_SIZE_ASSERT(Act1State::NamedPlane, 0x4c)
|
||||
|
||||
|
@@ -151,3 +151,18 @@ done:
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10065f60
|
||||
BOOL LegoTextureInfo::SetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo* p_textureInfo)
|
||||
{
|
||||
TglImpl::MeshImpl::MeshData* data = ((TglImpl::MeshImpl*) pMesh)->ImplementationData();
|
||||
data->groupMesh->SetGroupTexture(data->groupIndex, p_textureInfo->m_texture);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10066010
|
||||
LegoResult LegoTextureInfo::FUN_10066010(LegoU8* p_bits)
|
||||
{
|
||||
// TODO
|
||||
return SUCCESS;
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "legoutil.h"
|
||||
|
||||
#include "legoinputmanager.h"
|
||||
#include "legonamedtexture.h"
|
||||
#include "legoomni.h"
|
||||
#include "legoworld.h"
|
||||
#include "legoworldlist.h"
|
||||
@@ -13,8 +14,6 @@
|
||||
#include <process.h>
|
||||
#include <string.h>
|
||||
|
||||
DECOMP_SIZE_ASSERT(NamedTexture, 0x14)
|
||||
|
||||
// STUB: LEGO1 0x1003e050
|
||||
void FUN_1003e050(LegoAnimPresenter* p_presenter)
|
||||
{
|
||||
@@ -297,7 +296,7 @@ void SetLightPosition(MxU32)
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1003f3b0
|
||||
NamedTexture* ReadNamedTexture(LegoFile* p_file)
|
||||
LegoNamedTexture* ReadNamedTexture(LegoFile* p_file)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -308,7 +307,7 @@ void FUN_1003f540(LegoFile* p_file, const char* p_filename)
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1003f8a0
|
||||
void WriteNamedTexture(LegoFile* p_file, NamedTexture* p_texture)
|
||||
void WriteNamedTexture(LegoFile* p_file, LegoNamedTexture* p_texture)
|
||||
{
|
||||
p_file->FUN_10006030(*p_texture->GetName());
|
||||
p_texture->GetTexture()->Write(p_file);
|
||||
|
@@ -227,7 +227,7 @@ MxResult LegoWorldPresenter::LoadWorld(char* p_worldName, LegoWorld* p_world)
|
||||
|
||||
LegoTexturePresenter texturePresenter;
|
||||
if (texturePresenter.Read(chunk) == SUCCESS) {
|
||||
texturePresenter.FUN_1004f290();
|
||||
texturePresenter.Store();
|
||||
}
|
||||
|
||||
delete[] buff;
|
||||
|
@@ -2,9 +2,14 @@
|
||||
|
||||
#include "legoomni.h"
|
||||
#include "legovideomanager.h"
|
||||
#include "misc/legocontainer.h"
|
||||
#include "misc/legoimage.h"
|
||||
#include "misc/legostorage.h"
|
||||
#include "mxcompositepresenter.h"
|
||||
|
||||
DECOMP_SIZE_ASSERT(LegoTexturePresenter, 0x54)
|
||||
DECOMP_SIZE_ASSERT(LegoNamedTexture, 0x14)
|
||||
DECOMP_SIZE_ASSERT(LegoNamedTextureList, 0x18)
|
||||
|
||||
// FUNCTION: LEGO1 0x1004eb40
|
||||
LegoTexturePresenter::~LegoTexturePresenter()
|
||||
@@ -19,17 +24,93 @@ MxResult LegoTexturePresenter::AddToManager()
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1004ebd0
|
||||
// FUNCTION: LEGO1 0x1004ebd0
|
||||
MxResult LegoTexturePresenter::Read(MxDSChunk& p_chunk)
|
||||
{
|
||||
// TODO
|
||||
return SUCCESS;
|
||||
MxResult result = FAILURE;
|
||||
LegoMemory storage(p_chunk.GetData());
|
||||
LegoChar* textureName = NULL;
|
||||
LegoS32 hardwareMode = VideoManager()->GetDirect3D()->AssignedDevice()->GetHardwareMode();
|
||||
|
||||
m_textures = new LegoNamedTextureList();
|
||||
|
||||
LegoU32 numTextures, i;
|
||||
if (storage.Read(&numTextures, sizeof(numTextures)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
for (i = 0; i < numTextures; i++) {
|
||||
LegoU32 textureNameLength;
|
||||
LegoTexture* texture;
|
||||
LegoNamedTexture* namedTexture;
|
||||
|
||||
if (storage.Read(&textureNameLength, sizeof(textureNameLength)) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
textureName = new LegoChar[textureNameLength + 1];
|
||||
if (storage.Read(textureName, textureNameLength) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
textureName[textureNameLength] = '\0';
|
||||
strlwr(textureName);
|
||||
|
||||
texture = new LegoTexture();
|
||||
if (texture->Read(&storage, hardwareMode) != SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
namedTexture = new LegoNamedTexture(textureName, texture);
|
||||
m_textures->Append(namedTexture);
|
||||
|
||||
delete[] textureName;
|
||||
textureName = NULL;
|
||||
}
|
||||
|
||||
result = SUCCESS;
|
||||
|
||||
done:
|
||||
if (textureName != NULL) {
|
||||
delete[] textureName;
|
||||
}
|
||||
if (result != SUCCESS && m_textures != NULL) {
|
||||
delete m_textures;
|
||||
m_textures = NULL;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1004f290
|
||||
void LegoTexturePresenter::FUN_1004f290()
|
||||
// FUNCTION: LEGO1 0x1004f290
|
||||
MxResult LegoTexturePresenter::Store()
|
||||
{
|
||||
// TODO
|
||||
LegoNamedTextureListCursor cursor(m_textures);
|
||||
LegoNamedTexture* namedTexture;
|
||||
VideoManager();
|
||||
|
||||
while (cursor.Next(namedTexture)) {
|
||||
LegoTexture* texture = namedTexture->GetTexture();
|
||||
LegoTextureInfo* textureInfo = TextureContainer()->Get(namedTexture->GetName()->GetData());
|
||||
|
||||
if (textureInfo == NULL) {
|
||||
textureInfo = LegoTextureInfo::Create(namedTexture->GetName()->GetData(), texture);
|
||||
|
||||
if (textureInfo != NULL) {
|
||||
TextureContainer()->Add(namedTexture->GetName()->GetData(), textureInfo);
|
||||
}
|
||||
}
|
||||
else {
|
||||
textureInfo->FUN_10066010(texture->GetImage()->GetBits());
|
||||
}
|
||||
}
|
||||
|
||||
if (m_textures != NULL) {
|
||||
delete m_textures;
|
||||
}
|
||||
|
||||
m_textures = NULL;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x1004fc60
|
||||
|
Reference in New Issue
Block a user