Skip to content

Commit

Permalink
Fix some file loading issues
Browse files Browse the repository at this point in the history
  • Loading branch information
janhohenheim committed Jan 21, 2024
1 parent 764f346 commit 7af4b9d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/file_system_interaction/game_state_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
use spew::prelude::*;
use std::borrow::Cow;
use std::fs;
use std::path::{Path, PathBuf};
use std::path::PathBuf;

pub(crate) fn game_state_serialization_plugin(app: &mut App) {
app.add_event::<GameSaveRequest>()
Expand Down Expand Up @@ -171,5 +171,5 @@ fn handle_save_requests(

fn get_save_path(filename: impl Into<Cow<'static, str>>) -> PathBuf {
let filename = filename.into().to_string();
Path::new("saves").join(filename).with_extension("sav.ron")
format!("saves/{filename}.sav.ron").into()
}
13 changes: 1 addition & 12 deletions src/file_system_interaction/level_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,7 @@ fn load_world(
level_handles: Res<LevelAssets>,
) -> Result<()> {
for load in load_requests.read() {
let mut path = Path::new("levels")
.join(load.filename.clone())
.with_extension("lvl.ron")
.to_str()
.with_context(|| {
format!(
"Failed to convert path to string for filename: {}",
load.filename
)
})?
.to_string();
path = path.replace('\\', "/");
let path = format!("levels/{}.lvl.ron", load.filename.clone());
let handle = match level_handles.levels.get(&path) {
Some(handle) => handle,
None => {
Expand Down
13 changes: 1 addition & 12 deletions src/world_interaction/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use bevy_egui::{egui, EguiContexts, EguiPlugin};
use bevy_mod_sysfail::*;
use leafwing_input_manager::prelude::ActionState;
use serde::{Deserialize, Serialize};
use std::path::Path;
use unicode_segmentation::UnicodeSegmentation;

mod resources;
Expand Down Expand Up @@ -46,17 +45,7 @@ fn set_current_dialog(
mut actions_frozen: ResMut<ActionsFrozen>,
) -> Result<()> {
for dialog_event in dialog_events.read() {
let path = Path::new("dialogs")
.join(&dialog_event.dialog.0.clone())
.with_extension("dlg.ron")
.to_str()
.with_context(|| {
format!(
"Failed to convert dialog path to string for dialog: {:?}",
dialog_event.dialog
)
})?
.to_owned();
let path = format!("dialogs/{}.dlg.ron", dialog_event.dialog.0.clone());
let dialog_handle = match dialog_handles.dialogs.get(&path) {
Some(handle) => handle,
None => {
Expand Down

0 comments on commit 7af4b9d

Please sign in to comment.