Skip to content

Commit

Permalink
Merge pull request #161 from 20kdc/new-project-fixes
Browse files Browse the repository at this point in the history
Create .luminol directory when saving data_cache & mark resources as modified by default
  • Loading branch information
melody-rs authored Feb 4, 2025
2 parents 4953fc7 + 9266d44 commit b9501b6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
29 changes: 24 additions & 5 deletions crates/core/src/data_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ macro_rules! from_defaults {
($parent:ident, $child:ident) => {
RefCell::new(rpg::$parent {
data: vec![rpg::$child::default()],
..Default::default()
modified: true,
})
};
}
Expand Down Expand Up @@ -181,26 +181,39 @@ impl Data {

pub fn from_defaults() -> Self {
let mut map_infos = std::collections::HashMap::with_capacity(16);
map_infos.insert(1, rpg::MapInfo::default());
map_infos.insert(
1,
rpg::MapInfo {
order: 1,
..Default::default()
},
);
let map_infos = RefCell::new(rpg::MapInfos {
data: map_infos,
..Default::default()
modified: true,
});

let system = rpg::System {
magic_number: rand::random(),
modified: true,
..Default::default()
};
let system = RefCell::new(system);

let scripts = vec![]; // FIXME legality of providing defualt scripts is unclear
let scripts = RefCell::new(rpg::Scripts {
data: scripts,
..Default::default()
modified: true,
});

let mut maps = std::collections::HashMap::with_capacity(32);
maps.insert(1, rpg::Map::default());
maps.insert(
1,
rpg::Map {
modified: true,
..Default::default()
},
);
let maps = RefCell::new(maps);

Self::Loaded {
Expand Down Expand Up @@ -320,6 +333,12 @@ impl Data {
.struct_names(true)
.enumerate_arrays(true);

// this is autocreated on load. however:
// since we're creating project config now, we need this directory
filesystem
.create_dir(".luminol")
.wrap_err("While creating .luminol")?;

let project_config = ron::ser::to_string_pretty(&config.project, pretty_config.clone())
.wrap_err("While serializing .luminol/config")?;
filesystem
Expand Down
2 changes: 1 addition & 1 deletion crates/data/src/rmxp/tileset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Tileset {
#[serde(with = "optional_path_serde")]
#[marshal(with = "optional_path_alox")]
pub tileset_name: Path,
pub autotile_names: Vec<String>,
pub autotile_names: [String; 7],
#[serde(with = "optional_path_serde")]
#[marshal(with = "optional_path_alox")]
pub panorama_name: Path,
Expand Down

0 comments on commit b9501b6

Please sign in to comment.