Skip to content

Commit

Permalink
Load from RTP on native too
Browse files Browse the repository at this point in the history
  • Loading branch information
melody-rs committed Jun 29, 2024
1 parent e64d80a commit f34e61a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
3 changes: 1 addition & 2 deletions crates/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,10 @@ impl<'res> UpdateState<'res> {
self.toasts,
format!("Failed to find suitable path for the RTP {missing_rtp}")
);
// FIXME we should probably load rtps from the RTP/<rtp> paths on non-wasm targets
#[cfg(not(target_arch = "wasm32"))]
info!(
self.toasts,
format!("You may want to set an RTP path for {missing_rtp}")
format!("You may want to set an RTP path for {missing_rtp} (you can place it in the RTP folder)")
);
#[cfg(target_arch = "wasm32")]
info!(self.toasts, format!("Please place the {missing_rtp} RTP in the 'RTP/{missing_rtp}' subdirectory in your project directory"));
Expand Down
24 changes: 22 additions & 2 deletions crates/filesystem/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ impl FileSystem {
#[cfg(windows)]
impl FileSystem {
fn find_rtp_paths(
filesystem: &host::FileSystem,
config: &luminol_config::project::Config,
global_config: &luminol_config::global::Config,
) -> (Vec<camino::Utf8PathBuf>, Vec<String>) {
Expand Down Expand Up @@ -293,6 +294,14 @@ impl FileSystem {
}
}

let path = camino::Utf8PathBuf::from("RTP").join(rtp);
if let Ok(exists) = filesystem.exists(&path) {
if exists {
paths.push(path);
continue;
}
}

if let Some(path) = global_config.rtp_paths.get(rtp) {
let path = camino::Utf8PathBuf::from(path);
if path.exists() {
Expand All @@ -312,6 +321,7 @@ impl FileSystem {
#[cfg(not(any(windows, target_arch = "wasm32")))]
impl FileSystem {
fn find_rtp_paths(
filesystem: &host::FileSystem,
config: &luminol_config::project::Config,
global_config: &luminol_config::global::Config,
) -> (Vec<camino::Utf8PathBuf>, Vec<String>) {
Expand All @@ -337,6 +347,14 @@ impl FileSystem {
}
}

let path = camino::Utf8PathBuf::from("RTP").join(rtp);
if let Ok(exists) = filesystem.exists(&path) {
if exists {
paths.push(path);
continue;
}
}

missing_rtps.push(rtp.to_string());
}
}
Expand Down Expand Up @@ -380,9 +398,11 @@ impl FileSystem {
.map(archiver::FileSystem::new)
.transpose()?;

list.push(host);
// FIXME: handle missing rtps
let (found_rtps, missing_rtps) = Self::find_rtp_paths(project_config, global_config);
let (found_rtps, missing_rtps) = Self::find_rtp_paths(&host, project_config, global_config);

list.push(host);

for path in found_rtps {
list.push(host::FileSystem::new(path))
}
Expand Down
10 changes: 10 additions & 0 deletions crates/graphics/src/loaders/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,13 @@ impl Loader {
&self.placeholder_image
}
}

// can't use Arc because of orphan rule, must use &instead (this does allow for for &Texture to be used in Image::new tho)
impl From<&Texture> for egui::load::SizedTexture {
fn from(val: &Texture) -> Self {
egui::load::SizedTexture {
id: val.texture_id,
size: val.size_vec2(),
}
}
}

0 comments on commit f34e61a

Please sign in to comment.