diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.hx b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.hx index 92c88b3b..6c631656 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.hx +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.hx @@ -29,6 +29,7 @@ import HabitModel; import sys.FileSystem; import hx.strings.Strings; import datetime.DateTime; +import flixel.ui.FlxButton; using kiss_flixel.CameraTools; using kiss_flixel.GroupTools; import haxe.ds.Option; diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss index 7d382a72..a8b04cac 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss @@ -148,7 +148,8 @@ (set shortcutHandler (new FlxKeyShortcutHandler)) (let [p (m.totalPoints) - &mut i 0 ] + &mut i 0 + &mut puzzleUnlocked -1] // Find, load, and add the current reward image as big as possible: (unless currentRewardFile (set currentRewardFile (nth m.rewardFiles 0)) @@ -159,14 +160,9 @@ (when (>= ++i m.rewardFiles.length) (let [lastStartingPoints .startingPoints (nth m.rewardFiles --i) nextStartingPoints (+ lastStartingPoints TOTAL_PIECES)] - (if (> p nextStartingPoints) - { - // TODO give the player a puzzle pack choice using (availablePacks) - (m.addRewardFile .path (firstUnsolvedPuzzle m "puzzles/trentnelson") nextStartingPoints) - (setModel m) - (return) - } - (break)))))) + (when (> p nextStartingPoints) + (set puzzleUnlocked nextStartingPoints)) + (break))))) (set save (new FlxSave)) (save.bind currentRewardFile.path) @@ -321,7 +317,10 @@ (map (m.activeTodoEntries) makeText) (set _color FlxColor.GRAY) (_makeText "[SPACE] Cycle background color" 0) - (add entryTexts)) + (add entryTexts) + + (when !(= puzzleUnlocked -1) + (startPuzzlePackChoice puzzleUnlocked))) (doFor e (m.allEntries) (when (HabitModel.isActive e) @@ -473,4 +472,30 @@ (unless (contains collected piece) (collected.push piece) (recursivelyConnectedPieces piece collected)))) - collected) \ No newline at end of file + collected) + +(prop &mut :FlxGroup nextPuzzleChoiceGroup null) + +(method startPuzzlePackChoice [nextStartingPoints] + (unless nextPuzzleChoiceGroup + (set nextPuzzleChoiceGroup (new FlxGroup)) + (set nextPuzzleChoiceGroup.cameras [uiCamera]) + + // TODO position these aesthetically with a partly transparent background behind them + // like the habit ui window should also have + (let [x 0 &mut y 0] + (doFor pack (availablePacks model) + (let [text (new FlxText x y 0 "$(haxe.io.Path.withoutDirectory pack.path): ${pack.puzzlesDone}/${pack.puzzlesTotal}" textSize)] + // TODO not that color though + (set text.color FlxColor.LIME) + (nextPuzzleChoiceGroup.add text) + (whenLet [(Some np) pack.nextPuzzle] + (nextPuzzleChoiceGroup.add (new FlxButton (+ x text.width) y "CHOOSE" ->:Void { + (remove nextPuzzleChoiceGroup) + (set nextPuzzleChoiceGroup null) + (model.addRewardFile np.path nextStartingPoints) + (setModel model) + + })))) + (+= y textSize))) + (add nextPuzzleChoiceGroup)))