DEADSOFTWARE

menu: improve menu drawing
[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
50 typedef struct new_str_msg_t {
51 byte type;
52 char *s;
53 int maxlen;
54 } new_str_msg_t;
56 typedef struct new_int_msg_t {
57 byte type;
58 int i, a, b, s;
59 } new_int_msg_t;
61 typedef union new_msg_t {
62 byte type;
63 new_str_msg_t string;
64 new_int_msg_t integer;
65 } new_msg_t;
67 typedef struct new_var_t new_var_t;
68 typedef struct new_menu_t new_menu_t;
70 struct new_var_t {
71 byte type;
72 char *caption;
73 void *data;
74 int (*handler)(new_msg_t *msg, const new_menu_t *m, void *data);
75 const new_menu_t *submenu;
76 };
78 struct new_menu_t {
79 byte type;
80 char *title;
81 void *data;
82 int (*handler)(new_msg_t *msg, const new_menu_t *m, void *data);
83 new_var_t entries[];
84 };
86 extern byte _warp;
88 #define GM_MAX_INPUT 24
89 extern char ibuf[GM_MAX_INPUT];
90 extern byte input;
91 extern int icur;
92 extern int imax;
94 extern short lastkey;
96 void GM_push (const new_menu_t *m);
97 void GM_pop (void);
98 void GM_popall (void);
99 const new_menu_t *GM_get (void);
100 int GM_geti (void);
101 int GM_send_this (const new_menu_t *m, new_msg_t *msg);
102 int GM_send (const new_menu_t *m, int i, new_msg_t *msg);
104 void GM_key (int key, int down);
105 void GM_input (int ch);
106 void G_code (void);
107 int GM_act (void);
108 void GM_init (void);
110 #endif /* MENU_H_INCLUDED */