parent
0e8056c1d2
commit
efa4f89915
7 changed files with 37 additions and 34 deletions
|
|
@ -4,7 +4,7 @@ use clap::Parser;
|
|||
#[command(author, version, about, name = "Nostalgaia Save Editor")]
|
||||
pub(crate) struct Options {
|
||||
pub(crate) save_file: String,
|
||||
|
||||
|
||||
#[arg(short, long)]
|
||||
pub(crate) gui: bool,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize,Debug, Default)]
|
||||
#[derive(Serialize, Deserialize, Debug, Default)]
|
||||
pub(crate) struct AreaConfig {
|
||||
#[serde(rename = "killedEnemies")]
|
||||
pub killed_enemies: Vec<String>,
|
||||
|
|
@ -12,4 +12,4 @@ pub(crate) struct AreaConfig {
|
|||
pub custom_beacon_resetables: Vec<String>,
|
||||
#[serde(rename = "visibilityBitMask")]
|
||||
pub visibility_bit_mask: i64,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
mod game_config;
|
||||
mod area_config;
|
||||
mod game_config;
|
||||
mod player_config;
|
||||
mod quest_config;
|
||||
mod world_config;
|
||||
mod player_config;
|
||||
|
||||
use area_config::AreaConfig;
|
||||
use game_config::GameConfig;
|
||||
use player_config::PlayerConfig;
|
||||
use quest_config::QuestConfig;
|
||||
use std::collections::VecDeque;
|
||||
use std::error::Error;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use game_config::GameConfig;
|
||||
use area_config::AreaConfig;
|
||||
use quest_config::QuestConfig;
|
||||
use player_config::PlayerConfig;
|
||||
use world_config::WorldConfig;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -38,15 +38,19 @@ impl CoreConfig {
|
|||
// This assumes that there are never any semicolons elsewhere!
|
||||
let mut rest: VecDeque<&str> = rest_config.split(";").collect();
|
||||
|
||||
let player_config: PlayerConfig = serde_json::from_str(rest.pop_front().ok_or("No Player Config")?)?;
|
||||
let world_config: WorldConfig = serde_json::from_str(rest.pop_front().ok_or("No World Config")?)?;
|
||||
let quest_config: QuestConfig = serde_json::from_str(rest.pop_front().ok_or("No Quest Config")?)?;
|
||||
|
||||
let area_configs: Vec<AreaConfig> = rest.iter()
|
||||
let player_config: PlayerConfig =
|
||||
serde_json::from_str(rest.pop_front().ok_or("No Player Config")?)?;
|
||||
let world_config: WorldConfig =
|
||||
serde_json::from_str(rest.pop_front().ok_or("No World Config")?)?;
|
||||
let quest_config: QuestConfig =
|
||||
serde_json::from_str(rest.pop_front().ok_or("No Quest Config")?)?;
|
||||
|
||||
let area_configs: Vec<AreaConfig> = rest
|
||||
.iter()
|
||||
.map(|s| serde_json::from_str(s))
|
||||
.filter_map(|s| s.ok())
|
||||
.collect();
|
||||
|
||||
|
||||
if rest.len() != area_configs.len() {
|
||||
return Err("Failed Parsing Area Configs".into());
|
||||
}
|
||||
|
|
@ -63,25 +67,24 @@ impl CoreConfig {
|
|||
pub(crate) fn to_string(&self) -> Result<String, Box<dyn Error>> {
|
||||
let game_config = serde_json::to_string(&self.game_config)?;
|
||||
|
||||
let area_config: Vec<String> = self.area_configs
|
||||
let area_config: Vec<String> = self
|
||||
.area_configs
|
||||
.iter()
|
||||
.map(|a| serde_json::to_string(a))
|
||||
.filter_map(|a| a.ok())
|
||||
.collect();
|
||||
|
||||
|
||||
let rest_config = [
|
||||
serde_json::to_string(&self.player_config)?,
|
||||
serde_json::to_string(&self.player_config)?,
|
||||
serde_json::to_string(&self.world_config)?,
|
||||
serde_json::to_string(&self.quest_config)?,
|
||||
area_config.join(";"),
|
||||
].join(";");
|
||||
|
||||
let full_config = [
|
||||
game_config,
|
||||
rest_config,
|
||||
].join(SETTINGS_SPLIT);
|
||||
|
||||
]
|
||||
.join(";");
|
||||
|
||||
let full_config = [game_config, rest_config].join(SETTINGS_SPLIT);
|
||||
|
||||
Ok(full_config)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,4 +209,4 @@ pub(crate) struct PlayerConfig {
|
|||
pub hoover_dead: bool,
|
||||
#[serde(rename = "regionName")]
|
||||
pub region_name: String,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,4 +102,4 @@ pub(crate) struct QuestConfig {
|
|||
pub quest_stage_chained_hero: i64,
|
||||
#[serde(rename = "questStage_BrendenMerkle")]
|
||||
pub quest_stage_brenden_merkle: i64,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,4 +83,4 @@ pub(crate) struct WorldConfig {
|
|||
pub hv_water_control_type: i64,
|
||||
#[serde(rename = "HV_Water_LerpIndex")]
|
||||
pub hv_water_lerp_index: i64,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
src/main.rs
12
src/main.rs
|
|
@ -1,23 +1,23 @@
|
|||
mod cli;
|
||||
mod data;
|
||||
|
||||
use std::error::Error;
|
||||
use crate::cli::Options;
|
||||
use clap::Parser;
|
||||
use eframe;
|
||||
use eframe::egui;
|
||||
use crate::cli::Options;
|
||||
use std::error::Error;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let options = Options::parse();
|
||||
|
||||
|
||||
let save_data = data::CoreConfig::parse_file(options.save_file)?;
|
||||
|
||||
|
||||
println!("{}", save_data.to_string()?);
|
||||
|
||||
|
||||
if options.gui {
|
||||
run_gui()?;
|
||||
}
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue