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