From 77d13376d3cb2221e35f842fb4694ee952682c94 Mon Sep 17 00:00:00 2001 From: Imbris Date: Fri, 10 Apr 2020 00:33:35 -0400 Subject: [PATCH] Add right click to use, latern is not armor tweaks --- assets/common/items/armor/lantern/black_0.ron | 8 ------ assets/common/items/armor/lantern/green_0.ron | 8 ------ assets/common/items/debug/green_0.ron | 7 ++--- assets/common/items/lantern/black_0.ron | 5 ++++ assets/common/items/lantern/green_0.ron | 5 ++++ voxygen/src/ui/widgets/slot.rs | 27 ++++++++++++------- 6 files changed, 30 insertions(+), 30 deletions(-) delete mode 100644 assets/common/items/armor/lantern/black_0.ron delete mode 100644 assets/common/items/armor/lantern/green_0.ron create mode 100644 assets/common/items/lantern/black_0.ron create mode 100644 assets/common/items/lantern/green_0.ron diff --git a/assets/common/items/armor/lantern/black_0.ron b/assets/common/items/armor/lantern/black_0.ron deleted file mode 100644 index 950cc28f41..0000000000 --- a/assets/common/items/armor/lantern/black_0.ron +++ /dev/null @@ -1,8 +0,0 @@ -Item( - name: "Black Lantern", - description: "Used by city guards.", - kind: Armor( - kind: Lantern(Black0), - stats: (20), - ), -) diff --git a/assets/common/items/armor/lantern/green_0.ron b/assets/common/items/armor/lantern/green_0.ron deleted file mode 100644 index c37daf9b99..0000000000 --- a/assets/common/items/armor/lantern/green_0.ron +++ /dev/null @@ -1,8 +0,0 @@ -Item( - name: "Lime Zest Lantern", - description: "It has an opening that could fit a ring...", - kind: Armor( - kind: Lantern(Green0), - stats: (20), - ), -) diff --git a/assets/common/items/debug/green_0.ron b/assets/common/items/debug/green_0.ron index c37daf9b99..ea7d5cbcc7 100644 --- a/assets/common/items/debug/green_0.ron +++ b/assets/common/items/debug/green_0.ron @@ -1,8 +1,5 @@ Item( name: "Lime Zest Lantern", - description: "It has an opening that could fit a ring...", - kind: Armor( - kind: Lantern(Green0), - stats: (20), - ), + description: "It has an opening that could fit a ring...", + kind: Lantern(Green0), ) diff --git a/assets/common/items/lantern/black_0.ron b/assets/common/items/lantern/black_0.ron new file mode 100644 index 0000000000..cabb197911 --- /dev/null +++ b/assets/common/items/lantern/black_0.ron @@ -0,0 +1,5 @@ +Item( + name: "Black Lantern", + description: "Used by city guards.", + kind: Lantern(Black0), +) diff --git a/assets/common/items/lantern/green_0.ron b/assets/common/items/lantern/green_0.ron new file mode 100644 index 0000000000..ea7d5cbcc7 --- /dev/null +++ b/assets/common/items/lantern/green_0.ron @@ -0,0 +1,5 @@ +Item( + name: "Lime Zest Lantern", + description: "It has an opening that could fit a ring...", + kind: Lantern(Green0), +) diff --git a/voxygen/src/ui/widgets/slot.rs b/voxygen/src/ui/widgets/slot.rs index e1ba13e862..82607485e4 100644 --- a/voxygen/src/ui/widgets/slot.rs +++ b/voxygen/src/ui/widgets/slot.rs @@ -217,9 +217,10 @@ where _ => (), } + let input = ui.widget_input(widget); // TODO: make more robust wrt multiple events in the same frame (eg event order // may matter) TODO: handle taps as well - let click_count = ui.widget_input(widget).clicks().left().count(); + let click_count = input.clicks().left().count(); if click_count > 0 { let odd_num_clicks = click_count % 2 == 1; self.state = if let ManagerState::Selected(id, other_slot) = self.state { @@ -255,17 +256,25 @@ where }; } - // If not dragging and there is a drag event on this slot start dragging - if ui.widget_input(widget).drags().left().next().is_some() { + // Use on right click if not dragging + if input.clicks().right().next().is_some() { match self.state { ManagerState::Selected(_, _) | ManagerState::Idle => { - // Start dragging if widget is filled - if let Some(img) = content_img { - self.state = ManagerState::Dragging(widget, slot, img); - } + self.events.push(Event::Used(slot)); + // If something is selected, deselect + self.state = ManagerState::Idle; }, - // Already dragging or id doesn't match - _ => {}, + ManagerState::Dragging(_, _, _) => {}, + } + } + + // If not dragging and there is a drag event on this slot start dragging + if input.drags().left().next().is_some() + && !matches!(self.state, ManagerState::Dragging(_, _, _)) + { + // Start dragging if widget is filled + if let Some(img) = content_img { + self.state = ManagerState::Dragging(widget, slot, img); } }