GUI2: New add-ons description dialog...
...with more details than the description (merge 1)
This commit is contained in:
parent
ed922e9d8f
commit
e7b7abe209
5 changed files with 298 additions and 16 deletions
152
data/gui/default/window/addon_description.cfg
Normal file
152
data/gui/default/window/addon_description.cfg
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
#textdomain wesnoth-lib
|
||||||
|
|
||||||
|
[window]
|
||||||
|
id = "addon_description"
|
||||||
|
description = "Add-on description and details for the add-ons manager interface."
|
||||||
|
|
||||||
|
[resolution]
|
||||||
|
definition = "message"
|
||||||
|
|
||||||
|
click_dismiss = "true"
|
||||||
|
maximum_width = 800
|
||||||
|
|
||||||
|
[grid]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
vertical_alignment = "top"
|
||||||
|
|
||||||
|
[image]
|
||||||
|
id = "image"
|
||||||
|
definition = "default"
|
||||||
|
[/image]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
horizontal_alignment = "left"
|
||||||
|
vertical_alignment = "top"
|
||||||
|
|
||||||
|
[label]
|
||||||
|
id = "title"
|
||||||
|
definition = "title"
|
||||||
|
[/label]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
|
||||||
|
{GUI_FILLER}
|
||||||
|
|
||||||
|
[column]
|
||||||
|
|
||||||
|
horizontal_alignment = "left"
|
||||||
|
|
||||||
|
[grid]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
horizontal_alignment = "left"
|
||||||
|
|
||||||
|
[label]
|
||||||
|
definition = "default"
|
||||||
|
label = _ "Version:"
|
||||||
|
[/label]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
vertical_alignment = "top"
|
||||||
|
horizontal_alignment = "left"
|
||||||
|
|
||||||
|
[label]
|
||||||
|
id = "version"
|
||||||
|
definition = "default"
|
||||||
|
[/label]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
grow_factor = 1
|
||||||
|
|
||||||
|
[column]
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
horizontal_alignment = "left"
|
||||||
|
|
||||||
|
[label]
|
||||||
|
definition = "default"
|
||||||
|
label = _ "Description:"
|
||||||
|
[/label]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
vertical_alignment = "top"
|
||||||
|
horizontal_alignment = "left"
|
||||||
|
|
||||||
|
[scroll_label]
|
||||||
|
id = "description"
|
||||||
|
definition = "default"
|
||||||
|
[/scroll_label]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[row]
|
||||||
|
grow_factor = 1
|
||||||
|
|
||||||
|
[column]
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
horizontal_alignment = "left"
|
||||||
|
|
||||||
|
[label]
|
||||||
|
definition = "default"
|
||||||
|
label = _ "Translations:"
|
||||||
|
[/label]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[column]
|
||||||
|
border = "all"
|
||||||
|
border_size = 5
|
||||||
|
vertical_alignment = "top"
|
||||||
|
horizontal_alignment = "left"
|
||||||
|
|
||||||
|
[scroll_label]
|
||||||
|
id = "translations"
|
||||||
|
definition = "default"
|
||||||
|
[/scroll_label]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[/grid]
|
||||||
|
|
||||||
|
[/column]
|
||||||
|
|
||||||
|
[/row]
|
||||||
|
|
||||||
|
[/grid]
|
||||||
|
|
||||||
|
[/resolution]
|
||||||
|
|
||||||
|
[/window]
|
||||||
|
|
|
@ -342,6 +342,7 @@ wesnoth_sources = Split("""
|
||||||
gui/auxiliary/window_builder.cpp
|
gui/auxiliary/window_builder.cpp
|
||||||
gui/dialogs/addon_connect.cpp
|
gui/dialogs/addon_connect.cpp
|
||||||
gui/dialogs/addon_list.cpp
|
gui/dialogs/addon_list.cpp
|
||||||
|
gui/dialogs/addon/description.cpp
|
||||||
gui/dialogs/campaign_difficulty.cpp
|
gui/dialogs/campaign_difficulty.cpp
|
||||||
gui/dialogs/campaign_selection.cpp
|
gui/dialogs/campaign_selection.cpp
|
||||||
gui/dialogs/data_manage.cpp
|
gui/dialogs/data_manage.cpp
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "gettext.hpp"
|
#include "gettext.hpp"
|
||||||
#include "gui/dialogs/addon_connect.hpp"
|
#include "gui/dialogs/addon_connect.hpp"
|
||||||
#include "gui/dialogs/addon_list.hpp"
|
#include "gui/dialogs/addon_list.hpp"
|
||||||
|
#include "gui/dialogs/addon/description.hpp"
|
||||||
#include "gui/dialogs/message.hpp"
|
#include "gui/dialogs/message.hpp"
|
||||||
#include "gui/dialogs/simple_item_selector.hpp"
|
#include "gui/dialogs/simple_item_selector.hpp"
|
||||||
#include "gui/dialogs/transient_message.hpp"
|
#include "gui/dialogs/transient_message.hpp"
|
||||||
|
@ -329,14 +330,13 @@ namespace {
|
||||||
class display_description : public gui::dialog_button_action
|
class display_description : public gui::dialog_button_action
|
||||||
{
|
{
|
||||||
display& disp_;
|
display& disp_;
|
||||||
std::vector<std::string> titles_, desc_;
|
std::vector<addon_info> infov_;
|
||||||
gui::filter_textbox* filter_;
|
gui::filter_textbox* filter_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
display_description(display& disp, std::vector<std::string> const& titles, std::vector<std::string> const& descriptions, gui::filter_textbox* filter)
|
display_description(display& disp, std::vector<addon_info> const& infov, gui::filter_textbox* filter)
|
||||||
: disp_(disp)
|
: disp_(disp)
|
||||||
, titles_(titles)
|
, infov_(infov)
|
||||||
, desc_(descriptions)
|
|
||||||
, filter_(filter)
|
, filter_(filter)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
@ -347,18 +347,10 @@ namespace {
|
||||||
if(menu_selection < 0) { return gui::CONTINUE_DIALOG; }
|
if(menu_selection < 0) { return gui::CONTINUE_DIALOG; }
|
||||||
size_t const uchoice = static_cast<size_t>(menu_selection);
|
size_t const uchoice = static_cast<size_t>(menu_selection);
|
||||||
|
|
||||||
std::string text;
|
if(uchoice < infov_.size()) {
|
||||||
std::string title;
|
gui2::taddon_description ddlg(infov_[uchoice]);
|
||||||
|
ddlg.show(disp_.video());
|
||||||
if(uchoice >= desc_.size()) {
|
|
||||||
text = _("No description available.");
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
title = titles_[uchoice];
|
|
||||||
text = desc_[uchoice];
|
|
||||||
}
|
|
||||||
|
|
||||||
gui2::show_transient_message(disp_.video(), title, text);
|
|
||||||
|
|
||||||
return gui::CONTINUE_DIALOG;
|
return gui::CONTINUE_DIALOG;
|
||||||
}
|
}
|
||||||
|
@ -1161,6 +1153,8 @@ namespace {
|
||||||
|
|
||||||
std::vector< std::string > delete_options;
|
std::vector< std::string > delete_options;
|
||||||
|
|
||||||
|
std::vector< addon_info > infos;
|
||||||
|
|
||||||
foreach(const config &c, addon_cfgs)
|
foreach(const config &c, addon_cfgs)
|
||||||
{
|
{
|
||||||
const std::string& name = c["name"];
|
const std::string& name = c["name"];
|
||||||
|
@ -1171,10 +1165,15 @@ namespace {
|
||||||
const ADDON_TYPE type = get_addon_type(type_str);
|
const ADDON_TYPE type = get_addon_type(type_str);
|
||||||
const std::string& type_label_str = get_translatable_addon_type(type);
|
const std::string& type_label_str = get_translatable_addon_type(type);
|
||||||
|
|
||||||
|
addon_info inf;
|
||||||
|
|
||||||
addons.push_back(name);
|
addons.push_back(name);
|
||||||
versions.push_back(c["version"]);
|
versions.push_back(c["version"]);
|
||||||
uploads.push_back(c["uploads"]);
|
uploads.push_back(c["uploads"]);
|
||||||
descriptions.push_back(c["description"]);
|
descriptions.push_back(c["description"]);
|
||||||
|
|
||||||
|
inf.description = c["description"];
|
||||||
|
|
||||||
types.push_back(type_str);
|
types.push_back(type_str);
|
||||||
|
|
||||||
if(std::count(publish_options.begin(), publish_options.end(), name) != 0) {
|
if(std::count(publish_options.begin(), publish_options.end(), name) != 0) {
|
||||||
|
@ -1188,14 +1187,20 @@ namespace {
|
||||||
}
|
}
|
||||||
titles.push_back(title);
|
titles.push_back(title);
|
||||||
|
|
||||||
|
inf.name = title;
|
||||||
|
|
||||||
std::string version = c["version"], author = c["author"];
|
std::string version = c["version"], author = c["author"];
|
||||||
|
|
||||||
|
inf.version = version;
|
||||||
|
|
||||||
//add negative sizes to reverse the sort order
|
//add negative sizes to reverse the sort order
|
||||||
sizes.push_back(-size);
|
sizes.push_back(-size);
|
||||||
|
|
||||||
std::string icon = c["icon"];
|
std::string icon = c["icon"];
|
||||||
do_addon_icon_fixups(icon, name);
|
do_addon_icon_fixups(icon, name);
|
||||||
|
|
||||||
|
inf.icon = icon;
|
||||||
|
|
||||||
std::string text_columns =
|
std::string text_columns =
|
||||||
title + COLUMN_SEPARATOR +
|
title + COLUMN_SEPARATOR +
|
||||||
version + COLUMN_SEPARATOR +
|
version + COLUMN_SEPARATOR +
|
||||||
|
@ -1221,6 +1226,13 @@ namespace {
|
||||||
sizef + COLUMN_SEPARATOR;
|
sizef + COLUMN_SEPARATOR;
|
||||||
|
|
||||||
options.push_back(text_columns);
|
options.push_back(text_columns);
|
||||||
|
|
||||||
|
config::const_child_itors const& linguas = c.child_range("translation");
|
||||||
|
for(config::const_child_iterator i = linguas.first; i != linguas.second; ++i) {
|
||||||
|
inf.translations.push_back((*i)["language"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
infos.push_back(inf);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string pub_option_text, del_option_text;
|
std::string pub_option_text, del_option_text;
|
||||||
|
@ -1270,7 +1282,7 @@ namespace {
|
||||||
_("Filter: "), options, options_to_filter, 1, addon_dialog, 300);
|
_("Filter: "), options, options_to_filter, 1, addon_dialog, 300);
|
||||||
addon_dialog.set_textbox(filter);
|
addon_dialog.set_textbox(filter);
|
||||||
|
|
||||||
display_description description_helper(disp, titles, descriptions, filter);
|
display_description description_helper(disp, infos, filter);
|
||||||
|
|
||||||
gui::dialog_button* description = new gui::dialog_button(disp.video(), _("Description"), gui::button::TYPE_PRESS, gui::CONTINUE_DIALOG, &description_helper);
|
gui::dialog_button* description = new gui::dialog_button(disp.video(), _("Description"), gui::button::TYPE_PRESS, gui::CONTINUE_DIALOG, &description_helper);
|
||||||
addon_dialog.add_button(description, gui::dialog::BUTTON_EXTRA);
|
addon_dialog.add_button(description, gui::dialog::BUTTON_EXTRA);
|
||||||
|
|
64
src/gui/dialogs/addon/description.cpp
Normal file
64
src/gui/dialogs/addon/description.cpp
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
/* $Id$ */
|
||||||
|
/*
|
||||||
|
Copyright (C) 2010 by Ignacio R. 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define GETTEXT_DOMAIN "wesnoth-lib"
|
||||||
|
|
||||||
|
#include "gui/dialogs/addon/description.hpp"
|
||||||
|
|
||||||
|
#include "foreach.hpp"
|
||||||
|
#include "gui/widgets/settings.hpp"
|
||||||
|
#include "gui/widgets/window.hpp"
|
||||||
|
#include "language.hpp"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
t_string langcode_to_tstring(const std::string& lcode)
|
||||||
|
{
|
||||||
|
foreach(const language_def& ld, get_languages()) {
|
||||||
|
if(ld.localename == lcode) {
|
||||||
|
return ld.language;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace gui2 {
|
||||||
|
|
||||||
|
REGISTER_WINDOW(addon_description)
|
||||||
|
|
||||||
|
void taddon_description::pre_show(CVideo& /*video*/, twindow& window)
|
||||||
|
{
|
||||||
|
const std::string fixed_icon = ainfo_.icon + "~SCALE(72,72)";
|
||||||
|
find_widget<tcontrol>(&window, "image", false).set_label(fixed_icon);
|
||||||
|
|
||||||
|
find_widget<tcontrol>(&window, "title", false).set_label(ainfo_.name);
|
||||||
|
find_widget<tcontrol>(&window, "description", false).set_label(ainfo_.description);
|
||||||
|
find_widget<tcontrol>(&window, "version", false).set_label(ainfo_.version);
|
||||||
|
|
||||||
|
std::string languages;
|
||||||
|
|
||||||
|
foreach(const std::string& lc, ainfo_.translations) {
|
||||||
|
if(languages.empty() == false) {
|
||||||
|
languages += ", ";
|
||||||
|
}
|
||||||
|
languages += langcode_to_tstring(lc);
|
||||||
|
}
|
||||||
|
|
||||||
|
find_widget<tcontrol>(&window, "translations", false).set_label(languages);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
53
src/gui/dialogs/addon/description.hpp
Normal file
53
src/gui/dialogs/addon/description.hpp
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/* $Id$ */
|
||||||
|
/*
|
||||||
|
Copyright (C) 2010 by Ignacio R. 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_ADDON_DESCRIPTION_HPP_INCLUDED
|
||||||
|
#define GUI_DIALOGS_ADDON_DESCRIPTION_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include "gui/dialogs/dialog.hpp"
|
||||||
|
#include "tstring.hpp"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
struct addon_info
|
||||||
|
{
|
||||||
|
t_string name;
|
||||||
|
t_string description;
|
||||||
|
std::string icon;
|
||||||
|
std::string version;
|
||||||
|
std::vector<std::string> translations;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace gui2 {
|
||||||
|
|
||||||
|
class taddon_description : public tdialog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
taddon_description(const addon_info& ainfo)
|
||||||
|
: ainfo_(ainfo) {}
|
||||||
|
|
||||||
|
/** Inherited from tdialog, implemented by REGISTER_WINDOW. */
|
||||||
|
virtual const std::string& window_id() const;
|
||||||
|
|
||||||
|
/** Inherited from tdialog. */
|
||||||
|
void pre_show(CVideo& video, twindow& window);
|
||||||
|
|
||||||
|
private:
|
||||||
|
addon_info ainfo_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Reference in a new issue