/** * \brief Implementation of text_surface:get_rendering_mode(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_get_rendering_mode(lua_State* l) { TextSurface& text_surface = check_text_surface(l, 1); TextSurface::RenderingMode mode = text_surface.get_rendering_mode(); push_string(l, rendering_mode_names[mode]); return 1; }
/** * \brief Implementation of text_surface:get_vertical_alignment(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_get_vertical_alignment(lua_State* l) { TextSurface& text_surface = check_text_surface(l, 1); TextSurface::VerticalAlignment alignment = text_surface.get_vertical_alignment(); push_string(l, vertical_alignment_names[alignment]); return 1; }
/** * \brief Implementation of text_surface:get_color(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_get_color(lua_State* l) { TextSurface& text_surface = check_text_surface(l, 1); const Color& color = text_surface.get_text_color(); push_color(l, color); return 1; }
/** * \brief Implementation of text_surface:set_color(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_color(lua_State* l) { TextSurface& text_surface = check_text_surface(l, 1); const Color& color = LuaTools::check_color(l, 2); text_surface.set_text_color(color); return 0; }
/** * \brief Implementation of text_surface:get_text(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_get_text(lua_State* l) { TextSurface& text_surface = check_text_surface(l, 1); const std::string& text = text_surface.get_text(); push_string(l, text); return 1; }
/** * \brief Implementation of text_surface:get_font_size(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_get_font_size(lua_State* l) { return LuaTools::exception_boundary_handle(l, [&] { const TextSurface& text_surface = *check_text_surface(l, 1); lua_pushinteger(l, text_surface.get_font_size()); return 1; }); }
/** * \brief Implementation of text_surface:get_size(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_get_size(lua_State* l) { TextSurface& text_surface = check_text_surface(l, 1); lua_pushinteger(l, text_surface.get_width()); lua_pushinteger(l, text_surface.get_height()); return 2; }
/** * \brief Implementation of text_surface:set_vertical_alignment(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_vertical_alignment(lua_State* l) { TextSurface& text_surface = check_text_surface(l, 1); TextSurface::VerticalAlignment alignment = check_enum<TextSurface::VerticalAlignment>( l, 1, vertical_alignment_names); text_surface.set_vertical_alignment(alignment); return 0; }
/** * \brief Implementation of text_surface:set_rendering_mode(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_rendering_mode(lua_State* l) { TextSurface& text_surface = check_text_surface(l, 1); TextSurface::RenderingMode mode = LuaTools::check_enum<TextSurface::RenderingMode>( l, 1, rendering_mode_names); text_surface.set_rendering_mode(mode); return 0; }
/** * \brief Implementation of text_surface:set_font_size(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_font_size(lua_State* l) { return LuaTools::exception_boundary_handle(l, [&] { TextSurface& text_surface = *check_text_surface(l, 1); int font_size = LuaTools::check_int(l, 2); text_surface.set_font_size(font_size); return 0; }); }
/** * \brief Implementation of text_surface:get_rendering_mode(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_get_rendering_mode(lua_State* l) { return LuaTools::exception_boundary_handle(l, [&] { const TextSurface& text_surface = *check_text_surface(l, 1); TextSurface::RenderingMode mode = text_surface.get_rendering_mode(); push_string(l, rendering_mode_names.find(mode)->second); return 1; }); }
/** * \brief Implementation of text_surface:get_text(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_get_text(lua_State* l) { return LuaTools::exception_boundary_handle(l, [&] { const TextSurface& text_surface = *check_text_surface(l, 1); const std::string& text = text_surface.get_text(); push_string(l, text); return 1; }); }
/** * \brief Implementation of text_surface:set_text(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_text(lua_State* l) { TextSurface& text_surface = check_text_surface(l, 1); std::string text; if (lua_gettop(l) >= 2 && !lua_isnil(l, 2)) { text = luaL_checkstring(l, 2); } text_surface.set_text(text); return 0; }
/** * \brief Implementation of text_surface:get_color(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_get_color(lua_State* l) { return LuaTools::exception_boundary_handle(l, [&] { const TextSurface& text_surface = *check_text_surface(l, 1); const Color& color = text_surface.get_text_color(); push_color(l, color); return 1; }); }
/** * \brief Implementation of text_surface:get_vertical_alignment(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_get_vertical_alignment(lua_State* l) { return LuaTools::exception_boundary_handle(l, [&] { const TextSurface& text_surface = *check_text_surface(l, 1); TextSurface::VerticalAlignment alignment = text_surface.get_vertical_alignment(); push_string(l, vertical_alignment_names.find(alignment)->second); return 1; }); }
/** * \brief Implementation of text_surface:set_color(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_color(lua_State* l) { return LuaTools::exception_boundary_handle(l, [&] { TextSurface& text_surface = *check_text_surface(l, 1); const Color& color = LuaTools::check_color(l, 2); text_surface.set_text_color(color); return 0; }); }
/** * \brief Implementation of text_surface:set_horizontal_alignment(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_horizontal_alignment(lua_State* l) { TextSurface& text_surface = check_text_surface(l, 1); TextSurface::HorizontalAlignment alignment = LuaTools::check_enum<TextSurface::HorizontalAlignment>( l, 1, horizontal_alignment_names); text_surface.set_horizontal_alignment(alignment); return 0; }
/** * \brief Implementation of text_surface:set_rendering_mode(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_rendering_mode(lua_State* l) { return LuaTools::exception_boundary_handle(l, [&] { TextSurface& text_surface = *check_text_surface(l, 1); TextSurface::RenderingMode mode = LuaTools::check_enum<TextSurface::RenderingMode>( l, 2, rendering_mode_names); text_surface.set_rendering_mode(mode); return 0; }); }
/** * \brief Implementation of text_surface:set_text(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_font(lua_State* l) { TextSurface& text_surface = check_text_surface(l, 1); const std::string& font_id = luaL_checkstring(l, 2); if (!TextSurface::has_font(font_id)) { LuaTools::arg_error(l, 2, std::string("No such font: '") + font_id + "'"); } text_surface.set_font(font_id); return 0; }
/** * \brief Implementation of text_surface:set_vertical_alignment(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_vertical_alignment(lua_State* l) { return LuaTools::exception_boundary_handle(l, [&] { TextSurface& text_surface = *check_text_surface(l, 1); TextSurface::VerticalAlignment alignment = LuaTools::check_enum<TextSurface::VerticalAlignment>( l, 2, vertical_alignment_names); text_surface.set_vertical_alignment(alignment); return 0; }); }
/** * \brief Implementation of text_surface:set_text(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_text(lua_State* l) { return LuaTools::exception_boundary_handle(l, [&] { TextSurface& text_surface = *check_text_surface(l, 1); std::string text; if (lua_gettop(l) >= 2 && !lua_isnil(l, 2)) { text = LuaTools::check_string(l, 2); } text_surface.set_text(text); return 0; }); }
/** * \brief Implementation of text_surface:set_text(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_font(lua_State* l) { TextSurface& text_surface = check_text_surface(l, 1); const std::string& font_id = luaL_checkstring(l, 2); if (!TextSurface::has_font(font_id)) { arg_error(l, 2, StringConcat() << "No such font: '" << font_id << "'"); } text_surface.set_font(font_id); return 0; }
/** * \brief Implementation of text_surface:set_text(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_font(lua_State* l) { return LuaTools::exception_boundary_handle(l, [&] { TextSurface& text_surface = *check_text_surface(l, 1); const std::string& font_id = LuaTools::check_string(l, 2); if (!FontResource::exists(font_id)) { LuaTools::arg_error(l, 2, std::string("No such font: '") + font_id + "'"); } text_surface.set_font(font_id); return 0; }); }
/** * \brief Implementation of text_surface:set_text_key(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_text_key(lua_State* l) { TextSurface& text_surface = check_text_surface(l, 1); const std::string& key = luaL_checkstring(l, 2); if (!StringResource::exists(key)) { arg_error(l, 2, StringConcat() << "No value with key '" << key << "' in strings.dat for language '" << FileTools::get_language() << "'"); } text_surface.set_text(StringResource::get_string(key)); return 0; }
/** * \brief Implementation of text_surface:set_text_key(). * \param l the Lua context that is calling this function * \return number of values to return to Lua */ int LuaContext::text_surface_api_set_text_key(lua_State* l) { return LuaTools::exception_boundary_handle(l, [&] { TextSurface& text_surface = *check_text_surface(l, 1); const std::string& key = LuaTools::check_string(l, 2); if (!CurrentQuest::string_exists(key)) { LuaTools::arg_error(l, 2, std::string("No value with key '") + key + "' in strings.dat for language '" + CurrentQuest::get_language() + "'" ); } text_surface.set_text(CurrentQuest::get_string(key)); return 0; }); }