From fa2fa22de24158d958ed675371066bd9fc343449 Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Mon, 29 Aug 2022 19:05:55 +0000 Subject: [PATCH] make PuzzlePack toStringable --- .../source/HabitModel.hx | 7 ------ .../source/HabitState.kiss | 6 ++--- .../source/PuzzlePack.hx | 10 ++++++++ .../{PuzzlePacks.kiss => PuzzlePack.kiss} | 25 ++++++++++++------- 4 files changed, 28 insertions(+), 20 deletions(-) create mode 100644 projects/flixel-desktop-habit-puzzle-game/source/PuzzlePack.hx rename projects/flixel-desktop-habit-puzzle-game/source/{PuzzlePacks.kiss => PuzzlePack.kiss} (70%) diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.hx b/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.hx index 5eb97ca8..27753520 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.hx +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitModel.hx @@ -44,12 +44,5 @@ typedef Puzzle = { outOf:Int } -typedef PuzzlePack = { - path:String, - nextPuzzle:Option, - puzzlesDone:Int, - puzzlesTotal:Int -}; - @:build(kiss.Kiss.build()) class HabitModel {} diff --git a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss index 57cf08c6..b7623ce7 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss +++ b/projects/flixel-desktop-habit-puzzle-game/source/HabitState.kiss @@ -4,8 +4,6 @@ (prop &mut :FlxCamera pieceCamera) (prop &mut :FlxCamera uiCamera) -(load "PuzzlePacks.kiss") - (defAlias &ident textSize SimpleWindow.textSize) (method &override :Void create [] @@ -685,8 +683,8 @@ // 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)] + (doFor pack (PuzzlePack.availablePacks model) + (let [text (new FlxText x y 0 "$pack" textSize)] // TODO not that color though (set text.color FlxColor.LIME) (nextPuzzleChoiceGroup.add text) diff --git a/projects/flixel-desktop-habit-puzzle-game/source/PuzzlePack.hx b/projects/flixel-desktop-habit-puzzle-game/source/PuzzlePack.hx new file mode 100644 index 00000000..97351daf --- /dev/null +++ b/projects/flixel-desktop-habit-puzzle-game/source/PuzzlePack.hx @@ -0,0 +1,10 @@ +package; + +import kiss.Prelude; +import kiss.List; +import haxe.ds.Option; +import sys.FileSystem; +import HabitModel; + +@:build(kiss.Kiss.build()) +class PuzzlePack { } \ No newline at end of file diff --git a/projects/flixel-desktop-habit-puzzle-game/source/PuzzlePacks.kiss b/projects/flixel-desktop-habit-puzzle-game/source/PuzzlePack.kiss similarity index 70% rename from projects/flixel-desktop-habit-puzzle-game/source/PuzzlePacks.kiss rename to projects/flixel-desktop-habit-puzzle-game/source/PuzzlePack.kiss index e3f66fb5..372da00c 100644 --- a/projects/flixel-desktop-habit-puzzle-game/source/PuzzlePacks.kiss +++ b/projects/flixel-desktop-habit-puzzle-game/source/PuzzlePack.kiss @@ -1,3 +1,8 @@ +(defNew [&prop :String path + &prop :Option nextPuzzle + &prop :Int puzzlesDone + &prop :Int puzzlesTotal]) + (var puzzleSearchGlobs ["puzzles"]) // TODO add the itch io client folder to search paths- it's // C:\Users\$(userHome)\AppData\Roaming\itch\apps\ on windows @@ -14,14 +19,13 @@ (doFor packDir packDirs (let [fop (firstUnsolvedPuzzle model packDir)] (packs.push - (object - nextPuzzle - (if fop.path - (Some fop) - None) - path packDir - puzzlesDone fop.index - puzzlesTotal fop.outOf))))))) + (new PuzzlePack + packDir + (if fop.path + (Some fop) + None) + fop.index + fop.outOf))))))) packs)) (function :Puzzle firstUnsolvedPuzzle [:HabitModel model :String dir] @@ -34,4 +38,7 @@ (-= puzzleCount 1) (unless (rewardFilePaths.contains fullPath) (return (object path fullPath index idx outOf images.length)))))) - (object path null index images.length outOf images.length))) \ No newline at end of file + (object path null index images.length outOf images.length))) + +(method toString [] + "$(haxe.io.Path.withoutDirectory path): ${puzzlesDone}/${puzzlesTotal}") \ No newline at end of file