Files
@ 64a0a5d6b5cf
Branch filter:
Location: libtransport.git/backends/frotz/hotkey.c - annotation
64a0a5d6b5cf
4.9 KiB
text/plain
support setting int/bool in [purple] section
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 51c03d82ea50 | /* hotkey.c - Hot key functions
* Copyright (c) 1995-1997 Stefan Jokisch
*
* This file is part of Frotz.
*
* Frotz is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Frotz is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "frotz.h"
extern int restore_undo (void);
extern int read_number (void);
extern int read_yes_or_no (const char *);
extern void replay_open (void);
extern void replay_close (void);
extern void record_open (void);
extern void record_close (void);
extern void seed_random (int);
/*
* hot_key_debugging
*
* ...allows user to toggle cheating options on/off.
*
*/
static int hot_key_debugging (void)
{
print_string ("Debugging options\n");
f_setup.attribute_assignment = read_yes_or_no ("Watch attribute assignment");
f_setup.attribute_testing = read_yes_or_no ("Watch attribute testing");
f_setup.object_movement = read_yes_or_no ("Watch object movement");
f_setup.object_locating = read_yes_or_no ("Watch object locating");
return FALSE;
}/* hot_key_debugging */
/*
* hot_key_help
*
* ...displays a list of all hot keys.
*
*/
static int hot_key_help (void) {
print_string ("Help\n");
print_string (
"\n"
"Alt-D debugging options\n"
"Alt-H help\n"
"Alt-N new game\n"
"Alt-P playback on\n"
"Alt-R recording on/off\n"
"Alt-S seed random numbers\n"
"Alt-U undo one turn\n"
"Alt-X exit game\n");
return FALSE;
}/* hot_key_help */
/*
* hot_key_playback
*
* ...allows user to turn playback on.
*
*/
static int hot_key_playback (void)
{
print_string ("Playback on\n");
if (!istream_replay)
replay_open ();
return FALSE;
}/* hot_key_playback */
/*
* hot_key_recording
*
* ...allows user to turn recording on/off.
*
*/
static int hot_key_recording (void)
{
if (istream_replay) {
print_string ("Playback off\n");
replay_close ();
} else if (ostream_record) {
print_string ("Recording off\n");
record_close ();
} else {
print_string ("Recording on\n");
record_open ();
}
return FALSE;
}/* hot_key_recording */
/*
* hot_key_seed
*
* ...allows user to seed the random number seed.
*
*/
static int hot_key_seed (void)
{
print_string ("Seed random numbers\n");
print_string ("Enter seed value (or return to randomize): ");
seed_random (read_number ());
return FALSE;
}/* hot_key_seed */
/*
* hot_key_undo
*
* ...allows user to undo the previous turn.
*
*/
static int hot_key_undo (void)
{
print_string ("Undo one turn\n");
if (restore_undo ()) {
if (h_version >= V5) { /* for V5+ games we must */
store (2); /* store 2 (for success) */
return TRUE; /* and abort the input */
}
if (h_version <= V3) { /* for V3- games we must */
z_show_status (); /* draw the status line */
return FALSE; /* and continue input */
}
} else print_string ("No more undo information available.\n");
return FALSE;
}/* hot_key_undo */
/*
* hot_key_restart
*
* ...allows user to start a new game.
*
*/
static int hot_key_restart (void)
{
print_string ("New game\n");
if (read_yes_or_no ("Do you wish to restart")) {
z_restart ();
return TRUE;
} else return FALSE;
}/* hot_key_restart */
/*
* hot_key_quit
*
* ...allows user to exit the game.
*
*/
static int hot_key_quit (void)
{
print_string ("Exit game\n");
if (read_yes_or_no ("Do you wish to quit")) {
z_quit ();
return TRUE;
} else return FALSE;
}/* hot_key_quit */
/*
* handle_hot_key
*
* Perform the action associated with a so-called hot key. Return
* true to abort the current input action.
*
*/
int handle_hot_key (zchar key)
{
if (cwin == 0) {
int aborting;
aborting = FALSE;
print_string ("\nHot key -- ");
switch (key) {
case ZC_HKEY_RECORD: aborting = hot_key_recording (); break;
case ZC_HKEY_PLAYBACK: aborting = hot_key_playback (); break;
case ZC_HKEY_SEED: aborting = hot_key_seed (); break;
case ZC_HKEY_UNDO: aborting = hot_key_undo (); break;
case ZC_HKEY_RESTART: aborting = hot_key_restart (); break;
case ZC_HKEY_QUIT: aborting = hot_key_quit (); break;
case ZC_HKEY_DEBUG: aborting = hot_key_debugging (); break;
case ZC_HKEY_HELP: aborting = hot_key_help (); break;
}
if (aborting)
return TRUE;
print_string ("\nContinue input...\n");
}
return FALSE;
}/* handle_hot_key */
|