Clean up GameFlowScript.

Remove a lot of members which were unused and which represented level properties already accounted for in GameScriptLevel.

Make TITLE_TYPE an enum class and relabel its values.

Add TitleScreenImagePath and SetTitleScreenImagePath, which replaces GameScriptLevel's Background member.

Register GameScriptColor in GameFlowScript since we will be using it for the fog and sky layer properties of levels.
This commit is contained in:
hispidence 2021-08-07 19:13:36 +01:00
parent d60a86b9b8
commit f4ef0dc468
2 changed files with 21 additions and 57 deletions

View file

@ -7,6 +7,7 @@
#include "savegame.h"
#include "draw.h"
#include "AudioTracks.h"
#include "GameScriptColor.h"
#include "ScriptAssert.h"
#include <Objects/objectslist.h>
#include <Game/newinv2.h>
@ -35,6 +36,7 @@ GameFlow::GameFlow(sol::state* lua) : LuaHandler{ lua }
GameScriptInventoryObject::Register(m_lua);
GameScriptSettings::Register(m_lua);
GameScriptAudioTrack::Register(m_lua);
GameScriptColor::Register(m_lua);
/***
Add a level to the gameflow.
@ -43,12 +45,19 @@ Add a level to the gameflow.
*/
m_lua->set_function("AddLevel", &GameFlow::AddLevel, this);
/***
/*** The path of the .jpg or .png image to show when loading the game.
@function SetIntroImagePath
@tparam string path the path to the image, relative to the TombEngine exe
*/
m_lua->set_function("SetIntroImagePath", &GameFlow::SetIntroImagePath, this);
/*** The path of the .jpg or .png image to show in the background of the title screen.
__(not yet implemented)__
@function SetTitleScreenImagePath
@tparam string path the path to the image, relative to the TombEngine exe
*/
m_lua->set_function("SetTitleScreenImagePath", &GameFlow::SetTitleScreenImagePath, this);
/***
@function SetAudioTracks
@tparam table table array-style table with @{AudioTrack} objects
@ -107,6 +116,11 @@ void GameFlow::SetIntroImagePath(std::string const& path)
IntroImagePath = path;
}
void GameFlow::SetTitleScreenImagePath(std::string const& path)
{
TitleScreenImagePath = path;
}
void GameFlow::SetAudioTracks(sol::as_table_t<std::vector<GameScriptAudioTrack>>&& src)
{
std::vector<GameScriptAudioTrack> tracks = std::move(src);
@ -148,47 +162,6 @@ GameScriptLevel* GameFlow::GetLevel(int id)
return Levels[id];
}
void GameFlow::SetHorizon(bool horizon, bool colAddHorizon)
{
DrawHorizon = horizon;
ColAddHorizon = colAddHorizon;
}
void GameFlow::SetLayer1(byte r, byte g, byte b, short speed)
{
SkyColor1.r = r;
SkyColor1.g = g;
SkyColor1.b = b;
SkyVelocity1 = speed;
SkyColorLayer1.x = r / 255.0f;
SkyColorLayer1.y = g / 255.0f;
SkyColorLayer1.z = b / 255.0f;
SkySpeedLayer1 = speed;
}
void GameFlow::SetLayer2(byte r, byte g, byte b, short speed)
{
SkyColor2.r = r;
SkyColor2.g = g;
SkyColor2.b = b;
SkyVelocity2 = speed;
SkyColorLayer2.x = r / 255.0f;
SkyColorLayer2.y = g / 255.0f;
SkyColorLayer2.z = b / 255.0f;
SkySpeedLayer2 = speed;
}
void GameFlow::SetFog(byte r, byte g, byte b, short startDistance, short endDistance)
{
FogColor.x = r / 255.0f;
FogColor.y = g / 255.0f;
FogColor.z = b / 255.0f;
FogInDistance = startDistance;
FogOutDistance = endDistance;
}
int GameFlow::GetNumLevels()
{
return Levels.size();

View file

@ -6,10 +6,10 @@
#include "GameScriptSettings.h"
#include "GameScriptAudioTrack.h"
enum TITLE_TYPE
enum class TITLE_TYPE
{
TITLE_FLYBY,
TITLE_BACKGROUND
FLYBY,
BACKGROUND
};
class GameFlow : public LuaHandler
@ -23,15 +23,8 @@ private:
std::map<short, short> m_itemsMap;
public:
Vector3 SkyColorLayer1{};
Vector3 SkyColorLayer2{};
Vector3 FogColor{};
int SkySpeedLayer1{ 0 };
int SkySpeedLayer2{ 0 };
int FogInDistance{ 0 };
int FogOutDistance{ 0 };
bool DrawHorizon{ false };
bool ColAddHorizon{ false };
int SelectedLevelForNewGame{ 0 };
int SelectedSaveGame{ 0 };
bool EnableLoadSave{ true };
@ -39,8 +32,9 @@ public:
bool FlyCheat{ true };
bool DebugMode{ false };
int LevelFarView{ 0 };
TITLE_TYPE TitleType{ TITLE_FLYBY };
TITLE_TYPE TitleType{ TITLE_TYPE::FLYBY };
std::string IntroImagePath{};
std::string TitleScreenImagePath{};
// Selected language set
std::vector<GameScriptLevel*> Levels;
@ -57,11 +51,8 @@ public:
void SetSettings(GameScriptSettings const & src);
GameScriptSettings* GetSettings();
GameScriptLevel* GetLevel(int id);
void SetHorizon(bool horizon, bool colAddHorizon);
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();
void SetIntroImagePath(std::string const& path);
void SetTitleScreenImagePath(std::string const& path);
};