mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
use own settings to have less crashes
This commit is contained in:
parent
d71e78a080
commit
9f541530f1
5 changed files with 62 additions and 68 deletions
33
noita-proxy/Cargo.lock
generated
33
noita-proxy/Cargo.lock
generated
|
@ -18,16 +18,6 @@ version = "0.1.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046"
|
checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "accesskit"
|
|
||||||
version = "0.16.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "99b76d84ee70e30a4a7e39ab9018e2b17a6a09e31084176cc7c0b2dec036ba45"
|
|
||||||
dependencies = [
|
|
||||||
"enumn",
|
|
||||||
"serde",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "addr2line"
|
name = "addr2line"
|
||||||
version = "0.24.2"
|
version = "0.24.2"
|
||||||
|
@ -63,7 +53,6 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"getrandom",
|
"getrandom",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"serde",
|
|
||||||
"version_check",
|
"version_check",
|
||||||
"zerocopy",
|
"zerocopy",
|
||||||
]
|
]
|
||||||
|
@ -793,7 +782,6 @@ checksum = "775cfde491852059e386c4e1deb4aef381c617dc364184c6f6afee99b87c402b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"emath",
|
"emath",
|
||||||
"serde",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -811,7 +799,6 @@ dependencies = [
|
||||||
"glow",
|
"glow",
|
||||||
"glutin",
|
"glutin",
|
||||||
"glutin-winit",
|
"glutin-winit",
|
||||||
"home",
|
|
||||||
"image",
|
"image",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"log",
|
"log",
|
||||||
|
@ -821,8 +808,6 @@ dependencies = [
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"ron",
|
|
||||||
"serde",
|
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
|
@ -839,14 +824,11 @@ version = "0.29.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "53eafabcce0cb2325a59a98736efe0bf060585b437763f8c476957fb274bb974"
|
checksum = "53eafabcce0cb2325a59a98736efe0bf060585b437763f8c476957fb274bb974"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
|
||||||
"ahash",
|
"ahash",
|
||||||
"emath",
|
"emath",
|
||||||
"epaint",
|
"epaint",
|
||||||
"log",
|
"log",
|
||||||
"nohash-hasher",
|
"nohash-hasher",
|
||||||
"ron",
|
|
||||||
"serde",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -872,7 +854,6 @@ dependencies = [
|
||||||
"egui",
|
"egui",
|
||||||
"log",
|
"log",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
"serde",
|
|
||||||
"smithay-clipboard",
|
"smithay-clipboard",
|
||||||
"web-time",
|
"web-time",
|
||||||
"webbrowser",
|
"webbrowser",
|
||||||
|
@ -943,7 +924,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b1fe0049ce51d0fb414d029e668dd72eb30bc2b739bf34296ed97bd33df544f3"
|
checksum = "b1fe0049ce51d0fb414d029e668dd72eb30bc2b739bf34296ed97bd33df544f3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"serde",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -976,17 +956,6 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "enumn"
|
|
||||||
version = "0.1.14"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2f9ed6b3789237c8a0c1c505af1c7eb2c560df6186f01b098c3a1064ea532f38"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "epaint"
|
name = "epaint"
|
||||||
version = "0.29.1"
|
version = "0.29.1"
|
||||||
|
@ -1002,7 +971,6 @@ dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"nohash-hasher",
|
"nohash-hasher",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"serde",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1972,6 +1940,7 @@ dependencies = [
|
||||||
"quick-xml",
|
"quick-xml",
|
||||||
"rand",
|
"rand",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
"ron",
|
||||||
"rustc-hash 2.0.0",
|
"rustc-hash 2.0.0",
|
||||||
"self-replace",
|
"self-replace",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
@ -11,12 +11,13 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
eframe = { version="0.29.1", features = ["persistence", "glow", "default_fonts"], default-features = false }
|
eframe = { version="0.29.1", features = ["glow", "default_fonts"], default-features = false }
|
||||||
egui-file-dialog = "0.7.0"
|
egui-file-dialog = "0.7.0"
|
||||||
egui_extras = { version = "0.29.1", features = ["all_loaders"] }
|
egui_extras = { version = "0.29.1", features = ["all_loaders"] }
|
||||||
egui_plot = "0.29.0"
|
egui_plot = "0.29.0"
|
||||||
image = { version = "0.25.1", default-features = false, features = ["png", "webp"] }
|
image = { version = "0.25.1", default-features = false, features = ["png", "webp"] }
|
||||||
|
|
||||||
|
ron = "0.8.1"
|
||||||
tungstenite = "0.24.0"
|
tungstenite = "0.24.0"
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
|
@ -60,4 +61,4 @@ lto = true
|
||||||
strip = true
|
strip = true
|
||||||
|
|
||||||
[profile.release-lto]
|
[profile.release-lto]
|
||||||
inherits = "release"
|
inherits = "release"
|
|
@ -33,6 +33,8 @@ use std::{
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use std::{net::IpAddr, path::PathBuf};
|
use std::{net::IpAddr, path::PathBuf};
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::{Read, Write};
|
||||||
use steamworks::{LobbyId, SteamAPIInitError};
|
use steamworks::{LobbyId, SteamAPIInitError};
|
||||||
use tangled::Peer;
|
use tangled::Peer;
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
@ -61,7 +63,7 @@ pub(crate) enum GameMode {
|
||||||
// MestariMina, // TODO later
|
// MestariMina, // TODO later
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Decode, Encode, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Decode, Encode, Clone, Serialize, Deserialize, PartialEq)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub struct GameSettings {
|
pub struct GameSettings {
|
||||||
seed: u64,
|
seed: u64,
|
||||||
|
@ -141,7 +143,7 @@ enum AppState {
|
||||||
AskSavestateReset,
|
AskSavestateReset,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
struct PlayerAppearance {
|
struct PlayerAppearance {
|
||||||
player_color: PlayerColor,
|
player_color: PlayerColor,
|
||||||
player_picker: PlayerPicker,
|
player_picker: PlayerPicker,
|
||||||
|
@ -160,7 +162,7 @@ impl Default for PlayerAppearance {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
struct AppSavedState {
|
struct AppSavedState {
|
||||||
addr: String,
|
addr: String,
|
||||||
|
@ -244,9 +246,6 @@ pub struct App {
|
||||||
appearance: PlayerAppearance,
|
appearance: PlayerAppearance,
|
||||||
}
|
}
|
||||||
|
|
||||||
const MODMANAGER: &str = "modman";
|
|
||||||
const APPEARANCE: &str = "appearance";
|
|
||||||
|
|
||||||
fn filled_group<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
|
fn filled_group<R>(ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse<R> {
|
||||||
let style = ui.style();
|
let style = ui.style();
|
||||||
let frame = egui::Frame {
|
let frame = egui::Frame {
|
||||||
|
@ -279,31 +278,50 @@ fn square_button_icon(ui: &mut Ui, icon: egui::Image) -> egui::Response {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Default)]
|
||||||
|
pub struct Settings {
|
||||||
|
color: PlayerAppearance,
|
||||||
|
app: AppSavedState,
|
||||||
|
modmanager: ModmanagerSettings,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn settings_get() -> Settings {
|
||||||
|
if let Ok(s) = std::env::current_exe() {
|
||||||
|
let file = s.parent().unwrap().join("proxy.ron");
|
||||||
|
if let Ok(mut file) = File::open(file) {
|
||||||
|
let mut s = String::new();
|
||||||
|
let _ = file.read_to_string(&mut s);
|
||||||
|
ron::from_str::<Settings>(&s).unwrap_or_default()
|
||||||
|
} else {
|
||||||
|
Settings::default()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Settings::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn settings_set(app: AppSavedState, color: PlayerAppearance, modmanager: ModmanagerSettings) {
|
||||||
|
if let Ok(s) = std::env::current_exe() {
|
||||||
|
let settings = Settings {
|
||||||
|
app,
|
||||||
|
color,
|
||||||
|
modmanager,
|
||||||
|
};
|
||||||
|
let file = s.parent().unwrap().join("proxy.ron");
|
||||||
|
let settings = ron::to_string(&settings).unwrap();
|
||||||
|
if let Ok(mut file) = File::create(file) {
|
||||||
|
file.write_all(settings.as_bytes()).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn new(cc: &eframe::CreationContext<'_>, args: Args) -> Self {
|
pub fn new(cc: &eframe::CreationContext<'_>, args: Args) -> Self {
|
||||||
cc.egui_ctx.set_visuals(Visuals::dark());
|
cc.egui_ctx.set_visuals(Visuals::dark());
|
||||||
let mut saved_state: AppSavedState = cc
|
let settings = settings_get();
|
||||||
.storage
|
let mut saved_state: AppSavedState = settings.app;
|
||||||
.and_then(|storage| eframe::get_value(storage, eframe::APP_KEY))
|
let modmanager_settings: ModmanagerSettings = settings.modmanager;
|
||||||
.unwrap_or_default();
|
let appearance: PlayerAppearance = settings.color;
|
||||||
let modmanager_settings: ModmanagerSettings = cc
|
|
||||||
.storage
|
|
||||||
.and_then(|storage| eframe::get_value(storage, MODMANAGER))
|
|
||||||
.unwrap_or_default();
|
|
||||||
let appearance: PlayerAppearance = cc
|
|
||||||
.storage
|
|
||||||
.and_then(|storage| {
|
|
||||||
eframe::get_value(storage, APPEARANCE).inspect(|x| info!("Loaded appearance {x:?}"))
|
|
||||||
})
|
|
||||||
.unwrap_or_else(|| {
|
|
||||||
// Fallback to loading from the old location
|
|
||||||
cc.storage
|
|
||||||
.and_then(|storage| {
|
|
||||||
eframe::get_value(storage, eframe::APP_KEY)
|
|
||||||
.inspect(|x| info!("Loaded appearance from fallback: {x:?}"))
|
|
||||||
})
|
|
||||||
.unwrap_or_default()
|
|
||||||
});
|
|
||||||
saved_state.times_started += 1;
|
saved_state.times_started += 1;
|
||||||
|
|
||||||
info!("Setting fonts...");
|
info!("Setting fonts...");
|
||||||
|
@ -364,6 +382,10 @@ impl App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_settings(&self) {
|
||||||
|
settings_set(self.app_saved_state.clone(), self.appearance.clone(), self.modmanager_settings.clone())
|
||||||
|
}
|
||||||
|
|
||||||
fn get_netman_init(&self) -> NetManagerInit {
|
fn get_netman_init(&self) -> NetManagerInit {
|
||||||
let steam_nickname = if let Ok(steam) = &self.steam_state {
|
let steam_nickname = if let Ok(steam) = &self.steam_state {
|
||||||
Some(steam.get_user_name(steam.get_my_id()))
|
Some(steam.get_user_name(steam.get_my_id()))
|
||||||
|
@ -1160,11 +1182,8 @@ impl eframe::App for App {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
fn on_exit(&mut self, _: Option<&eframe::glow::Context>) {
|
||||||
fn save(&mut self, storage: &mut dyn eframe::Storage) {
|
self.set_settings()
|
||||||
eframe::set_value(storage, eframe::APP_KEY, &self.app_saved_state);
|
|
||||||
eframe::set_value(storage, MODMANAGER, &self.modmanager_settings);
|
|
||||||
eframe::set_value(storage, APPEARANCE, &self.appearance);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1320,4 +1339,4 @@ pub fn host_cli(port: u16) {
|
||||||
let player_path = netmaninit.player_path.clone();
|
let player_path = netmaninit.player_path.clone();
|
||||||
let netman = net::NetManager::new(varient, netmaninit);
|
let netman = net::NetManager::new(varient, netmaninit);
|
||||||
netman.start_inner(player_path, true).unwrap();
|
netman.start_inner(player_path, true).unwrap();
|
||||||
}
|
}
|
|
@ -1025,6 +1025,8 @@ local function find_target()
|
||||||
if not did_hit then
|
if not did_hit then
|
||||||
last_did_hit = false
|
last_did_hit = false
|
||||||
target = id
|
target = id
|
||||||
|
target_is_polied = false
|
||||||
|
target_has_ambrosia = false
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -128,6 +128,9 @@ local function target()
|
||||||
local my_x, my_y = GameGetCameraPos()
|
local my_x, my_y = GameGetCameraPos()
|
||||||
local mx, my
|
local mx, my
|
||||||
local to_x, to_y = EntityGetTransform(cam_target.entity)
|
local to_x, to_y = EntityGetTransform(cam_target.entity)
|
||||||
|
if to_x == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
if GameGetIsGamepadConnected() then
|
if GameGetIsGamepadConnected() then
|
||||||
mx, my = InputGetJoystickAnalogStick(0, 1)
|
mx, my = InputGetJoystickAnalogStick(0, 1)
|
||||||
mx, my = mx * 256 + to_x, my * 256 + to_y
|
mx, my = mx * 256 + to_x, my * 256 + to_y
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue