1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00
planetblupi/src/event.h

229 lines
4.9 KiB
C
Raw Normal View History

2017-01-21 17:27:46 +01:00
// Event.h
2017-01-21 23:44:30 +01:00
#pragma once
2017-01-21 17:27:46 +01:00
2017-02-08 22:50:19 +01:00
#include <vector>
#include <unordered_map>
2017-02-10 00:14:28 +01:00
#include "blupi.h"
2017-01-28 23:34:02 +01:00
#include "jauge.h"
#include "menu.h"
#include "button.h"
2017-01-28 23:34:02 +01:00
class CMovie;
2017-01-21 17:27:46 +01:00
/////////////////////////////////////////////////////////////////////////////
typedef struct
{
Uint32 message;
Sint32 type;
Sint32 iconMenu[20];
Sint32 x, y;
2017-02-08 22:50:19 +01:00
const char *toolTips[16];
2017-01-21 17:27:46 +01:00
}
Button;
typedef struct
{
Uint32 phase;
2017-01-21 17:27:46 +01:00
char backName[20];
Sint32 bCDrom;
2017-01-21 17:27:46 +01:00
Button buttons[MAXBUTTON];
}
Phase;
typedef struct
{
Sint16 majRev;
Sint16 minRev;
Sint16 bSchool;
Sint16 bPrivate;
Sint16 world;
Sint16 skill;
Sint16 reserve1[99];
2017-01-21 17:27:46 +01:00
}
DemoHeader;
typedef struct
{
Sint32 time;
Uint32 message;
Uint32 wParam; // WPARAM
Uint32 lParam; // LPARAM
2017-01-21 17:27:46 +01:00
}
DemoEvent;
class CEvent
{
public:
CEvent();
~CEvent();
POINT GetMousePos();
2017-02-05 09:15:08 +01:00
void Create(CPixmap *pPixmap, CDecor *pDecor, CSound *pSound, CMovie *pMovie);
void SetFullScreen(bool bFullScreen);
void SetMouseType(Sint32 mouseType);
Sint32 GetWorld();
Sint32 GetPhysicalWorld();
Sint32 GetImageWorld();
bool IsHelpHide();
bool ChangePhase(Uint32 phase);
2017-01-21 17:27:46 +01:00
void MovieToStart();
Uint32 GetPhase();
2017-01-21 17:27:46 +01:00
void TryInsert();
void RestoreGame();
Sint32 GetButtonIndex(Sint32 button);
Sint32 GetState(Sint32 button);
void SetState(Sint32 button, Sint32 state);
bool GetEnable(Sint32 button);
void SetEnable(Sint32 button, bool bEnable);
bool GetHide(Sint32 button);
void SetHide(Sint32 button, bool bHide);
Sint32 GetMenu(Sint32 button);
void SetMenu(Sint32 button, Sint32 menu);
2017-01-21 17:27:46 +01:00
bool DrawButtons();
2017-01-28 23:34:02 +01:00
MouseSprites MousePosToSprite(POINT pos);
2017-01-21 17:27:46 +01:00
void MouseSprite(POINT pos);
void WaitMouse(bool bWait);
void HideMouse(bool bHide);
2017-01-21 17:27:46 +01:00
POINT GetLastMousePos();
bool TreatEvent(const SDL_Event &event);
bool TreatEventBase(const SDL_Event &event);
2017-01-21 17:27:46 +01:00
void DecorAutoShift(POINT pos);
2017-02-11 18:33:40 +01:00
bool StartMovie(const char *pFilename);
2017-01-21 17:27:46 +01:00
void StopMovie();
bool IsMovie();
2017-01-21 17:27:46 +01:00
void Read(Sint32 message);
void Write(Sint32 message);
2017-01-21 17:27:46 +01:00
void SetSpeed(Sint32 speed);
Sint32 GetSpeed();
bool GetPause();
bool IsShift();
2017-01-21 17:27:46 +01:00
void DemoStep();
void IntroStep();
2017-01-28 23:34:02 +01:00
public:
static void PushUserEvent (Sint32 code);
2017-01-28 23:34:02 +01:00
2017-01-21 17:27:46 +01:00
protected:
void DrawTextCenter(const char *text, Sint32 x, Sint32 y, Sint32 font=0);
bool CreateButtons();
2017-01-28 23:34:02 +01:00
bool EventButtons(const SDL_Event &event, POINT pos);
bool MouseOnButton(POINT pos);
Sint32 SearchPhase(Uint32 phase);
void DecorShift(Sint32 dx, Sint32 dy);
2017-01-21 17:27:46 +01:00
2017-01-28 23:34:02 +01:00
bool PlayDown(POINT pos, const SDL_Event &event);
bool PlayMove(POINT pos, Uint16 mod);
bool PlayUp(POINT pos, Uint16 mod);
void ChangeButtons(Sint32 message);
2017-01-21 17:27:46 +01:00
void BuildFloor(POINT cel, Sint32 insIcon);
void BuildWater(POINT cel, Sint32 insIcon);
2017-01-28 23:34:02 +01:00
bool BuildDown(POINT pos, Uint16 mod, bool bMix=true);
bool BuildMove(POINT pos, Uint16 mod, const SDL_Event &event);
bool BuildUp(POINT pos);
2017-01-21 17:27:46 +01:00
void PrivateLibelle();
bool ReadLibelle(Sint32 world, bool bSchool, bool bHelp);
bool WriteInfo();
bool ReadInfo();
2017-01-21 17:27:46 +01:00
void DemoRecStart();
void DemoRecStop();
bool DemoPlayStart();
2017-01-21 17:27:46 +01:00
void DemoPlayStop();
static void WinToSDLEvent (Uint32 msg, WPARAM wParam, LPARAM lParam, SDL_Event &event);
void DemoRecEvent(Uint32 message, WPARAM wParam, LPARAM lParam);
2017-01-21 17:27:46 +01:00
protected:
Sint32 m_speed;
Sint32 m_exercice;
Sint32 m_mission;
Sint32 m_private;
Sint32 m_maxMission;
Uint32 m_phase;
Sint32 m_index;
bool m_bSchool;
bool m_bPrivate;
bool m_bAccessBuild;
bool m_bFullScreen;
Sint32 m_mouseType;
2017-01-21 17:27:46 +01:00
CPixmap* m_pPixmap;
CDecor* m_pDecor;
CSound* m_pSound;
CMovie* m_pMovie;
char m_movieToStart[MAX_PATH];
Sint32 m_phaseAfterMovie;
2017-01-21 17:27:46 +01:00
CButton m_buttons[MAXBUTTON];
Sint32 m_lastFloor[MAXBUTTON];
Sint32 m_lastObject[MAXBUTTON];
Sint32 m_lastHome[MAXBUTTON];
bool m_bRunMovie;
bool m_bBuildModify;
2017-01-21 17:27:46 +01:00
CJauge m_jauges[2];
CMenu m_menu;
bool m_bMenu;
2017-01-21 17:27:46 +01:00
POINT m_menuPos;
Sint32 m_menuNb;
Sint32 m_menuButtons[MAXBUTTON];
Sint32 m_menuErrors[MAXBUTTON];
std::unordered_map<Sint32, const char *> m_menuTexts;
Sint32 m_menuPerso;
2017-01-21 17:27:46 +01:00
POINT m_menuCel;
POINT m_oldMousePos;
bool m_bMouseDown;
bool m_bHili;
Sint32 m_fileWorld[10];
Sint32 m_fileTime[10];
2017-01-21 17:27:46 +01:00
POINT m_posToolTips;
char m_textToolTips[50];
2017-01-28 23:34:02 +01:00
MouseSprites m_mouseSprite;
bool m_bFillMouse;
bool m_bWaitMouse;
bool m_bHideMouse;
Sint32 m_rankCheat;
Sint32 m_posCheat;
bool m_bMovie;
bool m_bSpeed;
bool m_bHelp;
bool m_bAllMissions;
bool m_bChangeCheat;
Sint32 m_scrollSpeed;
bool m_bPause;
bool m_bShift;
Sint32 m_shiftPhase;
2017-01-21 17:27:46 +01:00
POINT m_shiftVector;
POINT m_shiftOffset;
char m_libelle[1000];
Sint32 m_tryPhase;
Sint32 m_tryInsertCount;
2017-01-21 17:27:46 +01:00
POINT m_posInfoButton;
POINT m_posHelpButton;
bool m_bHiliInfoButton;
bool m_bHiliHelpButton;
bool m_bInfoHelp;
bool m_bDemoRec;
bool m_bDemoPlay;
2017-01-21 17:27:46 +01:00
DemoEvent* m_pDemoBuffer;
Sint32 m_demoTime;
size_t m_demoIndex;
size_t m_demoEnd;
Sint32 m_demoNumber;
2017-01-28 23:34:02 +01:00
Uint16 m_keymod;
2017-01-21 17:27:46 +01:00
POINT m_debugPos;
Sint32 m_introTime;
2017-01-21 17:27:46 +01:00
};
/////////////////////////////////////////////////////////////////////////////