begin implementation of InfoCenter class (#444)

* Push changes

* fixes

* Implement Infocenter::HandleEndAction

* match Infocenter::StopCutScene

* implement Infocenter::HandleKeyPress

* fixes

* Update infocenter.cpp

* Update legoworld.cpp

* use enums

* WIP Fixes

* Fix

* Fix

* Fix

* Rename function

* Change enum

* Update enums

* Refactor another enum

* Refactor MxDSType

* Refactor HashTableOpt

* Fixes

* Refactor tickle enum

* Update other enums

* Add EnumConstantName to ncc

* Move enum to global namespace

* Rename enum

---------

Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
Misha
2024-01-17 11:53:53 -05:00
committed by GitHub
parent aaa18bc9e2
commit f50b771fff
100 changed files with 1160 additions and 555 deletions

View File

@@ -19,7 +19,7 @@ void LegoActionControlPresenter::ReadyTickle()
if (chunk) {
ParseExtra();
ProgressTickleState(TickleState_Starting);
ProgressTickleState(e_starting);
m_subscriber->DestroyChunk(chunk);
if (m_compositePresenter) {
@@ -40,13 +40,13 @@ void LegoActionControlPresenter::RepeatingTickle()
#ifdef COMPAT_MODE
{
MxAtomId atom(m_unk0x54.GetData(), LookupMode_LowerCase2);
MxAtomId atom(m_unk0x54.GetData(), e_lowerCase2);
InvokeAction(m_unk0x50, atom, m_unk0x64, NULL);
}
#else
InvokeAction(m_unk0x50, MxAtomId(m_unk0x54.GetData(), LookupMode_LowerCase2), m_unk0x64, NULL);
InvokeAction(m_unk0x50, MxAtomId(m_unk0x54.GetData(), e_lowerCase2), m_unk0x64, NULL);
#endif
ProgressTickleState(TickleState_Done);
ProgressTickleState(e_done);
}
}
@@ -92,11 +92,11 @@ void LegoActionControlPresenter::ParseExtra()
char output[1024];
if (KeyValueStringParse(output, g_strACTION, buf)) {
m_unk0x50 = MatchActionString(strtok(output, g_parseExtraTokens));
if (m_unk0x50 != ExtraActionType_exit) {
if (m_unk0x50 != Extra::ActionType::e_exit) {
MakeSourceName(buf, strtok(NULL, g_parseExtraTokens));
m_unk0x54 = buf;
m_unk0x54.ToLowerCase();
if (m_unk0x50 != ExtraActionType_run) {
if (m_unk0x50 != Extra::ActionType::e_run) {
m_unk0x64 = atoi(strtok(NULL, g_parseExtraTokens));
}
}

View File

@@ -92,11 +92,18 @@ LegoGameState::~LegoGameState()
delete[] m_savePath;
}
// STUB: LEGO1 0x10039780
void LegoGameState::FUN_10039780(MxU8)
{
// TODO
}
// FUNCTION: LEGO1 0x10039980
MxResult LegoGameState::Save(MxULong p_slot)
{
MxResult result;
InfocenterState* infocenterState = (InfocenterState*) GameState()->GetState("InfocenterState");
if (!infocenterState || infocenterState->GetInfocenterBufferElement(0) == 0)
result = SUCCESS;
else {
@@ -105,7 +112,7 @@ MxResult LegoGameState::Save(MxULong p_slot)
MxString savePath;
GetFileSavePath(&savePath, p_slot);
LegoFileStream fileStream;
if (fileStream.Open(savePath.GetData(), LegoStream::WriteBit) != FAILURE) {
if (fileStream.Open(savePath.GetData(), LegoStream::c_writeBit) != FAILURE) {
MxU32 maybeVersion = 0x1000C;
fileStream.Write(&maybeVersion, 4);
fileStream.Write(&m_unk0x24, 2);
@@ -216,7 +223,7 @@ void LegoGameState::HandleAction(MxU32 p_area)
// TODO: implement other cases
}
InvokeAction(ExtraActionType_opendisk, *script, 0, NULL);
InvokeAction(Extra::ActionType::e_opendisk, *script, 0, NULL);
}
// FUNCTION: LEGO1 0x1003bac0
@@ -310,7 +317,7 @@ void LegoGameState::SerializeScoreHistory(MxS16 p_flags)
savePath += "\\";
savePath += g_historyGSI;
if (p_flags == LegoStream::WriteBit) {
if (p_flags == LegoStream::c_writeBit) {
m_unk0xa6.WriteScoreHistory();
}

View File

@@ -106,7 +106,7 @@
// FUNCTION: LEGO1 0x10006e40
LegoObjectFactory::LegoObjectFactory()
{
#define X(V) this->m_id##V = MxAtomId(#V, LookupMode_Exact);
#define X(V) this->m_id##V = MxAtomId(#V, e_exact);
FOR_LEGOOBJECTFACTORY_OBJECTS(X)
#undef X
}
@@ -114,7 +114,7 @@ LegoObjectFactory::LegoObjectFactory()
// FUNCTION: LEGO1 0x10009a90
MxCore* LegoObjectFactory::Create(const char* p_name)
{
MxAtomId atom(p_name, LookupMode_Exact);
MxAtomId atom(p_name, e_exact);
#define X(V) \
if (this->m_id##V == atom) { \

View File

@@ -167,18 +167,18 @@ MxResult LegoFileStream::Open(const char* p_filename, OpenFlags p_mode)
fclose(m_hFile);
modeString[0] = '\0';
if (p_mode & ReadBit) {
if (p_mode & c_readBit) {
m_mode = LEGOSTREAM_MODE_READ;
strcat(modeString, "r");
}
if (p_mode & WriteBit) {
if (p_mode & c_writeBit) {
if (m_mode != LEGOSTREAM_MODE_READ)
m_mode = LEGOSTREAM_MODE_WRITE;
strcat(modeString, "w");
}
if ((p_mode & 4) != 0)
if ((p_mode & c_binaryBit) != 0)
strcat(modeString, "b");
else
strcat(modeString, "t");

View File

@@ -11,30 +11,30 @@
#include <string.h>
// FUNCTION: LEGO1 0x1003e300
ExtraActionType MatchActionString(const char* p_str)
Extra::ActionType MatchActionString(const char* p_str)
{
ExtraActionType result = ExtraActionType_unknown;
Extra::ActionType result = Extra::ActionType::e_unknown;
if (!strcmpi("openram", p_str))
result = ExtraActionType_openram;
result = Extra::ActionType::e_openram;
else if (!strcmpi("opendisk", p_str))
result = ExtraActionType_opendisk;
result = Extra::ActionType::e_opendisk;
else if (!strcmpi("close", p_str))
result = ExtraActionType_close;
result = Extra::ActionType::e_close;
else if (!strcmpi("start", p_str))
result = ExtraActionType_start;
result = Extra::ActionType::e_start;
else if (!strcmpi("stop", p_str))
result = ExtraActionType_stop;
result = Extra::ActionType::e_stop;
else if (!strcmpi("run", p_str))
result = ExtraActionType_run;
result = Extra::ActionType::e_run;
else if (!strcmpi("exit", p_str))
result = ExtraActionType_exit;
result = Extra::ActionType::e_exit;
else if (!strcmpi("enable", p_str))
result = ExtraActionType_enable;
result = Extra::ActionType::e_enable;
else if (!strcmpi("disable", p_str))
result = ExtraActionType_disable;
result = Extra::ActionType::e_disable;
else if (!strcmpi("notify", p_str))
result = ExtraActionType_notify;
result = Extra::ActionType::e_notify;
return result;
}
@@ -43,54 +43,54 @@ MxBool CheckIfEntityExists(MxBool p_enable, const char* p_filename, MxS32 p_enti
void NotifyEntity(const char* p_filename, MxS32 p_entityId, LegoEntity* p_sender);
// FUNCTION: LEGO1 0x1003e430
void InvokeAction(ExtraActionType p_actionId, MxAtomId& p_pAtom, int p_targetEntityId, LegoEntity* p_sender)
void InvokeAction(Extra::ActionType p_actionId, MxAtomId& p_pAtom, int p_targetEntityId, LegoEntity* p_sender)
{
MxDSAction action;
action.SetAtomId(p_pAtom);
action.SetObjectId(p_targetEntityId);
switch (p_actionId) {
case ExtraActionType_opendisk:
case Extra::ActionType::e_opendisk:
if (!CheckIfEntityExists(TRUE, p_pAtom.GetInternal(), p_targetEntityId)) {
Streamer()->Open(p_pAtom.GetInternal(), MxStreamer::e_DiskStream);
Streamer()->Open(p_pAtom.GetInternal(), MxStreamer::e_diskStream);
Start(&action);
}
break;
case ExtraActionType_openram:
case Extra::ActionType::e_openram:
if (!CheckIfEntityExists(TRUE, p_pAtom.GetInternal(), p_targetEntityId)) {
Streamer()->Open(p_pAtom.GetInternal(), MxStreamer::e_RAMStream);
Start(&action);
}
break;
case ExtraActionType_close:
case Extra::ActionType::e_close:
action.SetUnknown24(-2);
DeleteObject(action);
Streamer()->Close(p_pAtom.GetInternal());
break;
case ExtraActionType_start:
case Extra::ActionType::e_start:
if (!CheckIfEntityExists(TRUE, p_pAtom.GetInternal(), p_targetEntityId)) {
Start(&action);
}
break;
case ExtraActionType_stop:
case Extra::ActionType::e_stop:
action.SetUnknown24(-2);
if (!FUN_1003ee00(p_pAtom, p_targetEntityId)) {
DeleteObject(action);
}
break;
case ExtraActionType_run:
case Extra::ActionType::e_run:
_spawnl(0, "\\lego\\sources\\main\\main.exe", "\\lego\\sources\\main\\main.exe", "/script", &p_pAtom, 0);
break;
case ExtraActionType_exit:
case Extra::ActionType::e_exit:
Lego()->SetExit(TRUE);
break;
case ExtraActionType_enable:
case Extra::ActionType::e_enable:
CheckIfEntityExists(TRUE, p_pAtom.GetInternal(), p_targetEntityId);
break;
case ExtraActionType_disable:
case Extra::ActionType::e_disable:
CheckIfEntityExists(FALSE, p_pAtom.GetInternal(), p_targetEntityId);
break;
case ExtraActionType_notify:
case Extra::ActionType::e_notify:
NotifyEntity(p_pAtom.GetInternal(), p_targetEntityId, p_sender);
break;
}
@@ -99,8 +99,7 @@ void InvokeAction(ExtraActionType p_actionId, MxAtomId& p_pAtom, int p_targetEnt
// FUNCTION: LEGO1 0x1003e670
MxBool CheckIfEntityExists(MxBool p_enable, const char* p_filename, MxS32 p_entityId)
{
LegoWorld* world =
(LegoWorld*) FindEntityByAtomIdOrEntityId(MxAtomId(p_filename, LookupMode_LowerCase2), p_entityId);
LegoWorld* world = (LegoWorld*) FindEntityByAtomIdOrEntityId(MxAtomId(p_filename, e_lowerCase2), p_entityId);
if (world) {
world->VTable0x68(p_enable);
return TRUE;

View File

@@ -55,7 +55,7 @@ MxResult MxCompositeMediaPresenter::StartAction(MxStreamController* p_controller
if (presenter && presenter->AddToManager() == SUCCESS) {
presenter->SetCompositePresenter(this);
if (presenter->StartAction(p_controller, action) == SUCCESS) {
presenter->SetTickleState(TickleState_Idle);
presenter->SetTickleState(e_idle);
if (presenter->IsA("MxVideoPresenter"))
VideoManager()->UnregisterPresenter(*presenter);
@@ -75,7 +75,7 @@ MxResult MxCompositeMediaPresenter::StartAction(MxStreamController* p_controller
}
if (!m_compositePresenter) {
SetTickleState(TickleState_Ready);
SetTickleState(e_ready);
MxLong time = Timer()->GetTime();
m_action->SetUnknown90(time);
}
@@ -93,10 +93,10 @@ void MxCompositeMediaPresenter::StartingTickle()
if (!m_unk0x4e) {
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
if ((*it)->GetCurrentTickleState() < TickleState_Streaming) {
if ((*it)->GetCurrentTickleState() < e_streaming) {
(*it)->Tickle();
if ((*it)->GetCurrentTickleState() == TickleState_Streaming ||
if ((*it)->GetCurrentTickleState() == e_streaming ||
((*it)->GetAction() && (*it)->GetAction()->GetStartTime()))
m_unk0x4c++;
}
@@ -115,15 +115,15 @@ void MxCompositeMediaPresenter::StartingTickle()
else {
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++) {
if (!(*it)->GetAction()->GetStartTime() && ((MxMediaPresenter*) *it)->CurrentChunk() &&
!((*it)->GetAction()->GetFlags() & MxDSAction::Flag_Bit9)) {
!((*it)->GetAction()->GetFlags() & MxDSAction::c_bit9)) {
(*it)->Tickle();
(*it)->GetAction()->SetFlags((*it)->GetAction()->GetFlags() | MxDSAction::Flag_Bit9);
(*it)->GetAction()->SetFlags((*it)->GetAction()->GetFlags() | MxDSAction::c_bit9);
m_unk0x4c--;
}
}
if (!m_unk0x4c) {
ProgressTickleState(TickleState_Streaming);
ProgressTickleState(e_streaming);
MxLong time = Timer()->GetTime();
m_action->SetUnknown90(time);
}
@@ -136,15 +136,15 @@ MxResult MxCompositeMediaPresenter::Tickle()
MxAutoLocker lock(&m_criticalSection);
switch (m_currentTickleState) {
case TickleState_Ready:
ProgressTickleState(TickleState_Starting);
case TickleState_Starting:
case e_ready:
ProgressTickleState(e_starting);
case e_starting:
StartingTickle();
break;
case TickleState_Streaming:
case TickleState_Repeating:
case TickleState_unk5:
case TickleState_Done: {
case e_streaming:
case e_repeating:
case e_unk5:
case e_done: {
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++)
(*it)->Tickle();
break;
@@ -161,7 +161,7 @@ MxResult MxCompositeMediaPresenter::PutData()
{
MxAutoLocker lock(&m_criticalSection);
if (m_currentTickleState >= TickleState_Streaming && m_currentTickleState <= TickleState_Done) {
if (m_currentTickleState >= e_streaming && m_currentTickleState <= e_done) {
for (MxCompositePresenterList::iterator it = m_list.begin(); it != m_list.end(); it++)
(*it)->PutData();
}