Pause Movie timers
This commit is contained in:
@@ -30,16 +30,22 @@
|
|||||||
sh)
|
sh)
|
||||||
|
|
||||||
(method :Void pause []
|
(method :Void pause []
|
||||||
|
(FlxG.inputs.remove actionManager)
|
||||||
// TODO !!
|
// TODO !!
|
||||||
null)
|
null)
|
||||||
|
|
||||||
(method :Void resume []
|
(method :Void resume []
|
||||||
// TODO !!
|
// TODO !!
|
||||||
|
(FlxG.inputs.add actionManager)
|
||||||
null)
|
null)
|
||||||
|
|
||||||
(method :Void showPauseMenu [:Continuation resume]
|
(method :Void showPauseMenu [:Continuation resume]
|
||||||
// TODO
|
// TODO register escape to resume (and register escape to pause lol)
|
||||||
null)
|
(chooseString "PAUSED" ["Resume"]
|
||||||
|
->choice
|
||||||
|
(case choice
|
||||||
|
("Resume" (resume))
|
||||||
|
(never otherwise))))
|
||||||
|
|
||||||
(method :Void showSet [:FlxSprite setSprite :SceneTime time :ScenePerspective perspective :Appearance appearance :FlxCamera camera :Continuation cc]
|
(method :Void showSet [:FlxSprite setSprite :SceneTime time :ScenePerspective perspective :Appearance appearance :FlxCamera camera :Continuation cc]
|
||||||
(case appearance
|
(case appearance
|
||||||
|
@@ -14,6 +14,7 @@ import uuid.Uuid;
|
|||||||
import haxe.ds.Option;
|
import haxe.ds.Option;
|
||||||
import kiss_tools.JsonMap;
|
import kiss_tools.JsonMap;
|
||||||
import kiss_tools.JsonableArray;
|
import kiss_tools.JsonableArray;
|
||||||
|
import kiss_tools.TimerWithPause;
|
||||||
|
|
||||||
using kiss.FuzzyMapTools;
|
using kiss.FuzzyMapTools;
|
||||||
|
|
||||||
|
@@ -144,14 +144,15 @@
|
|||||||
|
|
||||||
(method pause []
|
(method pause []
|
||||||
(unless paused
|
(unless paused
|
||||||
// TODO pause all delays (which will require ditching haxe.Timer!!!)
|
(TimerWithPause.pause)
|
||||||
(set paused true)
|
(set paused true)
|
||||||
(director.pause)))
|
(director.pause)))
|
||||||
|
|
||||||
(method resume []
|
(method resume []
|
||||||
(when paused
|
(when paused
|
||||||
(set paused false)
|
(set paused false)
|
||||||
(director.resume)))
|
(director.resume)
|
||||||
|
(TimerWithPause.resume)))
|
||||||
|
|
||||||
(method resolvePosition [:Dynamic position]
|
(method resolvePosition [:Dynamic position]
|
||||||
(typeCase [position]
|
(typeCase [position]
|
||||||
@@ -194,10 +195,13 @@
|
|||||||
(shortcutHandler.start)
|
(shortcutHandler.start)
|
||||||
(process cc)
|
(process cc)
|
||||||
})
|
})
|
||||||
|
(set shortcutHandler.onBadKey
|
||||||
|
->[_ _]
|
||||||
|
(shortcutHandler.start))
|
||||||
(shortcutHandler.registerItem "{escape} Pause the movie"
|
(shortcutHandler.registerItem "{escape} Pause the movie"
|
||||||
->cc (director.showPauseMenu cc))
|
->cc (director.showPauseMenu cc))
|
||||||
|
|
||||||
// TODO (#when debug)
|
(#when debug
|
||||||
(shortcutHandler.registerItem "[d]efine [l]ight source"
|
(shortcutHandler.registerItem "[d]efine [l]ight source"
|
||||||
->cc
|
->cc
|
||||||
(director.defineLightSource
|
(director.defineLightSource
|
||||||
@@ -216,12 +220,10 @@
|
|||||||
(shortcutHandler.registerItem "skip to [l]abel"
|
(shortcutHandler.registerItem "skip to [l]abel"
|
||||||
->cc
|
->cc
|
||||||
(let [runners (labelRunners)]
|
(let [runners (labelRunners)]
|
||||||
(localVar &mut buttonY 0)
|
|
||||||
(localVar buttonsPerColumn 25)
|
|
||||||
(director.chooseString
|
(director.chooseString
|
||||||
"Skip to scene?"
|
"Skip to scene?"
|
||||||
(sort (collect (runners.keys)))
|
(sort (collect (runners.keys)))
|
||||||
->label ((dictGet runners label)))))
|
->label ((dictGet runners label))))))
|
||||||
|
|
||||||
(shortcutHandler.start))
|
(shortcutHandler.start))
|
||||||
|
|
||||||
@@ -266,19 +268,19 @@
|
|||||||
(never otherwise))]
|
(never otherwise))]
|
||||||
(case delayHandling
|
(case delayHandling
|
||||||
(Auto
|
(Auto
|
||||||
(Timer.delay cc (* 1000 sec)))
|
(TimerWithPause.delay cc sec))
|
||||||
(AutoWithSkip
|
(AutoWithSkip
|
||||||
(let [autoDelay
|
(let [autoDelay
|
||||||
(Timer.delay
|
(TimerWithPause.delay
|
||||||
->{
|
->{
|
||||||
(director.stopWaitForInput cc)
|
(director.stopWaitForInput cc)
|
||||||
(cc)
|
(cc)
|
||||||
}
|
}
|
||||||
(* 1000 sec))]
|
sec)]
|
||||||
(director.startWaitForInput
|
(director.startWaitForInput
|
||||||
->{
|
->{
|
||||||
(director.stopWaitForInput cc)
|
(director.stopWaitForInput cc)
|
||||||
(autoDelay.stop)
|
(TimerWithPause.stop autoDelay)
|
||||||
(cc)
|
(cc)
|
||||||
})))
|
})))
|
||||||
(Manual
|
(Manual
|
||||||
|
15
projects/kiss-tools/src/kiss_tools/TimerWithPause.hx
Normal file
15
projects/kiss-tools/src/kiss_tools/TimerWithPause.hx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package kiss_tools;
|
||||||
|
|
||||||
|
import kiss.Prelude;
|
||||||
|
import kiss.List;
|
||||||
|
import haxe.Timer;
|
||||||
|
|
||||||
|
typedef WrappedTimer = {
|
||||||
|
startTime:Float,
|
||||||
|
duration:Float,
|
||||||
|
t:Timer,
|
||||||
|
f:Void->Void
|
||||||
|
}
|
||||||
|
|
||||||
|
@:build(kiss.Kiss.build())
|
||||||
|
class TimerWithPause {}
|
31
projects/kiss-tools/src/kiss_tools/TimerWithPause.kiss
Normal file
31
projects/kiss-tools/src/kiss_tools/TimerWithPause.kiss
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
(var &mut :Array<WrappedTimer> timers [])
|
||||||
|
|
||||||
|
(function :WrappedTimer delay [:Void->Void f :Float sec]
|
||||||
|
(let [wrapped
|
||||||
|
(object
|
||||||
|
startTime (Timer.stamp)
|
||||||
|
duration sec
|
||||||
|
t null
|
||||||
|
f f)
|
||||||
|
wrappedF
|
||||||
|
->{(timers.remove wrapped)(f)}]
|
||||||
|
(set wrapped.t (Timer.delay wrappedF (Std.int (* sec 1000))))
|
||||||
|
(timers.push wrapped)
|
||||||
|
wrapped))
|
||||||
|
|
||||||
|
(function stop [:WrappedTimer timer]
|
||||||
|
(timer.t.stop)
|
||||||
|
(timers.remove timer))
|
||||||
|
|
||||||
|
(function pause []
|
||||||
|
(let [now (Timer.stamp)]
|
||||||
|
(doFor timer timers
|
||||||
|
(let [elapsed (- now timer.startTime)]
|
||||||
|
(-= timer.duration elapsed)
|
||||||
|
(timer.t.stop)))))
|
||||||
|
|
||||||
|
(function resume []
|
||||||
|
(let [oldTimers timers]
|
||||||
|
(set timers [])
|
||||||
|
(doFor timer oldTimers
|
||||||
|
(delay timer.f timer.duration))))
|
Reference in New Issue
Block a user