Skip to content

Commit

Permalink
page clears before tweening down
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 committed Jan 19, 2024
1 parent a18fd3e commit f14eea6
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions pets-lib/src/dialogue/dbox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,25 @@ impl DialogBox {
/// sets the speaker and message labels to the given page
pub fn goto_current_page(&mut self) {
let pageno = self.current_page_number;
let ix = self.current_ix.as_ref().unwrap().clone();

let Some(page) = ix.pages.get(pageno) else {
godot_warn!("Page out of bounds! {}", pageno);
return;
};
let ix = self.current_ix.as_ref();

self.update_meta(&page.metadata);
if let Some(ix) = ix {
let ix = ix.clone();
let Some(page) = ix.pages.get(pageno) else {
panic!("Page number {} out of range!", pageno);
};

let msg = page.content.clone();
let spk = spk_display(&self.speaker.temporary);
self.spk_txt = spk.into();
self.msg_txt = msg.into();
self.update_meta(&page.metadata);
self.spk_txt = spk_display(&self.speaker.temporary).into();
self.msg_txt = page.content.clone().into();
} else {
self.spk_txt = "".into();
self.msg_txt = "".into();
};
}

/// The method that moves the dialog box (on|off)-screen
/// and sets the `active` flag
pub fn tween_into_view(&mut self, up: bool) -> Gd<Tween> {
let node = self.base();
let viewport_y = node.get_viewport_rect().size.y;
Expand Down Expand Up @@ -151,6 +154,8 @@ impl DialogBox {

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);
self.tween_into_view(false);
}
Expand Down Expand Up @@ -261,7 +266,6 @@ impl IPanelContainer for DialogBox {
}

if event.is_action_pressed("ui_accept".into()) {
godot_print!(":D");
self.on_accept();
}
}
Expand Down

0 comments on commit f14eea6

Please sign in to comment.