]> git.lizzy.rs Git - nothing.git/blob - src/game/level/level_editor/point_layer.h
Remove Lt from LevelEditor
[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 void point_layer_reload(PointLayer *point_layer,
39                         Memory *memory,
40                         String *input);
41 void point_layer_clean(PointLayer *point_layer);
42
43
44 static inline
45 void destroy_point_layer(PointLayer point_layer)
46 {
47     free(point_layer.positions.data);
48     free(point_layer.colors.data);
49     free(point_layer.ids.data);
50 }
51
52
53 int point_layer_render(const PointLayer *point_layer,
54                        const Camera *camera,
55                        int active);
56 int point_layer_event(PointLayer *point_layer,
57                       const SDL_Event *event,
58                       const Camera *camera,
59                       UndoHistory *undo_history);
60
61 int point_layer_dump_stream(const PointLayer *point_layer,
62                             FILE *filedump);
63
64 size_t point_layer_count(const PointLayer *point_layer);
65 const Vec2f *point_layer_positions(const PointLayer *point_layer);
66 const Color *point_layer_colors(const PointLayer *point_layer);
67 const char *point_layer_ids(const PointLayer *point_layer);
68
69 #endif  // POINT_LAYER_H_