Debian Codegraph @

src/cdogsed/nk_window.h

raw symbols SCIP
1 /*
2 C-Dogs SDL
3 A port of the legendary (and fun) action/arcade cdogs.
4 Copyright (c) 2019-2021, 2023 Cong Xu
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10 Redistributions of source code must retain the above copyright notice, this
11 list of conditions and the following disclaimer.
12 Redistributions in binary form must reproduce the above copyright notice,
13 this list of conditions and the following disclaimer in the documentation
14 and/or other materials provided with the distribution.
15
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 POSSIBILITY OF SUCH DAMAGE.
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 // Guard against compile time constant in nk_memset
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 // Note: need to init before initialising textures
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 // Util functions
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);