+#include <stdio.h>
+
#include <SDL.h>
#include "system/line_stream.h"
#include "label_layer.h"
#include "dynarray.h"
#include "color.h"
+#include "game/camera.h"
#define LABEL_LAYER_ID_MAX_SIZE 36
}
size_t n = 0;
- if (sscanf(line, "%lu", &n) == EOF) {
+ if (sscanf(line, "%zu", &n) == EOF) {
log_fail("Could not parse amount of labels\n");
RETURN_LT(label_layer->lt, NULL);
}
int label_layer_render(const LabelLayer *label_layer,
Camera *camera,
- float fa)
+ int active)
{
trace_assert(label_layer);
trace_assert(camera);
- (void) fa;
+
+ size_t n = dynarray_count(label_layer->ids);
+ Point *positions = dynarray_data(label_layer->positions);
+ Color *colors = dynarray_data(label_layer->colors);
+ char **texts = dynarray_data(label_layer->texts);
+
+ /* TODO(#891): LabelLayer doesn't show the final position of Label after the animation */
+ for (size_t i = 0; i < n; ++i) {
+ if (camera_render_text(
+ camera,
+ texts[i],
+ vec(2.0f, 2.0f),
+ color_scale(
+ colors[i],
+ rgba(1.0f, 1.0f, 1.0f, active ? 1.0f : 0.5f)),
+ positions[i]) < 0) {
+ return -1;
+ }
+ }
+
return 0;
}
trace_assert(label_layer);
trace_assert(event);
trace_assert(camera);
+ /* TODO(#892): LabelLayer doesn't allow to modify and add labels */
return 0;
}
{
return dynarray_data(label_layer->texts);
}
+
+int label_layer_dump_stream(const LabelLayer *label_layer, FILE *filedump)
+{
+ trace_assert(label_layer);
+ trace_assert(filedump);
+
+ size_t n = dynarray_count(label_layer->ids);
+ char *ids = dynarray_data(label_layer->ids);
+ Point *positions = dynarray_data(label_layer->positions);
+ Color *colors = dynarray_data(label_layer->colors);
+ char **texts = dynarray_data(label_layer->texts);
+
+ fprintf(filedump, "%zd\n", n);
+ for (size_t i = 0; i < n; ++i) {
+ fprintf(filedump, "%s %f %f ",
+ ids + LABEL_LAYER_ID_MAX_SIZE * i,
+ positions[i].x, positions[i].y);
+ color_hex_to_stream(colors[i], filedump);
+ fprintf(filedump, "\n%s\n", texts[i]);
+ }
+
+ return 0;
+}