]> git.lizzy.rs Git - nothing.git/blob - src/game/level/level_editor/label_layer.h
Remove *_from_memory
[nothing.git] / src / game / level / level_editor / label_layer.h
1 #ifndef LABEL_LAYER_H_
2 #define LABEL_LAYER_H_
3
4 #include "layer.h"
5 #include "color.h"
6 #include "math/vec.h"
7 #include "dynarray.h"
8 #include "game/level/level_editor/color_picker.h"
9 #include "ui/edit_field.h"
10
11 #define LABELS_SIZE vec(2.0f, 2.0f)
12 #define LABEL_LAYER_ID_MAX_SIZE 36
13 #define LABEL_LAYER_TEXT_MAX_SIZE 256
14
15 typedef enum {
16     LABEL_LAYER_IDLE = 0,
17     LABEL_LAYER_MOVE,
18     LABEL_LAYER_EDIT_TEXT,
19     LABEL_LAYER_EDIT_ID,
20     LABEL_LAYER_RECOLOR
21 } LabelLayerState;
22
23 typedef struct {
24     LabelLayerState state;
25     Dynarray ids;
26     Dynarray positions;
27     Dynarray colors;
28     Dynarray texts;
29     int selection;
30     ColorPicker color_picker;
31     Vec2f move_anchor;
32     Edit_field edit_field;
33     Vec2f inter_position;
34     Color inter_color;
35     int id_name_counter;
36     const char *id_name_prefix;
37 } LabelLayer;
38
39 LayerPtr label_layer_as_layer(LabelLayer *label_layer);
40
41 // NOTE: create_label_layer and create_label_layer_from_line_stream do
42 // not own id_name_prefix
43 LabelLayer *create_label_layer(Memory *memory, const char *id_name_prefix);
44 void label_layer_load(LabelLayer *label_layer,
45                         Memory *memory,
46                         String *input);
47
48 static inline
49 void destroy_label_layer(LabelLayer label_layer)
50 {
51     free(label_layer.ids.data);
52     free(label_layer.positions.data);
53     free(label_layer.colors.data);
54     free(label_layer.texts.data);
55 }
56
57 int label_layer_render(const LabelLayer *label_layer,
58                        const Camera *camera,
59                        int active);
60 int label_layer_event(LabelLayer *label_layer,
61                       const SDL_Event *event,
62                       const Camera *camera,
63                       UndoHistory *undo_history);
64
65 size_t label_layer_count(const LabelLayer *label_layer);
66
67 int label_layer_dump_stream(const LabelLayer *label_layer, FILE *filedump);
68
69 char *label_layer_ids(const LabelLayer *label_layer);
70 Vec2f *label_layer_positions(const LabelLayer *label_layer);
71 Color *label_layer_colors(const LabelLayer *label_layer);
72 char *labels_layer_texts(const LabelLayer *label_layer);
73
74 #endif  // LABEL_LAYER_H_