Launcher : musique, pack HD par parties, export confirmé et bouton Arrêter
- Musique « Double Trouble » (VF et VUS, créées avec Suno par LinkAtPlug), MP3 96 kb/s embarqués dans l'exe, jouée par MCI (winmm) : lecture/pause, drapeaux VF/VUS, volume (75 % par défaut), Muet (coupe aussi au prochain démarrage). Version selon la langue, coupée au lancement du jeu et reprise à sa fermeture. - Langue : libellé « Language » et liste déroulante avec drapeaux. - Créer un pack HD : cases Décors, Cinématiques, Barre d'actions, Personnages et objets ; « Même modèle pour tout » décoché = un modèle par partie (mods\hd_perso). Bouton « + barre d'actions » sur les packs qui ne l'ont pas. - Exporter les images d'origine : fenêtre de confirmation (contenu, durée, dossier). - Bouton Arrêter (barre du bas et carte Mods) : tue la tâche et ses enfants (python, Upscayl). - Docs GUIDE et TEXTURES FR/EN à jour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8e943e81aa
commit
2315723854
10 files changed
+585
-77
No files matched your search
@@ -19,3 +19,6 @@
|
||||
|
||||
# Police Bangers : SIL OFL 1.1
|
||||
launcher/assets/fonts/*.ttf binary
|
||||
|
||||
# Musiques du launcher (créées avec Suno par LinkAtPlug)
|
||||
*.mp3 binary
|
||||
+6
-3
@@ -279,11 +279,13 @@ The action bar (verbs and background) goes HD too; texts stay the game's own. Th
|
||||
1. Install [Upscayl](https://upscayl.org) ([step by step](TEXTURES.en.md#1-install-upscayl)). While
|
||||
it's missing, the launcher shows a yellow "Upscayl is not installed" box.
|
||||
2. In the launcher, **Mods & HD backgrounds** card, "Create an HD pack with Upscayl": pick a model,
|
||||
keep **Backgrounds, cutscenes and bar** ticked, then **Create pack**. The 148 images (122
|
||||
keep **Backgrounds**, **Cutscenes** and **Action bar** ticked, then **Create pack**. The 148 images (122
|
||||
backgrounds, 24 cutscene pictures, the action bar) are upscaled ×4 in a few minutes. **Characters
|
||||
and objects** (experimental, unticked by default) adds several thousand images and takes much
|
||||
longer. Everything goes into `mods\hd_upscayl` (or `mods\hd_upscayl_<model>`),
|
||||
with **one model for the whole pack**. For an existing background pack: **+ HD sprites** button
|
||||
with **one model for the whole pack**. Untick **One model for everything** to pick a model per
|
||||
part (composed pack, in `mods\hd_perso`). The **Stop** button (next to it, or in the bottom bar)
|
||||
interrupts the creation; **Repair** then redoes the empty pictures. For an existing background pack: **+ HD sprites** button
|
||||
on its line. The 24 still pictures of the cutscenes (pyramid, maps, newspapers…) are made with the
|
||||
backgrounds. **Close games and 3D applications while the pack is made**: Upscayl puts a heavy load
|
||||
on the graphics card. If pictures are missing after a crash, **Repair** button on the pack's line.
|
||||
@@ -305,7 +307,8 @@ Command line: `python tools\hd_export.py C:\Games\TUCKER mods\hd_upscayl\hd --up
|
||||
|
||||
### With the tool of your choice
|
||||
|
||||
1. Launcher: **Export original images**. The backgrounds (320×200 PNGs) go to `mods\_decors_originaux`
|
||||
1. Launcher: **Export original images** (a window sums up what will happen; **Stop** interrupts
|
||||
the export). The backgrounds (320×200 PNGs) go to `mods\_decors_originaux`
|
||||
(the `_` makes the game ignore that folder), then the characters and objects into its `SHEETS` and
|
||||
`SPRITES` subfolders (2-3 minutes). The folder opens at the end.
|
||||
2. Upscale them with anything you like: Upscayl, chaiNNer, waifu2x, Topaz, hand retouching…
|
||||
|
||||
+6
-3
@@ -285,11 +285,13 @@ créées **sur votre PC à partir de votre copie** : rien n'est téléchargé ni
|
||||
1. Installez [Upscayl](https://upscayl.org) ([pas à pas](TEXTURES.md#1-installer-upscayl)). Tant
|
||||
qu'il manque, le launcher affiche un encadré jaune « Upscayl n'est pas installé ».
|
||||
2. Dans le launcher, carte **Mods et décors HD**, section « Créer un pack HD avec Upscayl » :
|
||||
choisissez un modèle, gardez **Décors, cinématiques et barre** coché, puis **Créer le pack**.
|
||||
choisissez un modèle, laissez **Décors**, **Cinématiques** et **Barre d'actions** cochés, puis **Créer le pack**.
|
||||
Les 148 images (122 décors, 24 images de cinématique, la barre d'actions) sont agrandies ×4 en
|
||||
quelques minutes. **Personnages et objets** (expérimental, décoché par défaut) ajoute plusieurs
|
||||
milliers d'images et prend nettement plus longtemps. Le tout va dans `mods\hd_upscayl` (ou
|
||||
`mods\hd_upscayl_<modèle>`), avec **un seul modèle pour tout le pack**.
|
||||
`mods\hd_upscayl_<modèle>`), avec **un seul modèle pour tout le pack**. Décochez **Même modèle pour
|
||||
tout** pour choisir un modèle par partie (pack composé, dans `mods\hd_perso`). Le bouton **Arrêter**
|
||||
(à côté, ou dans la barre du bas) interrompt la création ; **Réparer** reprend ensuite les images vides.
|
||||
Pour un pack de décors déjà fait : bouton **+ sprites HD** sur sa ligne. Les 24 images fixes des
|
||||
cinématiques (pyramide, cartes, journaux…) sont faites avec les décors.
|
||||
**Fermez les jeux et applications 3D pendant la création** : Upscayl sollicite fortement la carte
|
||||
@@ -313,7 +315,8 @@ En ligne de commande : `python tools\hd_export.py C:\Jeux\TUCKER mods\hd_upscayl
|
||||
|
||||
### Avec l'outil de votre choix
|
||||
|
||||
1. Launcher : **Exporter les images d'origine**. Les décors (PNG 320×200) arrivent dans
|
||||
1. Launcher : **Exporter les images d'origine** (une fenêtre résume ce qui va se passer ; **Arrêter**
|
||||
interrompt l'export). Les décors (PNG 320×200) arrivent dans
|
||||
`mods\_decors_originaux` (le `_` fait que le jeu ignore ce dossier), puis les personnages et objets
|
||||
dans ses sous-dossiers `SHEETS` et `SPRITES` (2 à 3 minutes). Le dossier s'ouvre à la fin.
|
||||
2. Agrandissez-les avec ce que vous voulez : Upscayl, chaiNNer, waifu2x, Topaz, retouche à la main…
|
||||
|
||||
+3
-2
@@ -109,7 +109,8 @@ Upscayl won't work, but you can:
|
||||
|
||||
1. Install Upscayl ([section 1](#1-install-upscayl)).
|
||||
2. Launcher → **Mods & HD backgrounds** card → "Create an HD pack with Upscayl".
|
||||
3. Pick a **model** (see the table). Leave **Backgrounds, cutscenes and bar** ticked; **Characters and
|
||||
3. Pick a **model** (see the table). Leave **Backgrounds**, **Cutscenes** and **Action bar** ticked (untick **One model for everything** to
|
||||
pick a model per part: composed pack in `mods\hd_perso`); **Characters and
|
||||
objects** (experimental, unticked by default) adds the HD sprites (much longer, see [section I](#i-hd-characters-and-objects-sprites)). Then **Create pack**.
|
||||
4. Wait: a few seconds to a few minutes depending on the graphics card. The log (**Log** button, at
|
||||
the bottom) shows progress. **Close games and 3D applications meanwhile**: Upscayl puts a heavy
|
||||
@@ -389,7 +390,7 @@ backgrounds', because the object sheet has its own palette.
|
||||
| Black or flickering screens while the pack is being made, or a frozen PC | The graphics driver failed under Upscayl's load. Close games and 3D apps, update the driver, then resume with **Repair** (below); the export stops by itself after three failures in a row. On a modest PC, pick `upscayl-lite-4x`. |
|
||||
| Pictures are missing after a crash or an interrupted export | Failed pictures are removed from the pack (the game keeps the original). **Repair** button on the pack's line, or: `python tools\hd_export.py "C:\Games\TUCKER" mods\hd_upscayl\hd --reparer --upscayl <pack model>`. |
|
||||
| The pack is created but stays empty / Vulkan error in the log | Update your graphics driver; open Upscayl on its own to check that it works. On a laptop with two GPUs, pick the dedicated one in Upscayl's settings. |
|
||||
| The action bar or the cutscenes stay pixelated | The pack predates their addition (December 5, 2026): create it again with **Backgrounds, cutscenes and bar** ticked (same model). Also check the **Action bar** box. |
|
||||
| The action bar or the cutscenes stay pixelated | The pack predates their addition (December 5, 2026): create it again with **Backgrounds**, **Cutscenes** and **Action bar** ticked (same model); for the bar alone, **+ action bar** button on the pack's line. Also check the **Action bar** box. |
|
||||
| My image doesn't show in game | Exact name (`LOC01.png`, not `LOC01_upscayl…png`); `mods\<name>\hd\` folder; mod ticked; **HD pack** and **Backgrounds** ticked; a filter other than CRT; 16:10 image. |
|
||||
| The image is offset or "bleeds" around characters | The framing changed (crop, border, ratio). Start again from the export and keep the whole image. |
|
||||
| A vertical seam in the middle of a scrolling room | The `A`/`B`… pieces weren't processed the same way; redo them with the same tool and size. |
|
||||
|
||||
+3
-2
@@ -111,7 +111,8 @@ Upscayl ne marchera pas, mais vous pouvez :
|
||||
|
||||
1. Installez Upscayl ([section 1](#1-installer-upscayl)).
|
||||
2. Launcher → carte **Mods et décors HD** → « Créer un pack HD avec Upscayl ».
|
||||
3. Choisissez un **modèle** (voir le tableau). Laissez **Décors, cinématiques et barre** coché ; **Personnages et
|
||||
3. Choisissez un **modèle** (voir le tableau). Laissez **Décors**, **Cinématiques** et **Barre d'actions** cochés (décochez **Même modèle pour tout** pour
|
||||
choisir un modèle par partie : pack composé dans `mods\hd_perso`) ; **Personnages et
|
||||
objets** (expérimental, décoché par défaut) ajoute les sprites HD (beaucoup plus long, voir [section I](#i-personnages-et-objets-hd-sprites)). Puis **Créer le pack**.
|
||||
4. Patientez : de quelques secondes à quelques minutes selon la carte graphique. Le journal
|
||||
(bouton **Journal**, en bas) montre l'avancement. **Fermez les jeux et applications 3D pendant ce
|
||||
@@ -392,7 +393,7 @@ que ceux des décors, parce que la planche d'objets a sa propre palette.
|
||||
| Écrans noirs ou qui clignotent pendant la création du pack, voire PC figé | Le pilote de la carte graphique a décroché sous la charge d'Upscayl. Fermez les jeux et applis 3D, mettez à jour le pilote, puis reprenez avec **Réparer** (ci-dessous) ; l'export s'arrête de lui-même après trois échecs de suite. Sur un petit PC, choisissez `upscayl-lite-4x`. |
|
||||
| Des images manquent après un plantage ou un export interrompu | Les images ratées sont retirées du pack (le jeu garde l'original). Bouton **Réparer** sur la ligne du pack, ou : `python tools\hd_export.py "C:\Jeux\TUCKER" mods\hd_upscayl\hd --reparer --upscayl <modèle du pack>`. |
|
||||
| Le pack se crée mais reste vide / erreur Vulkan dans le journal | Mettez à jour le pilote de la carte graphique ; ouvrez Upscayl seul pour vérifier qu'il fonctionne. Sur un PC portable à deux cartes, choisissez la carte dédiée dans les réglages d'Upscayl. |
|
||||
| La barre d'actions ou les cinématiques restent pixelisées | Le pack date d'avant leur ajout (5 décembre 2026) : recréez-le avec **Décors, cinématiques et barre** coché (même modèle). Vérifiez aussi la case **Barre d'actions**. |
|
||||
| La barre d'actions ou les cinématiques restent pixelisées | Le pack date d'avant leur ajout (5 décembre 2026) : recréez-le avec **Décors**, **Cinématiques** et **Barre d'actions** cochés (même modèle) ; pour la barre seule, bouton **+ barre d'actions** sur la ligne du pack. Vérifiez aussi la case **Barre d'actions**. |
|
||||
| Mon image n'apparaît pas en jeu | Nom exact (`LOC01.png`, pas `LOC01_upscayl…png`) ; dossier `mods\<nom>\hd\` ; mod coché ; **Pack HD** et **Décors** cochés ; filtre autre que CRT ; image en 16:10. |
|
||||
| L'image est décalée ou « bave » autour des personnages | Le cadrage a changé (recadrage, bordure, ratio). Repartez de l'export et gardez l'image entière. |
|
||||
| Une couture verticale au milieu d'une pièce qui défile | Les morceaux `A`/`B`… n'ont pas été traités pareil ; refaites-les avec le même outil et la même taille. |
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+421
-67
@@ -11,6 +11,7 @@
|
||||
|
||||
mod art;
|
||||
mod mods;
|
||||
mod music;
|
||||
mod preview;
|
||||
mod saves;
|
||||
mod settings;
|
||||
@@ -21,6 +22,7 @@ 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::atomic::{AtomicBool, AtomicU32, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
|
||||
@@ -60,6 +62,10 @@ struct Config {
|
||||
/// aperçu : zoom ×4 (sinon image entière), comparaison avec l'original
|
||||
preview_zoom: bool,
|
||||
preview_compare: bool,
|
||||
/// musique du launcher coupée au démarrage
|
||||
music_mute: bool,
|
||||
/// volume de la musique, en %
|
||||
music_volume: u32,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -78,6 +84,8 @@ impl Default for Config {
|
||||
maximized: false,
|
||||
preview_zoom: true,
|
||||
preview_compare: false,
|
||||
music_mute: false,
|
||||
music_volume: 75,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,6 +116,8 @@ impl Config {
|
||||
"maximized" => c.maximized = b,
|
||||
"preview_zoom" => c.preview_zoom = b,
|
||||
"preview_compare" => c.preview_compare = b,
|
||||
"music_mute" => c.music_mute = b,
|
||||
"music_volume" => c.music_volume = v.parse::<u32>().unwrap_or(75).min(100),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -122,7 +132,7 @@ impl Config {
|
||||
let b = |x: bool| if x { "1" } else { "0" };
|
||||
let text = format!(
|
||||
"lang={}\ngame_path={}\ninstall_dir={}\nsound={}\nskip_intro={}\nresume={}\nresume_slot={}\nverbose={}\n\
|
||||
window_width={}\nwindow_height={}\nmaximized={}\npreview_zoom={}\npreview_compare={}\n",
|
||||
window_width={}\nwindow_height={}\nmaximized={}\npreview_zoom={}\npreview_compare={}\nmusic_mute={}\nmusic_volume={}\n",
|
||||
if self.lang == Lang::En { "en" } else { "fr" },
|
||||
self.game_path,
|
||||
self.install_dir,
|
||||
@@ -135,7 +145,9 @@ impl Config {
|
||||
self.win_h,
|
||||
b(self.maximized),
|
||||
b(self.preview_zoom),
|
||||
b(self.preview_compare)
|
||||
b(self.preview_compare),
|
||||
b(self.music_mute),
|
||||
self.music_volume
|
||||
);
|
||||
let _ = std::fs::write(f, text);
|
||||
}
|
||||
@@ -322,6 +334,10 @@ impl Ui {
|
||||
}
|
||||
}
|
||||
|
||||
/// processus (cmd.exe) de l'étape en cours d'une tâche, 0 sans tâche ; et demande d'arrêt du bouton Arrêter
|
||||
static TASK_PID: AtomicU32 = AtomicU32::new(0);
|
||||
static TASK_STOP: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
/// exécute une ligne de commande cmd.exe dans `cwd` en envoyant chaque ligne de sortie au journal
|
||||
fn run_streamed(ui: &Ui, cwd: &Path, line: &str) -> bool {
|
||||
ui.log(format!("> {line}"));
|
||||
@@ -342,10 +358,13 @@ fn run_streamed(ui: &Ui, cwd: &Path, line: &str) -> bool {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
TASK_PID.store(child.id(), Ordering::SeqCst);
|
||||
if let Some(out) = child.stdout.take() {
|
||||
stream_lines(ui, out);
|
||||
}
|
||||
matches!(child.wait(), Ok(s) if s.success())
|
||||
let ok = matches!(child.wait(), Ok(s) if s.success());
|
||||
TASK_PID.store(0, Ordering::SeqCst);
|
||||
ok
|
||||
}
|
||||
|
||||
fn stream_lines(ui: &Ui, r: impl Read) {
|
||||
@@ -715,18 +734,92 @@ struct App {
|
||||
upscayl_models: Vec<String>,
|
||||
upscayl_model: String,
|
||||
new_mod_name: String,
|
||||
/// contenu du pack HD à créer
|
||||
pack_decors: bool,
|
||||
pack_sprites: bool,
|
||||
/// contenu du pack HD à créer, partie par partie (voir PACK_PARTS), et modèle de chaque partie quand
|
||||
/// « même modèle pour tout » est décoché
|
||||
pack_parts: [bool; 4],
|
||||
pack_same_model: bool,
|
||||
part_models: [String; 4],
|
||||
/// fenêtre de confirmation de « Exporter les images d'origine »
|
||||
export_confirm: bool,
|
||||
mod_msg: Option<(bool, String)>,
|
||||
/// dossier à ouvrir quand la tâche en cours réussit
|
||||
open_after: Option<PathBuf>,
|
||||
art: Art,
|
||||
/// musique du launcher ; `music_resume` : elle jouait quand le jeu a été lancé, elle reprend à sa fermeture
|
||||
player: music::Player,
|
||||
music_resume: bool,
|
||||
tx: Sender<Msg>,
|
||||
rx: Receiver<Msg>,
|
||||
ctx: egui::Context,
|
||||
}
|
||||
|
||||
/// drapeaux dessinés (pas d'émoji dans la police) : 0 = France, 1 = États-Unis
|
||||
fn paint_flag(p: &egui::Painter, r: Rect, which: usize) {
|
||||
if which == 0 {
|
||||
let w = r.width() / 3.0;
|
||||
for (i, c) in [Color32::from_rgb(0x00, 0x55, 0xA4), Color32::WHITE, Color32::from_rgb(0xEF, 0x41, 0x35)].into_iter().enumerate() {
|
||||
p.rect_filled(Rect::from_min_size(r.min + egui::vec2(w * i as f32, 0.0), egui::vec2(w, r.height())), 0.0, c);
|
||||
}
|
||||
} else {
|
||||
let h = r.height() / 7.0;
|
||||
for i in 0..7 {
|
||||
let c = if i % 2 == 0 { Color32::from_rgb(0xB2, 0x22, 0x34) } else { Color32::WHITE };
|
||||
p.rect_filled(Rect::from_min_size(r.min + egui::vec2(0.0, h * i as f32), egui::vec2(r.width(), h)), 0.0, c);
|
||||
}
|
||||
let canton = Rect::from_min_size(r.min, egui::vec2(r.width() * 0.45, h * 4.0));
|
||||
p.rect_filled(canton, 0.0, Color32::from_rgb(0x3C, 0x3B, 0x6E));
|
||||
for y in 0..2 {
|
||||
for x in 0..3 {
|
||||
let c = canton.min + egui::vec2(canton.width() * (x as f32 + 0.5) / 3.0, canton.height() * (y as f32 + 0.5) / 2.0);
|
||||
p.circle_filled(c, 0.8, Color32::WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// drapeau cliquable, entouré de jaune quand il est choisi, assombri sinon
|
||||
fn flag_button(ui: &mut egui::Ui, which: usize, selected: bool, tip: &str) -> egui::Response {
|
||||
let (r, resp) = ui.allocate_exact_size(egui::vec2(26.0, 18.0), egui::Sense::click());
|
||||
let resp = resp.on_hover_cursor(egui::CursorIcon::PointingHand).on_hover_text(tip);
|
||||
let p = ui.painter();
|
||||
let f = r.shrink(2.0);
|
||||
paint_flag(p, f, which);
|
||||
if !selected {
|
||||
p.rect_filled(f, 0.0, Color32::from_black_alpha(if resp.hovered() { 60 } else { 130 }));
|
||||
}
|
||||
p.rect_stroke(
|
||||
r.shrink(1.0),
|
||||
CornerRadius::same(2),
|
||||
Stroke::new(if selected { 2.0 } else { 1.0 }, if selected { ACCENT } else { BORDER }),
|
||||
egui::StrokeKind::Middle,
|
||||
);
|
||||
resp
|
||||
}
|
||||
|
||||
/// parties d'un pack HD : (libellé, motif de hd_export.py --motif, nom court pour mod.ini, libellé anglais).
|
||||
/// Les cinématiques reprennent la liste CINEMATIQUES de tools/hd_export.py, la barre sa liste PANNEAUX.
|
||||
const PACK_PARTS: [(&str, &str, &str, &str); 4] = [
|
||||
("Décors (122)", "LOC*", "décors", "Backgrounds (122)"),
|
||||
(
|
||||
"Cinématiques (24)",
|
||||
"CLIO1,CLIO2,DICKDIGS,MAP1,MAP2,MEANW01,MEANW02,MEANW03,SOME01,SOME02,SOME03,NEWS1,NEWS2,\
|
||||
PAPER_3,PHOTO,MEMO,POSTIT,PROFNOTE,PARTSCR,PT1BAK,PT2BAK,PT3BAK,CONGRAT,CONGRATS",
|
||||
"cinématiques",
|
||||
"Cutscenes (24)",
|
||||
),
|
||||
("Barre d'actions", "PANEL1,PANEL2", "barre", "Action bar"),
|
||||
("Personnages et objets", "", "sprites", "Characters and objects"),
|
||||
];
|
||||
|
||||
/// liste déroulante des modèles Upscayl
|
||||
fn model_combo(ui: &mut egui::Ui, salt: impl std::hash::Hash + std::fmt::Debug, value: &mut String, models: &[String]) {
|
||||
egui::ComboBox::from_id_salt(salt).selected_text(value.clone()).show_ui(ui, |ui| {
|
||||
for m in models {
|
||||
ui.selectable_value(value, m.clone(), m);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// tutoriel des textures HD (wiki du dépôt)
|
||||
fn textures_guide(en: bool) -> &'static str {
|
||||
if en {
|
||||
@@ -757,6 +850,11 @@ impl App {
|
||||
setup_theme(&cc.egui_ctx);
|
||||
let (tx, rx) = channel();
|
||||
let cfg = Config::load();
|
||||
// la version suit la langue du launcher : VF en français, VUS en anglais
|
||||
let mut player = music::Player::new(if cfg.lang == Lang::En { 1 } else { 0 }, cfg.music_volume);
|
||||
if !cfg.music_mute {
|
||||
player.play();
|
||||
}
|
||||
let mut app = Self {
|
||||
root: find_root(),
|
||||
saved: cfg.clone(),
|
||||
@@ -782,12 +880,16 @@ impl App {
|
||||
upscayl_models: Vec::new(),
|
||||
upscayl_model: mods::DEFAULT_MODEL.to_string(),
|
||||
new_mod_name: String::new(),
|
||||
pack_decors: true,
|
||||
// sprites HD encore expérimentaux : pas cochés par défaut
|
||||
pack_sprites: false,
|
||||
pack_parts: [true, true, true, false],
|
||||
pack_same_model: true,
|
||||
part_models: std::array::from_fn(|_| mods::DEFAULT_MODEL.to_string()),
|
||||
export_confirm: false,
|
||||
mod_msg: None,
|
||||
open_after: None,
|
||||
art: Art::default(),
|
||||
player,
|
||||
music_resume: false,
|
||||
tx,
|
||||
rx,
|
||||
ctx: cc.egui_ctx.clone(),
|
||||
@@ -917,31 +1019,42 @@ impl App {
|
||||
.collect();
|
||||
}
|
||||
|
||||
/// crée ou complète un pack Upscayl : décors et/ou sprites (planches PCX + fichiers SPR), avec un seul
|
||||
/// modèle pour tout le pack (deux modèles n'agrandissent pas les couleurs pareil : voir docs/MODS.md)
|
||||
fn create_hd_pack(&mut self, target: Option<PathBuf>, model: String, decors: bool, sprites: bool) {
|
||||
/// crée ou complète un pack Upscayl, partie par partie : (index dans PACK_PARTS, modèle). Les images fixes
|
||||
/// (décors, cinématiques, barre) d'un même modèle partent en une commande, les sprites (planches PCX et
|
||||
/// fichiers SPR) dans une autre. Un seul modèle : dossier hd_upscayl[_modèle] ; plusieurs : hd_perso
|
||||
fn create_hd_pack(&mut self, target: Option<PathBuf>, parts: Vec<(usize, String)>) {
|
||||
let (Some(game), Some(mdir)) = (self.checks.game_dir.clone(), self.mods_dir()) else { return };
|
||||
if !decors && !sprites {
|
||||
if parts.is_empty() {
|
||||
return;
|
||||
}
|
||||
let target = target.unwrap_or_else(|| mdir.join(mods::pack_id(&model)));
|
||||
mods::write_mod_ini(&target, &model);
|
||||
let mut cmd = format!(
|
||||
"python -I tools\\hd_export.py \"{}\" \"{}\"",
|
||||
game.display(),
|
||||
target.join("hd").display()
|
||||
);
|
||||
if !decors {
|
||||
cmd.push_str(" --sans-decors");
|
||||
let first = parts[0].1.clone();
|
||||
let same = parts.iter().all(|(_, m)| *m == first);
|
||||
let target = target.unwrap_or_else(|| mdir.join(if same { mods::pack_id(&first) } else { mods::MIXED_PACK.to_string() }));
|
||||
if same {
|
||||
mods::write_mod_ini(&target, &first);
|
||||
} else {
|
||||
let desc: Vec<String> = parts.iter().map(|(i, m)| format!("{} {m}", PACK_PARTS[*i].2)).collect();
|
||||
mods::write_mod_ini_mixed(&target, &desc.join(", "));
|
||||
}
|
||||
if sprites {
|
||||
cmd.push_str(" --planches --sprites");
|
||||
let base = format!("python -I tools\\hd_export.py \"{}\" \"{}\"", game.display(), target.join("hd").display());
|
||||
let bin = self.upscayl.as_ref().map(|b| format!(" --upscayl-bin \"{}\"", b.display())).unwrap_or_default();
|
||||
let mut steps = Vec::new();
|
||||
// images fixes, regroupées par modèle
|
||||
let mut models: Vec<&String> = parts.iter().filter(|(i, _)| *i < 3).map(|(_, m)| m).collect();
|
||||
models.dedup();
|
||||
let mut done: Vec<&String> = Vec::new();
|
||||
for m in models {
|
||||
if done.contains(&m) {
|
||||
continue;
|
||||
}
|
||||
done.push(m);
|
||||
let motif: Vec<&str> = parts.iter().filter(|(i, pm)| *i < 3 && pm == m).map(|(i, _)| PACK_PARTS[*i].1).collect();
|
||||
steps.push(format!("{base} --motif {} --upscayl {m}{bin}", motif.join(",")));
|
||||
}
|
||||
cmd.push_str(&format!(" --upscayl {model}"));
|
||||
if let Some(bin) = &self.upscayl {
|
||||
cmd.push_str(&format!(" --upscayl-bin \"{}\"", bin.display()));
|
||||
if let Some((_, m)) = parts.iter().find(|(i, _)| *i == 3) {
|
||||
steps.push(format!("{base} --sans-decors --planches --sprites --upscayl {m}{bin}"));
|
||||
}
|
||||
self.start_task("hd", vec![cmd]);
|
||||
self.start_task("hd", steps);
|
||||
}
|
||||
|
||||
/// refait seulement les images vides d'un pack (hd_export.py --reparer), avec le modèle du pack
|
||||
@@ -968,6 +1081,8 @@ impl App {
|
||||
let mut refresh = false;
|
||||
let mut create = false;
|
||||
let mut add_sprites: Option<(PathBuf, String)> = None;
|
||||
let mut add_bar: Option<(PathBuf, String)> = None;
|
||||
let mut stop = false;
|
||||
let mut repair: Option<(PathBuf, String)> = None;
|
||||
let mut export = false;
|
||||
let mut new_mod = false;
|
||||
@@ -1038,6 +1153,20 @@ impl App {
|
||||
add_sprites = Some((m.path.clone(), model.clone()));
|
||||
}
|
||||
}
|
||||
// pack créé avant la barre d'actions HD : l'ajouter avec le même modèle (2 images)
|
||||
if let (Some(model), true, true) = (&m.model, m.hd_images > 0 && !m.has_panel, self.upscayl.is_some()) {
|
||||
if ui
|
||||
.add_enabled(can_create, egui::Button::new(tr("+ barre d'actions", "+ action bar")).small())
|
||||
.on_hover_text(if en {
|
||||
format!("Adds the action bar in HD (PANEL1, PANEL2) with the same model as the pack ({model}). A few seconds.")
|
||||
} else {
|
||||
format!("Ajoute la barre d'actions en HD (PANEL1, PANEL2) avec le même modèle que le pack ({model}). Quelques secondes.")
|
||||
})
|
||||
.clicked()
|
||||
{
|
||||
add_bar = Some((m.path.clone(), model.clone()));
|
||||
}
|
||||
}
|
||||
// images ratées (vides) après un plantage du pilote ou un export interrompu
|
||||
if let (Some(model), true, true) = (&m.model, m.hd_images + m.hd_sprites > 0, self.upscayl.is_some()) {
|
||||
if ui
|
||||
@@ -1077,36 +1206,57 @@ impl App {
|
||||
if self.upscayl.is_some() {
|
||||
ui.label(RichText::new(tr("Créer un pack HD avec Upscayl", "Create an HD pack with Upscayl")).strong());
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
egui::ComboBox::from_id_salt("upscayl_model")
|
||||
.selected_text(self.upscayl_model.clone())
|
||||
.show_ui(ui, |ui| {
|
||||
for m in &self.upscayl_models {
|
||||
ui.selectable_value(&mut self.upscayl_model, m.clone(), m);
|
||||
}
|
||||
});
|
||||
ui.checkbox(&mut self.pack_decors, tr("Décors, cinématiques et barre", "Backgrounds, cutscenes and bar"))
|
||||
.on_hover_text(tr(
|
||||
"Les 122 décors des pièces, les 24 images fixes des cinématiques (pyramide, cartes, journaux…) et la barre d'actions.",
|
||||
"The 122 room backgrounds, the 24 still cutscene pictures (pyramid, maps, newspapers…) and the action bar.",
|
||||
));
|
||||
ui.checkbox(&mut self.pack_sprites, tr("Personnages et objets", "Characters and objects"))
|
||||
.on_hover_text(tr(
|
||||
"Expérimental, encore bogué : plusieurs milliers d'images, nettement plus long.",
|
||||
"Experimental, still buggy: thousands of images, much longer.",
|
||||
));
|
||||
ui.label(RichText::new(tr("(expérimental)", "(experimental)")).color(ACCENT).small());
|
||||
let some = self.pack_decors || self.pack_sprites;
|
||||
ui.checkbox(&mut self.pack_same_model, tr("Même modèle pour tout", "One model for everything")).on_hover_text(tr(
|
||||
"Décoché : un modèle par partie (par exemple les décors avec un modèle, la barre d'actions avec un autre), dans mods\\hd_perso. Les modèles ne rendent pas les couleurs pareil : le mélange peut se voir.",
|
||||
"Unticked: one model per part (for instance backgrounds with one model, the action bar with another), in mods\\hd_perso. Models don't render colours the same way: the mix may show.",
|
||||
));
|
||||
if self.pack_same_model {
|
||||
model_combo(ui, "upscayl_model", &mut self.upscayl_model, &self.upscayl_models);
|
||||
}
|
||||
});
|
||||
for (i, (fr, _, _, e)) in PACK_PARTS.iter().enumerate() {
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(24.0);
|
||||
let cb = ui.checkbox(&mut self.pack_parts[i], tr(fr, e));
|
||||
match i {
|
||||
0 => cb.on_hover_text(tr("Les 122 décors des pièces.", "The 122 room backgrounds.")),
|
||||
1 => cb.on_hover_text(tr(
|
||||
"Les 24 images fixes des cinématiques : pyramide, cartes, journaux, écrans de partie…",
|
||||
"The 24 still cutscene pictures: pyramid, maps, newspapers, part screens…",
|
||||
)),
|
||||
2 => cb.on_hover_text(tr(
|
||||
"Verbes, fond de la barre et panneau d'options (PANEL1, PANEL2).",
|
||||
"Verbs, bar background and options panel (PANEL1, PANEL2).",
|
||||
)),
|
||||
_ => cb.on_hover_text(tr(
|
||||
"Expérimental, encore bogué : plusieurs milliers d'images, nettement plus long.",
|
||||
"Experimental, still buggy: thousands of images, much longer.",
|
||||
)),
|
||||
};
|
||||
if i == 3 {
|
||||
ui.label(RichText::new(tr("(expérimental)", "(experimental)")).color(ACCENT).small());
|
||||
}
|
||||
if !self.pack_same_model {
|
||||
model_combo(ui, ("part_model", i), &mut self.part_models[i], &self.upscayl_models);
|
||||
}
|
||||
});
|
||||
}
|
||||
let some = self.pack_parts.iter().any(|&b| b);
|
||||
ui.horizontal(|ui| {
|
||||
if ui.add_enabled(can_create && some, egui::Button::new(tr("Créer le pack", "Create pack"))).clicked() {
|
||||
create = true;
|
||||
}
|
||||
if matches!(self.busy, Busy::Task("hd")) && ui.button(tr("Arrêter", "Stop")).clicked() {
|
||||
stop = true;
|
||||
}
|
||||
});
|
||||
let folder = if self.pack_same_model { mods::pack_id(&self.upscayl_model) } else { mods::MIXED_PACK.to_string() };
|
||||
ui.label(RichText::new(format!(
|
||||
"{} mods\\{}",
|
||||
"{} mods\\{folder}",
|
||||
tr(
|
||||
"Tout le pack avec le même modèle. Décors, cinématiques et barre d'actions : 148 images, quelques minutes ; personnages et objets : plusieurs milliers d'images, nettement plus long. Fermez les jeux et applis 3D pendant la création. Dossier :",
|
||||
"The whole pack with one model. Backgrounds, cutscenes and action bar: 148 images, a few minutes; characters and objects: thousands of images, much longer. Close games and 3D apps while it runs. Folder:"
|
||||
"Décors, cinématiques et barre d'actions : 148 images, quelques minutes ; personnages et objets : plusieurs milliers d'images, nettement plus long. Fermez les jeux et applis 3D pendant la création. Dossier :",
|
||||
"Backgrounds, cutscenes and action bar: 148 images, a few minutes; characters and objects: thousands of images, much longer. Close games and 3D apps while it runs. Folder:"
|
||||
),
|
||||
mods::pack_id(&self.upscayl_model)
|
||||
)).weak().small());
|
||||
} else {
|
||||
// Upscayl absent : prévenir clairement, avec quoi faire
|
||||
@@ -1133,12 +1283,17 @@ impl App {
|
||||
ui.label(RichText::new(tr("Faire son propre pack HD", "Make your own HD pack")).strong());
|
||||
ui.hyperlink_to(tr("(tutoriel)", "(tutorial)"), textures_guide(en));
|
||||
});
|
||||
if ui
|
||||
.add_enabled(can_create, egui::Button::new(tr("Exporter les images d'origine", "Export original images")))
|
||||
.clicked()
|
||||
{
|
||||
export = true;
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
if ui
|
||||
.add_enabled(can_create, egui::Button::new(tr("Exporter les images d'origine", "Export original images")))
|
||||
.clicked()
|
||||
{
|
||||
export = true;
|
||||
}
|
||||
if matches!(self.busy, Busy::Task("hd-export")) && ui.button(tr("Arrêter", "Stop")).clicked() {
|
||||
stop = true;
|
||||
}
|
||||
});
|
||||
ui.label(RichText::new(format!(
|
||||
"{} mods\\{}",
|
||||
tr(
|
||||
@@ -1175,22 +1330,84 @@ impl App {
|
||||
self.reload_mods();
|
||||
}
|
||||
if create {
|
||||
self.create_hd_pack(None, self.upscayl_model.clone(), self.pack_decors, self.pack_sprites);
|
||||
let parts: Vec<(usize, String)> = (0..PACK_PARTS.len())
|
||||
.filter(|&i| self.pack_parts[i])
|
||||
.map(|i| (i, if self.pack_same_model { self.upscayl_model.clone() } else { self.part_models[i].clone() }))
|
||||
.collect();
|
||||
self.create_hd_pack(None, parts);
|
||||
}
|
||||
if let Some((path, model)) = add_sprites {
|
||||
self.create_hd_pack(Some(path), model, false, true);
|
||||
self.create_hd_pack(Some(path), vec![(3, model)]);
|
||||
}
|
||||
if let Some((path, model)) = add_bar {
|
||||
self.create_hd_pack(Some(path), vec![(2, model)]);
|
||||
}
|
||||
if stop {
|
||||
self.stop_task();
|
||||
}
|
||||
if let Some((path, model)) = repair {
|
||||
self.repair_hd_pack(path, model);
|
||||
}
|
||||
if export {
|
||||
self.export_originals();
|
||||
self.export_confirm = true;
|
||||
}
|
||||
if self.export_confirm {
|
||||
self.export_dialog(ui, en);
|
||||
}
|
||||
if new_mod {
|
||||
self.new_mod();
|
||||
}
|
||||
}
|
||||
|
||||
/// confirmation avant l'export : ce qu'il fait, combien de temps, où ça va
|
||||
fn export_dialog(&mut self, ui: &mut egui::Ui, en: bool) {
|
||||
let tr = |fr: &'static str, e: &'static str| if en { e } else { fr };
|
||||
let mut go = false;
|
||||
let mut cancel = false;
|
||||
let modal = egui::Modal::new(ui.scope_id().with("export_confirm")).show(ui.ctx(), |ui| {
|
||||
ui.set_max_width(460.0);
|
||||
ui.label(RichText::new(tr("Exporter les images d'origine ?", "Export the original pictures?")).heading().color(ACCENT));
|
||||
ui.add_space(6.0);
|
||||
ui.label(tr(
|
||||
"Le launcher va extraire les images du jeu en PNG, à leur taille d'origine :",
|
||||
"The launcher will extract the game's pictures as PNG, at their original size:",
|
||||
));
|
||||
ui.label(tr(
|
||||
"• décors, cinématiques et barre d'actions : 148 images 320×200, quelques secondes ;",
|
||||
"• backgrounds, cutscenes and action bar: 148 320×200 pictures, a few seconds;",
|
||||
));
|
||||
ui.label(tr(
|
||||
"• puis personnages et objets (SHEETS et SPRITES) : plusieurs milliers d'images, 2 à 3 minutes.",
|
||||
"• then characters and objects (SHEETS and SPRITES): thousands of pictures, 2-3 minutes.",
|
||||
));
|
||||
ui.add_space(4.0);
|
||||
ui.label(format!(
|
||||
"{} mods\\{}{}",
|
||||
tr("Rien n'est agrandi : ce sont les images à retoucher ou agrandir avec l'outil de votre choix. Elles vont dans", "Nothing is upscaled: these are the pictures to retouch or upscale with any tool. They go to"),
|
||||
mods::EXPORT_DIR,
|
||||
tr(
|
||||
" (ignoré par le jeu), qui s'ouvrira à la fin. Le bouton Arrêter interrompt l'export à tout moment.",
|
||||
" (ignored by the game), which opens at the end. The Stop button interrupts the export at any time.",
|
||||
),
|
||||
));
|
||||
ui.add_space(10.0);
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button(RichText::new(tr("Lancer l'export", "Start the export")).strong()).clicked() {
|
||||
go = true;
|
||||
}
|
||||
if ui.button(tr("Annuler", "Cancel")).clicked() {
|
||||
cancel = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
if go {
|
||||
self.export_confirm = false;
|
||||
self.export_originals();
|
||||
} else if cancel || modal.should_close() {
|
||||
self.export_confirm = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// images d'origine en PNG dans mods/_decors_originaux (ignoré par le jeu) : décors 320×200, puis
|
||||
/// personnages et objets dans SHEETS/ et SPRITES/ ; ouvre le dossier à la fin
|
||||
fn export_originals(&mut self) {
|
||||
@@ -1537,13 +1754,40 @@ impl App {
|
||||
self.last_ok = None;
|
||||
self.show_log = true;
|
||||
let ui = self.ui_handle();
|
||||
TASK_STOP.store(false, Ordering::SeqCst);
|
||||
thread::spawn(move || {
|
||||
let ok = steps.iter().all(|s| run_streamed(&ui, &root, s));
|
||||
ui.log(if ok { "== OK ==" } else { "== ÉCHEC / FAILED ==" });
|
||||
ui.send(Msg::TaskDone { ok });
|
||||
let ok = steps.iter().all(|s| !TASK_STOP.load(Ordering::SeqCst) && run_streamed(&ui, &root, s));
|
||||
let stopped = TASK_STOP.load(Ordering::SeqCst);
|
||||
ui.log(if stopped {
|
||||
"== ARRÊTÉ / STOPPED =="
|
||||
} else if ok {
|
||||
"== OK =="
|
||||
} else {
|
||||
"== ÉCHEC / FAILED =="
|
||||
});
|
||||
ui.send(Msg::TaskDone { ok: ok && !stopped });
|
||||
});
|
||||
}
|
||||
|
||||
/// bouton Arrêter : tue l'étape en cours avec tous ses enfants (python, upscayl-bin…) et saute les suivantes
|
||||
fn stop_task(&mut self) {
|
||||
TASK_STOP.store(true, Ordering::SeqCst);
|
||||
let pid = TASK_PID.load(Ordering::SeqCst);
|
||||
if pid != 0 {
|
||||
let _ = hidden("taskkill").args(["/F", "/T", "/PID", &pid.to_string()]).stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null()).status();
|
||||
}
|
||||
self.open_after = None;
|
||||
}
|
||||
|
||||
/// libellé de la tâche en cours, barre du bas
|
||||
fn task_label(&self, name: &str) -> &'static str {
|
||||
match name {
|
||||
"hd" => self.t("Création du pack HD…", "Creating the HD pack…"),
|
||||
"hd-export" => self.t("Export des images…", "Exporting pictures…"),
|
||||
_ => self.t("Compilation en cours…", "Working…"),
|
||||
}
|
||||
}
|
||||
|
||||
fn build(&mut self, regenerate: bool) {
|
||||
let (Some(dir), Some(vc)) = (self.checks.game_dir.clone(), self.checks.vcvars.clone()) else { return };
|
||||
// build.bat DOSSIER régénère le C depuis le jeu choisi, build.bat nogen recompile seulement
|
||||
@@ -1627,6 +1871,9 @@ impl App {
|
||||
match cmd.spawn() {
|
||||
Ok(mut child) => {
|
||||
self.game_running = true;
|
||||
// le jeu a sa propre musique : on coupe celle du launcher
|
||||
self.music_resume = self.player.playing;
|
||||
self.player.pause();
|
||||
let ui = self.ui_handle();
|
||||
thread::spawn(move || {
|
||||
if let Some(err) = child.stderr.take() {
|
||||
@@ -1680,6 +1927,9 @@ impl App {
|
||||
}
|
||||
Msg::GameExited(code) => {
|
||||
self.game_running = false;
|
||||
if std::mem::take(&mut self.music_resume) {
|
||||
self.player.play();
|
||||
}
|
||||
self.reload_saves();
|
||||
self.reload_mods();
|
||||
// le joueur a pu changer ses réglages avec F12 : on relit le fichier
|
||||
@@ -1784,11 +2034,28 @@ impl App {
|
||||
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));
|
||||
// langue : liste déroulante (d'autres langues viendront), drapeau de la langue choisie à côté
|
||||
let lr = Rect::from_min_size(egui::pos2(rect.right() - 260.0, rect.top() + 10.0), egui::vec2(250.0, 28.0));
|
||||
let lang_before = self.cfg.lang;
|
||||
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());
|
||||
let name = |l: Lang| if l == Lang::En { "English" } else { "Français" };
|
||||
egui::ComboBox::from_id_salt("lang").width(110.0).selected_text(name(self.cfg.lang)).show_ui(ui, |ui| {
|
||||
for l in [Lang::Fr, Lang::En] {
|
||||
ui.horizontal(|ui| {
|
||||
let (r, _) = ui.allocate_exact_size(egui::vec2(22.0, 14.0), egui::Sense::hover());
|
||||
paint_flag(ui.painter(), r, if l == Lang::En { 1 } else { 0 });
|
||||
ui.selectable_value(&mut self.cfg.lang, l, name(l));
|
||||
});
|
||||
}
|
||||
});
|
||||
let (r, _) = ui.allocate_exact_size(egui::vec2(24.0, 16.0), egui::Sense::hover());
|
||||
paint_flag(ui.painter(), r, if self.cfg.lang == Lang::En { 1 } else { 0 });
|
||||
ui.label(RichText::new("Language").strong());
|
||||
});
|
||||
// changer de langue change aussi de version de la musique
|
||||
if self.cfg.lang != lang_before {
|
||||
self.player.set_track(if self.cfg.lang == Lang::En { 1 } else { 0 });
|
||||
}
|
||||
}
|
||||
|
||||
fn status_bar(&mut self, ui: &mut egui::Ui) {
|
||||
@@ -1802,10 +2069,13 @@ impl App {
|
||||
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 {
|
||||
if let Busy::Task(name) = self.busy {
|
||||
ui.label(RichText::new("•").weak());
|
||||
ui.spinner();
|
||||
ui.label(RichText::new(self.t("Compilation en cours…", "Working…")).color(ACCENT));
|
||||
ui.label(RichText::new(self.task_label(name)).color(ACCENT));
|
||||
if ui.small_button(self.t("Arrêter", "Stop")).on_hover_text(self.t("Arrête la tâche en cours", "Stops the running task")).clicked() {
|
||||
self.stop_task();
|
||||
}
|
||||
}
|
||||
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") };
|
||||
@@ -1821,6 +2091,90 @@ impl App {
|
||||
coffee_link(ui, self.cfg.lang == Lang::En);
|
||||
});
|
||||
});
|
||||
// lecteur de musique, centré dans la barre (largeur mesurée à l'image précédente)
|
||||
let full = ui.max_rect();
|
||||
let id = ui.scope_id().with("music_controls_w");
|
||||
let w = ui.ctx().data(|d| d.get_temp::<f32>(id)).unwrap_or(280.0);
|
||||
let r = Rect::from_center_size(full.center(), egui::vec2(w, full.height()));
|
||||
let used = ui
|
||||
.scope_builder(egui::UiBuilder::new().max_rect(r).layout(egui::Layout::left_to_right(egui::Align::Center)), |ui| {
|
||||
self.music_controls(ui)
|
||||
})
|
||||
.response
|
||||
.rect
|
||||
.width();
|
||||
if (used - w).abs() > 0.5 {
|
||||
ui.ctx().data_mut(|d| d.insert_temp(id, used));
|
||||
ui.ctx().request_repaint();
|
||||
}
|
||||
}
|
||||
|
||||
/// lecture/pause (dessiné : ▶ n'existe pas dans la police), VF / VUS, muet au prochain démarrage
|
||||
fn music_controls(&mut self, ui: &mut egui::Ui) {
|
||||
let en = self.cfg.lang == Lang::En;
|
||||
let playing = self.player.playing;
|
||||
let (r, resp) = ui.allocate_exact_size(egui::vec2(28.0, 22.0), egui::Sense::click());
|
||||
let resp = resp.on_hover_cursor(egui::CursorIcon::PointingHand).on_hover_text(match (playing, en) {
|
||||
(true, false) => "Mettre la musique en pause",
|
||||
(true, true) => "Pause the music",
|
||||
(false, false) => "Jouer la musique",
|
||||
(false, true) => "Play the music",
|
||||
});
|
||||
let p = ui.painter();
|
||||
p.rect_filled(r, CornerRadius::same(5), if resp.hovered() { BTN_HOVER } else { BTN });
|
||||
let c = r.center();
|
||||
if playing {
|
||||
for dx in [-3.0, 3.0] {
|
||||
p.rect_filled(Rect::from_center_size(c + egui::vec2(dx, 0.0), egui::vec2(3.5, 11.0)), 1.0, ACCENT);
|
||||
}
|
||||
} else {
|
||||
p.add(egui::Shape::convex_polygon(
|
||||
vec![c + egui::vec2(-4.0, -6.0), c + egui::vec2(6.0, 0.0), c + egui::vec2(-4.0, 6.0)],
|
||||
ACCENT,
|
||||
Stroke::NONE,
|
||||
));
|
||||
}
|
||||
if resp.clicked() {
|
||||
self.player.toggle();
|
||||
}
|
||||
ui.add_space(4.0);
|
||||
for i in 0..music::TRACKS.len() {
|
||||
let tip = match (i, en) {
|
||||
(0, false) => "Version française",
|
||||
(0, true) => "French version",
|
||||
(_, false) => "Version anglaise (US)",
|
||||
(_, true) => "English (US) version",
|
||||
};
|
||||
if flag_button(ui, i, self.player.track == i, tip).clicked() {
|
||||
self.player.set_track(i);
|
||||
}
|
||||
}
|
||||
ui.add_space(6.0);
|
||||
// volume, retenu dans launcher.ini
|
||||
ui.spacing_mut().slider_width = 90.0;
|
||||
let vol = ui
|
||||
.add(egui::Slider::new(&mut self.cfg.music_volume, 0..=100).show_value(false))
|
||||
.on_hover_text(format!("{} {} %", if en { "Volume" } else { "Volume :" }, self.cfg.music_volume));
|
||||
if vol.changed() {
|
||||
self.player.set_volume(self.cfg.music_volume);
|
||||
}
|
||||
ui.add_space(6.0);
|
||||
// couper aussi tout de suite, et reprendre si on décoche
|
||||
if ui
|
||||
.checkbox(&mut self.cfg.music_mute, if en { "Mute" } else { "Muet" })
|
||||
.on_hover_text(if en {
|
||||
"Stops the music now and at the next launches"
|
||||
} else {
|
||||
"Coupe la musique maintenant et aux prochains démarrages"
|
||||
})
|
||||
.changed()
|
||||
{
|
||||
if self.cfg.music_mute {
|
||||
self.player.pause();
|
||||
} else {
|
||||
self.player.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn log_view(&mut self, ui: &mut egui::Ui) {
|
||||
|
||||
@@ -19,6 +19,8 @@ pub struct Mod {
|
||||
pub hd_sprites_complete: bool,
|
||||
/// modèle Upscayl du pack (mod.ini model=, sinon déduit du nom hd_upscayl[_modèle])
|
||||
pub model: Option<String>,
|
||||
/// barre d'actions en HD (hd/PANEL1.png) : absente des packs créés avant qu'elle soit prise en charge
|
||||
pub has_panel: bool,
|
||||
pub files: usize,
|
||||
}
|
||||
|
||||
@@ -108,6 +110,7 @@ pub fn list(mods_dir: &Path) -> Vec<Mod> {
|
||||
hd_sprites_complete: count_png(&path.join("hd").join("SHEETS")) > 0
|
||||
&& count_png(&path.join("hd").join("SPRITES")) >= SPR_FILES,
|
||||
model: if model.is_empty() { model_from_id(&id) } else { Some(model) },
|
||||
has_panel: path.join("hd").join("PANEL1.png").is_file(),
|
||||
files: count_files(&path.join("files")),
|
||||
id,
|
||||
path,
|
||||
@@ -268,6 +271,25 @@ pub fn pack_id(model: &str) -> String {
|
||||
if model == DEFAULT_MODEL { "hd_upscayl".into() } else { format!("hd_upscayl_{model}") }
|
||||
}
|
||||
|
||||
/// dossier du pack composé (un modèle par partie)
|
||||
pub const MIXED_PACK: &str = "hd_perso";
|
||||
|
||||
/// mod.ini d'un pack composé, réécrit à chaque création : pas de clé model= (Réparer et « + sprites » ne savent
|
||||
/// pas quel modèle reprendre), les modèles de chaque partie sont dans la description
|
||||
pub fn write_mod_ini_mixed(mod_dir: &Path, parts: &str) {
|
||||
let _ = std::fs::create_dir_all(mod_dir);
|
||||
let _ = std::fs::write(
|
||||
mod_dir.join("mod.ini"),
|
||||
format!(
|
||||
"[mod]
|
||||
name=Pack HD composé (Upscayl)
|
||||
author=créé par le launcher
|
||||
description=Agrandi ×4 avec Upscayl, un modèle par partie : {parts}
|
||||
"
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// écrit mod.ini s'il n'existe pas encore
|
||||
pub fn write_mod_ini(mod_dir: &Path, model: &str) {
|
||||
let p = mod_dir.join("mod.ini");
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
//! Musique du launcher : « Double Trouble » (VF et VUS, créées avec Suno par LinkAtPlug), jouée en boucle par
|
||||
//! le lecteur MCI de Windows (winmm.dll, décodage MP3 fourni par le système) : aucune dépendance de plus.
|
||||
//! Les MP3 sont embarqués dans l'exécutable et copiés au premier besoin dans %APPDATA%\DoubleTroubleRecomp\music.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[link(name = "winmm")]
|
||||
extern "system" {
|
||||
fn mciSendStringW(command: *const u16, ret: *mut u16, ret_len: u32, hwnd: isize) -> u32;
|
||||
}
|
||||
|
||||
/// envoie une commande MCI ; 0 = réussite
|
||||
fn mci(cmd: &str) -> u32 {
|
||||
let w: Vec<u16> = cmd.encode_utf16().chain(std::iter::once(0)).collect();
|
||||
// SAFETY : chaîne UTF-16 terminée par 0, pas de tampon de retour
|
||||
unsafe { mciSendStringW(w.as_ptr(), std::ptr::null_mut(), 0, 0) }
|
||||
}
|
||||
|
||||
const ALIAS: &str = "dtr_music";
|
||||
|
||||
/// (étiquette, nom de fichier, contenu) : 0 = VF, 1 = VUS
|
||||
pub const TRACKS: [(&str, &str, &[u8]); 2] = [
|
||||
("VF", "double-trouble-vf.mp3", include_bytes!("../assets/music/double-trouble-vf.mp3")),
|
||||
("VUS", "double-trouble-vus.mp3", include_bytes!("../assets/music/double-trouble-vus.mp3")),
|
||||
];
|
||||
|
||||
pub struct Player {
|
||||
pub track: usize,
|
||||
pub playing: bool,
|
||||
/// volume en %, 0 à 100
|
||||
pub volume: u32,
|
||||
open: bool,
|
||||
}
|
||||
|
||||
impl Player {
|
||||
pub fn new(track: usize, volume: u32) -> Self {
|
||||
Self { track: track.min(TRACKS.len() - 1), playing: false, volume: volume.min(100), open: false }
|
||||
}
|
||||
|
||||
/// MCI compte de 0 à 1000
|
||||
pub fn set_volume(&mut self, volume: u32) {
|
||||
self.volume = volume.min(100);
|
||||
if self.open {
|
||||
mci(&format!("setaudio {ALIAS} volume to {}", self.volume * 10));
|
||||
}
|
||||
}
|
||||
|
||||
/// copie du MP3 sur le disque (MCI lit un fichier), refaite si la taille ne correspond pas
|
||||
fn file(&self) -> Option<PathBuf> {
|
||||
let (_, name, data) = TRACKS[self.track];
|
||||
let dir = PathBuf::from(std::env::var_os("APPDATA")?).join("DoubleTroubleRecomp").join("music");
|
||||
let path = dir.join(name);
|
||||
if std::fs::metadata(&path).map(|m| m.len() as usize) .ok() != Some(data.len()) {
|
||||
std::fs::create_dir_all(&dir).ok()?;
|
||||
std::fs::write(&path, data).ok()?;
|
||||
}
|
||||
Some(path)
|
||||
}
|
||||
|
||||
fn ensure_open(&mut self) -> bool {
|
||||
if self.open {
|
||||
return true;
|
||||
}
|
||||
let Some(path) = self.file() else { return false };
|
||||
mci(&format!("close {ALIAS}"));
|
||||
self.open = mci(&format!("open \"{}\" type mpegvideo alias {ALIAS}", path.display())) == 0;
|
||||
if self.open {
|
||||
mci(&format!("setaudio {ALIAS} volume to {}", self.volume * 10));
|
||||
}
|
||||
self.open
|
||||
}
|
||||
|
||||
/// lecture en boucle, reprise là où la pause l'a laissée
|
||||
pub fn play(&mut self) {
|
||||
if self.ensure_open() {
|
||||
self.playing = mci(&format!("play {ALIAS} repeat")) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pause(&mut self) {
|
||||
if self.open {
|
||||
mci(&format!("pause {ALIAS}"));
|
||||
}
|
||||
self.playing = false;
|
||||
}
|
||||
|
||||
pub fn toggle(&mut self) {
|
||||
if self.playing {
|
||||
self.pause()
|
||||
} else {
|
||||
self.play()
|
||||
}
|
||||
}
|
||||
|
||||
/// change de version ; continue de jouer si la musique jouait
|
||||
pub fn set_track(&mut self, track: usize) {
|
||||
if track == self.track || track >= TRACKS.len() {
|
||||
return;
|
||||
}
|
||||
let was = self.playing;
|
||||
self.close();
|
||||
self.track = track;
|
||||
if was {
|
||||
self.play();
|
||||
}
|
||||
}
|
||||
|
||||
fn close(&mut self) {
|
||||
if self.open {
|
||||
mci(&format!("close {ALIAS}"));
|
||||
self.open = false;
|
||||
}
|
||||
self.playing = false;
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Player {
|
||||
fn drop(&mut self) {
|
||||
self.close();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user