/** * \brief Calls sol.main.on_draw() if it exists. * \param dst_surface The destination surface. */ void LuaContext::main_on_draw(Surface& dst_surface) { push_main(l); on_draw(dst_surface); menus_on_draw(-1, dst_surface); lua_pop(l, 1); }
/** * @brief Calls the on_draw() method of a Lua game. * @param game A game. * @param dst_surface The destination surface. */ void LuaContext::game_on_draw(Game& game, Surface& dst_surface) { push_game(l, game.get_savegame()); menus_on_draw(-1, dst_surface); on_draw(dst_surface); lua_pop(l, 1); }
/** * \brief Calls the on_draw() method of a Lua menu. * \param menu_ref A reference to the menu object. * \param dst_surface The destination surface. */ void LuaContext::menu_on_draw( const ScopedLuaRef& menu_ref, const SurfacePtr& dst_surface ) { push_ref(l, menu_ref); on_draw(dst_surface); menus_on_draw(-1, dst_surface); // Draw children menus if any. lua_pop(l, 1); }
/** * \brief Calls the on_draw() method of a Lua game if it is defined. * * Also calls the method on its menus. * * \param game A game. * \param dst_surface The destination surface. */ void LuaContext::game_on_draw(Game& game, Surface& dst_surface) { if (!game.get_savegame().is_known_to_lua()) { return; } push_game(l, game.get_savegame()); if (userdata_has_field(game.get_savegame(), "on_draw")) { on_draw(dst_surface); } menus_on_draw(-1, dst_surface); lua_pop(l, 1); }