Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data conversion #141

Merged
merged 7 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ pub enum DataFormat {
#[strum(to_string = "Ruby Marshal")]
Marshal,
#[strum(to_string = "RON")]
Ron,
Ron { pretty: bool },
#[strum(to_string = "JSON")]
Json,
Json { pretty: bool },
}

impl DataFormat {
pub fn extension(self) -> &'static str {
match self {
Self::Marshal => "rxdata",
Self::Ron => "ron",
Self::Json => "json",
Self::Ron { .. } => "ron",
Self::Json { .. } => "json",
}
}
}
Expand Down
90 changes: 0 additions & 90 deletions crates/core/src/data_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,96 +366,6 @@ impl Data {
}
Ok(())
}

pub fn convert_project(
&mut self,
filesystem: &impl luminol_filesystem::FileSystem,
config: &luminol_config::project::Config,
to: luminol_config::DataFormat,
) -> color_eyre::Result<()> {
let from_handler = data_formats::Handler::new(config.project.data_format);
let to_handler = data_formats::Handler::new(to);

let Self::Loaded {
actors,
animations,
armors,
classes,
common_events,
enemies,
items,
map_infos,
scripts,
skills,
states,
system,
tilesets,
troops,
weapons,
..
} = self
else {
panic!("project not loaded")
};

to_handler.write_nil_padded(&actors.get_mut().data, filesystem, "Actors")?;
from_handler.remove_file(filesystem, "Actors")?;

to_handler.write_nil_padded(&animations.get_mut().data, filesystem, "Animations")?;
from_handler.remove_file(filesystem, "Animations")?;

to_handler.write_nil_padded(&armors.get_mut().data, filesystem, "Armors")?;
from_handler.remove_file(filesystem, "Armors")?;

to_handler.write_nil_padded(&classes.get_mut().data, filesystem, "Classes")?;
from_handler.remove_file(filesystem, "Classes")?;

to_handler.write_nil_padded(&common_events.get_mut().data, filesystem, "CommonEvents")?;
from_handler.remove_file(filesystem, "CommonEvents")?;

to_handler.write_nil_padded(&enemies.get_mut().data, filesystem, "Enemies")?;
from_handler.remove_file(filesystem, "Enemies")?;

to_handler.write_nil_padded(&items.get_mut().data, filesystem, "Items")?;
from_handler.remove_file(filesystem, "Items")?;

to_handler.write_nil_padded(&skills.get_mut().data, filesystem, "Skills")?;
from_handler.remove_file(filesystem, "Skills")?;

to_handler.write_nil_padded(&states.get_mut().data, filesystem, "States")?;
from_handler.remove_file(filesystem, "States")?;

to_handler.write_nil_padded(&tilesets.get_mut().data, filesystem, "Tilesets")?;
from_handler.remove_file(filesystem, "Tilesets")?;

to_handler.write_nil_padded(&troops.get_mut().data, filesystem, "Troops")?;
from_handler.remove_file(filesystem, "Troops")?;

to_handler.write_nil_padded(&weapons.get_mut().data, filesystem, "Weapons")?;
from_handler.remove_file(filesystem, "Weapons")?;

// special handling
to_handler.write_data(
&scripts.get_mut().data,
filesystem,
&config.project.scripts_path,
)?;
from_handler.remove_file(filesystem, &config.project.scripts_path)?;

to_handler.write_data(&system.get_mut(), filesystem, "System")?;
from_handler.remove_file(filesystem, "System")?;

to_handler.write_data(&map_infos.get_mut().data, filesystem, "MapInfos")?;
from_handler.remove_file(filesystem, "MapInfos")?;

for id in map_infos.get_mut().data.keys() {
let map: rpg::Map = from_handler.read_data(filesystem, format!("Map{id:0>3}"))?;
to_handler.write_data(&map, filesystem, format!("Map{id:0>3}"))?;
from_handler.remove_file(filesystem, format!("Map{id:0>3}"))?;
}

Ok(())
}
}

macro_rules! nested_ref_getter {
Expand Down
Loading