From 308d29ec0765c9e3ba4840a4f22882d3a00c31f2 Mon Sep 17 00:00:00 2001 From: "Ignacio R. Morelle" Date: Thu, 24 Sep 2009 21:35:18 +0000 Subject: [PATCH] Disable (gray out) the Update and Remove add-ons options... ...in the connection dialog when there are no add-ons installed. --- changelog | 2 ++ data/gui/default/window/addon_connect.cfg | 4 ++++ players_changelog | 2 ++ src/addon_management.cpp | 3 +++ src/gui/dialogs/addon_connect.cpp | 7 +++++++ src/gui/dialogs/addon_connect.hpp | 19 +++++++++++++++++++ 6 files changed, 37 insertions(+) diff --git a/changelog b/changelog index ea0853a43f4..98d20065e34 100644 --- a/changelog +++ b/changelog @@ -39,6 +39,8 @@ Version 1.7.5+svn: * Better visually differentiate name, type and race in sidebar * Add colorized terrain defense info in sidebar * In attack dialog, split damages and chance to hit and color the later. + * The Remove and Update add-ons options are disabled when there are no + add-ons installed * WML engine: * Fix silent=yes for objectives * Allow [story] [part] blocks to specify the title box alignment diff --git a/data/gui/default/window/addon_connect.cfg b/data/gui/default/window/addon_connect.cfg index c0fef2df34d..5be7148dc7c 100644 --- a/data/gui/default/window/addon_connect.cfg +++ b/data/gui/default/window/addon_connect.cfg @@ -127,6 +127,8 @@ horizontal_alignment = "left" [button] + id = "update_addons" + # just show how the default looks. definition = "default" @@ -158,6 +160,8 @@ horizontal_alignment = "right" [button] + id = "remove_addons" + # just show how the default looks. definition = "default" diff --git a/players_changelog b/players_changelog index 7a68afa13bc..c72cb14fc2e 100644 --- a/players_changelog +++ b/players_changelog @@ -32,6 +32,8 @@ Version 1.7.5+svn: * Better visually differentiate name, type and race in sidebar. * Add colorized terrain defense info in sidebar. * In attack dialog, split damages and chance to hit and color the later. + * Disable the Remove and Update add-ons buttons when there are no add-ons + installed. Version 1.7.5: diff --git a/src/addon_management.cpp b/src/addon_management.cpp index f36913ad3b9..f3c368a4c21 100644 --- a/src/addon_management.cpp +++ b/src/addon_management.cpp @@ -1179,10 +1179,13 @@ void manage_addons(game_display& disp) bool do_refresh = false; std::string remote_host; const std::string default_host = preferences::campaign_server(); + const bool have_addons = !installed_addons().empty(); gui2::taddon_connect addon_dlg; addon_dlg.set_host_name(default_host); + addon_dlg.set_allow_remove(have_addons); + addon_dlg.set_allow_updates(have_addons); addon_dlg.show(disp.video()); res = addon_dlg.get_retval(); diff --git a/src/gui/dialogs/addon_connect.cpp b/src/gui/dialogs/addon_connect.cpp index fb3f2d113b4..2dabba3b7cb 100644 --- a/src/gui/dialogs/addon_connect.cpp +++ b/src/gui/dialogs/addon_connect.cpp @@ -16,6 +16,7 @@ #include "gui/dialogs/addon_connect.hpp" +#include "gui/widgets/button.hpp" #include "gui/widgets/window.hpp" #include "gui/widgets/text_box.hpp" @@ -48,6 +49,12 @@ void taddon_connect::pre_show(CVideo& /*video*/, twindow& window) { ttext_box& host_widget = find_widget(&window, "host_name", false); + tbutton& update_cmd = + find_widget(&window, "update_addons", false); + update_cmd.set_active( allow_updates_ ); + tbutton& remove_cmd = + find_widget(&window, "remove_addons", false); + remove_cmd.set_active( allow_remove_ ); host_widget.set_value(host_name_); window.keyboard_capture(&host_widget); diff --git a/src/gui/dialogs/addon_connect.hpp b/src/gui/dialogs/addon_connect.hpp index 9cb9b3f4437..83545b04cb6 100644 --- a/src/gui/dialogs/addon_connect.hpp +++ b/src/gui/dialogs/addon_connect.hpp @@ -26,9 +26,25 @@ class taddon_connect public: taddon_connect() : host_name_() + , allow_updates_() + , allow_remove_() { } + bool allow_updates() const { return allow_updates_; } + + void set_allow_updates(bool allow_updates) + { + allow_updates_ = allow_updates; + } + + bool allow_remove() const { return allow_remove_; } + + void set_allow_remove(bool allow_remove) + { + allow_remove_ = allow_remove; + } + const std::string& host_name() const { return host_name_; } void set_host_name(const std::string& host_name) @@ -39,6 +55,9 @@ public: private: std::string host_name_; + bool allow_updates_; + bool allow_remove_; + /** Inherited from tdialog. */ twindow* build_window(CVideo& video);