Daniele Bartolini 10 лет назад
Родитель
Сommit
8af20cb59a

+ 0 - 87
src/core/settings/float_setting.cpp

@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
- * License: https://github.com/taylor001/crown/blob/master/LICENSE
- */
-
-#include "float_setting.h"
-#include "string_utils.h"
-#include "math_utils.h"
-
-namespace crown
-{
-
-static FloatSetting* g_float_settings_head = NULL;
-
-FloatSetting::FloatSetting(const char* name, const char* synopsis, float value, float min, float max)
-	: _name(name)
-	, _synopsis(synopsis)
-	, _value(0)
-	, _min(min)
-	, _max(max)
-	, _next(NULL)
-{
-	*this = value;
-
-	if (g_float_settings_head != NULL)
-	{
-		_next = g_float_settings_head;
-	}
-
-	g_float_settings_head = this;
-}
-
-const char* FloatSetting::name() const
-{
-	return _name;
-}
-
-const char* FloatSetting::synopsis() const
-{
-	return _synopsis;
-}
-
-float FloatSetting::value() const
-{
-	return _value;
-}
-
-float FloatSetting::min() const
-{
-	return _min;
-}
-
-float FloatSetting::max() const
-{
-	return _max;
-}
-
-FloatSetting::operator float()
-{
-	return _value;
-}
-
-FloatSetting& FloatSetting::operator=(const float value)
-{
-	_value = clamp(_min, _max, value);
-	return *this;
-}
-
-FloatSetting* FloatSetting::find_setting(const char* name)
-{
-	FloatSetting* head = g_float_settings_head;
-
-	while (head != NULL)
-	{
-		if (strcmp(name, head->name()) == 0)
-		{
-			return head;
-		}
-
-		head = head->_next;
-	}
-
-	return NULL;
-}
-
-} // namespace crown
-

+ 0 - 48
src/core/settings/float_setting.h

@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
- * License: https://github.com/taylor001/crown/blob/master/LICENSE
- */
-
-#pragma once
-
-#include "types.h"
-
-namespace crown
-{
-
-/// Facility to store global float settings.
-class FloatSetting
-{
-public:
-
-	FloatSetting(const char* name, const char* synopsis, float value, float min, float max);
-
-	const char* name() const;
-	const char* synopsis() const;
-
-	float value() const;
-	float min() const;
-	float max() const;
-
-	operator float();
-	FloatSetting& operator=(const float value);
-
-public:
-
-	/// Returns the setting @name or NULL if not found.
-	static FloatSetting* find_setting(const char* name);
-
-private:
-
-	const char* _name;
-	const char* _synopsis;
-
-	float _value;
-	float _min;
-	float _max;
-
-	FloatSetting* _next;
-};
-
-} // namespace crown
-

+ 0 - 87
src/core/settings/int_setting.cpp

@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
- * License: https://github.com/taylor001/crown/blob/master/LICENSE
- */
-
-#include "int_setting.h"
-#include "string_utils.h"
-#include "math_utils.h"
-
-namespace crown
-{
-
-static IntSetting* g_int_settings_head = NULL;
-
-IntSetting::IntSetting(const char* name, const char* synopsis, int32_t value, int32_t min, int32_t max)
-	: _name(name)
-	, _synopsis(synopsis)
-	, _value(0)
-	, _min(min)
-	, _max(max)
-	, _next(NULL)
-{
-	*this = value;
-
-	if (g_int_settings_head != NULL)
-	{
-		_next = g_int_settings_head;
-	}
-
-	g_int_settings_head = this;
-}
-
-const char* IntSetting::name() const
-{
-	return _name;
-}
-
-const char* IntSetting::synopsis() const
-{
-	return _synopsis;
-}
-
-int32_t IntSetting::value() const
-{
-	return _value;
-}
-
-int32_t IntSetting::min() const
-{
-	return _min;
-}
-
-int32_t IntSetting::max() const
-{
-	return _max;
-}
-
-IntSetting::operator int()
-{
-	return _value;
-}
-
-IntSetting& IntSetting::operator=(const int32_t value)
-{
-	_value = clamp(_min, _max, value);
-	return *this;
-}
-
-IntSetting*	IntSetting::find_setting(const char* name)
-{
-	IntSetting* head = g_int_settings_head;
-
-	while (head != NULL)
-	{
-		if (strcmp(name, head->name()) == 0)
-		{
-			return head;
-		}
-
-		head = head->_next;
-	}
-
-	return NULL;
-}
-
-} // namespace crown
-

+ 0 - 49
src/core/settings/int_setting.h

@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
- * License: https://github.com/taylor001/crown/blob/master/LICENSE
- */
-
-#pragma once
-
-#include "types.h"
-
-namespace crown
-{
-
-/// Facility to store global integer settings.
-class IntSetting
-{
-public:
-
-	IntSetting(const char* name, const char* synopsis, int32_t value, int32_t min, int32_t max);
-
-	const char* name() const;
-	const char* synopsis() const;
-
-	int32_t value() const;
-	int32_t min() const;
-	int32_t max() const;
-
-	operator int();
-
-	IntSetting& operator=(const int32_t value);
-
-public:
-
-	/// Returns the setting @name or NULL if not found.
-	static IntSetting* find_setting(const char* name);
-
-private:
-
-	const char* _name;
-	const char* _synopsis;
-
-	int32_t _value;
-	int32_t _min;
-	int32_t _max;
-
-	IntSetting* _next;
-};
-
-} // namespace crown
-

+ 0 - 68
src/core/settings/string_setting.cpp

@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
- * License: https://github.com/taylor001/crown/blob/master/LICENSE
- */
-
-#include "string_setting.h"
-#include "string_utils.h"
-
-namespace crown
-{
-
-static StringSetting* g_string_settings_head = NULL;
-
-StringSetting::StringSetting(const char* name, const char* synopsis, const char* value)
-	: _name(name)
-	, _synopsis(synopsis)
-	, _value(value)
-	, _next(NULL)
-{
-	*this = value;
-
-	if (g_string_settings_head != NULL)
-	{
-		_next = g_string_settings_head;
-	}
-
-	g_string_settings_head = this;
-}
-
-const char* StringSetting::name() const
-{
-	return _name;
-}
-
-const char* StringSetting::synopsis() const
-{
-	return _synopsis;
-}
-
-const char*	StringSetting::value() const
-{
-	return _value;
-}
-
-StringSetting& StringSetting::operator=(const char* value)
-{
-	_value = value;
-	return *this;
-}
-
-StringSetting* StringSetting::find_setting(const char* name)
-{
-	StringSetting* head = g_string_settings_head;
-
-	while (head != NULL)
-	{
-		if (strcmp(name, head->name()) == 0)
-		{
-			return head;
-		}
-
-		head = head->_next;
-	}
-
-	return NULL;
-}
-
-} // namespace crown

+ 0 - 41
src/core/settings/string_setting.h

@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
- * License: https://github.com/taylor001/crown/blob/master/LICENSE
- */
-
-#pragma once
-
-#include "types.h"
-
-namespace crown
-{
-
-/// Facility to store global string settings.
-class StringSetting
-{
-public:
-
-	StringSetting(const char* name, const char* synopsis, const char* value);
-
-	const char* name() const;
-	const char* synopsis() const;
-
-	const char* value() const;
-
-	StringSetting& operator=(const char* value);
-
-public:
-
-	/// Returns the setting @name or NULL if not found.
-	static StringSetting*	find_setting(const char* name);
-
-private:
-
-	const char* _name;
-	const char* _synopsis;
-	const char* _value;
-
-	StringSetting* _next;
-};
-
-} // namespace crown

+ 0 - 2
src/lua/lua_environment.cpp

@@ -30,7 +30,6 @@ extern void load_raycast(LuaEnvironment& env);
 extern void load_resource_package(LuaEnvironment& env);
 extern void load_sound_world(LuaEnvironment& env);
 extern void load_sprite(LuaEnvironment& env);
-extern void load_settings(LuaEnvironment& env);
 extern void load_unit(LuaEnvironment& env);
 extern void load_window(LuaEnvironment& env);
 extern void load_world(LuaEnvironment& env);
@@ -189,7 +188,6 @@ void LuaEnvironment::load_libs()
 	load_resource_package(*this);
 	load_sound_world(*this);
 	load_sprite(*this);
-	load_settings(*this);
 	load_unit(*this);
 	load_window(*this);
 	load_world(*this);

+ 0 - 167
src/lua/lua_settings.cpp

@@ -1,167 +0,0 @@
-/*
- * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
- * License: https://github.com/taylor001/crown/blob/master/LICENSE
- */
-
-#include "int_setting.h"
-#include "float_setting.h"
-#include "string_setting.h"
-#include "lua_stack.h"
-#include "lua_environment.h"
-
-namespace crown
-{
-
-static int int_setting_query_value(lua_State* L)
-{
-	LuaStack stack(L);
-	const char* setting_name = stack.get_string(1);
-	IntSetting* setting = IntSetting::find_setting(setting_name);
-	LUA_ASSERT(setting != NULL, stack, "Setting not found");
-	stack.push_int32(setting->value());
-	return 1;
-}
-
-static int int_setting_query_synopsis(lua_State* L)
-{
-	LuaStack stack(L);
-	const char* setting_name = stack.get_string(1);
-	IntSetting* setting = IntSetting::find_setting(setting_name);
-	LUA_ASSERT(setting != NULL, stack, "Setting not found");
-	stack.push_string(setting->synopsis());
-	return 1;
-}
-
-static int int_setting_query_min(lua_State* L)
-{
-	LuaStack stack(L);
-	const char* setting_name = stack.get_string(1);
-	IntSetting* setting = IntSetting::find_setting(setting_name);
-	LUA_ASSERT(setting != NULL, stack, "Setting not found");
-	stack.push_int32(setting->min());
-	return 1;
-}
-
-static int int_setting_query_max(lua_State* L)
-{
-	LuaStack stack(L);
-	const char* setting_name = stack.get_string(1);
-	IntSetting* setting = IntSetting::find_setting(setting_name);
-	LUA_ASSERT(setting != NULL, stack, "Setting not found");
-	stack.push_int32(setting->max());
-	return 1;
-}
-
-static int int_setting_update(lua_State* L)
-{
-	LuaStack stack(L);
-	const char* setting_name = stack.get_string(1);
-	const int32_t setting_value = stack.get_int(2);
-	IntSetting* setting = IntSetting::find_setting(setting_name);
-	LUA_ASSERT(setting != NULL, stack, "Setting not found");
-	*setting = setting_value;
-	return 0;
-}
-
-static int float_setting_value(lua_State* L)
-{
-	LuaStack stack(L);
-	const char* setting_name = stack.get_string(1);
-	FloatSetting* setting = FloatSetting::find_setting(setting_name);
-	LUA_ASSERT(setting != NULL, stack, "Setting not found");
-	stack.push_float(setting->value());
-	return 1;
-}
-
-static int float_setting_synopsis(lua_State* L)
-{
-	LuaStack stack(L);
-	const char* setting_name = stack.get_string(1);
-	FloatSetting* setting = FloatSetting::find_setting(setting_name);
-	LUA_ASSERT(setting != NULL, stack, "Setting not found");
-	stack.push_string(setting->synopsis());
-	return 1;
-}
-
-static int float_setting_min(lua_State* L)
-{
-	LuaStack stack(L);
-	const char* setting_name = stack.get_string(1);
-	FloatSetting* setting = FloatSetting::find_setting(setting_name);
-	LUA_ASSERT(setting != NULL, stack, "Setting not found");
-	stack.push_float(setting->min());
-	return 1;
-}
-
-static int float_setting_max(lua_State* L)
-{
-	LuaStack stack(L);
-	const char* setting_name = stack.get_string(1);
-	FloatSetting* setting = FloatSetting::find_setting(setting_name);
-	LUA_ASSERT(setting != NULL, stack, "Setting not found");
-	stack.push_float(setting->max());
-	return 1;
-}
-
-static int float_setting_update(lua_State* L)
-{
-	LuaStack stack(L);
-	const char* setting_name = stack.get_string(1);
-	const float setting_value = stack.get_float(2);
-	FloatSetting* setting = FloatSetting::find_setting(setting_name);
-	LUA_ASSERT(setting != NULL, stack, "Setting not found");
-	*setting = setting_value;
-	return 0;
-}
-
-static int string_setting_value(lua_State* L)
-{
-	LuaStack stack(L);
-	const char* setting_name = stack.get_string(1);
-	StringSetting* setting = StringSetting::find_setting(setting_name);
-	LUA_ASSERT(setting != NULL, stack, "Setting not found");
-	stack.push_string(setting->value());
-	return 1;
-}
-
-static int string_setting_synopsis(lua_State* L)
-{
-	LuaStack stack(L);
-	const char* setting_name = stack.get_string(1);
-	StringSetting* setting = StringSetting::find_setting(setting_name);
-	LUA_ASSERT(setting != NULL, stack, "Setting not found");
-	stack.push_string(setting->synopsis());
-	return 1;
-}
-
-static int string_setting_update(lua_State* L)
-{
-	LuaStack stack(L);
-	const char* setting_name = stack.get_string(1);
-	const char* setting_value = stack.get_string(2);
-	StringSetting* setting = StringSetting::find_setting(setting_name);
-	LUA_ASSERT(setting != NULL, stack, "Setting not found");
-	*setting = setting_value;
-	return 0;
-}
-
-void load_settings(LuaEnvironment& env)
-{
-	env.load_module_function("IntSetting", "value",    int_setting_query_value);
-	env.load_module_function("IntSetting", "synopsis", int_setting_query_synopsis);
-	env.load_module_function("IntSetting", "min",      int_setting_query_min);
-	env.load_module_function("IntSetting", "max",      int_setting_query_max);
-	env.load_module_function("IntSetting", "update",   int_setting_update);
-
-	env.load_module_function("FloatSetting", "value",    float_setting_value);
-	env.load_module_function("FloatSetting", "synopsis", float_setting_synopsis);
-	env.load_module_function("FloatSetting", "min",      float_setting_min);
-	env.load_module_function("FloatSetting", "max",      float_setting_max);
-	env.load_module_function("FloatSetting", "update",   float_setting_update);
-
-	env.load_module_function("StringSetting", "value",    string_setting_value);
-	env.load_module_function("StringSetting", "synopsis", string_setting_synopsis);
-	env.load_module_function("StringSetting", "update",   string_setting_update);
-}
-
-} // namespace crown

+ 0 - 1
src/physics/physics_world.cpp

@@ -23,7 +23,6 @@
 #include "world.h"
 #include "debug_line.h"
 #include "color4.h"
-#include "int_setting.h"
 #include "physics.h"
 #include "matrix4x4.h"
 #include "log.h"

+ 1 - 5
src/world/world.cpp

@@ -12,14 +12,11 @@
 #include "level_resource.h"
 #include "memory.h"
 #include "matrix4x4.h"
-#include "int_setting.h"
 #include <new>
 
 namespace crown
 {
 
-static IntSetting g_physics_debug("physics.debug", "Enable physics debug rendering.", 0, 0, 1);
-
 World::World(ResourceManager& rm, LuaEnvironment& env)
 	: _resource_manager(&rm)
 	, _lua_environment(&env)
@@ -156,8 +153,7 @@ void World::render(Camera* camera)
 	_render_world->update(camera->view_matrix(), camera->projection_matrix(), camera->_view_x, camera->_view_y,
 		camera->_view_width, camera->_view_height);
 
-	if (g_physics_debug == 1)
-		_physics_world->draw_debug(*_lines);
+	// _physics_world->draw_debug(*_lines);
 }
 
 CameraId World::create_camera(SceneGraph& sg, UnitId id, ProjectionType::Enum type, float near, float far)