Isle
Loading...
Searching...
No Matches
legotexturepresenter.cpp
Go to the documentation of this file.
2
3#include "legovideomanager.h"
4#include "misc.h"
6#include "misc/legoimage.h"
7#include "misc/legostorage.h"
10#include "mxdssubscriber.h"
11
16
17// FUNCTION: LEGO1 0x1004eb40
19{
21}
22
23// FUNCTION: LEGO1 0x1004ebb0
25{
27 return SUCCESS;
28}
29
30// FUNCTION: LEGO1 0x1004ebd0
32{
33 MxResult result = FAILURE;
34 LegoMemory storage(p_chunk.GetData());
35 LegoChar* textureName = NULL;
37
38 m_textures = new LegoNamedTextureList();
39
40 LegoU32 numTextures, i;
41 if (storage.Read(&numTextures, sizeof(numTextures)) != SUCCESS) {
42 goto done;
43 }
44
45 for (i = 0; i < numTextures; i++) {
46 LegoU32 textureNameLength;
47 LegoTexture* texture;
48 LegoNamedTexture* namedTexture;
49
50 if (storage.Read(&textureNameLength, sizeof(textureNameLength)) != SUCCESS) {
51 goto done;
52 }
53
54 textureName = new LegoChar[textureNameLength + 1];
55 if (storage.Read(textureName, textureNameLength) != SUCCESS) {
56 goto done;
57 }
58
59 textureName[textureNameLength] = '\0';
60 strlwr(textureName);
61
62 texture = new LegoTexture();
63 if (texture->Read(&storage, hardwareMode) != SUCCESS) {
64 goto done;
65 }
66
67 namedTexture = new LegoNamedTexture(textureName, texture);
68 m_textures->Append(namedTexture);
69
70 delete[] textureName;
71 textureName = NULL;
72 }
73
74 result = SUCCESS;
75
76done:
77 if (textureName != NULL) {
78 delete[] textureName;
79 }
80 if (result != SUCCESS && m_textures != NULL) {
81 delete m_textures;
82 m_textures = NULL;
83 }
84
85 return result;
86}
87
88// FUNCTION: LEGO1 0x1004f290
90{
91 LegoNamedTextureListCursor cursor(m_textures);
92 LegoNamedTexture* namedTexture;
94
95 while (cursor.Next(namedTexture)) {
96 LegoTexture* texture = namedTexture->GetTexture();
97 LegoTextureInfo* textureInfo = TextureContainer()->Get(namedTexture->GetName()->GetData());
98
99 if (textureInfo == NULL) {
100 textureInfo = LegoTextureInfo::Create(namedTexture->GetName()->GetData(), texture);
101
102 if (textureInfo != NULL) {
103 TextureContainer()->Add(namedTexture->GetName()->GetData(), textureInfo);
104 }
105 }
106 else {
107 textureInfo->FUN_10066010(texture->GetImage()->GetBits());
108 }
109 }
110
111 if (m_textures != NULL) {
112 delete m_textures;
113 }
114
115 m_textures = NULL;
116 return SUCCESS;
117}
118
119// FUNCTION: LEGO1 0x1004fc60
121{
122 MxResult result = SUCCESS;
123
125 result = Read(*m_currentChunk);
126 if (result == SUCCESS) {
127 Store();
128 }
129
132 }
134 }
135
136 return result;
137}
138
139// FUNCTION: LEGO1 0x1004fcb0
141{
142 if (this->m_compositePresenter && !this->m_compositePresenter->VTable0x64(2)) {
144 return;
145 }
146
148}
T * Get(const char *p_name)
Retrieve the element mapped to the given name, or nullptr if missing.
Definition: legocontainer.h:92
void Add(const char *p_name, T *p_value)
Add an element mapped to the given name, replacing existing item if present.
LegoU8 * GetBits()
[AI] Returns pointer to the buffer containing indexed pixel data.
Definition: legoimage.h:116
Implementation of LegoStorage for memory-backed buffers.
Definition: legostorage.h:317
LegoResult Read(void *p_buffer, LegoU32 p_size) override
Reads bytes from memory buffer at current position.
Definition: legostorage.cpp:20
[AI] Cursor/iterator for traversing a LegoNamedTextureList.
[AI] A list class that manages a collection of pointers to LegoNamedTexture objects.
[AI] Associates a named string with a LegoTexture instance, allowing textures to be referenced symbol...
LegoTexture * GetTexture()
[AI] Returns a pointer to the owned LegoTexture instance.
const MxString * GetName() const
[AI] Returns a pointer to the name string associated with this texture.
[AI] Contains DirectDraw and Direct3DRM handles and metadata for a texture used in the LEGO Island re...
LegoResult FUN_10066010(const LegoU8 *p_bits)
[AI] Updates the pixel bits for the current surface/texture with the provided bitmap data.
static LegoTextureInfo * Create(const char *p_name, LegoTexture *p_texture)
[AI] Creates a new LegoTextureInfo for a given logical name and loaded LegoTexture.
[AI] Manages the loading, storage, and management of named textures for the LEGO Island engine.
MxResult Read(MxDSChunk &p_chunk)
[AI] Loads and parses one or more texture objects from a provided serialized data chunk.
MxResult Store()
[AI] Transfers all loaded textures to the global texture container and initializes their info structu...
void DoneTickle() override
[AI] Updates this presenter when the tickle state reaches "Done".
MxResult PutData() override
[AI] Loads texture data from the current data chunk, registers these textures with the global texture...
MxResult AddToManager() override
[AI] Registers this presenter with the VideoManager, making it available for video/texture updates an...
[AI] Represents a texture which wraps a LegoImage and provides loading/saving functionality.
Definition: legotexture.h:15
LegoResult Read(LegoStorage *p_storage, LegoU32 p_square)
[AI] Reads texture data from a LegoStorage.
Definition: legotexture.cpp:22
LegoImage * GetImage()
[AI] Returns the associated image used by this texture.
Definition: legotexture.h:25
MxDirect3D * GetDirect3D()
[AI] Returns the active Direct3D wrapper (engine/utility) object.
BOOL GetHardwareMode()
[AI] Checks if the device is operating in hardware mode.
Definition: mxdirectxinfo.h:88
virtual MxBool VTable0x64(undefined4 p_undefined)
[AI] Delegated state/mode checking.
[AI] Represents a chunk of data extracted from a stream (typically from a Mindscape/Mx SI file or str...
Definition: mxdschunk.h:38
MxU8 * GetData()
[AI] Returns a pointer to the start of the data payload. [AI]
Definition: mxdschunk.h:108
void FreeDataChunk(MxStreamChunk *p_chunk)
[AI] Frees (deletes) a data chunk if it's found in the consumed data list; also forcibly deletes sing...
MxAssignedDevice * AssignedDevice()
[AI] Returns the currently selected/active rendering device information for 3D output.
Definition: mxdirect3d.h:75
MxBool Next()
[AI]
void Append(T p_obj)
[AI]
Definition: mxlist.h:100
virtual void RegisterPresenter(MxPresenter &p_presenter)
[AI] Register a new presenter for tickle management and playback coordination.
virtual void UnregisterPresenter(MxPresenter &p_presenter)
[AI] Remove a presenter from tickle and managed output lists.
void DoneTickle() override
[AI] Per-frame update for the "done" state; transitions this presenter to idle and ends the action.
MxDSSubscriber * m_subscriber
[AI] Subscriber that provides the stream data (e.g., audio/video chunks) for this presenter.
MxStreamChunk * m_currentChunk
[AI] Currently active data chunk for playback or processing.
virtual void SetTickleState(TickleState p_tickleState)
[AI] Forces the tickle state, advancing to the requested lifecycle stage.
Definition: mxpresenter.h:100
MxBool IsEnabled()
[AI] Returns whether this presenter is logically enabled (based on the associated action's flags).
TickleState m_currentTickleState
[AI] Current state in the tickle lifecycle.
Definition: mxpresenter.h:199
@ e_idle
[AI] Not processing an action.
Definition: mxpresenter.h:24
@ e_streaming
[AI] Streaming or rendering actively.
Definition: mxpresenter.h:27
MxCompositePresenter * m_compositePresenter
[AI] Owner composite presenter, if any.
Definition: mxpresenter.h:217
char * GetData() const
Returns a pointer to the internal character buffer.
Definition: mxstring.h:110
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
unsigned long LegoU32
[AI] Unsigned 32-bit integer type for cross-platform compatibility.
Definition: legotypes.h:71
char LegoChar
[AI] Alias for char, for use in character/byte data and string handling.
Definition: legotypes.h:83
#define FAILURE
[AI] Used to indicate a failed operation in result codes.
Definition: legotypes.h:34
long LegoS32
[AI] Signed 32-bit integer type for cross-platform compatibility.
Definition: legotypes.h:65
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
LegoVideoManager * VideoManager()
[AI] Accessor for the game's LegoVideoManager subsystem. Used for managing 3D/video hardware....
Definition: misc.cpp:29
LegoTextureContainer * TextureContainer()
[AI] Accessor for the texture container used for global texture management. [AI]
Definition: misc.cpp:130
MxLong MxResult
[AI]
Definition: mxtypes.h:106