Missed these in the last commit.

This commit is contained in:
hispidence 2021-07-28 19:06:15 +01:00
parent 5562667f98
commit 8b7928d83e
2 changed files with 52 additions and 242 deletions

View file

@ -14,6 +14,12 @@
#include <iostream>
#endif
/***
functions for gameflow
@module gameflow
@pragma nostrip
*/
using std::string;
using std::vector;
using std::unordered_map;
@ -22,92 +28,44 @@ extern unordered_map<string, AudioTrack> g_AudioTracks;
GameFlow::GameFlow(sol::state* lua) : LuaHandler{ lua }
{
// Settings type
m_lua->new_usertype<GameScriptSettings>("GameScriptSettings",
"screenWidth", &GameScriptSettings::ScreenWidth,
"screenHeight", &GameScriptSettings::ScreenHeight,
"windowTitle", &GameScriptSettings::WindowTitle,
"enableDynamicShadows", &GameScriptSettings::EnableDynamicShadows,
"windowed", &GameScriptSettings::Windowed,
"enableWaterCaustics", &GameScriptSettings::EnableWaterCaustics,
"drawingDistance", &GameScriptSettings::DrawingDistance,
"showRendererSteps", &GameScriptSettings::ShowRendererSteps,
"showDebugInfo", &GameScriptSettings::ShowDebugInfo
);
GameScriptLevel::Register(m_lua);
GameScriptSkyLayer::Register(m_lua);
GameScriptMirror::Register(m_lua);
GameScriptInventoryObject::Register(m_lua);
GameScriptSettings::Register(m_lua);
GameScriptAudioTrack::Register(m_lua);
// Layer type
m_lua->new_usertype<GameScriptSkyLayer>("SkyLayer",
sol::constructors<GameScriptSkyLayer(byte, byte, byte, short)>(),
"r", &GameScriptSkyLayer::R,
"g", &GameScriptSkyLayer::G,
"b", &GameScriptSkyLayer::B,
"speed", &GameScriptSkyLayer::CloudSpeed
);
/***
Add a level to the gameflow.
@function AddLevel
@tparam @{Level} level a level object
*/
m_lua->set_function("AddLevel", &GameFlow::AddLevel, this);
// Mirror type
m_lua->new_usertype<GameScriptMirror>("Mirror",
sol::constructors<GameScriptMirror(short, int, int, int, int)>(),
"room", &GameScriptMirror::Room,
"startX", &GameScriptMirror::StartX,
"endX", &GameScriptMirror::EndX,
"startZ", &GameScriptMirror::StartZ,
"endZ", &GameScriptMirror::EndZ
);
/***
@function SetIntroImagePath
@tparam string path the path to the image, relative to the TombEngine exe
*/
m_lua->set_function("SetIntroImagePath", &GameFlow::SetIntroImagePath, this);
// Inventory object type
m_lua->new_usertype<GameScriptInventoryObject>("InventoryObject",
sol::constructors<GameScriptInventoryObject(std::string, short, float, float, float, float, float, short, int, __int64)>(),
"name", &GameScriptInventoryObject::name,
"yOffset", &GameScriptInventoryObject::yOffset,
"scale", &GameScriptInventoryObject::scale,
"xRot", &GameScriptInventoryObject::xRot,
"yRot", &GameScriptInventoryObject::yRot,
"zRot", &GameScriptInventoryObject::zRot,
"rotationFlags", &GameScriptInventoryObject::rotationFlags,
"meshBits", &GameScriptInventoryObject::meshBits,
"operation", &GameScriptInventoryObject::operation
);
/***
@function SetAudioTracks
@tparam table table array-style table with @{AudioTrack} objects
*/
m_lua->set_function("SetAudioTracks", &GameFlow::SetAudioTracks, this);
// 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",
sol::constructors<GameScriptLevel()>(),
"name", &GameScriptLevel::NameStringKey,
"script", &GameScriptLevel::ScriptFileName,
"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
);
/***
@function SetStrings
@tparam table table array-style table with strings
*/
m_lua->set_function("SetStrings", &GameFlow::SetStrings, this);
(*m_lua)["GameFlow"] = std::ref(*this);
m_lua->new_usertype<GameFlow>("_GameFlow",
sol::no_constructor,
"AddLevel", &GameFlow::AddLevel,
"WriteDefaults", &GameFlow::WriteDefaults,
"SetAudioTracks", &GameFlow::SetAudioTracks,
"SetStrings", &GameFlow::SetStrings,
"SetLanguageNames", &GameFlow::SetLanguageNames
);
/***
@function SetLanguageNames
@tparam table table array-style table with TODO EXTRA INFO HERE
*/
m_lua->set_function("SetLanguageNames", &GameFlow::SetLanguageNames, this);
}
GameFlow::~GameFlow()
@ -128,17 +86,16 @@ void GameFlow::SetStrings(sol::nested<std::unordered_map<std::string, std::vecto
m_translationsMap = std::move(src);
}
//hardcoded for now
void GameFlow::WriteDefaults()
{
Intro = "SCREENS\\MAIN.PNG";
}
void GameFlow::AddLevel(GameScriptLevel const& 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)
{
std::vector<GameScriptAudioTrack> tracks = std::move(src);
@ -169,9 +126,7 @@ bool GameFlow::LoadGameFlowScript()
std::cout << err << "\n";
}
// Hardcode English for now - this will be changed
// to something like "Strings.lua" once that system
// through
// Populate strings
if (!ExecuteScript("Scripts/Strings.lua", err)) {
std::cout << err << "\n";
}
@ -184,7 +139,7 @@ char const * GameFlow::GetString(const char* id)
if (m_translationsMap.find(id) == m_translationsMap.end())
return "String not found";
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()