Isle
Loading...
Searching...
No Matches
mxutilities.h
Go to the documentation of this file.
1#ifndef MXUTILITIES_H
2#define MXUTILITIES_H
3
4#include "mxtypes.h"
5
6#include <string.h>
7
8class MxDSFile;
9class MxDSObject;
10class MxDSAction;
12class MxPresenter;
13
21template <class T>
22inline T Abs(T p_t)
23{
24 return p_t < 0 ? -p_t : p_t;
25}
26
35template <class T>
36inline T Min(T p_t1, T p_t2)
37{
38 return p_t1 < p_t2 ? p_t1 : p_t2;
39}
40
49template <class T>
50inline T Max(T p_t1, T p_t2)
51{
52 return p_t1 > p_t2 ? p_t1 : p_t2;
53}
54
62template <class T>
63inline void GetScalar(MxU8*& p_source, T& p_dest)
64{
65 p_dest = *(T*) p_source;
66 p_source += sizeof(T);
67}
68
76template <class T>
77inline T GetScalar(T*& p_source)
78{
79 T val = *p_source;
80 p_source += 1;
81 return val;
82}
83
91template <class T>
92inline void GetDouble(MxU8*& p_source, T& p_dest)
93{
94 p_dest = *(double*) p_source;
95 p_source += sizeof(double);
96}
97
107template <class T>
108inline void GetString(MxU8*& p_source, char*& p_dest, T* p_obj, void (T::*p_setter)(const char*))
109{
110 (p_obj->*p_setter)((char*) p_source);
111 p_source += strlen(p_dest) + 1;
112}
113
130 MxS32 p_rect1Width,
131 MxS32 p_rect1Height,
132 MxS32 p_rect2Width,
133 MxS32 p_rect2Height,
134 MxS32* p_rect1Left,
135 MxS32* p_rect1Top,
136 MxS32* p_rect2Left,
137 MxS32* p_rect2Top,
138 MxS32* p_width,
139 MxS32* p_height
140);
141
148void MakeSourceName(char*, const char*);
149
156void OmniError(const char* p_message, MxS32 p_status);
157
163void SetOmniUserMessage(void (*p_omniUserMessage)(const char*, MxS32));
164
172MxBool ContainsPresenter(MxCompositePresenterList& p_presenterList, MxPresenter* p_presenter);
173
181void FUN_100b7220(MxDSAction* p_action, MxU32 p_newFlags, MxBool p_setFlags);
182
191MxBool KeyValueStringParse(char*, const char*, const char*);
192
193// TEMPLATE: BETA10 0x1012dfd0
194// ?Max@@YAHHH@Z
195
196// TEMPLATE: BETA10 0x1012dff0
197// ?Min@@YAHHH@Z
198
199#endif // MXUTILITIES_H
[AI] STL list of MxPresenter pointers, used to manage multiple child presenters under composite contr...
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
[AI] Represents a source file handler for SI (Streamer Interface) files, providing buffered access fo...
Definition: mxdsfile.h:20
[AI] Base class for any object deserialized from an SI (script/data) file in the LEGO Island engine.
Definition: mxdsobject.h:44
[AI] Abstract base class for all presenter types in the LEGO Island engine, responsible for managing ...
Definition: mxpresenter.h:20
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
unsigned char MxU8
[AI]
Definition: mxtypes.h:8
signed int MxS32
[AI]
Definition: mxtypes.h:38
unsigned int MxU32
[AI]
Definition: mxtypes.h:32
void GetScalar(MxU8 *&p_source, T &p_dest)
Reads a value of type T from a memory buffer and advances the pointer.
Definition: mxutilities.h:63
void GetDouble(MxU8 *&p_source, T &p_dest)
Reads a double-precision value from memory and advances the pointer.
Definition: mxutilities.h:92
MxBool KeyValueStringParse(char *, const char *, const char *)
Searches p_string for a key command and copies its associated value to p_output.
Definition: mxutilities.cpp:85
T Max(T p_t1, T p_t2)
Returns the maximum of two values.
Definition: mxutilities.h:50
void GetString(MxU8 *&p_source, char *&p_dest, T *p_obj, void(T::*p_setter)(const char *))
Extracts a string from a buffer and assigns it using a setter function on an object.
Definition: mxutilities.h:108
void FUN_100b7220(MxDSAction *p_action, MxU32 p_newFlags, MxBool p_setFlags)
Recursively sets or clears flags for an MxDSAction and all sub-actions if applicable.
MxBool ContainsPresenter(MxCompositePresenterList &p_presenterList, MxPresenter *p_presenter)
Determines if a presenter exists within a composite presenter hierarchy.
void MakeSourceName(char *, const char *)
Parses an SI source filename and normalizes it for use in the engine.
Definition: mxutilities.cpp:66
void SetOmniUserMessage(void(*p_omniUserMessage)(const char *, MxS32))
Sets the callback to handle user messages, such as errors or logs, for the OMNI engine.
MxBool GetRectIntersection(MxS32 p_rect1Width, MxS32 p_rect1Height, MxS32 p_rect2Width, MxS32 p_rect2Height, MxS32 *p_rect1Left, MxS32 *p_rect1Top, MxS32 *p_rect2Left, MxS32 *p_rect2Top, MxS32 *p_width, MxS32 *p_height)
Computes intersection of two rectangles and modifies their positions and dimensions to the intersecti...
Definition: mxutilities.cpp:19
void OmniError(const char *p_message, MxS32 p_status)
Displays or logs an error message using the current user message handler, or aborts on error status i...
T Min(T p_t1, T p_t2)
Returns the minimum of two values.
Definition: mxutilities.h:36
T Abs(T p_t)
Returns the absolute value of a value.
Definition: mxutilities.h:22