重构布局系统并改进界面

This commit is contained in:
2025-08-03 03:57:21 +08:00
parent 445e15646b
commit 4beb42f615
5 changed files with 123 additions and 26 deletions

View File

@@ -4,10 +4,10 @@ import pathlib
import auxiliary as aux
import compositions as comps
import random
#from pprint import pprint as print # debug
class Apparatus():
"""反应器对象, 决策一个原子的不同记忆方式, 并反馈到布局"""
def __init__(self, screen, atom):
def __init__(self, screen, reactor, atom):
self.electron: pt.Electron = atom[0]
self.nucleon: pt.Nucleon = atom[1]
self.positron: dict = atom[2]
@@ -15,12 +15,12 @@ class Apparatus():
self.procession: typing.List[comps.Composition] = list()
if self.positron["is_new_activation"] == 1:
self.positron["is_new_activation"] = 0
self.procession.append(comps.registry["recognition"](screen, atom))
self.procession.append(comps.registry["recognition"](screen, reactor, atom))
return
for i in self.positron["testdata"].keys():
if i == "additional_inf":
continue
self.procession.append(comps.registry[i](screen, atom))
self.procession.append(comps.registry[i](screen, reactor, atom))
# self.procession.reverse()
random.shuffle(self.procession)
@@ -76,6 +76,7 @@ class Reactor():
self.current_atom: typing.Tuple[pt.Electron, pt.Nucleon, dict]
self.round_set = 0
self.current_atom = pt.Atom.placeholder()
#print(self.atoms_new)
def set_round(self, title, procession):
self.round_set = 1
@@ -90,11 +91,10 @@ class Reactor():
2: "新记忆模式",
3: "总复习模式"
}
processions = {
1: self.atoms_review,
2: self.atoms_new,
3: list(set(self.atoms_new + self.atoms_review))
3: (self.atoms_new + self.atoms_review)
}
ret = 1
if stage == 1 and len(processions[1]) == 0:
@@ -104,6 +104,12 @@ class Reactor():
return ret
def forward(self, step = 1):
"""
返回值规则:
1: 重定向至 failed
-1: 此轮已完成
0: 下一个记忆单元
"""
if self.index + step >= len(self.procession):
if len(self.failed) > 0:
self.procession = self.failed
@@ -118,7 +124,7 @@ class Reactor():
return -1 # 此轮已完成
self.index += step
self.current_atom = self.procession[self.index]
self.current_appar = Apparatus(self.screen, self.current_atom).iterator()
self.current_appar = Apparatus(self.screen, self, self.current_atom).iterator()
return 0
def save(self):