Skip to content

Commit

Permalink
fix state not modifying
Browse files Browse the repository at this point in the history
  • Loading branch information
mokurin000 committed Nov 25, 2022
1 parent d326c20 commit e29e38f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 77 deletions.
62 changes: 0 additions & 62 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ rust-version = "1.60"

[dependencies]
egui = "0.19.0"
eframe = { version = "0.19.0", features = ["persistence"] }
serde = { version = "1", features = ["derive"] }
eframe = { version = "0.19.0", features = [] }
cavestory-save-lib = "2.4.1"
rfd = "0.10.0"
strum = "0.24.1"
Expand Down
16 changes: 3 additions & 13 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ use std::{fs, path::PathBuf};
use cavestory_save::{GameProfile, Profile};

use cavestory_save::items::*;
use serde::{Deserialize, Serialize};
use strum::IntoEnumIterator;

#[derive(Serialize, Deserialize)]
pub struct App {
#[serde(skip)]
#[cfg(not(target_arch = "wasm32"))]
path: Option<PathBuf>,
#[serde(skip)]
profile: Option<GameProfile>,
#[serde(skip)]
raw_profile: Option<Profile>,
#[serde(skip)]
weapon_num: usize,
}

Expand Down Expand Up @@ -48,9 +43,7 @@ impl App {

impl eframe::App for App {
/// Called by the frame work to save state before shutdown.
fn save(&mut self, storage: &mut dyn eframe::Storage) {
eframe::set_value(storage, eframe::APP_KEY, self);
}
fn save(&mut self, _storage: &mut dyn eframe::Storage) {}

/// Called each time the UI needs repainting, which may be many times per second.
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
Expand Down Expand Up @@ -99,8 +92,7 @@ impl eframe::App for App {
#[cfg(target_arch = "wasm32")]
if false {} // todo: pick/save file on web

if let Some(_) = &self.raw_profile {
let profile = &mut self.profile.unwrap();
if let Some(profile) = &mut self.profile {
ui.label("Heal");
ui.add(egui::Slider::new(&mut profile.health, -1..=50));

Expand Down Expand Up @@ -138,14 +130,12 @@ impl eframe::App for App {
}

ui.horizontal(|ui| {
/*
if let Some(raw) = &self.raw_profile {
if ui.button("Undo all").clicked() {
self.profile = Some(GameProfile::dump(raw));
self.weapon_num = self.count_weapon().unwrap();
}
}
*/
});

ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| {
Expand Down

0 comments on commit e29e38f

Please sign in to comment.