Author: mordante
Date: Sun Aug 24 21:27:53 2008
New Revision: 28945
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28945&view=rev
Log:
Add a new title screen.
Now that all 'stable' --new-widgets code has been moved to the default way
starting with --new-widgets is no longer needed unless you want to develop for
it. So the new proof-of-concept title screen can be committed. Only has the
basic buttons which work, but needs some cleanup up, both in looks and code
working.
Added:
trunk/data/gui/default/window/title_screen.cfg (with props)
trunk/src/gui/dialogs/title_screen.cpp (with props)
trunk/src/gui/dialogs/title_screen.hpp (with props)
Modified:
trunk/po/wesnoth-lib/POTFILES.in
trunk/src/CMakeLists.txt
trunk/src/Makefile.am
trunk/src/SConscript
trunk/src/game.cpp
trunk/src/gui/widgets/settings.cpp
trunk/src/gui/widgets/settings.hpp
trunk/src/gui/widgets/window.cpp
trunk/src/titlescreen.hpp
Added: trunk/data/gui/default/window/title_screen.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/window/title_screen.cfg?rev=28945&view=auto
==============================================================================
--- trunk/data/gui/default/window/title_screen.cfg (added)
+++ trunk/data/gui/default/window/title_screen.cfg Sun Aug 24 21:27:53 2008
@@ -1,0 +1,120 @@
+###
+### Definition of the main screen for Wesnoth.
+###
+
+[window_definition]
+
+ id = "title_screen"
+ description = "The window definition for the title screen."
+
+ [resolution]
+
+ [background]
+
+ [draw]
+
+ [image]
+ x = 0
+ y = 0
+ w = "(width)"
+ h = "(height)"
+ name = "(background_image)"
+ [/image]
+
+ [text]
+ x = 0
+ y = "(height - text_height)"
+ w = "(text_width)"
+ h = "(text_height)"
+ font_size = 16
+ font_colour = "255, 255, 255, 128"
+ text = "(revision_number)"
+ [/text]
+
+ [/draw]
+
+ [/background]
+
+ [foreground]
+
+ [draw]
+
+ [/draw]
+
+ [/foreground]
+
+ [/resolution]
+
+[/window_definition]
+
+#define GUI_TIP_SECTION
+#enddef
+
+
+#define GUI_BUTTON ID CAPTION
+ [row]
+
+ [column]
+ border = "all"
+ border_size = 5
+ horizontal_alignment = "left"
+ [button]
+ id = {ID}
+ definition = "default"
+
+ label = {CAPTION}
+ [/button]
+
+ [/column]
+
+ [/row]
+
+#enddef
+
+#define MENU_SECTION
+ [grid]
+ {GUI_BUTTON "tutorial" _"Tutorial"}
+ {GUI_BUTTON "campaign" _"Campaign"}
+ {GUI_BUTTON "multiplayer" _"Multiplayer"}
+ {GUI_BUTTON "load" _"Load"}
+ {GUI_BUTTON "addons" _"Add-ons"}
+ {GUI_BUTTON "editor" _"Editor"}
+ {GUI_BUTTON "language" _"Language"}
+ {GUI_BUTTON "preferences" _"Preferences"}
+ {GUI_BUTTON "credits" _"Credits"}
+ {GUI_BUTTON "quit" _"Quit"}
+ [/grid]
+#enddef
+
+[window]
+ id = "title_screen"
+ description = "MP create game dialog."
+
+ [resolution]
+ definition = "title_screen"
+
+ automatic_placement = "false"
+ x = 0
+ y = 0
+ width = "(screen_width)"
+ height = "(screen_height)"
+
+ [grid]
+
+ [row]
+
+ [column]
+ {MENU_SECTION}
+ [/column]
+
+ [/row]
+
+ [/grid]
+
+ [/resolution]
+
+[/window]
+
+#undef GUI_TIP_SECTION
+#undef MENU_SECTION
+#undef GUI_BUTTON
Propchange: trunk/data/gui/default/window/title_screen.cfg
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/po/wesnoth-lib/POTFILES.in
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/po/wesnoth-lib/POTFILES.in?rev=28945&r1=28944&r2=28945&view=diff
==============================================================================
--- trunk/po/wesnoth-lib/POTFILES.in (original)
+++ trunk/po/wesnoth-lib/POTFILES.in Sun Aug 24 21:27:53 2008
@@ -11,6 +11,7 @@
src/gui/dialogs/mp_connect.cpp
src/gui/dialogs/mp_create_game.cpp
src/gui/dialogs/mp_method_selection.cpp
+src/gui/dialogs/title_screen.cpp
src/gui/widgets/button.cpp
src/gui/widgets/canvas.cpp
src/gui/widgets/control.cpp
Modified: trunk/src/CMakeLists.txt
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/CMakeLists.txt?rev=28945&r1=28944&r2=28945&view=diff
==============================================================================
--- trunk/src/CMakeLists.txt (original)
+++ trunk/src/CMakeLists.txt Sun Aug 24 21:27:53 2008
@@ -232,6 +232,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/Makefile.am
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/Makefile.am?rev=28945&r1=28944&r2=28945&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sun Aug 24 21:27:53 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/SConscript
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=28945&r1=28944&r2=28945&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Sun Aug 24 21:27:53 2008
@@ -209,6 +209,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=28945&r1=28944&r2=28945&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Sun Aug 24 21:27:53 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;
+ }
}
}
Added: trunk/src/gui/dialogs/title_screen.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/title_screen.cpp?rev=28945&view=auto
==============================================================================
--- trunk/src/gui/dialogs/title_screen.cpp (added)
+++ trunk/src/gui/dialogs/title_screen.cpp Sun Aug 24 21:27:53 2008
@@ -1,0 +1,100 @@
+/* $Id$ */
+/*
+ copyright (c) 2008 by mark de wever <[EMAIL PROTECTED]>
+ 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 version 2
+ 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/title_screen.hpp"
+
+#include "game_config.hpp"
+#include "gettext.hpp"
+#include "gui/dialogs/addon_connect.hpp"
+#include "gui/dialogs/language_selection.hpp"
+#include "gui/widgets/button.hpp"
+#include "gui/widgets/widget.hpp"
+#include "gui/widgets/window.hpp"
+#include "gui/widgets/window_builder.hpp"
+#include "gui/widgets/settings.hpp"
+#include "log.hpp"
+#include "wml_exception.hpp"
+
+#define DBG_GUI LOG_STREAM_INDENT(debug, gui)
+#define LOG_GUI LOG_STREAM_INDENT(info, gui)
+#define WRN_GUI LOG_STREAM_INDENT(warn, gui)
+#define ERR_GUI LOG_STREAM_INDENT(err, gui)
+
+#define ERR_CONFIG LOG_STREAM(err, config)
+
+namespace gui2 {
+
+namespace {
+
+template<class D>
+void show_dialog(twidget* caller)
+{
+ ttitle_screen *dialog = dynamic_cast<ttitle_screen*>(caller->dialog());
+ assert(dialog);
+
+ D dlg;
+ dlg.show(*(dialog->video()));
+}
+
+} // namespace
+
+/*WIKI
+ * @page = GUIWindowWML
+ * @order = 2_title_screen
+ *
+ * == Title screen ==
+ *
+ * This shows the title screen.
+ */
+
+twindow ttitle_screen::build_window(CVideo& video)
+{
+ return build(video, get_id(TITLE_SCREEN));
+}
+
+void ttitle_screen::pre_show(CVideo& video, twindow& window)
+{
+ assert(!video_);
+ video_ = &video;
+
+ set_restore(false);
+
+ // Note changing the language doesn't upate the title screen...
+ window.get_widget<tbutton>("language", false).
+ set_callback_mouse_left_click(
show_dialog<gui2::tlanguage_selection>);
+
+ window.get_widget<tbutton>("addons", false).
+ set_callback_mouse_left_click(
show_dialog<gui2::taddon_connect>);
+
+ window.canvas()[0].set_variable("revision_number",
+ variant(_("Version") + std::string(" ") +
game_config::revision));
+
+ /*Select a random game_title*/
+ std::vector<std::string> game_title_list =
+ utils::split(game_config::game_title, ',', utils::STRIP_SPACES
| utils::REMOVE_EMPTY);
+
+ if(game_title_list.empty()) {
+ ERR_CONFIG << "No title image defined\n";
+ } else {
+ window.canvas()[0].set_variable("background_image",
+
variant(game_title_list[rand()%game_title_list.size()]));
+ }
+}
+
+void ttitle_screen::post_show(twindow& /*window*/)
+{
+ video_ = NULL;
+}
+
+} // namespace gui2
Propchange: trunk/src/gui/dialogs/title_screen.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/src/gui/dialogs/title_screen.cpp
------------------------------------------------------------------------------
svn:keywords = 'Author Date Id Revision'
Added: trunk/src/gui/dialogs/title_screen.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/title_screen.hpp?rev=28945&view=auto
==============================================================================
--- trunk/src/gui/dialogs/title_screen.hpp (added)
+++ trunk/src/gui/dialogs/title_screen.hpp Sun Aug 24 21:27:53 2008
@@ -1,0 +1,48 @@
+/* $Id$ */
+/*
+ copyright (c) 2008 by mark de wever <[EMAIL PROTECTED]>
+ 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 version 2
+ 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_TITLE_SCREEN_HPP_INCLUDED
+#define GUI_DIALOGS_TITLE_SCREEN_HPP_INCLUDED
+
+#include "gui/dialogs/dialog.hpp"
+
+namespace gui2 {
+
+class ttitle_screen : public tdialog
+{
+public:
+ ttitle_screen() :
+ video_(NULL)
+ {
+ }
+
+ CVideo* video() { return video_; }
+
+private:
+ /** Used in show in order to show child windows. */
+ CVideo* video_;
+
+ /** Inherited from tdialog. */
+ twindow build_window(CVideo& video);
+
+ /** Inherited from tdialog. */
+ void pre_show(CVideo& video, twindow& window);
+
+ /** Inherited from tdialog. */
+ void post_show(twindow& window);
+};
+
+} // namespace gui2
+
+#endif
Propchange: trunk/src/gui/dialogs/title_screen.hpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/src/gui/dialogs/title_screen.hpp
------------------------------------------------------------------------------
svn:keywords = 'Author Date Id Revision'
Modified: trunk/src/gui/widgets/settings.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.cpp?rev=28945&r1=28944&r2=28945&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Sun Aug 24 21:27:53 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=28945&r1=28944&r2=28945&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.hpp (original)
+++ trunk/src/gui/widgets/settings.hpp Sun Aug 24 21:27:53 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=28945&r1=28944&r2=28945&view=diff
==============================================================================
--- trunk/src/gui/widgets/window.cpp (original)
+++ trunk/src/gui/widgets/window.cpp Sun Aug 24 21:27:53 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=28945&r1=28944&r2=28945&view=diff
==============================================================================
--- trunk/src/titlescreen.hpp (original)
+++ trunk/src/titlescreen.hpp Sun Aug 24 21:27:53 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