Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wait dialog for user choices during prestart events
gna.org/bugs/?23297 If we are waiting for a synced user choice during a prestart events we now show a gui2 dialog that informs the player about why the client is waiting and also offers the player the option to quit the game.
- Loading branch information
Showing
7 changed files
with
290 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
#textdomain wesnoth-lib | ||
### | ||
### Definition of the window to ask for the savegame filename | ||
### | ||
|
||
[window] | ||
id = "synced_choice_wait" | ||
description = "Waiting dialogs while other players execute local choices." | ||
|
||
[resolution] | ||
definition = "default" | ||
|
||
automatic_placement = "true" | ||
vertical_placement = "center" | ||
horizontal_placement = "center" | ||
|
||
[tooltip] | ||
id = "tooltip_large" | ||
[/tooltip] | ||
|
||
[helptip] | ||
id = "tooltip_large" | ||
[/helptip] | ||
|
||
[grid] | ||
|
||
[row] | ||
grow_factor = 0 | ||
|
||
[column] | ||
grow_factor = 1 | ||
|
||
border = "all" | ||
border_size = 5 | ||
horizontal_alignment = "left" | ||
[label] | ||
id = "lblTitle" | ||
definition = "title" | ||
|
||
label = _ "Waiting..." | ||
[/label] | ||
|
||
[/column] | ||
|
||
[/row] | ||
|
||
[row] | ||
grow_factor = 0 | ||
|
||
[column] | ||
grow_factor = 1 | ||
|
||
border = "all" | ||
border_size = 5 | ||
horizontal_alignment = "left" | ||
[label] | ||
id = "lblMessage" | ||
definition = "default" | ||
|
||
label = _ "Waiting for remote input" | ||
[/label] | ||
|
||
[/column] | ||
|
||
[/row] | ||
|
||
[row] | ||
grow_factor = 0 | ||
|
||
[column] | ||
grow_factor = 1 | ||
horizontal_grow = "true" | ||
|
||
[grid] | ||
|
||
[row] | ||
grow_factor = 0 | ||
|
||
[column] | ||
|
||
[spacer] | ||
definition = "default" | ||
[/spacer] | ||
|
||
[/column] | ||
|
||
[column] | ||
border = "all" | ||
border_size = 5 | ||
horizontal_alignment = "right" | ||
|
||
[button] | ||
id = "btn_quit_game" | ||
definition = "default" | ||
|
||
size_text = _ "Quit game" | ||
label = _ "Quit game" | ||
[/button] | ||
|
||
[/column] | ||
|
||
[/row] | ||
|
||
[/grid] | ||
|
||
[/column] | ||
|
||
[/row] | ||
|
||
[/grid] | ||
|
||
[/resolution] | ||
|
||
[/window] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
Copyright (C) 2014 - 2015 by Ignacio Riquelme Morelle <shadowm2006@gmail.com> | ||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/ | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY. | ||
See the COPYING file for more details. | ||
*/ | ||
|
||
#include "gui/dialogs/synced_choice_wait.hpp" | ||
|
||
#include "gui/auxiliary/find_widget.tpp" | ||
#include "gui/widgets/label.hpp" | ||
#include "gui/widgets/button.hpp" | ||
#include "gui/widgets/settings.hpp" | ||
#include "gui/widgets/window.hpp" | ||
|
||
|
||
#include "message.hpp" | ||
#include "../../game_end_exceptions.hpp" | ||
#include "../../gettext.hpp" | ||
#include "../../resources.hpp" | ||
#include "../../game_display.hpp" | ||
|
||
|
||
#include <boost/bind.hpp> | ||
|
||
namespace gui2 | ||
{ | ||
|
||
/*WIKI | ||
* @page = GUIWindowDefinitionWML | ||
* @order = 2_theme_list | ||
* | ||
* == Theme list == | ||
* | ||
* Dialog for selecting a GUI theme. | ||
* | ||
* @begin{table}{dialog_widgets} | ||
* | ||
* themes & & listbox & m & | ||
* Listbox displaying user choices. $ | ||
* | ||
* -name & & control & m & | ||
* Widget which shows a theme item name. $ | ||
* | ||
* -description & & control & m & | ||
* Widget which shows a theme item description. $ | ||
* | ||
* @end{table} | ||
*/ | ||
|
||
REGISTER_DIALOG(synced_choice_wait) | ||
|
||
tsynced_choice_wait::tsynced_choice_wait(user_choice_manager& mgr) | ||
: mgr_(mgr) | ||
, message_() | ||
{ | ||
mgr_.changed_event_.attach_handler(this); | ||
} | ||
|
||
tsynced_choice_wait::~tsynced_choice_wait() | ||
{ | ||
mgr_.changed_event_.detach_handler(this); | ||
} | ||
|
||
void tsynced_choice_wait::pre_show(CVideo& /*video*/, twindow& window) | ||
{ | ||
window_ = &window; | ||
message_ = find_widget<tlabel>(&window, "lblMessage", false, true); | ||
|
||
|
||
tbutton& quit_button = find_widget<tbutton>( | ||
&window, "btn_quit_game", false); | ||
|
||
connect_signal_mouse_left_click( | ||
quit_button, | ||
boost::bind(&tsynced_choice_wait::on_btn_quit_game, this) | ||
); | ||
|
||
message_->set_label(mgr_.wait_message()); | ||
if(mgr_.finished() || !mgr_.waiting()) { | ||
window_->close(); | ||
} | ||
} | ||
|
||
void tsynced_choice_wait::handle_generic_event(const std::string& event_name) | ||
{ | ||
assert(event_name == "user_choice_update"); | ||
assert(message_); | ||
message_->set_label(mgr_.wait_message()); | ||
if(mgr_.finished() || !mgr_.waiting()) { | ||
window_->close(); | ||
} | ||
} | ||
|
||
void tsynced_choice_wait::on_btn_quit_game() | ||
{ | ||
const int res = gui2::show_message(resources::screen->video(), _("Quit"), | ||
_("Do you really want to quit?"), gui2::tmessage::yes_no_buttons); | ||
if (res != gui2::twindow::CANCEL) { | ||
throw_quit_game_exception(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
Copyright (C) 2014 - 2015 by Ignacio Riquelme Morelle <shadowm2006@gmail.com> | ||
Part of the Battle for Wesnoth Project http://www.wesnoth.org/ | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY. | ||
See the COPYING file for more details. | ||
*/ | ||
|
||
#ifndef GUI_DIALOGS_THEME_LIST_HPP_INCLUDED | ||
#define GUI_DIALOGS_THEME_LIST_HPP_INCLUDED | ||
|
||
#include "gui/dialogs/dialog.hpp" | ||
#include "../../synced_user_choice.hpp" | ||
#include "../../generic_event.hpp" | ||
namespace gui2 | ||
{ | ||
class tlabel; | ||
class twindow; | ||
class tsynced_choice_wait : public tdialog, public events::observer | ||
{ | ||
public: | ||
explicit tsynced_choice_wait(user_choice_manager& mgr); | ||
~tsynced_choice_wait(); | ||
private: | ||
user_choice_manager& mgr_; | ||
tlabel* message_; | ||
twindow* window_; | ||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */ | ||
virtual const std::string& window_id() const; | ||
|
||
/** Inherited from tdialog. */ | ||
void pre_show(CVideo& video, twindow& window); | ||
|
||
virtual void handle_generic_event(const std::string& event_name); | ||
void on_btn_quit_game(); | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters