diff --git a/extra/game-loop/game-loop.factor b/extra/game-loop/game-loop.factor index 8abbe6ba25..982319541b 100644 --- a/extra/game-loop/game-loop.factor +++ b/extra/game-loop/game-loop.factor @@ -1,5 +1,5 @@ -USING: accessors calendar destructors kernel math math.order namespaces -system threads ; +USING: accessors calendar continuations destructors kernel math +math.order namespaces system threads ui ui.gadgets.worlds ; IN: game-loop TUPLE: game-loop @@ -27,6 +27,16 @@ SYMBOL: game-loop CONSTANT: MAX-FRAMES-TO-SKIP 5 +DEFER: stop-loop + +TUPLE: game-loop-error game-loop error ; + +: ?ui-error ( error -- ) + ui-running? [ ui-error ] [ rethrow ] if ; + +: game-loop-error ( game-loop error -- ) + [ drop stop-loop ] [ \ game-loop-error boa ?ui-error ] 2bi ; + > - ; @@ -91,3 +103,6 @@ PRIVATE> M: game-loop dispose stop-loop ; +USING: vocabs vocabs.loader ; + +"prettyprint" vocab [ "game-loop.prettyprint" require ] when diff --git a/extra/game-loop/prettyprint/prettyprint.factor b/extra/game-loop/prettyprint/prettyprint.factor new file mode 100644 index 0000000000..8b20dd4c9d --- /dev/null +++ b/extra/game-loop/prettyprint/prettyprint.factor @@ -0,0 +1,9 @@ +! (c)2009 Joe Groff bsd license +USING: accessors debugger game-loop io ; +IN: game-loop.prettyprint + +M: game-loop-error error. + "An error occurred inside a game loop." print + "The game loop has been stopped to prevent runaway errors." print + "The error was:" print nl + error>> error. ;