Launcher : sauvegarde automatique (SAVEGM.99) et Rejouer sur l'emplacement 98
Le jeu écrit désormais sa sauvegarde automatique dans SAVEGM.99 et la partie des
rapports dans SAVEGM.98 (c47f74f). Le launcher suit :
- Rejouer copie la partie du rapport dans SAVEGM.98 (plus 99 : elle aurait écrasé
la sauvegarde automatique) et lance --charger 98 ; lit SAVEGM.98, ou SAVEGM.99
des premiers rapports.
- 98 et 99 restent hors de la liste des parties et de la renumérotation (test).
- Sauvegardes : ligne « Sauvegarde automatique » (lieu, date, Jouer) et case
[game] autosave. Reprendre ma partie : la sauvegarde automatique si elle est
plus récente que la dernière partie, et proposée dans la liste.
- GUIDE FR/EN et SETTINGS.en.md à jour.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c47f74f2e2
commit
d54b9b9dac
7 files changed
+161
-38
No files matched your search
@@ -371,6 +371,11 @@ It also lets you:
|
||||
- **open the folder**;
|
||||
- **play** a game: the yellow button starts the game straight on that save.
|
||||
|
||||
**Automatic save**: the game also saves by itself when leaving each location, in `SAVEGM.99`, apart
|
||||
from your games (it never replaces them). It shows at the top of the card, framed in yellow, with its
|
||||
**Play** button. **Resume my game** picks it when it is more recent than your last game. A box on the
|
||||
card (or F12, Game tab) turns it off. Slot `SAVEGM.98` is used by the bug reports' **Replay** button.
|
||||
|
||||
Loading at startup (that button and **Resume my game**) needs an engine that knows the `--charger`
|
||||
option: if the compiled game is older, the launcher says so; just rebuild it after updating the
|
||||
project.
|
||||
|
||||
@@ -380,6 +380,12 @@ Elle permet aussi de :
|
||||
- **ouvrir le dossier** ;
|
||||
- **jouer** une partie : le bouton jaune lance le jeu directement sur cette sauvegarde.
|
||||
|
||||
**Sauvegarde automatique** : le jeu sauvegarde aussi tout seul en quittant chaque lieu, dans
|
||||
`SAVEGM.99`, à part de vos parties (il ne les remplace jamais). Elle apparaît en haut de la carte,
|
||||
encadrée de jaune, avec son bouton **Jouer**. **Reprendre ma partie** la choisit quand elle est plus
|
||||
récente que votre dernière partie. Une case de la carte (ou F12, onglet Jeu) la désactive.
|
||||
L'emplacement `SAVEGM.98` sert au bouton **Rejouer** des rapports de bug.
|
||||
|
||||
Le chargement au démarrage (ce bouton et **Reprendre ma partie**) demande un moteur qui connaît
|
||||
l'option `--charger` : si le jeu compilé est plus ancien, le launcher le signale, et il suffit de le
|
||||
recompiler après la mise à jour du projet.
|
||||
|
||||
+15
-1
@@ -59,6 +59,9 @@ enabled=1
|
||||
dir=
|
||||
disabled=
|
||||
|
||||
[game]
|
||||
autosave=1
|
||||
|
||||
[debug]
|
||||
crash_report=1
|
||||
```
|
||||
@@ -117,6 +120,17 @@ Mods are read at startup: a change to `[mods]` takes effect on the next launch.
|
||||
`hd_sprites` and `hd_panel`, however, apply immediately from the F12 menu; the F10 key toggles `hd_pack` during play, with a
|
||||
fade. The mod format is described in [MODS.en.md](MODS.en.md).
|
||||
|
||||
### `[game]`
|
||||
|
||||
| Key | Values | Default | Effect |
|
||||
|---|---|---|---|
|
||||
| `autosave` | `0` / `1` | `1` | Automatic save at each change of location, just before leaving the room (F12 menu, Jeu tab: « Sauvegarde automatique »; launcher: **Saved games** card) |
|
||||
|
||||
The automatic save goes to `SAVEGM.99`, in the saves folder. It uses the game's format and goes through a temporary file, so a crash can't leave it half written. It isn't counted in `NOFILES.DTA`: the game's Load panel doesn't show it, and it replaces none of the player's games. To load it:
|
||||
|
||||
- during play: F12 menu, Jeu tab, « Charger la sauvegarde auto ». The line shows the saved location. The game leaves the current location as if through an exit and resumes the saved game;
|
||||
- at startup: `--charger 99` (the launcher's **Play** button on the automatic save, or **Resume my game** when it is the most recent).
|
||||
|
||||
### `[debug]`
|
||||
|
||||
| Key | Values | Default | Effect |
|
||||
@@ -149,7 +163,7 @@ Folder contents:
|
||||
| `rapport.txt` | Kind, comment, date and version, then:<br>- the place: location, scrolling, Bud's position, mouse, the location's clickable areas;<br>- the display settings;<br>- the active mods |
|
||||
| `jeu.bmp` | Game picture, 320 × 200, as it was before the menu opened |
|
||||
| `ecran.bmp` | Screenshot of the window, HD backgrounds and sprites included. Halved beyond 2560 pixels wide |
|
||||
| `SAVEGM.99` | The game at that moment, in the game's save format. To get back to the bug: copy it into the saves folder, then start with `--charger 99` (the launcher's **Replay** button does both) |
|
||||
| `SAVEGM.98` | The game at that moment, in the game's save format (98, so as not to overwrite the automatic save). To get back to the bug: copy it into the saves folder, then start with `--charger 98` (the launcher's **Replay** button does both) |
|
||||
| `settings.ini` | Settings at the time of the report |
|
||||
| `memoire.bin` | Game variables (128 KB), for analysis |
|
||||
| `plantage.dmp` | Crash only: Windows minidump |
|
||||
|
||||
+91
-21
@@ -999,7 +999,7 @@ impl App {
|
||||
log: Vec::new(),
|
||||
show_log: false,
|
||||
config_open: None,
|
||||
saves: saves::Listing { saves: Vec::new(), last_used: 0, backups: Vec::new() },
|
||||
saves: saves::Listing { saves: Vec::new(), auto: None, last_used: 0, backups: Vec::new() },
|
||||
save_confirm: None,
|
||||
restore_confirm: None,
|
||||
save_msg: None,
|
||||
@@ -1794,6 +1794,8 @@ impl App {
|
||||
.map(|s| (s.slot, s.location, s.modified.map(|m| stamp(m, false)).unwrap_or_default()))
|
||||
.collect();
|
||||
let thumbs: Vec<Option<egui::TextureHandle>> = rows.iter().map(|r| self.thumb(r.1)).collect();
|
||||
let auto = self.saves.auto.as_ref().map(|a| (a.location, a.modified.map(|m| stamp(m, false)).unwrap_or_default()));
|
||||
let auto_tex = auto.as_ref().and_then(|a| self.thumb(a.0));
|
||||
let last = self.saves.last_used;
|
||||
let backups = self.saves.backups.clone();
|
||||
let confirm = self.save_confirm;
|
||||
@@ -1803,10 +1805,40 @@ impl App {
|
||||
let mut act: Option<SaveAct> = None;
|
||||
card(ui, |ui| {
|
||||
title(ui, tr("Sauvegardes", "Saved games"));
|
||||
if rows.is_empty() {
|
||||
if rows.is_empty() && auto.is_none() {
|
||||
ui.label(RichText::new(tr("Aucune sauvegarde pour l'instant.", "No saved game yet.")).weak());
|
||||
}
|
||||
ui.add_enabled_ui(!running, |ui| {
|
||||
// sauvegarde automatique du jeu (SAVEGM.99) : à part des parties, ni supprimable ni renumérotée
|
||||
if let Some((loc, date)) = &auto {
|
||||
ui.horizontal(|ui| {
|
||||
let (r, _) = ui.allocate_exact_size(egui::vec2(96.0, 50.0), egui::Sense::hover());
|
||||
match &auto_tex {
|
||||
Some(t) => paint_cover(ui.painter(), r, t, 1.0, 0.0),
|
||||
None => {
|
||||
ui.painter().rect_filled(r, CornerRadius::ZERO, CARD_DARK);
|
||||
}
|
||||
}
|
||||
ui.painter().rect_stroke(r, CornerRadius::ZERO, Stroke::new(1.5, ACCENT), egui::StrokeKind::Inside);
|
||||
ui.vertical(|ui| {
|
||||
ui.label(RichText::new(tr("Sauvegarde automatique", "Automatic save")).strong().color(ACCENT));
|
||||
ui.label(RichText::new(format!("{} {loc} · {date}", tr("Lieu", "Location"))).weak());
|
||||
});
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
if can_play
|
||||
&& ui
|
||||
.add(egui::Button::new(RichText::new(tr("Jouer", "Play")).strong().color(Color32::BLACK)).fill(ACCENT))
|
||||
.on_hover_text(tr(
|
||||
"Reprend là où le jeu a sauvegardé tout seul, au dernier changement de lieu.",
|
||||
"Resumes where the game saved by itself, at the last change of location.",
|
||||
))
|
||||
.clicked()
|
||||
{
|
||||
act = Some(SaveAct::Play(saves::AUTO_SLOT));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
for ((slot, loc, date), tex) in rows.iter().zip(&thumbs) {
|
||||
ui.horizontal(|ui| {
|
||||
let (r, _) = ui.allocate_exact_size(egui::vec2(96.0, 50.0), egui::Sense::hover());
|
||||
@@ -1857,6 +1889,11 @@ impl App {
|
||||
act = Some(SaveAct::OpenFolder);
|
||||
}
|
||||
});
|
||||
ui.checkbox(&mut self.gs.autosave, tr("Sauvegarde automatique à chaque changement de lieu", "Automatic save at each change of location"))
|
||||
.on_hover_text(tr(
|
||||
"Le jeu sauvegarde tout seul en quittant chaque lieu, à part de vos parties (il ne les remplace jamais). Aussi dans F12, onglet Jeu.",
|
||||
"The game saves by itself when leaving each location, apart from your saves (it never replaces them). Also in F12, Game tab.",
|
||||
));
|
||||
if !backups.is_empty() {
|
||||
egui::CollapsingHeader::new(format!("{} ({})", tr("Copies de sécurité", "Backups"), backups.len()))
|
||||
.id_salt("backups")
|
||||
@@ -1898,11 +1935,11 @@ impl App {
|
||||
let en = self.cfg.lang == Lang::En;
|
||||
let tr = |fr: &'static str, e: &'static str| if en { e } else { fr };
|
||||
const SHOWN: usize = 5;
|
||||
let rows: Vec<(PathBuf, String, String, String, Option<u32>, bool)> = self
|
||||
let rows: Vec<(PathBuf, String, String, String, Option<u32>, Option<PathBuf>)> = self
|
||||
.reports
|
||||
.iter()
|
||||
.take(SHOWN)
|
||||
.map(|r| (r.path.clone(), r.date.clone(), r.kind.clone(), r.comment.clone(), r.location, r.save.is_some()))
|
||||
.map(|r| (r.path.clone(), r.date.clone(), r.kind.clone(), r.comment.clone(), r.location, r.save.clone()))
|
||||
.collect();
|
||||
let more = self.reports.len().saturating_sub(SHOWN);
|
||||
let thumbs: Vec<Option<egui::TextureHandle>> = rows.iter().map(|r| r.4.and_then(|l| self.thumb(l))).collect();
|
||||
@@ -1978,17 +2015,17 @@ impl App {
|
||||
{
|
||||
act = Some(Act::Zip(path.clone()));
|
||||
}
|
||||
if *has_save
|
||||
&& can_play
|
||||
&& ui
|
||||
if let (Some(save), true) = (has_save, can_play) {
|
||||
if ui
|
||||
.add(egui::Button::new(RichText::new(tr("Rejouer", "Replay")).strong().color(Color32::BLACK)).fill(ACCENT))
|
||||
.on_hover_text(tr(
|
||||
"Lance le jeu sur la partie enregistrée par le rapport, au moment du bug.",
|
||||
"Starts the game on the save stored by the report, at the moment of the bug.",
|
||||
))
|
||||
.clicked()
|
||||
{
|
||||
act = Some(Act::Replay(path.clone()));
|
||||
{
|
||||
act = Some(Act::Replay(save.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -2013,16 +2050,17 @@ impl App {
|
||||
let Some(a) = act else { return };
|
||||
match a {
|
||||
Act::Replay(path) => {
|
||||
// la partie du rapport va dans l'emplacement 99 des sauvegardes (caché de la liste), puis --charger 99
|
||||
// la partie du rapport va dans l'emplacement 98 des sauvegardes (réservé, caché de la liste ; le 99
|
||||
// est la sauvegarde automatique du jeu, à ne pas écraser), puis --charger 98
|
||||
let Some(dir) = self.saves_dir() else { return };
|
||||
let _ = std::fs::create_dir_all(&dir);
|
||||
let dst = dir.join(format!("SAVEGM.{}", reports::REPLAY_SLOT));
|
||||
match std::fs::copy(path.join("SAVEGM.99"), &dst) {
|
||||
let dst = dir.join(format!("SAVEGM.{}", saves::REPORT_SLOT));
|
||||
match std::fs::copy(&path, &dst) {
|
||||
Ok(_) => {
|
||||
self.report_msg = None;
|
||||
self.play_slot(Some(reports::REPLAY_SLOT));
|
||||
self.play_slot(Some(saves::REPORT_SLOT));
|
||||
}
|
||||
Err(e) => self.report_msg = Some((false, format!("SAVEGM.99 : {e}"))),
|
||||
Err(e) => self.report_msg = Some((false, format!("{} : {e}", path.display()))),
|
||||
}
|
||||
}
|
||||
Act::Zip(path) => {
|
||||
@@ -2170,14 +2208,35 @@ impl App {
|
||||
return None;
|
||||
}
|
||||
let s = &self.saves.saves;
|
||||
let auto = self.saves.auto.as_ref();
|
||||
let has = |n: u32| n != 0 && s.iter().any(|x| x.slot == n);
|
||||
if self.cfg.resume_slot == saves::AUTO_SLOT && auto.is_some() {
|
||||
return Some(saves::AUTO_SLOT);
|
||||
}
|
||||
if has(self.cfg.resume_slot) {
|
||||
return Some(self.cfg.resume_slot);
|
||||
}
|
||||
if has(self.saves.last_used) {
|
||||
return Some(self.saves.last_used);
|
||||
// « la dernière jouée » : la partie du joueur, sauf si la sauvegarde automatique est plus récente
|
||||
// (elle suit la partie lieu après lieu : c'est là qu'on s'est arrêté)
|
||||
let player = if has(self.saves.last_used) {
|
||||
s.iter().find(|x| x.slot == self.saves.last_used)
|
||||
} else {
|
||||
s.iter().max_by_key(|x| x.modified)
|
||||
};
|
||||
match (player, auto) {
|
||||
(Some(p), Some(a)) if a.modified > p.modified => Some(saves::AUTO_SLOT),
|
||||
(Some(p), _) => Some(p.slot),
|
||||
(None, Some(_)) => Some(saves::AUTO_SLOT),
|
||||
(None, None) => None,
|
||||
}
|
||||
s.iter().max_by_key(|x| x.modified).map(|x| x.slot)
|
||||
}
|
||||
|
||||
/// lieu d'une sauvegarde, emplacement réservé de la sauvegarde automatique compris
|
||||
fn save_location(&self, slot: u32) -> u32 {
|
||||
if slot == saves::AUTO_SLOT {
|
||||
return self.saves.auto.as_ref().map(|a| a.location).unwrap_or(0);
|
||||
}
|
||||
self.saves.saves.iter().find(|s| s.slot == slot).map(|s| s.location).unwrap_or(0)
|
||||
}
|
||||
|
||||
fn play(&mut self) {
|
||||
@@ -2767,7 +2826,7 @@ impl App {
|
||||
)).color(ACCENT).small());
|
||||
return;
|
||||
}
|
||||
if self.saves.saves.is_empty() {
|
||||
if self.saves.saves.is_empty() && self.saves.auto.is_none() {
|
||||
ui.label(RichText::new(tr("Aucune sauvegarde : la partie commencera depuis le début.", "No saved game: the game will start from the beginning.")).weak().small());
|
||||
return;
|
||||
}
|
||||
@@ -2775,13 +2834,18 @@ impl App {
|
||||
let name = |slot: u32, loc: u32| {
|
||||
if slot == 0 {
|
||||
tr("La dernière jouée", "The last one played").to_string()
|
||||
} else if slot == saves::AUTO_SLOT {
|
||||
format!("{} · {} {loc}", tr("Sauvegarde automatique", "Automatic save"), tr("lieu", "location"))
|
||||
} else if en {
|
||||
format!("Save {slot} · location {loc}")
|
||||
} else {
|
||||
format!("Partie {slot} · lieu {loc}")
|
||||
}
|
||||
};
|
||||
let rows: Vec<(u32, u32)> = self.saves.saves.iter().map(|s| (s.slot, s.location)).collect();
|
||||
let mut rows: Vec<(u32, u32)> = self.saves.saves.iter().map(|s| (s.slot, s.location)).collect();
|
||||
if let Some(a) = &self.saves.auto {
|
||||
rows.insert(0, (a.slot, a.location));
|
||||
}
|
||||
let target = self.resume_target();
|
||||
let target_loc = rows.iter().find(|r| Some(r.0) == target).map(|r| r.1);
|
||||
let tex = target_loc.and_then(|l| self.thumb(l));
|
||||
@@ -2891,8 +2955,14 @@ impl App {
|
||||
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(n), true, false) = (self.resume_target(), c.can_load, self.game_running) {
|
||||
let loc = self.saves.saves.iter().find(|s| s.slot == n).map(|s| s.location).unwrap_or(0);
|
||||
ui.label(RichText::new(if en { format!("Starts on save {n} (location {loc}).") } else { format!("Démarre sur la partie {n} (lieu {loc}).") }).color(ACCENT));
|
||||
let loc = self.save_location(n);
|
||||
let text = match (n == saves::AUTO_SLOT, en) {
|
||||
(true, false) => format!("Démarre sur la sauvegarde automatique (lieu {loc})."),
|
||||
(true, true) => format!("Starts on the automatic save (location {loc})."),
|
||||
(false, false) => format!("Démarre sur la partie {n} (lieu {loc})."),
|
||||
(false, true) => format!("Starts on save {n} (location {loc})."),
|
||||
};
|
||||
ui.label(RichText::new(text).color(ACCENT));
|
||||
} 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 {
|
||||
|
||||
@@ -12,13 +12,10 @@ pub struct Report {
|
||||
pub kind: String,
|
||||
pub comment: String,
|
||||
pub location: Option<u32>,
|
||||
/// la partie à cet instant (SAVEGM.99) : de quoi retomber sur le bug
|
||||
/// la partie à cet instant (SAVEGM.98 ; SAVEGM.99 dans les premiers rapports) : de quoi retomber sur le bug
|
||||
pub save: Option<PathBuf>,
|
||||
}
|
||||
|
||||
/// emplacement d'une sauvegarde de rapport dans le dossier des sauvegardes ; à part des parties du joueur
|
||||
pub const REPLAY_SLOT: u32 = 99;
|
||||
|
||||
pub fn dir() -> Option<PathBuf> {
|
||||
crate::settings::path().and_then(|p| p.parent().map(|d| d.join("rapports")))
|
||||
}
|
||||
@@ -53,13 +50,13 @@ pub fn list_in(d: &Path) -> Vec<Report> {
|
||||
let path = e.path();
|
||||
let text = std::fs::read_to_string(path.join("rapport.txt")).ok()?;
|
||||
let name = e.file_name().to_string_lossy().to_string();
|
||||
let save = path.join("SAVEGM.99");
|
||||
let save = ["SAVEGM.98", "SAVEGM.99"].iter().map(|n| path.join(n)).find(|p| p.is_file());
|
||||
Some(Report {
|
||||
date: pretty_date(&name),
|
||||
kind: field(&text, "Type").unwrap_or("?").to_string(),
|
||||
comment: field(&text, "Commentaire").filter(|c| *c != "(aucun)").unwrap_or("").to_string(),
|
||||
location: field(&text, "Lieu").and_then(|l| l.parse().ok()),
|
||||
save: save.is_file().then_some(save),
|
||||
save,
|
||||
path,
|
||||
})
|
||||
})
|
||||
@@ -120,7 +117,7 @@ mod tests {
|
||||
"Rapport de bug - DoubleTroubleRecomp\n\nType : Graphismes HD\nCommentaire : (aucun)\n\nOù\nLieu : 32\n",
|
||||
)
|
||||
.unwrap();
|
||||
std::fs::write(r.join("SAVEGM.99"), [0u8; 2000]).unwrap();
|
||||
std::fs::write(r.join("SAVEGM.98"), [0u8; 2000]).unwrap();
|
||||
let l = list_in(&base);
|
||||
assert_eq!(l.len(), 1);
|
||||
assert_eq!(l[0].date, "2026-12-05 13:45");
|
||||
|
||||
+35
-9
@@ -16,12 +16,19 @@ pub struct Save {
|
||||
|
||||
pub struct Listing {
|
||||
pub saves: Vec<Save>,
|
||||
/// sauvegarde automatique du jeu (SAVEGM.99, écrite à chaque changement de lieu)
|
||||
pub auto: Option<Save>,
|
||||
pub last_used: u32,
|
||||
pub backups: Vec<(String, PathBuf)>,
|
||||
}
|
||||
|
||||
const NOFILES: &str = "NOFILES.DTA";
|
||||
|
||||
/// emplacements réservés, hors des parties du joueur (ni comptés dans NOFILES.DTA, ni renumérotés) :
|
||||
/// 99 = sauvegarde automatique du jeu, 98 = partie d'un rapport de bug rejouée par le launcher
|
||||
pub const AUTO_SLOT: u32 = 99;
|
||||
pub const REPORT_SLOT: u32 = 98;
|
||||
|
||||
fn slot_of(name: &str) -> Option<u32> {
|
||||
let up = name.to_ascii_uppercase();
|
||||
up.strip_prefix("SAVEGM.")?.parse().ok()
|
||||
@@ -37,12 +44,12 @@ pub fn backups_dir(dir: &Path) -> PathBuf {
|
||||
|
||||
pub fn list(dir: &Path) -> Listing {
|
||||
let mut saves = Vec::new();
|
||||
let mut auto = None;
|
||||
if let Ok(rd) = std::fs::read_dir(dir) {
|
||||
for e in rd.flatten() {
|
||||
let name = e.file_name().to_string_lossy().to_string();
|
||||
let Some(slot) = slot_of(&name) else { continue };
|
||||
// 99 : sauvegarde d'un rapport de bug, rejouée par le launcher ; pas une partie du joueur
|
||||
if slot >= 99 {
|
||||
if slot >= REPORT_SLOT && slot != AUTO_SLOT {
|
||||
continue;
|
||||
}
|
||||
let data = std::fs::read(e.path()).unwrap_or_default();
|
||||
@@ -50,12 +57,12 @@ pub fn list(dir: &Path) -> Listing {
|
||||
.get(0x730..0x734)
|
||||
.map(|b| u32::from_le_bytes([b[0], b[1], b[2], b[3]]))
|
||||
.unwrap_or(0);
|
||||
saves.push(Save {
|
||||
slot,
|
||||
path: e.path(),
|
||||
location,
|
||||
modified: e.metadata().and_then(|m| m.modified()).ok(),
|
||||
});
|
||||
let save = Save { slot, path: e.path(), location, modified: e.metadata().and_then(|m| m.modified()).ok() };
|
||||
if slot == AUTO_SLOT {
|
||||
auto = Some(save);
|
||||
} else {
|
||||
saves.push(save);
|
||||
}
|
||||
}
|
||||
}
|
||||
saves.sort_by_key(|s| s.slot);
|
||||
@@ -69,7 +76,7 @@ pub fn list(dir: &Path) -> Listing {
|
||||
})
|
||||
.unwrap_or_default();
|
||||
backups.sort_by(|a, b| b.0.cmp(&a.0));
|
||||
Listing { saves, last_used, backups }
|
||||
Listing { saves, auto, last_used, backups }
|
||||
}
|
||||
|
||||
/// fichiers du jeu présents dans `dir` (sauvegardes et NOFILES.DTA)
|
||||
@@ -168,6 +175,25 @@ mod tests {
|
||||
d
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reserved_slots_stay_apart() {
|
||||
let dir = std::env::temp_dir().join(format!("dtr-saves-auto-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join("SAVEGM.01"), save(3)).unwrap();
|
||||
std::fs::write(dir.join("SAVEGM.02"), save(9)).unwrap();
|
||||
std::fs::write(dir.join("SAVEGM.98"), save(32)).unwrap();
|
||||
std::fs::write(dir.join("SAVEGM.99"), save(15)).unwrap();
|
||||
let l = list(&dir);
|
||||
assert_eq!(l.saves.iter().map(|s| s.slot).collect::<Vec<_>>(), vec![1, 2]);
|
||||
assert_eq!(l.auto.as_ref().map(|a| a.location), Some(15));
|
||||
// supprimer une partie ne touche ni à la sauvegarde automatique ni à celle d'un rapport
|
||||
delete(&dir, 1).unwrap();
|
||||
assert!(dir.join("SAVEGM.98").is_file() && dir.join("SAVEGM.99").is_file());
|
||||
assert_eq!(list(&dir).auto.map(|a| a.location), Some(15));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn delete_renumbers_and_keeps_copy() {
|
||||
let dir = std::env::temp_dir().join(format!("dtr-saves-{}", std::process::id()));
|
||||
|
||||
@@ -29,6 +29,8 @@ pub struct GameSettings {
|
||||
pub hotspots: bool,
|
||||
/// [debug] rapport de bug écrit tout seul si le jeu plante
|
||||
pub crash_report: bool,
|
||||
/// [game] sauvegarde automatique à chaque changement de lieu (SAVEGM.99)
|
||||
pub autosave: bool,
|
||||
pub vol: [u32; 4],
|
||||
pub mods_enabled: bool,
|
||||
/// dossier des mods ; vide = détection automatique par le jeu
|
||||
@@ -55,6 +57,7 @@ impl Default for GameSettings {
|
||||
wide_fill: true,
|
||||
hotspots: true,
|
||||
crash_report: true,
|
||||
autosave: true,
|
||||
vol: [100; 4],
|
||||
mods_enabled: true,
|
||||
mods_dir: String::new(),
|
||||
@@ -131,6 +134,7 @@ impl GameSettings {
|
||||
("display", "hd_panel") => s.hd_panel = parse_bool(v).unwrap_or(s.hd_panel),
|
||||
("display", "wide_fill") => s.wide_fill = parse_bool(v).unwrap_or(s.wide_fill),
|
||||
("display", "hotspots") => s.hotspots = parse_bool(v).unwrap_or(s.hotspots),
|
||||
("game", "autosave") => s.autosave = parse_bool(v).unwrap_or(s.autosave),
|
||||
("debug", "crash_report") => s.crash_report = parse_bool(v).unwrap_or(s.crash_report),
|
||||
("mods", "enabled") => s.mods_enabled = parse_bool(v).unwrap_or(s.mods_enabled),
|
||||
("mods", "dir") => s.mods_dir = v.to_string(),
|
||||
@@ -168,6 +172,7 @@ impl GameSettings {
|
||||
for (i, k) in VOLUMES.iter().enumerate() {
|
||||
e.push(("audio", k, self.vol[i].to_string()));
|
||||
}
|
||||
e.push(("game", "autosave", b(self.autosave)));
|
||||
e.push(("debug", "crash_report", b(self.crash_report)));
|
||||
e.push(("mods", "enabled", b(self.mods_enabled)));
|
||||
e.push(("mods", "dir", self.mods_dir.clone()));
|
||||
|
||||
Reference in new issue
Block a user