MxVariable subclass for fsmovie setting (#147)

* LegoFullScreenMovie variable and related

* Changes after review
- Reduce scope on global strings
- Size assert for LegoGameState (based on the constructor references only)
- 1 -> TRUE for EnableFullScreenMovie
This commit is contained in:
MS 2023-09-29 16:38:08 -04:00 committed by GitHub
parent b77cd067d3
commit 0dc8dd641a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 103 additions and 5 deletions

View file

@ -65,6 +65,7 @@ add_library(lego1 SHARED
LEGO1/legoentity.cpp
LEGO1/legoentitypresenter.cpp
LEGO1/legoflctexturepresenter.cpp
LEGO1/legofullscreenmovie.cpp
LEGO1/legogamestate.cpp
LEGO1/legohideanimpresenter.cpp
LEGO1/legoinputmanager.cpp

View file

@ -3,6 +3,9 @@
#include "legoomni.h"
#include "legoutil.h"
#include "legovideomanager.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(LegoBackgroundColor, 0x30)
const char *g_delimiter = "\t";
const char *g_set = "set";

View file

@ -3,11 +3,13 @@
#include "mxvariable.h"
// VTABLE 0x100d74a8
// SIZE 0x30
class LegoBackgroundColor : public MxVariable
{
public:
__declspec(dllexport) LegoBackgroundColor(const char *p_key, const char *p_value);
void SetValue(const char *p_colorString);
virtual void SetValue(const char *p_colorString) override;
private:
float h;

View file

@ -0,0 +1,41 @@
#include "legofullscreenmovie.h"
#include "mxtypes.h"
#include "legoomni.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(LegoFullScreenMovie, 0x24)
// 0x100f3be8
const char *g_str_enable = "enable";
// 0x100f3bf4
const char *g_str_disable = "disable";
// OFFSET: LEGO1 0x1003c500
LegoFullScreenMovie::LegoFullScreenMovie(const char *p_key, const char *p_value)
{
m_key = p_key;
m_key.ToUpperCase();
SetValue(p_value);
}
// OFFSET: LEGO1 0x1003c5c0
void LegoFullScreenMovie::SetValue(const char *p_option)
{
m_value = p_option;
m_value.ToLowerCase();
LegoVideoManager *videomanager = VideoManager();
if (videomanager) {
if (!strcmp(m_value.GetData(), g_str_enable)) {
videomanager->EnableFullScreenMovie(TRUE);
return;
}
if (!strcmp(m_value.GetData(), g_str_disable)) {
videomanager->EnableFullScreenMovie(FALSE);
return;
}
}
}

View file

@ -0,0 +1,15 @@
#ifndef LEGOFULLSCREENMOVIE_H
#define LEGOFULLSCREENMOVIE_H
#include "mxvariable.h"
// VTABLE 0x100d74b8
// SIZE 0x24
class LegoFullScreenMovie : public MxVariable
{
public:
LegoFullScreenMovie(const char *p_key, const char *p_value);
virtual void SetValue(const char *p_option) override;
};
#endif // LEGOFULLSCREENMOVIE_H

View file

@ -1,10 +1,26 @@
#include "legogamestate.h"
#include "legoomni.h"
#include "decomp.h"
// Based on the highest dword offset (0x42c) referenced in the constructor.
// There may be other members that come after.
DECOMP_SIZE_ASSERT(LegoGameState, 0x430)
// OFFSET: LEGO1 0x10039550
LegoGameState::LegoGameState()
{
// TODO
m_backgroundColor = new LegoBackgroundColor("backgroundcolor", "set 56 54 68");
VariableTable()->SetVariable(m_backgroundColor);
m_tempBackgroundColor = new LegoBackgroundColor("tempBackgroundcolor", "set 56 54 68");
VariableTable()->SetVariable(m_tempBackgroundColor);
m_fullScreenMovie = new LegoFullScreenMovie("fsmovie", "disable");
VariableTable()->SetVariable(m_fullScreenMovie);
VariableTable()->SetVariable("lightposition", "2");
SerializeScoreHistory(1);
}
// OFFSET: LEGO1 0x10039720

View file

@ -1,8 +1,12 @@
#ifndef LEGOGAMESTATE_H
#define LEGOGAMESTATE_H
#include "decomp.h"
#include "mxtypes.h"
#include "legobackgroundcolor.h"
#include "legofullscreenmovie.h"
// SIZE 0x430 (at least)
class LegoGameState
{
public:
@ -15,7 +19,12 @@ class LegoGameState
__declspec(dllexport) void SetSavePath(char *p);
private:
char *m_savePath;
char *m_savePath; // 0x0
undefined m_unk04[20];
LegoBackgroundColor *m_backgroundColor; // 0x18
LegoBackgroundColor *m_tempBackgroundColor; // 0x1c
LegoFullScreenMovie *m_fullScreenMovie; // 0x20
undefined m_unk24[1036];
};
#endif // LEGOGAMESTATE_H

View file

@ -27,8 +27,14 @@ int LegoVideoManager::DisableRMDevice()
return 0;
}
// OFFSET: LEGO1 0x1007c300
void LegoVideoManager::EnableFullScreenMovie(MxBool p_enable)
{
EnableFullScreenMovie(p_enable, TRUE);
}
// OFFSET: LEGO1 0x1007c310 STUB
void LegoVideoManager::EnableFullScreenMovie(unsigned char a, unsigned char b)
void LegoVideoManager::EnableFullScreenMovie(MxBool p_enable, MxBool p_scale)
{
// TODO
}

View file

@ -16,7 +16,8 @@ class LegoVideoManager : public MxVideoManager
__declspec(dllexport) int EnableRMDevice();
__declspec(dllexport) int DisableRMDevice();
__declspec(dllexport) void EnableFullScreenMovie(unsigned char a, unsigned char b);
void EnableFullScreenMovie(MxBool p_enable);
__declspec(dllexport) void EnableFullScreenMovie(MxBool p_enable, MxBool p_scale);
__declspec(dllexport) void MoveCursor(int x, int y);
inline Lego3DManager *Get3DManager() { return this->m_3dManager; }

View file

@ -1,5 +1,8 @@
#include "mxvariable.h"
#include "mxstring.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(MxVariable, 0x24)
// OFFSET: LEGO1 0x1003bea0
MxString *MxVariable::GetValue()

View file

@ -4,7 +4,8 @@
#include "mxstring.h"
#include "mxcore.h"
//VTABLE: 0x100d74a8
// VTABLE 0x100d7498
// SIZE 0x24
class MxVariable
{
public: