make PuzzlePack toStringable

This commit is contained in:
2022-08-29 19:05:55 +00:00
parent c617c1510d
commit fa2fa22de2
4 changed files with 28 additions and 20 deletions

View File

@@ -44,12 +44,5 @@ typedef Puzzle = {
outOf:Int outOf:Int
} }
typedef PuzzlePack = {
path:String,
nextPuzzle:Option<Puzzle>,
puzzlesDone:Int,
puzzlesTotal:Int
};
@:build(kiss.Kiss.build()) @:build(kiss.Kiss.build())
class HabitModel {} class HabitModel {}

View File

@@ -4,8 +4,6 @@
(prop &mut :FlxCamera pieceCamera) (prop &mut :FlxCamera pieceCamera)
(prop &mut :FlxCamera uiCamera) (prop &mut :FlxCamera uiCamera)
(load "PuzzlePacks.kiss")
(defAlias &ident textSize SimpleWindow.textSize) (defAlias &ident textSize SimpleWindow.textSize)
(method &override :Void create [] (method &override :Void create []
@@ -685,8 +683,8 @@
// TODO position these aesthetically with a partly transparent background behind them // TODO position these aesthetically with a partly transparent background behind them
// like the habit ui window should also have // like the habit ui window should also have
(let [x 0 &mut y 0] (let [x 0 &mut y 0]
(doFor pack (availablePacks model) (doFor pack (PuzzlePack.availablePacks model)
(let [text (new FlxText x y 0 "$(haxe.io.Path.withoutDirectory pack.path): ${pack.puzzlesDone}/${pack.puzzlesTotal}" textSize)] (let [text (new FlxText x y 0 "$pack" textSize)]
// TODO not that color though // TODO not that color though
(set text.color FlxColor.LIME) (set text.color FlxColor.LIME)
(nextPuzzleChoiceGroup.add text) (nextPuzzleChoiceGroup.add text)

View File

@@ -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 { }

View File

@@ -1,3 +1,8 @@
(defNew [&prop :String path
&prop :Option<Puzzle> nextPuzzle
&prop :Int puzzlesDone
&prop :Int puzzlesTotal])
(var puzzleSearchGlobs ["puzzles"]) (var puzzleSearchGlobs ["puzzles"])
// TODO add the itch io client folder to search paths- it's // TODO add the itch io client folder to search paths- it's
// C:\Users\$(userHome)\AppData\Roaming\itch\apps\ on windows // C:\Users\$(userHome)\AppData\Roaming\itch\apps\ on windows
@@ -14,14 +19,13 @@
(doFor packDir packDirs (doFor packDir packDirs
(let [fop (firstUnsolvedPuzzle model packDir)] (let [fop (firstUnsolvedPuzzle model packDir)]
(packs.push (packs.push
(object (new PuzzlePack
nextPuzzle packDir
(if fop.path (if fop.path
(Some fop) (Some fop)
None) None)
path packDir fop.index
puzzlesDone fop.index fop.outOf)))))))
puzzlesTotal fop.outOf)))))))
packs)) packs))
(function :Puzzle firstUnsolvedPuzzle [:HabitModel model :String dir] (function :Puzzle firstUnsolvedPuzzle [:HabitModel model :String dir]
@@ -34,4 +38,7 @@
(-= puzzleCount 1) (-= puzzleCount 1)
(unless (rewardFilePaths.contains fullPath) (unless (rewardFilePaths.contains fullPath)
(return (object path fullPath index idx outOf images.length)))))) (return (object path fullPath index idx outOf images.length))))))
(object path null index images.length outOf images.length))) (object path null index images.length outOf images.length)))
(method toString []
"$(haxe.io.Path.withoutDirectory path): ${puzzlesDone}/${puzzlesTotal}")