mirror of
https://github.com/isledecomp/isle-portable.git
synced 2024-11-26 17:36:12 -05:00
Implement/Match JukeboxEntity (#562)
* Implement/Match JukeboxEntity * Style/naming * Style/naming --------- Co-authored-by: Christian Semmler <mail@csemmler.com>
This commit is contained in:
parent
1b696e4bd8
commit
271df035fd
8 changed files with 149 additions and 21 deletions
|
@ -25,8 +25,16 @@ class JukeBoxEntity : public LegoEntity {
|
|||
return !strcmp(p_name, JukeBoxEntity::ClassName()) || LegoEntity::IsA(p_name);
|
||||
}
|
||||
|
||||
void StartAction();
|
||||
void StopAction(MxU32 p_state);
|
||||
|
||||
inline MxBool IsBackgroundAudioEnabled() { return m_audioEnabled; }
|
||||
|
||||
// SYNTHETIC: LEGO1 0x10085db0
|
||||
// JukeBoxEntity::`scalar deleting destructor'
|
||||
|
||||
protected:
|
||||
MxBool m_audioEnabled; // 0x68
|
||||
};
|
||||
|
||||
#endif // JUKEBOXENTITY_H
|
||||
|
|
|
@ -22,8 +22,16 @@ class JukeBoxState : public LegoState {
|
|||
|
||||
MxBool VTable0x14() override; // vtable+0x14
|
||||
|
||||
inline MxU32 IsActive() { return m_active; }
|
||||
inline void SetActive(MxU32 p_active) { m_active = p_active; }
|
||||
inline MxU32 GetState() { return m_state; }
|
||||
|
||||
// SYNTHETIC: LEGO1 0x1000f3d0
|
||||
// JukeBoxState::`scalar deleting destructor'
|
||||
|
||||
protected:
|
||||
MxU32 m_state; // 0x08
|
||||
MxU32 m_active; // 0x0c
|
||||
};
|
||||
|
||||
#endif // JUKEBOXSTATE_H
|
||||
|
|
|
@ -107,12 +107,14 @@ class LegoGameState {
|
|||
inline Act GetLoadedAct() { return m_loadedAct; }
|
||||
inline Area GetCurrentArea() { return m_currentArea; }
|
||||
inline Area GetPreviousArea() { return m_previousArea; }
|
||||
inline MxU32 GetUnknown0x41c() { return m_unk0x41c; }
|
||||
inline Area GetUnknown0x42c() { return m_unk0x42c; }
|
||||
|
||||
inline void SetDirty(MxBool p_dirty) { m_isDirty = p_dirty; }
|
||||
inline void SetCurrentArea(Area p_currentArea) { m_currentArea = p_currentArea; }
|
||||
inline void SetPreviousArea(Area p_previousArea) { m_previousArea = p_previousArea; }
|
||||
inline void SetUnknown0x0c(MxU8 p_unk0x0c) { m_unk0x0c = p_unk0x0c; }
|
||||
inline void SetUnknown0x41c(undefined4 p_unk0x41c) { m_unk0x41c = p_unk0x41c; }
|
||||
inline void SetUnknown0x42c(Area p_unk0x42c) { m_unk0x42c = p_unk0x42c; }
|
||||
|
||||
void SetCurrentAct(Act p_currentAct);
|
||||
|
@ -147,7 +149,8 @@ class LegoGameState {
|
|||
MxU16 m_unk0x24; // 0x24
|
||||
undefined m_unk0x28[128]; // 0x28
|
||||
ScoreStruct m_unk0xa6; // 0xa6
|
||||
undefined m_unk0x41a[8]; // 0x41a - might be part of the structure at 0xa6
|
||||
undefined m_unk0x41a[2]; // 0x41a - might be part of the structure at 0xa6
|
||||
undefined4 m_unk0x41c; // 0x41c
|
||||
MxBool m_isDirty; // 0x420
|
||||
Area m_currentArea; // 0x424
|
||||
Area m_previousArea; // 0x428
|
||||
|
|
|
@ -31,7 +31,7 @@ class MxBackgroundAudioManager : public MxCore {
|
|||
return !strcmp(p_name, MxBackgroundAudioManager::ClassName()) || MxCore::IsA(p_name);
|
||||
}
|
||||
|
||||
inline MxBool GetMusicEnabled() { return m_musicEnabled; }
|
||||
inline MxBool GetEnabled() { return m_enabled; }
|
||||
|
||||
void StartAction(MxParam& p_param);
|
||||
void StopAction(MxParam& p_param);
|
||||
|
@ -56,7 +56,7 @@ class MxBackgroundAudioManager : public MxCore {
|
|||
MxResult OpenMusic(MxAtomId& p_script);
|
||||
void DestroyMusic();
|
||||
|
||||
MxBool m_musicEnabled; // 0x08
|
||||
MxBool m_enabled; // 0x08
|
||||
MxDSAction m_action1; // 0x0c
|
||||
MxAudioPresenter* m_unk0xa0; // 0xa0
|
||||
MxDSAction m_action2; // 0xa4
|
||||
|
|
|
@ -40,9 +40,9 @@ class Radio : public MxCore {
|
|||
private:
|
||||
void CreateRadioState();
|
||||
|
||||
RadioState* m_state; // 0x08
|
||||
MxBool m_unk0x0c; // 0x0c
|
||||
MxBool m_bgAudioPreviouslyEnabled; // 0x0d
|
||||
RadioState* m_state; // 0x08
|
||||
MxBool m_unk0x0c; // 0x0c
|
||||
MxBool m_audioEnabled; // 0x0d
|
||||
|
||||
MxLong HandleEndAction(MxEndActionNotificationParam& p_param);
|
||||
MxLong HandleClick(LegoControlManagerEvent& p_param);
|
||||
|
|
|
@ -21,7 +21,7 @@ MxBackgroundAudioManager::MxBackgroundAudioManager()
|
|||
m_unk0x140 = 0;
|
||||
m_targetVolume = 0;
|
||||
m_unk0x148 = 0;
|
||||
m_musicEnabled = FALSE;
|
||||
m_enabled = FALSE;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1007ec20
|
||||
|
@ -39,7 +39,7 @@ MxResult MxBackgroundAudioManager::Create(MxAtomId& p_script, MxU32 p_frequencyM
|
|||
|
||||
if (result == SUCCESS) {
|
||||
TickleManager()->RegisterClient(this, p_frequencyMS);
|
||||
m_musicEnabled = TRUE;
|
||||
m_enabled = TRUE;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -71,7 +71,7 @@ void MxBackgroundAudioManager::DestroyMusic()
|
|||
ds.SetUnknown24(-2);
|
||||
DeleteObject(ds);
|
||||
Streamer()->Close(m_script.GetInternal());
|
||||
m_musicEnabled = FALSE;
|
||||
m_enabled = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,9 +237,10 @@ void MxBackgroundAudioManager::StopAction(MxParam& p_param)
|
|||
// FUNCTION: LEGO1 0x1007f2f0
|
||||
MxResult MxBackgroundAudioManager::PlayMusic(MxDSAction& p_action, undefined4 p_unk0x140, undefined4 p_unk0x13c)
|
||||
{
|
||||
if (!m_musicEnabled) {
|
||||
if (!m_enabled) {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
if (m_action2.GetObjectId() == -1 && m_action1.GetObjectId() != p_action.GetObjectId()) {
|
||||
MxDSAction action;
|
||||
action.SetAtomId(GetCurrentAction().GetAtomId());
|
||||
|
@ -261,8 +262,10 @@ MxResult MxBackgroundAudioManager::PlayMusic(MxDSAction& p_action, undefined4 p_
|
|||
m_unk0x13c = p_unk0x13c;
|
||||
m_unk0x140 = p_unk0x140;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
|
@ -317,8 +320,9 @@ void MxBackgroundAudioManager::RaiseVolume()
|
|||
// FUNCTION: LEGO1 0x1007f5f0
|
||||
void MxBackgroundAudioManager::Enable(MxBool p_enable)
|
||||
{
|
||||
if (this->m_musicEnabled != p_enable) {
|
||||
this->m_musicEnabled = p_enable;
|
||||
if (this->m_enabled != p_enable) {
|
||||
this->m_enabled = p_enable;
|
||||
|
||||
if (!p_enable) {
|
||||
Stop();
|
||||
}
|
||||
|
|
|
@ -1,20 +1,125 @@
|
|||
#include "jukeboxentity.h"
|
||||
|
||||
// STUB: LEGO1 0x10085bc0
|
||||
#include "isle.h"
|
||||
#include "islepathactor.h"
|
||||
#include "jukeboxstate.h"
|
||||
#include "legogamestate.h"
|
||||
#include "legoutil.h"
|
||||
#include "mxbackgroundaudiomanager.h"
|
||||
#include "mxnotificationmanager.h"
|
||||
#include "mxtransitionmanager.h"
|
||||
|
||||
// FUNCTION: LEGO1 0x10085bc0
|
||||
JukeBoxEntity::JukeBoxEntity()
|
||||
{
|
||||
// TODO
|
||||
NotificationManager()->Register(this);
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10085dd0
|
||||
// FUNCTION: LEGO1 0x10085dd0
|
||||
JukeBoxEntity::~JukeBoxEntity()
|
||||
{
|
||||
// TODO
|
||||
NotificationManager()->Unregister(this);
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10085e40
|
||||
// FUNCTION: LEGO1 0x10085e40
|
||||
MxLong JukeBoxEntity::Notify(MxParam& p_param)
|
||||
{
|
||||
// TODO
|
||||
if (((MxNotificationParam&) p_param).GetType() == c_notificationType11) {
|
||||
if (!FUN_1003ef60()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (CurrentVehicle()->VTable0x60() != GameState()->GetUnknownC()) {
|
||||
CurrentVehicle()->VTable0xe4();
|
||||
}
|
||||
|
||||
((Isle*) FindWorld(*g_isleScript, 0))->SetUnknown13c(0x35);
|
||||
TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10085ed0
|
||||
void JukeBoxEntity::StartAction()
|
||||
{
|
||||
MxDSAction action;
|
||||
BackgroundAudioManager()->Stop();
|
||||
JukeBoxState* state = (JukeBoxState*) GameState()->GetState("JukeBoxState");
|
||||
state->SetActive(TRUE);
|
||||
|
||||
switch (state->GetState()) {
|
||||
case 0:
|
||||
InvokeAction(Extra::e_start, *g_isleScript, 0x319, NULL);
|
||||
GameState()->SetUnknown0x41c(0x37);
|
||||
break;
|
||||
case 1:
|
||||
InvokeAction(Extra::e_start, *g_isleScript, 0x31e, NULL);
|
||||
GameState()->SetUnknown0x41c(0x38);
|
||||
break;
|
||||
case 2:
|
||||
InvokeAction(Extra::e_start, *g_isleScript, 0x31b, NULL);
|
||||
GameState()->SetUnknown0x41c(0x39);
|
||||
break;
|
||||
case 3:
|
||||
InvokeAction(Extra::e_start, *g_isleScript, 0x31a, NULL);
|
||||
GameState()->SetUnknown0x41c(0x3a);
|
||||
break;
|
||||
case 4:
|
||||
InvokeAction(Extra::e_start, *g_isleScript, 0x31f, NULL);
|
||||
GameState()->SetUnknown0x41c(0x3b);
|
||||
break;
|
||||
case 5:
|
||||
InvokeAction(Extra::e_start, *g_isleScript, 0x31c, NULL);
|
||||
GameState()->SetUnknown0x41c(0x3c);
|
||||
break;
|
||||
}
|
||||
|
||||
action.SetAtomId(*g_jukeboxScript);
|
||||
action.SetObjectId(GameState()->GetUnknown0x41c());
|
||||
|
||||
m_audioEnabled = BackgroundAudioManager()->GetEnabled();
|
||||
if (!m_audioEnabled) {
|
||||
BackgroundAudioManager()->Enable(TRUE);
|
||||
}
|
||||
|
||||
BackgroundAudioManager()->PlayMusic(action, 5, 4);
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100860f0
|
||||
void JukeBoxEntity::StopAction(MxU32 p_state)
|
||||
{
|
||||
JukeBoxState* state = (JukeBoxState*) GameState()->GetState("JukeBoxState");
|
||||
|
||||
if (state && state->IsActive()) {
|
||||
switch (p_state) {
|
||||
case 0x37:
|
||||
state->SetActive(FALSE);
|
||||
InvokeAction(Extra::e_stop, *g_isleScript, 0x319, NULL);
|
||||
break;
|
||||
case 0x38:
|
||||
state->SetActive(FALSE);
|
||||
InvokeAction(Extra::e_stop, *g_isleScript, 0x31e, NULL);
|
||||
break;
|
||||
case 0x39:
|
||||
state->SetActive(FALSE);
|
||||
InvokeAction(Extra::e_stop, *g_isleScript, 0x31b, NULL);
|
||||
break;
|
||||
case 0x3a:
|
||||
state->SetActive(FALSE);
|
||||
InvokeAction(Extra::e_stop, *g_isleScript, 0x31a, NULL);
|
||||
break;
|
||||
case 0x3b:
|
||||
state->SetActive(FALSE);
|
||||
InvokeAction(Extra::e_stop, *g_isleScript, 0x31f, NULL);
|
||||
break;
|
||||
case 0x3c:
|
||||
state->SetActive(FALSE);
|
||||
InvokeAction(Extra::e_stop, *g_isleScript, 0x31c, NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
BackgroundAudioManager()->Enable(IsBackgroundAudioEnabled());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ void Radio::Play()
|
|||
action.SetAtomId(*g_jukeboxScript);
|
||||
action.SetLoopCount(1);
|
||||
|
||||
m_bgAudioPreviouslyEnabled = BackgroundAudioManager()->GetMusicEnabled();
|
||||
if (!m_bgAudioPreviouslyEnabled) {
|
||||
m_audioEnabled = BackgroundAudioManager()->GetEnabled();
|
||||
if (!m_audioEnabled) {
|
||||
BackgroundAudioManager()->Enable(TRUE);
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ void Radio::Stop()
|
|||
}
|
||||
|
||||
BackgroundAudioManager()->Stop();
|
||||
BackgroundAudioManager()->Enable(m_bgAudioPreviouslyEnabled);
|
||||
BackgroundAudioManager()->Enable(m_audioEnabled);
|
||||
m_state->SetActive(FALSE);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue