diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d0ef08e12..9de948c9a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Adlet caves - Durability free areas (`/area_add no_durability ...`) - Added Brazilian Portuguese translation. +- Added additional confirmation when trading for nothing. ### Changed diff --git a/assets/voxygen/i18n/en/hud/trade.ftl b/assets/voxygen/i18n/en/hud/trade.ftl index f17762a3d7..7fbebaee3e 100644 --- a/assets/voxygen/i18n/en/hud/trade.ftl +++ b/assets/voxygen/i18n/en/hud/trade.ftl @@ -29,3 +29,4 @@ hud-trade-tooltip_hint_2 = hud-trade-your_offer = Your offer hud-trade-their_offer = Their offer hud-trade-amount_input = Select an item +hud-confirm-trade-for-nothing = Really give away these items in exchange for nothing? diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 86405fe2a8..4a29265d82 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -3183,12 +3183,16 @@ impl Hud { } else { self.force_ungrab = true }; + self.show.prompt_dialog = None; } events.push(Event::TradeAction(action)); }, trade::TradeEvent::SetDetailsMode(mode) => { self.show.trade_details = mode; }, + trade::TradeEvent::ShowPrompt(prompt) => { + self.show.prompt_dialog = Some(prompt); + }, } } } diff --git a/voxygen/src/hud/trade.rs b/voxygen/src/hud/trade.rs index dbca96376f..63599aec65 100644 --- a/voxygen/src/hud/trade.rs +++ b/voxygen/src/hud/trade.rs @@ -19,7 +19,10 @@ use common_net::sync::WorldSyncExt; use i18n::Localization; use crate::{ - hud::bag::{BackgroundIds, InventoryScroller}, + hud::{ + bag::{BackgroundIds, InventoryScroller}, + Event as HudEvent, PromptDialogSettings, + }, ui::{ fonts::Fonts, slot::{ContentSize, SlotMaker}, @@ -36,11 +39,11 @@ use super::{ }; use std::borrow::Cow; -#[derive(Debug)] pub enum TradeEvent { TradeAction(TradeAction), SetDetailsMode(bool), HudUpdate(HudUpdate), + ShowPrompt(PromptDialogSettings), } #[derive(Debug)] @@ -98,6 +101,7 @@ pub struct Trade<'a> { msm: &'a MaterialStatManifest, pulse: f32, show: &'a mut Show, + needs_thirdconfirm: bool, } impl<'a> Trade<'a> { @@ -131,6 +135,7 @@ impl<'a> Trade<'a> { msm, pulse, show, + needs_thirdconfirm: false, } } } @@ -552,6 +557,10 @@ impl<'a> Trade<'a> { 1.0, )) .set(state.ids.inv_textslots[who * MAX_TRADE_SLOTS], ui); + + if !ours { + self.needs_thirdconfirm = true; + } } } @@ -590,7 +599,17 @@ impl<'a> Trade<'a> { .set(state.ids.accept_button, ui) .was_clicked() { - event = Some(TradeAction::Accept(trade.phase())); + if matches!(trade.phase, TradePhase::Review) && self.needs_thirdconfirm { + event = Some(TradeEvent::ShowPrompt(PromptDialogSettings::new( + self.localized_strings + .get_msg("hud-confirm-trade-for-nothing") + .to_string(), + HudEvent::TradeAction(TradeAction::Accept(trade.phase())), + None, + ))); + } else { + event = Some(TradeEvent::TradeAction(TradeAction::Accept(trade.phase()))); + } } if Button::image(self.imgs.button) @@ -606,9 +625,9 @@ impl<'a> Trade<'a> { .set(state.ids.decline_button, ui) .was_clicked() { - event = Some(TradeAction::Decline); + event = Some(TradeEvent::TradeAction(TradeAction::Decline)); } - event.map(TradeEvent::TradeAction) + event } fn input_item_amount(