TombEngine/TR5Main/Scripting/GameFlowScript.h

209 lines
4.1 KiB
C
Raw Normal View History

2018-09-02 21:13:34 +02:00
#pragma once
#include "ChunkId.h"
#include "ChunkReader.h"
#include "LEB128.h"
#include "LanguageScript.h"
2018-09-02 09:29:36 +02:00
#define TITLE_FLYBY 0
#define TITLE_BACKGROUND 1
struct ChunkId;
struct LEB128;
2018-09-02 09:29:36 +02:00
typedef enum WEATHER_TYPES
{
WEATHER_NORMAL,
WEATHER_RAIN,
WEATHER_SNOW
};
typedef enum LARA_DRAW_TYPE
{
LARA_NORMAL = 1,
LARA_YOUNG = 2,
LARA_BUNHEAD = 3,
LARA_CATSUIT = 4,
LARA_DIVESUIT = 5,
LARA_INVISIBLE = 7
};
struct GameScriptSettings
{
2019-12-02 09:11:21 +01:00
int ScreenWidth;
int ScreenHeight;
2018-09-02 09:29:36 +02:00
bool EnableLoadSave;
bool EnableDynamicShadows;
bool EnableWaterCaustics;
bool Windowed;
2020-06-18 15:54:08 +02:00
std::string WindowTitle;
2019-12-02 09:11:21 +01:00
int DrawingDistance;
bool ShowRendererSteps;
bool ShowDebugInfo;
2018-09-02 09:29:36 +02:00
};
struct GameScriptSkyLayer
{
bool Enabled;
2018-09-02 21:13:34 +02:00
byte R;
byte G;
byte B;
2019-12-02 09:11:21 +01:00
short CloudSpeed;
2018-09-02 21:13:34 +02:00
GameScriptSkyLayer()
{
Enabled = false;
R = G = B = CloudSpeed = 0;
2018-09-02 21:13:34 +02:00
}
2019-12-02 09:11:21 +01:00
GameScriptSkyLayer(byte r, byte g, byte b, short speed)
2018-09-02 21:13:34 +02:00
{
R = r;
G = g;
B = b;
CloudSpeed = speed;
Enabled = true;
2018-09-02 21:13:34 +02:00
}
};
struct GameScriptFog
{
2018-09-02 21:13:34 +02:00
byte R;
byte G;
byte B;
GameScriptFog()
{
}
GameScriptFog(byte r, byte g, byte b)
{
R = r;
G = g;
B = b;
}
};
struct GameScriptMirror
{
2019-12-02 09:11:21 +01:00
short Room;
int StartX;
int EndX;
int StartZ;
int EndZ;
GameScriptMirror()
{
Room = -1;
StartX = EndX = StartZ = EndZ = 0;
}
2019-12-02 09:11:21 +01:00
GameScriptMirror(short room, int startX, int endX, int startZ, int endZ)
{
Room = room;
StartX = startX;
EndX = endX;
StartZ = startZ;
EndZ = endZ;
}
};
struct GameScriptLevel
{
2019-12-02 09:11:21 +01:00
int NameStringIndex;
2020-06-18 15:54:08 +02:00
std::string FileName;
std::string ScriptFileName;
std::string LoadScreenFileName;
std::string Background;
2019-12-02 09:11:21 +01:00
int Name;
int Soundtrack;
2018-09-02 21:13:34 +02:00
GameScriptSkyLayer Layer1;
GameScriptSkyLayer Layer2;
bool Horizon;
bool Sky;
2018-09-02 21:13:34 +02:00
bool ColAddHorizon;
GameScriptFog Fog;
bool Storm;
WEATHER_TYPES Weather;
2018-09-09 22:07:28 +02:00
bool ResetHub;
bool Rumble;
LARA_DRAW_TYPE LaraType;
GameScriptMirror Mirror;
byte UVRotate;
int LevelFarView;
bool UnlimitedAir;
2018-09-02 21:13:34 +02:00
GameScriptLevel()
{
Storm = false;
Horizon = false;
ColAddHorizon = false;
2018-11-10 09:27:10 +01:00
ResetHub = false;
Rumble = false;
Weather = WEATHER_NORMAL;
LaraType = LARA_NORMAL;
UnlimitedAir = false;
2018-09-02 21:13:34 +02:00
}
};
extern ChunkReader* g_ScriptChunkIO;
2019-12-02 09:11:21 +01:00
bool __cdecl readGameFlowLevelChunks(ChunkId* chunkId, int maxSize, int arg);
bool __cdecl readGameFlowChunks(ChunkId* chunkId, int maxSize, int arg);
bool __cdecl readGameFlowLevel();
bool __cdecl readGameFlowStrings();
bool __cdecl readGameFlowTracks();
bool __cdecl readGameFlowFlags();
bool __cdecl LoadScript();
class GameFlow
2018-09-02 09:29:36 +02:00
{
private:
sol::state* m_lua;
2018-09-02 21:13:34 +02:00
GameScriptSettings m_settings;
std::string loadScriptFromFile(char* luaFilename);
std::map<short, short> m_itemsMap;
2018-09-02 09:29:36 +02:00
public:
2019-01-13 21:57:16 +01:00
Vector3 SkyColorLayer1;
2019-12-02 09:11:21 +01:00
int SkySpeedLayer1;
2019-01-13 21:57:16 +01:00
Vector3 SkyColorLayer2;
2019-12-02 09:11:21 +01:00
int SkySpeedLayer2;
2019-01-13 21:57:16 +01:00
Vector3 FogColor;
2019-12-02 09:11:21 +01:00
int FogInDistance;
int FogOutDistance;
2018-09-02 21:13:34 +02:00
bool DrawHorizon;
bool ColAddHorizon;
2019-12-02 09:11:21 +01:00
int SelectedLevelForNewGame;
int SelectedSaveGame;
bool EnableLoadSave;
bool PlayAnyLevel;
bool FlyCheat;
bool DebugMode;
2019-12-02 09:11:21 +01:00
int LevelFarView;
int TitleType;
char* Intro;
// Selected language set
LanguageScript* CurrentStrings;
std::vector<LanguageScript*> Strings;
std::vector<GameScriptLevel*> Levels;
2018-09-02 21:13:34 +02:00
GameFlow(sol::state* lua);
~GameFlow();
2018-09-02 09:29:36 +02:00
2018-09-02 21:13:34 +02:00
bool LoadGameStrings(char* luaFilename);
bool LoadGameSettings(char* luaFilename);
bool ExecuteScript(char* luaFilename);
2019-12-02 09:11:21 +01:00
char* GetString(int id);
2018-09-02 21:13:34 +02:00
GameScriptSettings* GetSettings();
2019-12-02 09:11:21 +01:00
GameScriptLevel* GetLevel(int id);
2018-09-02 21:13:34 +02:00
void SetHorizon(bool horizon, bool colAddHorizon);
2019-12-02 09:11:21 +01:00
void SetLayer1(byte r, byte g, byte b, short speed);
void SetLayer2(byte r, byte g, byte b, short speed);
void SetFog(byte r, byte g, byte b, short startDistance, short endDistance);
int GetNumLevels();
bool DoGameflow();
2018-09-02 09:29:36 +02:00
};