changed the save titles in the history list

This commit is contained in:
Faraphel 2023-03-09 17:22:27 +01:00
parent d14352d28e
commit b136ddbf62
3 changed files with 13 additions and 9 deletions

View file

@ -15,12 +15,8 @@ Label.default_kwargs["font_name"] = "Century Gothic" # NOQA: Label à un "defau
# Create a new window # Create a new window
window = GameWindow(resizable=True, vsync=True, caption="Bataille Navale") window = GameWindow(resizable=True, vsync=True, caption="Bataille Navale")
try: try: window.set_icon(pyglet.image.load("./assets/image/icon/icon.png"))
window.set_icon( except: pass # NOQA E722
pyglet.image.load("./assets/image/icon/icon.png")
)
except:
pass
window.set_minimum_size(720, 480) window.set_minimum_size(720, 480)
window.add_scene(MainMenu) window.add_scene(MainMenu)

View file

@ -230,7 +230,6 @@ class Game(BaseGame):
return path_history / ( return path_history / (
datetime.now().strftime("%Y-%m-%d %H-%M-%S") + datetime.now().strftime("%Y-%m-%d %H-%M-%S") +
self.get_save_suffix() + self.get_save_suffix() +
f" - Contre {self.name_enemy}" +
".bn-history" ".bn-history"
) )

View file

@ -1,3 +1,4 @@
import json
import math import math
from pathlib import Path from pathlib import Path
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
@ -6,7 +7,7 @@ from source.gui.position import vw, vh, top, vh_full, vw_full
from source.path import path_history from source.path import path_history
from source.gui import widget, texture from source.gui import widget, texture
from source.gui.scene.abc import Scene from source.gui.scene.abc import Scene
from source.utils import path_ctime_str
if TYPE_CHECKING: if TYPE_CHECKING:
from source.gui.window import Window from source.gui.window import Window
@ -54,12 +55,20 @@ class HistoryMenu(Scene):
) )
for i, path in enumerate(paths[page*self.PAGE_SIZE:(page+1)*self.PAGE_SIZE]): for i, path in enumerate(paths[page*self.PAGE_SIZE:(page+1)*self.PAGE_SIZE]):
with open(path, "r", encoding="utf-8") as file:
data = json.load(file)
title = (
f"{data['name_ally']} VS. {data['name_enemy']} "
f"({'Gagné' if data['my_turn'] else 'Perdu'}) "
f"- {path_ctime_str(path)}"
)
button = self.add_widget( button = self.add_widget(
widget.Button, widget.Button,
x=25*vw, y=top((25 + (i*9))*vh), width=50*vw, height=8*vh, x=25*vw, y=top((25 + (i*9))*vh), width=50*vw, height=8*vh,
label_text=path.stem, label_text=title,
style=texture.Button.Style1 style=texture.Button.Style1
) )