1 #include "term/gameterm.h"
2 #include "effect/attribute-types.h"
3 #include "system/system-variables.h"
4 #include "term/term-color-types.h"
5 #include "util/quarks.h"
6 #include "util/string-processor.h"
10 * Convert an "attr"/"char" pair into a "pict" (P)
12 #define PICT(A, C) ((((uint16_t)(A)) << 8) | ((byte)(C)))
15 * Standard window names
17 const char angband_term_name[8][16] = {
29 * Global table of color definitions
31 byte angband_color_table[256][4] = {
32 { 0x00, 0x00, 0x00, 0x00 }, /* TERM_DARK */
33 { 0x00, 0xFF, 0xFF, 0xFF }, /* TERM_WHITE */
34 { 0x00, 0x80, 0x80, 0x80 }, /* TERM_SLATE */
35 { 0x00, 0xFF, 0x80, 0x00 }, /* TERM_ORANGE */
36 { 0x00, 0xC0, 0x00, 0x00 }, /* TERM_RED */
37 { 0x00, 0x00, 0x80, 0x40 }, /* TERM_GREEN */
38 { 0x00, 0x00, 0x80, 0xFF }, /* TERM_BLUE */
39 { 0x00, 0x80, 0x40, 0x00 }, /* TERM_UMBER */
40 { 0x00, 0x40, 0x40, 0x40 }, /* TERM_L_DARK */
41 { 0x00, 0xC0, 0xC0, 0xC0 }, /* TERM_L_WHITE */
42 { 0x00, 0xFF, 0x00, 0xFF }, /* TERM_VIOLET */
43 { 0x00, 0xFF, 0xFF, 0x00 }, /* TERM_YELLOW */
44 { 0x00, 0xFF, 0x00, 0x00 }, /* TERM_L_RED */
45 { 0x00, 0x00, 0xFF, 0x00 }, /* TERM_L_GREEN */
46 { 0x00, 0x00, 0xFF, 0xFF }, /* TERM_L_BLUE */
47 { 0x00, 0xC0, 0x80, 0x40 } /* TERM_L_UMBER */
51 * @brief 色名称テーブル / Hack -- the "basic" color names (see "TERM_xxx")
53 const concptr color_names[16] = {
92 * @brief サブウィンドウ名称テーブル
95 * Certain "screens" always use the main screen, including News, Birth,
96 * Dungeon, Tomb-stone, High-scores, Macros, Colors, Visuals, Options.
98 * Later, special flags may allow sub-windows to "steal" stuff from the
99 * main window, including File dump (help), File dump (artifacts, uniques),
100 * Character screen, Small scale map, Previous Messages, Store screen, etc.
102 * The "ctrl-i" (tab) command flips the "Display inven/equip" and "Display
103 * equip/inven" flags for all windows.
105 * The "ctrl-g" command (or pseudo-command) should perhaps grab a snapshot
106 * of the main screen into any interested windows.
109 const concptr window_flag_desc[32] = {
110 _("持ち物/装備一覧", "Display inven/equip"),
111 _("装備/持ち物一覧", "Display equip/inven"),
112 _("呪文一覧", "Display spell list"),
113 _("キャラクタ情報", "Display character"),
114 _("視界内のモンスター表示", "Display monsters in sight"),
115 _("ペット一覧", "Display pets"),
116 _("メッセージ", "Display messages"),
117 _("ダンジョン全体図", "Display overhead view"),
118 _("モンスターの思い出", "Display monster recall"),
119 _("アイテムの詳細", "Display object recall"),
120 _("自分の周囲を表示", "Display dungeon view"),
121 _("記念撮影", "Display snap-shot"),
122 _("足元/床上のアイテム一覧", "Display items on grid"),
123 _("発見済みのアイテム一覧", "Display found items"),
145 * @brief シンボル解説テーブル /
146 * The table of "symbol info" -- each entry is a string of the form "X:desc" where "X" is the trigger, and "desc" is the "info".
148 const concptr ident_info[] = {
160 "*:財宝を含んだ鉱脈または球形の怪物",
165 "/:竿状武器(アックス/パイク/等)",
243 "}:飛び道具(弓/クロスボウ/スリング)",
247 "!:A potion (or oil)",
248 "\":An amulet (or necklace)",
249 "#:A wall (or secret door) / a plant / a gas",
250 "$:Treasure (gold or gems)",
251 "%:A vein (magma or quartz)",
256 "*:A vein with treasure or a ball monster",
258 ",:Food (or mushroom patch)",
261 "/:A polearm (Axe/Pike/etc)",
262 "0:Entrance to the Museum",
263 "1:Entrance to the General Store",
264 "2:Entrance to the Armoury",
265 "3:Entrance to the Weaponsmith's Shop",
266 "4:Entrance to the Temple",
267 "5:Entrance to the Alchemy Shop",
268 "6:Entrance to the Magic Shop",
269 "7:Entrance to the Black Market",
270 "8:Entrance to your home",
271 "9:Entrance to the Bookstore",
273 ";:A rune of protection / an explosive rune",
276 ">:A down staircase",
282 "D:Ancient Dragon/Wyrm",
291 "M:Multi-Headed Reptile",
295 "Q:Quylthulg (Pulsing Flesh Mound)",
296 "R:Reptile/Amphibian",
297 "S:Spider/Scorpion/Tick",
301 "W:Wight/Wraith/etc",
306 "\\:A hafted weapon (mace/whip/etc)",
310 "`:A figurine or statue",
318 "h:Hobbit/Elf/Dwarf",
337 "{:A missile (arrow/bolt/shot)",
338 "|:An edged weapon (sword/dagger/etc)",
339 "}:A launcher (bow/crossbow/sling)",
340 "~:Fluid terrain (or miscellaneous item)",
347 * The array of window pointers
349 std::array<term_type *, 8> angband_terms;
353 * Encode the screen colors
355 static const concptr color_char = "dwsorgbuDWvyRGBU";
358 * Specify attr/char pairs for visual special effects
359 * Be sure to use "index & 0x7F" to avoid illegal access
361 TERM_COLOR misc_to_attr[256];
362 char misc_to_char[256];
365 * Specify attr/char pairs for inventory items (by tval)
366 * Be sure to use "index & 0x7F" to avoid illegal access
368 TERM_COLOR tval_to_attr[128];
371 * Default spell color table
373 std::map<AttributeType, std::string> gf_colors;
376 * @brief 万色表現用にランダムな色を選択する関数 /
377 * Get a legal "multi-hued" color for drawing "spells"
381 static TERM_COLOR mh_attr(int max)
383 constexpr static auto colors = {
401 std::span<const term_color_type> candidates(colors.begin(), max);
402 return rand_choice(candidates);
406 * @brief 魔法属性に応じたエフェクトの色を返す /
407 * Return a color to use for the bolt/ball spells
411 static TERM_COLOR spell_color(AttributeType type)
413 /* Check if A.B.'s new graphics should be used (rr9) */
414 if (streq(ANGBAND_GRAF, "new") || streq(ANGBAND_GRAF, "ne2")) {
417 case AttributeType::PSY_SPEAR:
419 case AttributeType::MISSILE:
421 case AttributeType::ACID:
423 case AttributeType::ELEC:
425 case AttributeType::FIRE:
427 case AttributeType::COLD:
429 case AttributeType::POIS:
431 case AttributeType::HOLY_FIRE:
433 case AttributeType::HELL_FIRE:
435 case AttributeType::MANA:
438 case AttributeType::SEEKER:
440 case AttributeType::SUPER_RAY:
443 case AttributeType::DEBUG:
445 case AttributeType::WATER:
447 case AttributeType::NETHER:
449 case AttributeType::CHAOS:
451 case AttributeType::DISENCHANT:
453 case AttributeType::NEXUS:
455 case AttributeType::CONFUSION:
457 case AttributeType::SOUND:
459 case AttributeType::SHARDS:
461 case AttributeType::FORCE:
463 case AttributeType::INERTIAL:
465 case AttributeType::GRAVITY:
467 case AttributeType::TIME:
469 case AttributeType::LITE_WEAK:
471 case AttributeType::LITE:
473 case AttributeType::DARK_WEAK:
475 case AttributeType::DARK:
477 case AttributeType::PLASMA:
479 case AttributeType::METEOR:
481 case AttributeType::ICE:
483 case AttributeType::ROCKET:
485 case AttributeType::DEATH_RAY:
487 case AttributeType::NUKE:
489 case AttributeType::DISINTEGRATE:
491 case AttributeType::PSI:
492 case AttributeType::PSI_DRAIN:
493 case AttributeType::TELEKINESIS:
494 case AttributeType::DOMINATION:
495 case AttributeType::DRAIN_MANA:
496 case AttributeType::MIND_BLAST:
497 case AttributeType::BRAIN_SMASH:
499 case AttributeType::CAUSE_1:
500 case AttributeType::CAUSE_2:
501 case AttributeType::CAUSE_3:
502 case AttributeType::CAUSE_4:
504 case AttributeType::HAND_DOOM:
506 case AttributeType::CAPTURE:
508 case AttributeType::IDENTIFY:
510 case AttributeType::ATTACK:
512 case AttributeType::PHOTO:
518 /* Normal tiles or ASCII */
522 /* Lookup the default colors for this type */
523 const auto &color = gf_colors[type];
529 /* Pick a random color */
530 auto c = rand_choice(color);
532 /* Lookup this color */
533 a = angband_strchr(color_char, c) - color_char;
535 /* Invalid color (note check for < 0 removed, gave a silly
536 * warning because bytes are always >= 0 -- RG) */
545 /* Standard "color" */
550 * @brief 始点から終点にかけた方向毎にボルトのキャラクタを返す /
551 * Find the attr/char pair to use for a spell effect
560 * It is moving (or has moved) from (x,y) to (nx,ny).
561 * If the distance is not "one", we (may) return "*".
564 std::pair<TERM_COLOR, char> bolt_pict(POSITION y, POSITION x, POSITION ny, POSITION nx, AttributeType typ)
573 if ((ny == y) && (nx == x)) {
588 else if ((ny - y) == (x - nx)) {
593 else if ((ny - y) == (nx - x)) {
602 /* Basic spell color */
603 k = spell_color(typ);
605 /* Obtain attr/char */
606 a = misc_to_attr[base + k];
607 auto c = misc_to_char[base + k];
614 * @brief シンボル1文字をカラーIDに変更する /
615 * Convert a "color letter" into an "actual" color
616 * The colors are: dwsorgbuDWvyRGBU, as shown below
620 TERM_COLOR color_char_to_attr(char c)