@@ -43,7 +43,7 @@ public: | |||
BtPhysTest(bool editor = false); | |||
virtual ~BtPhysTest(); | |||
char const *GetName() { return "<BtPhysTest>"; } | |||
std::string GetName() const { return "<BtPhysTest>"; } | |||
protected: | |||
virtual void TickGame(float seconds); | |||
@@ -36,7 +36,7 @@ public: | |||
SceneSetup(std::string const& name); | |||
~SceneSetup(); | |||
static char const *GetName() { return "<scenesetup>"; } | |||
static std::string GetName() { return "<scenesetup>"; } | |||
//-- | |||
bool Startup(); | |||
@@ -1,8 +1,14 @@ | |||
// | |||
// BtPhysTest | |||
// Lol Engine — Bullet physics test | |||
// | |||
// Copyright: (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com> | |||
// (c) 2012 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
// © 2012—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
@@ -13,7 +19,7 @@ public: | |||
Nacl_PhysTest(bool editor = false); | |||
virtual ~Nacl_PhysTest(); | |||
char const *GetName() { return "<Nacl_PhysTest>"; } | |||
std::string GetName() const { return "<Nacl_PhysTest>"; } | |||
protected: | |||
virtual void TickGame(float seconds); | |||
@@ -1,11 +1,15 @@ | |||
// | |||
// Orbital | |||
// Lol Engine — Bullet physics test | |||
// | |||
// Copyright © 2009—2013 Cédric Lecacheur <jordx@free.fr> | |||
// © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
// © 2012—2015 Sam Hocevar <sam@hocevar.net> | |||
// © 2012—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// No licensing terms yet. All rights reserved. | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
@@ -141,13 +145,13 @@ public: | |||
if (!MeshRand.count()) | |||
{ | |||
array<String> colors_base = { "#add", "#dad", "#dda", "#daa", "#ada", "#aad" }; | |||
array<std::string> colors_base = { "#add", "#dad", "#dda", "#daa", "#ada", "#aad" }; | |||
MeshLimit << 0; | |||
#if USE_BOX | |||
{ | |||
array<String> colors = colors_base; | |||
array<std::string> colors = colors_base; | |||
while (colors.count()) | |||
{ | |||
EasyMesh m; | |||
@@ -196,7 +200,7 @@ public: | |||
MeshRand << "[tpbn tvnc sc#aaff aq 0 0]"; | |||
#else | |||
{ | |||
array<String> colors = colors_base; | |||
array<std::string> colors = colors_base; | |||
while (colors.count()) | |||
{ | |||
EasyMesh m; | |||
@@ -220,7 +224,7 @@ public: | |||
#if USE_CONE | |||
{ | |||
array<String> colors = colors_base; | |||
array<std::string> colors = colors_base; | |||
while (colors.count()) | |||
{ | |||
EasyMesh m; | |||
@@ -247,7 +251,7 @@ public: | |||
#if USE_CYLINDER | |||
{ | |||
array<String> colors = colors_base; | |||
array<std::string> colors = colors_base; | |||
while (colors.count()) | |||
{ | |||
EasyMesh m; | |||
@@ -275,7 +279,7 @@ public: | |||
#if USE_CAPSULE | |||
{ | |||
array<String> colors = colors_base; | |||
array<std::string> colors = colors_base; | |||
while (colors.count()) | |||
{ | |||
EasyMesh m; | |||
@@ -395,7 +399,7 @@ public: | |||
{ | |||
} | |||
char const *GetName() { return "<PhysicsObject>"; } | |||
std::string GetName() const { return "<PhysicsObject>"; } | |||
protected: | |||
virtual void TickGame(float seconds) | |||
@@ -1,13 +1,14 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine — Bullet physics test | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// (c) 2009-2013 Cédric Lecacheur <jordx@free.fr> | |||
// (c) 2009-2013 Benjamin "Touky" Huet <huet.benjamin@gmail.com> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
// © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#if HAVE_CONFIG_H | |||
@@ -125,7 +126,7 @@ void EasyCharacterController::BaseTransformChanged(const lol::mat4& PreviousMatr | |||
} | |||
//--- | |||
char const *EasyCharacterController::GetName() | |||
std::string EasyCharacterController::GetName() | |||
{ | |||
return "<EasyCharacterController>"; | |||
} | |||
@@ -1,10 +1,10 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine — Bullet physics test | |||
// | |||
// Copyright © 2009—2015 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
// © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
// © 2012—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// This library is free software. It comes without any warranty, to | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
@@ -69,9 +69,11 @@ public: | |||
virtual void Jump(); | |||
virtual void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation); | |||
protected: | |||
virtual void BaseTransformChanged(const lol::mat4& PreviousMatrix, const lol::mat4& NewMatrix); | |||
virtual char const *GetName(); | |||
virtual std::string GetName(); | |||
public: | |||
virtual void TickGame(float seconds); | |||
@@ -1,10 +1,10 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine — Bullet physics test | |||
// | |||
// Copyright © 2012—2015 Sam Hocevar <sam@hocevar.net> | |||
// © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
// Copyright © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
// © 2012—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// This library is free software. It comes without any warranty, to | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
@@ -83,7 +83,7 @@ public: | |||
Exit(); | |||
} | |||
char const *GetName() { return "<Simulation>"; } | |||
std::string GetName() const { return "<Simulation>"; } | |||
public: | |||
void Init() | |||
@@ -2,6 +2,7 @@ | |||
// Lol Engine — Lua tutorial | |||
// | |||
// Copyright © 2014—2017 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
// © 2017—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -113,7 +114,7 @@ public: | |||
static int GlobalAddString(lua_State* l) | |||
{ | |||
auto stack = LuaStack::Begin(l); | |||
auto s = stack.Get<String>(); | |||
auto s = stack.Get<std::string>(); | |||
s += "_added"; | |||
@@ -185,10 +186,10 @@ public: | |||
float testvalue_num = demo_loader->Get<float>("testvalue_num"); | |||
int32_t testvalue_int = demo_loader->Get<int32_t>("testvalue_int"); | |||
uint32_t testvalue_uint = demo_loader->Get<uint32_t>("testvalue_uint"); | |||
String testvalue_str = demo_loader->Get<String>("testvalue_str"); | |||
std::string testvalue_str = demo_loader->Get<std::string>("testvalue_str"); | |||
//Grab string modified with function | |||
String function_return = demo_loader->Get<String>("function_return"); | |||
std::string function_return = demo_loader->Get<std::string>("function_return"); | |||
//Grab global values modified with DemoObject | |||
int32_t loluademo_return = demo_loader->Get<int32_t>("loluademo_return"); | |||
@@ -198,10 +199,10 @@ public: | |||
msg::info("Lua Vars: \ | |||
testvalue_num: %.2f, testvalue_int: %i, testvalue_uint: %i, testvalue_str: %s.\n", | |||
testvalue_num, testvalue_int, testvalue_uint, testvalue_str.C()); | |||
testvalue_num, testvalue_int, testvalue_uint, testvalue_str.c_str()); | |||
msg::info("Lua Vars: \ | |||
function_return: %s, loluademo_return: %i, loluademo_inst_return: %.2f, loluademo_getx: %i, loluademo_inst->m_x: %i.\n", | |||
function_return.C(), loluademo_return, loluademo_inst_return, loluademo_getx, loluademo_inst->m_x); | |||
function_return.c_str(), loluademo_return, loluademo_inst_return, loluademo_getx, loluademo_inst->m_x); | |||
#define /***/ _LOLUA_ARG_1(a00) (float)a00 | |||
#define /***/ _LOLUA_ARG_2(a00, a01) _LOLUA_ARG_1(a00), _LOLUA_ARG_1(a01) | |||
@@ -86,9 +86,9 @@ void sample::TickGame(float seconds) | |||
Entity::TickGame(seconds); | |||
} | |||
char const *sample::GetName() | |||
std::string sample::GetName() const | |||
{ | |||
return data->m_name.c_str(); | |||
return data->m_name; | |||
} | |||
void sample::play() | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
@@ -28,7 +30,7 @@ public: | |||
Camera(); | |||
~Camera(); | |||
char const *GetName() { return "<camera>"; } | |||
std::string GetName() const { return "<camera>"; } | |||
//View functions | |||
void SetView(mat4 const &view); | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#include <lol/engine-internal.h> | |||
@@ -30,7 +32,7 @@ class DebugRecordData | |||
friend class DebugRecord; | |||
private: | |||
String m_path; | |||
std::string m_path; | |||
ivec2 m_size; | |||
int m_fps; | |||
#if defined USE_PIPI | |||
@@ -42,7 +44,7 @@ private: | |||
* Public DebugRecord class | |||
*/ | |||
DebugRecord::DebugRecord(String const &path, float fps) | |||
DebugRecord::DebugRecord(std::string const &path, float fps) | |||
: m_data(new DebugRecordData()) | |||
{ | |||
Ticker::StartRecording(); | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
@@ -25,7 +27,7 @@ class DebugRecordData; | |||
class DebugRecord : public Entity | |||
{ | |||
public: | |||
DebugRecord(String const &path, float fps); | |||
DebugRecord(std::string const &path, float fps); | |||
virtual ~DebugRecord(); | |||
protected: | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -64,7 +64,7 @@ Dict::~Dict() | |||
delete data; | |||
} | |||
int Dict::MakeSlot(char const *name) | |||
int Dict::MakeSlot(std::string const &name) | |||
{ | |||
int slotid, empty = -1; | |||
@@ -80,7 +80,7 @@ int Dict::MakeSlot(char const *name) | |||
} | |||
else | |||
{ | |||
char const *oldname = e->GetName(); | |||
char const *oldname = e->GetName().c_str(); | |||
if (*oldname == '<') | |||
{ | |||
while (*oldname && *oldname != '>') | |||
@@ -91,7 +91,7 @@ int Dict::MakeSlot(char const *name) | |||
oldname++; | |||
} | |||
if (!strcasecmp(name, oldname)) | |||
if (!strcasecmp(name.c_str(), oldname)) | |||
break; | |||
} | |||
} | |||
@@ -137,7 +137,7 @@ void Dict::RemoveSlot(Entity *entity) | |||
#if !LOL_BUILD_RELEASE | |||
msg::error("removing unregistered entity %p (%s)\n", | |||
entity, entity->GetName()); | |||
entity, entity->GetName().c_str()); | |||
#endif | |||
} | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
@@ -28,7 +30,7 @@ public: | |||
Dict(); | |||
~Dict(); | |||
int MakeSlot(char const *name); | |||
int MakeSlot(std::string const &name); | |||
void RemoveSlot(int slotid); | |||
void RemoveSlot(Entity *entity); | |||
@@ -41,7 +41,7 @@ struct CSGUsageBase : public StructSafeEnum | |||
Xor | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[Union] = "Union"; | |||
enum_map[Substract] = "Substract"; | |||
@@ -65,7 +65,7 @@ struct MeshTransformBase : public StructSafeEnum | |||
Shear | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[Taper] = "Taper"; | |||
enum_map[Twist] = "Twist"; | |||
@@ -38,7 +38,7 @@ struct MeshBuildOperationBase : public StructSafeEnum | |||
All = 0xffff, | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[ScaleWinding] = "ScaleWinding"; | |||
enum_map[CommandRecording] = "CommandRecording"; | |||
@@ -99,7 +99,7 @@ struct EasyMeshCmdTypeBase : public StructSafeEnum | |||
AppendCog, | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[MeshCsg] = "MeshCsg"; | |||
enum_map[LoopStart] = "LoopStart"; | |||
@@ -160,7 +160,7 @@ struct MeshTypeBase : public StructSafeEnum | |||
MAX | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[Triangle] = "Triangle"; | |||
enum_map[Quad] = "Quad"; | |||
@@ -200,7 +200,7 @@ struct TexCoordBuildTypeBase : public StructSafeEnum | |||
Max | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[TriangleDefault] = "TriangleDefault"; | |||
enum_map[QuadDefault] = "QuadDefault"; | |||
@@ -235,7 +235,7 @@ struct MeshFaceTypeBase : public StructSafeEnum | |||
MAX | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[BoxFront] = "BoxFront"; | |||
enum_map[QuadDefault] = "QuadDefault"; | |||
@@ -261,7 +261,7 @@ struct TexCoordPosBase : public StructSafeEnum | |||
TR // Top Right | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[BL] = "BL"; | |||
enum_map[BR] = "BR"; | |||
@@ -512,7 +512,7 @@ struct VDictTypeBase : public StructSafeEnum | |||
Master = -1, | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[DoesNotExist] = "DoesNotExist"; | |||
enum_map[Alone] = "Alone"; | |||
@@ -2,7 +2,7 @@ | |||
// Lol Engine | |||
// | |||
// Copyright © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
// © 2010—2017 Sam Hocevar <sam@hocevar.net> | |||
// © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// © 2009—2013 Cédric Lecacheur <jordx@free.fr> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
@@ -93,9 +93,9 @@ GpuShaderData::~GpuShaderData() | |||
} | |||
//----------------------------------------------------------------------------- | |||
void GpuShaderData::AddUniform(const lol::String &new_uniform) | |||
void GpuShaderData::AddUniform(std::string const &new_uniform) | |||
{ | |||
m_shader_uniform.push(new_uniform, m_shader->GetUniformLocation(new_uniform.C())); | |||
m_shader_uniform.push(new_uniform, m_shader->GetUniformLocation(new_uniform)); | |||
} | |||
//----------------------------------------------------------------------------- | |||
@@ -105,7 +105,7 @@ void GpuShaderData::AddAttribute(VertexUsage usage, int index) | |||
} | |||
//----------------------------------------------------------------------------- | |||
ShaderUniform const *GpuShaderData::GetUniform(const lol::String &uniform) | |||
ShaderUniform const *GpuShaderData::GetUniform(std::string const &uniform) | |||
{ | |||
for (int i = 0; i < m_shader_uniform.count(); ++i) | |||
if (m_shader_uniform[i].m1 == uniform) | |||
@@ -159,17 +159,18 @@ DefaultShaderData::DefaultShaderData(uint16_t vert_decl_flags, Shader* shader, b | |||
SetupDefaultData(with_UV); | |||
} | |||
static const String DefaultUniforms[8] = | |||
static std::string const DefaultUniforms[8] = | |||
{ | |||
String("u_lights"), | |||
String("u_model"), | |||
String("u_modelview"), | |||
String("u_view"), | |||
String("u_inv_view"), | |||
String("u_proj"), | |||
String("u_normalmat"), | |||
String("u_damage") | |||
"u_lights", | |||
"u_model", | |||
"u_modelview", | |||
"u_view", | |||
"u_inv_view", | |||
"u_proj", | |||
"u_normalmat", | |||
"u_damage", | |||
}; | |||
//----------------------------------------------------------------------------- | |||
void DefaultShaderData::StoreUniformNames() | |||
{ | |||
@@ -2,7 +2,7 @@ | |||
// Lol Engine | |||
// | |||
// Copyright © 2009—2013 Benjamin “Touky” Huet <huet.benjamin@gmail.com> | |||
// © 2010—2017 Sam Hocevar <sam@hocevar.net> | |||
// © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// © 2009—2013 Cédric Lecacheur <jordx@free.fr> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
@@ -14,6 +14,7 @@ | |||
#pragma once | |||
#include <string> | |||
#include <map> | |||
namespace lol | |||
@@ -31,7 +32,7 @@ struct MeshRenderBase : public StructSafeEnum | |||
IgnoreRender, | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[NeedData] = "NeedData"; | |||
enum_map[NeedConvert] = "NeedConvert"; | |||
@@ -81,20 +82,20 @@ public: | |||
GpuShaderData(uint16_t vert_decl_flags, Shader* shader, DebugRenderMode render_mode); | |||
virtual ~GpuShaderData(); | |||
//-- | |||
void AddUniform(const lol::String &new_uniform); | |||
void AddUniform(std::string const &new_uniform); | |||
void AddAttribute(VertexUsage usage, int index); | |||
ShaderUniform const *GetUniform(const lol::String &uniform); | |||
ShaderUniform const *GetUniform(std::string const &uniform); | |||
ShaderAttrib const *GetAttribute(VertexUsage usage, int index); | |||
//-- | |||
virtual void SetupShaderDatas(mat4 const &model) { UNUSED(model); } | |||
//-- | |||
protected: | |||
uint16_t m_vert_decl_flags; | |||
Shader* m_shader; | |||
int m_render_mode; | |||
array<lol::String, ShaderUniform> m_shader_uniform; | |||
array<ShaderAttrib> m_shader_attrib; | |||
uint16_t m_vert_decl_flags; | |||
Shader *m_shader; | |||
int m_render_mode; | |||
array<std::string, ShaderUniform> m_shader_uniform; | |||
array<ShaderAttrib> m_shader_attrib; | |||
}; | |||
class DefaultShaderData : public GpuShaderData | |||
@@ -109,7 +110,7 @@ public: | |||
void SetupDefaultData(bool with_UV); | |||
virtual void SetupShaderDatas(mat4 const &model); | |||
//-- | |||
array<String> m_uniform_names; | |||
array<std::string> m_uniform_names; | |||
}; | |||
class GpuEasyMeshData | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -44,7 +44,7 @@ Entity::~Entity() | |||
#endif | |||
} | |||
char const *Entity::GetName() | |||
std::string Entity::GetName() const | |||
{ | |||
return "<entity>"; | |||
} | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -50,7 +50,7 @@ class Entity | |||
friend class Emcee; | |||
public: | |||
virtual char const *GetName(); | |||
virtual std::string GetName() const; | |||
inline bool IsTicked() { return !!m_ref && !m_autorelease; } | |||
protected: | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -114,7 +114,7 @@ void Ticker::Ref(Entity *entity) | |||
ASSERT(entity, "dereferencing nullptr entity\n"); | |||
ASSERT(!entity->m_destroy, | |||
"referencing entity scheduled for destruction %s\n", | |||
entity->GetName()); | |||
entity->GetName().c_str()); | |||
if (entity->m_autorelease) | |||
{ | |||
@@ -139,9 +139,9 @@ int Ticker::Unref(Entity *entity) | |||
{ | |||
ASSERT(entity, "dereferencing null entity\n"); | |||
ASSERT(entity->m_ref > 0, "dereferencing unreferenced entity %s\n", | |||
entity->GetName()); | |||
entity->GetName().c_str()); | |||
ASSERT(!entity->m_autorelease, "dereferencing autoreleased entity %s\n", | |||
entity->GetName()); | |||
entity->GetName().c_str()); | |||
return --entity->m_ref; | |||
} | |||
@@ -223,7 +223,7 @@ void TickerData::GameThreadTick() | |||
{ | |||
Entity *e = data->m_list[g][i]; | |||
msg::debug(" \\-- [%p] %s (m_ref %d, destroy %d)\n", | |||
e, e->GetName(), e->m_ref, e->m_destroy); | |||
e, e->GetName().c_str(), e->m_ref, e->m_destroy); | |||
} | |||
} | |||
#endif | |||
@@ -276,7 +276,7 @@ void TickerData::GameThreadTick() | |||
if (e->m_ref) | |||
{ | |||
#if !LOL_BUILD_RELEASE | |||
msg::error("poking %s\n", e->GetName()); | |||
msg::error("poking %s\n", e->GetName().c_str()); | |||
#endif | |||
e->m_ref--; | |||
n++; | |||
@@ -401,14 +401,14 @@ void TickerData::GameThreadTick() | |||
#if !LOL_BUILD_RELEASE | |||
if (e->m_tickstate != Entity::STATE_IDLE) | |||
msg::error("entity %s [%p] not idle for game tick\n", | |||
e->GetName(), e); | |||
e->GetName().c_str(), e); | |||
e->m_tickstate = Entity::STATE_PRETICK_GAME; | |||
#endif | |||
e->TickGame(data->deltatime); | |||
#if !LOL_BUILD_RELEASE | |||
if (e->m_tickstate != Entity::STATE_POSTTICK_GAME) | |||
msg::error("entity %s [%p] missed super game tick\n", | |||
e->GetName(), e); | |||
e->GetName().c_str(), e); | |||
e->m_tickstate = Entity::STATE_IDLE; | |||
#endif | |||
} | |||
@@ -455,14 +455,14 @@ void TickerData::DrawThreadTick() | |||
#if !LOL_BUILD_RELEASE | |||
if (e->m_tickstate != Entity::STATE_IDLE) | |||
msg::error("entity %s [%p] not idle for draw tick\n", | |||
e->GetName(), e); | |||
e->GetName().c_str(), e); | |||
e->m_tickstate = Entity::STATE_PRETICK_DRAW; | |||
#endif | |||
e->TickDraw(data->deltatime, scene); | |||
#if !LOL_BUILD_RELEASE | |||
if (e->m_tickstate != Entity::STATE_POSTTICK_DRAW) | |||
msg::error("entity %s [%p] missed super draw tick\n", | |||
e->GetName(), e); | |||
e->GetName().c_str(), e); | |||
e->m_tickstate = Entity::STATE_IDLE; | |||
#endif | |||
} | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#include <lol/engine-internal.h> | |||
@@ -32,7 +34,7 @@ WorldEntity::~WorldEntity() | |||
{ | |||
} | |||
char const *WorldEntity::GetName() | |||
std::string WorldEntity::GetName() const | |||
{ | |||
return "<worldentity>"; | |||
} | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
@@ -25,7 +27,7 @@ namespace lol | |||
class WorldEntity : public Entity | |||
{ | |||
public: | |||
virtual char const *GetName(); | |||
virtual std::string GetName() const; | |||
public: | |||
box3 m_aabb; | |||
@@ -1,12 +1,14 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// 2013 Jean-Yves Lamoureux <jylam@lnxscene.org> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// 2013 Jean-Yves Lamoureux <jylam@lnxscene.org> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#include <lol/engine-internal.h> | |||
@@ -26,7 +28,7 @@ class FontData | |||
friend class Font; | |||
private: | |||
String m_name; | |||
std::string m_name; | |||
TileSet *tileset; | |||
ivec2 size; | |||
}; | |||
@@ -35,10 +37,10 @@ private: | |||
* Public Font class | |||
*/ | |||
Font::Font(char const *path) | |||
Font::Font(std::string const &path) | |||
: data(new FontData()) | |||
{ | |||
data->m_name = String("<font> ") + path; | |||
data->m_name = "<font> " + path; | |||
data->tileset = Tiler::Register(path, ivec2::zero, ivec2(16)); | |||
data->size = data->tileset->GetTileSize(0); | |||
@@ -63,17 +65,17 @@ void Font::TickDraw(float seconds, Scene &scene) | |||
} | |||
} | |||
char const *Font::GetName() | |||
std::string Font::GetName() const | |||
{ | |||
return data->m_name.C(); | |||
return data->m_name; | |||
} | |||
void Font::Print(Scene &scene, vec3 pos, char const *str, vec2 scale, float spacing) | |||
void Font::Print(Scene &scene, vec3 pos, std::string const &str, vec2 scale, float spacing) | |||
{ | |||
float origin_x = pos.x; | |||
while (*str) | |||
for (int i = 0; i < (int)str.length(); ++i) | |||
{ | |||
uint32_t ch = (uint8_t)*str++; | |||
uint32_t ch = str[i]; | |||
switch (ch) | |||
{ | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
@@ -25,17 +27,17 @@ class FontData; | |||
class Font : public Entity | |||
{ | |||
public: | |||
Font(char const *path); | |||
Font(std::string const &path); | |||
~Font(); | |||
protected: | |||
/* Inherited from Entity */ | |||
virtual char const *GetName(); | |||
virtual std::string GetName() const; | |||
virtual void TickDraw(float seconds, Scene &scene); | |||
public: | |||
/* New methods */ | |||
void Print(Scene &scene, vec3 pos, char const *str, vec2 scale = vec2(1.0f), float spacing = 0.0f); | |||
void Print(Scene &scene, vec3 pos, std::string const &str, vec2 scale = vec2(1.0f), float spacing = 0.0f); | |||
ivec2 GetSize() const; | |||
private: | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#include <lol/engine-internal.h> | |||
@@ -32,7 +34,7 @@ static ForgeData * const data = &forgedata; | |||
* Public Forge class | |||
*/ | |||
int Forge::Register(char const *path) | |||
int Forge::Register(std::string const &path) | |||
{ | |||
int id = data->fonts.MakeSlot(path); | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
@@ -24,7 +26,7 @@ namespace lol | |||
class Forge | |||
{ | |||
public: | |||
static int Register(char const *path); | |||
static int Register(std::string const &path); | |||
static void Deregister(int id); | |||
static Font *GetFont(int id); | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
@@ -28,7 +30,7 @@ public: | |||
Gradient(vec3 aa, vec3 bb); | |||
virtual ~Gradient(); | |||
char const *GetName() { return "<gradient>"; } | |||
std::string GetName() const { return "<gradient>"; } | |||
protected: | |||
virtual void TickGame(float seconds); | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2014 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#include <lol/engine-internal.h> | |||
@@ -107,25 +109,25 @@ uint16_t Color::ToRGB16(vec4 c) | |||
/* | |||
* Conversion from colours to hexadecimal | |||
*/ | |||
vec4 Color::C8BppHexString(String s) | |||
vec4 Color::C8BppHexString(std::string const &s) | |||
{ | |||
String c = s[0] == '#' ? &s[1] : s; | |||
uint32_t tmp = std::strtol(c.C(), nullptr, 16); | |||
if (c.count() == 3) | |||
std::string c = s[0] == '#' ? &s[1] : s; | |||
uint32_t tmp = std::strtol(c.c_str(), nullptr, 16); | |||
if (c.length() == 3) | |||
{ | |||
tmp = 0x11000000u * (tmp >> 8) | |||
| 0x00110000u * ((tmp >> 4) & 0xf) | |||
| 0x00001100u * (tmp & 0xf) | |||
| 0x000000ffu; | |||
} | |||
else if (c.count() == 4) | |||
else if (c.length() == 4) | |||
{ | |||
tmp = 0x11000000u * (tmp >> 12) | |||
| 0x00110000u * ((tmp >> 8) & 0xf) | |||
| 0x00001100u * ((tmp >> 4) & 0xf) | |||
| 0x00000011u * (tmp & 0xf); | |||
} | |||
else if (c.count() == 6) | |||
else if (c.length() == 6) | |||
{ | |||
tmp = 0xffu | 0x100u * tmp; | |||
} | |||
@@ -79,7 +79,7 @@ public: | |||
Light(); | |||
~Light(); | |||
char const *GetName() { return "<light>"; } | |||
std::string GetName() const { return "<light>"; } | |||
void SetType(LightType const &type); | |||
LightType GetType(); | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2016 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -35,7 +35,7 @@ public: | |||
protected: | |||
/* Inherited from Entity */ | |||
virtual char const *GetName(); | |||
virtual std::string GetName() const; | |||
virtual void TickGame(float seconds); | |||
public: | |||
@@ -44,232 +44,3 @@ std::string vformat(char const *format, va_list ap); | |||
} /* namespace lol */ | |||
// | |||
// The deprecated String class | |||
// --------------------------- | |||
// A very simple String class, based on Array. The most interesting | |||
// thing in there was LOL_ATTR_NODISCARD but apart from that there was | |||
// no real point in using our own class. Phase this out. | |||
// | |||
#include <lol/base/assert.h> | |||
#include <lol/base/array.h> | |||
#include <cstring> | |||
#include <cstdarg> | |||
namespace lol | |||
{ | |||
class LOL_ATTR_NODISCARD String : protected array<char> | |||
{ | |||
private: | |||
typedef array<char> super; | |||
public: | |||
inline String() | |||
: super() | |||
{ | |||
push('\0'); | |||
} | |||
inline String(char const *str) | |||
: super() | |||
{ | |||
using namespace std; | |||
ASSERT(str); | |||
resize((int)strlen(str)); | |||
memcpy(&(*this)[0], str, count() + 1); | |||
} | |||
inline String(char const *str, int item_count) | |||
: super() | |||
{ | |||
using namespace std; | |||
ASSERT(str); | |||
resize(item_count); | |||
memcpy(&(*this)[0], str, item_count); | |||
((super &)*this)[item_count] = '\0'; | |||
} | |||
/* Legacy constructor for std::string */ | |||
inline String(std::string const &s) | |||
: String(s.c_str()) | |||
{ | |||
} | |||
inline String(String const &s) | |||
: super((super const &)s) | |||
{ | |||
} | |||
inline char &operator [](int n) | |||
{ | |||
/* Allow n == count() because we might have reasonable reasons | |||
* to access that hidden null character. We cast to unsigned so | |||
* as to avoid a harmless message from the GCC optimiser. */ | |||
ASSERT(n >= 0); | |||
ASSERT((unsigned)n <= (unsigned)count()); | |||
return ((super &)*this)[n]; | |||
} | |||
inline char const &operator [](int n) const | |||
{ | |||
ASSERT(n >= 0); | |||
ASSERT((unsigned)n <= (unsigned)count()); | |||
return ((super const &)*this)[n]; | |||
} | |||
inline char &last() | |||
{ | |||
ASSERT(count() > 0); | |||
return (*this)[count() - 1]; | |||
} | |||
inline char const &last() const | |||
{ | |||
ASSERT(count() > 0); | |||
return (*this)[count() - 1]; | |||
} | |||
inline int count() const | |||
{ | |||
return ((super const &)*this).count() - 1; | |||
} | |||
/* Return a C string */ | |||
inline char const *C() const | |||
{ | |||
return &(*this)[0]; | |||
} | |||
/* Non-const version; make sure to not overflow the internal array */ | |||
inline char *C() | |||
{ | |||
return &(*this)[0]; | |||
} | |||
/* Does not initialise the newly allocated characters */ | |||
void resize(int item_count) | |||
{ | |||
ASSERT(item_count >= 0); | |||
((super &)*this).resize(item_count + 1); | |||
((super &)*this).last() = '\0'; | |||
} | |||
String sub(int start, int item_count = -1) const | |||
{ | |||
ASSERT(start >= 0); | |||
if (start >= count()) | |||
return String(); | |||
if (item_count < 0 || item_count >= count() - start) | |||
item_count = count() - start; | |||
return String(&(*this)[start], item_count); | |||
} | |||
int replace(char const old_token, char const new_token, | |||
bool all_occurrences = false) | |||
{ | |||
using namespace std; | |||
int res = 0; | |||
char *tmp = NULL; | |||
while ((tmp = strrchr(C(), old_token))) | |||
{ | |||
*tmp = new_token; | |||
res++; | |||
if (!all_occurrences) | |||
break; | |||
} | |||
return res; | |||
} | |||
inline String operator +(String const &s) const | |||
{ | |||
String ret(*this); | |||
return ret += s; | |||
} | |||
inline String operator +(char c) const | |||
{ | |||
String ret(*this); | |||
return ret += c; | |||
} | |||
inline String& operator +=(String const &s) | |||
{ | |||
using namespace std; | |||
int old_count = count(); | |||
resize(count() + s.count()); | |||
memcpy(&(*this)[old_count], &s[0], count() - old_count); | |||
return *this; | |||
} | |||
inline String& operator +=(char c) | |||
{ | |||
((super &)*this).last() = c; | |||
((super &)*this).push('\0'); | |||
return *this; | |||
} | |||
inline bool operator ==(String const &s) const | |||
{ | |||
using namespace std; | |||
return count() == s.count() | |||
&& memcmp(C(), s.C(), count()) == 0; | |||
} | |||
inline bool operator !=(String const &s) const | |||
{ | |||
return !(*this == s); | |||
} | |||
inline bool operator ==(char const* sz) const | |||
{ | |||
/* We parse the C string twice because of strlen + memcmp | |||
* but it's probably still faster than doing it by hand. */ | |||
using namespace std; | |||
int sz_len = (int)strlen(sz); | |||
return count() == sz_len | |||
&& memcmp(C(), sz, sz_len) == 0; | |||
} | |||
inline bool operator !=(char const* sz) const | |||
{ | |||
return !(*this == sz); | |||
} | |||
inline bool operator <(String const & s) const | |||
{ | |||
using namespace std; | |||
int res = memcmp(C(), s.C(), count() < s.count() ? count() : s.count()); | |||
if (!res) | |||
return count() < s.count(); | |||
return res < 0; | |||
} | |||
}; | |||
inline String operator +(char c, String const &s) | |||
{ | |||
return String() + c + s; | |||
} | |||
inline String operator +(char const *sz, String const &s) | |||
{ | |||
return String(sz) + s; | |||
} | |||
inline bool operator ==(char const* sz, String const &s) | |||
{ | |||
return s == sz; | |||
} | |||
inline bool operator !=(char const* sz, String const &s) | |||
{ | |||
return s != sz; | |||
} | |||
} /* namespace lol */ | |||
@@ -54,7 +54,7 @@ struct MeshPrimitiveBase : public StructSafeEnum | |||
Lines, | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[Triangles] = "Triangles"; | |||
enum_map[TriangleStrips] = "TriangleStrips"; | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -345,7 +345,7 @@ public: | |||
/* | |||
* Convert hex strings to colors. | |||
*/ | |||
static vec4 C8BppHexString(String c); | |||
static vec4 C8BppHexString(std::string const &c); | |||
/* | |||
* Some predefined colours | |||
@@ -37,7 +37,7 @@ struct AxisBase : public StructSafeEnum | |||
X = 0, Y, Z, MAX, XY = 2, XYZ = 3, | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[X] = "X"; | |||
enum_map[Y] = "Y"; | |||
@@ -58,7 +58,7 @@ struct DirectionBase : public StructSafeEnum | |||
Up = 0, Down, Left, Right, MAX, | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[Up] = "Up"; | |||
enum_map[Down] = "Down"; | |||
@@ -260,7 +260,7 @@ struct RayIntersectBase : public StructSafeEnum | |||
}; | |||
//LOL_DECLARE_ENUM_METHODS(RayIntersectBase) | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[Nothing] = "Nothing"; | |||
enum_map[All] = "All"; | |||
@@ -325,7 +325,7 @@ struct PlaneIntersectionBase : public StructSafeEnum | |||
Back, Front, Plane, | |||
}; | |||
protected: | |||
virtual bool BuildEnumMap(std::map<int64_t, String>& enum_map) | |||
virtual bool BuildEnumMap(std::map<int64_t, std::string>& enum_map) | |||
{ | |||
enum_map[Back] = "Back"; | |||
enum_map[Front] = "Front"; | |||
@@ -80,7 +80,7 @@ class ThreadJob | |||
protected: | |||
inline ThreadJob(ThreadJobType type) : m_type(type) {} | |||
public: | |||
char const *GetName() { return "<ThreadJob>"; } | |||
std::string GetName() const { return "<ThreadJob>"; } | |||
inline ThreadJob() : m_type(ThreadJobType::NONE) {} | |||
virtual ~ThreadJob() {} | |||
@@ -176,7 +176,7 @@ public: | |||
//------------------------------------------------------------------------- | |||
LolImGui(); | |||
~LolImGui(); | |||
char const *GetName() { return "<LolImGui>"; } | |||
std::string GetName() const { return "<LolImGui>"; } | |||
//------------------------------------------------------------------------- | |||
static void Init(); | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -104,9 +104,9 @@ void SubMesh::SetIndexBuffer(IndexBuffer* ibo) | |||
m_ibo = ibo; | |||
} | |||
void SubMesh::AddTexture(const char* name, Texture* texture) | |||
void SubMesh::AddTexture(std::string const &name, Texture* texture) | |||
{ | |||
m_textures.push(String(name), texture); | |||
m_textures.push(name, texture); | |||
} | |||
void SubMesh::Render() | |||
@@ -142,7 +142,7 @@ void SubMesh::Render() | |||
for (int i = 0; i < m_textures.count(); ++i) | |||
{ | |||
// TODO: might be good to cache this | |||
ShaderUniform u_tex = m_shader->GetUniformLocation(m_textures[i].m1.C()); | |||
ShaderUniform u_tex = m_shader->GetUniformLocation(m_textures[i].m1); | |||
m_shader->SetUniform(u_tex, m_textures[i].m2->GetTextureUniform(), i); | |||
} | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2016 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -94,7 +94,7 @@ public: | |||
void SetVertexDeclaration(VertexDeclaration *vdecl); | |||
void SetVertexBuffer(int index, VertexBuffer* vbo); | |||
void SetIndexBuffer(IndexBuffer* ibo); | |||
void AddTexture(const char* name, Texture* texture); | |||
void AddTexture(std::string const &name, Texture* texture); | |||
protected: | |||
void Render(); | |||
@@ -105,7 +105,7 @@ protected: | |||
array<VertexBuffer *> m_vbos; | |||
IndexBuffer *m_ibo; | |||
array<String, Texture*> m_textures; | |||
array<std::string, Texture*> m_textures; | |||
}; | |||
} /* namespace lol */ | |||
@@ -89,7 +89,7 @@ public: | |||
MessageService(); | |||
~MessageService(); | |||
static char const *GetName() { return "<messageservice>"; } | |||
static std::string GetName() { return "<messageservice>"; } | |||
//Setup/Destroy | |||
static void Setup(); | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2002—2016 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2002—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -44,7 +44,7 @@ struct getopt_private | |||
int m_argc; | |||
char * const *m_argv; | |||
String m_optstring; | |||
std::string m_optstring; | |||
array<optdesc> m_opts; | |||
}; | |||
@@ -90,7 +90,7 @@ int getopt::parse() | |||
optind = this->index; | |||
optarg = this->arg; | |||
m_private->m_opts.push(getopt_private::optdesc { nullptr, 0, nullptr, 0 }); | |||
ret = getopt_long(m_private->m_argc, m_private->m_argv, m_private->m_optstring.C(), | |||
ret = getopt_long(m_private->m_argc, m_private->m_argv, m_private->m_optstring.c_str(), | |||
(option const *)m_private->m_opts.data(), &longindex); | |||
this->index = optind; | |||
this->arg = optarg; | |||
@@ -117,7 +117,7 @@ int getopt::parse() | |||
if (ret == '\0') | |||
return -1; | |||
tmp = strchr(m_private->m_optstring.C(), ret); | |||
tmp = strchr(m_private->m_optstring.c_str(), ret); | |||
if (!tmp || ret == ':') | |||
return '?'; | |||
@@ -32,14 +32,19 @@ class FileUpdateTesterJob : public ThreadJob | |||
{ | |||
friend class FileUpdateTester; | |||
public: | |||
char const *GetName() { return "<FileUpdateTesterJob>"; } | |||
std::string GetName() const { return "<FileUpdateTesterJob>"; } | |||
FileUpdateTesterJob() | |||
: ThreadJob(ThreadJobType::NONE) { } | |||
: ThreadJob(ThreadJobType::NONE) | |||
{ | |||
} | |||
FileUpdateTesterJob(std::string const &path) | |||
: ThreadJob(ThreadJobType::WORK_TODO) | |||
: ThreadJob(ThreadJobType::WORK_TODO), | |||
m_path(path) | |||
{ | |||
m_path = path; | |||
} | |||
std::string const &GetPath() { return m_path; } | |||
long int GetTime() { return m_time; } | |||
bool HasUpdated() { return m_updated; } | |||
@@ -156,7 +161,8 @@ void FileUpdateTester::TreatResult(ThreadJob* result) | |||
class AsyncImageJob : public ThreadJob | |||
{ | |||
public: | |||
char const *GetName() { return "<AsyncImageJob>"; } | |||
std::string GetName() const { return "<AsyncImageJob>"; } | |||
AsyncImageJob() | |||
: ThreadJob(ThreadJobType::NONE) | |||
{ | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine — Unit tests | |||
// | |||
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -191,7 +191,7 @@ lolunit_declare_fixture(array_test) | |||
lolunit_declare_test(array_insert_tuple) | |||
{ | |||
array<int, float, String> b; | |||
array<int, float, std::string> b; | |||
b.insert(0, 5, 6.f, "lol"); | |||
lolunit_assert_equal(5, b[0].m1); | |||
lolunit_assert_equal(6.f, b[0].m2); | |||
@@ -28,9 +28,12 @@ lolunit_declare_fixture(thread_test) | |||
{ | |||
friend class UnitTestThreadManager; | |||
public: | |||
char const *GetName() { return "<UnitTestJob>"; } | |||
UnitTestJob() : ThreadJob(ThreadJobType::WORK_TODO) | |||
std::string GetName() const { return "<UnitTestJob>"; } | |||
UnitTestJob() | |||
: ThreadJob(ThreadJobType::WORK_TODO) | |||
{ } | |||
bool IsDone() | |||
{ | |||
return m_done; | |||
@@ -41,9 +44,9 @@ lolunit_declare_fixture(thread_test) | |||
{ | |||
timer t; | |||
m_done = false; | |||
msg::info("%s: STARTED WORK\n", GetName()); | |||
msg::info("%s: STARTED WORK\n", GetName().c_str()); | |||
t.wait(2.f); | |||
msg::info("%s: ENDED WORK\n", GetName()); | |||
msg::info("%s: ENDED WORK\n", GetName().c_str()); | |||
m_done = true; | |||
return true; | |||
} | |||
@@ -76,7 +79,7 @@ lolunit_declare_fixture(thread_test) | |||
typedef SafeEnum<UnitTestStatusBase> UnitTestStatus; | |||
public: | |||
char const *GetName() { return "<UnitTestThreadManager>"; } | |||
std::string GetName() const { return "<UnitTestThreadManager>"; } | |||
UnitTestThreadManager() : BaseThreadManager(4, 1) | |||
{ } | |||
virtual ~UnitTestThreadManager() | |||
@@ -84,14 +87,14 @@ lolunit_declare_fixture(thread_test) | |||
void AddJob(ThreadJob* job) | |||
{ | |||
msg::info("%s DISPATCHING JOB %s\n", GetName(), job->GetName()); | |||
msg::info("%s DISPATCHING JOB %s\n", GetName().c_str(), job->GetName().c_str()); | |||
DispatchJob(job); | |||
} | |||
bool GetWorkResult(array<ThreadJob*>& results) | |||
{ | |||
results += m_job_result; | |||
m_job_result.empty(); | |||
msg::info("%s GETWORKRESULT (%i)\n", GetName(), results.count()); | |||
msg::info("%s GETWORKRESULT (%i)\n", GetName().c_str(), results.count()); | |||
return results.count() > 0; | |||
} | |||
@@ -102,7 +105,7 @@ lolunit_declare_fixture(thread_test) | |||
case UnitTestStatus::NOT_QUEUED: | |||
if (!!GetDispatchCount()) | |||
{ | |||
msg::info("%s TICKGAME %s\n", GetName(), m_status.tostring().c_str()); | |||
msg::info("%s TICKGAME %s\n", GetName().c_str(), m_status.tostring().c_str()); | |||
m_status = UnitTestStatus::QUEUED; | |||
} | |||
break; | |||
@@ -113,14 +116,14 @@ lolunit_declare_fixture(thread_test) | |||
if (GetDispatchedCount()) | |||
#endif | |||
{ | |||
msg::info("%s TICKGAME %s\n", GetName(), m_status.tostring().c_str()); | |||
msg::info("%s TICKGAME %s\n", GetName().c_str(), m_status.tostring().c_str()); | |||
m_status = UnitTestStatus::RETRIEVED; | |||
} | |||
break; | |||
case UnitTestStatus::RETRIEVED: | |||
if (m_job_result.count() == 4) | |||
{ | |||
msg::info("%s TICKGAME %s\n", GetName(), m_status.tostring().c_str()); | |||
msg::info("%s TICKGAME %s\n", GetName().c_str(), m_status.tostring().c_str()); | |||
m_status = UnitTestStatus::DONE; | |||
} | |||
break; | |||
@@ -154,10 +157,10 @@ lolunit_declare_fixture(thread_test) | |||
lolunit_declare_test(threads) | |||
{ | |||
msg::info("%s START\n", m_manager.GetName()); | |||
msg::info("%s START\n", m_manager.GetName().c_str()); | |||
//Start threads manager | |||
m_manager.Start(); | |||
msg::info("%s STARTED\n", m_manager.GetName()); | |||
msg::info("%s STARTED\n", m_manager.GetName().c_str()); | |||
UnitTestJob job[4]; | |||
lolunit_assert_equal(0, m_manager.Test_GetDispatchCount()); | |||
@@ -190,10 +193,10 @@ lolunit_declare_fixture(thread_test) | |||
m_manager.GetWorkResult(results); | |||
lolunit_assert_equal(4, results.count()); | |||
msg::info("%s STOP\n", m_manager.GetName()); | |||
msg::info("%s STOP\n", m_manager.GetName().c_str()); | |||
//Stop manager | |||
m_manager.Stop(); | |||
msg::info("%s STOPPED\n", m_manager.GetName()); | |||
msg::info("%s STOPPED\n", m_manager.GetName().c_str()); | |||
} | |||
lolunit_declare_test(queue_try_push) | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -30,7 +30,7 @@ class TextData | |||
private: | |||
int m_font; | |||
TextAlign m_align; | |||
String m_text; | |||
std::string m_text; | |||
vec3 m_pos; | |||
vec2 m_scale; | |||
float m_spacing; | |||
@@ -40,7 +40,7 @@ private: | |||
* Public Text class | |||
*/ | |||
Text::Text(String const &text, char const *font) | |||
Text::Text(std::string const &text, char const *font) | |||
: data(new TextData()) | |||
{ | |||
data->m_font = Forge::Register(font); | |||
@@ -53,7 +53,7 @@ Text::Text(String const &text, char const *font) | |||
m_drawgroup = DRAWGROUP_HUD; | |||
} | |||
void Text::SetText(String const &text) | |||
void Text::SetText(std::string const &text) | |||
{ | |||
data->m_text = text; | |||
} | |||
@@ -98,7 +98,7 @@ void Text::TickDraw(float seconds, Scene &scene) | |||
{ | |||
Entity::TickDraw(seconds, scene); | |||
if (auto length = data->m_text.count()) | |||
if (auto length = data->m_text.length()) | |||
{ | |||
Font *font = Forge::GetFont(data->m_font); | |||
vec3 delta(0.0f); | |||
@@ -110,7 +110,7 @@ void Text::TickDraw(float seconds, Scene &scene) | |||
else if (data->m_align == TextAlign::Center) | |||
delta.x -= 0.5f * text_width * data->m_scale.x; | |||
font->Print(scene, data->m_pos + delta, data->m_text.C(), | |||
font->Print(scene, data->m_pos + delta, data->m_text, | |||
data->m_scale, data->m_spacing); | |||
} | |||
} | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
@@ -17,6 +19,8 @@ | |||
#include "engine/entity.h" | |||
#include <string> | |||
namespace lol | |||
{ | |||
@@ -32,11 +36,11 @@ enum class TextAlign | |||
class Text : public Entity | |||
{ | |||
public: | |||
Text(String const &text, char const *font); | |||
Text(std::string const &text, char const *font); | |||
virtual ~Text(); | |||
/** Set the text that will be displayed */ | |||
void SetText(String const &text); | |||
void SetText(std::string const &text); | |||
void SetInt(int val); | |||
/** Set the position of the text object, in the 3D world. */ | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
@@ -27,7 +29,7 @@ class TextureImageData | |||
//T'was protected .... should it be ? | |||
public: | |||
String m_name; | |||
std::string m_name; | |||
/* Pixels, then texture coordinates */ | |||
ivec2 m_image_size, m_texture_size; | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -40,13 +40,13 @@ TextureImageData* TextureImage::GetNewData() | |||
* Public TextureImage class | |||
*/ | |||
TextureImage::TextureImage(char const *path) | |||
TextureImage::TextureImage(std::string const &path) | |||
: m_data(GetNewData()) | |||
{ | |||
Init(path); | |||
} | |||
TextureImage::TextureImage(char const *path, image* img) | |||
TextureImage::TextureImage(std::string const &path, image* img) | |||
: m_data(GetNewData()) | |||
{ | |||
Init(path, img); | |||
@@ -57,12 +57,12 @@ TextureImage::~TextureImage() | |||
delete m_data; | |||
} | |||
void TextureImage::Init(char const *path) | |||
void TextureImage::Init(std::string const &path) | |||
{ | |||
Init(path, ResourceLoader::Load(path)); | |||
} | |||
void TextureImage::Init(char const *path, ResourceCodecData* loaded_data) | |||
void TextureImage::Init(std::string const &path, ResourceCodecData* loaded_data) | |||
{ | |||
//Load image if available | |||
auto image_data = dynamic_cast<ResourceImageData*>(loaded_data); | |||
@@ -74,9 +74,9 @@ void TextureImage::Init(char const *path, ResourceCodecData* loaded_data) | |||
delete image_data; | |||
} | |||
void TextureImage::Init(char const *path, image* img) | |||
void TextureImage::Init(std::string const &path, image* img) | |||
{ | |||
m_data->m_name = String("<textureimage> ") + path; | |||
m_data->m_name = "<textureimage> " + path; | |||
m_data->m_texture = nullptr; | |||
m_data->m_image = img; | |||
@@ -144,9 +144,9 @@ void TextureImage::TickDraw(float seconds, Scene &scene) | |||
} | |||
//----------------------------------------------------------------------------- | |||
char const *TextureImage::GetName() | |||
std::string TextureImage::GetName() const | |||
{ | |||
return m_data->m_name.C(); | |||
return m_data->m_name; | |||
} | |||
void TextureImage::UpdateTexture(image* img) | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
@@ -38,21 +40,21 @@ protected: | |||
virtual TextureImageData* GetNewData(); | |||
public: | |||
TextureImage(char const *path); | |||
TextureImage(char const *path, image* img); | |||
TextureImage(std::string const &path); | |||
TextureImage(std::string const &path, image* img); | |||
virtual ~TextureImage(); | |||
protected: | |||
void Init(char const *path); | |||
virtual void Init(char const *path, ResourceCodecData* loaded_data); | |||
virtual void Init(char const *path, image* img); | |||
void Init(std::string const &path); | |||
virtual void Init(std::string const &path, ResourceCodecData* loaded_data); | |||
virtual void Init(std::string const &path, image* img); | |||
protected: | |||
virtual void TickDraw(float seconds, Scene &scene); | |||
public: | |||
/* Inherited from Entity */ | |||
virtual char const *GetName(); | |||
virtual std::string GetName() const; | |||
void UpdateTexture(image* img); | |||
Texture * GetTexture(); | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#include <lol/engine-internal.h> | |||
@@ -36,11 +38,7 @@ static TilerData * const data = &tilerdata; | |||
* Public Tiler class | |||
*/ | |||
TileSet *Tiler::Register(String const &path, ivec2 size, ivec2 count) | |||
{ | |||
return Tiler::Register(path.C(), size, count); | |||
} | |||
TileSet *Tiler::Register(char const *path, ivec2 size, ivec2 count) | |||
TileSet *Tiler::Register(std::string const &path, ivec2 size, ivec2 count) | |||
{ | |||
int id = data->tilesets.MakeSlot(path); | |||
TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id); | |||
@@ -54,11 +52,7 @@ TileSet *Tiler::Register(char const *path, ivec2 size, ivec2 count) | |||
return tileset; | |||
} | |||
TileSet *Tiler::Register(String const &path) | |||
{ | |||
return Tiler::Register(path.C()); | |||
} | |||
TileSet *Tiler::Register(char const *path) | |||
TileSet *Tiler::Register(std::string const &path) | |||
{ | |||
int id = data->tilesets.MakeSlot(path); | |||
TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id); | |||
@@ -72,11 +66,7 @@ TileSet *Tiler::Register(char const *path) | |||
return tileset; | |||
} | |||
TileSet *Tiler::Register(String const &path, Image* image, ivec2 size, ivec2 count) | |||
{ | |||
return Tiler::Register(path.C(), image, size, count); | |||
} | |||
TileSet *Tiler::Register(char const *path, Image* image, ivec2 size, ivec2 count) | |||
TileSet *Tiler::Register(std::string const &path, Image* image, ivec2 size, ivec2 count) | |||
{ | |||
int id = data->tilesets.MakeSlot(path); | |||
TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id); | |||
@@ -90,11 +80,7 @@ TileSet *Tiler::Register(char const *path, Image* image, ivec2 size, ivec2 count | |||
return tileset; | |||
} | |||
TileSet *Tiler::Register(String const &path, Image* image) | |||
{ | |||
return Tiler::Register(path.C(), image); | |||
} | |||
TileSet *Tiler::Register(char const *path, Image* image) | |||
TileSet *Tiler::Register(std::string const &path, Image* image) | |||
{ | |||
int id = data->tilesets.MakeSlot(path); | |||
TileSet *tileset = (TileSet *)data->tilesets.GetEntity(id); | |||
@@ -1,11 +1,13 @@ | |||
// | |||
// Lol Engine | |||
// Lol Engine | |||
// | |||
// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net> | |||
// This program is free software; you can redistribute it and/or | |||
// modify it under the terms of the Do What The Fuck You Want To | |||
// Public License, Version 2, as published by Sam Hocevar. See | |||
// http://www.wtfpl.net/ for more details. | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
// and/or modify it under the terms of the Do What the Fuck You Want | |||
// to Public License, Version 2, as published by the WTFPL Task Force. | |||
// See http://www.wtfpl.net/ for more details. | |||
// | |||
#pragma once | |||
@@ -26,14 +28,10 @@ namespace lol | |||
class Tiler | |||
{ | |||
public: | |||
static TileSet *Register(String const &path, ivec2 size, ivec2 count); | |||
static TileSet *Register(char const *path, ivec2 size, ivec2 count); | |||
static TileSet *Register(String const &path); | |||
static TileSet *Register(char const *path); | |||
static TileSet *Register(String const &path, image* img, ivec2 size, ivec2 count); | |||
static TileSet *Register(char const *path, image* img, ivec2 size, ivec2 count); | |||
static TileSet *Register(String const &path, image* img); | |||
static TileSet *Register(char const *path, image* img); | |||
static TileSet *Register(std::string const &path, ivec2 size, ivec2 count); | |||
static TileSet *Register(std::string const &path); | |||
static TileSet *Register(std::string const &path, image* img, ivec2 size, ivec2 count); | |||
static TileSet *Register(std::string const &path, image* img); | |||
static void Deregister(TileSet *); | |||
private: | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -45,21 +45,21 @@ protected: | |||
* Public TileSet class | |||
*/ | |||
TileSet::TileSet(char const *path) | |||
TileSet::TileSet(std::string const &path) | |||
: TextureImage(path), | |||
m_tileset_data(new TileSetData()), | |||
m_palette(nullptr) | |||
{ | |||
} | |||
TileSet::TileSet(char const *path, Image* image) | |||
TileSet::TileSet(std::string const &path, Image* image) | |||
: TextureImage(path, image), | |||
m_tileset_data(new TileSetData()), | |||
m_palette(nullptr) | |||
{ | |||
} | |||
TileSet::TileSet(char const *path, Image* image, array<ivec2, ivec2>& tiles) | |||
TileSet::TileSet(std::string const &path, Image* image, array<ivec2, ivec2>& tiles) | |||
: TextureImage(path, image), | |||
m_tileset_data(new TileSetData()), | |||
m_palette(nullptr) | |||
@@ -67,7 +67,7 @@ TileSet::TileSet(char const *path, Image* image, array<ivec2, ivec2>& tiles) | |||
define_tile(tiles); | |||
} | |||
TileSet::TileSet(char const *path, ivec2 size, ivec2 count) | |||
TileSet::TileSet(std::string const &path, ivec2 size, ivec2 count) | |||
: TileSet(path) | |||
{ | |||
/* If count is valid, fix size; otherwise, fix count. */ | |||
@@ -90,7 +90,7 @@ TileSet::TileSet(char const *path, ivec2 size, ivec2 count) | |||
} | |||
} | |||
TileSet::TileSet(char const *path, Image* image, ivec2 size, ivec2 count) | |||
TileSet::TileSet(std::string const &path, Image* image, ivec2 size, ivec2 count) | |||
: TileSet(path, image) | |||
{ | |||
/* If count is valid, fix size; otherwise, fix count. */ | |||
@@ -118,7 +118,7 @@ TileSet::~TileSet() | |||
delete m_tileset_data; | |||
} | |||
void TileSet::Init(char const *path, ResourceCodecData* loaded_data) | |||
void TileSet::Init(std::string const &path, ResourceCodecData* loaded_data) | |||
{ | |||
//Load tileset if available | |||
auto tileset_data = dynamic_cast<ResourceTilesetData*>(loaded_data); | |||
@@ -127,22 +127,22 @@ void TileSet::Init(char const *path, ResourceCodecData* loaded_data) | |||
define_tile(tileset_data->m_tiles); | |||
} | |||
m_data->m_name = String("<tileset> ") + path; | |||
m_data->m_name = "<tileset> " + path; | |||
super::Init(path, loaded_data); | |||
} | |||
void TileSet::Init(char const *path, Image* image) | |||
void TileSet::Init(std::string const &path, Image* image) | |||
{ | |||
super::Init(path, image); | |||
m_data->m_name = String("<tileset> ") + path; | |||
m_data->m_name = "<tileset> " + path; | |||
} | |||
//Inherited from Entity ------------------------------------------------------- | |||
char const *TileSet::GetName() | |||
std::string TileSet::GetName() const | |||
{ | |||
return m_data->m_name.C(); | |||
return m_data->m_name; | |||
} | |||
//New methods ----------------------------------------------------------------- | |||
@@ -1,7 +1,7 @@ | |||
// | |||
// Lol Engine | |||
// | |||
// Copyright © 2010—2015 Sam Hocevar <sam@hocevar.net> | |||
// Copyright © 2010—2018 Sam Hocevar <sam@hocevar.net> | |||
// | |||
// Lol Engine is free software. It comes without any warranty, to | |||
// the extent permitted by applicable law. You can redistribute it | |||
@@ -41,23 +41,23 @@ class TileSet : public TextureImage | |||
typedef TextureImage super; | |||
public: | |||
TileSet(char const *path); | |||
TileSet(char const *path, image* img); | |||
TileSet(char const *path, image* img, array<ivec2, ivec2>& tiles); | |||
TileSet(std::string const &path); | |||
TileSet(std::string const &path, image* img); | |||
TileSet(std::string const &path, image* img, array<ivec2, ivec2>& tiles); | |||
/* Old style: path to PNG file */ | |||
TileSet(char const *path, ivec2 size, ivec2 count); | |||
TileSet(char const *path, image* img, ivec2 size, ivec2 count); | |||
TileSet(std::string const &path, ivec2 size, ivec2 count); | |||
TileSet(std::string const &path, image* img, ivec2 size, ivec2 count); | |||
virtual ~TileSet(); | |||
protected: | |||
virtual void Init(char const *path, ResourceCodecData* loaded_data); | |||
virtual void Init(char const *path, image* img); | |||
virtual void Init(std::string const &path, ResourceCodecData* loaded_data); | |||
virtual void Init(std::string const &path, image* img); | |||
public: | |||
/* Inherited from Entity */ | |||
virtual char const *GetName(); | |||
virtual std::string GetName() const; | |||
/* New methods */ | |||
void clear_all(); | |||