mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-15 12:03:43 +00:00
add preference to not get addon icons
also skip if DataURI is too large
This commit is contained in:
parent
352157d593
commit
8210f33a7b
|
@ -21,6 +21,14 @@
|
|||
[/option]
|
||||
[/advanced_preference]
|
||||
|
||||
[advanced_preference]
|
||||
field=addon_icons
|
||||
name= _ "Whether to show icons in the add-ons list on the add-ons manager"
|
||||
description= _ "Disabling saves bandwidth by not sending icons for the add-ons list in the add-ons manager"
|
||||
type=boolean
|
||||
default=yes
|
||||
[/advanced_preference]
|
||||
|
||||
[advanced_preference]
|
||||
field=ask_delete
|
||||
name= _ "Confirm deleting saves"
|
||||
|
|
|
@ -112,16 +112,20 @@ void addons_client::connect()
|
|||
<< " supports: " << utils::join(server_capabilities_, " ");
|
||||
}
|
||||
|
||||
bool addons_client::request_addons_list(config& cfg)
|
||||
bool addons_client::request_addons_list(config& cfg, bool icons)
|
||||
{
|
||||
cfg.clear();
|
||||
|
||||
config request;
|
||||
config& req_child = request.add_child("request_campaign_list");
|
||||
req_child["send_icons"] = icons;
|
||||
|
||||
config response_buf;
|
||||
|
||||
/** @todo FIXME: get rid of this legacy "campaign"/"campaigns" silliness
|
||||
*/
|
||||
|
||||
send_simple_request("request_campaign_list", response_buf);
|
||||
send_request(request, response_buf);
|
||||
wait_for_transfer_done(_("Downloading list of add-ons..."));
|
||||
|
||||
std::swap(cfg, response_buf.mandatory_child("campaigns"));
|
||||
|
|
|
@ -89,8 +89,9 @@ public:
|
|||
*
|
||||
* @param cfg A config object whose contents are replaced with
|
||||
* the server's list if available, cleared otherwise.
|
||||
* @param icons Whether to have the add-ons server populate the icon
|
||||
*/
|
||||
bool request_addons_list(config& cfg);
|
||||
bool request_addons_list(config& cfg, bool icons);
|
||||
|
||||
/**
|
||||
* Retrieves the add-ons server web URL if available.
|
||||
|
|
|
@ -233,9 +233,7 @@ std::string addon_info::display_icon() const
|
|||
{
|
||||
std::string ret = icon;
|
||||
|
||||
if(ret.empty()) {
|
||||
ERR_AC << "add-on '" << id << "' doesn't have an icon path set";
|
||||
} else if(!image::exists(image::locator{ret})) {
|
||||
if(!image::exists(image::locator{ret}) && !ret.empty()) {
|
||||
ERR_AC << "add-on '" << id << "' has an icon which cannot be found: '" << ret << "'";
|
||||
} else if(ret.find("units/") != std::string::npos && ret.find_first_of('~') == std::string::npos) {
|
||||
// HACK: prevent magenta icons, because they look awful
|
||||
|
|
|
@ -55,7 +55,7 @@ bool get_addons_list(addons_client& client, addons_list& list)
|
|||
list.clear();
|
||||
|
||||
config cfg;
|
||||
client.request_addons_list(cfg);
|
||||
client.request_addons_list(cfg, prefs::get().addon_icons());
|
||||
|
||||
read_addons_list(cfg, list);
|
||||
|
||||
|
|
|
@ -539,7 +539,7 @@ void addon_manager::toggle_details(button& btn, stacked_widget& stk)
|
|||
|
||||
void addon_manager::fetch_addons_list()
|
||||
{
|
||||
bool success = client_.request_addons_list(cfg_);
|
||||
bool success = client_.request_addons_list(cfg_, prefs::get().addon_icons());
|
||||
if(!success) {
|
||||
gui2::show_error_message(_("An error occurred while downloading the add-ons list from the server."));
|
||||
close();
|
||||
|
|
|
@ -485,6 +485,7 @@ public:
|
|||
*/
|
||||
void set_sub_achievement(const std::string& content_for, const std::string& id, const std::string& sub_id);
|
||||
|
||||
PREF_GETTER_SETTER(addon_icons, bool, true)
|
||||
PREF_GETTER_SETTER(show_ally_orb, bool, game_config::show_ally_orb)
|
||||
PREF_GETTER_SETTER(show_status_on_ally_orb, bool, game_config::show_status_on_ally_orb)
|
||||
PREF_GETTER_SETTER(show_enemy_orb, bool, game_config::show_enemy_orb)
|
||||
|
@ -811,6 +812,7 @@ private:
|
|||
prefs_list::sp_modifications,
|
||||
prefs_list::animate_map,
|
||||
prefs_list::animate_water,
|
||||
prefs_list::addon_icons,
|
||||
};
|
||||
static constexpr std::array synced_children_{
|
||||
prefs_list::acquaintance,
|
||||
|
|
|
@ -32,6 +32,8 @@ struct preferences_list_defines
|
|||
ADDPREF(achievements)
|
||||
/** player names marked as either friends or as ignored */
|
||||
ADDPREF(acquaintance)
|
||||
/** whether to get the add-on icons when downloading the add-ons list */
|
||||
ADDPREF(addon_icons)
|
||||
/** the sort direction, ie: ascending */
|
||||
ADDPREF(addon_manager_saved_order_direction)
|
||||
/** the name of the column in the add-ons manager to use by default to sort results */
|
||||
|
@ -554,7 +556,8 @@ struct preferences_list_defines
|
|||
turn_changed_lobby,
|
||||
game_created_sound,
|
||||
game_created_notif,
|
||||
game_created_lobby
|
||||
game_created_lobby,
|
||||
addon_icons
|
||||
)
|
||||
};
|
||||
using prefs_list = string_enums::enum_base<preferences_list_defines>;
|
||||
|
|
|
@ -1047,6 +1047,11 @@ void server::handle_request_campaign_list(const server::request& req)
|
|||
// or irrelevant to clients
|
||||
j.remove_attributes("passphrase", "passhash", "passsalt", "upload_ip", "email");
|
||||
|
||||
// don't include icons if requested
|
||||
if(!req.cfg["send_icons"].to_bool(true)) {
|
||||
j.remove_attribute("icon");
|
||||
}
|
||||
|
||||
// Build a feedback_url string attribute from the internal [feedback]
|
||||
// data or deliver an empty value, in case clients decide to assume its
|
||||
// presence.
|
||||
|
|
Loading…
Reference in New Issue
Block a user