Skip to content

Commit

Permalink
mark input as handled via viewport method
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 committed Dec 1, 2023
1 parent b7438a2 commit d362900
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
4 changes: 1 addition & 3 deletions pets-lib/src/dialogue/autoload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ impl DBoxInterface {
});

let mut dbox = self.instantiate_dbox();
let set_active = dbox.callable("set_active");
{
let mut dbox = dbox.bind_mut();
dbox.set_ix(ix.clone());
dbox.do_draw();
dbox.tween_into_view(true)
.connect("finished".into(), set_active);
dbox.tween_into_view(true);
}
}

Expand Down
28 changes: 8 additions & 20 deletions pets-lib/src/dialogue/dbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use dialogical::{Interaction, Page};
use dialogical::{Metaline, Metaline::*, PageMeta};

use godot::engine::tween::TransitionType;
use godot::engine::{IPanelContainer, InputEvent, PanelContainer, RichTextLabel, Tween};
use godot::engine::{IPanelContainer, InputEvent, PanelContainer, RichTextLabel, Tween, Viewport};
use godot::prelude::*;

use crate::consts::dialogue::*;
Expand Down Expand Up @@ -83,19 +83,6 @@ impl DialogBox {
self.node.get_node_as("VSplit/Content")
}

// TODO remove this when upgrading to godot 4.2
#[func]
pub fn set_active(&mut self) {
println!("set active");
self.active = true;
}

#[func]
pub fn set_inactive(&mut self) {
println!("set inactive");
self.active = false;
}

/// Sets the speaker and message text from strings
///
/// DON'T USE THIS FOR INTERACTIONS!!
Expand Down Expand Up @@ -182,6 +169,7 @@ impl DialogBox {
.set_trans(DBOX_TWEEN_TRANS)
.unwrap();

self.active = up;
self.tween = Some(y_tween.clone());
y_tween
}
Expand Down Expand Up @@ -219,15 +207,15 @@ impl IPanelContainer for DialogBox {
self.current_page_number += 1;

if self.current_page_number >= ix.pages.len() {
self.tween_into_view(false)
.connect("finished".into(), self.node.callable("set_inactive"));
self.tween_into_view(false);
self.current_page_number = 0;

return;
} else {
self.goto_page(self.current_page_number);
self.do_draw();
}

self.goto_page(self.current_page_number);
self.do_draw();
// mark the input as handled
self.node.get_viewport().unwrap().set_input_as_handled();
}
}
}

0 comments on commit d362900

Please sign in to comment.