Skip to content

Commit

Permalink
gui2/tgame_cache_options: New Preferences subdialog for cache management
Browse files Browse the repository at this point in the history
It allows the user to browse to the cache (using a desktop API call),
copy its path to clipboard, clean the cache contents (deleting stale
files), or purge it entirely.

This is ideal for people sticking to the same cache dir for very long
and thus keeping content that was generated by previous versions of
Wesnoth they might not even use anymore. Purging the cache might also
aid troubleshooting (although there is a --nocache switch for that too).

The dialog also makes Wesnoth slightly more transparent about its own
disk usage, information which may not be readily accessible to people
without the technical know-how to locate a hidden directory.

For now it's accessed by pushing a button in Preferences -> General,
even though this is not ideal since it is actually Advanced Preferences
material given the nature of the cache. Unfortunately, the Advanced
page's layout is currently monopolized by the advanced preferences
options and I'm not interested right now in solving that UI design
puzzle; it will have to wait, much like the Paths dialog has done and
continues to do for 1.12.
  • Loading branch information
irydacea committed Jun 20, 2014
1 parent 3154af1 commit 17c8d56
Show file tree
Hide file tree
Showing 8 changed files with 505 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog
Expand Up @@ -75,6 +75,7 @@ Version 1.13.0-dev:
* Fixed most of the minimap buttons and the End Turn button appearing
without contents or in the wrong state during WML start events until they
are interacted with or control is given to the player for the first time.
* Added a new subdialog in Preferences to clean or purge the WML cache.
* WML engine:
* Added customizable recall costs for unit types and individual units,
using the new recall_cost attribute in [unit_type] and [unit].
Expand Down
267 changes: 267 additions & 0 deletions data/gui/default/window/game_cache_options.cfg
@@ -0,0 +1,267 @@
#textdomain wesnoth-lib

[window]
id = "game_cache_options"
description = "Game data cache management dialog."

[resolution]
definition = "default"

click_dismiss = "true"
maximum_width = 600

[tooltip]
id = "tooltip_large"
[/tooltip]

[helptip]
id = "tooltip_large"
[/helptip]

[grid]

[row]
grow_factor = 0

[column]
grow_factor = 1

border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
id = "title"
definition = "title"

label = _ "WML Cache"
[/label]

[/column]

[/row]

[row]
grow_factor = 0

[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[label]
definition = "default"

label = _ "Wesnoth maintains a cache of preprocessed WML data for campaigns, multiplayer scenarios, and other add-ons to speed up the loading process. The cache may be safely cleaned to free up disk space, thus removing stale files generated by older versions; or you may purge its entire contents if you are experiencing issues when loading the game data."
wrap = "true"
[/label]

[/column]

[/row]

[row]
grow_factor = 1

[column]
horizontal_grow = "true"

[grid]

[row]

[column]
grow_factor = 0

border = "all"
border_size = 5
horizontal_alignment = "left"

[label]
definition = "default"

label = _ "Path:"
[/label]

[/column]

[column]
grow_factor = 1

border = "all"
border_size = 5
horizontal_grow = "true"

[text_box]
id = "path"
definition = "default"
label = ""
[/text_box]

[/column]

[column]
grow_factor = 0

border = "all"
border_size = 5
horizontal_alignment = "left"

[button]
id = "copy"
definition = "action_copy"
label = _ "filesystem^Copy"
tooltip = _ "Copy this path to clipboard"
[/button]

[/column]

[column]
grow_factor = 0

border = "all"
border_size = 5
horizontal_alignment = "left"

[button]
id = "browse"
definition = "action_go"
label = _ "filesystem^Browse"
tooltip = _ "Browse this location using a file manager"
[/button]

[/column]

[/row]

[/grid]

[/column]

[/row]

[row]
grow_factor = 1

[column]
horizontal_grow = "true"

[grid]

[row]

[column]
grow_factor = 0

border = "all"
border_size = 5
horizontal_alignment = "left"

[label]
definition = "default"

label = _ "Size:"
[/label]

[/column]

[column]
grow_factor = 1

border = "all"
border_size = 5
horizontal_grow = "true"

[label]
definition = "default"

id = "size"
label = ""
[/label]

[/column]

[column]
horizontal_alignment = "right"

[grid]

[row]

[column]
border = "all"
border_size = 5

[button]
id = "clean"
definition = "default"
label = _ "cache^Clean"
tooltip = _ "Clear stale and unused cache files"
[/button]

[/column]

[column]
border = "all"
border_size = 5

[button]
id = "purge"
definition = "default"
label = _ "cache^Purge"
tooltip = _ "Purge the entire contents of the cache"
[/button]

[/column]

[/row]

[/grid]

[/column]

[/row]

[/grid]

[/column]

[/row]

[row]
grow_factor = 0

[column]
horizontal_alignment = "right"

[grid]

[row]
grow_factor = 0

[column]
border = "all"
border_size = 5
horizontal_alignment = "right"

[button]
id = "ok"
definition = "default"

label = _ "OK"
[/button]

[/column]

[/row]

[/grid]

[/column]

[/row]


[/grid]

[/resolution]

[/window]
1 change: 1 addition & 0 deletions players_changelog
Expand Up @@ -22,6 +22,7 @@ Version 1.13.0-dev:
* Fixed most of the minimap buttons and the End Turn button appearing
without contents or in the wrong state during WML start events until they
are interacted with or control is given to the player for the first time.
* Added a new subdialog in Preferences to clean or purge the WML cache.

* Miscellaneous and bug fixes:
* Fixed halos glitching through locations that become shrouded after the
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Expand Up @@ -784,6 +784,7 @@ set(wesnoth-main_SRC
gui/dialogs/editor_set_starting_position.cpp
gui/dialogs/folder_create.cpp
gui/dialogs/formula_debugger.cpp
gui/dialogs/game_cache_options.cpp
gui/dialogs/game_delete.cpp
gui/dialogs/game_load.cpp
gui/dialogs/game_paths.cpp
Expand Down
1 change: 1 addition & 0 deletions src/SConscript
Expand Up @@ -379,6 +379,7 @@ wesnoth_sources = Split("""
gui/dialogs/editor_set_starting_position.cpp
gui/dialogs/folder_create.cpp
gui/dialogs/formula_debugger.cpp
gui/dialogs/game_cache_options.cpp
gui/dialogs/game_delete.cpp
gui/dialogs/game_load.cpp
gui/dialogs/game_paths.cpp
Expand Down
11 changes: 11 additions & 0 deletions src/game_preferences_display.cpp
Expand Up @@ -20,6 +20,7 @@
#include "filechooser.hpp"
#include "game_preferences.hpp"
#include "gettext.hpp"
#include "gui/dialogs/game_cache_options.hpp"
#include "gui/dialogs/game_paths.hpp"
#include "gui/dialogs/simple_item_selector.hpp"
#include "gui/dialogs/theme_list.hpp"
Expand Down Expand Up @@ -129,6 +130,7 @@ class preferences_dialog : public gui::preview_pane
show_haloing_button_, video_mode_button_,
theme_button_,
hotkeys_button_, paths_button_, colors_button_,
cache_button_,
advanced_button_, sound_button_,
music_button_, chat_timestamp_button_,
advanced_sound_button_, normal_sound_button_,
Expand Down Expand Up @@ -222,6 +224,7 @@ preferences_dialog::preferences_dialog(display& disp, const config& game_cfg)
hotkeys_button_(disp.video(), _("Hotkeys")),
paths_button_(disp.video(), _("Paths")),
colors_button_(disp.video(), _("Colors")),
cache_button_(disp.video(), _("Cache")),
advanced_button_(disp.video(), "", gui::button::TYPE_CHECK),
sound_button_(disp.video(), _("Sound effects"), gui::button::TYPE_CHECK),
music_button_(disp.video(), _("Music"), gui::button::TYPE_CHECK),
Expand Down Expand Up @@ -509,6 +512,7 @@ preferences_dialog::preferences_dialog(display& disp, const config& game_cfg)
hotkeys_button_.set_help_string(_("View and configure keyboard shortcuts"));
paths_button_.set_help_string(_("View game file paths"));
colors_button_.set_help_string(_("Adjust orb colors"));
cache_button_.set_help_string(_("Manage the game WML cache"));

set_advanced_menu();
set_friends_menu();
Expand Down Expand Up @@ -565,6 +569,7 @@ handler_vector preferences_dialog::handler_members()
h.push_back(&hotkeys_button_);
h.push_back(&paths_button_);
h.push_back(&colors_button_);
h.push_back(&cache_button_);
h.push_back(&advanced_button_);
h.push_back(&sound_button_);
h.push_back(&music_button_);
Expand Down Expand Up @@ -659,6 +664,7 @@ void preferences_dialog::update_location(SDL_Rect const &rect)
autosavemax_slider_.set_location(autosavemax_rect);
hotkeys_button_.set_location(rect.x, bottom_row_y - hotkeys_button_.height());
paths_button_.set_location(rect.x + hotkeys_button_.width() + 10, bottom_row_y - paths_button_.height());
cache_button_.set_location(paths_button_.location().x + paths_button_.width() + 10, bottom_row_y - cache_button_.height());

// Display tab
ypos = rect.y + top_border;
Expand Down Expand Up @@ -918,6 +924,10 @@ void preferences_dialog::process_event()
show_paths_dialog(disp_);
parent->clear_buttons();
}
if (cache_button_.pressed()) {
gui2::tgame_cache_options::display(disp_.video());
parent->clear_buttons();
}

set_scroll_speed(scroll_slider_.value());
set_autosavemax(autosavemax_slider_.value());
Expand Down Expand Up @@ -1543,6 +1553,7 @@ void preferences_dialog::set_selection(int index)
interrupt_when_ally_sighted_button_.hide(hide_general);
hotkeys_button_.hide(hide_general);
paths_button_.hide(hide_general);
cache_button_.hide(hide_general);
save_replays_button_.hide(hide_general);
delete_saves_button_.hide(hide_general);
autosavemax_slider_label_.hide(hide_general);
Expand Down

0 comments on commit 17c8d56

Please sign in to comment.