parent
0e8056c1d2
commit
efa4f89915
7 changed files with 37 additions and 34 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize,Debug, Default)]
|
#[derive(Serialize, Deserialize, Debug, Default)]
|
||||||
pub(crate) struct AreaConfig {
|
pub(crate) struct AreaConfig {
|
||||||
#[serde(rename = "killedEnemies")]
|
#[serde(rename = "killedEnemies")]
|
||||||
pub killed_enemies: Vec<String>,
|
pub killed_enemies: Vec<String>,
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
mod game_config;
|
|
||||||
mod area_config;
|
mod area_config;
|
||||||
|
mod game_config;
|
||||||
|
mod player_config;
|
||||||
mod quest_config;
|
mod quest_config;
|
||||||
mod world_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::collections::VecDeque;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use game_config::GameConfig;
|
|
||||||
use area_config::AreaConfig;
|
|
||||||
use quest_config::QuestConfig;
|
|
||||||
use player_config::PlayerConfig;
|
|
||||||
use world_config::WorldConfig;
|
use world_config::WorldConfig;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -38,11 +38,15 @@ impl CoreConfig {
|
||||||
// This assumes that there are never any semicolons elsewhere!
|
// This assumes that there are never any semicolons elsewhere!
|
||||||
let mut rest: VecDeque<&str> = rest_config.split(";").collect();
|
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 player_config: PlayerConfig =
|
||||||
let world_config: WorldConfig = serde_json::from_str(rest.pop_front().ok_or("No World Config")?)?;
|
serde_json::from_str(rest.pop_front().ok_or("No Player Config")?)?;
|
||||||
let quest_config: QuestConfig = serde_json::from_str(rest.pop_front().ok_or("No Quest 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 area_configs: Vec<AreaConfig> = rest
|
||||||
|
.iter()
|
||||||
.map(|s| serde_json::from_str(s))
|
.map(|s| serde_json::from_str(s))
|
||||||
.filter_map(|s| s.ok())
|
.filter_map(|s| s.ok())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
@ -63,7 +67,8 @@ impl CoreConfig {
|
||||||
pub(crate) fn to_string(&self) -> Result<String, Box<dyn Error>> {
|
pub(crate) fn to_string(&self) -> Result<String, Box<dyn Error>> {
|
||||||
let game_config = serde_json::to_string(&self.game_config)?;
|
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()
|
.iter()
|
||||||
.map(|a| serde_json::to_string(a))
|
.map(|a| serde_json::to_string(a))
|
||||||
.filter_map(|a| a.ok())
|
.filter_map(|a| a.ok())
|
||||||
|
|
@ -75,12 +80,10 @@ impl CoreConfig {
|
||||||
serde_json::to_string(&self.world_config)?,
|
serde_json::to_string(&self.world_config)?,
|
||||||
serde_json::to_string(&self.quest_config)?,
|
serde_json::to_string(&self.quest_config)?,
|
||||||
area_config.join(";"),
|
area_config.join(";"),
|
||||||
].join(";");
|
]
|
||||||
|
.join(";");
|
||||||
|
|
||||||
let full_config = [
|
let full_config = [game_config, rest_config].join(SETTINGS_SPLIT);
|
||||||
game_config,
|
|
||||||
rest_config,
|
|
||||||
].join(SETTINGS_SPLIT);
|
|
||||||
|
|
||||||
Ok(full_config)
|
Ok(full_config)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
mod cli;
|
mod cli;
|
||||||
mod data;
|
mod data;
|
||||||
|
|
||||||
use std::error::Error;
|
use crate::cli::Options;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use eframe;
|
use eframe;
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use crate::cli::Options;
|
use std::error::Error;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
let options = Options::parse();
|
let options = Options::parse();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue