/* * Hack -- ask for a keymap "trigger" (see below) * * Note that both "flush()" calls are extremely important. This may * no longer be true, since "util.c" is much simpler now. XXX XXX XXX */ static void do_cmd_macro_aux_keymap(char *buf) { char tmp[1024]; s32b ch; /* Flush */ flush(); ch = inkey(); if ((ch < 0) || (ch > 255)) { Term_addstr( -1, TERM_WHITE, "BAD TRIGGER"); return; } /* Get a key */ buf[0] = (char) ch; buf[1] = '\0'; /* Convert to ascii */ ascii_to_text(tmp, buf); /* Hack -- display the trigger */ Term_addstr( -1, TERM_WHITE, tmp); /* Flush */ flush(); }
/* * Hack -- Display the "name" and "attr/chars" of a monster race */ static void roff_top(const int r_idx, int m_idx) { byte a1, a2; char c1, c2; char desc[80]; monster_race *r_ptr = &r_info[r_idx]; /* Describe the monster */ if (m_idx) { /* Describe the monster */ monster_desc(desc, sizeof(desc), m_idx, 0x80); /* Capitalise the first letter */ if (islower(desc[0])) desc[0] = toupper(desc[0]); } /* Not describing a specific monster, so hack a description */ else { /* Get the name */ race_desc(desc, sizeof(desc), r_idx, 0x400, 1); /* Capitalise the first letter */ if (islower(desc[0])) desc[0] = toupper(desc[0]); } /* Get the chars */ c1 = r_ptr->d_char; c2 = r_ptr->x_char; /* Get the attrs */ a1 = r_ptr->d_attr; a2 = r_ptr->x_attr; /* Clear the top line */ Term_erase(0, 0, 255); /* Reset the cursor */ Term_gotoxy(0, 0); /* Dump the name */ Term_addstr(-1, TERM_WHITE, desc); if (!use_dbltile && !use_trptile) { /* Append the "standard" attr/char info */ Term_addstr(-1, TERM_WHITE, " ('"); Term_addch(a1, c1); Term_addstr(-1, TERM_WHITE, "')"); /* Append the "optional" attr/char info */ Term_addstr(-1, TERM_WHITE, "/('"); Term_addch(a2, c2); if (use_bigtile && (a2 & 0x80)) Term_addch(255, -1); Term_addstr(-1, TERM_WHITE, "'):"); } }
/** * Display a string on the screen using an attribute, and clear to the * end of the line. */ void c_prt(byte attr, const char *str, int row, int col) { /* Clear line, position cursor */ Term_erase(col, row, 255); /* Dump the attr/text */ Term_addstr(-1, attr, str); }
static void ui_keymap_query(const char *title, int row) { char tmp[1024]; int mode = OPT(rogue_like_commands) ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG; struct keypress c; const struct keypress *act; prt(title, 13, 0); prt("Key: ", 14, 0); /* Get a keymap trigger & mapping */ c = keymap_get_trigger(); act = keymap_find(mode, c); /* Keymap found? */ if (!act) { /* Prompt */ prt("No keymap with that trigger. Press any key to continue.", 16, 0); inkey(); } else { /* Analyze the current action */ keypress_to_text(tmp, sizeof(tmp), act, false); /* Display the current action */ prt("Found: ", 15, 0); Term_addstr(-1, COLOUR_WHITE, tmp); prt("Press any key to continue.", 17, 0); inkey(); } }
/* * Hack -- Display the "name" and "attr/chars" of a monster race */ void roff_top(int r_idx) { monster_race *r_ptr = &r_info[r_idx]; byte a1, a2; char c1, c2; /* Access the chars */ c1 = r_ptr->d_char; c2 = r_ptr->x_char; /* Access the attrs */ a1 = r_ptr->d_attr; a2 = r_ptr->x_attr; /* Clear the top line */ Term_erase(0, 0, 255); /* Reset the cursor */ Term_gotoxy(0, 0); /* A title (use "The" for non-uniques) */ if (!(r_ptr->flags1 & RF1_UNIQUE)) { Term_addstr(-1, TERM_WHITE, "The "); } /* Dump the name */ Term_addstr(-1, TERM_WHITE, (r_name + r_ptr->name)); /* Append the "standard" attr/char info */ Term_addstr(-1, TERM_WHITE, " ('"); Term_add_bigch(a1, c1); Term_addstr(-1, TERM_WHITE, "')"); /* Append the "optional" attr/char info */ Term_addstr(-1, TERM_WHITE, "/('"); Term_add_bigch(a2, c2); Term_addstr(-1, TERM_WHITE, "'):"); /* Wizards get extra info */ if (p_ptr->wizard) { char buf[6]; sprintf(buf, "%d", r_idx); Term_addstr(-1, TERM_WHITE, " ("); Term_addstr(-1, TERM_L_BLUE, buf); Term_addch(TERM_WHITE, ')'); } }
/* * Move to a location and, using an attr, add a string */ errr Term_putstr(int x, int y, int n, byte a, cptr s) { errr res; /* Move first */ if ((res = Term_gotoxy(x, y)) != 0) return (res); /* Then add the string */ if ((res = Term_addstr(n, a, s)) != 0) return (res); /* Success */ return (0); }
/* * Hack -- ask for a "trigger" (see below) * * Note the complex use of the "inkey()" function from "util.c". * * Note that both "flush()" calls are extremely important. */ static void do_cmd_macro_aux(char *buf, bool macro_screen) { s32b i, n = 0; char tmp[1024]; /* Flush */ flush(); /* Do not process macros */ inkey_base = TRUE; /* First key */ i = inkey(); /* Read the pattern */ while (i) { /* Save the key */ buf[n++] = i; /* Do not process macros */ inkey_base = TRUE; /* Do not wait for keys */ inkey_scan = TRUE; /* Attempt to read a key */ i = inkey(); } /* Terminate */ buf[n] = '\0'; /* Flush */ flush(); if (macro_screen) { /* Convert the trigger */ ascii_to_text(tmp, buf); /* Hack -- display the trigger */ Term_addstr( -1, TERM_WHITE, tmp); } }
/* Display an entry on a command menu */ static void cmd_sub_entry(menu_type *menu, int oid, bool cursor, int row, int col, int width) { byte attr = (cursor ? TERM_L_BLUE : TERM_WHITE); const struct cmd_info *commands = menu_priv(menu); int mode = OPT(rogue_like_commands) ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG; struct keypress kp = { EVT_KBRD, commands[oid].key[mode] }; char buf[16]; /* Write the description */ Term_putstr(col, row, -1, attr, commands[oid].desc); /* Include keypress */ Term_addch(attr, ' '); Term_addch(attr, '('); /* Get readable version */ keypress_to_readable(buf, sizeof buf, kp); Term_addstr(-1, attr, buf); Term_addch(attr, ')'); }
/** * Ask for, and display, a keymap trigger. * * Returns the trigger input. * * Note that both "event_signal(EVENT_INPUT_FLUSH)" calls are extremely * important. This may * no longer be true, since "util.c" is much simpler now. XXX XXX XXX */ static struct keypress keymap_get_trigger(void) { char tmp[80]; struct keypress buf[2] = { KEYPRESS_NULL, KEYPRESS_NULL }; /* Flush */ event_signal(EVENT_INPUT_FLUSH); /* Get a key */ buf[0] = inkey(); /* Convert to ascii */ keypress_to_text(tmp, sizeof(tmp), buf, false); /* Hack -- display the trigger */ Term_addstr(-1, COLOUR_WHITE, tmp); /* Flush */ event_signal(EVENT_INPUT_FLUSH); /* Return trigger */ return buf[0]; }
/* * Ask for, and display, a keymap trigger. * * Returns the trigger input. * * Note that both "flush()" calls are extremely important. This may * no longer be true, since "util.c" is much simpler now. XXX XXX XXX */ static struct keypress keymap_get_trigger(void) { char tmp[80]; struct keypress buf[2] = { { 0 }, { 0 } }; /* Flush */ flush(); /* Get a key */ buf[0] = inkey(); /* Convert to ascii */ keypress_to_text(tmp, sizeof(tmp), buf, false); /* Hack -- display the trigger */ Term_addstr(-1, TERM_WHITE, tmp); /* Flush */ flush(); /* Return trigger */ return buf[0]; }
/* * Hack -- Display the "name" and "attr/chars" of a monster race */ static void roff_top(int r_idx) { monster_race *r_ptr = &r_info[r_idx]; byte a1, a2; char c1, c2; /* Get the chars */ c1 = r_ptr->d_char; c2 = r_ptr->x_char; /* Get the attrs */ a1 = r_ptr->d_attr; a2 = r_ptr->x_attr; /* Clear the top line */ Term_erase(0, 0, 255); /* Reset the cursor */ Term_gotoxy(0, 0); /* A title (use "The" for non-uniques) */ if (!(r_ptr->flags1 & RF1_UNIQUE)) { Term_addstr(-1, TERM_WHITE, "The "); } /* Dump the name */ Term_addstr(-1, TERM_WHITE, (r_name + r_ptr->name)); /* Append the "standard" attr/char info */ Term_addstr(-1, TERM_WHITE, " ('"); Term_addch(a1, c1); Term_addstr(-1, TERM_WHITE, "')"); /* Append the "optional" attr/char info */ Term_addstr(-1, TERM_WHITE, "/('"); Term_addch(a2, c2); if (use_bigtile && (a2 & 0x80)) Term_addch(255, -1); Term_addstr(-1, TERM_WHITE, "'):"); }
/* * Examine a grid, return a keypress. * * The "mode" argument contains the "TARGET_LOOK" bit flag, which * indicates that the "space" key should scan through the contents * of the grid, instead of simply returning immediately. This lets * the "look" command get complete information, without making the * "target" command annoying. * * The "info" argument contains the "commands" which should be shown * inside the "[xxx]" text. This string must never be empty, or grids * containing monsters will be displayed with an extra comma. * * Note that if a monster is in the grid, we update both the monster * recall info and the health bar info to track that monster. * * This function correctly handles multiple objects per grid, and objects * and terrain features in the same grid, though the latter never happens. * * This function must handle blindness/hallucination. */ static ui_event_data target_set_interactive_aux(int y, int x, int mode, cptr info, bool list_floor_objects) { s16b this_o_idx, next_o_idx = 0; s16b this_x_idx, next_x_idx = 0; cptr s1, s2, s3; bool floored; u16b feat; ui_event_data query; char out_val[256]; char coords[20]; /* Describe the square location */ coords_desc(coords, sizeof(coords), y, x); /* Repeat forever */ while (1) { int i; char feat_name[80]; /* Terrain suffix for monsters and objects */ char terrain_suffix[200]; /* Temporary array of visible effects */ s16b x_seen[50]; u16b size_x_seen = 0; /* Paranoia */ query.key = ' '; /* Default */ s1 = "You see "; s2 = ""; s3 = "on "; /* The player */ if (cave_m_idx[y][x] < 0) { /* Description */ s1 = "You are "; /* Preposition */ s2 = "on "; } /* Feature (apply "mimic") */ feat = f_info[cave_feat[y][x]].f_mimic; /* Require knowledge about grid, or ability to see grid */ if (!(cave_info[y][x] & (CAVE_MARK)) && !player_can_see_bold(y,x)) { /* Forget feature */ feat = FEAT_NONE; } else { /* Hack -- track the current feature */ feature_kind_track(feat); /* Window stuff */ p_ptr->redraw |= (PR_FEATURE); } /* Pick a prefix */ if (*s2 && (!feat_ff1_match(feat, FF1_MOVE) || !feat_ff1_match(feat, FF1_LOS) || feat_ff1_match(feat, FF1_SHOP | FF1_DOOR) || feat_ff2_match(feat, FF2_SHALLOW | FF2_DEEP) || feat_ff3_match(feat, FF3_NEED_TREE))) { s3 = "in "; } /* Get a default name */ if (feat <= FEAT_NONE) { my_strcpy(feat_name, "an unknown grid", sizeof(feat_name)); } /* Get the real name */ else { feature_desc(feat_name, sizeof (feat_name), feat, TRUE, FALSE); } /* List all effects in the grid */ for (this_x_idx = cave_x_idx[y][x]; this_x_idx; this_x_idx = next_x_idx) { effect_type *x_ptr; /* Get the effect */ x_ptr = &x_list[this_x_idx]; /* Get the next effect */ next_x_idx = x_ptr->next_x_idx; /* Describe it, if not hidden */ if (!(x_ptr->x_flags & (EF1_HIDDEN)) && x_ptr->x_f_idx) { /* Check for available space */ if (size_x_seen < N_ELEMENTS(x_seen)) { x_seen[size_x_seen++] = x_ptr->x_f_idx; } } } /* Prepare the terrain suffix for monsters and objects */ my_strcpy(terrain_suffix, format(" %s%s", s3, feat_name), sizeof(terrain_suffix)); /* Concat the collected effect names */ for (i = 0; i < size_x_seen; i++) { char x_name[80]; /* Obtain an object description */ feature_desc(x_name, sizeof(x_name), x_seen[i], TRUE, TRUE); /* First effect */ if (i == 0) { if ((feat == FEAT_NONE) || !feat_ff1_match(feat, FF1_MOVE) || cave_any_trap_bold(y, x)) { /* Basic info */ my_strcat(terrain_suffix, format(" with %s", x_name), sizeof(terrain_suffix)); } else { /* Basic info */ my_strcat(terrain_suffix, format(" beneath %s", x_name), sizeof(terrain_suffix)); } } /* Basic info */ else if (i < (size_x_seen - 1)) { my_strcat(terrain_suffix, format(", %s", x_name), sizeof(terrain_suffix)); } /* Basic info */ else { my_strcat(terrain_suffix, format(" and %s", x_name), sizeof(terrain_suffix)); } } /* Ignore the terrain suffix if certain things happen */ if ((size_x_seen == 0) && (feat <= FEAT_FLOOR)) { terrain_suffix[0] = '\0'; } /* Hack -- hallucination */ if (p_ptr->timed[TMD_IMAGE]) { cptr name = "something strange"; /* Display a message */ if (p_ptr->wizard) { strnfmt(out_val, sizeof(out_val), "%s%s%s, [%s] %s (%d:%d).", s1, s2, name, info, coords, y, x); } else { strnfmt(out_val, sizeof(out_val), "%s%s%s [%s], %s.", s1, s2, name, info, coords); } prt(out_val, 0, 0); move_cursor_relative(y, x); query = inkey_ex(); /* Stop on everything but "return" */ if ((query.key != '\n') && (query.key != '\r')) break; /* Repeat forever */ continue; } /* Actual monsters */ if (cave_m_idx[y][x] > 0) { monster_type *m_ptr = &mon_list[cave_m_idx[y][x]]; monster_race *r_ptr = &r_info[m_ptr->r_idx]; /* Visible */ if (m_ptr->ml) { bool recall = FALSE; char m_name[80]; if (m_ptr->mimic_k_idx) { /*get the description*/ mimic_desc_object(m_name, sizeof(m_name), m_ptr->mimic_k_idx); } else { /* Get the monster name ("a kobold") */ monster_desc(m_name, sizeof(m_name), m_ptr, 0x08); /* Hack -- track this monster race */ monster_race_track(m_ptr->r_idx); /* Hack -- health bar for this monster */ health_track(cave_m_idx[y][x]); /*Track the feature*/ feature_kind_track(cave_feat[y][x]); /* Window stuff */ p_ptr->redraw |= (PR_FEATURE); /* Hack -- handle stuff */ handle_stuff(); } /* Interact */ while (1) { if (recall) button_add("[CLEAR_RECALL]", 'r'); else button_add("[RECALL]", 'r'); if (cave_o_idx[y][x] > 0)button_add("[VIEW_FLOOR]", 'f'); event_signal(EVENT_MOUSEBUTTONS); /* Recall, but not mimics */ if ((recall) && (!(m_ptr->mimic_k_idx))) { /* Save screen */ screen_save(); /* Recall on screen */ screen_roff(m_ptr->r_idx); /* Hack -- Complete the prompt (again) */ Term_addstr(-1, TERM_WHITE, format(" [r,%s]", info)); /* Command */ query = inkey_ex(); /* Load screen */ screen_load(); } /* Normal */ else { /* Basic info */ strnfmt(out_val, sizeof(out_val), "%s%s%s", s1, s2, m_name); /* Describe the monster, unless a mimic */ if (!(m_ptr->mimic_k_idx)) { char buf[80]; look_mon_desc(buf, sizeof(buf), cave_m_idx[y][x]); /* Monster state, terrain suffix, options */ my_strcat(out_val, format(" (%s)%s [r,%s]", buf, terrain_suffix, info), sizeof(out_val)); } /* Mimics */ else { /* Terrain suffix, options */ my_strcat(out_val, format("%s [I,%s]", terrain_suffix, info), sizeof(out_val)); } /* Wizards want coordinates */ if (p_ptr->wizard) { my_strcat(out_val, format(" (%d:%d)", y, x), sizeof(out_val)); } prt(out_val, 0, 0); /* Place cursor */ move_cursor_relative(y, x); /* Command */ query = inkey_ex(); } button_kill('r'); button_kill('f'); event_signal(EVENT_MOUSEBUTTONS); /* Handle fake object recall */ if (m_ptr->mimic_k_idx) { object_type body; object_type *o_ptr = &body; /* Validate input first */ if (query.key != 'I') break; /* Paranoia */ object_wipe(o_ptr); /* Prepare */ object_prep(o_ptr, m_ptr->mimic_k_idx); /* Fake history */ object_history(o_ptr, ORIGIN_FLOOR, 0); /* Clear prompt. Place cursor */ prt("", 0, 0); /* Show the fake info - EXPERIMENTAL */ object_info_screen(o_ptr); } /* Regular monsters */ else { /* Normal commands */ if (query.key != 'r') break; /* Toggle recall */ recall = !recall; } } /* Stop on everything but "return"/"space", or floor */ if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ') && (query.key != 'f')) break; /* continue with 'f' only if there are floor items....*/ if ((query.key == 'f') && (!cave_o_idx[y][x])) break; /* Sometimes stop at "space" key */ if ((query.key == ' ') && !(mode & (TARGET_LOOK))) break; /* Change the intro */ s1 = "It is "; /* Hack -- take account of gender */ if (r_ptr->flags1 & (RF1_FEMALE)) s1 = "She is "; else if (r_ptr->flags1 & (RF1_MALE)) s1 = "He is "; /* Use a preposition */ s2 = "carrying "; /* Scan all objects being carried */ for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx) { char o_name[80]; object_type *o_ptr; /* Get the object */ o_ptr = &o_list[this_o_idx]; /* Get the next object */ next_o_idx = o_ptr->next_o_idx; /*Don't let the player see certain objects (used for vault treasure)*/ if ((o_ptr->ident & (IDENT_HIDE_CARRY)) && (!p_ptr->wizard) && (!cheat_peek)) continue; /* Obtain an object description */ object_desc(o_name, sizeof(o_name), o_ptr, ODESC_PREFIX | ODESC_FULL); /* Describe the object */ strnfmt(out_val, sizeof(out_val), "%s%s%s [%s]", s1, s2, o_name, info); /* Wizards want coordinates */ if (p_ptr->wizard) { my_strcat(out_val, format(" (%d:%d)", y, x), sizeof(out_val)); } prt(out_val, 0, 0); move_cursor_relative(y, x); query = inkey_ex(); /* Stop on everything but "return"/"space" */ if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ')) break; /* Sometimes stop at "space" key */ if ((query.key == ' ') && !(mode & (TARGET_LOOK))) break; /* Change the intro */ s2 = "also carrying "; } /* Double break */ if (this_o_idx) break; /* Use a preposition */ s2 = "on "; } } /* Assume not floored */ floored = FALSE; /* Scan all objects in the grid */ if (TRUE) { int floor_list[MAX_FLOOR_STACK]; int floor_num; track_object(-floor_list[0]); handle_stuff(); /* Scan for floor objects */ floor_num = scan_floor(floor_list, MAX_FLOOR_STACK, y, x, 0x02); /* Actual pile */ if (floor_num > 1) { /* Floored */ floored = TRUE; /* Describe */ while (1) { /* Basic info */ strnfmt(out_val, sizeof(out_val), "%s%sa pile of %d objects%s [r,%s]", s1, s2, floor_num, terrain_suffix, info); /* Wizards want coordinates */ if (p_ptr->wizard) { my_strcat(out_val, format(" (%d:%d)", y, x), sizeof(out_val)); } prt(out_val, 0, 0); if (list_floor_objects) { /* Save screen */ screen_save(); /* Display */ show_floor(floor_list, floor_num, (OLIST_WEIGHT | OLIST_GOLD)); } move_cursor_relative(y, x); query = inkey_ex(); if (list_floor_objects) { screen_load(); } /* Display objects */ if (query.key == 'r') { int pos; pos = query.key - 'a'; if (0 <= pos && pos < floor_num) { track_object(-floor_list[pos]); handle_stuff(); } } /* Done */ break; } /* Stop on everything but "return"/"space" */ if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ')) break; /* Sometimes stop at "space" key */ if ((query.key == ' ') && !(mode & (TARGET_LOOK))) break; /* Change the intro */ s1 = "It is "; /* Preposition */ s2 = "on "; } } /* Scan all objects in the grid */ for (this_o_idx = cave_o_idx[y][x]; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; /* Get the object */ o_ptr = &o_list[this_o_idx]; /* Get the next object */ next_o_idx = o_ptr->next_o_idx; /* Skip objects if floored */ if (floored) continue; /* Describe it */ if (o_ptr->marked) { char o_name[80]; /* Obtain an object description */ object_desc(o_name, sizeof(o_name), o_ptr, ODESC_PREFIX | ODESC_FULL); /* Basic info */ strnfmt(out_val, sizeof(out_val), "%s%s%s%s [I,%s]", s1, s2, o_name, terrain_suffix, info); /* Wizards want coordinates */ if (p_ptr->wizard) { my_strcat(out_val, format(" (%d:%d)", y, x), sizeof(out_val)); } /* Show object. Handle object recall */ while (TRUE) { /* Print the prompt */ prt(out_val, 0, 0); /* Move cursor to that location */ move_cursor_relative(y, x); /* Read input key */ query = inkey_ex(); /* No object recall */ if (query.key != 'I') break; /* Object recall. Clear the first line */ prt("", 0, 0); /* Do it */ object_info_screen(o_ptr); } /* Stop on everything but "return"/"space" */ if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ')) break; /* Sometimes stop at "space" key */ if ((query.key == ' ') && !(mode & (TARGET_LOOK))) break; /* Change the intro */ s1 = "It is "; /* Plurals */ if (o_ptr->number != 1) s1 = "They are "; /* Preposition */ s2 = "on "; } } /* Double break */ if (this_o_idx) break; /* Display terrain */ if (TRUE) { u16b temp_feat; bool enable_recall; bool show_recall = FALSE; char temp_name[80]; /* * Display terrain and effects */ for (i = 0; i <= size_x_seen; i++) { /* Hack - This is the mark for the feature stored in cave_feat */ if (i == size_x_seen) { temp_feat = feat; /* Just copy the feature name */ my_strcpy(temp_name, feat_name, sizeof(temp_name)); } /* Any other value is an effect stored x_list */ else { temp_feat = x_seen[i]; /* Get the effect's name */ feature_desc(temp_name, sizeof(temp_name), temp_feat, TRUE, TRUE); } /* Don't display feature recall if the grid is unknown */ enable_recall = (temp_feat != FEAT_NONE); /* Handle recall */ while (TRUE) { /* Handle recall mode */ if (show_recall && enable_recall) { /* Save screen */ screen_save(); /* Recall feature on screen */ screen_feature_roff(temp_feat); } /* Display a message */ strnfmt(out_val, sizeof(out_val), "%s%s%s [%s%s]%s", s1, s2, temp_name, (enable_recall ? "r,": ""), info, (i < size_x_seen) ? " (more)": ""); /* Wizards want coordinates */ if (p_ptr->wizard) { my_strcat(out_val, format(" (%d:%d)", y, x), sizeof(out_val)); } /*Track this feature*/ feature_kind_track(temp_feat); /* Hack -- handle stuff */ handle_stuff(); prt(out_val, 0, 0); move_cursor_relative(y, x); query = inkey_ex(); /* Load screen if necessary */ if (show_recall && enable_recall) { screen_load(); } /* Stop on everything but the recall command, if enabled */ if (!enable_recall || (query.key != 'r')) break; /* Toggle recall */ show_recall = !show_recall; } /* Stop on everything but "return"/"space" */ if ((query.key != '\n') && (query.key != '\r') && (query.key != ' ')) break; } } /* Hack -- handle stuff */ handle_stuff(); /* Stop on everything but "return" */ if ((query.key != '\n') && (query.key != '\r')) break; } /* Keep going */ return (query); }
/* * Identify a character, allow recall of monsters * * Several "special" responses recall "mulitple" monsters: * ^A (all monsters) * ^U (all unique monsters) * ^N (all non-unique monsters) * * The responses may be sorted in several ways, see below. * * Note that the player ghosts are ignored, since they do not exist. */ void do_cmd_query_symbol(void) { int i, n, r_idx; char sym, query; char buf[128]; bool all = FALSE; bool uniq = FALSE; bool norm = FALSE; bool kill = TRUE; bool recall = FALSE; u16b why = 0; u16b *who; /* Get a character, or abort */ if (!get_com("Enter character to be identified: ", &sym)) return; /* Find that character info, and describe it */ for (i = 0; ident_info[i]; ++i) { if (sym == ident_info[i][0]) break; } /* Describe */ if (sym == KTRL('A')) { all = TRUE; strcpy(buf, "Full monster list."); } else if (sym == KTRL('U')) { all = uniq = TRUE; strcpy(buf, "Unique monster list."); } else if (sym == KTRL('N')) { all = norm = TRUE; strcpy(buf, "Non-unique monster list."); } else if (sym == KTRL('K')) { all = kill = TRUE; strcpy(buf, "Killed monster list."); } else if (ident_info[i]) { sprintf(buf, "%c - %s.", sym, ident_info[i] + 2); } else { sprintf(buf, "%c - %s.", sym, "Unknown Symbol"); } /* Display the result */ prt(buf, 0, 0); /* Allocate the "who" array */ C_MAKE(who, z_info->r_max, u16b); /* Collect matching monsters */ for (n = 0, i = 1; i < z_info->r_max - 1; i++) { monster_race *r_ptr = &r_info[i]; monster_lore *l_ptr = &l_list[i]; /* Nothing to recall */ if (!cheat_know && !l_ptr->sights) continue; /* Skip unused monsters */ if (!(r_ptr->hdice)) continue; /* Require non-unique monsters if needed */ if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue; /* Require unique monsters if needed */ if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue; /* Require killed if needed */ if (kill && !(l_ptr->pkills)) continue; /* Collect "appropriate" monsters */ if (all || (r_ptr->d_char == sym)) who[n++] = i; } /* Nothing to recall */ if (!n) { /* XXX XXX Free the "who" array */ FREE(who); return; } /* Prompt */ put_str("Recall details? (k/K/p/P/a/A/y/n): ", 0, 40); /* Query */ query = inkey(); /* Restore */ prt(buf, 0, 0); /* Sort by kills (and level) */ if (query == 'k') { why = 4; query = 'y'; } if (query == 'K') { why = 4+16; query = 'y'; } /* Sort by total kills (and level) */ if (query == 'a') { why = 3; query = 'y'; } if (query == 'A') { why = 3+16; query = 'y'; } /* Sort by level (and experience) */ if (query == 'p') { why = 2; query = 'y'; } if (query == 'P') { why = 2+16; query = 'y'; } /* Catch "escape" */ if (query != 'y') { /* XXX XXX Free the "who" array */ FREE(who); return; } /* Sort if needed */ if (why) { /* Select the sort method */ ang_sort_comp = ang_sort_comp_hook; ang_sort_swap = ang_sort_swap_hook; /* Sort the array */ ang_sort(who, &why, n); } /* Start at the end */ i = n - 1; /* Scan the monster memory */ while (1) { /* Extract a race */ r_idx = who[i]; /* Hack -- Auto-recall */ monster_race_track(r_idx); /* Hack -- Handle stuff */ handle_stuff(); /* Hack -- Begin the prompt */ roff_top(r_idx); /* Hack -- Complete the prompt */ Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]"); /* Interact */ while (1) { /* Recall */ if (recall) { /* Save screen */ screen_save(); /* Recall on screen */ screen_roff(who[i]); /* Hack -- Complete the prompt (again) */ Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]"); } /* Command */ query = inkey(); /* Unrecall */ if (recall) { /* Load screen */ screen_load(); } /* Normal commands */ if (query != 'r') break; /* Toggle recall */ recall = !recall; } /* Stop scanning */ if (query == ESCAPE) break; /* Move to "prev" monster */ if (query == '-') { if (++i == n) { i = 0; if (!expand_list) break; } } /* Move to "next" monster */ else { if (i-- == 0) { i = n - 1; if (!expand_list) break; } } } /* Re-display the identity */ prt(buf, 0, 0); /* Free the "who" array */ FREE(who); }
/* * Identify a character, allow recall of monsters * * Several "special" responses recall "multiple" monsters: * ^A (all monsters) * ^U (all unique monsters) * ^N (all non-unique monsters) * * The responses may be sorted in several ways, see below. * * Note that the player ghosts are ignored. XXX XXX XXX */ void do_cmd_query_symbol(void) { int i, n, r_idx; char sym, query; char buf[128]; bool all = FALSE; bool uniq = FALSE; bool norm = FALSE; bool ride = FALSE; char temp[80] = ""; bool recall = FALSE; u16b why = 0; u16b *who; /* Get a character, or abort */ if (!get_com("Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): ", &sym, FALSE)) return; /* Find that character info, and describe it */ for (i = 0; ident_info[i]; ++i) { if (sym == ident_info[i][0]) break; } /* Describe */ if (sym == KTRL('A')) { all = TRUE; strcpy(buf, "Full monster list."); } else if (sym == KTRL('U')) { all = uniq = TRUE; strcpy(buf, "Unique monster list."); } else if (sym == KTRL('N')) { all = norm = TRUE; strcpy(buf, "Non-unique monster list."); } else if (sym == KTRL('R')) { all = ride = TRUE; strcpy(buf, "Ridable monster list."); } /* XTRA HACK WHATSEARCH */ else if (sym == KTRL('M')) { all = TRUE; if (!get_string("Enter name:",temp, 70)) { temp[0]=0; return; } sprintf(buf, "Monsters with a name \"%s\"",temp); } else if (ident_info[i]) { sprintf(buf, "%c - %s.", sym, ident_info[i] + 2); } else { sprintf(buf, "%c - %s.", sym, "Unknown Symbol"); } /* Display the result */ prt(buf, 0, 0); /* Allocate the "who" array */ C_MAKE(who, max_r_idx, u16b); /* Collect matching monsters */ for (n = 0, i = 1; i < max_r_idx; i++) { monster_race *r_ptr = &r_info[i]; /* Nothing to recall */ if (!(cheat_know || p_ptr->wizard) && !r_ptr->r_sights) continue; /* Require non-unique monsters if needed */ if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue; /* Require unique monsters if needed */ if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue; /* Require ridable monsters if needed */ if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue; /* XTRA HACK WHATSEARCH */ if (temp[0]) { int xx; char temp2[80]; for (xx=0; temp[xx] && xx<80; xx++) { if (isupper(temp[xx])) temp[xx]=tolower(temp[xx]); } strcpy(temp2, r_name+r_ptr->name); for (xx=0; temp2[xx] && xx<80; xx++) if (isupper(temp2[xx])) temp2[xx]=tolower(temp2[xx]); if (my_strstr(temp2, temp)) who[n++]=i; } /* Collect "appropriate" monsters */ else if (all || (r_ptr->d_char == sym)) who[n++] = i; } /* Nothing to recall */ if (!n) { /* Free the "who" array */ C_KILL(who, max_r_idx, u16b); return; } /* Prompt XXX XXX XXX */ put_str("Recall details? (k/y/n): ", 0, 40); /* Query */ query = inkey(); /* Restore */ prt(buf, 0, 0); why = 2; /* Select the sort method */ ang_sort_comp = ang_sort_comp_hook; ang_sort_swap = ang_sort_swap_hook; /* Sort the array */ ang_sort(who, &why, n); /* Sort by kills (and level) */ if (query == 'k') { why = 4; query = 'y'; } /* Catch "escape" */ if (query != 'y') { /* Free the "who" array */ C_KILL(who, max_r_idx, u16b); return; } /* Sort if needed */ if (why == 4) { /* Select the sort method */ ang_sort_comp = ang_sort_comp_hook; ang_sort_swap = ang_sort_swap_hook; /* Sort the array */ ang_sort(who, &why, n); } /* Start at the end */ i = n - 1; /* Scan the monster memory */ while (1) { /* Extract a race */ r_idx = who[i]; /* Hack -- Auto-recall */ monster_race_track(r_idx); /* Hack -- Handle stuff */ handle_stuff(); /* Interact */ while (1) { /* Recall */ if (recall) { /* Save the screen */ screen_save(); /* Recall on screen */ screen_roff(who[i], 0); } /* Hack -- Begin the prompt */ roff_top(r_idx); /* Hack -- Complete the prompt */ Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]"); /* Command */ query = inkey(); /* Unrecall */ if (recall) { /* Restore */ screen_load(); } /* Normal commands */ if (query != 'r') break; /* Toggle recall */ recall = !recall; } /* Stop scanning */ if (query == ESCAPE) break; /* Move to "prev" monster */ if (query == '-') { if (++i == n) { i = 0; if (!expand_list) break; } } /* Move to "next" monster */ else { if (i-- == 0) { i = n - 1; if (!expand_list) break; } } } /* Free the "who" array */ C_KILL(who, max_r_idx, u16b); /* Re-display the identity */ prt(buf, 0, 0); }
/* * research_mon * -KMW- */ bool research_mon(void) { int i, n, r_idx; char sym, query; char buf[128]; s16b oldkills; byte oldwake; bool oldcheat; bool notpicked; bool recall = FALSE; u16b why = 0; monster_race *r2_ptr; u16b *who; #ifdef JP /* XTRA HACK WHATSEARCH */ bool all = FALSE; bool uniq = FALSE; bool norm = FALSE; char temp[80] = ""; /* XTRA HACK REMEMBER_IDX */ static int old_sym = '\0'; static int old_i = 0; #endif oldcheat = cheat_know; /* Save the screen */ screen_save(); /* Get a character, or abort */ #ifdef JP if (!get_com("モンスターの文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^M名前):", &sym)) #else if (!get_com("Enter character of monster: ", &sym)) #endif { /* Restore */ screen_load(); return (FALSE); } /* Allocate the "who" array */ C_MAKE(who, max_r_idx, u16b); /* Find that character info, and describe it */ for (i = 0; ident_info[i]; ++i) { if (sym == ident_info[i][0]) break; } #ifdef JP /* XTRA HACK WHATSEARCH */ if (sym == KTRL('A')) { all = TRUE; strcpy(buf, "全モンスターのリスト"); } else if (sym == KTRL('U')) { all = uniq = TRUE; strcpy(buf, "ユニーク・モンスターのリスト"); } else if (sym == KTRL('N')) { all = norm = TRUE; strcpy(buf, "ユニーク外モンスターのリスト"); } else if (sym == KTRL('M')) { all = TRUE; if (!get_string("名前(英語の場合小文字で可)", temp, 70)) { all = FALSE; temp[0] = 0; } sprintf(buf, "名前:%sにマッチ",temp); } else if (ident_info[i]) { sprintf(buf, "%c - %s.", sym, ident_info[i] + 2); } #else if (ident_info[i]) { sprintf(buf, "%c - %s.", sym, ident_info[i] + 2); } #endif else { #ifdef JP sprintf(buf, "%c - %s", sym, "無効な文字"); #else sprintf(buf, "%c - %s.", sym, "Unknown Symbol"); #endif } /* Display the result */ prt(buf, 16, 10); /* Collect matching monsters */ for (n = 0, i = 1; i < max_r_idx; i++) { monster_race *r_ptr = &r_info[i]; cheat_know = TRUE; #ifdef JP /* XTRA HACK WHATSEARCH */ /* Require non-unique monsters if needed */ if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue; /* Require unique monsters if needed */ if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue; /* 名前検索 */ if (temp[0]){ char temp2[80]; int xx; for (xx=0; temp[xx] && xx<80; xx++){ if (iskanji(temp[xx])) { xx++; continue; } if (isupper(temp[xx])) temp[xx]=tolower(temp[xx]); } strcpy(temp2, r_name+r_ptr->E_name); for (xx=0; temp2[xx] && xx<80; xx++) if (isupper(temp2[xx])) temp2[xx]=tolower(temp2[xx]); if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp) ) who[n++]=i; } else if (all || (r_ptr->d_char == sym)) who[n++] = i; #else /* Collect "appropriate" monsters */ if (r_ptr->d_char == sym) who[n++] = i; #endif } /* Nothing to recall */ if (!n) { cheat_know = oldcheat; /* Free the "who" array */ C_KILL(who, max_r_idx, u16b); /* Restore */ screen_load(); return (FALSE); } /* Sort by level */ why = 2; query = 'y'; /* Sort if needed */ if (why) { /* Select the sort method */ ang_sort_comp = ang_sort_comp_hook; ang_sort_swap = ang_sort_swap_hook; /* Sort the array */ ang_sort(who, &why, n); } /* Start at the end */ #ifdef JP /* XTRA HACK REMEMBER_IDX */ if (old_sym == sym && old_i < n) i = old_i; else i = n - 1; #else i = n - 1; #endif notpicked = TRUE; /* Scan the monster memory */ while (notpicked) { /* Extract a race */ r_idx = who[i]; /* Save this monster ID */ p_ptr->monster_race_idx = r_idx; /* Hack -- Handle stuff */ handle_stuff(); /* Hack -- Begin the prompt */ roff_top(r_idx); /* Hack -- Complete the prompt */ #ifdef JP Term_addstr(-1, TERM_WHITE, " ['r'思い出, ' 'で続行, ESC]"); #else Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC, space to continue]"); #endif /* Interact */ while (1) { /* Recall */ if (recall) { /* Recall on screen */ r2_ptr = &r_info[r_idx]; oldkills = r2_ptr->r_tkills; oldwake = r2_ptr->r_wake; screen_roff(who[i], 1); r2_ptr->r_tkills = oldkills; r2_ptr->r_wake = oldwake; cheat_know = oldcheat; notpicked = FALSE; #ifdef JP /* XTRA HACK REMEMBER_IDX */ old_sym = sym; old_i = i; #endif } /* Command */ query = inkey(); /* Normal commands */ if (query != 'r') break; /* Toggle recall */ recall = !recall; } /* Stop scanning */ if (query == ESCAPE) break; /* Move to "prev" monster */ if (query == '-') { if (++i == n) { i = 0; if (!expand_list) break; } } /* Move to "next" monster */ else { if (i-- == 0) { i = n - 1; if (!expand_list) break; } } } /* Re-display the identity */ /* prt(buf, 5, 5);*/ cheat_know = oldcheat; /* Free the "who" array */ C_KILL(who, max_r_idx, u16b); /* Restore */ screen_load(); return (!notpicked); }
/* * Identify a character, allow recall of monsters * * Several "special" responses recall "multiple" monsters: * ^A (all monsters) * ^U (all unique monsters) * ^N (all non-unique monsters) * * The responses may be sorted in several ways, see below. * * Note that the player ghosts are ignored, since they do not exist. */ void do_cmd_query_symbol(void) { int i, n, r_idx; char buf[128]; struct keypress sym; struct keypress query; bool all = FALSE; bool uniq = FALSE; bool norm = FALSE; bool recall = FALSE; u16b *who; /* Get a character, or abort */ if (!get_com("Enter character to be identified, or control+[ANU]: ", &sym)) return; /* Describe */ if (sym.code == KTRL('A')) { all = TRUE; my_strcpy(buf, "Full monster list.", sizeof(buf)); } else if (sym.code == KTRL('U')) { all = uniq = TRUE; my_strcpy(buf, "Unique monster list.", sizeof(buf)); } else if (sym.code == KTRL('N')) { all = norm = TRUE; my_strcpy(buf, "Non-unique monster list.", sizeof(buf)); } else { lookup_symbol(sym, buf, sizeof(buf)); } /* Display the result */ prt(buf, 0, 0); /* Allocate the "who" array */ who = C_ZNEW(z_info->r_max, u16b); /* Collect matching monsters */ for (n = 0, i = 1; i < z_info->r_max - 1; i++) { monster_race *r_ptr = &r_info[i]; monster_lore *l_ptr = &l_list[i]; /* Nothing to recall */ if (!OPT(cheat_know) && !l_ptr->sights) continue; /* Require non-unique monsters if needed */ if (norm && rf_has(r_ptr->flags, RF_UNIQUE)) continue; /* Require unique monsters if needed */ if (uniq && !rf_has(r_ptr->flags, RF_UNIQUE)) continue; /* Collect "appropriate" monsters */ if (all || (r_ptr->d_char == (char)sym.code)) who[n++] = i; } /* Nothing to recall */ if (!n) { /* XXX XXX Free the "who" array */ FREE(who); return; } /* Buttons */ button_add("[y]", 'y'); button_add("[k]", 'k'); /* Don't collide with the repeat button */ button_add("[n]", 'q'); redraw_stuff(p_ptr); /* Prompt */ put_str("Recall details? (y/k/n): ", 0, 40); /* Query */ query = inkey(); /* Restore */ prt(buf, 0, 0); /* Buttons */ button_kill('y'); button_kill('k'); button_kill('q'); redraw_stuff(p_ptr); /* Interpret the response */ if (query.code == 'k') { /* Sort by kills (and level) */ sort(who, n, sizeof(*who), cmp_pkill); } else if (query.code == 'y' || query.code == 'p') { /* Sort by level; accept 'p' as legacy */ sort(who, n, sizeof(*who), cmp_level); } else { /* Any unsupported response is "nope, no history please" */ /* XXX XXX Free the "who" array */ FREE(who); return; } /* Start at the end */ i = n - 1; /* Button */ button_add("[r]", 'r'); button_add("[-]", '-'); button_add("[+]", '+'); redraw_stuff(p_ptr); /* Scan the monster memory */ while (1) { /* Extract a race */ r_idx = who[i]; /* Hack -- Auto-recall */ monster_race_track(r_idx); /* Hack -- Handle stuff */ handle_stuff(p_ptr); /* Hack -- Begin the prompt */ roff_top(r_idx); /* Hack -- Complete the prompt */ Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]"); /* Interact */ while (1) { /* Recall */ if (recall) { /* Save screen */ screen_save(); /* Recall on screen */ screen_roff(who[i]); /* Hack -- Complete the prompt (again) */ Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]"); } /* Command */ query = inkey(); /* Unrecall */ if (recall) { /* Load screen */ screen_load(); } /* Normal commands */ if (query.code != 'r') break; /* Toggle recall */ recall = !recall; } /* Stop scanning */ if (query.code == ESCAPE) break; /* Move to "prev" monster */ if (query.code == '-') { if (++i == n) i = 0; } /* Move to "next" monster */ else { if (i-- == 0) i = n - 1; } } /* Button */ button_kill('r'); button_kill('-'); button_kill('+'); redraw_stuff(p_ptr); /* Re-display the identity */ prt(buf, 0, 0); /* Free the "who" array */ FREE(who); }