feat: implemented saving & loading
This commit is contained in:
parent
6724c38968
commit
61ba2a54f2
3 changed files with 120 additions and 0 deletions
|
|
@ -1,20 +1,46 @@
|
|||
#pragma once
|
||||
|
||||
#include "core/io/resource.h"
|
||||
#include "scene/gui/file_dialog.h"
|
||||
#include "terrain_editor/terrain_mesh_generator.h"
|
||||
|
||||
class SaveData : public Resource {
|
||||
GDCLASS(SaveData, Resource);
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void write_to_file();
|
||||
void set_save_path(String value);
|
||||
String get_save_path() const;
|
||||
void set_primitives(Array primitives);
|
||||
Array get_primitives() const;
|
||||
|
||||
private:
|
||||
String save_file_path{};
|
||||
Array primitives{};
|
||||
};
|
||||
|
||||
class TerrainMeshEditor : public TerrainMeshGenerator {
|
||||
GDCLASS(TerrainMeshEditor, TerrainMeshGenerator);
|
||||
static void _bind_methods();
|
||||
void ready();
|
||||
void on_primitive_list_changed(Array primitives);
|
||||
void on_primitive_node_removed();
|
||||
void on_save_file_selected(String path);
|
||||
|
||||
protected:
|
||||
void _notification(int what);
|
||||
virtual void unhandled_input(Ref<InputEvent> const &event) override;
|
||||
|
||||
public:
|
||||
void save_data();
|
||||
void set_point_primitive_object(Ref<PackedScene> scene);
|
||||
Ref<PackedScene> get_point_primitive_object() const;
|
||||
|
||||
private:
|
||||
Ref<SaveData> data{ memnew(SaveData) };
|
||||
FileDialog *file_dialog{};
|
||||
bool out_of_date{ false };
|
||||
Vector<Node3D *> primitive_nodes{};
|
||||
Ref<PackedScene> point_primitive_object{};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue