]> git.lizzy.rs Git - nothing.git/blob - src/game/level/level_editor/point_layer.h
a3923d8ed7008f71fff43d6f20d59584014df5a0
[nothing.git] / src / game / level / level_editor / point_layer.h
1 #ifndef POINT_LAYER_H_
2 #define POINT_LAYER_H_
3
4 #include "math/vec.h"
5 #include "color.h"
6 #include "layer.h"
7
8 #define ID_MAX_SIZE 36
9
10 typedef enum {
11     POINT_LAYER_IDLE = 0,
12     POINT_LAYER_EDIT_ID,
13     POINT_LAYER_MOVE,
14     POINT_LAYER_RECOLOR
15 } PointLayerState;
16
17 typedef struct {
18     PointLayerState state;
19     Dynarray/*<Vec2f>*/ positions;
20     Dynarray/*<Color>*/ colors;
21     Dynarray/*<char[ID_MAX_SIZE]>*/ ids;
22     int selection;
23     ColorPicker color_picker;
24
25     Vec2f inter_position;
26     Color inter_color;
27     Edit_field edit_field;
28
29     int id_name_counter;
30     const char *id_name_prefix;
31 } PointLayer;
32
33
34 LayerPtr point_layer_as_layer(PointLayer *point_layer);
35 // NOTE: create_point_layer and create_point_layer_from_line_stream do
36 // not own id_name_prefix
37 PointLayer create_point_layer(const char *id_name_prefix);
38 PointLayer chop_point_layer(Memory *memory,
39                              String *input,
40                              const char *id_name_prefix);
41
42 static inline
43 void destroy_point_layer(PointLayer point_layer)
44 {
45     free(point_layer.positions.data);
46     free(point_layer.colors.data);
47     free(point_layer.ids.data);
48 }
49
50
51 int point_layer_render(const PointLayer *point_layer,
52                        const Camera *camera,
53                        int active);
54 int point_layer_event(PointLayer *point_layer,
55                       const SDL_Event *event,
56                       const Camera *camera,
57                       UndoHistory *undo_history);
58
59 int point_layer_dump_stream(const PointLayer *point_layer,
60                             FILE *filedump);
61
62 size_t point_layer_count(const PointLayer *point_layer);
63 const Vec2f *point_layer_positions(const PointLayer *point_layer);
64 const Color *point_layer_colors(const PointLayer *point_layer);
65 const char *point_layer_ids(const PointLayer *point_layer);
66
67 #endif  // POINT_LAYER_H_