]> git.lizzy.rs Git - nothing.git/blobdiff - src/game/level/level_editor/player_layer.c
Implement chop_player_layer
[nothing.git] / src / game / level / level_editor / player_layer.c
index 711ade5b300f3e9afcd91b9f9846288a06e052ae..f3c312fe12206034a8ae944c7d85c1e551213320 100644 (file)
@@ -8,6 +8,7 @@
 #include "system/nth_alloc.h"
 #include "system/log.h"
 #include "undo_history.h"
+#include "system/memory.h"
 
 typedef struct {
     PlayerLayer *layer;
@@ -73,6 +74,19 @@ PlayerLayer create_player_layer_from_line_stream(LineStream *line_stream)
     return create_player_layer(position, hexstr(colorstr));
 }
 
+PlayerLayer chop_player_layer(Memory *memory, String *input)
+{
+    trace_assert(memory);
+    trace_assert(input);
+
+    String line = chop_by_delim(input, '\n');
+    float x = strtof(string_to_cstr(memory, chop_word(&line)), NULL);
+    float y = strtof(string_to_cstr(memory, chop_word(&line)), NULL);
+    Color color = hexs(chop_word(&line));
+
+    return create_player_layer(vec(x, y), color);
+}
+
 LayerPtr player_layer_as_layer(PlayerLayer *player_layer)
 {
     LayerPtr layer = {