24#define LOG_LUA LOG_STREAM(info, log_scripting_lua)
25#define ERR_LUA LOG_STREAM(err, log_scripting_lua)
44 lua_createtable(L, 0, 4);
55 c->color_range::~color_range();
66 const bool equal = left == right;
67 lua_pushboolean(L, equal);
90 std::string color_id = luaL_checkstring(L, 2);
98 char const *m = luaL_checkstring(L, 2);
100 if(strcmp(m,
"min") == 0) {
103 if(strcmp(m,
"max") == 0) {
106 if(strcmp(m,
"mid") == 0) {
109 if(strcmp(m,
"minimap") == 0) {
112 if(strcmp(m,
"font_color") == 0) {
116 if(strcmp(m,
"pango_color") == 0) {
117 lua_push(L,
c.font_color().to_hex_string());
125 static const std::vector<std::string> keys{
"min",
"max",
"mid",
"minimap",
"font_color",
"pango_color"};
132 return luaL_argerror(L, 2,
"color objects canot be modified");
137 std::vector<std::string> all_colours;
139 if(std::all_of(key.begin(), key.end(), [](
char c) {return utils::portable_isdigit(c);})) {
143 all_colours.push_back(key);
152 std::ostringstream cmd_out;
155 cmd_out <<
"Adding color metatable...\n";
159 lua_setfield(L, -2,
"__gc");
161 lua_setfield(L, -2,
"__eq");
163 lua_setfield(L, -2,
"__tostring");
165 lua_setfield(L, -2,
"__index");
167 lua_setfield(L, -2,
"__newindex");
169 lua_setfield(L, -2,
"__dir");
170 lua_pushstring(L,
"color range");
171 lua_setfield(L, -2,
"__metatable");
175 cmd_out <<
"Adding wesnoth.colors table...\n";
177 lua_getglobal(L,
"wesnoth");
178 lua_newuserdatauv(L, 0, 0);
179 lua_createtable(L, 0, 2);
181 lua_setfield(L, -2,
"__index");
183 lua_setfield(L, -2,
"__dir");
184 lua_pushstring(L,
"colors table");
185 lua_setfield(L, -2,
"__metatable");
186 lua_pushboolean(L,
true);
187 lua_setfield(L, -2,
"__dir_tablelike");
188 lua_setmetatable(L, -2);
189 lua_setfield(L, -2,
"colors");
192 return cmd_out.str();
Representing the "team color" information, this C++ class contains a subset of WML's [color_range] ta...
Standard logging facilities (interface).
static color_range * luaW_pushcolor(lua_State *L, const color_range &color)
static int impl_color_set(lua_State *L)
static int impl_color_tostring(lua_State *L)
Turns a lua color to string.
static lg::log_domain log_scripting_lua("scripting/lua")
static int impl_color_equality(lua_State *L)
Checks two color units for equality.
static int luaW_pushsinglecolor(lua_State *L, const color_t &color)
static color_range & LuaW_checkcolor(lua_State *L, int index)
static int impl_color_get(lua_State *L)
static int impl_color_dir(lua_State *L)
static int impl_colors_table_dir(lua_State *L)
static int impl_get_color(lua_State *L)
static const char colorKey[]
static int impl_color_collect(lua_State *L)
std::map< std::string, color_range, std::less<> > team_rgb_range
Colors defined by WML [color_range] tags.
const color_range & color_info(std::string_view name)
std::string register_metatables(lua_State *L)
void lua_push(lua_State *L, const T &val)
void luaW_table_set(lua_State *L, int index, std::string_view k, const T &value)
std::unique_ptr< MIX_Audio, decltype(&MIX_DestroyAudio)> value
The basic class for representing 8-bit RGB or RGBA colour values.