Author: mordante
Date: Sun Aug 24 20:17:56 2008
New Revision: 28941

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28941&view=rev
Log:
Make the restore of the window background conditionally.

Modified:
    trunk/src/Makefile.am
    trunk/src/game.cpp
    trunk/src/gui/dialogs/dialog.cpp
    trunk/src/gui/dialogs/dialog.hpp
    trunk/src/gui/widgets/settings.cpp
    trunk/src/gui/widgets/settings.hpp
    trunk/src/gui/widgets/window.cpp
    trunk/src/titlescreen.hpp

Modified: trunk/src/Makefile.am
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/Makefile.am?rev=28941&r1=28940&r2=28941&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sun Aug 24 20:17:56 2008
@@ -78,6 +78,7 @@
        gui/dialogs/mp_connect.cpp \
        gui/dialogs/mp_create_game.cpp \
        gui/dialogs/mp_method_selection.cpp \
+       gui/dialogs/title_screen.cpp \
        gui/widgets/button.cpp \
        gui/widgets/canvas.cpp \
        gui/widgets/control.cpp \

Modified: trunk/src/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=28941&r1=28940&r2=28941&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Sun Aug 24 20:17:56 2008
@@ -34,6 +34,7 @@
 #include "gui/dialogs/addon_connect.hpp"
 #include "gui/dialogs/language_selection.hpp"
 #include "gui/dialogs/mp_method_selection.hpp"
+#include "gui/dialogs/title_screen.hpp"
 #include "gui/widgets/window.hpp"
 #include "help.hpp"
 #include "hotkeys.hpp"
@@ -2158,11 +2159,20 @@
 
                gui::TITLE_RESULT res = game.is_loading() ? gui::LOAD_GAME : 
gui::NOTHING;
 
-               while(res == gui::NOTHING) {
-                       res = gui::show_title(game.disp(),tips_of_day);
-                       if (res == gui::REDRAW_BACKGROUND) {
-                               gui::set_background_dirty();
-                               res = gui::NOTHING;
+               if(gui2::new_widgets) {
+                       cursor::set(cursor::NORMAL); // does a window need a 
cursor manager as well???
+                       gui2::ttitle_screen dlg;
+                       dlg.show(game.disp().video());
+
+                       res = static_cast<gui::TITLE_RESULT>(dlg.get_retval());
+
+               } else {
+                       while(res == gui::NOTHING) {
+                               res = gui::show_title(game.disp(),tips_of_day);
+                               if (res == gui::REDRAW_BACKGROUND) {
+                                       gui::set_background_dirty();
+                                       res = gui::NOTHING;
+                               }
                        }
                }
 

Modified: trunk/src/gui/dialogs/dialog.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/dialog.cpp?rev=28941&r1=28940&r2=28941&view=diff
==============================================================================
--- trunk/src/gui/dialogs/dialog.cpp (original)
+++ trunk/src/gui/dialogs/dialog.cpp Sun Aug 24 20:17:56 2008
@@ -45,7 +45,7 @@
 
        pre_show(video, window);
 
-       retval_ = window.show(true);
+       retval_ = window.show(restore_);
 
        if(retval_ ==  twindow::OK) {
                finalize_fields(window);

Modified: trunk/src/gui/dialogs/dialog.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/dialog.hpp?rev=28941&r1=28940&r2=28941&view=diff
==============================================================================
--- trunk/src/gui/dialogs/dialog.hpp (original)
+++ trunk/src/gui/dialogs/dialog.hpp Sun Aug 24 20:17:56 2008
@@ -37,7 +37,8 @@
 public:
        tdialog() : 
                retval_(0),
-               fields_()
+               fields_(),
+               restore_(true)
        {}
 
        virtual ~tdialog();
@@ -45,7 +46,11 @@
        /** Shows the window */
        void show(CVideo& video);
 
+       /***** ***** ***** setters / getters for members ***** ****** *****/
+
        int get_retval() const { return retval_; }
+
+       void set_restore(const bool restore) { restore_ = restore; }
 
 protected:
 
@@ -106,6 +111,15 @@
         */
        std::vector<tfield_*> fields_;
 
+       /** 
+        * Restore the screen after showing?
+        *
+        * Most windows should restore the display after showing so this value
+        * defaults to true. Toplevel windows (like the titlescreen don't want 
this
+        * behaviour so they can change it in pre_show().
+        */
+       bool restore_;
+
        /**
         * Builds the window.
         *

Modified: trunk/src/gui/widgets/settings.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.cpp?rev=28941&r1=28940&r2=28941&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Sun Aug 24 20:17:56 2008
@@ -89,6 +89,7 @@
        window_type_list[MP_METHOD_SELECTION] = "mp_method_selection";
        window_type_list[MP_SERVER_LIST] = "mp_server_list";
        window_type_list[MP_CREATE_GAME] = "mp_create_game";
+       window_type_list[TITLE_SCREEN] = "title_screen";
 #ifdef USE_EDITOR2     
        window_type_list[EDITOR_NEW_MAP] = "editor_new_map";
        window_type_list[EDITOR_GENERATE_MAP] = "editor_generate_map";

Modified: trunk/src/gui/widgets/settings.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.hpp?rev=28941&r1=28940&r2=28941&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.hpp (original)
+++ trunk/src/gui/widgets/settings.hpp Sun Aug 24 20:17:56 2008
@@ -34,6 +34,7 @@
 extern bool new_widgets;
 
 enum twindow_type {
+       TITLE_SCREEN,            /**< The main title screen of the game. */
        ADDON_CONNECT,           //<! The addon server connection dialog.
        LANGUAGE_SELECTION,      //<! The language selection dialog.
        MP_CONNECT,              //<! The mp server connection dialog.

Modified: trunk/src/gui/widgets/window.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window.cpp?rev=28941&r1=28940&r2=28941&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.cpp (original)
+++ trunk/src/gui/widgets/window.cpp Sun Aug 24 20:17:56 2008
@@ -22,6 +22,7 @@
 #include "cursor.hpp"
 #include "font.hpp"
 #include "log.hpp"
+#include "titlescreen.hpp"
 #include "tstring.hpp"
 #include "video.hpp"
 
@@ -160,6 +161,42 @@
                return OK;
        } else if(id == "cancel") {
                return CANCEL;
+       
+       /**
+        * The ones for the title screen.
+        *
+        * This is a kind of hack, but the values are hardcoded in the 
titlescreen
+        * and don't want to change them at the moment. It would be a good idea 
to
+        * add some namespaces to avoid names clashing.
+        */
+       } else if(id == "tutorial") {
+               return static_cast<tretval>(gui::TUTORIAL);
+#ifdef USE_EDITOR2             
+       } else if(id == "editor") {
+               return static_cast<tretval>(gui::START_MAP_EDITOR);
+#endif         
+       } else if(id == "credits") {
+               return static_cast<tretval>(gui::SHOW_ABOUT);
+       } else if(id == "quit") {
+               return static_cast<tretval>(gui::QUIT_GAME);
+
+       /**
+        * The hacks which are here so the old engine can handle the event. The 
new
+        * engine can't handle all dialogs yet, so it needs to fall back to the 
old
+        * engine to make certain things happen.
+        */
+       } else if(id == "campaign") { 
+               return static_cast<tretval>(gui::NEW_CAMPAIGN);
+       } else if(id == "multiplayer") { 
+               return static_cast<tretval>(gui::MULTIPLAYER);
+       } else if(id == "load") { 
+               return static_cast<tretval>(gui::LOAD_GAME);
+       } else if(id == "addons") { 
+               return static_cast<tretval>(gui::GET_ADDONS);
+       } else if(id == "preferences") { 
+               return static_cast<tretval>(gui::EDIT_PREFERENCES);
+
+       // default if nothing matched
        } else {
                return NONE;
        }

Modified: trunk/src/titlescreen.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/titlescreen.hpp?rev=28941&r1=28940&r2=28941&view=diff
==============================================================================
--- trunk/src/titlescreen.hpp (original)
+++ trunk/src/titlescreen.hpp Sun Aug 24 20:17:56 2008
@@ -24,8 +24,10 @@
  * Values for the menu-items of the main menu. 
  *
  * The code assumes TUTORIAL is the first item.
+ * The values are also used as the button retour values, where 0 means no
+ * automatic value so we need to avoid 0.
  */
-enum TITLE_RESULT { TUTORIAL = 0,              /**< Start special campaign 
'tutorial' */
+enum TITLE_RESULT { TUTORIAL = 1,              /**< Start special campaign 
'tutorial' */
                                        NEW_CAMPAIGN,           /**< Let user 
select a campaign to play */
                                        MULTIPLAYER,            /**< Play 
single scenario against humans or AI */
                                        LOAD_GAME, GET_ADDONS, 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to