add transition and dialogue for exits (7.0)
This commit is contained in:
parent
0133731e97
commit
dd00686de0
|
@ -57,7 +57,6 @@ some more practical uses would be things like:
|
||||||
## todo
|
## todo
|
||||||
|
|
||||||
* test for bitsy 7.0 and implement new features
|
* test for bitsy 7.0 and implement new features
|
||||||
* add dialogues to exits
|
|
||||||
* titles can have multiple lines of dialog
|
* titles can have multiple lines of dialog
|
||||||
* dialogue names
|
* dialogue names
|
||||||
* implement Result return types on ::from functions so we can handle errors
|
* implement Result return types on ::from functions so we can handle errors
|
||||||
|
|
|
@ -46,6 +46,8 @@ pub struct Instance {
|
||||||
pub struct ExitInstance {
|
pub struct ExitInstance {
|
||||||
position: Position,
|
position: Position,
|
||||||
exit: Exit,
|
exit: Exit,
|
||||||
|
transition: Option<Transition>,
|
||||||
|
dialogue_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AnimationFrames {
|
pub trait AnimationFrames {
|
||||||
|
|
|
@ -396,6 +396,8 @@ pub fn room() -> Room {
|
||||||
position: Position { x: 10, y: 6 },
|
position: Position { x: 10, y: 6 },
|
||||||
effect: Transition::None,
|
effect: Transition::None,
|
||||||
},
|
},
|
||||||
|
transition: None,
|
||||||
|
dialogue_id: None
|
||||||
}],
|
}],
|
||||||
endings: vec![Instance {
|
endings: vec![Instance {
|
||||||
position: Position { x: 8, y: 7 },
|
position: Position { x: 8, y: 7 },
|
||||||
|
|
21
src/room.rs
21
src/room.rs
|
@ -1,5 +1,6 @@
|
||||||
use crate::{from_base36, optional_data_line, Exit, ExitInstance, Instance, Position, ToBase36};
|
use crate::{from_base36, optional_data_line, Exit, ExitInstance, Instance, Position, ToBase36};
|
||||||
use crate::game::{RoomType, RoomFormat};
|
use crate::game::{RoomType, RoomFormat};
|
||||||
|
use crate::exit::Transition;
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct Room {
|
pub struct Room {
|
||||||
|
@ -76,8 +77,17 @@ impl From<String> for Room {
|
||||||
let parts: Vec<&str> = last_line.split(' ').collect();
|
let parts: Vec<&str> = last_line.split(' ').collect();
|
||||||
let position = Position::from(parts[0].to_string()).unwrap();
|
let position = Position::from(parts[0].to_string()).unwrap();
|
||||||
let exit = Exit::from(format!("{} {}", parts[1], parts[2]));
|
let exit = Exit::from(format!("{} {}", parts[1], parts[2]));
|
||||||
|
let mut transition = None;
|
||||||
exits.push(ExitInstance { position, exit });
|
let mut dialogue_id = None;
|
||||||
|
let chunks = parts[3..].chunks(2);
|
||||||
|
for chunk in chunks {
|
||||||
|
if chunk[0] == "FX" {
|
||||||
|
transition = Some(Transition::from(chunk[1]));
|
||||||
|
} else if chunk[0] == "DLG" {
|
||||||
|
dialogue_id = Some(chunk[1].to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exits.push(ExitInstance { position, exit, transition, dialogue_id });
|
||||||
} else if last_line.starts_with("END") {
|
} else if last_line.starts_with("END") {
|
||||||
let last_line = last_line.replace("END ", "");
|
let last_line = last_line.replace("END ", "");
|
||||||
let ending_position: Vec<&str> = last_line.split(' ').collect();
|
let ending_position: Vec<&str> = last_line.split(' ').collect();
|
||||||
|
@ -163,9 +173,14 @@ impl Room {
|
||||||
|
|
||||||
for instance in &self.exits {
|
for instance in &self.exits {
|
||||||
exits.push_str(&format!(
|
exits.push_str(&format!(
|
||||||
"\nEXT {} {}",
|
"\nEXT {} {}{}{}{}",
|
||||||
instance.position.to_string(),
|
instance.position.to_string(),
|
||||||
instance.exit.to_string(),
|
instance.exit.to_string(),
|
||||||
|
if instance.transition.is_some() {
|
||||||
|
instance.transition.as_ref().unwrap().to_string()
|
||||||
|
} else {"".to_string()},
|
||||||
|
if instance.dialogue_id.is_some() {" DLG "} else {""},
|
||||||
|
instance.dialogue_id.as_ref().unwrap_or(&"".to_string()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue