mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Sort items in inventory by quantity
This commit is contained in:
parent
32c7994cca
commit
a648c68233
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Added
|
||||
|
||||
- Esperanto translation
|
||||
- Item quantity sort in player inventory.
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -40,3 +40,4 @@ hud-bag-sort_by_name = Sort by Name
|
||||
hud-bag-sort_by_quality = Sort by Quality
|
||||
hud-bag-sort_by_category = Sort by Category
|
||||
hud-bag-sort_by_tag = Sort by Tag
|
||||
hud-bag-sort_by_quantity = Sort by Quantity
|
||||
|
@ -40,3 +40,4 @@ hud-bag-sort_by_name = Trier par Nom
|
||||
hud-bag-sort_by_quality = Trier par Qualité
|
||||
hud-bag-sort_by_category = Trier par Catégorie
|
||||
hud-bag-sort_by_tag = Trier par Tag
|
||||
hud-bag-sort_by_quantity = Trier par Quantité
|
||||
|
@ -61,6 +61,7 @@ pub enum InventorySortOrder {
|
||||
Quality,
|
||||
Category,
|
||||
Tag,
|
||||
Amount,
|
||||
}
|
||||
|
||||
impl InventorySortOrder {
|
||||
@ -69,7 +70,8 @@ impl InventorySortOrder {
|
||||
InventorySortOrder::Name => InventorySortOrder::Quality,
|
||||
InventorySortOrder::Quality => InventorySortOrder::Tag,
|
||||
InventorySortOrder::Tag => InventorySortOrder::Category,
|
||||
InventorySortOrder::Category => InventorySortOrder::Name,
|
||||
InventorySortOrder::Category => InventorySortOrder::Amount,
|
||||
InventorySortOrder::Amount => InventorySortOrder::Name,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -217,6 +219,8 @@ impl Inventory {
|
||||
&a.tags().first().map_or("", |tag| tag.name()),
|
||||
&b.tags().first().map_or("", |tag| tag.name()),
|
||||
),
|
||||
// Amount is sorted in reverse since we want high amounts items first
|
||||
InventorySortOrder::Amount => Ord::cmp(&b.amount(), &a.amount()),
|
||||
});
|
||||
|
||||
self.push_all(items.into_iter()).expect(
|
||||
|
@ -915,6 +915,7 @@ impl<'a> Widget for Bag<'a> {
|
||||
InventorySortOrder::Quality => i18n.get_msg("hud-bag-sort_by_quality"),
|
||||
InventorySortOrder::Category => i18n.get_msg("hud-bag-sort_by_category"),
|
||||
InventorySortOrder::Tag => i18n.get_msg("hud-bag-sort_by_tag"),
|
||||
InventorySortOrder::Amount => i18n.get_msg("hud-bag-sort_by_quantity"),
|
||||
}),
|
||||
"",
|
||||
&tooltip,
|
||||
|
Loading…
Reference in New Issue
Block a user