DEADSOFTWARE

daee0d78d871520bc6dcf4dc4ba2cbf13cb0eda6
[flatwaifu.git] / src / menu.h
1 /*
2 Copyright (C) Prikol Software 1996-1997
3 Copyright (C) Aleksey Volynskov 1996-1997
5 This file is part of the Doom2D:Rembo project.
7 Doom2D:Rembo is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation.
11 Doom2D:Rembo is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/> or
18 write to the Free Software Foundation, Inc.,
19 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
22 #ifndef MENU_H_INCLUDED
23 #define MENU_H_INCLUDED
25 #include "glob.h"
27 /* menu types */
28 #define GM_BIG 1
29 #define GM_SMALL 2
31 /* variant types */
32 #define GM_BUTTON 1
33 #define GM_SCROLLER 2
34 #define GM_TEXTFIELD 3
35 #define GM_SMALL_BUTTON 4
36 #define GM_TEXTFIELD_BUTTON 5
38 /* menu messages */
39 #define GM_GETINT 1
40 #define GM_SETINT 2
41 #define GM_GETSTR 3
42 #define GM_SETSTR 4
43 #define GM_SELECT 5 // buttons
44 #define GM_ENTER 6 // menu
45 #define GM_LEAVE 7 // menu
46 #define GM_BEGIN 8 // textfield
47 #define GM_END 9 // textfield
48 #define GM_CANCEL 10 // textfield
49 #define GM_QUERY 11 // menu
50 #define GM_GETTITLE 12 // menu
51 #define GM_GETENTRY 13 // entry
52 #define GM_GETCAPTION 14 // entry
53 #define GM_UP 15
54 #define GM_DOWN 16
56 typedef struct menu_str_msg_t {
57 byte type;
58 char *s;
59 int maxlen;
60 } menu_str_msg_t;
62 typedef struct menu_int_msg_t {
63 byte type;
64 int i, a, b, s;
65 } menu_int_msg_t;
67 typedef union menu_msg_t {
68 byte type;
69 menu_str_msg_t string;
70 menu_int_msg_t integer;
71 } menu_msg_t;
73 typedef struct menu_t menu_t;
74 struct menu_t {
75 int (*handler)(menu_msg_t *msg, const menu_t *m, int i);
76 };
78 typedef struct simple_menu_t {
79 byte type;
80 char *title;
81 char *say;
82 struct simple_entry_t {
83 char *caption;
84 const menu_t *submenu;
85 } entries[];
86 } simple_menu_t;
88 extern byte _warp;
90 #define GM_MAX_INPUT 24
91 extern char ibuf[GM_MAX_INPUT];
92 extern byte input;
93 extern int icur;
94 extern int imax;
96 extern short lastkey;
98 #define GM_INIT_STRING(msg, str) GM_init_str(msg, str, sizeof str);
99 #define GM_CYCLE(i, m, n) ((i) < (m) ? (n) : (((i) > (n)) ? (m) : (i)))
100 int GM_init_int0 (menu_msg_t *msg, int i, int a, int b, int s);
101 int GM_init_int (menu_msg_t *msg, int i, int a, int b, int s);
102 int GM_init_str (menu_msg_t *msg, char *str, int maxlen);
103 int basic_menu_handler (menu_msg_t *msg, byte type, char *title, char *say, int n, int *cur);
104 int simple_menu_handler (menu_msg_t *msg, int i, int n, const simple_menu_t *m, int *cur);
106 int GM_push (const menu_t *m);
107 int GM_pop (void);
108 int GM_popall (void);
109 const menu_t *GM_get (void);
110 int GM_send_this (const menu_t *m, menu_msg_t *msg);
111 int GM_send (const menu_t *m, int i, menu_msg_t *msg);
113 void GM_key (int key, int down);
114 void GM_input (int ch);
115 void G_code (void);
116 int GM_act (void);
117 void GM_init (void);
119 #endif /* MENU_H_INCLUDED */