From 01320983331c873b7625f62658713fed70cb9383 Mon Sep 17 00:00:00 2001 From: Casper Rogild Storm Date: Fri, 29 Jan 2021 22:21:07 +0100 Subject: [PATCH 1/3] feat: added option categories column to catalog --- locale/cs_CZ.json | 5 +++-- locale/da_DK.json | 5 +++-- locale/de_DE.json | 5 +++-- locale/en_US.json | 5 +++-- locale/es_ES.json | 5 +++-- locale/fr_FR.json | 5 +++-- locale/hu_HU.json | 5 +++-- locale/nb_NO.json | 5 +++-- locale/pt_PT.json | 5 +++-- locale/ru_RU.json | 5 +++-- locale/se_SE.json | 5 +++-- locale/sk_SK.json | 5 +++-- locale/tr_TR.json | 5 +++-- src/gui/element/catalog.rs | 23 +++++++++++++++++++++++ src/gui/mod.rs | 17 +++++++++++++++++ src/gui/update.rs | 17 +++++++++++++++++ src/localization.rs | 1 + 17 files changed, 97 insertions(+), 26 deletions(-) diff --git a/locale/cs_CZ.json b/locale/cs_CZ.json index fa835f84..63f9c62e 100644 --- a/locale/cs_CZ.json +++ b/locale/cs_CZ.json @@ -102,5 +102,6 @@ "weakaura-update-available": "Dostupná aktualizace", "weakaura-update-queued": "Aktualizace zařazena", "settings-general": "Obecné", - "catalog-results": "Výsledky: {number}" -} \ No newline at end of file + "catalog-results": "Výsledky: {number}", + "categories": "" +} diff --git a/locale/da_DK.json b/locale/da_DK.json index ac4f7492..ed6445a0 100644 --- a/locale/da_DK.json +++ b/locale/da_DK.json @@ -102,5 +102,6 @@ "weakaura-update-available": "Opdatering tilgængelig", "weakaura-update-queued": "Opdatering klargjort", "settings-general": "Generelt", - "catalog-results": "Resultater: {number}" -} \ No newline at end of file + "catalog-results": "Resultater: {number}", + "categories": "" +} diff --git a/locale/de_DE.json b/locale/de_DE.json index edcfc853..eb1287e4 100644 --- a/locale/de_DE.json +++ b/locale/de_DE.json @@ -102,5 +102,6 @@ "weakaura-update-available": "Update verfügbar", "weakaura-update-queued": "Update in Warteschlange", "settings-general": "Allgemein", - "catalog-results": "Ergebnisse: {number}" -} \ No newline at end of file + "catalog-results": "Ergebnisse: {number}", + "categories": "" +} diff --git a/locale/en_US.json b/locale/en_US.json index 1cbd506e..ea64818f 100644 --- a/locale/en_US.json +++ b/locale/en_US.json @@ -102,5 +102,6 @@ "weakaura-update-available": "Update Available", "weakaura-update-queued": "Update Queued", "settings-general": "General", - "catalog-results": "Results: {number}" -} \ No newline at end of file + "catalog-results": "Results: {number}", + "categories": "Categories" +} diff --git a/locale/es_ES.json b/locale/es_ES.json index 4cb36897..f9e3e4da 100644 --- a/locale/es_ES.json +++ b/locale/es_ES.json @@ -102,5 +102,6 @@ "weakaura-update-available": "Actualización disponible", "weakaura-update-queued": "Actualización en cola", "settings-general": "Ajustes globales", - "catalog-results": "Resultados: {number}" -} \ No newline at end of file + "catalog-results": "Resultados: {number}", + "categories": "" +} diff --git a/locale/fr_FR.json b/locale/fr_FR.json index 497a9991..87445d25 100644 --- a/locale/fr_FR.json +++ b/locale/fr_FR.json @@ -102,5 +102,6 @@ "weakaura-update-available": "Mise à jour disponible", "weakaura-update-queued": "Mise à jour en attente", "settings-general": "Paramètres généraux", - "catalog-results": "Résultats: {number}" -} \ No newline at end of file + "catalog-results": "Résultats: {number}", + "categories": "" +} diff --git a/locale/hu_HU.json b/locale/hu_HU.json index 6b1c8f38..6ded1255 100644 --- a/locale/hu_HU.json +++ b/locale/hu_HU.json @@ -102,5 +102,6 @@ "weakaura-update-available": "Frissítés elérhető", "weakaura-update-queued": "Frissítés sorbaállítva", "settings-general": "Általános", - "catalog-results": "Találatok: {number}" -} \ No newline at end of file + "catalog-results": "Találatok: {number}", + "categories": "" +} diff --git a/locale/nb_NO.json b/locale/nb_NO.json index 9d37e6ad..3e837f72 100644 --- a/locale/nb_NO.json +++ b/locale/nb_NO.json @@ -102,5 +102,6 @@ "weakaura-update-available": "Oppdatering Tilgjengelig", "weakaura-update-queued": "Oppdatering Køet", "settings-general": "Generelt", - "catalog-results": "Resultater: {number}" -} \ No newline at end of file + "catalog-results": "Resultater: {number}", + "categories": "" +} diff --git a/locale/pt_PT.json b/locale/pt_PT.json index ccebb746..26a4cf6e 100644 --- a/locale/pt_PT.json +++ b/locale/pt_PT.json @@ -102,5 +102,6 @@ "weakaura-update-available": "Atualização disponível", "weakaura-update-queued": "Atualização em fila", "settings-general": "Configuração geral", - "catalog-results": "Resultados: {number}" -} \ No newline at end of file + "catalog-results": "Resultados: {number}", + "categories": "" +} diff --git a/locale/ru_RU.json b/locale/ru_RU.json index f65b6778..7a590106 100644 --- a/locale/ru_RU.json +++ b/locale/ru_RU.json @@ -102,5 +102,6 @@ "weakaura-update-available": "Доступны обновления", "weakaura-update-queued": "Обновления поставлены в очередь", "settings-general": "Общие", - "catalog-results": "Результат: {number}" -} \ No newline at end of file + "catalog-results": "Результат: {number}", + "categories": "" +} diff --git a/locale/se_SE.json b/locale/se_SE.json index 4cfe9651..fca81cd9 100644 --- a/locale/se_SE.json +++ b/locale/se_SE.json @@ -102,5 +102,6 @@ "weakaura-update-available": "Uppdateringar tillgängliga", "weakaura-update-queued": "Uppdateringar köade", "settings-general": "Allmänna inställningar", - "catalog-results": "Resultat: {number}" -} \ No newline at end of file + "catalog-results": "Resultat: {number}", + "categories": "" +} diff --git a/locale/sk_SK.json b/locale/sk_SK.json index 6a04cef6..840ceb4d 100644 --- a/locale/sk_SK.json +++ b/locale/sk_SK.json @@ -102,5 +102,6 @@ "weakaura-update-available": "Dostupná aktualizácia", "weakaura-update-queued": "Aktualizácia zaradená", "settings-general": "Všeobecné", - "catalog-results": "Výsledky: {number}" -} \ No newline at end of file + "catalog-results": "Výsledky: {number}", + "categories": "" +} diff --git a/locale/tr_TR.json b/locale/tr_TR.json index b53cb186..6e3a7eec 100644 --- a/locale/tr_TR.json +++ b/locale/tr_TR.json @@ -102,5 +102,6 @@ "weakaura-update-available": "Güncelleme Mevcut", "weakaura-update-queued": "Güncelleme Sırada", "settings-general": "Genel", - "catalog-results": "{number} sonuç" -} \ No newline at end of file + "catalog-results": "{number} sonuç", + "categories": "" +} diff --git a/src/gui/element/catalog.rs b/src/gui/element/catalog.rs index 88832956..37afab76 100644 --- a/src/gui/element/catalog.rs +++ b/src/gui/element/catalog.rs @@ -348,6 +348,29 @@ pub fn data_row_container<'a, 'b>( row_containers.push((idx, num_downloads_container)); } + if let Some((idx, width)) = column_config + .iter() + .enumerate() + .filter_map(|(idx, (key, width, hidden))| { + if *key == CatalogColumnKey::Categories && !hidden { + Some((idx, width)) + } else { + None + } + }) + .next() + { + let categories = Text::new(&addon_data.categories.join(", ")).size(DEFAULT_FONT_SIZE); + let categories_container = Container::new(categories) + .height(default_height) + .width(*width) + .center_y() + .padding(5) + .style(style::HoverableForegroundContainer(color_palette)); + + row_containers.push((idx, categories_container)); + } + let left_spacer = Space::new(Length::Units(DEFAULT_PADDING), Length::Units(0)); let right_spacer = Space::new(Length::Units(DEFAULT_PADDING + 5), Length::Units(0)); diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 59da33ca..70a9650d 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -1426,6 +1426,7 @@ pub enum CatalogColumnKey { GameVersion, DateReleased, Install, + Categories, } impl CatalogColumnKey { @@ -1439,6 +1440,7 @@ impl CatalogColumnKey { NumDownloads => localized_string("num-downloads"), GameVersion => localized_string("game-version"), DateReleased => localized_string("latest-release"), + Categories => localized_string("categories"), CatalogColumnKey::Install => localized_string("status"), } } @@ -1453,6 +1455,7 @@ impl CatalogColumnKey { NumDownloads => "num_downloads", GameVersion => "game_version", DateReleased => "date_released", + Categories => "categories", CatalogColumnKey::Install => "install", }; @@ -1470,6 +1473,7 @@ impl From<&str> for CatalogColumnKey { "install" => CatalogColumnKey::Install, "game_version" => CatalogColumnKey::GameVersion, "date_released" => CatalogColumnKey::DateReleased, + "categories" => CatalogColumnKey::Categories, _ => panic!(format!("Unknown CatalogColumnKey for {}", s)), } } @@ -1547,6 +1551,13 @@ impl Default for CatalogHeaderState { hidden: false, order: 6, }, + CatalogColumnState { + key: CatalogColumnKey::Categories, + btn_state: Default::default(), + width: Length::Units(85), + hidden: true, + order: 7, + }, ], } } @@ -1629,6 +1640,12 @@ impl Default for CatalogColumnSettings { up_btn_state: Default::default(), down_btn_state: Default::default(), }, + CatalogColumnSettingState { + key: CatalogColumnKey::Categories, + order: 7, + up_btn_state: Default::default(), + down_btn_state: Default::default(), + }, ], } } diff --git a/src/gui/update.rs b/src/gui/update.rs index 3143275b..523d2f7b 100644 --- a/src/gui/update.rs +++ b/src/gui/update.rs @@ -2360,6 +2360,23 @@ fn sort_catalog_addons( let gv_b = b.addon.game_versions.iter().find(|gc| &gc.flavor == flavor); gv_a.cmp(&gv_b).reverse() }), + (CatalogColumnKey::Categories, SortDirection::Desc) => { + addons.sort_by(|a, b| { + a.addon + .categories + .join(", ") + .cmp(&b.addon.categories.join(", ")) + .reverse() + }); + } + (CatalogColumnKey::Categories, SortDirection::Asc) => { + addons.sort_by(|a, b| { + a.addon + .categories + .join(", ") + .cmp(&b.addon.categories.join(", ")) + }); + } } } diff --git a/src/localization.rs b/src/localization.rs index 4ce48d5a..3d856e57 100644 --- a/src/localization.rs +++ b/src/localization.rs @@ -195,5 +195,6 @@ mod test { channel_beta: String, channel_alpha: String, catalog_results: String, + category: String, } } From 69b44c33bc066685ac67d0e78d6638e93d3f50ec Mon Sep 17 00:00:00 2001 From: Casper Rogild Storm Date: Fri, 29 Jan 2021 22:22:32 +0100 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e67435ab..cea48818 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ and `Removed`. ## [Unreleased] +## Added + +- Optional 'Categories' column for Catalog. + ## [0.7.0] - 2021-01-26 ### Added From 02da32f34e91b4ca260e635c0580906655d7a8dd Mon Sep 17 00:00:00 2001 From: Casper Rogild Storm Date: Fri, 29 Jan 2021 22:23:49 +0100 Subject: [PATCH 3/3] Update localization.rs --- src/localization.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/localization.rs b/src/localization.rs index 3d856e57..3eccc3dd 100644 --- a/src/localization.rs +++ b/src/localization.rs @@ -195,6 +195,6 @@ mod test { channel_beta: String, channel_alpha: String, catalog_results: String, - category: String, + categories: String, } }