From: Hourier Date: Tue, 9 Jun 2020 13:11:23 +0000 (+0900) Subject: [Refactor] #40014 Separated cmd-lore.c/h from cmd-item.c/h X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=a36d4ca7dc176f524ca67ac185bd4b69aa74bc2d;p=hengband%2Fhengband.git [Refactor] #40014 Separated cmd-lore.c/h from cmd-item.c/h --- diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index 110a834f2..141b456a5 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -168,6 +168,7 @@ + @@ -512,6 +513,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index ce6b9e7f0..d9e08d57a 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -1262,6 +1262,9 @@ view + + cmd-io + @@ -2776,6 +2779,9 @@ view + + cmd-io + diff --git a/src/Makefile.am b/src/Makefile.am index 40e5c325c..4690621bb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -73,6 +73,7 @@ hengband_SOURCES = \ cmd-io/cmd-gameoption.c cmd-io/cmd-gameoption.h \ cmd-io/cmd-help.c cmd-io/cmd-help.h \ cmd-io/cmd-knowledge.c cmd-io/cmd-knowledge.h \ + cmd-io/cmd-lore.c cmd-io/cmd-lore.h \ cmd-io/cmd-macro.c cmd-io/cmd-macro.h \ cmd-io/cmd-menu-content-table.c cmd-io/cmd-menu-content-table.h \ cmd-io/cmd-process-screen.c cmd-io/cmd-process-screen.h \ @@ -548,9 +549,10 @@ COMPILE = $(srcdir)/gcc-wrap $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ -Iart-definition -Iautopick -Ibirth -Icmd -Icmd-io -Icmd-item -Icombat \ -Icore -Idungeon -Ieffect -Ifloor -Igrid -Iinfo-reader -Iinventory -Iio \ -Iio-dump -Iknowledge -Imarket -Imelee -Imind -Imonster -Imonster-attack \ - -Imonster-race -Imspell -Imutation -Iobject -Iobject-enchant -Ipet -Iplayer \ - -Iplayer-attack -Irealm -Iroom -Ispecific-object -Ispell -Ispell-kind \ - -Ispell-realm -Isv-definition -Isystem -Iterm -Iutil -Iview -Iwizard -Iworld + -Imonster-lore -Imonster-race -Imspell -Imutation -Iobject -Iobject-enchant \ + -Ipet -Iplayer -Iplayer-attack -Irealm -Iroom -Ispecific-object -Ispell \ + -Ispell-kind -Ispell-realm -Isv-definition -Isystem -Iterm -Iutil -Iview \ + -Iwizard -Iworld install-exec-hook: if SET_GID diff --git a/src/cmd-io/cmd-lore.c b/src/cmd-io/cmd-lore.c new file mode 100644 index 000000000..6b2a69259 --- /dev/null +++ b/src/cmd-io/cmd-lore.c @@ -0,0 +1,201 @@ +#include "cmd-io/cmd-lore.h" +#include "core/sort.h" +#include "core/stuff-handler.h" +#include "monster-race/race-flags1.h" +#include "monster-race/race-flags7.h" +#include "term/gameterm.h" +#include "term/term-color-types.h" +#include "view/display-main-window.h" +#include "view/display-monster-lore.h" + +/*! + * @brief モンスターの思い出を見るコマンドのメインルーチン + * Identify a character, allow recall of monsters + * @param player_ptr プレーヤーへの参照ポインタ + * @return なし + * @details + *
+ * 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.
+ * 
+ */ +void do_cmd_query_symbol(player_type *creature_ptr) +{ + IDX i; + int n; + MONRACE_IDX 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; + MONRACE_IDX *who; + + if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ", + "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), + &sym, FALSE)) + return; + + for (i = 0; ident_info[i]; ++i) { + if (sym == ident_info[i][0]) + break; + } + + 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.")); + } else if (sym == KTRL('M')) { + all = TRUE; + if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"), temp, 70)) { + temp[0] = 0; + return; + } + sprintf(buf, _("名前:%sにマッチ", "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")); + } + + prt(buf, 0, 0); + C_MAKE(who, max_r_idx, MONRACE_IDX); + for (n = 0, i = 1; i < max_r_idx; i++) { + monster_race *r_ptr = &r_info[i]; + if (!cheat_know && !r_ptr->r_sights) + continue; + + if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) + continue; + + if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) + continue; + + if (ride && !(r_ptr->flags7 & (RF7_RIDING))) + continue; + + if (temp[0]) { + TERM_LEN xx; + char temp2[80]; + + for (xx = 0; temp[xx] && xx < 80; xx++) { +#ifdef JP + if (iskanji(temp[xx])) { + xx++; + continue; + } +#endif + if (isupper(temp[xx])) + temp[xx] = (char)tolower(temp[xx]); + } + +#ifdef JP + strcpy(temp2, r_name + r_ptr->E_name); +#else + strcpy(temp2, r_name + r_ptr->name); +#endif + for (xx = 0; temp2[xx] && xx < 80; xx++) + if (isupper(temp2[xx])) + temp2[xx] = (char)tolower(temp2[xx]); + +#ifdef JP + if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp)) +#else + if (my_strstr(temp2, temp)) +#endif + who[n++] = i; + } + + else if (all || (r_ptr->d_char == sym)) + who[n++] = i; + } + + if (!n) { + C_KILL(who, max_r_idx, MONRACE_IDX); + return; + } + + put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40)); + query = inkey(); + prt(buf, 0, 0); + why = 2; + ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook); + if (query == 'k') { + why = 4; + query = 'y'; + } + + if (query != 'y') { + C_KILL(who, max_r_idx, MONRACE_IDX); + return; + } + + if (why == 4) { + ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook); + } + + i = n - 1; + while (TRUE) { + r_idx = who[i]; + monster_race_track(creature_ptr, r_idx); + handle_stuff(creature_ptr); + while (TRUE) { + if (recall) { + screen_save(); + screen_roff(creature_ptr, who[i], 0); + } + + roff_top(r_idx); + Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]")); + query = inkey(); + if (recall) { + screen_load(); + } + + if (query != 'r') + break; + recall = !recall; + } + + if (query == ESCAPE) + break; + + if (query == '-') { + if (++i == n) { + i = 0; + if (!expand_list) + break; + } + } else { + if (i-- == 0) { + i = n - 1; + if (!expand_list) + break; + } + } + } + + C_KILL(who, max_r_idx, IDX); + prt(buf, 0, 0); +} diff --git a/src/cmd-io/cmd-lore.h b/src/cmd-io/cmd-lore.h new file mode 100644 index 000000000..4a5e2aaa8 --- /dev/null +++ b/src/cmd-io/cmd-lore.h @@ -0,0 +1,5 @@ +#pragma once + +#include "system/angband.h" + +void do_cmd_query_symbol(player_type *creature_ptr); diff --git a/src/cmd-item/cmd-item.c b/src/cmd-item/cmd-item.c index 506b9444a..3c5169d54 100644 --- a/src/cmd-item/cmd-item.c +++ b/src/cmd-item/cmd-item.c @@ -22,7 +22,6 @@ #include "cmd-item/cmd-zaprod.h" #include "cmd-item/cmd-zapwand.h" #include "cmd/cmd-basic.h" -#include "core/sort.h" #include "core/stuff-handler.h" #include "dungeon/quest.h" #include "floor/floor-object.h" @@ -31,8 +30,6 @@ #include "io/targeting.h" #include "main/sound-definitions-table.h" #include "mind/snipe-types.h" -#include "monster-race/race-flags1.h" -#include "monster-race/race-flags7.h" #include "object-enchant/item-feeling.h" #include "object-enchant/object-ego.h" #include "object-enchant/special-object-flags.h" @@ -57,11 +54,8 @@ #include "realm/realm-hex-numbers.h" #include "spell/spells3.h" #include "sv-definition/sv-lite-types.h" -#include "term/gameterm.h" -#include "term/term-color-types.h" #include "util/util.h" #include "view/display-main-window.h" -#include "view/display-monster-lore.h" /*! * @brief 持ち物一覧を表示するコマンドのメインルーチン / Display inventory_list @@ -1195,262 +1189,6 @@ void do_cmd_locate(player_type *creature_ptr) handle_stuff(creature_ptr); } - -/*! - * @brief モンスターの思い出を見るコマンドのメインルーチン - * Identify a character, allow recall of monsters - * @param player_ptr プレーヤーへの参照ポインタ - * @return なし - * @details - *
- * 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. 
- * 
- */ -void do_cmd_query_symbol(player_type *creature_ptr) -{ - IDX i; - int n; - MONRACE_IDX 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; - MONRACE_IDX *who; - - /* Get a character, or abort */ - if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ", - "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; - } - 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, _("名前:%sにマッチ", "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, MONRACE_IDX); - - /* 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 && !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]) - { - TERM_LEN xx; - char temp2[80]; - - for (xx = 0; temp[xx] && xx < 80; xx++) - { -#ifdef JP - if (iskanji(temp[xx])) { xx++; continue; } -#endif - if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]); - } - -#ifdef JP - strcpy(temp2, r_name + r_ptr->E_name); -#else - strcpy(temp2, r_name + r_ptr->name); -#endif - for (xx = 0; temp2[xx] && xx < 80; xx++) - if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]); - -#ifdef JP - if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp)) -#else - if (my_strstr(temp2, temp)) -#endif - who[n++] = i; - } - - /* Collect "appropriate" monsters */ - else if (all || (r_ptr->d_char == sym)) who[n++] = i; - } - - /* Nothing to recall */ - if (!n) - { - C_KILL(who, max_r_idx, MONRACE_IDX); - return; - } - - /* Prompt */ - put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40)); - - /* Query */ - query = inkey(); - prt(buf, 0, 0); - - why = 2; - - /* Sort the array */ - ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook); - - /* Sort by kills (and level) */ - if (query == 'k') - { - why = 4; - query = 'y'; - } - - /* Catch "escape" */ - if (query != 'y') - { - C_KILL(who, max_r_idx, MONRACE_IDX); - return; - } - - /* Sort if needed */ - if (why == 4) - { - ang_sort(who, &why, n, ang_sort_comp_hook, ang_sort_swap_hook); - } - - /* Start at the end */ - i = n - 1; - - /* Scan the monster memory */ - while (TRUE) - { - r_idx = who[i]; - - /* Hack -- Auto-recall */ - monster_race_track(creature_ptr, r_idx); - handle_stuff(creature_ptr); - - /* Interact */ - while (TRUE) - { - if (recall) - { - screen_save(); - - /* Recall on screen */ - screen_roff(creature_ptr, who[i], 0); - } - - /* Hack -- Begin the prompt */ - roff_top(r_idx); - - /* Hack -- Complete the prompt */ - Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]")); - - query = inkey(); - - /* Unrecall */ - if (recall) - { - screen_load(); - } - - /* Normal commands */ - if (query != 'r') break; - - 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, IDX); - - /* Re-display the identity */ - prt(buf, 0, 0); -} - /*! * @brief アイテムを汎用的に「使う」コマンドのメインルーチン / * Use an item @@ -1527,4 +1265,3 @@ void do_cmd_use(player_type *creature_ptr) break; } } - diff --git a/src/cmd-item/cmd-item.h b/src/cmd-item/cmd-item.h index deb5a0bee..4855d8b21 100644 --- a/src/cmd-item/cmd-item.h +++ b/src/cmd-item/cmd-item.h @@ -15,5 +15,4 @@ void do_cmd_refill(player_type *creature_ptr); void do_cmd_target(player_type *creature_ptr); void do_cmd_look(player_type *creature_ptr); void do_cmd_locate(player_type *creature_ptr); -void do_cmd_query_symbol(player_type *creature_ptr); void do_cmd_use(player_type *creature_ptr); diff --git a/src/io/input-key-processor.c b/src/io/input-key-processor.c index 049e2f402..deff6f5ad 100644 --- a/src/io/input-key-processor.c +++ b/src/io/input-key-processor.c @@ -17,6 +17,7 @@ #include "cmd-io/cmd-dump.h" #include "cmd-io/cmd-help.h" #include "cmd-io/cmd-knowledge.h" +#include "cmd-io/cmd-lore.h" #include "cmd-io/cmd-macro.h" #include "cmd-io/cmd-process-screen.h" #include "cmd-io/cmd-save.h" diff --git a/src/store/store.c b/src/store/store.c index 1e394fb1b..17bc7dcdd 100644 --- a/src/store/store.c +++ b/src/store/store.c @@ -18,6 +18,7 @@ #include "cmd-io/cmd-dump.h" #include "cmd-io/cmd-help.h" #include "cmd-io/cmd-knowledge.h" +#include "cmd-io/cmd-lore.h" #include "cmd-io/cmd-macro.h" #include "cmd-io/cmd-process-screen.h" #include "cmd-item/cmd-item.h"