habit game fix launching with no puzzles started
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
(#when debug
|
||||
(debugLayer.clear)
|
||||
|
||||
(when model.rewardFiles
|
||||
(doFor s rewardSprites
|
||||
null
|
||||
// Uncomment for debugging piece rotation:
|
||||
@@ -48,8 +49,9 @@
|
||||
**(let [matchZones [(matchZoneLeft s) (matchZoneRight s)(matchZoneUp s)(matchZoneDown s)]]
|
||||
(doFor z matchZones
|
||||
(unless z.isEmpty
|
||||
(debugLayer.drawFlxRect z FlxColor.RED))))))
|
||||
(debugLayer.drawFlxRect z FlxColor.RED)))))))
|
||||
|
||||
(when model.rewardFiles
|
||||
(let [zoom pieceCamera.zoom
|
||||
scroll (pieceCamera.scroll.copyTo)]
|
||||
(pieceCamera.updateScrollWheelZoom elapsed 5)
|
||||
@@ -65,6 +67,13 @@
|
||||
(entryWindow.hide)
|
||||
(entryWindow.show))))
|
||||
|
||||
(when (and FlxG.keys.justPressed.SPACE !entryNameText)
|
||||
(defAndCall method toggleBackgroundColor
|
||||
(set save.data.backgroundIndex #{(save.data.backgroundIndex + 1) % backgroundOptions.length;}#)
|
||||
(save.flush)
|
||||
// setModel so the entry text gets remade in inverted/lightened colors when necessary
|
||||
(refreshModel)))
|
||||
|
||||
(#when debug
|
||||
(when FlxG.keys.justPressed.SEMICOLON
|
||||
(set pieceCamera.zoom 1))
|
||||
@@ -72,7 +81,7 @@
|
||||
(set save.data.storedPositions (new Map<Int,FlxPoint>))
|
||||
(set save.data.storedAngles (new Map<Int,Float>))
|
||||
(set save.data.storedOrigins (new Map<Int,FlxPoint>))
|
||||
(save.flush)))
|
||||
(save.flush))))
|
||||
|
||||
(when FlxG.keys.justPressed.DELETE
|
||||
(Sys.exit 0))
|
||||
@@ -87,12 +96,7 @@
|
||||
(dictSet (the Map<Int,FlxPoint> save.data.storedOrigins) (dictGet indexMap s) s.origin))
|
||||
(save.flush)))
|
||||
|
||||
(when (and FlxG.keys.justPressed.SPACE !entryNameText)
|
||||
(defAndCall method toggleBackgroundColor
|
||||
(set save.data.backgroundIndex #{(save.data.backgroundIndex + 1) % backgroundOptions.length;}#)
|
||||
(save.flush)
|
||||
// setModel so the entry text gets remade in inverted/lightened colors when necessary
|
||||
(refreshModel)))
|
||||
|
||||
|
||||
(method startAdding [:EntryType type]
|
||||
(set typeAdding type)
|
||||
@@ -180,6 +184,8 @@
|
||||
// Find, load, and add the current reward image as big as possible:
|
||||
(unless currentRewardFile
|
||||
(set currentRewardFile (nth m.rewardFiles 0))
|
||||
|
||||
(if m.rewardFiles
|
||||
(while (> p .startingPoints (nth m.rewardFiles i))
|
||||
(set rewardFileIndex i)
|
||||
(set currentRewardFile (nth m.rewardFiles i))
|
||||
@@ -191,8 +197,59 @@
|
||||
nextStartingPoints (+ lastStartingPoints (Math.ceil (/ TOTAL_PIECES piecesPerPoint)))]
|
||||
(when (> p nextStartingPoints)
|
||||
(set puzzleUnlocked nextStartingPoints))
|
||||
(break)))))
|
||||
(break))))
|
||||
(set puzzleUnlocked 0)))
|
||||
|
||||
(when m.rewardFiles
|
||||
(makeRewardSprites m p currentRewardFile))
|
||||
|
||||
(localVar &mut windowWasShown true)
|
||||
(when entryWindow
|
||||
(set windowWasShown (entryWindow.isShown))
|
||||
(entryWindow.hide))
|
||||
(set entryWindow (new SimpleWindow "" (FlxColor.fromRGBFloat 0 0 0 0.5) FlxColor.WHITE 0.9 0.9))
|
||||
(set entryWindow.cameras [uiCamera])
|
||||
(set entryWindow.textColor FlxColor.LIME)
|
||||
(when m.rewardFiles
|
||||
(_makeText "Puzzle #$(+ 1 rewardFileIndex) / ${model.rewardFiles.length}" (max 0 (- TOTAL_PIECES (* currentRewardFile.piecesPerPoint (- p currentRewardFile.startingPoints))))))
|
||||
(set entryWindow.textColor FlxColor.ORANGE)
|
||||
(map (m.activeDailyEntries) makeText)
|
||||
(set entryWindow.textColor FlxColor.GREEN)
|
||||
(map (m.activeMonthlyEntries) makeText)
|
||||
(set entryWindow.textColor FlxColor.BLUE)
|
||||
(map (m.activeIntervalEntries) makeText)
|
||||
(set entryWindow.textColor FlxColor.WHITE)
|
||||
(map (m.activeBonusEntries) makeText)
|
||||
(set entryWindow.textColor FlxColor.YELLOW)
|
||||
(map (m.activeTodoEntries) makeText)
|
||||
(set entryWindow.textColor FlxColor.GRAY)
|
||||
(when m.rewardFiles
|
||||
(_makeText "[SPACE] Cycle background color" 0))
|
||||
(when windowWasShown
|
||||
(entryWindow.show))
|
||||
|
||||
(when !(= puzzleUnlocked -1)
|
||||
(startPuzzlePackChoice puzzleUnlocked)))
|
||||
|
||||
(unless debugLayer
|
||||
(set debugLayer (new DebugLayer))
|
||||
(set debugLayer.cameras [pieceCamera]))
|
||||
(remove debugLayer)
|
||||
(add debugLayer))
|
||||
|
||||
(method refreshModel [&opt m]
|
||||
(let [m (or m model)]
|
||||
(setModel m (nth m.rewardFiles rewardFileIndex))))
|
||||
|
||||
(prop &mut textY 0)
|
||||
|
||||
(prop :Array<FlxColor> backgroundOptions [
|
||||
FlxColor.BLACK
|
||||
FlxColor.WHITE
|
||||
FlxColor.GRAY
|
||||
])
|
||||
|
||||
(method makeRewardSprites [m p currentRewardFile]
|
||||
(set save (new FlxSave))
|
||||
(save.bind currentRewardFile.path)
|
||||
(unless save.data.storedPositions
|
||||
@@ -348,51 +405,7 @@
|
||||
(prop &mut lastTotalPoints -1)
|
||||
(set lastTotalPoints (m.totalPoints))
|
||||
|
||||
(pieceCamera.calculateScrollBounds rewardSprites uiCamera SCROLL_BOUND_MARGIN)
|
||||
|
||||
(localVar &mut windowWasShown true)
|
||||
(when entryWindow
|
||||
(set windowWasShown (entryWindow.isShown))
|
||||
(entryWindow.hide))
|
||||
(set entryWindow (new SimpleWindow "" (FlxColor.fromRGBFloat 0 0 0 0.5) FlxColor.WHITE 0.9 0.9))
|
||||
(set entryWindow.cameras [uiCamera])
|
||||
(set entryWindow.textColor FlxColor.LIME)
|
||||
(_makeText "Puzzle #$(+ 1 rewardFileIndex) / ${model.rewardFiles.length}" (max 0 (- TOTAL_PIECES (* currentRewardFile.piecesPerPoint (- p currentRewardFile.startingPoints)))))
|
||||
(set entryWindow.textColor FlxColor.ORANGE)
|
||||
(map (m.activeDailyEntries) makeText)
|
||||
(set entryWindow.textColor FlxColor.GREEN)
|
||||
(map (m.activeMonthlyEntries) makeText)
|
||||
(set entryWindow.textColor FlxColor.BLUE)
|
||||
(map (m.activeIntervalEntries) makeText)
|
||||
(set entryWindow.textColor FlxColor.WHITE)
|
||||
(map (m.activeBonusEntries) makeText)
|
||||
(set entryWindow.textColor FlxColor.YELLOW)
|
||||
(map (m.activeTodoEntries) makeText)
|
||||
(set entryWindow.textColor FlxColor.GRAY)
|
||||
(_makeText "[SPACE] Cycle background color" 0)
|
||||
(when windowWasShown
|
||||
(entryWindow.show))
|
||||
|
||||
(when !(= puzzleUnlocked -1)
|
||||
(startPuzzlePackChoice puzzleUnlocked)))
|
||||
|
||||
(unless debugLayer
|
||||
(set debugLayer (new DebugLayer))
|
||||
(set debugLayer.cameras [pieceCamera]))
|
||||
(remove debugLayer)
|
||||
(add debugLayer))
|
||||
|
||||
(method refreshModel [&opt m]
|
||||
(let [m (or m model)]
|
||||
(setModel m (nth m.rewardFiles rewardFileIndex))))
|
||||
|
||||
(prop &mut textY 0)
|
||||
|
||||
(prop :Array<FlxColor> backgroundOptions [
|
||||
FlxColor.BLACK
|
||||
FlxColor.WHITE
|
||||
FlxColor.GRAY
|
||||
])
|
||||
(pieceCamera.calculateScrollBounds rewardSprites uiCamera SCROLL_BOUND_MARGIN))
|
||||
|
||||
(method makeText [:Entry e]
|
||||
(let [label (HabitModel.activeLabel e)]
|
||||
|
Reference in New Issue
Block a user