Launcher : nouvelle identite visuelle

Theme labo & pizza (fond nuit, cartes, jaune Bud), banniere avec
diaporama des decors et vrai logo lus a l'execution dans la copie
du joueur (PCX, FLC), icone tiree de POINTER.PCX, gros bouton
JOUER, configuration repliee quand tout est pret, barre d'etat et
journal escamotable. Aucune image du jeu dans le depot.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
linkatplugandClaude Opus 5.5 committed 2026-12-05 02:56:16 +01:00
1 parent 90c398d531
commit 2c281ab3e3
2 files changed
+900 -201

No files matched your search

+374
View File
@@ -0,0 +1,374 @@
//! Visuels du launcher, lus à l'exécution dans la copie du jeu du joueur (jamais embarqués) :
//! décors PCX pour la bannière, logo tiré de BUDTTLE2.FLC, curseur POINTER.PCX pour l'icône.
//! Si les fichiers manquent, le launcher garde un thème sans image.
use std::path::Path;
/// image RGBA 8 bits, alpha non prémultiplié
pub struct Rgba {
pub w: usize,
pub h: usize,
pub px: Vec<u8>,
}
/// image indexée 8 bits + palette RGB 0..255
struct Indexed {
w: usize,
h: usize,
px: Vec<u8>,
pal: [[u8; 3]; 256],
}
impl Indexed {
fn to_rgba(&self, x0: usize, y0: usize, w: usize, h: usize, alpha: impl Fn(u8, [u8; 3]) -> u8) -> Rgba {
let mut px = Vec::with_capacity(w * h * 4);
for y in y0..y0 + h {
for x in x0..x0 + w {
let i = self.px[y * self.w + x];
let c = self.pal[i as usize];
px.extend_from_slice(&[c[0], c[1], c[2], alpha(i, c)]);
}
}
Rgba { w, h, px }
}
}
fn u16le(d: &[u8], o: usize) -> usize {
d.get(o..o + 2).map(|b| u16::from_le_bytes([b[0], b[1]]) as usize).unwrap_or(0)
}
fn u32le(d: &[u8], o: usize) -> usize {
d.get(o..o + 4).map(|b| u32::from_le_bytes([b[0], b[1], b[2], b[3]]) as usize).unwrap_or(0)
}
/// PCX 8 bits RLE + palette de fin de fichier (même lecture que le jeu : DAC VGA 6 bits)
fn decode_pcx(d: &[u8]) -> Option<Indexed> {
if d.len() < 128 + 769 || d[0] != 0x0A || d[3] != 8 {
return None;
}
let (x0, y0, x1, y1) = (u16le(d, 4), u16le(d, 6), u16le(d, 8), u16le(d, 10));
let (w, h) = (x1.checked_sub(x0)? + 1, y1.checked_sub(y0)? + 1);
let bpl = match u16le(d, 66) {
0 => w,
n => n,
};
let need = bpl * h;
let mut out = vec![0u8; need];
let (mut i, mut o) = (128, 0);
let end_data = d.len() - 769;
while o < need && i < end_data {
let b = d[i];
i += 1;
if b >= 0xC0 {
let n = (b - 0xC0) as usize;
let v = d.get(i).copied().unwrap_or(0);
i += 1;
let e = (o + n).min(need);
out[o..e].fill(v);
o = e;
} else {
out[o] = b;
o += 1;
}
}
let px = if bpl == w { out } else { (0..h).flat_map(|r| out[r * bpl..r * bpl + w].to_vec()).collect() };
let raw = &d[d.len() - 768..];
let mut pal = [[0u8; 3]; 256];
for (k, c) in pal.iter_mut().enumerate() {
for j in 0..3 {
c[j] = (((raw[3 * k + j] >> 2) as u32 * 255 + 31) / 63) as u8;
}
}
Some(Indexed { w, h, px, pal })
}
/// dernière image d'une animation FLC (chunks COLOR_256/64, BYTE_RUN, DELTA_FLC, DELTA_FLI, BLACK, COPY)
fn decode_flc_last(d: &[u8]) -> Option<Indexed> {
if d.len() < 128 || !matches!(u16le(d, 4), 0xAF12 | 0xAF11) {
return None;
}
let (frames, w, h) = (u16le(d, 6), u16le(d, 8), u16le(d, 10));
if w == 0 || h == 0 || w > 2048 || h > 2048 {
return None;
}
let mut img = Indexed { w, h, px: vec![0; w * h], pal: [[0; 3]; 256] };
let mut off = match u32le(d, 80) {
0 => 128,
n => n,
};
let mut done = 0;
let mut best_filled = 0;
let mut best = None;
while done < frames && off + 16 <= d.len() {
let (size, ty) = (u32le(d, off), u16le(d, off + 4));
if size < 6 {
break;
}
if ty == 0xF1FA {
let n = u16le(d, off + 6);
let mut c = off + 16;
for _ in 0..n {
let (csz, cty) = (u32le(d, c), u16le(d, c + 4));
if csz < 6 || c + csz > d.len() {
break;
}
apply_chunk(&mut img, cty, &d[c + 6..c + csz]);
c += csz;
}
done += 1;
// l'écran-titre finit par un volet vers le noir : on garde la dernière image complète
let filled = img.px.iter().filter(|&&p| p != 0).count();
if filled >= best_filled {
best_filled = filled;
best = Some((img.px.clone(), img.pal));
}
}
off += size;
}
if let Some((px, pal)) = best {
img.px = px;
img.pal = pal;
}
Some(img)
}
fn apply_chunk(img: &mut Indexed, ty: usize, d: &[u8]) {
let (w, h) = (img.w, img.h);
let get = |i: usize| d.get(i).copied().unwrap_or(0);
match ty {
4 | 11 => {
// palette : paquets (saut, nombre)
let shift = if ty == 11 { 2 } else { 0 };
let (mut i, mut idx) = (2, 0usize);
for _ in 0..u16le(d, 0) {
idx += get(i) as usize;
let mut n = get(i + 1) as usize;
if n == 0 {
n = 256;
}
i += 2;
for _ in 0..n {
if idx < 256 {
let s = |v: u8| if shift == 2 { ((v as u32 * 255 + 31) / 63) as u8 } else { v };
img.pal[idx] = [s(get(i)), s(get(i + 1)), s(get(i + 2))];
}
idx += 1;
i += 3;
}
}
}
13 => img.px.fill(0),
16 => {
let n = (w * h).min(d.len());
img.px[..n].copy_from_slice(&d[..n]);
}
15 => {
let mut i = 0;
for y in 0..h {
i += 1; // nombre de paquets, ignoré
let mut x = 0;
while x < w && i < d.len() {
let c = get(i) as i8;
i += 1;
if c < 0 {
for _ in 0..(-(c as i32)) as usize {
if x < w {
img.px[y * w + x] = get(i);
}
x += 1;
i += 1;
}
} else {
let v = get(i);
i += 1;
for _ in 0..c as usize {
if x < w {
img.px[y * w + x] = v;
}
x += 1;
}
}
}
}
}
7 => {
let mut i = 2;
let mut y = 0usize;
for _ in 0..u16le(d, 0) {
let packets;
loop {
let word = u16le(d, i) as u16;
i += 2;
match word & 0xC000 {
0xC000 => y += (-(word as i16) as i32) as usize,
0x8000 => {
if y < h {
img.px[y * w + w - 1] = word as u8;
}
}
_ => {
packets = word as usize;
break;
}
}
if i >= d.len() {
return;
}
}
let mut x = 0usize;
for _ in 0..packets {
x += get(i) as usize;
let c = get(i + 1) as i8;
i += 2;
if c > 0 {
for _ in 0..c as usize * 2 {
if y < h && x < w {
img.px[y * w + x] = get(i);
}
x += 1;
i += 1;
}
} else {
let (a, b) = (get(i), get(i + 1));
i += 2;
for _ in 0..(-(c as i32)) as usize {
for v in [a, b] {
if y < h && x < w {
img.px[y * w + x] = v;
}
x += 1;
}
}
}
}
y += 1;
}
}
12 => {
let mut y = u16le(d, 0);
let mut i = 4;
for _ in 0..u16le(d, 2) {
let packets = get(i) as usize;
i += 1;
let mut x = 0;
for _ in 0..packets {
x += get(i) as usize;
let c = get(i + 1) as i8;
i += 2;
if c > 0 {
for _ in 0..c as usize {
if y < h && x < w {
img.px[y * w + x] = get(i);
}
x += 1;
i += 1;
}
} else {
let v = get(i);
i += 1;
for _ in 0..(-(c as i32)) as usize {
if y < h && x < w {
img.px[y * w + x] = v;
}
x += 1;
}
}
}
y += 1;
}
}
_ => {}
}
}
/// rectangle englobant des pixels pour lesquels `keep` est vrai
fn bbox(img: &Indexed, keep: impl Fn(u8, [u8; 3]) -> bool) -> Option<(usize, usize, usize, usize)> {
let (mut x0, mut y0, mut x1, mut y1) = (usize::MAX, usize::MAX, 0, 0);
for y in 0..img.h {
for x in 0..img.w {
let i = img.px[y * img.w + x];
if keep(i, img.pal[i as usize]) {
x0 = x0.min(x);
y0 = y0.min(y);
x1 = x1.max(x);
y1 = y1.max(y);
}
}
}
(x0 != usize::MAX).then(|| (x0, y0, x1 - x0 + 1, y1 - y0 + 1))
}
fn read(dir: &Path, rel: &str) -> Option<Vec<u8>> {
std::fs::read(dir.join(rel)).ok()
}
/// décors utilisés en fond de bannière (partie jeu 320×140, sans le panneau)
const BACKDROPS: &[&str] = &["LOC01", "LOC20", "LOC10", "LOC50", "DICKDIGS", "LOC40A", "CLIO1"];
pub fn backdrops(dir: &Path) -> Vec<Rgba> {
BACKDROPS
.iter()
.filter_map(|n| decode_pcx(&read(dir, &format!("{n}.PCX"))?))
.map(|p| {
let h = p.h.min(140);
p.to_rgba(0, 0, p.w, h, |_, _| 255)
})
.collect()
}
/// logo « Bud Tucker in Double Trouble » : dernière image de l'écran-titre, le noir devient transparent
pub fn logo(dir: &Path) -> Option<Rgba> {
let img = decode_flc_last(&read(dir, "GRAPHICS/BUDTTLE2.FLC")?)?;
let lum = |c: [u8; 3]| c[0].max(c[1]).max(c[2]);
let (x, y, w, h) = bbox(&img, |_, c| lum(c) > 40)?;
Some(img.to_rgba(x, y, w, h, |_, c| (lum(c) as u32 * 4).min(255) as u8))
}
/// icône : premier curseur de POINTER.PCX (fond = couleur du coin bas droit), agrandi en 32×32
pub fn icon(dir: &Path) -> Option<Rgba> {
let img = decode_pcx(&read(dir, "POINTER.PCX")?)?;
let bg = img.px[img.w * img.h - 1];
// premier sprite : en haut à gauche, jusqu'à la première ligne vide
let mut h = 0;
while h < img.h && img.px[h * img.w..h * img.w + 24.min(img.w)].iter().any(|&p| p != bg) {
h += 1;
}
let sub = Indexed { w: img.w, h: h.max(1), px: img.px[..img.w * h.max(1)].to_vec(), pal: img.pal };
let (x, y, w, h) = bbox(&sub, |i, _| i != bg)?;
let side = w.max(h);
let src = sub.to_rgba(x, y, w, h, |i, _| if i == bg { 0 } else { 255 });
let n = 32;
let mut px = vec![0u8; n * n * 4];
let (ox, oy) = ((side - w) / 2, (side - h) / 2);
for ty in 0..n {
for tx in 0..n {
let (sx, sy) = (tx * side / n, ty * side / n);
if sx >= ox && sy >= oy && sx - ox < w && sy - oy < h {
let s = ((sy - oy) * w + (sx - ox)) * 4;
px[(ty * n + tx) * 4..][..4].copy_from_slice(&src.px[s..s + 4]);
}
}
}
Some(Rgba { w: n, h: n, px })
}
#[cfg(test)]
mod tests {
#[test]
fn dump_logo() {
let Ok(dir) = std::env::var("DTR_GAME") else { return };
let dir = std::path::Path::new(&dir);
let d = std::fs::read(dir.join("GRAPHICS/BUDTTLE2.FLC")).expect("lecture FLC");
let img = super::decode_flc_last(&d).expect("décodage FLC");
let nonzero = img.px.iter().filter(|&&p| p != 0).count();
eprintln!("flc {}x{} pixels non nuls {} pal[1..4] {:?}", img.w, img.h, nonzero, &img.pal[1..4]);
let logo = super::logo(dir);
eprintln!("logo {:?}", logo.as_ref().map(|l| (l.w, l.h)));
if let (Ok(out), Some(l)) = (std::env::var("DTR_OUT"), logo) {
let mut ppm = format!("P6 {} {} 255\n", l.w, l.h).into_bytes();
for p in l.px.chunks(4) {
ppm.extend_from_slice(&p[..3]);
}
std::fs::write(out, ppm).unwrap();
}
}
}
+526 -201
View File
@@ -9,12 +9,15 @@
#![windows_subsystem = "windows"]
use eframe::egui::{self, Color32, RichText};
mod art;
use eframe::egui::{self, Color32, CornerRadius, Rect, RichText, Stroke};
use std::io::{BufRead, BufReader, Read};
use std::os::windows::process::CommandExt;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::Arc;
use std::thread;
const NO_WINDOW: u32 = 0x0800_0000;
@@ -341,6 +344,130 @@ fn pick_dialog(kind: Pick, title: &str) -> Option<String> {
powershell(&script).filter(|s| !s.is_empty())
}
// ------------------------------------------------------------------ thème « labo & pizza »
const BG: Color32 = Color32::from_rgb(0x14, 0x11, 0x24);
const CARD: Color32 = Color32::from_rgb(0x1F, 0x1B, 0x38);
const CARD_DARK: Color32 = Color32::from_rgb(0x0E, 0x0C, 0x1A);
const BORDER: Color32 = Color32::from_rgb(0x4A, 0x3A, 0x8C);
const ACCENT: Color32 = Color32::from_rgb(0xFF, 0xD2, 0x00);
const OK: Color32 = Color32::from_rgb(0x2E, 0xCC, 0x71);
const BAD: Color32 = Color32::from_rgb(0xFF, 0x33, 0x66);
const BTN: Color32 = Color32::from_rgb(0x2C, 0x26, 0x52);
const BTN_HOVER: Color32 = Color32::from_rgb(0x3D, 0x34, 0x70);
fn setup_theme(ctx: &egui::Context) {
ctx.set_theme(egui::ThemePreference::Dark);
let mut v = egui::Visuals::dark();
v.panel_fill = BG;
v.window_fill = CARD;
v.faint_bg_color = CARD;
v.extreme_bg_color = CARD_DARK;
v.selection.bg_fill = Color32::from_rgb(0x6A, 0x3F, 0xD0);
v.hyperlink_color = Color32::from_rgb(0x7F, 0xD8, 0xFF);
let r = CornerRadius::same(8);
for w in [
&mut v.widgets.noninteractive,
&mut v.widgets.inactive,
&mut v.widgets.hovered,
&mut v.widgets.active,
&mut v.widgets.open,
] {
w.corner_radius = r;
}
v.widgets.noninteractive.bg_stroke = Stroke::new(1.0, BORDER);
v.widgets.inactive.weak_bg_fill = BTN;
v.widgets.inactive.bg_fill = BTN;
v.widgets.hovered.weak_bg_fill = BTN_HOVER;
v.widgets.hovered.bg_fill = BTN_HOVER;
v.widgets.hovered.bg_stroke = Stroke::new(1.5, ACCENT);
v.widgets.hovered.expansion = 1.5;
v.widgets.active.weak_bg_fill = Color32::from_rgb(0x55, 0x48, 0x9A);
v.widgets.active.bg_fill = Color32::from_rgb(0x55, 0x48, 0x9A);
ctx.set_visuals_of(egui::Theme::Dark, v);
ctx.style_mut_of(egui::Theme::Dark, |s| {
s.spacing.item_spacing = egui::vec2(8.0, 7.0);
s.spacing.button_padding = egui::vec2(10.0, 5.0);
});
}
fn card<R>(ui: &mut egui::Ui, add: impl FnOnce(&mut egui::Ui) -> R) -> R {
egui::Frame::NONE
.fill(CARD)
.stroke(Stroke::new(2.0, BORDER))
.corner_radius(CornerRadius::same(12))
.inner_margin(egui::Margin::same(14))
.show(ui, |ui| {
ui.set_width(ui.available_width());
add(ui)
})
.inner
}
fn title(ui: &mut egui::Ui, text: &str) {
ui.label(RichText::new(text).size(19.0).strong().color(ACCENT));
}
fn dot(ui: &mut egui::Ui, ok: bool) {
let (rect, _) = ui.allocate_exact_size(egui::vec2(14.0, 14.0), egui::Sense::hover());
ui.painter().circle_filled(rect.center(), 5.5, if ok { OK } else { BAD });
}
fn status(ui: &mut egui::Ui, ok: bool, label: &str, detail: &str) {
dot(ui, ok);
ui.label(label);
ui.label(RichText::new(detail).weak());
}
/// gros bouton jaune façon bande dessinée : ombre portée, contour noir, grossit au survol
fn play_button(ui: &mut egui::Ui, label: &str, enabled: bool) -> egui::Response {
let size = egui::vec2(ui.available_width(), 80.0);
let sense = if enabled { egui::Sense::click() } else { egui::Sense::hover() };
let (rect, resp) = ui.allocate_exact_size(size, sense);
let hover = enabled && resp.hovered();
let pressed = enabled && resp.is_pointer_button_down_on();
let t = ui.ctx().animate_bool(resp.id, hover);
let r = rect.shrink(6.0).expand(6.0 * t);
let r = if pressed { r.translate(egui::vec2(2.0, 3.0)) } else { r };
let p = ui.painter();
let radius = CornerRadius::same(16);
let (fill, text) = if enabled {
(ACCENT.lerp_to_gamma(Color32::from_rgb(0xFF, 0xE8, 0x60), t), Color32::BLACK)
} else {
(Color32::from_rgb(0x55, 0x4E, 0x2A), Color32::from_rgb(0x2A, 0x25, 0x14))
};
if !pressed {
p.rect_filled(r.translate(egui::vec2(4.0, 5.0)), radius, Color32::BLACK);
}
p.rect_filled(r, radius, fill);
p.rect_stroke(r, radius, Stroke::new(3.0, Color32::BLACK), egui::StrokeKind::Inside);
let font = egui::FontId::proportional(36.0);
p.text(r.center() + egui::vec2(2.0, 2.0), egui::Align2::CENTER_CENTER, label, font.clone(), Color32::from_black_alpha(60));
p.text(r.center(), egui::Align2::CENTER_CENTER, label, font, text);
if enabled {
resp.on_hover_cursor(egui::CursorIcon::PointingHand)
} else {
resp
}
}
/// dessine une texture en « cover » (recadrée pour remplir le rectangle), pixels 1:1,2 comme sur un écran 4:3
fn paint_cover(p: &egui::Painter, rect: Rect, tex: &egui::TextureHandle, alpha: f32, drift: f32) {
let s = tex.resolution_vec2();
let tex_aspect = s.x / (s.y * 1.2);
let rect_aspect = rect.width() / rect.height();
let uv = if rect_aspect > tex_aspect {
let h = tex_aspect / rect_aspect;
let top = (1.0 - h) * (0.5 + 0.5 * drift);
Rect::from_min_max(egui::pos2(0.0, top), egui::pos2(1.0, top + h))
} else {
let w = rect_aspect / tex_aspect;
let left = (1.0 - w) * (0.5 + 0.5 * drift);
Rect::from_min_max(egui::pos2(left, 0.0), egui::pos2(left + w, 1.0))
};
p.image(tex.id(), rect, uv, Color32::from_white_alpha((alpha.clamp(0.0, 1.0) * 255.0) as u8));
}
// ------------------------------------------------------------------ application
#[derive(PartialEq)]
@@ -350,6 +477,13 @@ enum Busy {
Task(&'static str),
}
#[derive(Default)]
struct Art {
dir: Option<PathBuf>,
backdrops: Vec<egui::TextureHandle>,
logo: Option<egui::TextureHandle>,
}
struct App {
root: Option<PathBuf>,
cfg: Config,
@@ -358,7 +492,11 @@ struct App {
busy: Busy,
game_running: bool,
last_ok: Option<bool>,
last_exit: Option<i32>,
log: Vec<String>,
show_log: bool,
config_open: Option<bool>,
art: Art,
tx: Sender<Msg>,
rx: Receiver<Msg>,
ctx: egui::Context,
@@ -376,8 +514,13 @@ fn find_root() -> Option<PathBuf> {
starts.iter().find_map(|s| s.ancestors().find(|d| is_root(d)).map(Path::to_path_buf))
}
fn to_image(img: &art::Rgba) -> egui::ColorImage {
egui::ColorImage::from_rgba_unmultiplied([img.w, img.h], &img.px)
}
impl App {
fn new(cc: &eframe::CreationContext<'_>) -> Self {
setup_theme(&cc.egui_ctx);
let (tx, rx) = channel();
let cfg = Config::load();
let mut app = Self {
@@ -388,7 +531,11 @@ impl App {
busy: Busy::No,
game_running: false,
last_ok: None,
last_exit: None,
log: Vec::new(),
show_log: false,
config_open: None,
art: Art::default(),
tx,
rx,
ctx: cc.egui_ctx.clone(),
@@ -414,6 +561,35 @@ impl App {
Ui { tx: self.tx.clone(), ctx: self.ctx.clone() }
}
fn prereqs_ok(&self) -> bool {
let c = &self.checks;
c.python.is_some() && c.capstone.is_some() && c.vcvars.is_some() && c.sdl
}
fn ready(&self) -> bool {
self.checks.game_dir.is_some() && self.prereqs_ok() && self.checks.built
}
/// charge les visuels depuis la copie du jeu quand le dossier du jeu change
fn refresh_art(&mut self) {
if self.art.dir == self.checks.game_dir {
return;
}
self.art = Art { dir: self.checks.game_dir.clone(), ..Default::default() };
let Some(dir) = self.art.dir.clone() else { return };
let opts = egui::TextureOptions::LINEAR;
self.art.backdrops = art::backdrops(&dir)
.iter()
.enumerate()
.map(|(i, b)| self.ctx.load_texture(format!("backdrop{i}"), to_image(b), opts))
.collect();
self.art.logo = art::logo(&dir).map(|l| self.ctx.load_texture("logo", to_image(&l), opts));
if let Some(ic) = art::icon(&dir) {
let data = egui::IconData { rgba: ic.px, width: ic.w as u32, height: ic.h as u32 };
self.ctx.send_viewport_cmd(egui::ViewportCommand::Icon(Some(Arc::new(data))));
}
}
fn recheck(&mut self) {
let Some(root) = self.root.clone() else { return };
if self.busy != Busy::No {
@@ -443,6 +619,7 @@ impl App {
let Some(root) = self.root.clone() else { return };
self.busy = Busy::Task(name);
self.last_ok = None;
self.show_log = true;
let ui = self.ui_handle();
thread::spawn(move || {
let ok = steps.iter().all(|s| run_streamed(&ui, &root, s));
@@ -491,7 +668,7 @@ impl App {
}
if let Some(r) = &self.root {
let d = r.join("..").join("Install").join("C").join("TUCKER");
if d.join("TUCKER.EXE").is_file() || d.is_dir() {
if d.is_dir() {
return d;
}
}
@@ -518,6 +695,7 @@ impl App {
if self.cfg.verbose { cmd.arg("-v"); }
cmd.stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::piped());
self.log.push(format!("> {:?}", cmd));
self.last_exit = None;
match cmd.spawn() {
Ok(mut child) => {
self.game_running = true;
@@ -530,7 +708,10 @@ impl App {
ui.send(Msg::GameExited(code));
});
}
Err(e) => self.log.push(format!("!! {e}")),
Err(e) => {
self.log.push(format!("!! {e}"));
self.show_log = true;
}
}
}
@@ -548,6 +729,10 @@ impl App {
if self.busy == Busy::Checking {
self.busy = Busy::No;
}
if self.config_open.is_none() {
self.config_open = Some(!self.ready());
}
self.refresh_art();
}
Msg::Picked(kind, p) => {
match kind {
@@ -563,11 +748,321 @@ impl App {
}
Msg::GameExited(code) => {
self.game_running = false;
self.last_exit = Some(code);
if code != 0 {
self.show_log = true;
}
self.log.push(format!("== {} {code} ==", self.t("jeu terminé, code", "game exited, code")));
}
}
}
}
// ---------------------------------------------------------------- vues
fn banner(&mut self, ui: &mut egui::Ui) {
let h = 220.0;
let (rect, _) = ui.allocate_exact_size(egui::vec2(ui.available_width(), h), egui::Sense::hover());
let p = ui.painter_at(rect);
p.rect_filled(rect, 0.0, CARD_DARK);
let t = ui.input(|i| i.time) as f32;
let n = self.art.backdrops.len();
if n > 0 {
// diaporama des décors, fondu enchaîné et lent glissement vertical
let per = 7.0;
let k = (t / per) as usize;
let phase = t % per;
let fade = ((phase - (per - 1.5)) / 1.5).clamp(0.0, 1.0);
let drift = |kk: usize, ph: f32| ((ph / per) * 2.0 - 1.0) * if kk % 2 == 0 { 1.0 } else { -1.0 };
paint_cover(&p, rect, &self.art.backdrops[k % n], 1.0, drift(k, phase));
if fade > 0.0 {
paint_cover(&p, rect, &self.art.backdrops[(k + 1) % n], fade, drift(k + 1, phase - per));
}
ui.ctx().request_repaint();
}
p.rect_filled(rect, 0.0, Color32::from_black_alpha(120));
// dégradé vers le fond de la fenêtre
let strips = 32;
let g0 = rect.top() + rect.height() * 0.35;
for s in 0..strips {
let f0 = s as f32 / strips as f32;
let y0 = g0 + (rect.bottom() - g0) * f0;
let y1 = g0 + (rect.bottom() - g0) * (s + 1) as f32 / strips as f32;
let a = (f0.powf(1.6) * 255.0) as u8;
p.rect_filled(
Rect::from_min_max(egui::pos2(rect.left(), y0), egui::pos2(rect.right(), y1 + 1.0)),
0.0,
Color32::from_rgba_unmultiplied(BG.r(), BG.g(), BG.b(), a),
);
}
// logo (de la copie du joueur) ou titre texte
let logo_bottom = if let Some(logo) = &self.art.logo {
let s = logo.resolution_vec2();
let sc = ((h - 70.0) / s.y).min(rect.width() * 0.62 / s.x);
let bob = (t * 1.3).sin() * 2.0;
let lr = Rect::from_center_size(
egui::pos2(rect.center().x, rect.top() + 18.0 + s.y * sc / 2.0 + bob),
s * sc,
);
p.image(logo.id(), lr, Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)), Color32::WHITE);
lr.bottom() - bob
} else {
let c = egui::pos2(rect.center().x, rect.top() + 80.0);
let f = egui::FontId::proportional(46.0);
p.text(c + egui::vec2(3.0, 3.0), egui::Align2::CENTER_CENTER, "Bud Tucker in Double Trouble", f.clone(), Color32::BLACK);
p.text(c, egui::Align2::CENTER_CENTER, "Bud Tucker in Double Trouble", f, ACCENT);
c.y + 30.0
};
// badge
let badge = self.t("DoubleTroubleRecomp · PORTAGE PC NATIF", "DoubleTroubleRecomp · NATIVE PC PORT");
let galley = p.layout_no_wrap(badge.to_string(), egui::FontId::proportional(14.0), Color32::BLACK);
let br = Rect::from_center_size(
egui::pos2(rect.center().x, (logo_bottom + 20.0).min(rect.bottom() - 18.0)),
galley.size() + egui::vec2(24.0, 10.0),
);
p.rect_filled(br, CornerRadius::same(255), ACCENT);
p.rect_stroke(br, CornerRadius::same(255), Stroke::new(2.0, Color32::BLACK), egui::StrokeKind::Outside);
p.galley(br.center() - galley.size() / 2.0, galley, Color32::BLACK);
// langue
let lr = Rect::from_min_size(egui::pos2(rect.right() - 110.0, rect.top() + 10.0), egui::vec2(100.0, 28.0));
ui.scope_builder(egui::UiBuilder::new().max_rect(lr).layout(egui::Layout::right_to_left(egui::Align::Center)), |ui| {
ui.selectable_value(&mut self.cfg.lang, Lang::En, RichText::new("EN").strong());
ui.selectable_value(&mut self.cfg.lang, Lang::Fr, RichText::new("FR").strong());
});
}
fn status_bar(&mut self, ui: &mut egui::Ui) {
ui.horizontal(|ui| {
let c = self.checks.clone();
dot(ui, c.game_dir.is_some());
ui.label(if c.game_dir.is_some() { self.t("Jeu trouvé", "Game found") } else { self.t("Jeu introuvable", "Game not found") });
ui.label(RichText::new("•").weak());
dot(ui, self.prereqs_ok());
ui.label(self.t("Prérequis", "Requirements"));
ui.label(RichText::new("•").weak());
dot(ui, c.built);
ui.label(if c.built { self.t("Build prêt", "Build ready") } else { self.t("Pas encore compilé", "Not built yet") });
if let Busy::Task(_) = self.busy {
ui.label(RichText::new("•").weak());
ui.spinner();
ui.label(RichText::new(self.t("Compilation en cours…", "Working…")).color(ACCENT));
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
let log_label = if self.show_log { self.t("Masquer le journal", "Hide log") } else { self.t("Journal", "Log") };
if ui.button(log_label).clicked() {
self.show_log = !self.show_log;
}
let open = self.config_open.unwrap_or(true);
let cfg_label = if open { self.t("Replier la configuration", "Collapse setup") } else { self.t("Configurer", "Setup") };
if ui.button(cfg_label).clicked() {
self.config_open = Some(!open);
}
});
});
}
fn log_view(&mut self, ui: &mut egui::Ui) {
ui.horizontal(|ui| {
ui.label(RichText::new(self.t("Journal", "Log")).strong().color(ACCENT));
if ui.small_button(self.t("Effacer", "Clear")).clicked() {
self.log.clear();
}
if ui.small_button(self.t("Copier", "Copy")).clicked() {
ui.ctx().copy_text(self.log.join("\n"));
}
});
egui::ScrollArea::vertical().stick_to_bottom(true).auto_shrink([false, false]).show(ui, |ui| {
for l in &self.log {
let color = if l.starts_with("> ") {
ACCENT
} else if l.contains("error") || l.contains("erreur") || l.starts_with("!!") || l.contains("ÉCHEC") {
BAD
} else {
ui.visuals().text_color()
};
ui.label(RichText::new(l).monospace().size(12.0).color(color));
}
});
}
fn setup_column(&mut self, ui: &mut egui::Ui, root: &Path) {
let busy = self.busy != Busy::No;
let c = self.checks.clone();
if self.config_open == Some(false) {
card(ui, |ui| {
title(ui, self.t("Installation", "Setup"));
ui.add_space(4.0);
ui.horizontal(|ui| status(ui, c.game_dir.is_some(), self.t("Jeu original", "Original game"),
&c.game_dir.as_ref().map(|d| d.display().to_string()).unwrap_or_default()));
ui.horizontal(|ui| status(ui, self.prereqs_ok(), self.t("Prérequis", "Requirements"), "Python · capstone · MSVC · SDL2"));
ui.horizontal(|ui| status(ui, c.built, self.t("Jeu compilé", "Game built"), "build\\tucker.exe"));
ui.add_space(6.0);
if ui.button(self.t("Configurer / recompiler…", "Setup / rebuild…")).clicked() {
self.config_open = Some(true);
}
});
// aperçu : un autre décor que celui de la bannière, change toutes les 7 s
let n = self.art.backdrops.len();
if n > 1 {
ui.add_space(10.0);
card(ui, |ui| {
title(ui, self.t("Bienvenue à Barryville", "Welcome to Barryville"));
let w = ui.available_width();
let (rect, _) = ui.allocate_exact_size(egui::vec2(w, w / 1.9), egui::Sense::hover());
let k = (ui.input(|i| i.time) / 7.0) as usize + n / 2;
paint_cover(ui.painter(), rect, &self.art.backdrops[k % n], 1.0, 0.0);
ui.painter().rect_stroke(rect, CornerRadius::ZERO, Stroke::new(2.0, Color32::BLACK), egui::StrokeKind::Inside);
});
}
return;
}
// ---------------- 1. jeu
card(ui, |ui| {
title(ui, self.t("1. Jeu original", "1. Original game"));
ui.label(RichText::new(self.t(
"Dossier du CD, lecteur (ex. E:\\) ou image .iso. Les fichiers sont lus, jamais modifiés.",
"CD folder, drive (e.g. E:\\) or .iso image. Files are read, never modified.",
)).weak());
let r = ui.add(egui::TextEdit::singleline(&mut self.cfg.game_path).desired_width(f32::INFINITY));
if r.lost_focus() {
self.recheck();
}
ui.horizontal(|ui| {
if ui.button(self.t("Dossier…", "Folder…")).clicked() {
self.pick(Pick::GameFolder);
}
if ui.button(self.t("Image ISO…", "ISO image…")).clicked() {
self.pick(Pick::GameIso);
}
});
ui.horizontal_wrapped(|ui| match (&c.game_dir, &c.game_error) {
(Some(d), _) => status(ui, true, self.t("Jeu trouvé", "Game found"), &d.display().to_string()),
(None, Some(e)) if !e.is_empty() => status(ui, false, self.t("Jeu introuvable", "Game not found"), e),
_ if c.done => status(ui, false, self.t("Choisissez le jeu", "Choose the game"), ""),
_ => {
ui.spinner();
}
});
ui.collapsing(self.t("Avancé : dossier d'installation", "Advanced: install folder"), |ui| {
ui.label(RichText::new(self.t(
"Optionnel : dossier TUCKER créé par l'installation DOS (C:\\TUCKER). Vide = automatique.",
"Optional: TUCKER folder created by the DOS install (C:\\TUCKER). Empty = automatic.",
)).weak());
ui.horizontal(|ui| {
ui.add(egui::TextEdit::singleline(&mut self.cfg.install_dir).desired_width(ui.available_width() - 40.0));
if ui.button("…").clicked() {
self.pick(Pick::Install);
}
});
});
});
ui.add_space(10.0);
// ---------------- 2. prérequis
let mut action: Option<&'static str> = None;
card(ui, |ui| {
ui.horizontal(|ui| {
title(ui, self.t("2. Prérequis", "2. Requirements"));
if ui.add_enabled(!busy, egui::Button::new(self.t("Vérifier", "Check"))).clicked() {
self.recheck();
}
if self.busy == Busy::Checking {
ui.spinner();
}
});
egui::Grid::new("checks").num_columns(4).spacing([8.0, 6.0]).show(ui, |ui| {
status(ui, c.python.is_some(), "Python 3", c.python.as_deref().unwrap_or(self.t("absent de PATH", "not in PATH")));
if c.python.is_none() {
ui.hyperlink_to("python.org", "https://www.python.org/downloads/");
}
ui.end_row();
status(ui, c.capstone.is_some(), "capstone", c.capstone.as_deref().unwrap_or(self.t("non installé", "not installed")));
if c.capstone.is_none() && c.python.is_some()
&& ui.add_enabled(!busy, egui::Button::new(self.t("Installer (pip)", "Install (pip)"))).clicked()
{
action = Some("capstone");
}
ui.end_row();
status(ui, c.vcvars.is_some(), "MSVC 2022", if c.vcvars.is_some() { "vcvars64.bat" } else { self.t("introuvable", "not found") });
if c.vcvars.is_none() {
ui.hyperlink_to("Build Tools 2022", "https://visualstudio.microsoft.com/downloads/");
}
ui.end_row();
status(ui, c.sdl, &format!("SDL2 {SDL_VER}"), if c.sdl { "third_party" } else { self.t("absent", "missing") });
if !c.sdl && ui.add_enabled(!busy, egui::Button::new(self.t("Télécharger", "Download"))).clicked() {
action = Some("sdl");
}
ui.end_row();
});
});
match action {
Some("capstone") => self.install_capstone(),
Some("sdl") => self.download_sdl(),
_ => {}
}
ui.add_space(10.0);
// ---------------- 3. compilation
card(ui, |ui| {
title(ui, self.t("3. Compilation", "3. Build"));
ui.label(RichText::new(self.t(
"Traduit TUCKER.EXE et INTRO.EXE en C, puis compile. Quelques minutes la première fois.",
"Translates TUCKER.EXE and INTRO.EXE to C, then compiles. Takes a few minutes the first time.",
)).weak());
ui.horizontal_wrapped(|ui| {
let can = !busy && c.can_build();
if ui.add_enabled(can, egui::Button::new(RichText::new(self.t("Générer et compiler", "Generate and build")).strong())).clicked() {
self.build(true);
}
if ui.add_enabled(can && root.join("build").join("gen_tucker").is_dir(), egui::Button::new(self.t("Recompiler seulement", "Rebuild only"))).clicked() {
self.build(false);
}
if let Busy::Task(_) = self.busy {
ui.spinner();
} else if let Some(ok) = self.last_ok {
ui.label(RichText::new(if ok { self.t("Terminé", "Done") } else { self.t("Échec, voir le journal", "Failed, see the log") })
.color(if ok { OK } else { BAD }));
}
});
ui.horizontal(|ui| status(ui, c.built, self.t("Jeu compilé", "Game built"), "build\\tucker.exe"));
});
}
fn play_column(&mut self, ui: &mut egui::Ui) {
let busy = self.busy != Busy::No;
let c = self.checks.clone();
let en = self.cfg.lang == Lang::En;
let tr = |fr: &'static str, e: &'static str| if en { e } else { fr };
card(ui, |ui| {
title(ui, tr("Prêt à jouer", "Ready to play"));
ui.add_space(4.0);
ui.checkbox(&mut self.cfg.sound, tr("Son", "Sound"));
ui.checkbox(&mut self.cfg.fullscreen, tr("Plein écran", "Fullscreen"));
ui.checkbox(&mut self.cfg.skip_intro, tr("Passer l'intro", "Skip intro"));
ui.checkbox(&mut self.cfg.verbose, tr("Journal détaillé", "Verbose log"));
ui.add_space(4.0);
ui.label(tr("Taille de la fenêtre", "Window scale"));
ui.horizontal(|ui| {
ui.add(egui::Slider::new(&mut self.cfg.scale, 1..=8).suffix("×"));
ui.label(RichText::new(format!("{}×{}", 320 * self.cfg.scale, 240 * self.cfg.scale)).weak());
});
ui.add_space(12.0);
let can_play = !busy && !self.game_running && c.built && c.game_dir.is_some();
let label = if self.game_running { tr("EN JEU…", "PLAYING…") } else { tr("JOUER", "PLAY") };
if play_button(ui, label, can_play).clicked() {
self.play();
}
ui.add_space(6.0);
if !c.built && c.done {
ui.label(RichText::new(tr("Compilez d'abord le jeu (étape 3).", "Build the game first (step 3).")).color(BAD));
} else if let Some(code) = self.last_exit.filter(|&c| c != 0) {
ui.label(RichText::new(format!("{} {code}", tr("Le jeu s'est arrêté avec le code", "The game stopped with code"))).color(BAD));
} else {
ui.label(RichText::new(tr("F11 ou Alt+Entrée : plein écran en jeu.", "F11 or Alt+Enter: toggle fullscreen in game.")).weak());
}
});
}
}
/// chemin lisible (sans le préfixe \\?\ de canonicalize)
@@ -576,214 +1071,44 @@ fn dunce(p: &Path) -> String {
s.strip_prefix(r"\\?\").map(str::to_string).unwrap_or(s)
}
const OK: Color32 = Color32::from_rgb(90, 200, 120);
const BAD: Color32 = Color32::from_rgb(230, 90, 90);
const ACCENT: Color32 = Color32::from_rgb(255, 196, 60);
fn status(ui: &mut egui::Ui, ok: bool, label: &str, detail: &str) {
// pastille de couleur (les polices par défaut n'ont pas ✔/✖)
let (rect, _) = ui.allocate_exact_size(egui::vec2(14.0, 14.0), egui::Sense::hover());
ui.painter().circle_filled(rect.center(), 5.0, if ok { OK } else { BAD });
ui.label(label);
ui.label(RichText::new(detail).weak());
}
impl eframe::App for App {
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
self.pump();
let busy = self.busy != Busy::No;
if busy || self.game_running {
if self.busy != Busy::No || self.game_running {
ui.ctx().request_repaint_after(std::time::Duration::from_millis(200));
}
// ---------------- en-tête
egui::Panel::top("top").show(ui, |ui| {
ui.add_space(6.0);
ui.horizontal(|ui| {
ui.label(RichText::new("DoubleTroubleRecomp").size(26.0).strong().color(ACCENT));
ui.label(RichText::new("Bud Tucker in Double Trouble").size(15.0).weak());
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
ui.selectable_value(&mut self.cfg.lang, Lang::En, "EN");
ui.selectable_value(&mut self.cfg.lang, Lang::Fr, "FR");
});
});
ui.add_space(4.0);
});
egui::Panel::top("banner").frame(egui::Frame::NONE).show(ui, |ui| self.banner(ui));
// ---------------- journal
egui::Panel::bottom("log").resizable(true).default_size(140.0).show(ui, |ui| {
ui.horizontal(|ui| {
ui.label(RichText::new(self.t("Journal", "Log")).strong());
if ui.small_button(self.t("Effacer", "Clear")).clicked() {
self.log.clear();
}
if ui.small_button(self.t("Copier", "Copy")).clicked() {
ui.ctx().copy_text(self.log.join("\n"));
}
});
egui::ScrollArea::vertical().stick_to_bottom(true).auto_shrink([false, false]).show(ui, |ui| {
for l in &self.log {
let color = if l.starts_with("> ") {
ACCENT
} else if l.contains("error") || l.contains("erreur") || l.starts_with("!!") || l.contains("ÉCHEC") {
BAD
} else {
ui.visuals().text_color()
};
ui.label(RichText::new(l).monospace().size(12.0).color(color));
}
});
});
egui::Panel::bottom("status")
.frame(egui::Frame::NONE.fill(CARD_DARK).inner_margin(egui::Margin::symmetric(14, 8)))
.show(ui, |ui| self.status_bar(ui));
egui::CentralPanel::default().show(ui, |ui| {
let Some(root) = self.root.clone() else {
ui.label(RichText::new(self.t(
"Dossier du projet introuvable : placez le launcher dans DoubleTroubleRecomp (à côté de build.bat).",
"Project folder not found: put the launcher inside DoubleTroubleRecomp (next to build.bat).",
)).color(BAD));
return;
};
egui::ScrollArea::vertical().show(ui, |ui| {
// ---------------- 1. jeu
ui.add_space(6.0);
ui.heading(self.t("1. Jeu original", "1. Original game"));
ui.label(RichText::new(self.t(
"Dossier du CD, lecteur (ex. E:\\) ou image .iso. Les fichiers sont lus, jamais modifiés.",
"CD folder, drive (e.g. E:\\) or .iso image. Files are read, never modified.",
)).weak());
ui.horizontal(|ui| {
let r = ui.add(egui::TextEdit::singleline(&mut self.cfg.game_path).desired_width(420.0));
if r.lost_focus() {
self.recheck();
}
if ui.button(self.t("Dossier…", "Folder…")).clicked() {
self.pick(Pick::GameFolder);
}
if ui.button(self.t("Image ISO…", "ISO image…")).clicked() {
self.pick(Pick::GameIso);
}
});
ui.horizontal(|ui| match (&self.checks.game_dir, &self.checks.game_error) {
(Some(d), _) => status(ui, true, self.t("Jeu trouvé", "Game found"), &d.display().to_string()),
(None, Some(e)) if !e.is_empty() => status(ui, false, self.t("Jeu introuvable", "Game not found"), e),
_ if self.checks.done => status(ui, false, self.t("Choisissez le jeu", "Choose the game"), ""),
_ => {
ui.spinner();
}
});
ui.collapsing(self.t("Avancé : dossier d'installation", "Advanced: install folder"), |ui| {
if self.show_log {
egui::Panel::bottom("log")
.resizable(true)
.default_size(180.0)
.frame(egui::Frame::NONE.fill(CARD_DARK).inner_margin(egui::Margin::same(10)))
.show(ui, |ui| self.log_view(ui));
}
egui::CentralPanel::default()
.frame(egui::Frame::NONE.fill(BG).inner_margin(egui::Margin::symmetric(16, 10)))
.show(ui, |ui| {
let Some(root) = self.root.clone() else {
ui.label(RichText::new(self.t(
"Optionnel : dossier TUCKER créé par l'installation DOS (C:\\TUCKER). Vide = automatique.",
"Optional: TUCKER folder created by the DOS install (C:\\TUCKER). Empty = automatic.",
)).weak());
ui.horizontal(|ui| {
ui.add(egui::TextEdit::singleline(&mut self.cfg.install_dir).desired_width(420.0));
if ui.button("…").clicked() {
self.pick(Pick::Install);
}
"Dossier du projet introuvable : placez le launcher dans DoubleTroubleRecomp (à côté de build.bat).",
"Project folder not found: put the launcher inside DoubleTroubleRecomp (next to build.bat).",
)).color(BAD));
return;
};
egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| {
ui.columns(2, |cols| {
self.setup_column(&mut cols[0], &root);
self.play_column(&mut cols[1]);
});
});
ui.separator();
// ---------------- 2. prérequis
ui.horizontal(|ui| {
ui.heading(self.t("2. Prérequis", "2. Requirements"));
if ui.add_enabled(!busy, egui::Button::new(self.t("Vérifier", "Check"))).clicked() {
self.recheck();
}
if self.busy == Busy::Checking {
ui.spinner();
}
});
let c = self.checks.clone();
let mut action: Option<&'static str> = None;
egui::Grid::new("checks").num_columns(4).spacing([10.0, 6.0]).show(ui, |ui| {
status(ui, c.python.is_some(), "Python 3", c.python.as_deref().unwrap_or(self.t("absent de PATH", "not in PATH")));
if c.python.is_none() {
ui.hyperlink_to("python.org", "https://www.python.org/downloads/");
}
ui.end_row();
status(ui, c.capstone.is_some(), "capstone", c.capstone.as_deref().unwrap_or(self.t("non installé", "not installed")));
if c.capstone.is_none() && c.python.is_some()
&& ui.add_enabled(!busy, egui::Button::new(self.t("Installer (pip)", "Install (pip)"))).clicked()
{
action = Some("capstone");
}
ui.end_row();
let vc = c.vcvars.as_ref().map(|p| p.display().to_string());
status(ui, vc.is_some(), "MSVC (Visual Studio 2022)", vc.as_deref().unwrap_or(self.t("introuvable", "not found")));
if vc.is_none() {
ui.hyperlink_to("Build Tools 2022", "https://visualstudio.microsoft.com/downloads/");
}
ui.end_row();
status(ui, c.sdl, &format!("SDL2 {SDL_VER}"), if c.sdl { "third_party" } else { self.t("absent", "missing") });
if !c.sdl && ui.add_enabled(!busy, egui::Button::new(self.t("Télécharger", "Download"))).clicked() {
action = Some("sdl");
}
ui.end_row();
});
match action {
Some("capstone") => self.install_capstone(),
Some("sdl") => self.download_sdl(),
_ => {}
}
ui.separator();
// ---------------- 3. compilation
ui.heading(self.t("3. Compilation", "3. Build"));
ui.label(RichText::new(self.t(
"Traduit TUCKER.EXE et INTRO.EXE en C, puis compile. Quelques minutes la première fois.",
"Translates TUCKER.EXE and INTRO.EXE to C, then compiles. Takes a few minutes the first time.",
)).weak());
ui.horizontal(|ui| {
let can = !busy && c.can_build();
if ui.add_enabled(can, egui::Button::new(RichText::new(self.t("Générer et compiler", "Generate and build")).strong())).clicked() {
self.build(true);
}
if ui.add_enabled(can && root.join("build").join("gen_tucker").is_dir(),
egui::Button::new(self.t("Recompiler seulement", "Rebuild only"))).clicked()
{
self.build(false);
}
if let Busy::Task(_) = self.busy {
ui.spinner();
ui.label(self.t("en cours…", "running…"));
} else if let Some(ok) = self.last_ok {
ui.label(RichText::new(if ok { self.t("Terminé", "Done") } else { self.t("Échec, voir le journal", "Failed, see the log") })
.color(if ok { OK } else { BAD }));
}
});
ui.horizontal(|ui| status(ui, c.built, self.t("Jeu compilé", "Game built"), "build\\tucker.exe"));
ui.separator();
// ---------------- 4. jouer
ui.heading(self.t("4. Jouer", "4. Play"));
let en = self.cfg.lang == Lang::En;
let tr = |fr: &'static str, e: &'static str| if en { e } else { fr };
ui.horizontal_wrapped(|ui| {
ui.checkbox(&mut self.cfg.sound, tr("Son", "Sound"));
ui.checkbox(&mut self.cfg.fullscreen, tr("Plein écran", "Fullscreen"));
ui.checkbox(&mut self.cfg.skip_intro, tr("Passer l'intro", "Skip intro"));
ui.checkbox(&mut self.cfg.verbose, tr("Journal détaillé", "Verbose log"));
});
ui.horizontal(|ui| {
ui.label(self.t("Taille de la fenêtre", "Window scale"));
ui.add(egui::Slider::new(&mut self.cfg.scale, 1..=8).suffix("×"));
ui.label(RichText::new(format!("{}×{}", 320 * self.cfg.scale, 240 * self.cfg.scale)).weak());
});
ui.add_space(6.0);
let can_play = !busy && !self.game_running && c.built && c.game_dir.is_some();
let label = if self.game_running { self.t("Jeu en cours…", "Game running…") } else { self.t("JOUER", "PLAY") };
if ui.add_enabled(can_play, egui::Button::new(RichText::new(label).size(20.0).strong().color(Color32::BLACK)).fill(ACCENT).min_size(egui::vec2(200.0, 44.0))).clicked() {
self.play();
}
ui.add_space(8.0);
ui.label(RichText::new(self.t("F11 ou Alt+Entrée : plein écran en jeu.", "F11 or Alt+Enter: toggle fullscreen in game.")).weak());
});
});
if self.cfg != self.saved {
self.cfg.save();
@@ -796,8 +1121,8 @@ fn main() -> eframe::Result {
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_title("DoubleTroubleRecomp")
.with_inner_size([860.0, 820.0])
.with_min_inner_size([640.0, 520.0]),
.with_inner_size([1000.0, 840.0])
.with_min_inner_size([760.0, 600.0]),
..Default::default()
};
eframe::run_native("DoubleTroubleRecomp", options, Box::new(|cc| Ok(Box::new(App::new(cc)))))