Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SDL_KeyCode in LEGO1.dll #51

Merged
merged 7 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions ISLE/isleapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ IsleApp::~IsleApp()
if (m_savePath) {
delete[] m_savePath;
}

if (m_mediaPath) {
delete[] m_mediaPath;
}
}

// FUNCTION: ISLE 0x401260
Expand Down Expand Up @@ -175,18 +179,16 @@ void IsleApp::Close()
MxS32 IsleApp::SetupLegoOmni()
{
MxS32 result = FALSE;
char mediaPath[256];
GetProfileStringA("LEGO Island", "MediaPath", "", mediaPath, sizeof(mediaPath));

#ifdef COMPAT_MODE
MxS32 failure;
{
MxOmniCreateParam param(mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags());
MxOmniCreateParam param(m_mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags());
failure = Lego()->Create(param) == FAILURE;
}
#else
MxS32 failure =
Lego()->Create(MxOmniCreateParam(mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags())) == FAILURE;
Lego()->Create(MxOmniCreateParam(m_mediaPath, m_windowHandle, m_videoParam, MxOmniCreateFlags())) == FAILURE;
#endif

if (!failure) {
Expand Down Expand Up @@ -525,11 +527,15 @@ void IsleApp::LoadConfig()
iniConfig = new char[strlen(m_iniPath) + 1];
strcpy(iniConfig, m_iniPath);
}
else {
else if (prefPath) {
iniConfig = new char[strlen(prefPath) + strlen("isle.ini") + 1]();
strcat(iniConfig, prefPath);
strcat(iniConfig, "isle.ini");
}
else {
iniConfig = new char[strlen("isle.ini") + 1];
strcpy(iniConfig, "isle.ini");
}
SDL_Log("Reading configuration from \"%s\"", iniConfig);

dictionary* dict = iniparser_load(iniConfig);
Expand All @@ -544,6 +550,10 @@ void IsleApp::LoadConfig()
strcpy(m_cdPath, cdPath);
MxOmni::SetCD(m_cdPath);

const char* mediaPath = iniparser_getstring(dict, "isle:mediapath", hdPath);
m_mediaPath = new char[strlen(mediaPath) + 1];
strcpy(m_mediaPath, mediaPath);

m_flipSurfaces = iniparser_getboolean(dict, "isle:Flip Surfaces", m_flipSurfaces);
m_fullScreen = iniparser_getboolean(dict, "isle:Full Screen", m_fullScreen);
m_wideViewAngle = iniparser_getboolean(dict, "isle:Wide View Angle", m_wideViewAngle);
Expand Down
1 change: 1 addition & 0 deletions ISLE/isleapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class IsleApp {
SDL_Cursor* m_cursorBusy; // 0x80
SDL_Cursor* m_cursorNo; // 0x84
SDL_Cursor* m_cursorCurrent; // 0x88
char* m_mediaPath;

char* m_iniPath;
};
Expand Down
4 changes: 3 additions & 1 deletion LEGO1/lego/legoomni/include/gasstation.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "legoworld.h"
#include "radio.h"

#include <SDL3/SDL_keycode.h>

class MxStillPresenter;

// VTABLE: LEGO1 0x100d46e0
Expand Down Expand Up @@ -95,7 +97,7 @@ class GasStation : public LegoWorld {
inline void StopAction(GarageScript::Script p_objectId);

MxLong HandleEndAction(MxEndActionNotificationParam& p_param);
MxLong HandleKeyPress(MxS8 p_key);
MxLong HandleKeyPress(SDL_Keycode p_key);
MxLong HandleButtonDown(LegoControlManagerNotificationParam& p_param);

MxS16 m_currentActorId; // 0xf8
Expand Down
2 changes: 1 addition & 1 deletion LEGO1/lego/legoomni/include/hospital.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Hospital : public LegoWorld {
// Hospital::`scalar deleting destructor'

private:
MxLong HandleKeyPress(MxS8 p_key);
MxLong HandleKeyPress(SDL_Keycode p_key);
MxLong HandleEndAction(MxEndActionNotificationParam& p_param);
MxLong HandleButtonDown(LegoControlManagerNotificationParam& p_param);
MxBool HandleControl(LegoControlManagerNotificationParam& p_param);
Expand Down
2 changes: 1 addition & 1 deletion LEGO1/lego/legoomni/include/infocenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class Infocenter : public LegoWorld {
private:
void InitializeBitmaps();

MxLong HandleKeyPress(MxS8 p_key);
MxLong HandleKeyPress(SDL_Keycode p_key);
MxU8 HandleMouseMove(MxS32 p_x, MxS32 p_y);
MxU8 HandleButtonUp(MxS32 p_x, MxS32 p_y);
MxU8 HandleControl(LegoControlManagerNotificationParam& p_param);
Expand Down
17 changes: 9 additions & 8 deletions LEGO1/lego/legoomni/include/legoeventnotificationparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "mxnotificationparam.h"
#include "mxtypes.h"

#include <SDL3/SDL_keycode.h>
#include <stdlib.h>

class LegoROI;
Expand Down Expand Up @@ -35,15 +36,15 @@ class LegoEventNotificationParam : public MxNotificationParam {
MxU8 p_modifier,
MxS32 p_x,
MxS32 p_y,
MxU8 p_key
SDL_Keycode p_key
)
: MxNotificationParam(p_type, p_sender), m_modifier(p_modifier), m_x(p_x), m_y(p_y), m_key(p_key), m_roi(NULL)
{
}

LegoROI* GetROI() { return m_roi; }
MxU8 GetModifier() { return m_modifier; }
MxU8 GetKey() const { return m_key; }
SDL_Keycode GetKey() const { return m_key; }

// FUNCTION: LEGO1 0x10012190
// FUNCTION: BETA10 0x10024210
Expand All @@ -59,7 +60,7 @@ class LegoEventNotificationParam : public MxNotificationParam {
void SetModifier(MxU8 p_modifier) { m_modifier = p_modifier; }

// FUNCTION: BETA10 0x1007d6b0
void SetKey(MxU8 p_key) { m_key = p_key; }
void SetKey(SDL_Keycode p_key) { m_key = p_key; }

// FUNCTION: BETA10 0x1007d650
void SetX(MxS32 p_x) { m_x = p_x; }
Expand All @@ -68,11 +69,11 @@ class LegoEventNotificationParam : public MxNotificationParam {
void SetY(MxS32 p_y) { m_y = p_y; }

protected:
MxU8 m_modifier; // 0x0c
MxS32 m_x; // 0x10
MxS32 m_y; // 0x14
MxU8 m_key; // 0x18
LegoROI* m_roi; // 0x1c
MxU8 m_modifier; // 0x0c
MxS32 m_x; // 0x10
MxS32 m_y; // 0x14
SDL_Keycode m_key; // 0x18
LegoROI* m_roi; // 0x1c
};

// SYNTHETIC: LEGO1 0x10028770
Expand Down
3 changes: 2 additions & 1 deletion LEGO1/lego/legoomni/include/legoinputmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <SDL3/SDL_joystick.h>
#include <SDL3/SDL_keyboard.h>
#include <SDL3/SDL_keycode.h>
#include <SDL3/SDL_timer.h>
#include <windows.h>

Expand Down Expand Up @@ -87,7 +88,7 @@ class LegoInputManager : public MxPresenter {
LegoInputManager();
~LegoInputManager() override;

LEGO1_EXPORT void QueueEvent(NotificationId p_id, MxU8 p_modifier, MxLong p_x, MxLong p_y, MxU8 p_key);
LEGO1_EXPORT void QueueEvent(NotificationId p_id, MxU8 p_modifier, MxLong p_x, MxLong p_y, SDL_Keycode p_key);
void Register(MxCore*);
void UnRegister(MxCore*);

Expand Down
2 changes: 1 addition & 1 deletion LEGO1/lego/legoomni/include/registrationbook.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class RegistrationBook : public LegoWorld {
LPDIRECTDRAWSURFACE m_checkboxNormal; // 0x2cc

MxLong HandleEndAction(MxEndActionNotificationParam& p_param);
MxLong HandleKeyPress(MxU8 p_key);
MxLong HandleKeyPress(SDL_Keycode p_key);
MxLong HandleControl(LegoControlManagerNotificationParam& p_param);
MxLong HandlePathStruct(LegoPathStructNotificationParam& p_param);
void FUN_100775c0(MxS16 p_playerIndex);
Expand Down
Loading
Loading