UI: Fixes and enhancements to trading window

This commit is contained in:
Xeriab Nabil 2021-08-05 23:08:56 +03:00
parent c855b14b14
commit ea5de81f9b
9 changed files with 105 additions and 44 deletions

Binary file not shown.

Binary file not shown.

BIN
assets/voxygen/element/ui/bag/inv_middle_bg_bag.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/ui/bag/inv_middle_frame.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/element/ui/bag/second_phase_scrollbar_bg.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -3,7 +3,7 @@
/// Localization for "global" English
(
string_map: {
"hud.trade.trade_window": "Trade window",
"hud.trade.trade_window": "Trade",
"hud.trade.phase1_description": "Drag the items you want to trade\n into the corresponding area.",
"hud.trade.phase2_description": "The trade is now locked to give you\n time to review it.",
/// Phase3 should only be visible for a few milliseconds if everything is working properly, but is included for completeness
@ -21,6 +21,8 @@
"hud.trade.coin": "coin(s)",
"hud.trade.tooltip_hint_1": "<Shift-Click to Add/Remove from trade.>",
"hud.trade.tooltip_hint_2": "<Ctrl-Click to Auto-Balance with this.>",
"hud.trade.your_offer": "Your offer",
"hud.trade.their_offer": "Their offer",
},

View File

@ -56,7 +56,9 @@ widget_ids! {
inventory_title,
inventory_title_bg,
scrollbar_bg,
second_phase_scrollbar_bg,
scrollbar_slots,
left_scrollbar_slots,
}
}
@ -138,11 +140,11 @@ impl<'a> InventoryScroller<'a> {
} else {
self.imgs.inv_bg_armor
})
.w_h(424.0, 708.0);
.w_h(424.0, if self.show_bag_inv { 548.0 } else { 708.0 });
if self.on_right {
bg = bg.bottom_right_with_margins_on(ui.window, 60.0, 5.0);
bg = bg.bottom_right_with_margins_on(ui.window, 70.0, 5.0);
} else {
bg = bg.bottom_left_with_margins_on(ui.window, 60.0, 5.0);
bg = bg.bottom_left_with_margins_on(ui.window, 230.0, 5.0);
}
bg.color(Some(UI_MAIN)).set(self.bg_ids.bg, ui);
Image::new(if self.show_bag_inv {
@ -150,7 +152,7 @@ impl<'a> InventoryScroller<'a> {
} else {
self.imgs.inv_frame
})
.w_h(424.0, 708.0)
.w_h(424.0, if self.show_bag_inv { 548.0 } else { 708.0 })
.middle_of(self.bg_ids.bg)
.color(Some(UI_HIGHLIGHT_0))
.set(self.bg_ids.bg_frame, ui);
@ -187,6 +189,7 @@ impl<'a> InventoryScroller<'a> {
ui: &mut UiCell<'_>,
) {
let space_max = self.inventory.slots().count();
// Slots Scrollbar
if space_max > 45 && !self.show_bag_inv {
// Scrollbar-BG
@ -217,12 +220,34 @@ impl<'a> InventoryScroller<'a> {
.middle_of(state.ids.scrollbar_bg)
.set(state.ids.scrollbar_slots, ui);
};
// This is just for the offeror inventory scrollbar
if space_max >= 108 && self.show_bag_inv {
// Left bag scrollbar background
Image::new(self.imgs.second_phase_scrollbar_bg)
.w_h(9.0, 434.0)
.bottom_right_with_margins_on(self.bg_ids.bg_frame, 42.0, 3.0)
.color(Some(UI_HIGHLIGHT_0))
.set(state.ids.second_phase_scrollbar_bg, ui);
// Left bag scrollbar
Scrollbar::y_axis(state.ids.inv_alignment)
.thickness(5.0)
.h(384.0)
.color(UI_MAIN)
.middle_of(state.ids.second_phase_scrollbar_bg)
.set(state.ids.left_scrollbar_slots, ui);
}
// Alignment for Grid
Rectangle::fill_with(
[362.0, if self.show_bag_inv { 600.0 } else { 200.0 }],
[362.0, if self.show_bag_inv { 440.0 } else { 200.0 }],
color::TRANSPARENT,
)
.bottom_left_with_margins_on(self.bg_ids.bg_frame, 29.0, 46.5)
.bottom_left_with_margins_on(
self.bg_ids.bg_frame,
29.0,
if self.show_bag_inv { 28.0 } else { 46.5 },
)
.scroll_kids_vertically()
.set(state.ids.inv_alignment, ui);

View File

@ -441,6 +441,8 @@ image_ids! {
inv_frame: "voxygen.element.ui.bag.inv_frame",
inv_frame_bag: "voxygen.element.ui.bag.inv_frame_bag",
inv_bg_bag: "voxygen.element.ui.bag.inv_bg_bag",
inv_middle_bg_bag: "voxygen.element.ui.bag.inv_middle_bg_bag",
inv_middle_frame: "voxygen.element.ui.bag.inv_middle_frame",
char_art: "voxygen.element.ui.bag.icons.character",
inv_slot: "voxygen.element.ui.bag.buttons.inv_slot",
inv_slot_grey: "voxygen.element.ui.bag.buttons.inv_slot_grey",
@ -453,6 +455,7 @@ image_ids! {
inv_slot_sel: "voxygen.element.ui.bag.buttons.inv_slot_sel",
scrollbar_bg: "voxygen.element.ui.generic.slider.scrollbar",
scrollbar_bg_big: "voxygen.element.ui.generic.slider.scrollbar_1",
second_phase_scrollbar_bg: "voxygen.element.ui.bag.second_phase_scrollbar_bg",
inv_tab_active: "voxygen.element.ui.bag.buttons.inv_tab_active",
inv_tab_inactive: "voxygen.element.ui.bag.buttons.inv_tab_inactive",
inv_tab_inactive_hover: "voxygen.element.ui.bag.buttons.inv_tab_inactive",

View File

@ -1,17 +1,12 @@
use super::{
img_ids::{Imgs, ImgsRot},
item_imgs::ItemImgs,
slots::{SlotManager, TradeSlot},
TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN,
};
use crate::{
hud::bag::{BackgroundIds, InventoryScroller},
ui::{
fonts::Fonts,
slot::{ContentSize, SlotMaker},
ImageFrame, ItemTooltip, ItemTooltipManager, ItemTooltipable,
},
use conrod_core::{
color,
position::Relative,
widget::{self, Button, Image, Rectangle, State as ConrodState, Text},
widget_ids, Color, Colorable, Labelable, Positionable, Sizeable, UiCell, Widget, WidgetCommon,
};
use specs::Entity as EcsEntity;
use vek::*;
use client::Client;
use common::{
comp::{
@ -21,15 +16,23 @@ use common::{
trade::{PendingTrade, SitePrices, TradeAction, TradePhase},
};
use common_net::sync::WorldSyncExt;
use conrod_core::{
color,
position::Relative,
widget::{self, Button, Image, Rectangle, State as ConrodState, Text},
widget_ids, Color, Colorable, Labelable, Positionable, Sizeable, UiCell, Widget, WidgetCommon,
};
use i18n::Localization;
use specs::Entity as EcsEntity;
use vek::*;
use crate::{
hud::bag::{BackgroundIds, InventoryScroller},
ui::{
fonts::Fonts,
slot::{ContentSize, SlotMaker},
ImageFrame, ItemTooltip, ItemTooltipManager, ItemTooltipable,
},
};
use super::{
img_ids::{Imgs, ImgsRot},
item_imgs::ItemImgs,
slots::{SlotManager, TradeSlot},
TEXT_COLOR, UI_HIGHLIGHT_0, UI_MAIN,
};
pub struct State {
ids: Ids,
@ -99,17 +102,18 @@ impl<'a> Trade<'a> {
}
}
}
const MAX_TRADE_SLOTS: usize = 16;
impl<'a> Trade<'a> {
fn background(&mut self, state: &mut ConrodState<'_, State>, ui: &mut UiCell<'_>) {
Image::new(self.imgs.inv_bg_bag)
.w_h(424.0, 708.0)
.middle()
Image::new(self.imgs.inv_middle_bg_bag)
.w_h(424.0, 500.0)
.color(Some(UI_MAIN))
.mid_bottom_with_margin_on(ui.window, 281.0)
.set(state.ids.bg, ui);
Image::new(self.imgs.inv_frame_bag)
.w_h(424.0, 708.0)
Image::new(self.imgs.inv_middle_frame)
.w_h(424.0, 500.0)
.middle_of(state.ids.bg)
.color(Some(UI_HIGHLIGHT_0))
.set(state.ids.bg_frame, ui);
@ -173,9 +177,9 @@ impl<'a> Trade<'a> {
let inventory = inventories.get(entity)?;
// Alignment for Grid
let mut alignment = Rectangle::fill_with([200.0, 340.0], color::TRANSPARENT);
let mut alignment = Rectangle::fill_with([200.0, 180.0], color::TRANSPARENT);
if !ours {
alignment = alignment.top_left_with_margins_on(state.ids.bg, 180.0, 46.5);
alignment = alignment.top_left_with_margins_on(state.ids.bg, 180.0, 32.5);
} else {
alignment = alignment.right_from(state.ids.inv_alignment[1 - who], 0.0);
}
@ -198,9 +202,27 @@ impl<'a> Trade<'a> {
.unwrap_or_else(|| format!("Player {}", who));
let offer_header = self
.localized_strings
.get("hud.trade.persons_offer")
.replace("{playername}", &name);
.client
.player_list()
.get(&uid)
.map(|_| {
self.localized_strings
.get("hud.trade.your_offer")
.to_owned()
})
.or_else(|| {
self.client
.state()
.read_storage::<Stats>()
.get(entity)
.map(|_| {
self.localized_strings
.get("hud.trade.their_offer")
.to_owned()
})
})
.unwrap_or_else(|| format!("Player {}", who));
Text::new(&offer_header)
.up_from(state.ids.inv_alignment[who], 20.0)
.font_id(self.fonts.cyri.conrod_id)
@ -214,7 +236,7 @@ impl<'a> Trade<'a> {
.get("hud.trade.has_accepted")
.replace("{playername}", &name);
Text::new(&accept_indicator)
.down_from(state.ids.inv_alignment[who], 20.0)
.down_from(state.ids.inv_alignment[who], 50.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(20))
.color(Color::Rgba(
@ -461,7 +483,7 @@ impl<'a> Trade<'a> {
.w_h(31.0 * 5.0, 12.0 * 2.0)
.hover_image(self.imgs.button_hover)
.press_image(self.imgs.button_press)
.bottom_left_with_margins_on(state.ids.bg, 80.0, 60.0)
.bottom_left_with_margins_on(state.ids.bg, 110.0, 47.0)
.label(self.localized_strings.get("hud.trade.accept"))
.label_font_size(self.fonts.cyri.scale(14))
.label_color(TEXT_COLOR)