OSDN Git Service

[Refactor] #1479 Changed creature_ptr to player_ptr
[hengbandforosx/hengbandosx.git] / src / cmd-io / cmd-floor.cpp
1 #include "cmd-io/cmd-floor.h"
2 #include "core/asking-player.h"
3 #include "core/player-redraw-types.h"
4 #include "core/player-update-types.h"
5 #include "core/stuff-handler.h"
6 #include "core/window-redrawer.h"
7 #include "floor/geometry.h"
8 #include "game-option/keymap-directory-getter.h"
9 #include "io/cursor.h"
10 #include "io/screen-util.h"
11 #include "main/sound-of-music.h"
12 #include "system/player-type-definition.h"
13 #include "target/target-checker.h"
14 #include "target/target-setter.h"
15 #include "target/target-types.h"
16 #include "util/bit-flags-calculator.h"
17 #include "view/display-messages.h"
18 #include "window/main-window-util.h"
19
20 /*!
21  * @brief ターゲットを設定するコマンドのメインルーチン
22  * Target command
23  */
24 void do_cmd_target(player_type *player_ptr)
25 {
26     if (player_ptr->wild_mode)
27         return;
28
29     if (target_set(player_ptr, TARGET_KILL))
30         msg_print(_("ターゲット決定。", "Target Selected."));
31     else
32         msg_print(_("ターゲット解除。", "Target Aborted."));
33 }
34
35 /*!
36  * @brief 周囲を見渡すコマンドのメインルーチン
37  * Look command
38  */
39 void do_cmd_look(player_type *player_ptr)
40 {
41     set_bits(player_ptr->window_flags, PW_MONSTER_LIST | PW_FLOOR_ITEM_LIST);
42     handle_stuff(player_ptr);
43     if (target_set(player_ptr, TARGET_LOOK))
44         msg_print(_("ターゲット決定。", "Target Selected."));
45 }
46
47 /*!
48  * @brief 位置を確認するコマンドのメインルーチン
49  * Allow the player to examine other sectors on the map
50  */
51 void do_cmd_locate(player_type *player_ptr)
52 {
53     DIRECTION dir;
54     POSITION y1, x1;
55     GAME_TEXT tmp_val[80];
56     GAME_TEXT out_val[MAX_MONSTER_NAME];
57     TERM_LEN wid, hgt;
58     get_screen_size(&wid, &hgt);
59     POSITION y2 = y1 = panel_row_min;
60     POSITION x2 = x1 = panel_col_min;
61     while (true) {
62         if ((y2 == y1) && (x2 == x1))
63             strcpy(tmp_val, _("真上", "\0"));
64         else
65             sprintf(tmp_val, "%s%s", ((y2 < y1) ? _("北", " North") : (y2 > y1) ? _("南", " South") : ""),
66                 ((x2 < x1) ? _("西", " West") : (x2 > x1) ? _("東", " East") : ""));
67
68         sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s)  方向?", "Map sector [%d(%02d),%d(%02d)], which is%s your sector.  Direction?"),
69             y2 / (hgt / 2), y2 % (hgt / 2), x2 / (wid / 2), x2 % (wid / 2), tmp_val);
70
71         dir = 0;
72         while (!dir) {
73             char command;
74             if (!get_com(out_val, &command, true))
75                 break;
76
77             dir = get_keymap_dir(command);
78             if (!dir)
79                 bell();
80         }
81
82         if (!dir)
83             break;
84
85         if (change_panel(player_ptr, ddy[dir], ddx[dir])) {
86             y2 = panel_row_min;
87             x2 = panel_col_min;
88         }
89     }
90
91     verify_panel(player_ptr);
92     player_ptr->update |= PU_MONSTERS;
93     player_ptr->redraw |= PR_MAP;
94     player_ptr->window_flags |= PW_OVERHEAD | PW_DUNGEON;
95     handle_stuff(player_ptr);
96 }