mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'Kay_Hemme/fix_item_label_cut-off_when_trading_merchant' into 'master'
Fixes #1865 -Item label gets cut-off when trading with Merchant Closes #1865 See merge request veloren/veloren!4389
This commit is contained in:
commit
51098b2012
@ -523,6 +523,8 @@ impl<'a> Trade<'a> {
|
||||
.resize(2 * MAX_TRADE_SLOTS, &mut ui.widget_id_generator());
|
||||
});
|
||||
}
|
||||
let max_width = 170.0;
|
||||
let mut total_text_height = 0.0;
|
||||
let mut total_quantity = 0;
|
||||
for i in 0..MAX_TRADE_SLOTS {
|
||||
let slot = tradeslots.get(i).cloned().unwrap_or(TradeSlot {
|
||||
@ -543,10 +545,16 @@ impl<'a> Trade<'a> {
|
||||
})
|
||||
.unwrap_or(Cow::Borrowed(""));
|
||||
let is_present = slot.quantity > 0 && slot.invslot.is_some();
|
||||
Text::new(&format!("{} x {}", slot.quantity, itemname))
|
||||
.top_left_with_margins_on(state.ids.inv_alignment[who], 10.0 + i as f64 * 30.0, 0.0)
|
||||
Text::new(&format!("{}x {}", slot.quantity, &itemname))
|
||||
.top_left_with_margins_on(
|
||||
state.ids.inv_alignment[who],
|
||||
15.0 + i as f64 * 20.0 + total_text_height,
|
||||
0.0,
|
||||
)
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.font_size(self.fonts.cyri.scale(20))
|
||||
.wrap_by_word()
|
||||
.w(max_width)
|
||||
.color(Color::Rgba(
|
||||
1.0,
|
||||
1.0,
|
||||
@ -554,6 +562,15 @@ impl<'a> Trade<'a> {
|
||||
if is_present { 1.0 } else { 0.0 },
|
||||
))
|
||||
.set(state.ids.inv_textslots[i + who * MAX_TRADE_SLOTS], ui);
|
||||
let label_height = match ui
|
||||
.widget_graph()
|
||||
.widget(state.ids.inv_textslots[i + who * MAX_TRADE_SLOTS])
|
||||
.map(|widget| widget.rect)
|
||||
{
|
||||
Some(label_rect) => label_rect.h(),
|
||||
None => 10.0,
|
||||
};
|
||||
total_text_height += label_height;
|
||||
}
|
||||
if total_quantity == 0 {
|
||||
Text::new("Nothing!")
|
||||
|
Loading…
Reference in New Issue
Block a user