Compare commits

..

No commits in common. "b2f28c36f18ae913c00552688b10146a649344b6" and "8199ed790cc9ef65a35b918f5d9b51d4475a938b" have entirely different histories.

6 changed files with 43 additions and 99 deletions

View file

@ -54,6 +54,7 @@ Press **ESC** to view these any time from the in-game menu.
- **T**: Cruise control
- **R**: Rotate (hold + move mouse)
- **Y**: Rotation stabilizer
- **`**: Fast forward conversation
- **AWSD/Shift/Ctrl**: Move
- **J/K/U/L/I/O**: Rotate
- **F11**: Fullscreen

View file

@ -25,8 +25,6 @@ pub const CHATS: &[&str] = &[
include_str!("chats/thebe.yaml"),
];
pub const TEXT_CONTINUE: &str = "Continue...";
pub const TOKEN_CHAT: &str = "chat";
pub const TOKEN_MSG: &str = "msg";
pub const TOKEN_SYSTEM: &str = "system";
@ -48,7 +46,6 @@ pub const TOKEN_IF_INLINE: &str = "if "; // for lines like `- if foo:`
pub const DEFAULT_SOUND: &str = "chat";
pub const MAX_BRANCH_DEPTH: usize = 64;
pub const ENABLE_CHOICE_TIMER: bool = false;
pub const CHOICE_TIMER: f64 = 40.0 * var::DEFAULT_CHAT_SPEED as f64;
pub const LETTERS_PER_SECOND: f32 = 17.0;
pub const TALKER_SPEED_FACTOR: f32 = var::DEFAULT_CHAT_SPEED / LETTERS_PER_SECOND;
@ -108,7 +105,6 @@ pub struct Chat {
pub internal_id: usize,
pub position: ChatPos,
pub timer: f64,
pub message_open: bool,
pub talker: Talker,
}
@ -477,7 +473,6 @@ impl ChatDB {
let mut processed_a_choice = false;
match current_item {
Some(Value::String(message)) => {
chat.message_open = true;
event.send(ChatEvent::SpawnMessage(
message.to_string(),
hud::LogLevel::Chat,
@ -525,35 +520,23 @@ impl ChatDB {
let key = key.as_str();
match (key, value) {
(Some(TOKEN_MSG), Value::String(message)) => {
let loglevel = hud::LogLevel::Chat;
if loglevel.is_subtitle() {
chat.message_open = true;
}
event.send(ChatEvent::SpawnMessage(
message.to_string(),
loglevel,
hud::LogLevel::Chat,
sound.clone(),
));
}
(Some(TOKEN_SYSTEM), Value::String(message)) => {
let loglevel = hud::LogLevel::Info;
if loglevel.is_subtitle() {
chat.message_open = true;
}
event.send(ChatEvent::SpawnMessage(
message.to_string(),
loglevel,
hud::LogLevel::Info,
sound.clone(),
));
}
(Some(TOKEN_WARN), Value::String(message)) => {
let loglevel = hud::LogLevel::Warning;
if loglevel.is_subtitle() {
chat.message_open = true;
}
event.send(ChatEvent::SpawnMessage(
message.to_string(),
loglevel,
hud::LogLevel::Warning,
sound.clone(),
));
}
@ -592,7 +575,11 @@ impl ChatDB {
}
None => {
if chat.position.len() == 0 {
// Here it used to spawn the "Disconnected" message.
event.send(ChatEvent::SpawnMessage(
"Disconnected.".to_string(),
hud::LogLevel::Info,
DEFAULT_SOUND.to_string(),
));
event.send(ChatEvent::DespawnAllChats);
}
}
@ -646,19 +633,6 @@ impl ChatDB {
break;
}
}
// Add a "Continue" choice to any conversation line that doesn't define any choices
let choices_available = key > 0;
if chat.message_open && !choices_available {
let goto: Vec<usize> = chat.position.clone();
event.send(ChatEvent::SpawnChoice(
String::from(TEXT_CONTINUE),
0,
goto,
true,
None,
));
}
}
}
}
@ -697,7 +671,6 @@ pub fn handle_new_conversations(
let mut chat = Chat {
internal_id: chat_id,
position: vec![0],
message_open: false,
timer: time.elapsed_seconds_f64(),
talker: event.talker.clone(),
};
@ -755,12 +728,6 @@ pub fn handle_chat_events(
}
ChatEvent::DespawnAllChats => {
commands.entity(chat_entity).despawn();
// also despawn all choices (keep in sync with DespawnAllChoices handler)
for entity in &q_choices {
commands.entity(entity).despawn();
}
choice_key = 0;
}
ChatEvent::SpawnMessage(message, level, sound) => {
match level {
@ -787,15 +754,11 @@ pub fn handle_chat_events(
);
}
}
if ENABLE_CHOICE_TIMER {
chat.timer = now
+ ((message.len() as f32).max(CHAT_SPEED_MIN_LEN)
* TALKER_SPEED_FACTOR
* chat.talker.talking_speed
/ settings.chat_speed) as f64;
} else {
chat.timer = f64::INFINITY;
}
chat.timer = now
+ ((message.len() as f32).max(CHAT_SPEED_MIN_LEN)
* TALKER_SPEED_FACTOR
* chat.talker.talking_speed
/ settings.chat_speed) as f64;
let sfx = audio::str2sfx(sound);
ew_sfx.send(audio::PlaySfxEvent(sfx));
@ -815,10 +778,8 @@ pub fn handle_chat_events(
},
));
choice_key += 1;
if ENABLE_CHOICE_TIMER && !nowait {
if !nowait {
chat.timer = now + CHOICE_TIMER / settings.chat_speed as f64;
} else {
chat.timer = f64::INFINITY;
}
}
ChatEvent::RunScript(script) => {
@ -848,8 +809,7 @@ fn handle_reply_keys(
settings: Res<var::Settings>,
q_choices: Query<&Choice>,
mut q_chats: Query<&mut Chat>,
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
mut ew_chat: EventWriter<ChatEvent>,
mut evwriter_sfx: EventWriter<audio::PlaySfxEvent>,
time: Res<Time>,
) {
let mut selected_choice: usize = 0;
@ -857,18 +817,10 @@ fn handle_reply_keys(
if keyboard_input.just_pressed(key) {
for choice in &q_choices {
if choice.key == selected_choice {
if choice.goto.is_empty() {
// Conversation ended. No need to advance the chat.
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
ew_chat.send(ChatEvent::DespawnAllChats);
break 'outer;
}
if let Ok(mut chat) = q_chats.get_single_mut() {
// Advance the chat.
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
evwriter_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
chat.timer = time.elapsed_seconds_f64();
chat.position = choice.goto.clone();
chat.message_open = false;
}
break 'outer;
}
@ -876,6 +828,13 @@ fn handle_reply_keys(
}
selected_choice += 1;
}
if keyboard_input.just_pressed(settings.key_next_chat_line) {
if let Ok(mut chat) = q_chats.get_single_mut() {
evwriter_sfx.send(audio::PlaySfxEvent(audio::Sfx::Click));
chat.timer = 0.0;
}
}
}
pub fn handle_chat_scripts(
@ -1028,11 +987,7 @@ pub fn update_chat_variables(
vars.set_in_scope(
"$",
"ar",
if settings.hud_active {
String::from("1")
} else {
String::from("0")
},
if settings.hud_active { String::from("1") } else { String::from("0") }
);
let wears_chefhat = if let Some(ava) = hud::PLAYER_AR_AVATARS.get(settings.ar_avatar) {
match ava.0 {

View file

@ -470,8 +470,8 @@
- You age slower, can fly further, time dilation from special relativity.
- label: skiprelativityintro
- Given the right speed, you age so slowly that you can literally go anywhere you want.
- set: timetravel
- Any *time* you want.
- set: timetravel
- Time travel! Only into the future though, of course.:
- Exactly.
- goto: continuemonologue

View file

@ -7,6 +7,7 @@ C: Camera
T: Cruise control
R: Rotate (hold + move mouse)
Y: Rotation stabilizer
`: Fast forward conversation
AWSD/Shift/Ctrl: Move
J/K/U/L/I/O: Rotate
F11: Fullscreen

View file

@ -213,7 +213,6 @@ pub enum Avatar {
Armor,
}
#[derive(Clone)]
pub enum LogLevel {
Achievement,
Always,
@ -225,18 +224,7 @@ pub enum LogLevel {
//Ping,
}
impl LogLevel {
pub fn is_subtitle(&self) -> bool {
match self {
LogLevel::Chat => true,
LogLevel::Info => true,
_ => false,
}
}
}
#[derive(Clone)]
pub struct Message {
struct Message {
text: String,
sender: String,
level: LogLevel,
@ -322,20 +310,6 @@ impl Log {
pub fn clear(&mut self) {
self.logs.clear();
}
pub fn get_subtitle_line(&self) -> Option<Message> {
let messages: Vec<&Message> = self
.logs
.iter()
.filter(|msg: &&Message| msg.level.is_subtitle())
.rev()
.take(1)
.collect();
if messages.len() > 0 {
return Some(messages[0].clone());
}
return None;
}
}
pub fn setup(
@ -1042,8 +1016,19 @@ fn update_hud(
// Display the last chat line as "subtitles"
if !q_chat.is_empty() {
if let Some(message) = log.get_subtitle_line() {
node_currentline.sections[0].value = message.format();
let messages: Vec<&Message> = log
.logs
.iter()
.filter(|msg: &&Message| match msg.level {
LogLevel::Chat => true,
LogLevel::Info => true,
_ => false,
})
.rev()
.take(1)
.collect();
if messages.len() > 0 {
node_currentline.sections[0].value = messages[0].format();
} else {
node_currentline.sections[0].value = "".to_string();
}

View file

@ -143,6 +143,7 @@ pub struct Settings {
pub key_reply8: KeyCode,
pub key_reply9: KeyCode,
pub key_reply10: KeyCode,
pub key_next_chat_line: KeyCode,
pub key_cheat_god_mode: KeyCode,
pub key_cheat_stop: KeyCode,
pub key_cheat_speed: KeyCode,
@ -285,6 +286,7 @@ impl Default for Settings {
key_reply8: KeyCode::Digit8,
key_reply9: KeyCode::Digit9,
key_reply10: KeyCode::Digit0,
key_next_chat_line: KeyCode::Backquote,
key_cheat_god_mode: KeyCode::KeyG,
key_cheat_stop: KeyCode::KeyZ,
key_cheat_speed: KeyCode::KeyV,