minesweeper: always relayout-1 on click/mark.

This fixes the smiley uhoh to repaint immediately rather than
waiting for the next timer tick.
factor-shell
John Benediktsson 2018-02-11 10:09:36 -08:00
parent 52a503fef3
commit ffb42c913e
1 changed files with 3 additions and 5 deletions

View File

@ -229,7 +229,7 @@ M: grid-gadget draw-gadget*
h 3 55 between? h 3 55 between?
gadget pref-dim first 2/ w - abs 26 < and [ gadget pref-dim first 2/ w - abs 26 < and [
gadget [ reset-cells ] change-cells gadget [ reset-cells ] change-cells
f >>start f >>end relayout-1 f >>start f >>end drop
] when ] when
] [ ] [
h 58 - w [ 32 /i ] bi@ :> ( row col ) h 58 - w [ 32 /i ] bi@ :> ( row col )
@ -238,10 +238,9 @@ M: grid-gadget draw-gadget*
cells row col click-cell-at [ cells row col click-cell-at [
gadget start>> [ now gadget start<< ] unless gadget start>> [ now gadget start<< ] unless
cells game-over? [ now gadget end<< ] when cells game-over? [ now gadget end<< ] when
gadget relayout-1
] when ] when
] unless ] unless
] if ; ] if gadget relayout-1 ;
:: on-mark ( gadget -- ) :: on-mark ( gadget -- )
gadget hand-rel first2 :> ( w h ) gadget hand-rel first2 :> ( w h )
@ -252,10 +251,9 @@ M: grid-gadget draw-gadget*
cells row col mark-cell-at [ cells row col mark-cell-at [
gadget start>> [ now gadget start<< ] unless gadget start>> [ now gadget start<< ] unless
cells game-over? [ now gadget end<< ] when cells game-over? [ now gadget end<< ] when
gadget relayout-1
] when ] when
] unless ] unless
] when ; ] when gadget relayout-1 ;
: new-game ( gadget rows cols mines -- ) : new-game ( gadget rows cols mines -- )
[ make-cells ] dip place-mines update-counts >>cells [ make-cells ] dip place-mines update-counts >>cells