Skip to content

Commit

Permalink
mark input as handled for picking dialog choices
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 committed Jan 19, 2024
1 parent bf03b4d commit bf5fbc4
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions pets-lib/src/dialogue/dbox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ impl DialogBox {
}
}

/// close the dialog and tween choices away
pub fn end_interaction(&mut self) {
// close the dialog and tween choices away
self.current_page_number = 0;
self.current_ix = None;
self.tween_choices_wave(false);
Expand All @@ -176,6 +176,10 @@ impl DialogBox {
}
}

fn mark_input_handled(&mut self) {
self.base().get_viewport().unwrap().set_input_as_handled();
}

fn on_accept(&mut self) {
// go to next page
self.current_page_number += 1;
Expand All @@ -185,9 +189,6 @@ impl DialogBox {
}

self.do_draw();

// mark the input as handled
self.base().get_viewport().unwrap().set_input_as_handled();
}

pub fn process_choice_input(&mut self) {
Expand Down Expand Up @@ -261,11 +262,13 @@ impl IPanelContainer for DialogBox {
}

if self.awaiting_choice {
self.mark_input_handled();
self.process_choice_input();
return;
}

if event.is_action_pressed("ui_accept".into()) {
self.mark_input_handled();
self.on_accept();
}
}
Expand Down Expand Up @@ -297,12 +300,17 @@ impl DialogBox {
self.active
}

pub fn is_one_page(&self) -> bool {
let ix = self.current_ix.as_ref().unwrap();
ix.pages.len() == 1
}

pub fn set_ix(&mut self, ix: Interaction) {
self.current_ix = Some(ix);
self.current_page_number = 0;
self.do_draw();

if self.is_on_or_past_last_page() {
if self.is_one_page() {
let ending = self.current_ix_ending().unwrap().clone();
if let DialogueEnding::Choices(choices) = ending {
self.recreate_choice_labels(&choices);
Expand Down

0 comments on commit bf5fbc4

Please sign in to comment.