From 4965ec95fa8a1cfe57f30739f5645ec427a592e0 Mon Sep 17 00:00:00 2001 From: Ali El Gariani Date: Mon, 23 Jun 2008 10:01:23 +0000 Subject: [PATCH] Allow to use the small-gui mode by starting wesnoth with --smallgui The configure switch is still working, will remove it later --- src/dialogs.cpp | 23 +++++++---------------- src/game.cpp | 16 ++++++++++------ src/game_config.cpp | 2 +- src/game_config.hpp | 2 +- src/preferences.cpp | 23 +++++++++++++++++++++-- src/preferences.hpp | 15 +++------------ src/preferences_display.cpp | 2 +- src/video.cpp | 4 ++-- 8 files changed, 46 insertions(+), 41 deletions(-) diff --git a/src/dialogs.cpp b/src/dialogs.cpp index 17560032e35..68097d7b6a9 100644 --- a/src/dialogs.cpp +++ b/src/dialogs.cpp @@ -671,30 +671,21 @@ std::string load_game_dialog(display& disp, const config& game_config, bool* sho lmenu.add_pane(&save_preview); // create an option for whether the replay should be shown or not if(show_replay != NULL) { - #ifdef USE_SMALL_GUI - lmenu.add_option(_("Show replay"), false, gui::dialog::BUTTON_STANDARD); - #else - lmenu.add_option(_("Show replay"), false); - #endif + lmenu.add_option(_("Show replay"), false, + game_config::small_gui ? gui::dialog::BUTTON_CHECKBOX : gui::dialog::BUTTON_STANDARD); } if(cancel_orders != NULL) { - #ifdef USE_SMALL_GUI - lmenu.add_option(_("Cancel orders"), false, gui::dialog::BUTTON_STANDARD); - #else - lmenu.add_option(_("Cancel orders"), false); - #endif + lmenu.add_option(_("Cancel orders"), false, + game_config::small_gui ? gui::dialog::BUTTON_EXTRA : gui::dialog::BUTTON_STANDARD); } lmenu.add_button(new gui::standard_dialog_button(disp.video(),_("OK"),0,false), gui::dialog::BUTTON_STANDARD); lmenu.add_button(new gui::standard_dialog_button(disp.video(),_("Cancel"),1,true), gui::dialog::BUTTON_STANDARD); delete_save save_deleter(disp,*filter,games,summaries); gui::dialog_button_info delete_button(&save_deleter,_("Delete Save")); - #ifdef USE_SMALL_GUI - //placing the buttons in one line so that none is coverd by any of the others - lmenu.add_button(delete_button,gui::dialog::BUTTON_HELP); - #else - lmenu.add_button(delete_button); - #endif + + lmenu.add_button(delete_button, + game_config::small_gui ? gui::dialog::BUTTON_HELP : gui::dialog::BUTTON_STANDARD); int res = lmenu.show(); diff --git a/src/game.cpp b/src/game.cpp index 74026765ebb..2829eff0d8a 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -273,6 +273,8 @@ game_controller::game_controller(int argc, char** argv) no_gui_ = true; no_sound = true; preferences::disable_preferences_save(); + } else if(val == "--smallgui") { + game_config::small_gui = true; } else if(val == "--windowed" || val == "-w") { preferences::set_fullscreen(false); } else if(val == "--fullscreen" || val == "-f") { @@ -339,6 +341,11 @@ game_controller::game_controller(int argc, char** argv) } std::cerr << "Data at '" << game_config::path << "'\n"; + //TODO: remove this and the configure option +#ifdef USE_SMALL_GUI + game_config::small_gui = true; +#endif + // disable sound in nosound mode, or when sound engine failed to initialize if (no_sound || ((preferences::sound_on() || preferences::music_on() || preferences::turn_bell() || preferences::UI_sound_on()) && @@ -439,8 +446,7 @@ bool game_controller::init_video() } #endif -#ifdef USE_SMALL_GUI - if(bpp == 0) { + if(game_config::small_gui && bpp == 0) { std::cerr << "800x600x" << DefaultBPP << " not available - attempting 800x480x" << DefaultBPP << "...\n"; resolution.first = 800; @@ -448,7 +454,6 @@ bool game_controller::init_video() bpp = video_.modePossible(resolution.first,resolution.second,DefaultBPP,video_flags); } -#endif if(bpp == 0) { //couldn't do 1024x768 or 800x600 @@ -2215,9 +2220,8 @@ void game_controller::reset_defines_map() defines_map_["TINY"] = preproc_define(); #endif -#ifdef USE_SMALL_GUI - defines_map_["SMALL_GUI"] = preproc_define(); -#endif + if (game_config::small_gui) + defines_map_["SMALL_GUI"] = preproc_define(); #ifdef HAVE_PYTHON defines_map_["PYTHON"] = preproc_define(); diff --git a/src/game_config.cpp b/src/game_config.cpp index b6d0f98b9da..aaa471e6f83 100644 --- a/src/game_config.cpp +++ b/src/game_config.cpp @@ -51,7 +51,7 @@ namespace game_config const std::string revision = VERSION; #endif std::string wesnothd_name; - bool debug = false, editor = false, ignore_replay_errors = false, mp_debug = false, exit_at_end = false, no_delay = false, disable_autosave = false; + bool debug = false, editor = false, ignore_replay_errors = false, mp_debug = false, exit_at_end = false, no_delay = false, small_gui = false, disable_autosave = false; std::string game_icon = "wesnoth-icon.png", game_title, game_logo, title_music, lobby_music; int title_logo_x = 0, title_logo_y = 0, title_buttons_x = 0, title_buttons_y = 0, title_buttons_padding = 0, diff --git a/src/game_config.hpp b/src/game_config.hpp index aaf2b2f039d..74943c3a61c 100644 --- a/src/game_config.hpp +++ b/src/game_config.hpp @@ -46,7 +46,7 @@ namespace game_config //! starting gold and carryover gold. extern const bool gold_carryover_add; - extern bool debug, editor, ignore_replay_errors, mp_debug, exit_at_end, no_delay, disable_autosave; + extern bool debug, editor, ignore_replay_errors, mp_debug, exit_at_end, no_delay, small_gui, disable_autosave; extern std::string path; diff --git a/src/preferences.cpp b/src/preferences.cpp index ffc21b042cb..73c55fd995e 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -117,6 +117,25 @@ void _set_fullscreen(bool ison) prefs["fullscreen"] = (ison ? "true" : "false"); } +int min_allowed_width() +{ +#ifdef USE_TINY_GUI + return 320; +#endif + return 800; +} + +int min_allowed_height() +{ +#ifdef USE_TINY_GUI + return 240; +#endif + if (game_config::small_gui) + return 480; + + return 600; +} + std::pair resolution() { const std::string postfix = fullscreen() ? "resolution" : "windowsize"; @@ -124,8 +143,8 @@ std::pair resolution() const string_map::const_iterator y = prefs.values.find('y' + postfix); if(x != prefs.values.end() && y != prefs.values.end() && x->second.empty() == false && y->second.empty() == false) { - std::pair res (maximum(atoi(x->second.c_str()),min_allowed_width), - maximum(atoi(y->second.c_str()),min_allowed_height)); + std::pair res (maximum(atoi(x->second.c_str()),min_allowed_width()), + maximum(atoi(y->second.c_str()),min_allowed_height())); // Make sure resolutions are always divisible by 4 //res.first &= ~3; diff --git a/src/preferences.hpp b/src/preferences.hpp index 7e6f2edbec1..11eb093ec58 100644 --- a/src/preferences.hpp +++ b/src/preferences.hpp @@ -28,18 +28,6 @@ class display; #include #include -// Only there temporary -#ifdef USE_TINY_GUI -const int min_allowed_width = 320; -const int min_allowed_height = 240; -#elif defined USE_SMALL_GUI -const int min_allowed_width = 800; -const int min_allowed_height = 480; -#else -const int min_allowed_width = 800; -const int min_allowed_height = 600; -#endif - namespace preferences { struct base_manager @@ -64,6 +52,9 @@ namespace preferences { bool fullscreen(); void _set_fullscreen(bool ison); + int min_allowed_width(); + int min_allowed_height(); + std::pair resolution(); void _set_resolution(const std::pair& res); diff --git a/src/preferences_display.cpp b/src/preferences_display.cpp index f2b4b962692..f59c1cbef20 100644 --- a/src/preferences_display.cpp +++ b/src/preferences_display.cpp @@ -435,7 +435,7 @@ bool show_video_mode_dialog(display& disp) std::vector > resolutions; for(int i = 0; modes[i] != NULL; ++i) { - if(modes[i]->w >= min_allowed_width && modes[i]->h >= min_allowed_height) { + if(modes[i]->w >= min_allowed_width() && modes[i]->h >= min_allowed_height()) { resolutions.push_back(std::pair(modes[i]->w,modes[i]->h)); } } diff --git a/src/video.cpp b/src/video.cpp index 1eecfc14bdd..c918c2c0934 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -80,8 +80,8 @@ namespace { int disallow_resize = 0; } void resize_monitor::process(events::pump_info &info) { - if(info.resize_dimensions.first >= min_allowed_width - && info.resize_dimensions.second >= min_allowed_height + if(info.resize_dimensions.first >= preferences::min_allowed_width() + && info.resize_dimensions.second >= preferences::min_allowed_height() && disallow_resize == 0) { preferences::set_resolution(info.resize_dimensions); }