Author: mordante
Date: Tue Nov 25 20:07:06 2008
New Revision: 31075
URL: http://svn.gna.org/viewcvs/wesnoth?rev=31075&view=rev
Log:
Improved the new ingame dialogs with portrait.
The code can now show a scrollbar if the text doesn't fit like the normal
dialog. (Note there's a redraw glitch which turns most of the dialog black.)
Also updated the changelog.
Added:
trunk/src/gui/dialogs/wml_message.cpp (with props)
trunk/src/gui/dialogs/wml_message.hpp (with props)
Modified:
trunk/changelog
trunk/data/gui/default/window/message.cfg
trunk/po/wesnoth-lib/POTFILES.in
trunk/src/CMakeLists.txt
trunk/src/Makefile.am
trunk/src/SConscript
trunk/src/game_events.cpp
trunk/src/gui/dialogs/message.cpp
trunk/src/gui/dialogs/message.hpp
trunk/src/gui/widgets/settings.cpp
trunk/src/gui/widgets/settings.hpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=31075&r1=31074&r2=31075&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Tue Nov 25 20:07:06 2008
@@ -16,6 +16,8 @@
* Tweaked the algorithm that extends the darkened area below long
story texts so that it gives a more consistent appearance.
* Added a border and blurring to story screens' text blocks.
+ * Improved wrapping in the new widgets.
+ * Improved easy close handling.
Version 1.5.6:
* Authoring tools:
Modified: trunk/data/gui/default/window/message.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/gui/default/window/message.cfg?rev=31075&r1=31074&r2=31075&view=diff
==============================================================================
--- trunk/data/gui/default/window/message.cfg (original)
+++ trunk/data/gui/default/window/message.cfg Tue Nov 25 20:07:06 2008
@@ -94,7 +94,7 @@
)#enddef
[window_definition]
- id = "message_test_left"
+ id = "wml_message_left"
description = "bar"
[resolution]
@@ -129,7 +129,7 @@
[/window_definition]
[window_definition]
- id = "message_test_right"
+ id = "wml_message_right"
description = "bar"
[resolution]
@@ -227,7 +227,7 @@
window_width = {WIDTH}
window_height = {HEIGHT}
- definition = "message_test_left"
+ definition = "wml_message_left"
automatic_placement = "false"
@@ -309,14 +309,14 @@
[window]
- id = "message_test_left"
- description = "Test dialog to test Jetryl's new message style and
Kitty's portraits."
+ id = "wml_message_left"
+ description = "Dialog showing a unit portrait on the left side"
[resolution]
window_width = 0
window_height = 0
- definition = "message_test_left"
+ definition = "wml_message_left"
automatic_placement = "false"
@@ -362,16 +362,66 @@
[/column]
[column]
-
grow_factor = 1
horizontal_grow = "true"
-
border = "all"
-
border_size = 5
-
-
[scroll_label]
-
id = "message"
-
definition = "default"
-
[/scroll_label]
+
[grid]
+
+
[row]
+
+
[column]
+
border = "all"
+
border_size = 5
+
horizontal_alignment = "left"
+
+
[label]
+
id = "title"
+
definition = "title"
+
[/label]
+
+
[/column]
+
+
[/row]
+
+
[row]
+
+
[column]
+
grow_factor = 1
+
horizontal_grow = "true"
+
+
border = "all"
+
border_size = 5
+
+
[scroll_label] # NOTE maybe change the
code to use message instead of label as id
+
id = "label"
+
definition = "default"
+
[/scroll_label]
+
+
[/column]
+
+
[/row]
+
+
[row]
+
+
[column]
+
border = "all"
+
border_size = 5
+
horizontal_alignment = "center"
+
+
[button]
+
# This button will be shown or
hidden depending on the
+
# whether or not a scrollbar is
needed to show the
+
# text.
+
id = "ok"
+
definition = "default"
+
+
label = "close"
+
[/button]
+
+
[/column]
+
+
[/row]
+
+
[/grid]
[/column]
@@ -404,7 +454,7 @@
window_width = {WIDTH}
window_height = {HEIGHT}
- definition = "message_test_right"
+ definition = "wml_message_right"
automatic_placement = "false"
@@ -485,7 +535,7 @@
#enddef
[window]
- id = "message_test_right"
+ id = "wml_message_right"
description = "Test dialog to test Jetryl's new message style and
Kitty's portraits."
{RESOLUTION_RIGHT 1000 700 250}
{RESOLUTION_RIGHT 0 0 500}
Modified: trunk/po/wesnoth-lib/POTFILES.in
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/po/wesnoth-lib/POTFILES.in?rev=31075&r1=31074&r2=31075&view=diff
==============================================================================
--- trunk/po/wesnoth-lib/POTFILES.in (original)
+++ trunk/po/wesnoth-lib/POTFILES.in Tue Nov 25 20:07:06 2008
@@ -12,6 +12,7 @@
src/gui/dialogs/mp_create_game.cpp
src/gui/dialogs/mp_method_selection.cpp
src/gui/dialogs/title_screen.cpp
+src/gui/dialogs/wml_message.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=31075&r1=31074&r2=31075&view=diff
==============================================================================
--- trunk/src/CMakeLists.txt (original)
+++ trunk/src/CMakeLists.txt Tue Nov 25 20:07:06 2008
@@ -228,6 +228,7 @@
gui/dialogs/mp_create_game.cpp
gui/dialogs/mp_method_selection.cpp
gui/dialogs/title_screen.cpp
+ gui/dialogs/wml_message.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=31075&r1=31074&r2=31075&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Tue Nov 25 20:07:06 2008
@@ -76,6 +76,7 @@
gui/dialogs/mp_create_game.cpp \
gui/dialogs/mp_method_selection.cpp \
gui/dialogs/title_screen.cpp \
+ gui/dialogs/wml_message.cpp \
gui/widgets/button.cpp \
gui/widgets/debug.cpp \
gui/widgets/canvas.cpp \
Modified: trunk/src/SConscript
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=31075&r1=31074&r2=31075&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Tue Nov 25 20:07:06 2008
@@ -214,6 +214,7 @@
gui/dialogs/mp_create_game.cpp
gui/dialogs/mp_method_selection.cpp
gui/dialogs/title_screen.cpp
+ gui/dialogs/wml_message.cpp
gui/widgets/button.cpp
gui/widgets/canvas.cpp
gui/widgets/control.cpp
Modified: trunk/src/game_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=31075&r1=31074&r2=31075&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Tue Nov 25 20:07:06 2008
@@ -25,8 +25,9 @@
#include "game_events.hpp"
#include "game_preferences.hpp"
#include "gettext.hpp"
-#include "gui/widgets/spacer.hpp"
-#include "gui/widgets/window.hpp"
+#include "gui/dialogs/wml_message.hpp"
+#include "gui/widgets/settings.hpp"
+#include "log.hpp"
#include "map.hpp"
#include "map_label.hpp"
#include "map_exception.hpp"
@@ -34,6 +35,7 @@
#include "sound.hpp"
#include "terrain_filter.hpp"
#include "unit_display.hpp"
+#include "wml_exception.hpp"
#include <boost/scoped_ptr.hpp>
@@ -2891,23 +2893,11 @@
const tportrait* portrait =
speaker->second.portrait(400,
tportrait::LEFT);
if(portrait) {
-
- gui2::twindow window =
-
gui2::build((screen)->video(), "message_test_left");
-
- const t_string message =
cfg["message"];
- const std::string image =
portrait ? portrait->image : "";
- const bool mirror = portrait ?
portrait->mirror : false;
-
-
window.canvas(1).set_variable("portrait_image", variant(image));
-
window.canvas(1).set_variable("portrait_mirror", variant(mirror));
-
- gui2::tcontrol* label =
dynamic_cast<gui2::tcontrol*>(window.find_widget("message", false));
- assert(label);
- label->set_label(message);
-
- window.show();
-
+ gui2::twml_message_left (
+ caption,
+ cfg["message"],
+ portrait->image,
+
portrait->mirror).show(screen->video());
return;
}
}
Modified: trunk/src/gui/dialogs/message.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/message.cpp?rev=31075&r1=31074&r2=31075&view=diff
==============================================================================
--- trunk/src/gui/dialogs/message.cpp (original)
+++ trunk/src/gui/dialogs/message.cpp Tue Nov 25 20:07:06 2008
@@ -20,11 +20,6 @@
#include "gui/widgets/window.hpp"
namespace gui2 {
-
-twindow tmessage::build_window(CVideo& video)
-{
- return build(video, get_id(MESSAGE));
-}
void tmessage::pre_show(CVideo& /*video*/, twindow& window)
{
@@ -77,6 +72,11 @@
}
}
+twindow tmessage::build_window(CVideo& video)
+{
+ return build(video, get_id(MESSAGE));
+}
+
/** @todo the caption is ignored. */
void show_message(CVideo& video, const std::string& title,
const std::string& message, const std::string& /*button_caption*/,
Modified: trunk/src/gui/dialogs/message.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/message.hpp?rev=31075&r1=31074&r2=31075&view=diff
==============================================================================
--- trunk/src/gui/dialogs/message.hpp (original)
+++ trunk/src/gui/dialogs/message.hpp Tue Nov 25 20:07:06 2008
@@ -44,6 +44,10 @@
void set_message(const std::string& message) { message_ = message; }
+protected:
+ /** Inherited from tdialog. */
+ void pre_show(CVideo& video, twindow& window);
+
private:
/** The title for the dialog. */
std::string title_;
@@ -66,9 +70,6 @@
/** Inherited from tdialog. */
twindow build_window(CVideo& video);
-
- /** Inherited from tdialog. */
- void pre_show(CVideo& video, twindow& window);
};
/**
Added: trunk/src/gui/dialogs/wml_message.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/wml_message.cpp?rev=31075&view=auto
==============================================================================
--- trunk/src/gui/dialogs/wml_message.cpp (added)
+++ trunk/src/gui/dialogs/wml_message.cpp Tue Nov 25 20:07:06 2008
@@ -1,0 +1,41 @@
+/* $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/wml_message.hpp"
+
+#include "gui/widgets/window.hpp"
+
+namespace gui2 {
+
+void twml_message_::pre_show(CVideo& video, twindow& window)
+{
+ // Inherited.
+ tmessage::pre_show(video, window);
+
+ window.canvas(1).set_variable("portrait_image", variant(portrait_));
+ window.canvas(1).set_variable("portrait_mirror", variant(mirror_));
+}
+
+twindow twml_message_left::build_window(CVideo& video)
+{
+ return build(video, get_id(WML_MESSAGE_LEFT));
+}
+
+twindow twml_message_right::build_window(CVideo& video)
+{
+ return build(video, get_id(WML_MESSAGE_RIGHT));
+}
+
+} // namespace gui2
+
Propchange: trunk/src/gui/dialogs/wml_message.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/src/gui/dialogs/wml_message.cpp
------------------------------------------------------------------------------
svn:keywords = 'Author Date Id Revision'
Added: trunk/src/gui/dialogs/wml_message.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/wml_message.hpp?rev=31075&view=auto
==============================================================================
--- trunk/src/gui/dialogs/wml_message.hpp (added)
+++ trunk/src/gui/dialogs/wml_message.hpp Tue Nov 25 20:07:06 2008
@@ -1,0 +1,88 @@
+/* $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_WML_MESSAGE_HPP_INCLUDED
+#define GUI_DIALOGS_WML_MESSAGE_HPP_INCLUDED
+
+#include "gui/dialogs/message.hpp"
+
+namespace gui2 {
+
+/**
+ * Base class for the wml generated messages.
+ *
+ * We have a separate sub class for left and right images.
+ */
+class twml_message_ : public tmessage
+{
+public:
+ twml_message_(const std::string& title, const std::string& message,
+ const std::string portrait, const bool mirror)
+ : tmessage(title, message, true)
+ , portrait_(portrait)
+ , mirror_(mirror)
+ {
+ }
+
+private:
+
+ /** Filename of the portrait. */
+ std::string portrait_;
+
+ /** Mirror the portrait? */
+ bool mirror_;
+
+ /**
+ * Inherited from tmessage.
+ *
+ * The subclasses need to implement the left or right definition.
+ */
+ twindow build_window(CVideo& /*video*/) = 0;
+
+ /** Inherited from tmessage. */
+ void pre_show(CVideo& video, twindow& window);
+};
+
+/** Shows a dialog with the portrait on the left side. */
+class twml_message_left : public twml_message_
+{
+public:
+ twml_message_left(const std::string& title, const std::string& message,
+ const std::string portrait, const bool mirror)
+ : twml_message_(title, message, portrait, mirror)
+ {
+ }
+private:
+ /** Inherited from twml_message_. */
+ twindow build_window(CVideo& video);
+};
+
+/** Shows a dialog with the portrait on the right side. */
+class twml_message_right : public twml_message_
+{
+public:
+ twml_message_right(const std::string& title, const std::string& message,
+ const std::string portrait, const bool mirror)
+ : twml_message_(title, message, portrait, mirror)
+ {
+ }
+private:
+ /** Inherited from twml_message_. */
+ twindow build_window(CVideo& video);
+};
+
+} // namespace gui2
+
+#endif
+
Propchange: trunk/src/gui/dialogs/wml_message.hpp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: trunk/src/gui/dialogs/wml_message.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=31075&r1=31074&r2=31075&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.cpp (original)
+++ trunk/src/gui/widgets/settings.cpp Tue Nov 25 20:07:06 2008
@@ -62,6 +62,8 @@
{
window_type_list[ADDON_CONNECT] = "addon_connect";
window_type_list[LANGUAGE_SELECTION] = "language_selection";
+ window_type_list[WML_MESSAGE_LEFT] = "wml_message_left";
+ window_type_list[WML_MESSAGE_RIGHT] = "wml_message_right";
window_type_list[MESSAGE] = "message";
window_type_list[MP_CONNECT] = "mp_connect";
window_type_list[MP_METHOD_SELECTION] = "mp_method_selection";
Modified: trunk/src/gui/widgets/settings.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/settings.hpp?rev=31075&r1=31074&r2=31075&view=diff
==============================================================================
--- trunk/src/gui/widgets/settings.hpp (original)
+++ trunk/src/gui/widgets/settings.hpp Tue Nov 25 20:07:06 2008
@@ -40,23 +40,31 @@
ADDON_CONNECT, /**< The addon server connection dialog. */
LANGUAGE_SELECTION, /**< The language selection dialog. */
MESSAGE, /**< A generic message dialog. */
+ WML_MESSAGE_LEFT, /**<
+ * A WML message dialog with the portrait on
+ * the left side.
+ */
+ WML_MESSAGE_RIGHT, /**<
+ * A WML message dialog with the portrait on
+ * the right side.
+ */
MP_CONNECT, /**< The mp server connection dialog. */
MP_METHOD_SELECTION, /**<
* The dialog which allows you to choose the
kind
* mp game the user wants to play.
- */
+ */
MP_SERVER_LIST, /**< The mp server list dialog. */
MP_CREATE_GAME, /**< The mp creation dialog. */
#ifndef DISABLE_EDITOR2
EDITOR_NEW_MAP, /**< New map dialog. */
EDITOR_GENERATE_MAP, /**< Editor random map genarator dialog. */
- EDITOR_RESIZE_MAP, /**< Editor resize map dialog. */
- EDITOR_SETTINGS, /**< Editor settings dialog. */
+ EDITOR_RESIZE_MAP, /**< Editor resize map dialog. */
+ EDITOR_SETTINGS, /**< Editor settings dialog. */
#endif
COUNT /**<
- * The last one to
hold the number of items and as
- * sentinel.
- */
+ * The last one to hold the number of items
and as
+ * sentinel.
+ */
};
const std::string& get_id(const twindow_type window_type);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits