mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-06 19:01:06 +03:00
Add GameScriptCameraInfo.h and GameScriptCameraInfo.cpp.
This commit is contained in:
parent
dbe6ffdd5c
commit
cb59e06493
3 changed files with 121 additions and 0 deletions
90
TR5Main/Scripting/GameScriptCameraInfo.cpp
Normal file
90
TR5Main/Scripting/GameScriptCameraInfo.cpp
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
#include "framework.h"
|
||||||
|
#include "GameScriptCameraInfo.h"
|
||||||
|
#include "GameScriptPosition.h"
|
||||||
|
/***
|
||||||
|
Camera info
|
||||||
|
|
||||||
|
@classmod CameraInfo
|
||||||
|
@pragma nostrip
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern bool const WarningsAsErrors;
|
||||||
|
|
||||||
|
static constexpr auto LUA_CLASS_NAME{ "CameraInfo" };
|
||||||
|
|
||||||
|
static auto index_error = index_error_maker(GameScriptCameraInfo, LUA_CLASS_NAME);
|
||||||
|
|
||||||
|
GameScriptCameraInfo::GameScriptCameraInfo(LEVEL_CAMERA_INFO & ref, bool temp) : m_camera{ref}, m_temporary{ temp }
|
||||||
|
{};
|
||||||
|
|
||||||
|
GameScriptCameraInfo::~GameScriptCameraInfo() {
|
||||||
|
if (m_temporary)
|
||||||
|
{
|
||||||
|
s_callbackRemoveName(m_camera.luaName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScriptCameraInfo::Register(sol::state* state)
|
||||||
|
{
|
||||||
|
state->new_usertype<GameScriptCameraInfo>(LUA_CLASS_NAME,
|
||||||
|
sol::meta_function::index, index_error,
|
||||||
|
|
||||||
|
/// (@{Position}) position in level
|
||||||
|
// @mem pos
|
||||||
|
"pos", sol::property(&GameScriptCameraInfo::GetPos, &GameScriptCameraInfo::SetPos),
|
||||||
|
|
||||||
|
/// (string) unique string identifier.
|
||||||
|
// e.g. "flyby\_start" or "big\_door\_hint"
|
||||||
|
// @mem name
|
||||||
|
"name", sol::property(&GameScriptCameraInfo::GetName, &GameScriptCameraInfo::SetName),
|
||||||
|
|
||||||
|
/// (string) room number
|
||||||
|
// @mem room
|
||||||
|
"room", sol::property(&GameScriptCameraInfo::GetRoom, &GameScriptCameraInfo::SetRoom)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameScriptPosition GameScriptCameraInfo::GetPos() const
|
||||||
|
{
|
||||||
|
return GameScriptPosition{ m_camera.x, m_camera.y, m_camera.z };
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScriptCameraInfo::SetPos(GameScriptPosition const& pos)
|
||||||
|
{
|
||||||
|
m_camera.x = pos.x;
|
||||||
|
m_camera.y = pos.y;
|
||||||
|
m_camera.z = pos.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GameScriptCameraInfo::GetName() const
|
||||||
|
{
|
||||||
|
return m_camera.luaName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScriptCameraInfo::SetName(std::string const & id)
|
||||||
|
{
|
||||||
|
if (id.empty() && WarningsAsErrors)
|
||||||
|
throw std::runtime_error("Name cannot be blank");
|
||||||
|
|
||||||
|
// remove the old name if we have one
|
||||||
|
s_callbackRemoveName(m_camera.luaName);
|
||||||
|
|
||||||
|
// un-register any other objects using this name.
|
||||||
|
// maybe we should throw an error if another object
|
||||||
|
// already uses the name...
|
||||||
|
s_callbackRemoveName(id);
|
||||||
|
m_camera.luaName = id;
|
||||||
|
// todo add error checking
|
||||||
|
s_callbackSetName(id, m_camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
short GameScriptCameraInfo::GetRoom() const
|
||||||
|
{
|
||||||
|
return m_camera.roomNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameScriptCameraInfo::SetRoom(short room)
|
||||||
|
{
|
||||||
|
m_camera.roomNumber = room;
|
||||||
|
}
|
||||||
|
|
29
TR5Main/Scripting/GameScriptCameraInfo.h
Normal file
29
TR5Main/Scripting/GameScriptCameraInfo.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GameScriptNamedBase.h"
|
||||||
|
#include "phd_global.h"
|
||||||
|
|
||||||
|
namespace sol {
|
||||||
|
class state;
|
||||||
|
}
|
||||||
|
class GameScriptPosition;
|
||||||
|
|
||||||
|
class GameScriptCameraInfo : public GameScriptNamedBase<GameScriptCameraInfo, LEVEL_CAMERA_INFO &>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GameScriptCameraInfo(LEVEL_CAMERA_INFO& ref, bool temp);
|
||||||
|
~GameScriptCameraInfo();
|
||||||
|
static void Register(sol::state *);
|
||||||
|
GameScriptPosition GetPos() const;
|
||||||
|
void SetPos(GameScriptPosition const& pos);
|
||||||
|
|
||||||
|
short GetRoom() const;
|
||||||
|
void SetRoom(short Room);
|
||||||
|
|
||||||
|
std::string GetName() const;
|
||||||
|
void SetName(std::string const &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
LEVEL_CAMERA_INFO & m_camera;
|
||||||
|
bool m_temporary;
|
||||||
|
};
|
|
@ -170,6 +170,7 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
|
||||||
<ClInclude Include="Game\prng.h" />
|
<ClInclude Include="Game\prng.h" />
|
||||||
<ClInclude Include="Game\puzzles_keys.h" />
|
<ClInclude Include="Game\puzzles_keys.h" />
|
||||||
<ClInclude Include="Game\room.h" />
|
<ClInclude Include="Game\room.h" />
|
||||||
|
<ClInclude Include="Scripting\GameScriptCameraInfo.h" />
|
||||||
<ClInclude Include="Scripting\GameScriptColor.h" />
|
<ClInclude Include="Scripting\GameScriptColor.h" />
|
||||||
<ClInclude Include="Scripting\GameScriptItemInfo.h" />
|
<ClInclude Include="Scripting\GameScriptItemInfo.h" />
|
||||||
<ClInclude Include="Game\smoke.h" />
|
<ClInclude Include="Game\smoke.h" />
|
||||||
|
@ -496,6 +497,7 @@ xcopy /Y "$(ProjectDir)Shaders\HUD\*.hlsl" "$(TargetDir)\Shaders\HUD\"</Command>
|
||||||
<ClCompile Include="Game\pickup\pickup_weapon.cpp" />
|
<ClCompile Include="Game\pickup\pickup_weapon.cpp" />
|
||||||
<ClCompile Include="Game\prng.cpp" />
|
<ClCompile Include="Game\prng.cpp" />
|
||||||
<ClCompile Include="Game\puzzles_keys.cpp" />
|
<ClCompile Include="Game\puzzles_keys.cpp" />
|
||||||
|
<ClCompile Include="Scripting\GameScriptCameraInfo.cpp" />
|
||||||
<ClCompile Include="Scripting\GameScriptColor.cpp" />
|
<ClCompile Include="Scripting\GameScriptColor.cpp" />
|
||||||
<ClCompile Include="Scripting\GameScriptItemInfo.cpp" />
|
<ClCompile Include="Scripting\GameScriptItemInfo.cpp" />
|
||||||
<ClCompile Include="Game\trmath.cpp" />
|
<ClCompile Include="Game\trmath.cpp" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue