Launcher : retient la taille de sa fenetre (et l'etat agrandi) dans launcher.ini

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
linkatplugandClaude Opus 5.5 committed 2026-12-05 04:29:11 +01:00
1 parent 5c84413723
commit ae0a743c5d
1 file changed
+36 -3
+36 -3
View File
@@ -49,6 +49,10 @@ struct Config {
sound: bool,
skip_intro: bool,
verbose: bool,
/// taille de la fenêtre (points), retenue d'une fois sur l'autre ; 0 = taille par défaut
win_w: u32,
win_h: u32,
maximized: bool,
}
impl Default for Config {
@@ -60,6 +64,9 @@ impl Default for Config {
sound: true,
skip_intro: false,
verbose: false,
win_w: 0,
win_h: 0,
maximized: false,
}
}
}
@@ -83,6 +90,9 @@ impl Config {
"sound" => c.sound = b,
"skip_intro" => c.skip_intro = b,
"verbose" => c.verbose = b,
"window_width" => c.win_w = v.parse().unwrap_or(0),
"window_height" => c.win_h = v.parse().unwrap_or(0),
"maximized" => c.maximized = b,
_ => {}
}
}
@@ -96,13 +106,17 @@ impl Config {
}
let b = |x: bool| if x { "1" } else { "0" };
let text = format!(
"lang={}\ngame_path={}\ninstall_dir={}\nsound={}\nskip_intro={}\nverbose={}\n",
"lang={}\ngame_path={}\ninstall_dir={}\nsound={}\nskip_intro={}\nverbose={}\n\
window_width={}\nwindow_height={}\nmaximized={}\n",
if self.lang == Lang::En { "en" } else { "fr" },
self.game_path,
self.install_dir,
b(self.sound),
b(self.skip_intro),
b(self.verbose)
b(self.verbose),
self.win_w,
self.win_h,
b(self.maximized)
);
let _ = std::fs::write(f, text);
}
@@ -1716,6 +1730,18 @@ impl eframe::App for App {
}
self.gs_saved = self.gs.clone();
}
// taille de la fenêtre : retenue quand on ne la redimensionne plus (bouton de souris relâché)
let (rect, maxi, mini, down) =
self.ctx.input(|i| (i.viewport().inner_rect, i.viewport().maximized, i.viewport().minimized, i.pointer.any_down()));
if !down && mini != Some(true) {
if let Some(m) = maxi {
self.cfg.maximized = m;
}
if let (Some(r), Some(false)) = (rect, maxi) {
self.cfg.win_w = r.width().round() as u32;
self.cfg.win_h = r.height().round() as u32;
}
}
if self.cfg != self.saved {
self.cfg.save();
self.saved = self.cfg.clone();
@@ -1724,10 +1750,17 @@ impl eframe::App for App {
}
fn main() -> eframe::Result {
let cfg = Config::load();
let size = if cfg.win_w >= 760 && cfg.win_h >= 600 {
[cfg.win_w.min(7680) as f32, cfg.win_h.min(4320) as f32]
} else {
[1000.0, 840.0]
};
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_title("DoubleTroubleRecomp")
.with_inner_size([1000.0, 840.0])
.with_inner_size(size)
.with_maximized(cfg.maximized)
.with_min_inner_size([760.0, 600.0]),
..Default::default()
};