Addons Manager: display full info of local, unpublished addons
This works by changing the assumption that any addon with addon_info provided is a remote one. Instead, we construct a addon_info object locally and consider it along with the rest of the addons. This also fixes a few crashes when using filters in the manager.
This commit is contained in:
parent
3a1b6eea2b
commit
187731cedf
5 changed files with 64 additions and 33 deletions
|
@ -62,6 +62,10 @@ struct addon_info
|
|||
// is not serialized anywhere.
|
||||
unsigned order;
|
||||
|
||||
// Flag to indicate whether this object was generaled from pbl info for an addon
|
||||
// not previously published.
|
||||
bool local_only;
|
||||
|
||||
addon_info()
|
||||
: id(), title(), description(), icon()
|
||||
, version(), author(), size(), downloads()
|
||||
|
@ -72,6 +76,7 @@ struct addon_info
|
|||
, updated()
|
||||
, created()
|
||||
, order()
|
||||
, local_only(false)
|
||||
{}
|
||||
|
||||
explicit addon_info(const config& cfg)
|
||||
|
@ -84,6 +89,7 @@ struct addon_info
|
|||
, updated()
|
||||
, created()
|
||||
, order()
|
||||
, local_only(false)
|
||||
{
|
||||
this->read(cfg);
|
||||
}
|
||||
|
@ -107,6 +113,7 @@ struct addon_info
|
|||
this->updated = o.updated;
|
||||
this->created = o.created;
|
||||
this->order = o.order;
|
||||
this->local_only = o.local_only;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -32,19 +32,27 @@ addon_tracking_info get_addon_tracking_info(const addon_info& addon)
|
|||
|
||||
if(is_addon_installed(id)) {
|
||||
if(t.can_publish) {
|
||||
// Try to obtain the version number from the .pbl first.
|
||||
config pbl = get_addon_pbl_info(id);
|
||||
if(addon.local_only) {
|
||||
t.installed_version = addon.version;
|
||||
//t.remote_version = version_info();
|
||||
} else {
|
||||
t.remote_version = addon.version;
|
||||
|
||||
if(pbl.has_attribute("version")) {
|
||||
t.installed_version = pbl["version"].str();
|
||||
// Try to obtain the version number from the .pbl first.
|
||||
config pbl = get_addon_pbl_info(id);
|
||||
|
||||
if(pbl.has_attribute("version")) {
|
||||
t.installed_version = pbl["version"].str();
|
||||
} else {
|
||||
t.installed_version = get_addon_version_info(id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// We normally use the _info.cfg version instead.
|
||||
t.installed_version = get_addon_version_info(id);
|
||||
t.remote_version = addon.version;
|
||||
}
|
||||
|
||||
t.remote_version = addon.version;
|
||||
|
||||
if(t.remote_version == t.installed_version) {
|
||||
t.state = ADDON_INSTALLED;
|
||||
} else if(t.remote_version > t.installed_version) {
|
||||
|
|
|
@ -303,6 +303,11 @@ static std::string describe_status_verbose(const addon_tracking_info& state)
|
|||
|
||||
s = utils::interpolate_variables_into_string(vstr, &i18n_symbols);
|
||||
} break;
|
||||
case ADDON_INSTALLED_LOCAL_ONLY:
|
||||
s = !state.can_publish
|
||||
? _("addon_state^Installed, not ready to publish")
|
||||
: _("addon_state^Ready to publish");
|
||||
break;
|
||||
case ADDON_INSTALLED_BROKEN:
|
||||
s = !state.can_publish
|
||||
? _("addon_state^Installed, broken")
|
||||
|
@ -425,20 +430,28 @@ void addon_manager::load_addon_list(window& window)
|
|||
|
||||
read_addons_list(cfg_, addons_);
|
||||
|
||||
addons_including_publishable_ = addons_;
|
||||
std::vector<std::string> publishable_addons = available_addons();
|
||||
|
||||
for(std::string id : publishable_addons) {
|
||||
if(addons_including_publishable_.find(id) == addons_including_publishable_.end()) {
|
||||
if(addons_.find(id) == addons_.end()) {
|
||||
// Get a config from the addon's pbl file
|
||||
// Note that the name= key is necessary or stuff breaks, since the filter code uses this key
|
||||
// to match add-ons in the config list. It also fills in addon_info's id field.
|
||||
config pbl_cfg = get_addon_pbl_info(id);
|
||||
pbl_cfg["name"] = id;
|
||||
|
||||
// Add the add-on to the list.
|
||||
addon_info addon;
|
||||
addon.id = id;
|
||||
addons_including_publishable_[id] = addon;
|
||||
addon_info addon(pbl_cfg);
|
||||
addon.local_only = true;
|
||||
addons_[id] = addon;
|
||||
|
||||
// Add the addon to the config entry
|
||||
cfg_.add_child("campaign", pbl_cfg);
|
||||
}
|
||||
}
|
||||
|
||||
addon_list& list = find_widget<addon_list>(&window, "addons", false);
|
||||
list.set_addons(addons_including_publishable_);
|
||||
list.set_addons(addons_);
|
||||
|
||||
bool has_upgradable_addons = false;
|
||||
for(const auto& a : addons_) {
|
||||
|
|
|
@ -59,7 +59,6 @@ private:
|
|||
addons_client& client_;
|
||||
|
||||
addons_list addons_;
|
||||
addons_list addons_including_publishable_;
|
||||
|
||||
addons_tracking_list tracking_info_;
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ std::string addon_list::colorify_addon_state_string(const std::string& str, ADDO
|
|||
colorname = "#a69275";
|
||||
break;
|
||||
case ADDON_INSTALLED:
|
||||
case ADDON_INSTALLED_LOCAL_ONLY:
|
||||
case ADDON_NOT_TRACKED:
|
||||
colorname = "#00ff00"; // GOOD_COLOR
|
||||
break;
|
||||
|
@ -83,6 +84,9 @@ std::string addon_list::describe_status(const addon_tracking_info& info)
|
|||
// on their status.
|
||||
tx = info.can_publish ? _("addon_state^Published") : _("addon_state^Installed");
|
||||
break;
|
||||
case ADDON_INSTALLED_LOCAL_ONLY:
|
||||
tx = info.can_publish ? _("addon_state^Ready to publish") : _("addon_state^Installed, not ready to publish");
|
||||
break;
|
||||
|
||||
case ADDON_INSTALLED_UPGRADABLE:
|
||||
tx = info.can_publish ? _("addon_state^Published, upgradable") : _("addon_state^Installed, upgradable");
|
||||
|
@ -127,37 +131,37 @@ void addon_list::set_addons(const addons_list& addons)
|
|||
|
||||
item["label"] = addon.display_title();
|
||||
data.emplace("name", item);
|
||||
|
||||
item["label"] = describe_status(tracking_info);
|
||||
data.emplace("installation_status", item);
|
||||
|
||||
item["label"] = addon.version.str();
|
||||
data.emplace("version", item);
|
||||
|
||||
item["label"] = addon.author;
|
||||
data.emplace("author", item);
|
||||
|
||||
item["label"] = size_display_string(addon.size);
|
||||
data.emplace("size", item);
|
||||
|
||||
item["label"] = std::to_string(addon.downloads);
|
||||
data.emplace("downloads", item);
|
||||
|
||||
item["label"] = addon.display_type();
|
||||
data.emplace("type", item);
|
||||
} else {
|
||||
item["label"] = "icons/icon-game.png~BLIT(icons/icon-addon-publish.png)";
|
||||
item["label"] = addon.display_icon() + "~BLIT(icons/icon-addon-publish.png)";
|
||||
data.emplace("icon", item);
|
||||
|
||||
const std::string publish_name = formatter()
|
||||
<< "<span color='#00ff00'>" // GOOD_COLOR
|
||||
<< vgettext("Publish: $addon_title", { { "addon_title", addon.display_title() } })
|
||||
<< addon.display_title()
|
||||
<< "</span>";
|
||||
|
||||
item["label"] = publish_name;
|
||||
data.emplace("name", item);
|
||||
}
|
||||
|
||||
item["label"] = describe_status(tracking_info);
|
||||
data.emplace("installation_status", item);
|
||||
|
||||
item["label"] = addon.version.str();
|
||||
data.emplace("version", item);
|
||||
|
||||
item["label"] = addon.author;
|
||||
data.emplace("author", item);
|
||||
|
||||
item["label"] = size_display_string(addon.size);
|
||||
data.emplace("size", item);
|
||||
|
||||
item["label"] = std::to_string(addon.downloads);
|
||||
data.emplace("downloads", item);
|
||||
|
||||
item["label"] = addon.display_type();
|
||||
data.emplace("type", item);
|
||||
|
||||
grid* row_grid = &list.add_row(data);
|
||||
|
||||
stacked_widget& install_update_stack = find_widget<stacked_widget>(row_grid, "install_update_stack", false);
|
||||
|
|
Loading…
Add table
Reference in a new issue