예제 #1
0
파일: MainAPI.cpp 프로젝트: Arvek/SOLARME
/**
 * \brief Calls sol.main.on_update() if it exists.
 *
 * This function is called at each cycle by the main loop.
 */
void LuaContext::main_on_update() {

  push_main(l);
  on_update();
  menus_on_update(-1);
  lua_pop(l, 1);
}
예제 #2
0
/**
 * \brief Calls the on_update() method of a Lua menu.
 * \param menu_ref A reference to the menu object.
 */
void LuaContext::menu_on_update(const ScopedLuaRef& menu_ref) {

  push_ref(l, menu_ref);
  on_update();
  menus_on_update(-1);  // Update children menus if any.
  lua_pop(l, 1);
}
예제 #3
0
/**
 * @brief Calls the on_update() method of a Lua game.
 * @param game A game.
 */
void LuaContext::game_on_update(Game& game) {

  push_game(l, game.get_savegame());
  on_update();
  menus_on_update(-1);
  lua_pop(l, 1);
}
예제 #4
0
/**
 * \brief Calls the on_update() method of a Lua game if it is defined.
 *
 * Also calls the method on its menus.
 *
 * \param game A game.
 */
void LuaContext::game_on_update(Game& game) {

  if (!game.get_savegame().is_known_to_lua()) {
    return;
  }

  push_game(l, game.get_savegame());
  // This particular method is tried so often that we want to save optimize
  // the std::string construction.
  static const std::string method_name = "on_update";
  if (userdata_has_field(game.get_savegame(), method_name)) {
    on_update();
  }
  menus_on_update(-1);
  lua_pop(l, 1);
}