2018-09-02 21:13:34 +02:00
|
|
|
#pragma once
|
|
|
|
|
2018-09-02 09:29:36 +02:00
|
|
|
#include <sol.hpp>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <map>
|
2019-03-15 23:03:54 +01:00
|
|
|
|
2018-09-02 21:13:34 +02:00
|
|
|
#include "..\Global\global.h"
|
2019-03-15 23:03:54 +01:00
|
|
|
#include "..\Specific\IO\ChunkId.h"
|
|
|
|
#include "..\Specific\IO\ChunkReader.h"
|
|
|
|
#include "..\Specific\IO\LEB128.h"
|
|
|
|
#include "LanguageScript.h"
|
2018-09-02 09:29:36 +02:00
|
|
|
|
2019-05-06 23:48:35 +02:00
|
|
|
#define TITLE_FLYBY 0
|
|
|
|
#define TITLE_BACKGROUND 1
|
|
|
|
|
2019-03-15 23:03:54 +01:00
|
|
|
struct ChunkId;
|
|
|
|
struct LEB128;
|
2018-09-02 09:29:36 +02:00
|
|
|
|
2019-03-15 23:03:54 +01:00
|
|
|
using namespace std;
|
2018-09-02 09:29:36 +02:00
|
|
|
|
2019-05-06 23:48:35 +02:00
|
|
|
struct GameScriptSettings {
|
2018-09-02 09:29:36 +02:00
|
|
|
__int32 ScreenWidth;
|
|
|
|
__int32 ScreenHeight;
|
|
|
|
bool EnableLoadSave;
|
|
|
|
bool EnableDynamicShadows;
|
2018-09-03 21:08:40 +02:00
|
|
|
bool EnableWaterCaustics;
|
|
|
|
bool Windowed;
|
2018-09-02 09:29:36 +02:00
|
|
|
string WindowTitle;
|
2018-09-03 21:08:40 +02:00
|
|
|
__int32 DrawingDistance;
|
2018-10-30 18:49:16 +01:00
|
|
|
bool ShowRendererSteps;
|
|
|
|
bool ShowDebugInfo;
|
2018-09-02 09:29:36 +02:00
|
|
|
};
|
|
|
|
|
2019-05-06 23:48:35 +02:00
|
|
|
struct GameScriptSkyLayer {
|
2018-12-28 12:12:58 +01:00
|
|
|
bool Enabled;
|
2018-09-02 21:13:34 +02:00
|
|
|
byte R;
|
|
|
|
byte G;
|
|
|
|
byte B;
|
|
|
|
__int16 CloudSpeed;
|
|
|
|
|
|
|
|
GameScriptSkyLayer()
|
|
|
|
{
|
2018-12-28 12:12:58 +01:00
|
|
|
Enabled = false;
|
|
|
|
R = G = B = CloudSpeed = 0;
|
2018-09-02 21:13:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GameScriptSkyLayer(byte r, byte g, byte b, __int16 speed)
|
|
|
|
{
|
|
|
|
R = r;
|
|
|
|
G = g;
|
|
|
|
B = b;
|
|
|
|
CloudSpeed = speed;
|
2018-12-28 12:12:58 +01:00
|
|
|
Enabled = true;
|
2018-09-02 21:13:34 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-05-06 23:48:35 +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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-05-06 23:48:35 +02:00
|
|
|
struct GameScriptMirror {
|
2018-11-24 09:39:37 +01:00
|
|
|
__int16 Room;
|
|
|
|
__int32 StartX;
|
|
|
|
__int32 EndX;
|
|
|
|
__int32 StartZ;
|
|
|
|
__int32 EndZ;
|
|
|
|
|
|
|
|
GameScriptMirror()
|
|
|
|
{
|
|
|
|
Room = -1;
|
|
|
|
StartX = EndX = StartZ = EndZ = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
GameScriptMirror(__int16 room, __int32 startX, __int32 endX, __int32 startZ, __int32 endZ)
|
|
|
|
{
|
|
|
|
Room = room;
|
|
|
|
StartX = startX;
|
|
|
|
EndX = endX;
|
|
|
|
StartZ = startZ;
|
|
|
|
EndZ = endZ;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-05-06 23:48:35 +02:00
|
|
|
struct GameScriptLevel {
|
2019-03-15 23:03:54 +01:00
|
|
|
__int32 NameStringIndex;
|
2018-09-02 21:13:34 +02:00
|
|
|
string FileName;
|
|
|
|
string ScriptFileName;
|
|
|
|
string LoadScreenFileName;
|
2018-09-03 21:08:40 +02:00
|
|
|
string Background;
|
2018-09-02 21:13:34 +02:00
|
|
|
__int32 Name;
|
|
|
|
__int32 Soundtrack;
|
|
|
|
GameScriptSkyLayer Layer1;
|
|
|
|
GameScriptSkyLayer Layer2;
|
|
|
|
bool Horizon;
|
2019-03-15 23:03:54 +01:00
|
|
|
bool Sky;
|
2018-09-02 21:13:34 +02:00
|
|
|
bool ColAddHorizon;
|
|
|
|
GameScriptFog Fog;
|
2018-09-03 21:08:40 +02:00
|
|
|
bool Storm;
|
2019-03-20 23:43:52 +01:00
|
|
|
WEATHER_TYPES Weather;
|
2018-09-09 22:07:28 +02:00
|
|
|
bool ResetHub;
|
2018-11-08 23:05:25 +01:00
|
|
|
bool Rumble;
|
2018-09-05 23:56:39 +02:00
|
|
|
LARA_DRAW_TYPE LaraType;
|
2018-11-24 09:39:37 +01:00
|
|
|
GameScriptMirror Mirror;
|
2019-03-15 23:03:54 +01:00
|
|
|
byte UVRotate;
|
|
|
|
int LevelFarView;
|
2019-03-20 23:43:52 +01:00
|
|
|
bool UnlimitedAir;
|
2018-09-02 21:13:34 +02:00
|
|
|
|
|
|
|
GameScriptLevel()
|
|
|
|
{
|
2018-09-04 20:54:15 +02:00
|
|
|
Storm = false;
|
|
|
|
Horizon = false;
|
|
|
|
ColAddHorizon = false;
|
2018-11-10 09:27:10 +01:00
|
|
|
ResetHub = false;
|
|
|
|
Rumble = false;
|
2019-03-20 23:43:52 +01:00
|
|
|
Weather = WEATHER_NORMAL;
|
2019-04-30 12:56:27 +02:00
|
|
|
LaraType = LARA_NORMAL;
|
2019-03-20 23:43:52 +01:00
|
|
|
UnlimitedAir = false;
|
2018-09-02 21:13:34 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-03-15 23:03:54 +01:00
|
|
|
extern ChunkReader* g_ScriptChunkIO;
|
|
|
|
|
|
|
|
bool __cdecl readGameFlowLevelChunks(ChunkId* chunkId, __int32 maxSize, __int32 arg);
|
|
|
|
bool __cdecl readGameFlowChunks(ChunkId* chunkId, __int32 maxSize, __int32 arg);
|
|
|
|
bool __cdecl readGameFlowLevel();
|
|
|
|
bool __cdecl readGameFlowStrings();
|
2019-05-31 21:45:13 +02:00
|
|
|
bool __cdecl readGameFlowTracks();
|
2019-03-15 23:03:54 +01:00
|
|
|
bool __cdecl readGameFlowFlags();
|
|
|
|
|
|
|
|
bool __cdecl LoadScript();
|
|
|
|
|
2018-09-22 23:54:36 +02:00
|
|
|
class GameFlow
|
2018-09-02 09:29:36 +02:00
|
|
|
{
|
|
|
|
private:
|
2018-09-22 23:54:36 +02:00
|
|
|
sol::state* m_lua;
|
2018-09-02 21:13:34 +02:00
|
|
|
GameScriptSettings m_settings;
|
2019-03-15 23:03:54 +01:00
|
|
|
|
2018-09-02 21:13:34 +02:00
|
|
|
string loadScriptFromFile(char* luaFilename);
|
2018-09-22 23:54:36 +02:00
|
|
|
map<__int16, __int16> m_itemsMap;
|
2018-09-02 09:29:36 +02:00
|
|
|
|
|
|
|
public:
|
2019-01-13 21:57:16 +01:00
|
|
|
Vector3 SkyColorLayer1;
|
2018-09-02 21:13:34 +02:00
|
|
|
__int32 SkySpeedLayer1;
|
2019-01-13 21:57:16 +01:00
|
|
|
Vector3 SkyColorLayer2;
|
2018-09-02 21:13:34 +02:00
|
|
|
__int32 SkySpeedLayer2;
|
2019-01-13 21:57:16 +01:00
|
|
|
Vector3 FogColor;
|
2018-09-02 21:13:34 +02:00
|
|
|
__int32 FogInDistance;
|
|
|
|
__int32 FogOutDistance;
|
|
|
|
bool DrawHorizon;
|
|
|
|
bool ColAddHorizon;
|
2018-09-03 21:08:40 +02:00
|
|
|
__int32 SelectedLevelForNewGame;
|
2018-10-24 23:32:22 +02:00
|
|
|
__int32 SelectedSaveGame;
|
2019-03-15 23:03:54 +01:00
|
|
|
bool EnableLoadSave;
|
|
|
|
bool PlayAnyLevel;
|
|
|
|
bool FlyCheat;
|
|
|
|
bool DebugMode;
|
|
|
|
__int32 LevelFarView;
|
2019-05-06 23:48:35 +02:00
|
|
|
__int32 TitleType;
|
2019-05-31 21:45:13 +02:00
|
|
|
char* Intro;
|
2019-03-15 23:03:54 +01:00
|
|
|
|
|
|
|
// Selected language set
|
|
|
|
LanguageScript* CurrentStrings;
|
|
|
|
vector<LanguageScript*> Strings;
|
|
|
|
vector<GameScriptLevel*> Levels;
|
2018-09-02 21:13:34 +02:00
|
|
|
|
2018-09-22 23:54:36 +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);
|
|
|
|
char* GetString(__int32 id);
|
|
|
|
GameScriptSettings* GetSettings();
|
|
|
|
GameScriptLevel* GetLevel(__int32 id);
|
|
|
|
void SetHorizon(bool horizon, bool colAddHorizon);
|
|
|
|
void SetLayer1(byte r, byte g, byte b, __int16 speed);
|
|
|
|
void SetLayer2(byte r, byte g, byte b, __int16 speed);
|
|
|
|
void SetFog(byte r, byte g, byte b, __int16 startDistance, __int16 endDistance);
|
2019-03-15 23:03:54 +01:00
|
|
|
__int32 GetNumLevels();
|
2018-09-04 13:24:50 +02:00
|
|
|
bool DoGameflow();
|
2018-09-02 09:29:36 +02:00
|
|
|
};
|