Close #98: 30s refresh for habit puzzles

This commit is contained in:
2022-07-26 17:00:11 +00:00
parent eee25cfdf4
commit db99dbc939
2 changed files with 11 additions and 2 deletions

View File

@@ -84,6 +84,8 @@
(prop &mut :FlxExtendedSprite draggingSprite null) (prop &mut :FlxExtendedSprite draggingSprite null)
(prop &mut :FlxPoint draggingLastPos null) (prop &mut :FlxPoint draggingLastPos null)
// Main.hx sets off 99% of the app's logic by parsing the model file and calling setModel on startup and on a 30s loop:
(method setModel [m &opt :RewardFile currentRewardFile] (method setModel [m &opt :RewardFile currentRewardFile]
(set model m) (set model m)
(set shortcutHandler (new FlxKeyShortcutHandler)) (set shortcutHandler (new FlxKeyShortcutHandler))

View File

@@ -3,6 +3,7 @@ package;
import flixel.FlxG; import flixel.FlxG;
import flixel.FlxGame; import flixel.FlxGame;
import openfl.display.Sprite; import openfl.display.Sprite;
import flixel.util.FlxTimer;
class Main extends Sprite class Main extends Sprite
{ {
@@ -16,7 +17,13 @@ class Main extends Sprite
} else { } else {
"habits/default.txt"; "habits/default.txt";
}; };
t.setModel(new HabitModel(habitFile)); function reloadModel(_) {
t.model.save(); t.setModel(new HabitModel(habitFile));
t.model.save();
}
reloadModel(null);
new FlxTimer().start(30, reloadModel, 0);
} }
} }