mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-03 18:17:20 +00:00
gui2/taddon_description: Display add-on status information in this dialog
The exact presentation isn't yet final, and the code isn't too elegant either, but the way it is right now should be more or less easy for translators to handle. The coloring is an experiment and it'll be removed if people don't like it.
This commit is contained in:
parent
ced3354d27
commit
35504da204
@ -135,6 +135,36 @@
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
vertical_alignment = "top"
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "default"
|
||||
label = _ "Status:"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
vertical_alignment = "top"
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
id = "status"
|
||||
definition = "default"
|
||||
[/label]
|
||||
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[row]
|
||||
grow_factor = 1
|
||||
|
||||
|
@ -281,11 +281,12 @@ class description_display_action : public gui::dialog_button_action
|
||||
display& disp_;
|
||||
std::vector<std::string> display_ids_;
|
||||
addons_list addons_;
|
||||
std::map<std::string, addon_tracking_info> tracking_;
|
||||
gui::filter_textbox* filter_;
|
||||
|
||||
public:
|
||||
description_display_action(display& disp, const std::vector<std::string>& display_ids, const addons_list& addons, gui::filter_textbox* filter)
|
||||
: disp_(disp) , display_ids_(display_ids), addons_(addons), filter_(filter)
|
||||
description_display_action(display& disp, const std::vector<std::string>& display_ids, const addons_list& addons, const std::map<std::string, addon_tracking_info>& tracking, gui::filter_textbox* filter)
|
||||
: disp_(disp) , display_ids_(display_ids), addons_(addons), tracking_(tracking), filter_(filter)
|
||||
{}
|
||||
|
||||
virtual gui::dialog_button_action::RESULT button_pressed(int filter_choice)
|
||||
@ -297,7 +298,9 @@ public:
|
||||
|
||||
const size_t choice = static_cast<size_t>(menu_selection);
|
||||
if(choice < display_ids_.size()) {
|
||||
gui2::taddon_description::display(addons_[display_ids_[choice]], disp_.video());
|
||||
const std::string& id = display_ids_[choice];
|
||||
assert(tracking_.find(id) != tracking_.end());
|
||||
gui2::taddon_description::display(addons_[id], tracking_[id], disp_.video());
|
||||
}
|
||||
|
||||
return gui::CONTINUE_DIALOG;
|
||||
@ -484,7 +487,7 @@ void show_addons_manager_dialog(display& disp, addons_client& client, addons_lis
|
||||
_("Filter: "), options, filter_options, 1, dlg, 300);
|
||||
dlg.set_textbox(filter_box);
|
||||
|
||||
description_display_action description_helper(disp, option_ids, addons, filter_box);
|
||||
description_display_action description_helper(disp, option_ids, addons, tracking, filter_box);
|
||||
gui::dialog_button* description_button = new gui::dialog_button(disp.video(),
|
||||
_("Description"), gui::button::TYPE_PRESS, gui::CONTINUE_DIALOG, &description_helper);
|
||||
dlg.add_button(description_button, gui::dialog::BUTTON_EXTRA);
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "gui/dialogs/addon/description.hpp"
|
||||
|
||||
#include "foreach.hpp"
|
||||
#include "formula_string_utils.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "language.hpp"
|
||||
|
||||
@ -32,6 +34,75 @@ namespace {
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string describe_addon_state_info(const addon_tracking_info& state)
|
||||
{
|
||||
std::string s;
|
||||
|
||||
utils::string_map i18n_symbols;
|
||||
i18n_symbols["local_version"] = state.installed_version.str();
|
||||
|
||||
switch(state.state) {
|
||||
case ADDON_NONE:
|
||||
if(!state.can_publish) {
|
||||
s += _("addon_state^Not installed");
|
||||
} else {
|
||||
s += _("addon_state^Published");
|
||||
}
|
||||
break;
|
||||
case ADDON_INSTALLED:
|
||||
s += "<span color='green'>";
|
||||
if(!state.can_publish) {
|
||||
s += _("addon_state^Installed");
|
||||
} else {
|
||||
s += _("addon_state^Published");
|
||||
}
|
||||
s += "</span>";
|
||||
break;
|
||||
case ADDON_INSTALLED_UPGRADABLE:
|
||||
s += "<span color='yellow'>";
|
||||
{
|
||||
const char* const vstr = !state.can_publish
|
||||
? _("addon_state^Installed, server updated ($local_version|)")
|
||||
: _("addon_state^Published, server updated ($local_version|)");
|
||||
s += utils::interpolate_variables_into_string(vstr, &i18n_symbols);
|
||||
}
|
||||
s += "</span>";
|
||||
break;
|
||||
case ADDON_INSTALLED_OUTDATED:
|
||||
s += "<span color='orange'>";
|
||||
{
|
||||
const char* const vstr = !state.can_publish
|
||||
? _("addon_state^Installed, server outdated ($local_version|)")
|
||||
: _("addon_state^Published, server outdated ($local_version|)");
|
||||
s += utils::interpolate_variables_into_string(vstr, &i18n_symbols);
|
||||
}
|
||||
s += "</span>";
|
||||
break;
|
||||
case ADDON_INSTALLED_BROKEN:
|
||||
s += "<span color='red'>";
|
||||
if(!state.can_publish) {
|
||||
s += _("addon_state^Installed, broken");
|
||||
} else {
|
||||
s += _("addon_state^Published, broken");
|
||||
}
|
||||
s += "</span>";
|
||||
break;
|
||||
default:
|
||||
if(!state.can_publish) {
|
||||
s += "<span color='red'>";
|
||||
s += _("addon_state^Not tracked");
|
||||
} else {
|
||||
// Published add-ons often don't have local status information,
|
||||
// hence untracked. This should be considered normal.
|
||||
s += "<span color='green'>";
|
||||
s += _("addon_state^Published");
|
||||
}
|
||||
s += "</span>";
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
namespace gui2 {
|
||||
@ -55,6 +126,9 @@ namespace gui2 {
|
||||
* version & & control & m &
|
||||
* Label for displaying the add-on version number. $
|
||||
*
|
||||
* status & & control & m &
|
||||
* Label for displaying the current installation/upgradability status. $
|
||||
*
|
||||
* author & & control & m &
|
||||
* Label for displaying the add-on author/maintainer name. $
|
||||
*
|
||||
@ -77,11 +151,12 @@ namespace gui2 {
|
||||
|
||||
REGISTER_DIALOG(addon_description)
|
||||
|
||||
taddon_description::taddon_description(const addon_info& addon)
|
||||
taddon_description::taddon_description(const addon_info& addon, const addon_tracking_info& state)
|
||||
{
|
||||
register_label("image", true, addon.display_icon());
|
||||
register_label("title", true, addon.title);
|
||||
register_label("version", true, addon.version);
|
||||
register_label("status", true, describe_addon_state_info(state), true);
|
||||
register_label("author", true, addon.author);
|
||||
register_label("size", true, size_display_string(addon.size));
|
||||
if(!addon.description.empty()) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "gui/dialogs/dialog.hpp"
|
||||
|
||||
#include "addon/info.hpp"
|
||||
#include "addon/state.hpp"
|
||||
|
||||
namespace gui2 {
|
||||
|
||||
@ -31,12 +32,12 @@ public:
|
||||
*
|
||||
* @param addon The information about the addon to show.
|
||||
*/
|
||||
explicit taddon_description(const addon_info& addon);
|
||||
taddon_description(const addon_info& addon, const addon_tracking_info& state);
|
||||
|
||||
/** The display function see @ref tdialog for more information. */
|
||||
static void display(const addon_info& addon, CVideo& video)
|
||||
static void display(const addon_info& addon, const addon_tracking_info& state, CVideo& video)
|
||||
{
|
||||
taddon_description(addon).show(video);
|
||||
taddon_description(addon, state).show(video);
|
||||
}
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user