58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include "core/io/resource.h"
|
|
#include "scene/gui/file_dialog.h"
|
|
#include "terrain_editor/terrain_mesh_generator.h"
|
|
#include "terrain_editor/terrain_primitive.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);
|
|
void load_new();
|
|
|
|
protected:
|
|
void _notification(int what);
|
|
virtual void unhandled_input(Ref<InputEvent> const &event) override;
|
|
|
|
public:
|
|
void save_data();
|
|
void save_data_as();
|
|
void set_new_file_data(Ref<SaveData> data);
|
|
Ref<SaveData> get_new_file_data() const;
|
|
void set_current_selected(Ref<TerrainPrimitive>);
|
|
Ref<TerrainPrimitive> get_current_selected() const;
|
|
void set_point_primitive_object(Ref<PackedScene> scene);
|
|
Ref<PackedScene> get_point_primitive_object() const;
|
|
|
|
private:
|
|
Ref<SaveData> new_file_data{};
|
|
Ref<SaveData> data{ memnew(SaveData) };
|
|
Ref<TerrainPrimitive> current_selected{};
|
|
FileDialog *file_dialog{};
|
|
Vector<Node3D *> primitive_nodes{};
|
|
Ref<PackedScene> point_primitive_object{};
|
|
|
|
public:
|
|
static String const sig_selection_changed;
|
|
};
|