Skip to content

Commit

Permalink
Sorta start getting somewhere
Browse files Browse the repository at this point in the history
  • Loading branch information
melody-rs committed Oct 5, 2023
1 parent 689b1cb commit 4aaf372
Show file tree
Hide file tree
Showing 35 changed files with 447 additions and 395 deletions.
67 changes: 67 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ paste = "1.0.14"
thiserror = "1.0"
bitflags = "2.4.0"

parking_lot = "0.12.1"
parking_lot = { version = "0.12.1", features = ["deadlock_detection"] }
once_cell = "1.18.0"
crossbeam = "0.8.2"
dashmap = "5.5.3"
Expand All @@ -75,15 +75,24 @@ slab = { version = "0.4.9", features = ["serde"] }

itertools = "0.11.0"

rfd = "0.12.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
eframe.workspace = true
egui.workspace = true

[features]
steamworks = [] # ["dep:steamworks", "crc"]
rfd.workspace = true

parking_lot.workspace = true
once_cell.workspace = true

steamworks = { version = "0.10.0", optional = true }
crc = { version = "3.0.1", optional = true }

[features]
steamworks = ["dep:steamworks", "crc"]

[target.'cfg(windows)'.build-dependencies]
winres = "0.1"
Expand Down
4 changes: 2 additions & 2 deletions crates/luminol-filesystem/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rfd = "0.12.0"
rfd.workspace = true

thiserror.workspace = true
bitflags.workspace = true
Expand All @@ -27,4 +27,4 @@ luminol-data = { version = "0.1.0", path = "../luminol-data/" }
luminol-config = { version = "0.1.0", path = "../luminol-config/" }

[target.'cfg(windows)'.dependencies]
winreg = "0.51.0"
winreg = "0.51.0"
6 changes: 3 additions & 3 deletions crates/luminol-filesystem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
//
// You should have received a copy of the GNU General Public License
// along with Luminol. If not, see <http://www.gnu.org/licenses/>.
use std::io::prelude::*;

mod archiver;
mod erased;
mod host;
mod list;
mod path_cache;
pub mod project;

mod archiver;
pub mod project;
pub use project::FileSystem;
31 changes: 15 additions & 16 deletions crates/luminol-filesystem/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use luminol_core::filesystem::FileSystem as _;
use luminol_core::filesystem::{DirEntry, Error, Metadata, OpenFlags};

#[derive(Default)]
enum FileSystem {
pub enum FileSystem {
#[default]
Unloaded,
HostLoaded(host::FileSystem),
Expand All @@ -30,7 +30,7 @@ enum FileSystem {
},
}

enum File<'fs> {
pub enum File<'fs> {
Host(<host::FileSystem as luminol_core::filesystem::FileSystem>::File<'fs>),
Loaded(
<path_cache::FileSystem<list::FileSystem> as luminol_core::filesystem::FileSystem>::File<
Expand Down Expand Up @@ -121,12 +121,13 @@ impl FileSystem {
fn find_rtp_paths(
config: &luminol_config::project::Config,
global_config: &luminol_config::global::Config,
) -> Vec<camino::Utf8PathBuf> {
) -> (Vec<camino::Utf8PathBuf>, Vec<String>) {
let Some(section) = config.game_ini.section(Some("Game")) else {
return vec![];
return (vec![], vec![]);
};
let mut paths = vec![];
let mut seen_rtps = vec![];
let mut missing_rtps = vec![];
// FIXME: handle vx ace?
for rtp in ["RTP1", "RTP2", "RTP3"] {
if let Some(rtp) = section.get(rtp) {
Expand Down Expand Up @@ -179,15 +180,10 @@ impl FileSystem {
}
}

state!()
.toasts
.warning(format!("Failed to find suitable path for the RTP {rtp}"));
state!()
.toasts
.info(format!("You may want to set an RTP path for {rtp}"));
missing_rtps.push(rtp.to_string());
}
}
paths
(paths, missing_rtps)
}

#[cfg(not(windows))]
Expand Down Expand Up @@ -242,7 +238,9 @@ impl FileSystem {

list.push(host::FileSystem::new(path));

for path in Self::find_rtp_paths(&config, &global_config) {
// FIXME: handle missing rtps
let (found_rtps, missing_rtps) = Self::find_rtp_paths(&config, &global_config);
for path in found_rtps {
list.push(host::FileSystem::new(path))
}

Expand All @@ -259,10 +257,11 @@ impl FileSystem {
project_path: path.to_path_buf(),
};

if let Err(e) = state!().data_cache.load() {
*self = FileSystem::Unloaded;
return Err(e);
}
// FIXME: handle
// if let Err(e) = state!().data_cache.load() {
// *self = FileSystem::Unloaded;
// return Err(e);
// }

let mut projects: std::collections::VecDeque<_> = global_config
.recent_projects
Expand Down
5 changes: 3 additions & 2 deletions crates/luminol-graphics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
luminol-data = { version = "*", path = "../luminol-data/" }

image = "0.24.7"

glam = { version = "0.24.2", features = ["bytemuck"] }
Expand All @@ -28,3 +26,6 @@ bytemuck.workspace = true
itertools.workspace = true

camino.workspace = true

luminol-data = { version = "0.1.0", path = "../luminol-data/" }
luminol-core = { version = "0.1.0", path = "../luminol-core/" }
24 changes: 18 additions & 6 deletions crates/luminol-graphics/src/atlas_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,45 @@
//
// You should have received a copy of the GNU General Public License
// along with Luminol. If not, see <http://www.gnu.org/licenses/>.
use crate::primitives;

#[derive(Default, Debug)]
pub struct Cache {
atlases: dashmap::DashMap<usize, primitives::Atlas>,
atlases: dashmap::DashMap<usize, crate::tiles::Atlas>,
}

impl Cache {
pub fn load_atlas(
&self,
render_state: &egui_wgpu::RenderState,
filesystem: &impl luminol_core::filesystem::FileSystem,
image_cache: &crate::image_cache::Cache,
tileset: &luminol_data::rpg::Tileset,
) -> Result<primitives::Atlas, String> {
) -> Result<crate::tiles::Atlas, String> {
Ok(self
.atlases
.entry(tileset.id)
.or_try_insert_with(|| primitives::Atlas::new(tileset))?
.or_try_insert_with(|| {
crate::tiles::Atlas::new(render_state, filesystem, image_cache, tileset)
})?
.clone())
}

pub fn reload_atlas(
&self,
render_state: &egui_wgpu::RenderState,
filesystem: &impl luminol_core::filesystem::FileSystem,
image_cache: &crate::image_cache::Cache,
tileset: &luminol_data::rpg::Tileset,
) -> Result<primitives::Atlas, String> {
) -> Result<crate::tiles::Atlas, String> {
Ok(self
.atlases
.entry(tileset.id)
.insert(primitives::Atlas::new(tileset)?)
.insert(crate::tiles::Atlas::new(
render_state,
filesystem,
image_cache,
tileset,
)?)
.clone())
}

Expand Down
Loading

0 comments on commit 4aaf372

Please sign in to comment.