Execute a sensible action when the player double-clicks an add-on
Previously double-clicking always installed the add-on, even if installing wasn't a sensible choice (e.g. for add-ons which are already installed). Now double-click always does something sensible, e.g. it uninstalls add-ons which are already installed.
This commit is contained in:
parent
e228f8683a
commit
a6719622b5
6 changed files with 39 additions and 4 deletions
|
@ -17,6 +17,8 @@ Version 1.13.7+dev:
|
|||
* Greatly speeded up switching between add-ons in the add-on manager (bug #25523)
|
||||
* User Interface:
|
||||
* Updated Attack Predictions dialog to GUI2.
|
||||
* Double-clicking an add-on now installs, updates, uninstalls or publishes it depending
|
||||
on the situation.
|
||||
* Fixed file path being truncated on the wrong side in the File Browser.
|
||||
* WML Engine:
|
||||
* Add base_income key to [store_side]
|
||||
|
|
|
@ -5,6 +5,9 @@ changelog: https://github.com/wesnoth/wesnoth/blob/master/changelog
|
|||
Version 1.13.7+dev:
|
||||
* Language and i18n:
|
||||
* Updated translations: British English, Lithuanian, Spanish.
|
||||
* User Interface:
|
||||
* Double-clicking an add-on now installs, updates, uninstalls or publishes it depending
|
||||
on the situation.
|
||||
|
||||
|
||||
Version 1.13.7:
|
||||
|
|
|
@ -695,6 +695,30 @@ void addon_manager::delete_addon(const addon_info& addon, window& window)
|
|||
}
|
||||
}
|
||||
|
||||
/** Called when the player double-clicks an add-on. */
|
||||
void addon_manager::execute_default_action(const addon_info& addon, window& window)
|
||||
{
|
||||
switch(tracking_info_[addon.id].state) {
|
||||
case ADDON_NONE:
|
||||
install_addon(addon, window);
|
||||
break;
|
||||
case ADDON_INSTALLED:
|
||||
if(!tracking_info_[addon.id].can_publish) {
|
||||
uninstall_addon(addon, window);
|
||||
}
|
||||
break;
|
||||
case ADDON_INSTALLED_UPGRADABLE:
|
||||
update_addon(addon, window);
|
||||
break;
|
||||
case ADDON_INSTALLED_LOCAL_ONLY:
|
||||
case ADDON_INSTALLED_OUTDATED:
|
||||
publish_addon(addon, window);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void addon_manager::show_help(window& window)
|
||||
{
|
||||
help::show_help(window.video(), "installing_addons");
|
||||
|
@ -814,8 +838,8 @@ void addon_manager::on_addon_select(window& window)
|
|||
|
||||
bool addon_manager::exit_hook(window& window)
|
||||
{
|
||||
if(window.get_retval() == addon_list::INSTALL_ADDON_RETVAL) {
|
||||
install_selected_addon(window);
|
||||
if(window.get_retval() == addon_list::DEFAULT_ACTION_RETVAL) {
|
||||
execute_default_action_on_selected_addon(window);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,6 +112,12 @@ private:
|
|||
execute_action_on_selected_addon<&addon_manager::delete_addon>(window);
|
||||
}
|
||||
|
||||
void execute_default_action(const addon_info& addon, window& window);
|
||||
void execute_default_action_on_selected_addon(window& window)
|
||||
{
|
||||
execute_action_on_selected_addon<&addon_manager::execute_default_action>(window);
|
||||
}
|
||||
|
||||
void update_all_addons(window& window);
|
||||
|
||||
void browse_url_callback(text_box& url_box);
|
||||
|
|
|
@ -171,7 +171,7 @@ void addon_list::set_addons(const addons_list& addons)
|
|||
grid* row_grid = &list.add_row(data);
|
||||
|
||||
// Set special retval for the toggle panels
|
||||
find_widget<toggle_panel>(row_grid, "list_panel", false).set_retval(INSTALL_ADDON_RETVAL);
|
||||
find_widget<toggle_panel>(row_grid, "list_panel", false).set_retval(DEFAULT_ACTION_RETVAL);
|
||||
|
||||
grid* control_grid = find_widget<grid>(row_grid, "single_install_buttons", false, false);
|
||||
if(!control_grid) {
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
{}
|
||||
|
||||
/** Special retval for the toggle panels in the addons list */
|
||||
static const int INSTALL_ADDON_RETVAL = 200;
|
||||
static const int DEFAULT_ACTION_RETVAL = 200;
|
||||
|
||||
/** Sets the add-ons to show. */
|
||||
void set_addons(const addons_list& addons);
|
||||
|
|
Loading…
Add table
Reference in a new issue