86 lines
1.2 KiB
C
86 lines
1.2 KiB
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <stdbool.h>
|
|
#include <math.h>
|
|
|
|
#include <raylib.h>
|
|
#include <raymath.h>
|
|
|
|
#include "types.h"
|
|
|
|
#pragma once
|
|
|
|
#define WIDGET_N 16
|
|
#define MOUSE_BUTTON_NULL 7
|
|
|
|
enum CaptureFlags {
|
|
CF_None = 0x0,
|
|
CF_Mouse = 0x2, //Mouse clicks
|
|
CF_Keyb = 0x4
|
|
};
|
|
|
|
enum EventTypes {
|
|
EV_None = 0,
|
|
EV_Mouse = 1,
|
|
EV_Keyb = 2
|
|
};
|
|
|
|
typedef struct {
|
|
|
|
int type;
|
|
union {
|
|
int key;
|
|
int click;
|
|
};
|
|
V2d pos;
|
|
|
|
} MTEvent;
|
|
|
|
struct Widget;
|
|
|
|
typedef void (widget_filler_t)(struct Widget*, Game*);
|
|
typedef void (widget_event_t)(struct Widget*, Game*, MTEvent);
|
|
typedef void (button_handler_t)(Game *);
|
|
|
|
typedef struct {
|
|
|
|
Rectangle box;
|
|
Color color_0; // Fill
|
|
Color color_1; // Outline
|
|
Color color_txt;
|
|
char *txt;
|
|
bool curr_select;
|
|
button_handler_t *handler;
|
|
|
|
} Button;
|
|
|
|
typedef struct Widget {
|
|
|
|
Rectangle box;
|
|
widget_filler_t *draw;
|
|
widget_event_t *do_event;
|
|
int capt_flags;
|
|
Button buttons[10];
|
|
int button_n;
|
|
|
|
} Widget;
|
|
|
|
typedef struct {
|
|
|
|
Widget *widgets[WIDGET_N];
|
|
bool widget_active[WIDGET_N];
|
|
|
|
float *zoom;
|
|
|
|
} GUIInfo;
|
|
|
|
void init_ui();
|
|
|
|
void draw_widgets(Game *game);
|
|
|
|
// World pos
|
|
void try_interface(Game *game, V2d pos);
|
|
|
|
void get_keys(Game *game);
|