DEADSOFTWARE

update copyrights
[flatwaifu.git] / src / menu.h
index ed4a5e994f39d24090f8393b14864ec87adaff00..8431ee484597f6f860fdd22c0e14ad4f6e7b3adb 100644 (file)
-/*
-   Copyright (C) Prikol Software 1996-1997
-   Copyright (C) Aleksey Volynskov 1996-1997
+/* Copyright (C) 2020 SovietPony
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License ONLY.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef MENU_H_INCLUDED
+#define MENU_H_INCLUDED
 
-   This file is part of the Doom2D:Rembo project.
+#include "glob.h"
 
-   Doom2D:Rembo is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License version 2 as
-   published by the Free Software Foundation.
+/* menu types */
+#define GM_BIG 1
+#define GM_SMALL 2
 
-   Doom2D:Rembo is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
+/* variant types */
+#define GM_BUTTON 1
+#define GM_SCROLLER 2
+#define GM_TEXTFIELD 3
+#define GM_SMALL_BUTTON 4
+#define GM_TEXTFIELD_BUTTON 5
 
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, see <http://www.gnu.org/licenses/> or
-   write to the Free Software Foundation, Inc.,
-   51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
-*/
+/* menu messages */
+#define GM_GETINT 1
+#define GM_SETINT 2
+#define GM_GETSTR 3
+#define GM_SETSTR 4
+#define GM_SELECT 5 // buttons
+#define GM_ENTER  6 // menu
+#define GM_LEAVE  7 // menu
+#define GM_BEGIN  8 // textfield
+#define GM_END    9 // textfield
+#define GM_CANCEL 10 // textfield
+#define GM_QUERY  11 // menu
+#define GM_GETTITLE 12 // menu
+#define GM_GETENTRY 13 // entry
+#define GM_GETCAPTION 14 // entry
+#define GM_UP 15
+#define GM_DOWN 16
 
-// Game menus
+typedef struct menu_str_msg_t {
+  byte type;
+  char *s;
+  int maxlen;
+} menu_str_msg_t;
 
-typedef struct{
+typedef struct menu_int_msg_t {
   byte type;
-  int n,cur,x;
-  char *ttl;
-  char **m;
-  byte *t;
-}menu_t;
+  int i, a, b, s;
+} menu_int_msg_t;
 
-extern menu_t save_mnu;
+typedef union menu_msg_t {
+  byte type;
+  menu_str_msg_t string;
+  menu_int_msg_t integer;
+} menu_msg_t;
 
-extern byte *panimp;
+typedef struct menu_t menu_t;
+struct menu_t {
+  int (*handler)(menu_msg_t *msg, const menu_t *m, int i);
+};
 
-#define PCOLORN 10
-extern byte pcolortab[PCOLORN];
-extern int p1color;
-extern int p2color;
+typedef struct simple_menu_t {
+  byte type;
+  char *title;
+  char *say;
+  struct simple_entry_t {
+    char *caption;
+    const menu_t *submenu;
+  } entries[];
+} simple_menu_t;
 
-extern char ibuf[24];
+extern byte _warp;
+
+#define GM_MAX_INPUT 24
+extern char ibuf[GM_MAX_INPUT];
 extern byte input;
+extern int icur;
+extern int imax;
+
+extern short lastkey;
 
-extern menu_t *mnu;
-extern byte gm_redraw;
+#define GM_INIT_STRING(msg, str) GM_init_str(msg, str, sizeof str);
+#define GM_CYCLE(i, m, n) ((i) < (m) ? (n) : (((i) > (n)) ? (m) : (i)))
+int GM_init_int0 (menu_msg_t *msg, int i, int a, int b, int s);
+int GM_init_int (menu_msg_t *msg, int i, int a, int b, int s);
+int GM_init_str (menu_msg_t *msg, char *str, int maxlen);
+int basic_menu_handler (menu_msg_t *msg, byte type, char *title, char *say, int n, int *cur);
+int simple_menu_handler (menu_msg_t *msg, int i, int n, const simple_menu_t *m, int *cur);
 
-void GMV_say(char *);
-void GMV_stop(void);
+int GM_push (const menu_t *m);
+int GM_pop (void);
+int GM_popall (void);
+const menu_t *GM_get (void);
+int GM_send_this (const menu_t *m, menu_msg_t *msg);
+int GM_send (const menu_t *m, int i, menu_msg_t *msg);
 
-void GM_init(void);
-int GM_act(void);
+void GM_key (int key, int down);
+void GM_input (int ch);
+void G_code (void);
+int GM_act (void);
+void GM_init (void);
 
-void G_code(void);
+#endif /* MENU_H_INCLUDED */