Splitting reset into pre and post reset.

pull/1/head
Ozbolt Menegatti 4 years ago
parent 4bac269257
commit 00827e7b0b

@ -21,13 +21,26 @@ class Model:
self.translation = None
self.sense = None
# choosing examples
self.chosen_examples = []
self.reset()
self.modal_reset()
def reset(self):
# do both resets at once
self.pre_reset()
self.post_reset()
def pre_reset(self):
# the reset before updating models
self.menu_target = None
self.modal_shown = False
def post_reset(self):
# the reset after updating the models
self.chosen_examples = []
def modal_reset(self):
self.modal = lambda: []

@ -7,18 +7,28 @@ class Update:
self.view = None
def update_model(self):
# any update resets menu_location, except if it explicitly defines it
# check if we need to reset the model
reset = False
for msg in self.message_queue:
if msg.reset():
self.model.reset()
reset = True
break
if reset:
self.model.pre_reset()
# check if we need to signal the data change
for msg in self.message_queue:
if msg.data_change():
screenful.changed()
break
# do update
for msg in self.message_queue:
msg.update_model(self.model)
if reset:
self.model.post_reset()
self.message_queue = []
self.view.view(self.model)

Loading…
Cancel
Save