OSDN Git Service

日本語版
[nazghul-jp/nazghul-jp.git] / src / cmd.h
1 //
2 // nazghul - an old-school RPG engine
3 // Copyright (C) 2002, 2003 Gordon McNutt
4 //
5 // This program is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by the Free
7 // Software Foundation; either version 2 of the License, or (at your option)
8 // any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13 // more details.
14 //
15 // You should have received a copy of the GNU General Public License along with
16 // this program; if not, write to the Free Foundation, Inc., 59 Temple Place,
17 // Suite 330, Boston, MA 02111-1307 USA
18 //
19 // Gordon McNutt
20 // gmcnutt@users.sourceforge.net
21 //
22 #ifndef cmd_h
23 #define cmd_h
24
25 #include "macros.h"
26 #include "event.h" /* for v_funcpointer_ii */
27
28 #define MIN_XAMINE_LIGHT_LEVEL 32
29
30 class Character;
31 class Object;
32 class Party;
33
34 BEGIN_DECL;
35
36 // I really shouldn't pollute this interface with these, but they don't really
37 // fit anywhere else right now, either.
38 #include "status.h"
39 struct ScrollerContext {
40         enum StatusSelection selector;
41         const void *selection;
42         bool abort;
43         bool done;
44         bool mixing; // for mix reagents
45 };
46
47 /**
48  * Request format for select_target_generic().
49  */
50 typedef struct ui_select_target_req 
51 {
52         struct place *place;   /* place this is happening in       */
53         int x1, y1;            /* center of target zone            */
54         int x2, y2;            /* initial/final cursor position    */
55         struct templ *tiles;   /* template of tiles in target zone */
56         struct list suggest;   /* quick-target tiles               */
57         void *data;            /* caller context                   */
58
59         /* called when the cursor moves over a new tile */
60         void (*move)(struct place *, int, int, void *);
61
62         /* Called when user hits 'enter' or otherwise selects a tile. Returns
63          * non-zero to end the targeting session, zero otherwise. */
64         int (*select)(struct place *, int, int, void *);
65
66 } ui_select_target_req_t;
67
68 #define SCROLLER_HINT "\005\006=ÁªÂò ENT=·èÄê ESC=Ìá¤ë"
69 #define PAGER_HINT  "\005\006=ɽ¼¨ ESC=Ìá¤ë"
70
71 extern int dirkey(struct KeyHandler *kh, int key, int keymod);
72 extern int cardinaldirkey(struct KeyHandler *kh, int key, int keymod);
73 extern int yesnokey(struct KeyHandler *kh, int key, int keymod);
74 extern int anykey(struct KeyHandler *kh, int key, int keymod);
75 extern int scroller(struct KeyHandler *kh, int key, int keymod);
76 extern int movecursor(struct KeyHandler *kh, int key, int keymod);
77 extern int getnum(struct KeyHandler *kh, int key, int keymod);
78 extern void getkey(void *data, int(*handler) (struct KeyHandler * kh,
79                                                int key, int keymod));
80 #define CMD_SELECT_MEMBER (1 << 0)
81 #define CMD_PRINT_MEMBER  (1 << 1)
82   
83 extern void cmdAttack(void);
84 extern int cmd_camp_in_town(class Character *camper);
85 extern int cmd_camp_in_wilderness(class Party *camper);
86 extern void cmdFire(void);
87 extern void cmdHelp(void);
88 extern void cmdLoiter(class Being *subject);
89 extern bool cmdMixReagents(class Character *mixer);
90 extern void cmdNewOrder(void);
91 extern bool cmdSave(void);
92 extern void cmdReload(void);
93 extern bool cmdSearch(class Character *pc);
94 extern void cmdTalk(Object *member);
95 extern void cmdZoomIn(void);
96 extern bool cmdUse(class Character * pc, int flags);
97 extern bool cmdHandle(class Character * pc);
98 extern bool cmdReady(class Character * pc);
99 extern bool cmdZtats(class Character * pc);
100 extern bool cmdXamine (class Object *examiner);
101 extern bool cmdAT(class Character * pc);
102 extern bool cmdGet(class Object *actor);
103 extern bool cmdOpen(class Character * pc);
104 extern bool cmdCastSpell(class Character * pc);
105 extern bool cmdQuit(void);
106 extern bool cmdLook(int x, int y);
107 extern bool cmd_terraform(struct place *place, int x, int y);
108 extern bool cmd_save_current_place (struct place * place);
109 extern bool cmdSaveTerrainMap(class Character * pc);
110 extern bool cmdSetSoloMode(int party_member_index);
111 extern bool cmdToggleFollowMode(void);
112 extern void cmdSettings(void);
113 extern void cmdDrop(class Character *pc);
114 extern void cmdYuse(class Character *pc);
115 extern void cmdDeveloperEval(struct session *);
116   
117 extern class Character *select_party_member(void);
118     
119 struct location_list {
120         struct list list;
121         int x;
122         int y;
123 };
124
125 extern int select_target(int ox, int oy, int *x, int *y, int range, 
126                          struct list *suggest);
127
128 extern const char * name_of_context (void);
129
130 extern int ui_get_quantity(int max);
131   
132 // the new ui api
133 extern int ui_get_direction(void);
134 extern int ui_get_yes_no(const char *asked_persons_name);
135 extern int ui_getline(char *buf, int len);
136 extern int ui_getline_plain(char *buf, int len);
137 extern void ui_name_vehicle(class Vehicle *vehicle);
138
139 /**
140  * The merchant information for a trading session.
141  */
142 struct merchant {
143         const char *name;                /* The merchant's name */
144         int n_trades;              /* Num entries in the array of items */
145         struct trade_info *trades; /* The array of trade items */
146 };
147
148 /**
149  * These three functions all engage in the trading UI with a merchant. ui_trade
150  * will allow the player to choose between buying and selling, and will call
151  * the other two functions.
152  *
153  * @param merch is the merchant info
154  * @returns the quantity of items traded
155  */
156 extern int ui_trade(struct merchant *merch);
157 extern int ui_buy(struct merchant *merch);
158 extern int ui_sell(struct merchant *merch);
159
160 /**
161  * Prompt the player to enter a line. By default (no filter provided) this will
162  * accept all printable characters as valid input from the player. Especially
163  * the ESC, '\n' and '\b' characters are taken to mean control characters and
164  * aren't considered printable.
165  *
166  * @param buf The string buffer to fill with the response. On success this
167  * contains a null-terminated string. The NULL will be there, and the buffer
168  * length will not be exceeded. The user reply will be truncated if necessary.
169  *
170  * @param len The length of buf.
171  *
172  * @param filter An optional filter function. This function should return
173  * non-zero to reject a key. Note that all non-printable characters are already
174  * filtered automatically; this param let's you filter even more. The filter is
175  * applied after checking for ESC, '\n' and '\b', which are processed as
176  * control characters and never appear in the result anyway.
177  *
178  * @returns The actual number of characters stored. Note that if the player
179  * hits ESC this will be zero as if no keys were pressed.
180  */
181 extern int ui_getline_filtered(char *buf, int len, int (*filter)(int key));
182
183 /**
184  * More general version of select_target(). Prompts the player to select a tile
185  * within a range or template of tiles.
186  *
187  * @parm req tells the function how to carry out its business.
188  *
189  * @returns zero iff the (x2, y2) fields of the req hold the player-selected
190  * target location. The only time it won't is if the player aborts the prompt.
191  */
192 extern int ui_select_target_generic(ui_select_target_req_t *req);
193
194 /**
195  * Initialize a target request to safe defaults. Note that this is for a new
196  * request, if you try to re-init without doing some manual cleanup first
197  * you'll get a memory leak.
198  *
199  * @parm req will be initialized.
200  */
201 extern void ui_select_target_req_init(ui_select_target_req_t *req);
202
203 /**
204  * Prompt the player to select something from inventory. This assumes that the
205  * status mode has already been set by the caller.
206  */
207 extern struct inv_entry *ui_select_item(void);
208
209 END_DECL;
210
211 #endif