This commit is contained in:
ln-zookeeper 2014-02-19 18:22:31 +02:00
commit 53674ac5fd
18 changed files with 467 additions and 61 deletions

View file

@ -28,11 +28,17 @@ Version 1.11.9+dev:
* Fixed bug #21584: Properly redraw the minimap when the minimap is
resized.
* Fixed: Enable blurring in the title screen.
* Added descriptions to the options in Preferences -> Display -> Themes.
* WML engine:
* WML loading phase errors are reported to stderr in a new indented format.
* Implemented [true] and [false] ConditionalWML tags, which describe a
condition that always yields true or false, respectively.
* Fixed: Disallow change and remove sections without an id in the ThemeWML.
* Added [theme] description attribute for including a description of the
theme that will be displayed in Preferences.
* [theme] name attribute is now expected to be translatable and used only
for the theme selection UI. Existing [theme]s need to be converted to
have a separate 'id' attribute.
* Miscellaneous and bug fixes:
* Fixed: A compilation warning with DEBUG_WINDOW_LAYOUT_GRAPHS.
* Added -Wold-style-cast to the CMake strict flags.

View file

@ -554,6 +554,22 @@
facing=sw
[/unit]
[move_unit_fake]
type=Gryphon Master
side=6
x=38,41
y=22,22
[/move_unit_fake]
[unit]
type=Gryphon Master
x=41
y=22
side=6
generate_name=yes
random_traits=yes
[/unit]
[move_unit_fake]
type=Gryphon Master
side=6
@ -573,21 +589,11 @@
[/modifications]
[/unit]
[move_unit_fake]
type=Gryphon Master
side=6
x=38,41
y=22,22
[/move_unit_fake]
[unit]
type=Gryphon Master
x=41
y=22
side=6
generate_name=yes
random_traits=yes
[/unit]
{ATTACK_ANIM gryphon1 warrior1 yes 16 16}
{ATTACK_ANIM warrior1 gryphon1 no 0 ()}
{ATTACK_ANIM gryphon1 warrior1 yes 16 16}
{ATTACK_ANIM warrior1 gryphon1 yes 10 10}
{ATTACK_ANIM warrior1 gryphon1 no 0 ()}
[move_unit_fake]
type=Gryphon Master
@ -609,6 +615,15 @@
facing=sw
[/unit]
{ATTACK_ANIM gryphon2 warrior1 yes 16 16}
{ATTACK_ANIM warrior1 gryphon2 no 0 ()}
{ATTACK_ANIM gryphon2 warrior1 yes 7 7}
[kill]
id=warrior1
animate=yes
[/kill]
[message]
speaker=Howgarth III
message= _ "Kapoue, it is essential that I make it back to my camp to bring news of our agreement and this treachery. One of my gryphon riders will take me. My bodyguards and the rest of my gryphons will help you fight free of this ambush. Once you get back to your camp, we will make a joint assault on these traitors. Once they are dead and dispersed, then I trust you will carry out our agreement."
@ -638,21 +653,6 @@
variable=stored_Hogwarth
[/unstore_unit]
{ATTACK_ANIM gryphon1 warrior1 yes 16 16}
{ATTACK_ANIM warrior1 gryphon1 no 0 ()}
{ATTACK_ANIM gryphon1 warrior1 yes 16 16}
{ATTACK_ANIM warrior1 gryphon1 yes 10 10}
{ATTACK_ANIM warrior1 gryphon1 no 0 ()}
{ATTACK_ANIM gryphon2 warrior1 yes 16 16}
{ATTACK_ANIM warrior1 gryphon2 no 0 ()}
{ATTACK_ANIM gryphon2 warrior1 yes 7 7}
[kill]
id=warrior1
animate=yes
[/kill]
[message]
speaker=Shan Taum
message= _ "Blast! The human has escaped. Orcs, bring me Kapoues head. I must get to my camp and assault the city."

View file

@ -102,6 +102,7 @@
{_GUI_DEFINITION "default_large" "default, large font size" LARGE () DEFAULT ({GUI__TEXT_VERTICALLY_CENTRED})}
{_GUI_DEFINITION "default_small" "default, small font size" SMALL () DEFAULT ({GUI__TEXT_VERTICALLY_CENTRED})}
{_GUI_DEFINITION "default_tiny" "default, small font size" TINY () DEFAULT ({GUI__TEXT_VERTICALLY_CENTRED})}
{_GUI_DEFINITION "gold_small" "small gold label" SMALL () TITLE ({GUI__TEXT_VERTICALLY_CENTRED})}
#undef _GUI_DEFINITION
#undef _GUI_RESOLUTION

View file

@ -0,0 +1,189 @@
#textdomain wesnoth-lib
###
### Definition of the window to select a GUI theme.
###
[window]
id = "theme_list"
description = "GUI theme selection dialog."
[resolution]
definition = "default"
automatic_placement = "true"
vertical_placement = "center"
horizontal_placement = "center"
maximum_width = 600
maximum_height = 600
[linked_group]
id = "name"
fixed_width = "true"
[/linked_group]
[linked_group]
id = "description"
fixed_width = "true"
[/linked_group]
[tooltip]
id = "tooltip_large"
[/tooltip]
[helptip]
id = "tooltip_large"
[/helptip]
[grid]
[row]
grow_factor = 0
[column]
grow_factor = 1
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "title"
label = _ "Choose Theme"
[/label]
[/column]
[/row]
[row]
grow_factor = 0
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "default"
label = _ "The new theme will take effect after loading or starting a new game."
wrap = true
[/label]
[/column]
[/row]
[row]
grow_factor = 1
[column]
horizontal_grow = "true"
vertical_grow = "true"
border = "all"
border_size = 5
[listbox]
id = "themes"
definition = "default"
[list_definition]
[row]
[column]
vertical_grow = "true"
horizontal_grow = "true"
[toggle_panel]
definition = "default"
return_value_id = "ok"
[grid]
[row]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[label]
id = "name"
definition = "default"
linked_group = "name"
[/label]
[/column]
[/row]
[row]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[label]
id = "description"
definition = "gold_small"
linked_group = "description"
[/label]
[/column]
[/row]
[/grid]
[/toggle_panel]
[/column]
[/row]
[/list_definition]
[/listbox]
[/column]
[/row]
[row]
grow_factor = 0
[column]
horizontal_alignment = "right"
[grid]
[row]
grow_factor = 0
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "ok"
definition = "default"
label = _ "OK"
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "cancel"
definition = "default"
label = _ "Cancel"
[/button]
[/column]
[/row]
[/grid]
[/column]
[/row]
[/grid]
[/resolution]
[/window]

View file

@ -7,7 +7,9 @@
# http://www.wesnoth.org/forum/viewtopic.php?p=213708#213708
[theme]
name=Default
id=Default
name= _ "theme^Default"
description= _ "Default theme."
#define DEFAULT_FONT_NORMAL
14 #enddef

View file

@ -7,7 +7,8 @@
# http://www.wesnoth.org/forum/viewtopic.php?p=213708#213708
[theme]
name=editor
id=editor
name= _ "theme^Editor"
hidden=yes
#define DEFAULT_EDITOR_FONT_NORMAL

View file

@ -5,7 +5,7 @@
#
[theme]
name=null
id=null
hidden=yes
[resolution]
width=1

View file

@ -18,7 +18,9 @@
{themes/macros.cfg}
[theme]
name=Pandora
id=Pandora
name= _ "theme^Pandora"
description= _ "800x480 theme optimized for Pandora devices."
[resolution]
id=800x480

View file

@ -7,7 +7,9 @@
# http://www.wesnoth.org/forum/viewtopic.php?p=213708#213708
[theme]
name=UnitBox
id=UnitBox
name= _ "theme^UnitBox"
description= _ "Experimental work-in-progress replacement for the default theme."
#define DEFAULT_FONT_NORMAL
14 #enddef

View file

@ -7,7 +7,9 @@
# http://www.wesnoth.org/forum/viewtopic.php?p=213708#213708
[theme]
name=Widescreen
id=Widescreen
name= _ "theme^Widescreen"
description= _ "Experimental theme optimized for widescreen resolutions."
#define DEFAULT_FONT_NORMAL
14 #enddef

View file

@ -780,6 +780,7 @@ set(wesnoth-main_SRC
gui/dialogs/popup.cpp
gui/dialogs/edit_text.cpp
gui/dialogs/simple_item_selector.cpp
gui/dialogs/theme_list.cpp
gui/dialogs/title_screen.cpp
gui/dialogs/transient_message.cpp
gui/dialogs/unit_attack.cpp

View file

@ -389,6 +389,7 @@ wesnoth_sources = Split("""
gui/dialogs/popup.cpp
gui/dialogs/edit_text.cpp
gui/dialogs/simple_item_selector.cpp
gui/dialogs/theme_list.cpp
gui/dialogs/tip.cpp
gui/dialogs/title_screen.cpp
gui/dialogs/transient_message.cpp

View file

@ -331,12 +331,20 @@ const config& controller_base::get_theme(const config& game_config, std::string
{
if (theme_name.empty()) theme_name = preferences::theme();
if (const config &c = game_config.find_child("theme", "name", theme_name))
if (const config &c = game_config.find_child("theme", "id", theme_name))
return c;
// Themes created for version 1.11.9 and earlier use name= for
// untranslatable ids.
// TODO: remove support for this in 1.13.x (1.13.2?).
if (const config &c = game_config.find_child("theme", "name", theme_name)) {
ERR_DP << "Theme '" << theme_name << "' uses [theme] name= instead of id= to specify its id; this usage is deprecated and will be removed in version 1.13.x.\n";
return c;
}
ERR_DP << "Theme '" << theme_name << "' not found. Trying the default theme.\n";
if (const config &c = game_config.find_child("theme", "name", "Default"))
if (const config &c = game_config.find_child("theme", "id", "Default"))
return c;
ERR_DP << "Default theme not found.\n";

View file

@ -22,8 +22,10 @@
#include "gettext.hpp"
#include "gui/dialogs/game_paths.hpp"
#include "gui/dialogs/simple_item_selector.hpp"
#include "gui/dialogs/theme_list.hpp"
#include "gui/dialogs/transient_message.hpp"
#include "lobby_preferences.hpp"
#include "marked-up_text.hpp"
#include "preferences_display.hpp"
#include "wml_separators.hpp"
#include "widgets/combo.hpp"
@ -1437,12 +1439,13 @@ void show_preferences_dialog(display& disp, const config& game_cfg)
bool show_theme_dialog(display& disp)
{
std::vector<std::string> options = disp.get_theme().get_known_themes();
if(!options.empty()){
gui2::tsimple_item_selector dlg(_("Choose Theme"), "", options);
std::vector<theme_info> themes = disp.get_theme().get_known_themes();
for(size_t k = 0; k < options.size(); ++k) {
if(options[k] == preferences::theme()) {
if(!themes.empty()){
gui2::ttheme_list dlg(themes);
for(size_t k = 0; k < themes.size(); ++k) {
if(themes[k].id == preferences::theme()) {
dlg.set_selected_index(static_cast<int>(k));
}
}
@ -1451,16 +1454,16 @@ bool show_theme_dialog(display& disp)
const int action = dlg.selected_index();
if(action >= 0){
preferences::set_theme(options[action]);
//it would be preferable for the new theme to take effect
//immediately, however, this will have to do for now.
gui2::show_transient_message(disp.video(),"",_("New theme will take effect on next new or loaded game."));
return(1);
preferences::set_theme(themes[action].id);
// FIXME: it would be preferable for the new theme to take effect
// immediately.
return 1;
}
}else{
} else {
gui2::show_transient_message(disp.video(),"",_("No known themes. Try changing from within an existing game."));
}
return(0);
return 0;
}
void show_paths_dialog(display& disp)

View file

@ -0,0 +1,102 @@
/*
Copyright (C) 2014 by Ignacio Riquelme Morelle <shadowm2006@gmail.com>
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 as published by
the Free Software Foundation; either version 2 of the License, 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/theme_list.hpp"
#include "gui/auxiliary/find_widget.tpp"
#ifdef GUI2_EXPERIMENTAL_LISTBOX
#include "gui/widgets/list.hpp"
#else
#include "gui/widgets/listbox.hpp"
#endif
#include "gui/widgets/settings.hpp"
#include "gui/widgets/window.hpp"
#include "theme.hpp"
#include "utils/foreach.tpp"
namespace gui2
{
/*WIKI
* @page = GUIWindowDefinitionWML
* @order = 2_theme_list
*
* == Theme list ==
*
* Dialog for selecting a GUI theme.
*
* @begin{table}{dialog_widgets}
*
* themes & & listbox & m &
* Listbox displaying user choices. $
*
* -name & & control & m &
* Widget which shows a theme item name. $
*
* -description & & control & m &
* Widget which shows a theme item description. $
*
* @end{table}
*/
REGISTER_DIALOG(theme_list)
ttheme_list::ttheme_list(const std::vector<theme_info>& themes,
int selection)
: index_(selection)
, themes_(themes)
{
}
void ttheme_list::pre_show(CVideo& /*video*/, twindow& window)
{
tlistbox& list = find_widget<tlistbox>(&window, "themes", false);
window.keyboard_capture(&list);
FOREACH(const AUTO & t, themes_)
{
std::map<std::string, string_map> data;
string_map column;
std::string theme_name = t.name;
if(theme_name.empty()) {
theme_name = t.id;
}
column["label"] = theme_name;
data.insert(std::make_pair("name", column));
column["label"] = t.description;
data.insert(std::make_pair("description", column));
list.add_row(data);
}
if(index_ != -1 && static_cast<unsigned>(index_) < list.get_item_count()) {
list.select_row(index_);
}
index_ = -1;
}
void ttheme_list::post_show(twindow& window)
{
if(get_retval() != twindow::OK) {
return;
}
tlistbox& list = find_widget<tlistbox>(&window, "themes", false);
index_ = list.get_selected_row();
}
}

View file

@ -0,0 +1,63 @@
/*
Copyright (C) 2014 by Ignacio Riquelme Morelle <shadowm2006@gmail.com>
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 as published by
the Free Software Foundation; either version 2 of the License, 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_THEME_LIST_HPP_INCLUDED
#define GUI_DIALOGS_THEME_LIST_HPP_INCLUDED
#include "gui/dialogs/dialog.hpp"
struct theme_info;
namespace gui2
{
class ttheme_list : public tdialog
{
public:
explicit ttheme_list(const std::vector<theme_info>& themes,
int selection = -1);
/**
* Returns the selected item index after displaying.
* @return -1 if the dialog was canceled.
*/
int selected_index() const
{
return index_;
}
/** Sets the initially selected item index (-1 by default). */
void set_selected_index(int index)
{
index_ = index;
}
private:
int index_;
std::vector<theme_info> themes_;
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
/** Inherited from tdialog. */
void pre_show(CVideo& video, twindow& window);
/** Inherited from tdialog. */
void post_show(twindow& window);
};
}
#endif

View file

@ -904,7 +904,9 @@ const theme::status_item* theme::get_status_item(const std::string& key) const
return NULL;
}
std::map<std::string, config> theme::known_themes;
typedef std::map<std::string, config> known_themes_map;
known_themes_map theme::known_themes;
void theme::set_known_themes(const config* cfg)
{
known_themes.clear();
@ -913,20 +915,34 @@ void theme::set_known_themes(const config* cfg)
BOOST_FOREACH(const config &thm, cfg->child_range("theme"))
{
std::string thm_name = thm["name"];
if (!thm["hidden"].to_bool(false))
known_themes[thm_name] = thm;
std::string thm_id = thm["id"];
if (thm_id.empty() && thm.has_attribute("name")) {
thm_id = thm["name"].str();
ERR_DP << "Theme '" << thm_id << "' uses [theme] name= instead of id= to specify its id; this usage is deprecated and will be removed in version 1.13.x.\n";
}
if (!thm["hidden"].to_bool(false)) {
known_themes[thm_id] = thm;
}
}
}
std::vector<std::string> theme::get_known_themes(){
std::vector<std::string> names;
std::vector<theme_info> theme::get_known_themes()
{
std::vector<theme_info> res;
for(known_themes_map::const_iterator i = known_themes.begin();
i != known_themes.end();
++i)
{
res.push_back(theme_info());
res.back().id = i->first;
res.back().name = i->second["name"].t_str();
res.back().description = i->second["description"].t_str();
}
for(std::map<std::string, config>::iterator p_thm=known_themes.begin();p_thm!=known_themes.end();++p_thm){
names.push_back(p_thm->first);
}
return(names);
return res;
}
const theme::menu *theme::get_menu_item(const std::string &key) const

View file

@ -26,6 +26,13 @@
typedef struct { size_t x1,y1,x2,y2; } _rect;
struct theme_info
{
std::string id;
t_string name;
t_string description;
};
class theme
{
@ -279,7 +286,7 @@ public:
{ return palette_.location(screen); }
static void set_known_themes(const config* cfg);
static std::vector<std::string> get_known_themes();
static std::vector<theme_info> get_known_themes();
const tborder& border() const { return border_; }