mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-10 13:10:47 +00:00
update gui after control transfert to match an human side
This commit is contained in:
parent
cb6c4a9829
commit
fed2a7768e
@ -512,6 +512,29 @@ void play_controller::enter_textbox()
|
|||||||
menu_handler_.get_textbox().close(*gui_);
|
menu_handler_.get_textbox().close(*gui_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int play_controller::find_human_team_before(const size_t team_num) const
|
||||||
|
{
|
||||||
|
if (team_num > teams_.size())
|
||||||
|
return -2;
|
||||||
|
|
||||||
|
int human_side = -2;
|
||||||
|
for (int i = team_num-2; i > -1; --i) {
|
||||||
|
if (teams_[i].is_human()) {
|
||||||
|
human_side = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (human_side == -2) {
|
||||||
|
for (size_t i = teams_.size()-1; i > team_num-1; --i) {
|
||||||
|
if (teams_[i].is_human()) {
|
||||||
|
human_side = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return human_side+1;
|
||||||
|
}
|
||||||
|
|
||||||
void play_controller::handle_event(const SDL_Event& event)
|
void play_controller::handle_event(const SDL_Event& event)
|
||||||
{
|
{
|
||||||
if(gui::in_dialog()) {
|
if(gui::in_dialog()) {
|
||||||
|
@ -97,6 +97,8 @@ protected:
|
|||||||
team& current_team() { return teams_[player_number_-1]; }
|
team& current_team() { return teams_[player_number_-1]; }
|
||||||
const team& current_team() const { return teams_[player_number_-1]; }
|
const team& current_team() const { return teams_[player_number_-1]; }
|
||||||
|
|
||||||
|
int find_human_team_before(const size_t team) const;
|
||||||
|
|
||||||
//managers
|
//managers
|
||||||
const verification_manager verify_manager_;
|
const verification_manager verify_manager_;
|
||||||
teams_manager team_manager_;
|
teams_manager team_manager_;
|
||||||
|
@ -68,8 +68,21 @@ redo_turn:
|
|||||||
play_human_turn();
|
play_human_turn();
|
||||||
after_human_turn();
|
after_human_turn();
|
||||||
} catch(end_turn_exception& end_turn) {
|
} catch(end_turn_exception& end_turn) {
|
||||||
if (end_turn.redo == team_index)
|
if (end_turn.redo == team_index) {
|
||||||
player_type_changed_ = true;
|
player_type_changed_ = true;
|
||||||
|
// if new controller is not human,
|
||||||
|
// reset gui to prev human one
|
||||||
|
if (!teams_[team_index-1].is_human()) {
|
||||||
|
int t = find_human_team_before(team_index);
|
||||||
|
if (t) {
|
||||||
|
gui_->set_team(t-1);
|
||||||
|
gui_->recalculate_minimap();
|
||||||
|
gui_->invalidate_all();
|
||||||
|
gui_->draw();
|
||||||
|
gui_->update_display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LOG_NG << "human finished turn...\n";
|
LOG_NG << "human finished turn...\n";
|
||||||
} else if(current_team().is_ai()) {
|
} else if(current_team().is_ai()) {
|
||||||
|
@ -418,8 +418,21 @@ redo_turn:
|
|||||||
play_human_turn();
|
play_human_turn();
|
||||||
after_human_turn();
|
after_human_turn();
|
||||||
} catch(end_turn_exception& end_turn) {
|
} catch(end_turn_exception& end_turn) {
|
||||||
if (end_turn.redo == team_index)
|
if (end_turn.redo == team_index) {
|
||||||
player_type_changed_ = true;
|
player_type_changed_ = true;
|
||||||
|
// if new controller is not human,
|
||||||
|
// reset gui to prev human one
|
||||||
|
if (!teams_[team_index-1].is_human()) {
|
||||||
|
int t = find_human_team_before(team_index);
|
||||||
|
if (t) {
|
||||||
|
gui_->set_team(t-1);
|
||||||
|
gui_->recalculate_minimap();
|
||||||
|
gui_->invalidate_all();
|
||||||
|
gui_->draw();
|
||||||
|
gui_->update_display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(game_config::debug)
|
if(game_config::debug)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user