Commit 18f60ef9 authored by Otto Wallenius's avatar Otto Wallenius Committed by Christian Persch

games: api: Fix undo/redo

Current status message and status message history is saved and
restored in api.scm in the same way as game score.

Fixes bug 744679.
parent fb573047
......@@ -734,6 +734,11 @@
(define-public (add-to-score! delta)
(set-score! (+ (get-score) delta)))
(define-public (set-statusbar-message message)
(set! STATUSBAR-MESSAGE message)
(set-statusbar-message-c message)
)
;; INTERNAL procedures
; global variables
......@@ -755,6 +760,7 @@
(define-public LEFT-SLOTS '())
(define-public RIGHT-SLOTS '())
(define-public SCORE 0)
(define-public STATUSBAR-MESSAGE "")
; called from C:
(define-public (start-game)
......@@ -779,13 +785,9 @@
(set-cards! slot-id (car card-positions))
(return-cards (cdr card-positions) (+ 1 slot-id))))
(define-public (give-status-message)
#t)
(define-public (eval-move move)
(return-cards (caddr move) 0)
((car move) (cadr move))
(give-status-message))
((car move) (cadr move)))
; called from C:
(define-public (undo)
......@@ -814,7 +816,8 @@
(define-public (undo-func data)
(set-score! (car data))
(set! FLIP-COUNTER (cadr data))
(restore-variables variable-list (caddr data)))
(set-statusbar-message (caddr data))
(restore-variables variable-list (cadddr data)))
;(register-undo-function undo-func '(score FLIP-COUNTER))
(define-public (snapshot-board slot-id moving-slot old-cards)
......@@ -831,6 +834,7 @@
(define-public (record-move slot-id old-cards)
(set! MOVE (list undo-func
(list (get-score) FLIP-COUNTER
STATUSBAR-MESSAGE
(save-variables variable-list))
(snapshot-board 0 slot-id old-cards))))
......
......@@ -1030,7 +1030,7 @@ cscm_init (void *data G_GNUC_UNUSED)
/* Let the scheme side of things know about our C functions. */
scm_c_define_gsubr ("set-feature-word!", 1, 0, 0, scm_set_feature_word);
scm_c_define_gsubr ("get-feature-word", 0, 0, 0, scm_get_feature_word);
scm_c_define_gsubr ("set-statusbar-message", 1, 0, 0,
scm_c_define_gsubr ("set-statusbar-message-c", 1, 0, 0,
scm_set_statusbar_message);
scm_c_define_gsubr ("reset-surface", 0, 0, 0, scm_reset_surface);
scm_c_define_gsubr ("add-slot", 1, 0, 0, cscmi_add_slot);
......@@ -1054,7 +1054,7 @@ cscm_init (void *data G_GNUC_UNUSED)
scm_c_export ("set-feature-word!",
"get-feature-word",
"set-statusbar-message",
"set-statusbar-message-c",
"reset-surface",
"add-slot",
"get-slot",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment