/* * Write all current options to a user preference file. */ void option_dump(ang_file * fff) { int i, j; /* Dump interface and gameplay options */ for (i = 0; i < OPT_MAX; i++) { const char *name = option_name(i); int type = option_type(i); if ((type != OP_GAMEPLAY) && (type != OP_INTERFACE)) continue; /* Comment */ file_putf(fff, "# Option '%s'\n", option_desc(i)); /* Dump the option */ if (op_ptr->opt[i]) file_putf(fff, "Y:%s\n", name); else file_putf(fff, "X:%s\n", name); /* Skip a line */ file_putf(fff, "\n"); } /* Dump window flags */ for (i = 1; i < ANGBAND_TERM_MAX; i++) { /* Require a real window */ if (!angband_term[i]) continue; /* Check each flag */ for (j = 0; j < (int) N_ELEMENTS(window_flag_desc); j++) { /* Require a real flag */ if (!window_flag_desc[j]) continue; /* Comment */ file_putf(fff, "# Window '%s', Flag '%s'\n", angband_term_name[i], window_flag_desc[j]); /* Dump the flag */ if (op_ptr->window_flag[i] & (1L << j)) file_putf(fff, "W:%d:%d:1\n", i, j); else file_putf(fff, "W:%d:%d:0\n", i, j); /* Skip a line */ file_putf(fff, "\n"); } } autoinsc_dump(fff); keymap_dump(fff); }
/* * Write all current options to a user preference file. */ void option_dump(ang_file * fff) { int i, j; /* Dump options (skip cheat, adult, score) */ for (i = 0; i < OPT_CHEAT; i++) { const char *name = option_name(i); if (!name) continue; /* Comment */ file_putf(fff, "# Option '%s'\n", option_desc(i)); /* Dump the option */ if (op_ptr->opt[i]) file_putf(fff, "Y:%s\n", name); else file_putf(fff, "X:%s\n", name); /* Skip a line */ file_putf(fff, "\n"); } /* Dump window flags */ for (i = 1; i < ANGBAND_TERM_MAX; i++) { /* Require a real window */ if (!angband_term[i]) continue; /* Check each flag */ for (j = 0; j < (int) N_ELEMENTS(window_flag_desc); j++) { /* Require a real flag */ if (!window_flag_desc[j]) continue; /* Comment */ file_putf(fff, "# Window '%s', Flag '%s'\n", angband_term_name[i], window_flag_desc[j]); /* Dump the flag */ if (op_ptr->window_flag[i] & (1L << j)) file_putf(fff, "W:%d:%d:1\n", i, j); else file_putf(fff, "W:%d:%d:0\n", i, j); /* Skip a line */ file_putf(fff, "\n"); } } autoinsc_dump(fff); keymap_dump(fff); }
/* * Interact with "macros" * * Note that the macro "action" must be defined before the trigger. * * Could use some helpful instructions on this page. XXX XXX XXX */ void do_cmd_macros(void) { s32b i; char tmp[1024]; char buf[1024]; s32b mode; /* Roguelike */ if (rogue_like_commands) { mode = KEYMAP_MODE_ROGUE; } /* Original */ else { mode = KEYMAP_MODE_ORIG; } /* Enter "icky" mode */ character_icky++; /* Save screen */ Term_save(); /* Process requests until done */ while (1) { /* Clear screen */ Term_clear(); /* Describe */ prt("Interact with Macros", 2, 0); /* Describe that action */ prt("Current action (if any) shown below:", 20, 0); /* Analyze the current action */ ascii_to_text(buf, macro__buf); /* Display the current action */ prt(buf, 22, 0); /* Selections */ prt("(1) Load a user pref file", 4, 5); #ifdef ALLOW_MACROS prt("(2) Append macros to a file", 5, 5); prt("(3) Query a macro", 6, 5); prt("(4) Create a macro", 7, 5); prt("(5) Remove a macro", 8, 5); prt("(6) Append keymaps to a file", 9, 5); prt("(7) Query a keymap", 10, 5); prt("(8) Create a keymap", 11, 5); prt("(9) Remove a keymap", 12, 5); prt("(0) Enter a new action", 13, 5); #endif /* ALLOW_MACROS */ /* Prompt */ prt("Command: ", 16, 0); /* Get a command */ i = inkey(); /* Leave */ if (i == ESCAPE) break; /* Load a 'macro' file */ else if (i == '1') { /* Prompt */ prt("Command: Load a user pref file", 16, 0); /* Prompt */ prt("File: ", 18, 0); /* Default filename */ strnfmt(tmp, 1024, "%s.prf", player_name); /* Ask for a file */ if (!askfor_aux(tmp, 80)) continue; /* Process the given filename */ if (0 != process_pref_file(tmp)) { /* Prompt */ msg_print("Could not load file!"); } } #ifdef ALLOW_MACROS /* Save macros */ else if (i == '2') { /* Prompt */ prt("Command: Append macros to a file", 16, 0); /* Prompt */ prt("File: ", 18, 0); /* Default filename */ strnfmt(tmp, 1024, "%s.prf", player_name); /* Ask for a file */ if (!askfor_aux(tmp, 80)) continue; /* Dump the macros */ (void)macro_dump(tmp); /* Prompt */ msg_print("Appended macros."); } /* Query a macro */ else if (i == '3') { s32b k; /* Prompt */ prt("Command: Query a macro", 16, 0); /* Prompt */ prt("Trigger: ", 18, 0); /* Get a macro trigger */ do_cmd_macro_aux(buf, TRUE); /* Acquire action */ k = macro_find_exact(buf); /* Nothing found */ if (k < 0) { /* Prompt */ msg_print("Found no macro."); } /* Found one */ else { /* Obtain the action */ strcpy(macro__buf, macro__act[k]); /* Analyze the current action */ ascii_to_text(buf, macro__buf); /* Display the current action */ prt(buf, 22, 0); /* Prompt */ msg_print("Found a macro."); } } /* Create a macro */ else if (i == '4') { /* Prompt */ prt("Command: Create a macro", 16, 0); /* Prompt */ prt("Trigger: ", 18, 0); /* Get a macro trigger */ do_cmd_macro_aux(buf, TRUE); /* Clear */ clear_from(20); /* Prompt */ prt("Action: ", 20, 0); /* Convert to text */ ascii_to_text(tmp, macro__buf); /* Get an encoded action */ if (askfor_aux(tmp, 80)) { /* Convert to ascii */ text_to_ascii(macro__buf, tmp); /* Link the macro */ macro_add(buf, macro__buf); /* Prompt */ msg_print("Added a macro."); } } /* Remove a macro */ else if (i == '5') { /* Prompt */ prt("Command: Remove a macro", 16, 0); /* Prompt */ prt("Trigger: ", 18, 0); /* Get a macro trigger */ do_cmd_macro_aux(buf, TRUE); /* Link the macro */ macro_add(buf, buf); /* Prompt */ msg_print("Removed a macro."); } /* Save keymaps */ else if (i == '6') { /* Prompt */ prt("Command: Append keymaps to a file", 16, 0); /* Prompt */ prt("File: ", 18, 0); /* Default filename */ strnfmt(tmp, 1024, "%s.prf", player_name); /* Ask for a file */ if (!askfor_aux(tmp, 80)) continue; /* Dump the macros */ (void)keymap_dump(tmp); /* Prompt */ msg_print("Appended keymaps."); } /* Query a keymap */ else if (i == '7') { cptr act; /* Prompt */ prt("Command: Query a keymap", 16, 0); /* Prompt */ prt("Keypress: ", 18, 0); /* Get a keymap trigger */ do_cmd_macro_aux_keymap(buf); /* Look up the keymap */ act = keymap_act[mode][(byte)(buf[0])]; /* Nothing found */ if (!act) { /* Prompt */ msg_print("Found no keymap."); } /* Found one */ else { /* Obtain the action */ strcpy(macro__buf, act); /* Analyze the current action */ ascii_to_text(buf, macro__buf); /* Display the current action */ prt(buf, 22, 0); /* Prompt */ msg_print("Found a keymap."); } } /* Create a keymap */ else if (i == '8') { /* Prompt */ prt("Command: Create a keymap", 16, 0); /* Prompt */ prt("Keypress: ", 18, 0); /* Get a keymap trigger */ do_cmd_macro_aux_keymap(buf); /* Clear */ clear_from(20); /* Prompt */ prt("Action: ", 20, 0); /* Convert to text */ ascii_to_text(tmp, macro__buf); /* Get an encoded action */ if (askfor_aux(tmp, 80)) { /* Convert to ascii */ text_to_ascii(macro__buf, tmp); /* Free old keymap */ string_free(keymap_act[mode][(byte)(buf[0])]); /* Make new keymap */ keymap_act[mode][(byte)(buf[0])] = string_make(macro__buf); /* Prompt */ msg_print("Added a keymap."); } } /* Remove a keymap */ else if (i == '9') { /* Prompt */ prt("Command: Remove a keymap", 16, 0); /* Prompt */ prt("Keypress: ", 18, 0); /* Get a keymap trigger */ do_cmd_macro_aux_keymap(buf); /* Free old keymap */ string_free(keymap_act[mode][(byte)(buf[0])]); /* Make new keymap */ keymap_act[mode][(byte)(buf[0])] = NULL; /* Prompt */ msg_print("Removed a keymap."); } /* Enter a new action */ else if (i == '0') { /* Prompt */ prt("Command: Enter a new action", 16, 0); /* Go to the correct location */ Term_gotoxy(0, 22); /* Hack -- limit the value */ tmp[80] = '\0'; /* Get an encoded action */ if (!askfor_aux(buf, 80)) continue; /* Extract an action */ text_to_ascii(macro__buf, buf); } #endif /* ALLOW_MACROS */ /* Oops */ else { /* Oops */ bell(); } /* Flush messages */ msg_print(NULL); } /* Load screen */ Term_load(); /* Leave "icky" mode */ character_icky--; }