void playsingle_controller::init_gui(){
	LOG_NG << "Initializing GUI... " << (SDL_GetTicks() - ticks()) << "\n";
	play_controller::init_gui();

	// Scroll to the starting position of the first team. If there is a
	// human team, use that team; otherwise use team 1. If the map defines
	// a starting position for the selected team, scroll to that tile. Note
	// this often does not matter since many scenario start with messages,
	// which will usually scroll to the speaker. Also note that the map
	// does not necessarily define the starting positions. While usually
	// best to use the map, the scenarion may explicitly set the positions,
	// overriding those found in the map (if any).
	{
		int scroll_team = gamestate().first_human_team_ + 1;
		if (scroll_team == 0) {
			scroll_team = 1;
		}
		map_location loc(gamestate().board_.map().starting_position(scroll_team));
		if ((loc.x >= 0) && (loc.y >= 0)) {
			gui_->scroll_to_tile(loc, game_display::WARP);
		}
	}

	update_locker lock_display(gui_->video(), is_skipping_replay());
	gui_->draw();
	get_hotkey_command_executor()->set_button_state();
	events::raise_draw_event();
}
Beispiel #2
0
void play_controller::init_side_end()
{
    const time_of_day& tod = gamestate().tod_manager_.get_time_of_day();

    if (current_side() == 1 || !init_side_done_now_)
        sound::play_sound(tod.sounds, sound::SOUND_SOURCES);

    if (!is_skipping_replay()) {
        gui_->invalidate_all();
    }

    if (!is_skipping_replay() && current_team().get_scroll_to_leader()) {
        gui_->scroll_to_leader(current_side(), game_display::ONSCREEN,false);
    }
    whiteboard_manager_->on_init_side();
}
void playsingle_controller::init_gui(){
	LOG_NG << "Initializing GUI... " << (SDL_GetTicks() - ticks()) << "\n";
	play_controller::init_gui();

	if(gamestate().first_human_team_ != -1) {
		gui_->scroll_to_tile(gamestate().board_.map().starting_position(gamestate().first_human_team_ + 1), game_display::WARP);
	}
	gui_->scroll_to_tile(gamestate().board_.map().starting_position(1), game_display::WARP);

	update_locker lock_display(gui_->video(), is_skipping_replay());
	gui_->draw();
	get_hotkey_command_executor()->set_button_state();
	events::raise_draw_event();
}
Beispiel #4
0
void play_controller::start_game()
{
    fire_preload();

    if(!gamestate().start_event_fired_)
    {
        gamestate().start_event_fired_ = true;
        resources::recorder->add_start_if_not_there_yet();
        resources::recorder->get_next_action();

        set_scontext_synced sync;

        fire_prestart();
        if (is_regular_game_end()) {
            return;
        }

        for ( int side = gamestate().board_.teams().size(); side != 0; --side )
            actions::clear_shroud(side, false, false);

        init_gui();
        LOG_NG << "first_time..." << (is_skipping_replay() ? "skipping" : "no skip") << "\n";

        events::raise_draw_event();
        fire_start();
        if (is_regular_game_end()) {
            return;
        }
        sync.do_final_checkup();
        gui_->recalculate_minimap();
        // Initialize countdown clock.
        for (const team& t : gamestate().board_.teams())
        {
            if (saved_game_.mp_settings().mp_countdown) {
                t.set_countdown_time(1000 * saved_game_.mp_settings().mp_countdown_init_time);
            }
        }
    }
    else
    {
        init_gui();
        events::raise_draw_event();
        gamestate().gamedata_.set_phase(game_data::PLAY);
        gui_->recalculate_minimap();
    }
}
Beispiel #5
0
void play_controller::do_init_side()
{
    set_scontext_synced sync;
    log_scope("player turn");
    // In case we might end up calling sync:network during the side turn events,
    // and we don't want do_init_side to be called when a player drops.
    gamestate_->init_side_done() = true;
    init_side_done_now_ = true;

    const std::string turn_num = std::to_string(turn());
    const std::string side_num = std::to_string(current_side());

    gamestate().gamedata_.get_variable("side_number") = current_side();

    // We might have skipped some sides because they were empty so it is not enough to check for side_num==1
    if(!gamestate().tod_manager_.has_turn_event_fired())
    {
        pump().fire("turn_" + turn_num);
        pump().fire("new_turn");
        gamestate().tod_manager_.turn_event_fired();
    }

    pump().fire("side_turn");
    pump().fire("side_" + side_num + "_turn");
    pump().fire("side_turn_" + turn_num);
    pump().fire("side_" + side_num + "_turn_" + turn_num);

    // We want to work out if units for this player should get healed,
    // and the player should get income now.
    // Healing/income happen if it's not the first turn of processing,
    // or if we are loading a game.
    if (turn() > 1) {
        gamestate().board_.new_turn(current_side());
        current_team().new_turn();

        // If the expense is less than the number of villages owned
        // times the village support capacity,
        // then we don't have to pay anything at all
        int expense = gamestate().board_.side_upkeep(current_side()) -
                      current_team().support();
        if(expense > 0) {
            current_team().spend_gold(expense);
        }

        calculate_healing(current_side(), !is_skipping_replay());
    }

    // Prepare the undo stack.
    undo_stack().new_side_turn(current_side());

    pump().fire("turn_refresh");
    pump().fire("side_" + side_num + "_turn_refresh");
    pump().fire("turn_" + turn_num + "_refresh");
    pump().fire("side_" + side_num + "_turn_" + turn_num + "_refresh");

    // Make sure vision is accurate.
    actions::clear_shroud(current_side(), true);
    init_side_end();
    check_victory();
    sync.do_final_checkup();
}