Author: esr
Date: Mon Jul 2 18:45:51 2007
New Revision: 18615
URL: http://svn.gna.org/viewcvs/wesnoth?rev=18615&view=rev
Log:
Convert show_dialog() calls to basic_dialog object invocations.
Modified:
trunk/src/basic_dialog.hpp
trunk/src/dialogs.cpp
trunk/src/game.cpp
trunk/src/menu_events.cpp
trunk/src/multiplayer.cpp
trunk/src/multiplayer_connect.cpp
trunk/src/multiplayer_wait.cpp
trunk/src/play_controller.cpp
trunk/src/preferences_display.cpp
trunk/src/show_dialog.cpp
Modified: trunk/src/basic_dialog.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/basic_dialog.hpp?rev=18615&r1=18614&r2=18615&view=diff
==============================================================================
--- trunk/src/basic_dialog.hpp (original)
+++ trunk/src/basic_dialog.hpp Mon Jul 2 18:45:51 2007
@@ -196,6 +196,8 @@
//add_pane - preview panes are not currently memory managed (for
backwards compat)
void add_pane(preview_pane *const pp) { preview_panes_.push_back(pp); }
+ void set_panes(std::vector<preview_pane*> panes) { preview_panes_ =
panes; }
+
void set_textbox(dialog_textbox *const box) {
delete text_widget_;
text_widget_ = box;
Modified: trunk/src/dialogs.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/dialogs.cpp?rev=18615&r1=18614&r2=18615&view=diff
==============================================================================
--- trunk/src/dialogs.cpp (original)
+++ trunk/src/dialogs.cpp Mon Jul 2 18:45:51 2007
@@ -118,10 +118,7 @@
_("What should our victorious unit
become?"),
gui::OK_ONLY);
advances.set_menu(lang_options);
- std::vector<gui::preview_pane*>::const_iterator itor;
- for(itor = preview_panes.begin(); itor != preview_panes.end();
++itor)
-
- advances.add_pane(*itor);
+ advances.set_panes(preview_panes);
res = advances.show();
}
@@ -260,8 +257,8 @@
}
*fname = d.textbox_text();
if (res == 0 && save_game_exists(*fname)) {
- overwrite = gui::show_dialog(disp,NULL,_("Overwrite?"),
- _("Save already exists. Do you want to
overwrite it ?"),gui::YES_NO);
+ overwrite = gui::basic_dialog(disp,_("Overwrite?"),
+ _("Save already exists. Do you want to
overwrite it ?"),gui::YES_NO).show();
} else {
overwrite = 0;
}
@@ -551,11 +548,10 @@
std::vector<save_info> games = get_saves_list();
if(games.empty()) {
- gui::show_dialog(disp,NULL,
+ gui::basic_dialog(disp,
_("No Saved Games"),
- _("There are no saved games to
load.\n\
-(Games are saved automatically when you complete a scenario)"),
- gui::OK_ONLY);
+ _("There are no saved games to load.\n\(Games
are saved automatically when you complete a scenario)"),
+ gui::OK_ONLY).show();
return "";
}
Modified: trunk/src/game.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=18615&r1=18614&r2=18615&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Mon Jul 2 18:45:51 2007
@@ -692,13 +692,13 @@
if(state_.version != game_config::version) {
if(state_.version < game_config::min_savegame_version) {
- gui::show_dialog(disp(), NULL, "", _("This save
is from a version too old to be loaded."), gui::OK_ONLY);
+ gui::message_dialog(disp(), "", _("This save is
from a version too old to be loaded.")).show();
return false;
}
- const int res = gui::show_dialog(disp(),NULL,"",
+ const int res = gui::basic_dialog(disp(),"",
_("This save is from a different
version of the game. Do you want to try to load it?"),
- gui::YES_NO);
+ gui::YES_NO).show();
if(res == 1) {
return false;
}
@@ -829,10 +829,11 @@
std::copy(difficulties.begin(),difficulties.end(),difficulty_options.begin());
}
- const int res = gui::show_dialog(disp(),NULL,_("Difficulty"),
+ gui::basic_dialog dmenu(disp(),_("Difficulty"),
_("Select difficulty level:"),
- gui::OK_CANCEL,&difficulty_options);
- if(res == -1) {
+ gui::OK_CANCEL);
+ dmenu.set_menu(difficulty_options);
+ if(dmenu.show() == -1) {
return false;
}
@@ -958,12 +959,11 @@
"Are you sure you want to remove the
add-on \'"
+ addons.at(index)
+ "?\'";
- res = gui::show_dialog(
+ res = gui::basic_dialog(
disp(),
- NULL,
_("Confirm"),
confirm_message,
- gui::YES_NO);
+ gui::YES_NO).show();
} while (res != 0);
bool delete_success = true;
@@ -992,13 +992,13 @@
std::string success_message = "Add-on \'" +
addons.at(index) + "\' deleted.";
- gui::show_dialog(disp(), NULL, _("Add-on
deleted"), success_message,
- gui::OK_ONLY);
+ gui::basic_dialog(disp(), _("Add-on deleted"),
success_message,
+ gui::OK_ONLY).show();
}
else
{
- gui::show_dialog(disp(), NULL, _("Error"),
_("Add-on could not be deleted -- a file was not found."),
- gui::OK_ONLY);
+ gui::basic_dialog(disp(), _("Error"), _("Add-on
could not be deleted -- a file was not found."),
+ gui::OK_ONLY).show();
}
}
else // Cancel or unexpected result
@@ -1166,12 +1166,14 @@
}
}
// If there are any, display a message.
- // TODO: Somehow offer to automatically download the
missing dependencies.
+ // TODO: Somehow offer to automatically download
+ // the missing dependencies.
if (!missing.empty()) {
- if (gui::show_dialog(disp(), NULL,
_("Dependencies"),
- std::string(_("This add-on requires the
following additional dependencies:")) +
- "\n" + missing +
- "\n" + _("Do you still want to download
it?"), gui::OK_CANCEL))
+ if (gui::basic_dialog(disp(),
+ _("Dependencies"),
+ std::string(_("This
add-on requires the following additional dependencies:")) +
+ "\n" + missing +
+ "\n" + _("Do you still
want to download it?"), gui::OK_CANCEL).show())
return;
}
}
@@ -1264,7 +1266,7 @@
(*data.child("error"))["message"].str()
+ '"');
return;
} else if(data.child("message")) {
- const int res =
gui::show_dialog(disp(),NULL,_("Terms"),(*data.child("message"))["message"],gui::OK_CANCEL);
+ const int res =
gui::basic_dialog(disp(),_("Terms"),(*data.child("message"))["message"],gui::OK_CANCEL).show();
if(res != 0) {
return;
}
@@ -1413,12 +1415,12 @@
} catch(network::error& e) {
std::cerr << "caught network error...\n";
if(e.message != "") {
- gui::show_dialog(disp(),NULL,"",e.message,gui::OK_ONLY);
+
gui::basic_dialog(disp(),"",e.message,gui::OK_ONLY).show();
}
} catch(config::error& e) {
std::cerr << "caught config::error...\n";
if(e.message != "") {
- gui::show_dialog(disp(),NULL,"",e.message,gui::OK_ONLY);
+
gui::basic_dialog(disp(),"",e.message,gui::OK_ONLY).show();
}
} catch(gamemap::incorrect_format_exception& e) {
gui::show_error_message(disp(), std::string(_("The game map
could not be loaded: ")) + e.msg_);
@@ -1445,9 +1447,11 @@
}
}
- const int res = gui::show_dialog(disp(),NULL,_("Language"),
+ gui::basic_dialog lmenu(disp(),_("Language"),
_("Choose your preferred language:"),
- gui::OK_CANCEL,&langs);
+ gui::OK_CANCEL);
+ lmenu.set_menu(langs);
+ const int res = lmenu.show();
if(size_t(res) < langs.size()) {
::set_language(languages[res]);
preferences::set_language(languages[res].localename);
Modified: trunk/src/menu_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=18615&r1=18614&r2=18615&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Mon Jul 2 18:45:51 2007
@@ -249,7 +249,7 @@
symbols["noun"] = (u.gender() ==
unit_race::MALE ? _("him") : _("her"));
message =
utils::interpolate_variables_into_string(message, &symbols);
- const int res =
gui::show_dialog(disp_,NULL,"",message,gui::YES_NO);
+ const int res =
gui::basic_dialog(disp_,"",message,gui::YES_NO).show();
if(res != 0) {
return gui::CONTINUE_DIALOG;
}
@@ -516,9 +516,9 @@
if (res == 0) {
if (file_exists(input_name)) {
- overwrite = gui::show_dialog(*gui_,
NULL, "",
+ overwrite = gui::basic_dialog(*gui_, "",
_("The map already exists. Do
you want to overwrite it?"),
- gui::YES_NO);
+ gui::YES_NO).show();
}
else
overwrite = 0;
@@ -915,7 +915,7 @@
"You must have at least $cost
gold pieces to recall a unit",
game_config::recall_cost,
i18n_symbols);
-
gui::show_dialog(*gui_,NULL,"",msg.str());
+
gui::basic_dialog(*gui_,"",msg.str()).show();
} else {
std::cerr << "recall index: " << res <<
"\n";
unit& un = recall_list[res];
@@ -925,7 +925,7 @@
const std::string err =
recruit_unit(map_,team_num,units_,un,loc,(gui_!=NULL));
if(!err.empty()) {
recorder.undo();
-
gui::show_dialog(*gui_,NULL,"",err,gui::OK_ONLY);
+
gui::basic_dialog(*gui_,"",err,gui::OK_ONLY).show();
} else {
statistics::recall_unit(un);
current_team.spend_gold(game_config::recall_cost);
@@ -1088,7 +1088,7 @@
recorder.add_checksum_check(action.recall_loc);
} else {
recorder.undo();
-
gui::show_dialog(*gui_,NULL,"",msg,gui::OK_ONLY);
+
gui::basic_dialog(*gui_,"",msg,gui::OK_ONLY).show();
}
}
} else if(action.is_recruit()) {
@@ -1130,7 +1130,7 @@
recorder.add_checksum_check(loc);
} else {
recorder.undo();
-
gui::show_dialog(*gui_,NULL,"",msg,gui::OK_ONLY);
+
gui::basic_dialog(*gui_,"",msg,gui::OK_ONLY).show();
}
} else {
// Redo movement action
@@ -1240,7 +1240,7 @@
//Ask for confirmation if the player hasn't made any moves
(other than gotos).
if(preferences::confirm_no_moves() && ! some_units_have_moved) {
- const int res = gui::show_dialog(*gui_,NULL,"",_("You
have not started your turn yet. Do you really want to end your turn?"),
gui::YES_NO);
+ const int res = gui::basic_dialog(*gui_,"",_("You have
not started your turn yet. Do you really want to end your turn?"),
gui::YES_NO).show();
if(res != 0) {
return false;
}
@@ -1248,12 +1248,12 @@
// Ask for confirmation if units still have movement left
if(preferences::yellow_confirm() && partmoved_units) {
- const int res = gui::show_dialog(*gui_,NULL,"",_("Some
units have movement left. Do you really want to end your turn?"),gui::YES_NO);
+ const int res = gui::basic_dialog(*gui_,"",_("Some
units have movement left. Do you really want to end your
turn?"),gui::YES_NO).show();
if (res != 0) {
return false;
}
} else if (preferences::green_confirm() && unmoved_units) {
- const int res = gui::show_dialog(*gui_,NULL,"",_("Some
units have movement left. Do you really want to end your turn?"),gui::YES_NO);
+ const int res = gui::basic_dialog(*gui_,"",_("Some
units have movement left. Do you really want to end your
turn?"),gui::YES_NO).show();
if (res != 0) {
return false;
}
@@ -1785,7 +1785,7 @@
symbols["search"] = last_search_;
const std::string msg =
utils::interpolate_variables_into_string(
_("Couldn't find label or unit containing the
string '$search'."),&symbols);
- gui::show_dialog(*gui_,NULL,"",msg);
+ gui::basic_dialog(*gui_,"",msg).show();
}
}
Modified: trunk/src/multiplayer.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer.cpp?rev=18615&r1=18614&r2=18615&view=diff
==============================================================================
--- trunk/src/multiplayer.cpp (original)
+++ trunk/src/multiplayer.cpp Mon Jul 2 18:45:51 2007
@@ -219,7 +219,7 @@
do {
if(error != NULL) {
-
gui::show_dialog(disp,NULL,"",(*error)["message"],gui::OK_ONLY);
+
gui::basic_dialog(disp,"",(*error)["message"],gui::OK_ONLY).show();
}
std::string login = preferences::login();
Modified: trunk/src/multiplayer_connect.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer_connect.cpp?rev=18615&r1=18614&r2=18615&view=diff
==============================================================================
--- trunk/src/multiplayer_connect.cpp (original)
+++ trunk/src/multiplayer_connect.cpp Mon Jul 2 18:45:51 2007
@@ -1261,9 +1261,9 @@
return;
}
- const int res = gui::show_dialog(disp(), NULL, "",
+ const int res = gui::basic_dialog(disp(), "",
_("This save is from a different
version of the game. Do you want to try to load it?"),
- gui::YES_NO);
+ gui::YES_NO).show();
if(res == 1) {
set_result(QUIT);
return;
Modified: trunk/src/multiplayer_wait.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer_wait.cpp?rev=18615&r1=18614&r2=18615&view=diff
==============================================================================
--- trunk/src/multiplayer_wait.cpp (original)
+++ trunk/src/multiplayer_wait.cpp Mon Jul 2 18:45:51 2007
@@ -13,6 +13,7 @@
#include "global.hpp"
+#include "basic_dialog.hpp"
#include "game_display.hpp"
#include "game_events.hpp"
#include "gettext.hpp"
@@ -337,7 +338,7 @@
ui::process_network_data(data, sock);
if(data["message"] != "") {
-
gui::show_dialog(disp(),NULL,_("Response"),data["message"],gui::OK_ONLY);
+
gui::basic_dialog(disp(),_("Response"),data["message"],gui::OK_ONLY).show();
}
if(data["failed"] == "yes") {
set_result(QUIT);
Modified: trunk/src/play_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.cpp?rev=18615&r1=18614&r2=18615&view=diff
==============================================================================
--- trunk/src/play_controller.cpp (original)
+++ trunk/src/play_controller.cpp Mon Jul 2 18:45:51 2007
@@ -390,7 +390,7 @@
player_number_,status_,gamestate_);
} catch(replay::error&) {
//in next version after string freeze add to text ".
continue playing?"
- if(gui::show_dialog(*gui_,NULL,"",_("The file you have
tried to load is corrupt"),gui::OK_CANCEL))
+ if(gui::basic_dialog(*gui_,"",_("The file you have
tried to load is corrupt"),gui::OK_CANCEL).show())
throw;
result = false;
Modified: trunk/src/preferences_display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/preferences_display.cpp?rev=18615&r1=18614&r2=18615&view=diff
==============================================================================
--- trunk/src/preferences_display.cpp (original)
+++ trunk/src/preferences_display.cpp Mon Jul 2 18:45:51 2007
@@ -1240,7 +1240,7 @@
modes = scr_modes_list;
} else if(modes == NULL) {
std::cerr << "No modes supported\n";
- gui::show_dialog(disp,NULL,"",_("There are no alternative video
modes available"));
+ gui::message_dialog(disp,"",_("There are no alternative video
modes available")).show();
return false;
}
Modified: trunk/src/show_dialog.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/show_dialog.cpp?rev=18615&r1=18614&r2=18615&view=diff
==============================================================================
--- trunk/src/show_dialog.cpp (original)
+++ trunk/src/show_dialog.cpp Mon Jul 2 18:45:51 2007
@@ -356,7 +356,7 @@
void show_error_message(display &disp, std::string const &message)
{
ERR_G << message << std::endl;
- show_dialog(disp, NULL, _("Error"), message, OK_ONLY);
+ basic_dialog(disp, _("Error"), message, OK_ONLY).show();
}
int show_dialog(display& screen, surface image,
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits