mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-02 17:57:59 +03:00
Missed these in the last commit.
This commit is contained in:
parent
e6c076eb41
commit
b566e33f68
2 changed files with 52 additions and 242 deletions
|
@ -14,6 +14,12 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/***
|
||||||
|
functions for gameflow
|
||||||
|
@module gameflow
|
||||||
|
@pragma nostrip
|
||||||
|
*/
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
using std::unordered_map;
|
using std::unordered_map;
|
||||||
|
@ -22,92 +28,44 @@ extern unordered_map<string, AudioTrack> g_AudioTracks;
|
||||||
|
|
||||||
GameFlow::GameFlow(sol::state* lua) : LuaHandler{ lua }
|
GameFlow::GameFlow(sol::state* lua) : LuaHandler{ lua }
|
||||||
{
|
{
|
||||||
// Settings type
|
GameScriptLevel::Register(m_lua);
|
||||||
m_lua->new_usertype<GameScriptSettings>("GameScriptSettings",
|
GameScriptSkyLayer::Register(m_lua);
|
||||||
"screenWidth", &GameScriptSettings::ScreenWidth,
|
GameScriptMirror::Register(m_lua);
|
||||||
"screenHeight", &GameScriptSettings::ScreenHeight,
|
GameScriptInventoryObject::Register(m_lua);
|
||||||
"windowTitle", &GameScriptSettings::WindowTitle,
|
GameScriptSettings::Register(m_lua);
|
||||||
"enableDynamicShadows", &GameScriptSettings::EnableDynamicShadows,
|
GameScriptAudioTrack::Register(m_lua);
|
||||||
"windowed", &GameScriptSettings::Windowed,
|
|
||||||
"enableWaterCaustics", &GameScriptSettings::EnableWaterCaustics,
|
|
||||||
"drawingDistance", &GameScriptSettings::DrawingDistance,
|
|
||||||
"showRendererSteps", &GameScriptSettings::ShowRendererSteps,
|
|
||||||
"showDebugInfo", &GameScriptSettings::ShowDebugInfo
|
|
||||||
);
|
|
||||||
|
|
||||||
// Layer type
|
/***
|
||||||
m_lua->new_usertype<GameScriptSkyLayer>("SkyLayer",
|
Add a level to the gameflow.
|
||||||
sol::constructors<GameScriptSkyLayer(byte, byte, byte, short)>(),
|
@function AddLevel
|
||||||
"r", &GameScriptSkyLayer::R,
|
@tparam @{Level} level a level object
|
||||||
"g", &GameScriptSkyLayer::G,
|
*/
|
||||||
"b", &GameScriptSkyLayer::B,
|
m_lua->set_function("AddLevel", &GameFlow::AddLevel, this);
|
||||||
"speed", &GameScriptSkyLayer::CloudSpeed
|
|
||||||
);
|
|
||||||
|
|
||||||
// Mirror type
|
/***
|
||||||
m_lua->new_usertype<GameScriptMirror>("Mirror",
|
@function SetIntroImagePath
|
||||||
sol::constructors<GameScriptMirror(short, int, int, int, int)>(),
|
@tparam string path the path to the image, relative to the TombEngine exe
|
||||||
"room", &GameScriptMirror::Room,
|
*/
|
||||||
"startX", &GameScriptMirror::StartX,
|
m_lua->set_function("SetIntroImagePath", &GameFlow::SetIntroImagePath, this);
|
||||||
"endX", &GameScriptMirror::EndX,
|
|
||||||
"startZ", &GameScriptMirror::StartZ,
|
|
||||||
"endZ", &GameScriptMirror::EndZ
|
|
||||||
);
|
|
||||||
|
|
||||||
// Inventory object type
|
/***
|
||||||
m_lua->new_usertype<GameScriptInventoryObject>("InventoryObject",
|
@function SetAudioTracks
|
||||||
sol::constructors<GameScriptInventoryObject(std::string, short, float, float, float, float, float, short, int, __int64)>(),
|
@tparam table table array-style table with @{AudioTrack} objects
|
||||||
"name", &GameScriptInventoryObject::name,
|
*/
|
||||||
"yOffset", &GameScriptInventoryObject::yOffset,
|
m_lua->set_function("SetAudioTracks", &GameFlow::SetAudioTracks, this);
|
||||||
"scale", &GameScriptInventoryObject::scale,
|
|
||||||
"xRot", &GameScriptInventoryObject::xRot,
|
|
||||||
"yRot", &GameScriptInventoryObject::yRot,
|
|
||||||
"zRot", &GameScriptInventoryObject::zRot,
|
|
||||||
"rotationFlags", &GameScriptInventoryObject::rotationFlags,
|
|
||||||
"meshBits", &GameScriptInventoryObject::meshBits,
|
|
||||||
"operation", &GameScriptInventoryObject::operation
|
|
||||||
);
|
|
||||||
|
|
||||||
// Audio track type
|
|
||||||
m_lua->new_usertype<GameScriptAudioTrack>("AudioTrack",
|
|
||||||
sol::constructors<GameScriptAudioTrack(std::string, bool)>(),
|
|
||||||
"trackName", &GameScriptAudioTrack::trackName,
|
|
||||||
"looped", &GameScriptAudioTrack::looped
|
|
||||||
);
|
|
||||||
|
|
||||||
// Level type
|
/***
|
||||||
m_lua->new_usertype<GameScriptLevel>("Level",
|
@function SetStrings
|
||||||
sol::constructors<GameScriptLevel()>(),
|
@tparam table table array-style table with strings
|
||||||
"name", &GameScriptLevel::NameStringKey,
|
*/
|
||||||
"script", &GameScriptLevel::ScriptFileName,
|
m_lua->set_function("SetStrings", &GameFlow::SetStrings, this);
|
||||||
"fileName", &GameScriptLevel::FileName,
|
|
||||||
"loadScreen", &GameScriptLevel::LoadScreenFileName,
|
|
||||||
"ambientTrack", &GameScriptLevel::AmbientTrack,
|
|
||||||
"layer1", &GameScriptLevel::Layer1,
|
|
||||||
"layer2", &GameScriptLevel::Layer2,
|
|
||||||
"fog", &GameScriptLevel::Fog,
|
|
||||||
"horizon", &GameScriptLevel::Horizon,
|
|
||||||
"colAddHorizon", &GameScriptLevel::ColAddHorizon,
|
|
||||||
"storm", &GameScriptLevel::Storm,
|
|
||||||
"background", &GameScriptLevel::Background,
|
|
||||||
"weather", &GameScriptLevel::Weather,
|
|
||||||
"laraType", &GameScriptLevel::LaraType,
|
|
||||||
"rumble", &GameScriptLevel::Rumble,
|
|
||||||
"resetHub", &GameScriptLevel::ResetHub,
|
|
||||||
"mirror", &GameScriptLevel::Mirror,
|
|
||||||
"objects", &GameScriptLevel::InventoryObjects
|
|
||||||
);
|
|
||||||
|
|
||||||
(*m_lua)["GameFlow"] = std::ref(*this);
|
/***
|
||||||
|
@function SetLanguageNames
|
||||||
m_lua->new_usertype<GameFlow>("_GameFlow",
|
@tparam table table array-style table with TODO EXTRA INFO HERE
|
||||||
sol::no_constructor,
|
*/
|
||||||
"AddLevel", &GameFlow::AddLevel,
|
m_lua->set_function("SetLanguageNames", &GameFlow::SetLanguageNames, this);
|
||||||
"WriteDefaults", &GameFlow::WriteDefaults,
|
|
||||||
"SetAudioTracks", &GameFlow::SetAudioTracks,
|
|
||||||
"SetStrings", &GameFlow::SetStrings,
|
|
||||||
"SetLanguageNames", &GameFlow::SetLanguageNames
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameFlow::~GameFlow()
|
GameFlow::~GameFlow()
|
||||||
|
@ -128,17 +86,16 @@ void GameFlow::SetStrings(sol::nested<std::unordered_map<std::string, std::vecto
|
||||||
m_translationsMap = std::move(src);
|
m_translationsMap = std::move(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
//hardcoded for now
|
|
||||||
void GameFlow::WriteDefaults()
|
|
||||||
{
|
|
||||||
Intro = "SCREENS\\MAIN.PNG";
|
|
||||||
}
|
|
||||||
|
|
||||||
void GameFlow::AddLevel(GameScriptLevel const& level)
|
void GameFlow::AddLevel(GameScriptLevel const& level)
|
||||||
{
|
{
|
||||||
Levels.push_back(new GameScriptLevel{ level });
|
Levels.push_back(new GameScriptLevel{ level });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameFlow::SetIntroImagePath(std::string const& path)
|
||||||
|
{
|
||||||
|
IntroImagePath = path;
|
||||||
|
}
|
||||||
|
|
||||||
void GameFlow::SetAudioTracks(sol::as_table_t<std::vector<GameScriptAudioTrack>>&& src)
|
void GameFlow::SetAudioTracks(sol::as_table_t<std::vector<GameScriptAudioTrack>>&& src)
|
||||||
{
|
{
|
||||||
std::vector<GameScriptAudioTrack> tracks = std::move(src);
|
std::vector<GameScriptAudioTrack> tracks = std::move(src);
|
||||||
|
@ -169,9 +126,7 @@ bool GameFlow::LoadGameFlowScript()
|
||||||
std::cout << err << "\n";
|
std::cout << err << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hardcode English for now - this will be changed
|
// Populate strings
|
||||||
// to something like "Strings.lua" once that system
|
|
||||||
// through
|
|
||||||
if (!ExecuteScript("Scripts/Strings.lua", err)) {
|
if (!ExecuteScript("Scripts/Strings.lua", err)) {
|
||||||
std::cout << err << "\n";
|
std::cout << err << "\n";
|
||||||
}
|
}
|
||||||
|
@ -184,7 +139,7 @@ char const * GameFlow::GetString(const char* id)
|
||||||
if (m_translationsMap.find(id) == m_translationsMap.end())
|
if (m_translationsMap.find(id) == m_translationsMap.end())
|
||||||
return "String not found";
|
return "String not found";
|
||||||
else
|
else
|
||||||
return (char*)(m_translationsMap.at(string(id)).at(0).c_str());
|
return m_translationsMap.at(string(id)).at(0).c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
GameScriptSettings* GameFlow::GetSettings()
|
GameScriptSettings* GameFlow::GetSettings()
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#include "LanguageScript.h"
|
#include "LanguageScript.h"
|
||||||
#include "LuaHandler.h"
|
#include "LuaHandler.h"
|
||||||
#include "GameScriptColor.h"
|
#include "GameScriptColor.h"
|
||||||
|
#include "GameScriptLevel.h"
|
||||||
|
#include "GameScriptSettings.h"
|
||||||
|
#include "GameScriptAudioTrack.h"
|
||||||
|
|
||||||
enum TITLE_TYPE
|
enum TITLE_TYPE
|
||||||
{
|
{
|
||||||
|
@ -9,163 +12,15 @@ enum TITLE_TYPE
|
||||||
TITLE_BACKGROUND
|
TITLE_BACKGROUND
|
||||||
};
|
};
|
||||||
|
|
||||||
enum WEATHER_TYPE
|
|
||||||
{
|
|
||||||
WEATHER_NORMAL,
|
|
||||||
WEATHER_RAIN,
|
|
||||||
WEATHER_SNOW
|
|
||||||
};
|
|
||||||
|
|
||||||
enum LARA_DRAW_TYPE
|
|
||||||
{
|
|
||||||
LARA_NORMAL = 1,
|
|
||||||
LARA_YOUNG = 2,
|
|
||||||
LARA_BUNHEAD = 3,
|
|
||||||
LARA_CATSUIT = 4,
|
|
||||||
LARA_DIVESUIT = 5,
|
|
||||||
LARA_INVISIBLE = 7
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GameScriptSettings
|
|
||||||
{
|
|
||||||
int ScreenWidth;
|
|
||||||
int ScreenHeight;
|
|
||||||
bool EnableLoadSave;
|
|
||||||
bool EnableDynamicShadows;
|
|
||||||
bool EnableWaterCaustics;
|
|
||||||
bool Windowed;
|
|
||||||
std::string WindowTitle;
|
|
||||||
int DrawingDistance;
|
|
||||||
bool ShowRendererSteps;
|
|
||||||
bool ShowDebugInfo;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GameScriptInventoryObject
|
|
||||||
{
|
|
||||||
std::string name;
|
|
||||||
short slot;
|
|
||||||
float yOffset;
|
|
||||||
float scale;
|
|
||||||
float xRot;
|
|
||||||
float yRot;
|
|
||||||
float zRot;
|
|
||||||
short rotationFlags;
|
|
||||||
int meshBits;
|
|
||||||
__int64 operation;
|
|
||||||
|
|
||||||
GameScriptInventoryObject(std::string name, short slot, float yOffset, float scale, float xRot, float yRot, float zRot, short rotationFlags, int meshBits, __int64 operation)
|
|
||||||
{
|
|
||||||
this->name = name;
|
|
||||||
this->slot = slot;
|
|
||||||
this->yOffset = yOffset;
|
|
||||||
this->scale = scale;
|
|
||||||
this->xRot = xRot;
|
|
||||||
this->yRot = yRot;
|
|
||||||
this->zRot = zRot;
|
|
||||||
this->rotationFlags = rotationFlags;
|
|
||||||
this->meshBits = meshBits;
|
|
||||||
this->operation = operation;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GameScriptSkyLayer
|
|
||||||
{
|
|
||||||
bool Enabled;
|
|
||||||
byte R;
|
|
||||||
byte G;
|
|
||||||
byte B;
|
|
||||||
short CloudSpeed;
|
|
||||||
|
|
||||||
GameScriptSkyLayer()
|
|
||||||
{
|
|
||||||
Enabled = false;
|
|
||||||
R = G = B = CloudSpeed = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameScriptSkyLayer(byte r, byte g, byte b, short speed)
|
|
||||||
{
|
|
||||||
R = r;
|
|
||||||
G = g;
|
|
||||||
B = b;
|
|
||||||
CloudSpeed = speed;
|
|
||||||
Enabled = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GameScriptMirror
|
|
||||||
{
|
|
||||||
short Room;
|
|
||||||
int StartX;
|
|
||||||
int EndX;
|
|
||||||
int StartZ;
|
|
||||||
int EndZ;
|
|
||||||
|
|
||||||
GameScriptMirror()
|
|
||||||
{
|
|
||||||
Room = -1;
|
|
||||||
StartX = EndX = StartZ = EndZ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
GameScriptMirror(short room, int startX, int endX, int startZ, int endZ)
|
|
||||||
{
|
|
||||||
Room = room;
|
|
||||||
StartX = startX;
|
|
||||||
EndX = endX;
|
|
||||||
StartZ = startZ;
|
|
||||||
EndZ = endZ;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GameScriptLevel
|
|
||||||
{
|
|
||||||
std::string NameStringKey;
|
|
||||||
std::string FileName;
|
|
||||||
std::string ScriptFileName;
|
|
||||||
std::string LoadScreenFileName;
|
|
||||||
std::string Background;
|
|
||||||
int Name;
|
|
||||||
std::string AmbientTrack;
|
|
||||||
GameScriptSkyLayer Layer1;
|
|
||||||
GameScriptSkyLayer Layer2;
|
|
||||||
bool Horizon{ false };
|
|
||||||
bool Sky;
|
|
||||||
bool ColAddHorizon{ false };
|
|
||||||
GameScriptColor Fog{ 0,0,0 };
|
|
||||||
bool Storm{ false };
|
|
||||||
WEATHER_TYPE Weather{ WEATHER_NORMAL };
|
|
||||||
bool ResetHub{ false };
|
|
||||||
bool Rumble{ false };
|
|
||||||
LARA_DRAW_TYPE LaraType{ LARA_NORMAL };
|
|
||||||
GameScriptMirror Mirror;
|
|
||||||
byte UVRotate;
|
|
||||||
int LevelFarView;
|
|
||||||
bool UnlimitedAir{ false };
|
|
||||||
std::vector<GameScriptInventoryObject> InventoryObjects;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct GameScriptAudioTrack
|
|
||||||
{
|
|
||||||
std::string trackName;
|
|
||||||
bool looped;
|
|
||||||
|
|
||||||
GameScriptAudioTrack(std::string trackName, bool looped)
|
|
||||||
{
|
|
||||||
this->trackName = trackName;
|
|
||||||
this->looped = looped;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
bool __cdecl LoadScript();
|
|
||||||
|
|
||||||
class GameFlow : public LuaHandler
|
class GameFlow : public LuaHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
GameScriptSettings m_settings;
|
GameScriptSettings m_settings;
|
||||||
|
|
||||||
std::unordered_map < std::string, std::vector<std::string > > m_translationsMap;
|
std::unordered_map < std::string, std::vector<std::string > > m_translationsMap;
|
||||||
std::vector<std::string> m_languageNames;
|
std::vector<std::string> m_languageNames;
|
||||||
|
|
||||||
std::map<short, short> m_itemsMap;
|
std::map<short, short> m_itemsMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Vector3 SkyColorLayer1{};
|
Vector3 SkyColorLayer1{};
|
||||||
|
@ -185,7 +40,7 @@ public:
|
||||||
bool DebugMode{ false };
|
bool DebugMode{ false };
|
||||||
int LevelFarView{ 0 };
|
int LevelFarView{ 0 };
|
||||||
TITLE_TYPE TitleType{ TITLE_BACKGROUND };
|
TITLE_TYPE TitleType{ TITLE_BACKGROUND };
|
||||||
char const* Intro{ nullptr };
|
std::string IntroImagePath{};
|
||||||
|
|
||||||
// Selected language set
|
// Selected language set
|
||||||
std::vector<GameScriptLevel*> Levels;
|
std::vector<GameScriptLevel*> Levels;
|
||||||
|
@ -193,7 +48,6 @@ public:
|
||||||
GameFlow(sol::state* lua);
|
GameFlow(sol::state* lua);
|
||||||
~GameFlow();
|
~GameFlow();
|
||||||
|
|
||||||
void WriteDefaults();
|
|
||||||
void AddLevel(GameScriptLevel const& level);
|
void AddLevel(GameScriptLevel const& level);
|
||||||
void SetAudioTracks(sol::as_table_t<std::vector<GameScriptAudioTrack>>&& src);
|
void SetAudioTracks(sol::as_table_t<std::vector<GameScriptAudioTrack>>&& src);
|
||||||
bool LoadGameFlowScript();
|
bool LoadGameFlowScript();
|
||||||
|
@ -208,4 +62,5 @@ public:
|
||||||
void SetFog(byte r, byte g, byte b, short startDistance, short endDistance);
|
void SetFog(byte r, byte g, byte b, short startDistance, short endDistance);
|
||||||
int GetNumLevels();
|
int GetNumLevels();
|
||||||
bool DoGameflow();
|
bool DoGameflow();
|
||||||
|
void SetIntroImagePath(std::string const& path);
|
||||||
};
|
};
|
Loading…
Add table
Add a link
Reference in a new issue