mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-09 03:58:19 +03:00
Move GameScriptAudioTrack and GameScriptMeshInfo to Scripting.
This commit is contained in:
parent
a2ecc0e55c
commit
e0cbde2135
8 changed files with 20 additions and 14 deletions
|
@ -22,12 +22,15 @@
|
|||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="frameworkandsol.h" />
|
||||
<ClInclude Include="include\GameScriptAIObject.h" />
|
||||
<ClInclude Include="include\GameScriptAudioTrack.h" />
|
||||
<ClInclude Include="include\GameScriptCameraInfo.h" />
|
||||
<ClInclude Include="include\GameScriptColor.h" />
|
||||
<ClInclude Include="include\GameScriptInventoryObject.h" />
|
||||
<ClInclude Include="include\GameScriptMeshInfo.h" />
|
||||
<ClInclude Include="include\GameScriptNamedBase.h" />
|
||||
<ClInclude Include="include\GameScriptPosition.h" />
|
||||
<ClInclude Include="include\GameScriptRotation.h" />
|
||||
<ClInclude Include="include\ItemEnumPair.h" />
|
||||
<ClInclude Include="include\ScriptAssert.h" />
|
||||
<ClInclude Include="include\ScriptUtil.h" />
|
||||
</ItemGroup>
|
||||
|
@ -38,9 +41,11 @@
|
|||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GameScriptAIObject.cpp" />
|
||||
<ClCompile Include="src\GameScriptAudioTrack.cpp" />
|
||||
<ClCompile Include="src\GameScriptCameraInfo.cpp" />
|
||||
<ClCompile Include="src\GameScriptColor.cpp" />
|
||||
<ClCompile Include="src\GameScriptInventoryObject.cpp" />
|
||||
<ClCompile Include="src\GameScriptMeshInfo.cpp" />
|
||||
<ClCompile Include="src\GameScriptPosition.cpp" />
|
||||
<ClCompile Include="src\GameScriptRotation.cpp" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -48,6 +48,15 @@
|
|||
<ClInclude Include="include\GameScriptInventoryObject.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\ItemEnumPair.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\GameScriptAudioTrack.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\GameScriptMeshInfo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="frameworkandsol.cpp">
|
||||
|
@ -71,6 +80,12 @@
|
|||
<ClCompile Include="src\GameScriptInventoryObject.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GameScriptAudioTrack.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GameScriptMeshInfo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
|
16
Scripting/include/GameScriptAudioTrack.h
Normal file
16
Scripting/include/GameScriptAudioTrack.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace sol {
|
||||
class state;
|
||||
}
|
||||
|
||||
struct GameScriptAudioTrack
|
||||
{
|
||||
std::string trackName;
|
||||
bool looped;
|
||||
|
||||
GameScriptAudioTrack(std::string const & trackName, bool looped);
|
||||
static void Register(sol::state* lua);
|
||||
};
|
39
Scripting/include/GameScriptMeshInfo.h
Normal file
39
Scripting/include/GameScriptMeshInfo.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
#pragma once
|
||||
|
||||
#include "GameScriptNamedBase.h"
|
||||
#include "Game/room.h"
|
||||
|
||||
namespace sol {
|
||||
class state;
|
||||
}
|
||||
|
||||
class GameScriptPosition;
|
||||
class GameScriptColor;
|
||||
|
||||
class GameScriptMeshInfo : public GameScriptNamedBase<GameScriptMeshInfo, MESH_INFO &>
|
||||
{
|
||||
public:
|
||||
using IdentifierType = std::reference_wrapper<MESH_INFO>;
|
||||
GameScriptMeshInfo(MESH_INFO & id, bool temporary);
|
||||
~GameScriptMeshInfo();
|
||||
GameScriptMeshInfo& operator=(GameScriptMeshInfo const& other) = delete;
|
||||
GameScriptMeshInfo(GameScriptMeshInfo const& other) = delete;
|
||||
|
||||
static void Register(sol::state *);
|
||||
|
||||
GameScriptPosition GetPos() const;
|
||||
void SetPos(GameScriptPosition const & pos);
|
||||
int GetRot() const;
|
||||
void SetRot(int yRot);
|
||||
std::string GetName() const;
|
||||
void SetName(std::string const & name);
|
||||
int GetStaticNumber() const;
|
||||
void SetStaticNumber(int staticNumber);
|
||||
GameScriptColor GetColor() const;
|
||||
void SetColor(GameScriptColor const & col);
|
||||
int GetHP() const;
|
||||
void SetHP(int hp);
|
||||
private:
|
||||
MESH_INFO & m_mesh;
|
||||
bool m_temporary;
|
||||
};
|
27
Scripting/src/GameScriptAudioTrack.cpp
Normal file
27
Scripting/src/GameScriptAudioTrack.cpp
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include "frameworkandsol.h"
|
||||
#include "GameScriptAudioTrack.h"
|
||||
|
||||
/***
|
||||
Metadata about audio tracks (music and ambience).
|
||||
|
||||
__In progress__
|
||||
|
||||
@pregameclass AudioTrack
|
||||
@pragma nostrip
|
||||
*/
|
||||
// TODO FIXME find out what is meant to happen and whether we need this or not
|
||||
|
||||
GameScriptAudioTrack::GameScriptAudioTrack(std::string const & trackName, bool looped)
|
||||
{
|
||||
this->trackName = trackName;
|
||||
this->looped = looped;
|
||||
}
|
||||
|
||||
void GameScriptAudioTrack::Register(sol::state* lua)
|
||||
{
|
||||
lua->new_usertype<GameScriptAudioTrack>("AudioTrack",
|
||||
sol::constructors<GameScriptAudioTrack(std::string, bool)>(),
|
||||
"trackName", &GameScriptAudioTrack::trackName,
|
||||
"looped", &GameScriptAudioTrack::looped
|
||||
);
|
||||
}
|
134
Scripting/src/GameScriptMeshInfo.cpp
Normal file
134
Scripting/src/GameScriptMeshInfo.cpp
Normal file
|
@ -0,0 +1,134 @@
|
|||
#pragma once
|
||||
#include "frameworkandsol.h"
|
||||
#include "ScriptAssert.h"
|
||||
#include "GameScriptMeshInfo.h"
|
||||
#include "GameScriptPosition.h"
|
||||
#include "GameScriptColor.h"
|
||||
#include "ScriptUtil.h"
|
||||
/***
|
||||
Mesh info
|
||||
|
||||
@entityclass MeshInfo
|
||||
@pragma nostrip
|
||||
*/
|
||||
|
||||
constexpr auto LUA_CLASS_NAME{ "MeshInfo" };
|
||||
|
||||
static auto index_error = index_error_maker(GameScriptMeshInfo, LUA_CLASS_NAME);
|
||||
static auto newindex_error = newindex_error_maker(GameScriptMeshInfo, LUA_CLASS_NAME);
|
||||
|
||||
GameScriptMeshInfo::GameScriptMeshInfo(MESH_INFO & ref, bool temp) : m_mesh{ref}, m_temporary{ temp }
|
||||
{};
|
||||
|
||||
GameScriptMeshInfo::~GameScriptMeshInfo() {
|
||||
if (m_temporary)
|
||||
{
|
||||
s_callbackRemoveName(m_mesh.luaName);
|
||||
}
|
||||
}
|
||||
|
||||
void GameScriptMeshInfo::Register(sol::state* state)
|
||||
{
|
||||
state->new_usertype<GameScriptMeshInfo>(LUA_CLASS_NAME,
|
||||
sol::meta_function::index, index_error,
|
||||
sol::meta_function::new_index, newindex_error,
|
||||
|
||||
/// (@{Position}) position in level
|
||||
// @mem pos
|
||||
"pos", sol::property(&GameScriptMeshInfo::GetPos, &GameScriptMeshInfo::SetPos),
|
||||
|
||||
/// (int) y-axis rotation
|
||||
// @mem yRot
|
||||
"yRot", sol::property(&GameScriptMeshInfo::GetRot, &GameScriptMeshInfo::SetRot),
|
||||
|
||||
/// (string) unique string identifier.
|
||||
// e.g. "my\_vase" or "oldrubble"
|
||||
// @mem name
|
||||
"name", sol::property(&GameScriptMeshInfo::GetName, &GameScriptMeshInfo::SetName),
|
||||
|
||||
/// (int) static number
|
||||
// @mem staticNumber
|
||||
"staticNumber", sol::property(&GameScriptMeshInfo::GetStaticNumber, &GameScriptMeshInfo::SetStaticNumber),
|
||||
|
||||
/// (@{Color}) color of mesh
|
||||
// @mem color
|
||||
"color", sol::property(&GameScriptMeshInfo::GetColor, &GameScriptMeshInfo::SetColor),
|
||||
|
||||
/// (int) hp
|
||||
// @mem HP
|
||||
"HP", sol::property(&GameScriptMeshInfo::GetHP, &GameScriptMeshInfo::SetHP)
|
||||
);
|
||||
}
|
||||
|
||||
GameScriptPosition GameScriptMeshInfo::GetPos() const
|
||||
{
|
||||
return GameScriptPosition{ m_mesh.pos.xPos, m_mesh.pos.yPos, m_mesh.pos.zPos };
|
||||
}
|
||||
|
||||
void GameScriptMeshInfo::SetPos(GameScriptPosition const& pos)
|
||||
{
|
||||
m_mesh.pos.xPos = pos.x;
|
||||
m_mesh.pos.yPos = pos.y;
|
||||
m_mesh.pos.zPos = pos.z;
|
||||
}
|
||||
|
||||
int GameScriptMeshInfo::GetRot() const
|
||||
{
|
||||
return m_mesh.pos.yRot;
|
||||
}
|
||||
|
||||
void GameScriptMeshInfo::SetRot(int yRot)
|
||||
{
|
||||
m_mesh.pos.yRot = yRot;
|
||||
}
|
||||
|
||||
std::string GameScriptMeshInfo::GetName() const
|
||||
{
|
||||
return m_mesh.luaName;
|
||||
}
|
||||
|
||||
void GameScriptMeshInfo::SetName(std::string const & id)
|
||||
{
|
||||
ScriptAssert(!id.empty(), "Name cannot be blank", ERROR_MODE::TERMINATE);
|
||||
|
||||
// remove the old name if we have one
|
||||
s_callbackRemoveName(m_mesh.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_mesh.luaName = id;
|
||||
// todo add error checking
|
||||
s_callbackSetName(id, m_mesh);
|
||||
}
|
||||
|
||||
int GameScriptMeshInfo::GetStaticNumber() const
|
||||
{
|
||||
return m_mesh.staticNumber;
|
||||
}
|
||||
|
||||
void GameScriptMeshInfo::SetStaticNumber(int staticNumber)
|
||||
{
|
||||
m_mesh.staticNumber = staticNumber;
|
||||
}
|
||||
|
||||
GameScriptColor GameScriptMeshInfo::GetColor() const
|
||||
{
|
||||
return GameScriptColor{ m_mesh.color };
|
||||
}
|
||||
|
||||
void GameScriptMeshInfo::SetColor(GameScriptColor const & col)
|
||||
{
|
||||
m_mesh.color = col;
|
||||
}
|
||||
|
||||
int GameScriptMeshInfo::GetHP() const
|
||||
{
|
||||
return m_mesh.hitPoints;
|
||||
}
|
||||
|
||||
void GameScriptMeshInfo::SetHP(int hp)
|
||||
{
|
||||
m_mesh.hitPoints = hp;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue