void playsingle_controller::before_human_turn(bool save) { browse_ = false; linger_ = false; gui_->refresh_access_troops(player_number_ - 1); gui_->refresh_access_heros(player_number_ - 1); ai::manager::raise_turn_started(); if (save) { // uint32_t start = SDL_GetTicks(); config snapshot; to_config(snapshot); // uint32_t mid1 = SDL_GetTicks(); // posix_print("(mid1)used time: %u ms\n", mid1 - start); savegame::autosave_savegame save(heros_, heros_start_, gamestate_, *gui_, snapshot); // uint32_t mid2 = SDL_GetTicks(); // posix_print("(mid2)used time: %u ms\n", mid2 - mid1); save.autosave(game_config::disable_autosave, preferences::autosavemax(), preferences::INFINITE_AUTO_SAVES); // uint32_t mid3 = SDL_GetTicks(); // posix_print("(mid3)used time: %u ms\n", mid3 - mid2); } else { teams_[player_number_ - 1].refresh_tactic_slots(*gui_); } if (preferences::turn_bell()) { sound::play_bell(game_config::sounds::turn_bell); } // button: undo undo_stack_.clear(); if (teams_[player_number_-1].uses_shroud() || teams_[player_number_-1].uses_fog()) { gui_->hide_menu("undo", true); } else { gui_->hide_menu("undo", false); gui_->enable_menu("undo", false); } // button: endturn gui_->enable_menu("play_card", true); gui_->enable_menu("endturn", true); /* if (rpg::stratum == hero_stratum_leader) { if (card_mode_) { execute_card_uh(turn(), player_number_); } execute_guard_attack(player_number_); } */ // card refresh_card_button(current_team(), *gui_); // if (!network::nconnections()) { // show_context_menu(NULL, *gui_); // } else { // Multiplayer mod, there is context-button when network player playing. // In order to display correct, need hide "before" button. gui_->goto_main_context_menu(); // } }
void playsingle_controller::execute_card_bh(size_t turn, int team_index) { team& current_team = teams_[team_index - 1]; int sum = game_config::cards_per_turn + ((turn == 1 && team_index == 1)? 1: 0); for (int index = 0; index < sum; index ++) { if (!current_team.add_card(CARDS_INVALID_NUMBER)) break; } if (current_team.is_human()) { // card refresh_card_button(current_team, *gui_); } }
void playsingle_controller::before_human_turn(bool save) { team& t = current_team(); if (pause_when_human_) { browse_ = false; } linger_ = false; if (gui_->access_is_null(game_display::taccess_list::TROOP)) { // change resolution will result to enter it. gui_->refresh_access_troops(player_number_ - 1, game_display::REFRESH_RELOAD); } if (!tent::tower_mode() && !preferences::developer()) { gui_->refresh_access_troops(player_number_ - 1, game_display::REFRESH_HIDE, NULL); } gui_->refresh_access_heros(player_number_ - 1, game_display::REFRESH_RELOAD); ai::manager::raise_turn_started(); if (tent::mode != mode_tag::LAYOUT && save) { autosave_ticks_ = unit_map::main_ticks; config snapshot; to_config(snapshot); savegame::autosave_savegame save(heros_, heros_start_, gamestate_, *gui_, snapshot); save.autosave(game_config::disable_autosave, preferences::autosavemax(), preferences::INFINITE_AUTO_SAVES); if (tent::turn_based) { const std::vector<hero*>& last_active_tactic = t.last_active_tactic(); for (std::vector<hero*>::const_iterator it = last_active_tactic.begin(); it != last_active_tactic.end(); ++ it) { hero& selected_hero = **it; unit* tactician = units_.find_unit(selected_hero); if (tactician && !tactician->is_resided()) { do_add_active_tactic(*tactician, selected_hero, true); } } } // autosave ticks changed, refresh top panel. gui_->invalidate_game_status(); } else { teams_[player_number_ - 1].refresh_tactic_slots(*gui_); } if (unit::actor && unit::actor->is_city()) { if (preferences::turn_bell()) { sound::play_bell(game_config::sounds::turn_bell); } if (game_config::show_side_report) { gui2::tside_report dlg(*gui_, teams_, units_, heros_, unit::actor->side()); dlg.show(gui_->video()); } } // button: undo undo_stack_.clear(); if (teams_[player_number_-1].uses_shroud() || teams_[player_number_-1].uses_fog()) { gui_->set_theme_object_visible("undo", gui2::twidget::INVISIBLE); } else { gui_->set_theme_object_visible("undo", gui2::twidget::VISIBLE); gui_->set_theme_object_active("undo", false); } // button: endturn if (tent::mode == mode_tag::SIEGE) { if (pause_when_human_) { refresh_endturn_button(*gui_, "buttons/ctrl-play.png"); gui_->set_theme_object_active("endturn", true); } } else if (tent::mode != mode_tag::LAYOUT) { gui_->set_theme_object_active("card", true); gui_->set_theme_object_active("endturn", true); } else { gui_->set_theme_object_visible("card", gui2::twidget::INVISIBLE); gui_->set_theme_object_visible("endturn", gui2::twidget::INVISIBLE); } // card refresh_card_button(t, *gui_); // if (!network::nconnections()) { // gui_->show_context_menu(); // } else { // Multiplayer mod, there is context-button when network player playing. // In order to display correct, need hide "before" button. gui_->goto_main_context_menu(); // } }