mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Deprecation step of Item::name/description
- Mark Item::name() and Item::description() deprecated, along with corresponding ItemDesc methods. - Dummify dialogue code that uses items, as it's not used anyway. In the future it should use common_i18n::Content. - Allow usage of deprecated .name() for Inventory ordering, for now. - Allow usage of deprecated .name() for Inventory ordering for merchants, for now.
This commit is contained in:
parent
75013cc04a
commit
1347a31108
@ -92,7 +92,7 @@ pub enum MoodState {
|
||||
Bad(MoodContext),
|
||||
}
|
||||
|
||||
// TODO: dialogue localization
|
||||
// TODO: this should return common_i18n::Content
|
||||
impl MoodState {
|
||||
pub fn describe(&self) -> String {
|
||||
match self {
|
||||
@ -105,7 +105,7 @@ impl MoodState {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: dialogue localization
|
||||
// TODO: this should return common_i18n::Content
|
||||
impl MoodContext {
|
||||
pub fn describe(&self) -> String {
|
||||
match &self {
|
||||
@ -114,11 +114,16 @@ impl MoodContext {
|
||||
format!("{} helped me on {}", hero, quest_desc)
|
||||
},
|
||||
&MoodContext::EverydayLife => "Life's going as always.".to_string(),
|
||||
MoodContext::NeedItem { item, quantity } => {
|
||||
format!("I need {} {}!", quantity, item.name())
|
||||
MoodContext::NeedItem {
|
||||
item: _,
|
||||
quantity: _,
|
||||
} => {
|
||||
// format!("I need {} {}!", quantity, item.name())
|
||||
format!("I need some item, not just any item!")
|
||||
},
|
||||
&MoodContext::MissingItem { item } => {
|
||||
format!("Someone robbed my {}!", item.name())
|
||||
&MoodContext::MissingItem { item: _ } => {
|
||||
// format!("Someone robbed my {}!", item.name())
|
||||
format!("Someone robbed me of my item!")
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -1148,6 +1148,7 @@ impl Item {
|
||||
}
|
||||
|
||||
/// Generate a human-readable description of the item and amount.
|
||||
#[deprecated]
|
||||
pub fn describe(&self) -> String {
|
||||
if self.amount() > 1 {
|
||||
format!("{} x {}", self.amount(), self.name())
|
||||
@ -1156,6 +1157,7 @@ impl Item {
|
||||
}
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn name(&self) -> Cow<str> {
|
||||
match &self.item_base {
|
||||
ItemBase::Simple(item_def) => {
|
||||
@ -1169,6 +1171,7 @@ impl Item {
|
||||
}
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
pub fn description(&self) -> &str {
|
||||
match &self.item_base {
|
||||
ItemBase::Simple(item_def) => &item_def.description,
|
||||
@ -1395,6 +1398,7 @@ pub fn flatten_counted_items<'a>(
|
||||
/// Provides common methods providing details about an item definition
|
||||
/// for either an `Item` containing the definition, or the actual `ItemDef`
|
||||
pub trait ItemDesc {
|
||||
#[deprecated]
|
||||
fn description(&self) -> &str;
|
||||
fn name(&self) -> Cow<str>;
|
||||
fn kind(&self) -> Cow<ItemKind>;
|
||||
|
@ -184,6 +184,7 @@ impl Inventory {
|
||||
)
|
||||
},
|
||||
Some(CustomOrder::Quality) => cmp = Ord::cmp(&b_quality, &a_quality),
|
||||
#[allow(deprecated)]
|
||||
Some(CustomOrder::Name) => cmp = Ord::cmp(&a.name(), &b.name()),
|
||||
Some(CustomOrder::Tag) => {
|
||||
cmp = Ord::cmp(
|
||||
@ -203,6 +204,7 @@ impl Inventory {
|
||||
let mut items: Vec<Item> = self.slots_mut().filter_map(mem::take).collect();
|
||||
|
||||
items.sort_by(|a, b| match sort_order {
|
||||
#[allow(deprecated)]
|
||||
InventorySortOrder::Name => Ord::cmp(&a.name(), &b.name()),
|
||||
// Quality is sorted in reverse since we want high quality items first
|
||||
InventorySortOrder::Quality => Ord::cmp(&b.quality(), &a.quality()),
|
||||
|
@ -1131,7 +1131,7 @@ fn sort_wares(bag: &mut [Item]) {
|
||||
)
|
||||
)
|
||||
// sort by name
|
||||
.then(Ord::cmp(&a.name(), &b.name()))
|
||||
.then(#[allow(deprecated)] Ord::cmp(&a.name(), &b.name()))
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user