| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#pragma once |
| 29 |
|
| 30 |
#include <SDL_opengl.h> |
| 31 |
#define NK_INCLUDE_FIXED_TYPES |
| 32 |
#define NK_INCLUDE_STANDARD_IO |
| 33 |
#define NK_INCLUDE_DEFAULT_ALLOCATOR |
| 34 |
#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT |
| 35 |
#define NK_INCLUDE_FONT_BAKING |
| 36 |
#define NK_INCLUDE_DEFAULT_FONT |
| 37 |
#define NK_BUTTON_TRIGGER_ON_RELEASE |
| 38 |
#ifdef _MSC_VER |
| 39 |
|
| 40 |
#pragma warning(push) |
| 41 |
#pragma warning(disable : 4127) |
| 42 |
#endif |
| 43 |
#include <nuklear/nuklear.h> |
| 44 |
#ifdef _MSC_VER |
| 45 |
#pragma warning(pop) |
| 46 |
#endif |
| 47 |
|
| 48 |
#include <cdogs/animation.h> |
| 49 |
#include <cdogs/character.h> |
| 50 |
#include <cdogs/color.h> |
| 51 |
#include <cdogs/defs.h> |
| 52 |
#include <cdogs/events.h> |
| 53 |
#include <cdogs/vector.h> |
| 54 |
|
| 55 |
#define PIC_SCALE 2 |
| 56 |
|
| 57 |
typedef struct |
| 58 |
{ |
| 59 |
SDL_Window *win; |
| 60 |
struct nk_context *ctx; |
| 61 |
SDL_GLContext glContext; |
| 62 |
|
| 63 |
const char *Title; |
| 64 |
struct vec2i Size; |
| 65 |
struct vec2i MinSize; |
| 66 |
int WindowFlags; |
| 67 |
color_t BG; |
| 68 |
SDL_Surface *Icon; |
| 69 |
EventHandlers *Handlers; |
| 70 |
bool (*Draw)(SDL_Window *, struct nk_context *, void *); |
| 71 |
void *DrawData; |
| 72 |
} NKWindowConfig; |
| 73 |
|
| 74 |
void NKWindowInit(NKWindowConfig *cfg); |
| 75 |
void NKWindow(NKWindowConfig cfg); |
| 76 |
|
| 77 |
int nk_combo_separator_image( |
| 78 |
struct nk_context *ctx, const GLuint *img_ids, |
| 79 |
const char *items_separated_by_separator, int separator, int selected, |
| 80 |
int count, int item_height, struct nk_vec2 size); |
| 81 |
|
| 82 |
|
| 83 |
void LoadTexFromPic(const GLuint texid, const Pic *pic); |
| 84 |
bool DrawCheckbox( |
| 85 |
struct nk_context *ctx, const char *label, const char *tooltip, |
| 86 |
bool *value); |
| 87 |
void DrawPic( |
| 88 |
struct nk_context *ctx, const Pic *pic, const GLuint texid, |
| 89 |
const struct vec2i pos, const float scale); |
| 90 |
void DrawTextbox( |
| 91 |
struct nk_context *ctx, char *value, const int len, const char *tooltip, |
| 92 |
const nk_flags flags); |
| 93 |
bool DrawNumberSlider( |
| 94 |
struct nk_context *ctx, const char *label, const char *tooltip, |
| 95 |
const int min, const int max, const int step, int *value); |
| 96 |
bool ColorPicker( |
| 97 |
struct nk_context *ctx, const float height, const char *label, color_t *c); |
| 98 |
void PickupClassDrawPropsSidebar( |
| 99 |
struct nk_context *ctx, const PickupClass *pc, const float rh); |