1 /* hotkey.c - Hot key functions
2 * Copyright (c) 1995-1997 Stefan Jokisch
4 * Changes for Rockbox copyright 2009 Torne Wuff
6 * This file is part of Frotz.
8 * Frotz is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * Frotz is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
24 #include "lib/pluginlib_exit.h"
26 extern int restore_undo (void);
28 extern int read_number (void);
30 extern bool read_yes_or_no (const char *);
32 extern void replay_open (void);
33 extern void replay_close (void);
34 extern void record_open (void);
35 extern void record_close (void);
37 extern void seed_random (int);
42 * ...allows user to toggle cheating options on/off.
46 static bool hot_key_debugging (void)
49 f_setup
.attribute_assignment
= read_yes_or_no ("Watch attribute assignment");
50 f_setup
.attribute_testing
= read_yes_or_no ("Watch attribute testing");
52 f_setup
.object_movement
= read_yes_or_no ("Watch object movement");
53 f_setup
.object_locating
= read_yes_or_no ("Watch object locating");
57 }/* hot_key_debugging */
62 * ...allows user to turn playback on.
66 static bool hot_key_playback (void)
69 rb
->splash(HZ
, "Playback on");
76 }/* hot_key_playback */
81 * ...allows user to turn recording on/off.
85 static bool hot_key_recording (void)
89 rb
->splash(HZ
, "Playback off");
91 } else if (ostream_record
) {
92 rb
->splash(HZ
, "Recording off");
95 rb
->splash(HZ
, "Recording on");
101 }/* hot_key_recording */
106 * ...allows user to seed the random number seed.
110 static bool hot_key_seed (void)
113 print_string ("Enter seed value (or return to randomize): ");
114 seed_random (read_number ());
123 * ...allows user to undo the previous turn.
127 static bool hot_key_undo (void)
130 if (restore_undo ()) {
132 print_string ("undo\n");
134 if (h_version
>= V5
) { /* for V5+ games we must */
135 store (2); /* store 2 (for success) */
136 return TRUE
; /* and abort the input */
139 if (h_version
<= V3
) { /* for V3- games we must */
140 z_show_status (); /* draw the status line */
141 return FALSE
; /* and continue input */
144 } else rb
->splash(HZ
, "No undo information available.");
153 * ...allows user to start a new game.
157 static bool hot_key_restart (void)
160 if (read_yes_or_no ("Do you wish to restart")) {
167 }/* hot_key_restart */
172 * ...allows user to exit the game.
176 bool hot_key_quit (void)
179 if (read_yes_or_no ("Do you wish to quit")) {
190 * Perform the action associated with a so-called hot key. Return
191 * true to abort the current input action.
195 bool handle_hot_key (zchar key
)
205 case ZC_HKEY_RECORD
: aborting
= hot_key_recording (); break;
206 case ZC_HKEY_PLAYBACK
: aborting
= hot_key_playback (); break;
207 case ZC_HKEY_SEED
: aborting
= hot_key_seed (); break;
208 case ZC_HKEY_UNDO
: aborting
= hot_key_undo (); break;
209 case ZC_HKEY_RESTART
: aborting
= hot_key_restart (); break;
210 case ZC_HKEY_QUIT
: aborting
= hot_key_quit (); break;
211 case ZC_HKEY_DEBUG
: aborting
= hot_key_debugging (); break;
221 }/* handle_hot_key */