Disable (gray out) the Update and Remove add-ons options...

...in the connection dialog when there are no add-ons installed.
This commit is contained in:
Ignacio R. Morelle 2009-09-24 21:35:18 +00:00
parent 89bc70b37c
commit 308d29ec07
6 changed files with 37 additions and 0 deletions

View file

@ -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

View file

@ -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"

View file

@ -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:

View file

@ -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();

View file

@ -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<ttext_box>(&window, "host_name", false);
tbutton& update_cmd =
find_widget<tbutton>(&window, "update_addons", false);
update_cmd.set_active( allow_updates_ );
tbutton& remove_cmd =
find_widget<tbutton>(&window, "remove_addons", false);
remove_cmd.set_active( allow_remove_ );
host_widget.set_value(host_name_);
window.keyboard_capture(&host_widget);

View file

@ -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);