Skip to content

Commit

Permalink
implement dialogical 0.8.1 minimum example (IT WORKSSSSSSSSSSSSSSSSSS…
Browse files Browse the repository at this point in the history
…SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS OMFGGGGGGGGGGGGGGGGG)
  • Loading branch information
Lamby777 committed Nov 30, 2023
1 parent 36d0e0f commit 7ab7f8d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pets-lib/src/dialogue/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
pub mod autoload;
pub mod dbox;

use dialogical::prelude::*;
use dialogical::InteractionMap;
use indoc::indoc;

use std::sync::OnceLock;

static INTERACTIONS: OnceLock<Vec<Interaction>> = OnceLock::new();
static INTERACTIONS: OnceLock<InteractionMap> = OnceLock::new();

macro_rules! packed_dialogue {
() => {
Expand All @@ -21,8 +21,8 @@ macro_rules! packed_dialogue {
};
}

// load dialogues
pub fn interactions() {
/// Load every interaction in the game from `packed.dgc`
pub fn ix_list() -> &'static InteractionMap {
INTERACTIONS.get_or_init(|| {
packed_dialogue!().expect(indoc! {"
Failed to load dialogues. If you are a player,
Expand All @@ -31,5 +31,5 @@ pub fn interactions() {
ran properly or manually compile the interaction
list yourself.
"})
});
})
}
1 change: 1 addition & 0 deletions pets-lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ mod prelude {
pub use crate::macros::*;
pub use crate::stats::*;

pub use crate::dialogue::ix_list;
pub use crate::world::interaction::manager::InteractionManager;

// is this bad practice? no clue and idc honestly
Expand Down
21 changes: 20 additions & 1 deletion pets-lib/src/world/interaction/zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,26 @@ pub struct InteractionZone {
impl InteractionZone {
#[func]
pub fn interact(&self) {
show_dialog!("Deez", "Test");
use dialogical::Metaline::*;
use dialogical::Speaker::*;

let ix_list = ix_list();
let ix = ix_list.get("Rodrick Sign #1").unwrap();
let page = ix.pages.get(0).unwrap();
let spk = page.metadata.speaker.clone();

let spk = match spk {
PageOnly(v) | Permanent(v) => v,
NoChange => unreachable!(),
};

let spk = match spk {
Named(v) => v,
Narrator => "".to_string(),
Unknown => "".to_string(),
};

show_dialog!(spk, "{}", page.content.clone());
}

#[func]
Expand Down

0 comments on commit 7ab7f8d

Please sign in to comment.