2024-03-09 15:07:52 -05:00
|
|
|
#include "mxutilities.h"
|
2024-01-08 06:45:07 -05:00
|
|
|
|
2024-01-29 17:46:22 -05:00
|
|
|
#include "mxcompositepresenter.h"
|
2024-01-15 14:08:28 -05:00
|
|
|
#include "mxdsaction.h"
|
|
|
|
#include "mxdsactionlist.h"
|
2024-01-08 06:45:07 -05:00
|
|
|
#include "mxdsfile.h"
|
2024-01-15 14:08:28 -05:00
|
|
|
#include "mxdsmultiaction.h"
|
2024-01-08 06:45:07 -05:00
|
|
|
#include "mxdsobject.h"
|
2024-01-29 17:46:22 -05:00
|
|
|
#include "mxpresenterlist.h"
|
2024-01-08 06:45:07 -05:00
|
|
|
#include "mxrect32.h"
|
|
|
|
|
2024-03-12 14:27:24 -04:00
|
|
|
#include <assert.h>
|
|
|
|
|
2024-01-08 06:45:07 -05:00
|
|
|
// GLOBAL: LEGO1 0x101020e8
|
2024-03-05 03:45:09 -05:00
|
|
|
void (*g_omniUserMessage)(const char*, int) = NULL;
|
2024-01-08 06:45:07 -05:00
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100b6e10
|
2024-01-19 09:38:06 -05:00
|
|
|
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,
|
2024-01-08 06:45:07 -05:00
|
|
|
MxS32* p_width,
|
|
|
|
MxS32* p_height
|
|
|
|
)
|
|
|
|
{
|
2024-01-19 09:38:06 -05:00
|
|
|
MxPoint32 rect1Origin(*p_rect1Left, *p_rect1Top);
|
|
|
|
MxRect32 rect1(MxPoint32(0, 0), MxSize32(p_rect1Width, p_rect1Height));
|
2024-01-08 06:45:07 -05:00
|
|
|
|
2024-01-19 09:38:06 -05:00
|
|
|
MxPoint32 rect2Origin(*p_rect2Left, *p_rect2Top);
|
|
|
|
MxRect32 rect2(MxPoint32(0, 0), MxSize32(p_rect2Width, p_rect2Height));
|
2024-01-08 06:45:07 -05:00
|
|
|
|
|
|
|
MxRect32 rect(0, 0, *p_width, *p_height);
|
2024-01-19 09:38:06 -05:00
|
|
|
rect.AddPoint(rect1Origin);
|
2024-01-08 06:45:07 -05:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!rect.IntersectsWith(rect1)) {
|
2024-01-08 06:45:07 -05:00
|
|
|
return FALSE;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-08 06:45:07 -05:00
|
|
|
|
2024-01-19 09:38:06 -05:00
|
|
|
rect.Intersect(rect1);
|
|
|
|
rect.SubtractPoint(rect1Origin);
|
|
|
|
rect.AddPoint(rect2Origin);
|
2024-01-08 06:45:07 -05:00
|
|
|
|
2024-02-01 15:42:10 -05:00
|
|
|
if (!rect.IntersectsWith(rect2)) {
|
2024-01-08 06:45:07 -05:00
|
|
|
return FALSE;
|
2024-02-01 15:42:10 -05:00
|
|
|
}
|
2024-01-08 06:45:07 -05:00
|
|
|
|
2024-01-19 09:38:06 -05:00
|
|
|
rect.Intersect(rect2);
|
|
|
|
rect.SubtractPoint(rect2Origin);
|
2024-01-08 06:45:07 -05:00
|
|
|
|
2024-01-19 09:38:06 -05:00
|
|
|
*p_rect1Left += rect.GetLeft();
|
|
|
|
*p_rect1Top += rect.GetTop();
|
|
|
|
*p_rect2Left += rect.GetLeft();
|
|
|
|
*p_rect2Top += rect.GetTop();
|
2024-01-08 06:45:07 -05:00
|
|
|
*p_width = rect.GetWidth();
|
|
|
|
*p_height = rect.GetHeight();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100b6ff0
|
|
|
|
void MakeSourceName(char* p_output, const char* p_input)
|
|
|
|
{
|
|
|
|
const char* cln = strchr(p_input, ':');
|
|
|
|
if (cln) {
|
|
|
|
p_input = cln + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(p_output, p_input);
|
|
|
|
|
|
|
|
strlwr(p_output);
|
|
|
|
|
|
|
|
char* extLoc = strstr(p_output, ".si");
|
|
|
|
if (extLoc) {
|
|
|
|
*extLoc = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FUNCTION: LEGO1 0x100b7050
|
2024-03-12 14:27:24 -04:00
|
|
|
MxBool KeyValueStringParse(char* p_output, const char* p_command, const char* p_string)
|
2024-01-08 06:45:07 -05:00
|
|
|
{
|
|
|
|
MxBool didMatch = FALSE;
|
2024-03-12 14:27:24 -04:00
|
|
|
assert(p_string);
|
|
|
|
assert(p_command);
|
2024-01-08 06:45:07 -05:00
|
|
|
|
2024-03-12 14:27:24 -04:00
|
|
|
MxS16 len = strlen(p_string);
|
|
|
|
char* string = new char[len + 1];
|
|
|
|
assert(string);
|
|
|
|
strcpy(string, p_string);
|
2024-01-08 06:45:07 -05:00
|
|
|
|
2024-03-12 14:27:24 -04:00
|
|
|
for (char* token = strtok(string, ", \t\r\n:"); token; token = strtok(NULL, ", \t\r\n:")) {
|
2024-01-08 06:45:07 -05:00
|
|
|
len -= (strlen(token) + 1);
|
|
|
|
|
2024-03-12 14:27:24 -04:00
|
|
|
if (strcmpi(token, p_command) == 0) {
|
|
|
|
if (p_output && len > 0) {
|
|
|
|
char* output = p_output;
|
|
|
|
char* cur = &token[strlen(p_command)];
|
2024-01-08 06:45:07 -05:00
|
|
|
cur++;
|
2024-03-12 14:27:24 -04:00
|
|
|
while (*cur != ',' && *cur != ' ' && *cur != '\0' && *cur != '\t' && *cur != '\n' && *cur != '\r') {
|
|
|
|
*output++ = *cur++;
|
2024-01-08 06:45:07 -05:00
|
|
|
}
|
2024-03-12 14:27:24 -04:00
|
|
|
*output = '\0';
|
2024-01-08 06:45:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
didMatch = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-12 14:27:24 -04:00
|
|
|
delete[] string;
|
2024-01-08 06:45:07 -05:00
|
|
|
return didMatch;
|
|
|
|
}
|
|
|
|
|
2024-01-29 17:46:22 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b7170
|
|
|
|
MxBool ContainsPresenter(MxCompositePresenterList& p_presenterList, MxPresenter* p_presenter)
|
|
|
|
{
|
|
|
|
for (MxCompositePresenterList::iterator it = p_presenterList.begin(); it != p_presenterList.end(); it++) {
|
2024-02-01 15:42:10 -05:00
|
|
|
if (p_presenter == *it || ((*it)->IsA("MxCompositePresenter") &&
|
2024-03-20 12:26:10 -04:00
|
|
|
ContainsPresenter(*((MxCompositePresenter*) *it)->GetList(), p_presenter))) {
|
2024-01-29 17:46:22 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2024-02-27 15:04:17 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b71e0
|
|
|
|
void OmniError(const char* p_message, MxS32 p_status)
|
|
|
|
{
|
|
|
|
if (g_omniUserMessage) {
|
|
|
|
g_omniUserMessage(p_message, p_status);
|
|
|
|
}
|
|
|
|
else if (p_status) {
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-08 06:45:07 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b7210
|
2024-02-27 15:04:17 -05:00
|
|
|
void SetOmniUserMessage(void (*p_omniUserMessage)(const char*, MxS32))
|
2024-01-08 06:45:07 -05:00
|
|
|
{
|
2024-02-27 15:04:17 -05:00
|
|
|
g_omniUserMessage = p_omniUserMessage;
|
2024-01-08 06:45:07 -05:00
|
|
|
}
|
|
|
|
|
2024-01-15 14:08:28 -05:00
|
|
|
// FUNCTION: LEGO1 0x100b7220
|
|
|
|
void FUN_100b7220(MxDSAction* p_action, MxU32 p_newFlags, MxBool p_setFlags)
|
|
|
|
{
|
|
|
|
p_action->SetFlags(!p_setFlags ? p_action->GetFlags() & ~p_newFlags : p_action->GetFlags() | p_newFlags);
|
|
|
|
|
|
|
|
if (p_action->IsA("MxDSMultiAction")) {
|
|
|
|
MxDSActionListCursor cursor(((MxDSMultiAction*) p_action)->GetActionList());
|
|
|
|
MxDSAction* action;
|
|
|
|
|
|
|
|
while (cursor.Next(action)) {
|
|
|
|
FUN_100b7220(action, p_newFlags, p_setFlags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-08 06:45:07 -05:00
|
|
|
// Should probably be somewhere else
|
|
|
|
// FUNCTION: LEGO1 0x100c0280
|
|
|
|
MxDSObject* CreateStreamObject(MxDSFile* p_file, MxS16 p_ofs)
|
|
|
|
{
|
|
|
|
MxU8* buf;
|
|
|
|
_MMCKINFO tmpChunk;
|
|
|
|
|
|
|
|
if (p_file->Seek(((MxLong*) p_file->GetBuffer())[p_ofs], 0)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'S', 't')) {
|
|
|
|
if (p_file->Read((MxU8*) &tmpChunk.ckid, 8) == 0 && tmpChunk.ckid == FOURCC('M', 'x', 'O', 'b')) {
|
|
|
|
|
|
|
|
buf = new MxU8[tmpChunk.cksize];
|
|
|
|
if (!buf) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p_file->Read(buf, tmpChunk.cksize) != 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save a copy so we can clean up properly, because
|
|
|
|
// this function will alter the pointer value.
|
|
|
|
MxU8* copy = buf;
|
|
|
|
MxDSObject* obj = DeserializeDSObjectDispatch(&buf, -1);
|
|
|
|
delete[] copy;
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|