This commit is contained in:
2025-11-06 01:25:41 +08:00
parent b63813f84d
commit 1a53c53e38
10 changed files with 67 additions and 17 deletions

View File

@@ -5,7 +5,11 @@ from textual.containers import Center
from textual.screen import Screen
from enum import Enum, auto
from heurams.context import config_var
from heurams.kernel.reactor import *
import heurams.kernel.particles as pt
import heurams.kernel.puzzles as pz
from .. import shim
class AtomState(Enum):
FAILED = auto()
@@ -13,10 +17,13 @@ class AtomState(Enum):
class MemScreen(Screen):
BINDINGS = [
("q", "pop_screen", "返回"),
("p", "pop_screen", "上一个"),
("d", "toggle_dark", "改变色调"),
("q", "pop_screen", "返回主菜单"),
("v", "play_voice", "朗读"),
]
if config_var.get()["quick_pass"]:
BINDINGS.append(("k", "quick_pass", "跳过"))
def __init__(self, atoms: list):
super().__init__(name=None, id=None, classes=None)
@@ -24,11 +31,17 @@ class MemScreen(Screen):
self.phaser = Phaser(atoms)
self.procession: Procession = self.phaser.current_procession() # type: ignore
def current_widget(self):
self.fission = Fission(self.procession.current_atom, self.phaser.state)
puzzle: pz.BasePuzzle = next(self.fission.generate())
print(shim.puzzle2widget[puzzle])
return shim.puzzle2widget[puzzle](atom = self.procession.current_atom)
def compose(self) -> ComposeResult:
yield Header(show_clock=True)
with Center():
yield Static(f"当前进度: {self.procession.process()}/{self.procession.total_length()}")
yield Label()
self.mount(self.current_widget())
yield Button("重新学习此单元", id="re-recognize", variant="warning")
yield Footer()