From 85b7009fc7a962da61f5750a011f412ede963145 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 27 Jun 2020 14:22:41 +0200 Subject: [PATCH] Removed PropTool (again). Will be reimplemented as a tool that can convert scenes. Kind of like the meshlibrary converter. --- SCsub | 10 - prop_tool/prop_tool.cpp | 222 ----------------- prop_tool/prop_tool.h | 74 ------ prop_tool/prop_tool_editor_plugin.cpp | 340 -------------------------- prop_tool/prop_tool_editor_plugin.h | 75 ------ prop_tool/prop_tool_entity.cpp | 152 ------------ prop_tool/prop_tool_entity.h | 69 ------ prop_tool/prop_tool_light.cpp | 74 ------ prop_tool/prop_tool_light.h | 58 ----- prop_tool/prop_tool_mesh.cpp | 183 -------------- prop_tool/prop_tool_mesh.h | 75 ------ prop_tool/prop_tool_prop.cpp | 99 -------- prop_tool/prop_tool_prop.h | 62 ----- prop_tool/prop_tool_scene.cpp | 99 -------- prop_tool/prop_tool_scene.h | 61 ----- register_types.cpp | 19 -- 16 files changed, 1672 deletions(-) delete mode 100644 prop_tool/prop_tool.cpp delete mode 100644 prop_tool/prop_tool.h delete mode 100644 prop_tool/prop_tool_editor_plugin.cpp delete mode 100644 prop_tool/prop_tool_editor_plugin.h delete mode 100644 prop_tool/prop_tool_entity.cpp delete mode 100644 prop_tool/prop_tool_entity.h delete mode 100644 prop_tool/prop_tool_light.cpp delete mode 100644 prop_tool/prop_tool_light.h delete mode 100644 prop_tool/prop_tool_mesh.cpp delete mode 100644 prop_tool/prop_tool_mesh.h delete mode 100644 prop_tool/prop_tool_prop.cpp delete mode 100644 prop_tool/prop_tool_prop.h delete mode 100644 prop_tool/prop_tool_scene.cpp delete mode 100644 prop_tool/prop_tool_scene.h diff --git a/SCsub b/SCsub index e5e6ecd..e136ae4 100644 --- a/SCsub +++ b/SCsub @@ -28,13 +28,6 @@ sources = [ "props/prop_data_prop.cpp", "props/prop_data_entity.cpp", - "prop_tool/prop_tool.cpp", - "prop_tool/prop_tool_entity.cpp", - "prop_tool/prop_tool_prop.cpp", - "prop_tool/prop_tool_scene.cpp", - "prop_tool/prop_tool_light.cpp", - "prop_tool/prop_tool_mesh.cpp", - "library/voxelman_library.cpp", "library/voxelman_library_simple.cpp", @@ -91,9 +84,6 @@ if has_texture_packer: sources.append("library/voxelman_library_merger.cpp") sources.append("library/voxel_surface_merger.cpp") -if env['tools']: - sources.append("prop_tool/prop_tool_editor_plugin.cpp") - if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes': # Shared lib compilation module_env.Append(CCFLAGS=['-fPIC']) diff --git a/prop_tool/prop_tool.cpp b/prop_tool/prop_tool.cpp deleted file mode 100644 index f1ceedc..0000000 --- a/prop_tool/prop_tool.cpp +++ /dev/null @@ -1,222 +0,0 @@ -#include "prop_tool.h" - -#ifdef TOOLS_ENABLED - -#include "../props/prop_data.h" -#include "../props/prop_data_entity.h" -#include "../props/prop_data_light.h" -#include "../props/prop_data_mesh.h" -#include "../props/prop_data_prop.h" -#include "../props/prop_data_scene.h" - -#include "prop_tool_entity.h" -#include "prop_tool_light.h" -#include "prop_tool_mesh.h" -#include "prop_tool_prop.h" -#include "prop_tool_scene.h" - -#include "core/io/resource_saver.h" -#include "prop_tool_editor_plugin.h" - -void PropTool::edit(const Ref &prop) { -} - -void PropTool::save() { - if (!_target_prop.is_valid()) - return; - - print_verbose("save " + _target_prop->get_path()); - - while (_target_prop->get_prop_count() > 0) - _target_prop->remove_prop(0); - - for (int i = 0; i < get_child_count(); ++i) { - save_node(get_child(i), get_transform()); - } - - _target_prop->set_snap_to_mesh(_snap_to_mesh); - _target_prop->set_snap_axis(_snap_axis); - - ResourceSaver::save(_target_prop->get_path(), _target_prop); - - print_error("save"); -} - -void PropTool::save_node(Node *node, Transform parent_transform) { - Spatial *snode = Object::cast_to(node); - - if (ObjectDB::instance_validate(snode) && snode->has_method("get_data")) { - Ref prop = node->call("get_data"); - - if (prop.is_valid()) { - prop->set_transform(parent_transform * snode->get_transform()); - - _target_prop->add_prop(prop); - } - - if (snode->has_method("evaluate_children") && !snode->call("evaluate_children")) - return; - - for (int i = 0; i < get_child_count(); ++i) { - save_node(get_child(i), parent_transform * snode->get_transform()); - } - } else { - if (node->has_method("set_target_prop") && node->has_method("get_target_prop")) { - Ref tprop = node->call("get_target_prop"); - - if (tprop.is_valid()) { - Ref prop; - prop.instance(); - - prop->set_prop(tprop); - - prop->set_transform(parent_transform * snode->get_transform()); - - _target_prop->add_prop(prop); - } - } else { - for (int i = 0; i < get_child_count(); ++i) { - save_node(get_child(i), parent_transform * snode->get_transform()); - } - } - } -} - -void PropTool::rebuild_hierarchy() { - for (int i = 0; i < get_child_count(); ++i) - get_child(i)->queue_delete(); - - if (!_target_prop.is_valid()) - return; - - _snap_to_mesh = _target_prop->get_snap_to_mesh(); - _snap_axis = _target_prop->get_snap_axis(); - - for (int i = 0; i < _target_prop->get_prop_count(); ++i) { - Ref prop = _target_prop->get_prop(i); - - Ref prop_light = prop; - Ref prop_mesh = prop; - Ref prop_scene = prop; - Ref prop_prop = prop; - Ref prop_entity = prop; - - if (prop_light.is_valid()) { - PropToolLight *l = memnew(PropToolLight); - - add_child(l); - l->set_owner(this); - l->set_transform(prop->get_transform()); - - l->set_data(prop_light); - } else if (prop_mesh.is_valid()) { - PropToolMesh *m = memnew(PropToolMesh); - - add_child(m); - m->set_owner(this); - m->set_transform(prop->get_transform()); - - m->set_data(prop_mesh); - } else if (prop_scene.is_valid()) { - PropToolScene *s = memnew(PropToolScene); - - add_child(s); - s->set_owner(this); - s->set_transform(prop->get_transform()); - - s->set_data(prop_scene); - } else if (prop_prop.is_valid()) { - PropTool *s = _plugin->create_or_get_scene(prop_prop->get_prop()); - - add_child(s); - s->set_owner(this); - s->set_transform(prop->get_transform()); - s->set_target_prop(prop_prop->get_prop()); - } else if (prop_entity.is_valid()) { - PropToolEntity *s = memnew(PropToolEntity); - - add_child(s); - s->set_owner(this); - s->set_transform(prop->get_transform()); - - s->set_data(prop_entity); - } - } -} - -void PropTool::refresh_set(bool value) { - if (value) - rebuild_hierarchy(); -} - -Ref PropTool::get_target_prop() { - return _target_prop; -} - -void PropTool::set_target_prop(const Ref &prop) { - _target_prop = prop; - - rebuild_hierarchy(); -} - -void PropTool::target_prop_set(const Ref &prop) { - _target_prop = prop; - - if (!prop.is_valid()) - return; - - PropTool *last_prop_tool = this; - Node *root = this; - - while (root->get_parent() != NULL) { - root = root->get_parent(); - - if (root && root->has_method("target_prop_set")) - last_prop_tool = Object::cast_to(root); - } - - if (last_prop_tool == this) - return; - - last_prop_tool->load_scene_for(this, prop); -} - -void PropTool::load_scene_for(PropTool *t, const Ref &prop) { - if (_plugin == NULL) - return; - - t->queue_delete(); - - Node *s = _plugin->create_or_get_scene(prop); - - add_child(s); - //s->set_owner(this); -} - -PropToolEditorPlugin *PropTool::get_plugin() { - return _plugin; -} - -void PropTool::set_plugin(PropToolEditorPlugin *plugin) { - _plugin = plugin; -} - -PropTool::PropTool() { - _snap_to_mesh = false; - _snap_axis = Vector3(0, -1, 0); -} -PropTool::PropTool(EditorNode *p_editor) { - _snap_to_mesh = false; - _snap_axis = Vector3(0, -1, 0); -} -PropTool::~PropTool() { - _target_prop.unref(); -} - -void PropTool::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_target_prop"), &PropTool::get_target_prop); - ClassDB::bind_method(D_METHOD("set_target_prop", "value"), &PropTool::set_target_prop); - //ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "target_prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_target_prop", "get_target_prop"); -} - -#endif \ No newline at end of file diff --git a/prop_tool/prop_tool.h b/prop_tool/prop_tool.h deleted file mode 100644 index f45a7a2..0000000 --- a/prop_tool/prop_tool.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -Copyright (c) 2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef PROP_TOOL_H -#define PROP_TOOL_H - -class EditorNode; -class EditorPlugin; -class PropData; - -#include "core/math/vector3.h" -#include "core/reference.h" -#include "scene/3d/spatial.h" - -class propData; -class PropToolEditorPlugin; - -class PropTool : public Spatial { - GDCLASS(PropTool, Spatial); - -#ifdef TOOLS_ENABLED -public: - void edit(const Ref &prop); - - void save(); - void save_node(Node *node, Transform parent_transform); - void rebuild_hierarchy(); - void refresh_set(bool value); - - Ref get_target_prop(); - void set_target_prop(const Ref &prop); - - void target_prop_set(const Ref &prop); - void load_scene_for(PropTool *t, const Ref &prop); - - PropToolEditorPlugin *get_plugin(); - void set_plugin(PropToolEditorPlugin *plugin); - - PropTool(); - PropTool(EditorNode *p_editor); - ~PropTool(); - -protected: - static void _bind_methods(); - -private: - bool _refresh; - Ref _target_prop; - bool _snap_to_mesh; - Vector3 _snap_axis; - PropToolEditorPlugin *_plugin; -#endif -}; - -#endif diff --git a/prop_tool/prop_tool_editor_plugin.cpp b/prop_tool/prop_tool_editor_plugin.cpp deleted file mode 100644 index 63b79a9..0000000 --- a/prop_tool/prop_tool_editor_plugin.cpp +++ /dev/null @@ -1,340 +0,0 @@ -/* -Copyright (c) 2019-2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "prop_tool_editor_plugin.h" - -#include "core/os/dir_access.h" -#include "core/os/file_access.h" -#include "editor/editor_scale.h" -#include "editor/editor_settings.h" -#include "scene/resources/packed_scene.h" - -#include "../props/prop_data.h" - -#include "prop_tool.h" -#include "prop_tool_entity.h" -#include "prop_tool_light.h" -#include "prop_tool_mesh.h" -#include "prop_tool_scene.h" - -#include "editor/plugins/spatial_editor_plugin.h" - -void PropToolEditorPlugin::edit(Object *p_object) { - Ref pedited_prop(Object::cast_to(p_object)); - - String p = create_or_get_scene_path(pedited_prop); - - get_editor_interface()->open_scene_from_path(p); -} - -bool PropToolEditorPlugin::handles(Object *p_object) const { - - bool handles = p_object->is_class("PropData"); - - return handles; -} - -void PropToolEditorPlugin::make_visible(bool p_visible) { -} - -String PropToolEditorPlugin::create_or_get_scene_path(const Ref &data) { - ERR_FAIL_COND_V(!data.is_valid(), ""); - - String temp_path = EditorSettings::get_singleton()->get("editors/prop_tool/temp_path"); - - String path = temp_path + data->get_path().get_file().get_basename() + ".tscn"; - - if (!FileAccess::exists(path)) - create_scene(data); - - return path; -} -PropTool *PropToolEditorPlugin::create_or_get_scene(const Ref &data) { - ERR_FAIL_COND_V(!data.is_valid(), NULL); - - String temp_path = EditorSettings::get_singleton()->get("editors/prop_tool/temp_path"); - - String path = temp_path + data->get_path().get_file().get_basename() + ".tscn"; - - Ref ps; - - if (!FileAccess::exists(path)) - ps = create_scene(data); - else - ps = ResourceLoader::load(path, "PackedScene"); - - if (!ps.is_valid()) - return NULL; - - PropTool *pt = Object::cast_to(ps->instance()); - pt->set_plugin(this); - return pt; -} -Ref PropToolEditorPlugin::create_scene(const Ref &data) { - PropTool *pt = memnew(PropTool); - - pt->set_plugin(this); - pt->set_target_prop(data); - - Ref ps; - ps.instance(); - ps->pack(pt); - - String temp_path = EditorSettings::get_singleton()->get("editors/prop_tool/temp_path"); - - Error err = ResourceSaver::save(temp_path + data->get_path().get_file().get_basename() + ".tscn", ps); - - if (err) - print_error("PropTool: create_scene failed! Error_code:" + String::num(err)); - - pt->queue_delete(); - return ps; -} - -void PropToolEditorPlugin::on_scene_changed(Node *scene) { - PropTool *pt = Object::cast_to(scene); - - if (ObjectDB::instance_validate(pt)) { - pt->set_plugin(this); - - light_button->show(); - mesh_button->show(); - prop_button->show(); - scene_button->show(); - entity_button->show(); - } else { - light_button->hide(); - mesh_button->hide(); - prop_button->hide(); - scene_button->hide(); - entity_button->hide(); - } -} - -void PropToolEditorPlugin::apply_changes() { - Node *scene = get_editor_interface()->get_edited_scene_root(); - PropTool *pt = Object::cast_to(scene); - - if (ObjectDB::instance_validate(pt)) { - pt->save(); - } -} - -void PropToolEditorPlugin::add_light() { - Array selection = get_editor_interface()->get_selection()->get_selected_nodes(); - - Node *selected; - - if (selection.size() != 1) - selected = get_editor_interface()->get_edited_scene_root(); - else - selected = selection[0]; - - Node *s = selected; - PropToolLight *n = memnew(PropToolLight); - - UndoRedo &u = get_undo_redo(); - u.create_action("Add Light"); - u.add_do_method(s, "add_child", n); - u.add_do_property(n, "owner", get_editor_interface()->get_edited_scene_root()); - u.add_undo_method(s, "remove_child", n); - u.commit_action(); - - get_editor_interface()->get_selection()->clear(); - get_editor_interface()->get_selection()->add_node(n); -} - -void PropToolEditorPlugin::add_mesh() { - Array selected = get_editor_interface()->get_selection()->get_selected_nodes(); - - if (selected.size() != 1) - return; - - Node *s = selected[0]; - PropToolMesh *n = memnew(PropToolMesh); - - UndoRedo &u = get_undo_redo(); - u.create_action("Add Mesh"); - u.add_do_method(s, "add_child", n); - u.add_do_property(n, "owner", get_editor_interface()->get_edited_scene_root()); - u.add_undo_method(s, "remove_child", n); - u.commit_action(); - - get_editor_interface()->get_selection()->clear(); - get_editor_interface()->get_selection()->add_node(n); -} - -void PropToolEditorPlugin::add_prop() { - - Array selected = get_editor_interface()->get_selection()->get_selected_nodes(); - - if (selected.size() != 1) - return; - - Node *s = selected[0]; - PropTool *n = memnew(PropTool); - - UndoRedo &u = get_undo_redo(); - u.create_action("Add Prop"); - u.add_do_method(s, "add_child", n); - u.add_do_property(n, "owner", get_editor_interface()->get_edited_scene_root()); - u.add_undo_method(s, "remove_child", n); - u.commit_action(); - - get_editor_interface()->get_selection()->clear(); - get_editor_interface()->get_selection()->add_node(n); -} - -void PropToolEditorPlugin::add_scene() { - Array selected = get_editor_interface()->get_selection()->get_selected_nodes(); - - if (selected.size() != 1) - return; - - Node *s = selected[0]; - PropToolScene *n = memnew(PropToolScene); - - UndoRedo &u = get_undo_redo(); - u.create_action("Add Scene"); - u.add_do_method(s, "add_child", n); - u.add_do_property(n, "owner", get_editor_interface()->get_edited_scene_root()); - u.add_undo_method(s, "remove_child", n); - u.commit_action(); - - get_editor_interface()->get_selection()->clear(); - get_editor_interface()->get_selection()->add_node(n); -} - -void PropToolEditorPlugin::add_entity() { - Array selected = get_editor_interface()->get_selection()->get_selected_nodes(); - - if (selected.size() != 1) - return; - - Node *s = selected[0]; - PropToolEntity *n = memnew(PropToolEntity); - - UndoRedo &u = get_undo_redo(); - u.create_action("Add Entity"); - u.add_do_method(s, "add_child", n); - u.add_do_property(n, "owner", get_editor_interface()->get_edited_scene_root()); - u.add_undo_method(s, "remove_child", n); - u.commit_action(); - - get_editor_interface()->get_selection()->clear(); - get_editor_interface()->get_selection()->add_node(n); -} - -PropToolEditorPlugin::PropToolEditorPlugin(EditorNode *p_node) { - EDITOR_DEF("editors/prop_tool/temp_path", "res://.prop_tool_temp/"); - EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "editors/prop_tool/temp_path")); - - String tp = EditorSettings::get_singleton()->get("editors/prop_tool/temp_path"); - - if (!tp.ends_with("/")) { - tp += "/"; - EditorSettings::get_singleton()->set("editors/prop_tool/temp_path", tp); - } - - if (!DirAccess::exists(tp)) { - DirAccess *d = DirAccess::create_for_path(tp); - - Error err = d->make_dir_recursive(tp); - - memdelete(d); - - if (err) - print_error("PropTool: Temporary directory creation failed: error code: " + String::num(err)); - } - - editor = p_node; - - light_button = memnew(ToolButton); - light_button->set_text("Light"); - light_button->connect("pressed", this, "add_light"); - - mesh_button = memnew(ToolButton); - mesh_button->set_text("Mesh"); - mesh_button->connect("pressed", this, "add_mesh"); - - prop_button = memnew(ToolButton); - prop_button->set_text("Prop"); - prop_button->connect("pressed", this, "add_prop"); - - scene_button = memnew(ToolButton); - scene_button->set_text("Scene"); - scene_button->connect("pressed", this, "add_scene"); - - entity_button = memnew(ToolButton); - entity_button->set_text("Entity"); - entity_button->connect("pressed", this, "add_entity"); - - add_control_to_container(EditorPlugin::CONTAINER_SPATIAL_EDITOR_MENU, light_button); - add_control_to_container(EditorPlugin::CONTAINER_SPATIAL_EDITOR_MENU, mesh_button); - add_control_to_container(EditorPlugin::CONTAINER_SPATIAL_EDITOR_MENU, prop_button); - add_control_to_container(EditorPlugin::CONTAINER_SPATIAL_EDITOR_MENU, scene_button); - add_control_to_container(EditorPlugin::CONTAINER_SPATIAL_EDITOR_MENU, entity_button); - - light_button->hide(); - mesh_button->hide(); - prop_button->hide(); - scene_button->hide(); - entity_button->hide(); - - call_deferred("connect", "scene_changed", this, "on_scene_changed"); -} - -PropToolEditorPlugin::~PropToolEditorPlugin() { - _edited_prop.unref(); -} - -void PropToolEditorPlugin::_notification(int p_what) { - if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { - - String tp = EditorSettings::get_singleton()->get("editors/prop_tool/temp_path"); - - if (!tp.ends_with("/")) { - tp += "/"; - EditorSettings::get_singleton()->set("editors/prop_tool/temp_path", tp); - } - - if (!DirAccess::exists(tp)) { - DirAccess *d = DirAccess::create_for_path(tp); - - Error err = d->make_dir_recursive(tp); - - memdelete(d); - - ERR_FAIL_COND_MSG(err, "PropTool: Temporary directory creation failed: error code: " + String::num(err)); - } - } -} - -void PropToolEditorPlugin::_bind_methods() { - ClassDB::bind_method(D_METHOD("on_scene_changed", "scene_root"), &PropToolEditorPlugin::on_scene_changed); - ClassDB::bind_method(D_METHOD("apply_changes"), &PropToolEditorPlugin::apply_changes); - ClassDB::bind_method(D_METHOD("add_light"), &PropToolEditorPlugin::add_light); - ClassDB::bind_method(D_METHOD("add_mesh"), &PropToolEditorPlugin::add_mesh); - ClassDB::bind_method(D_METHOD("add_prop"), &PropToolEditorPlugin::add_prop); - ClassDB::bind_method(D_METHOD("add_scene"), &PropToolEditorPlugin::add_scene); - ClassDB::bind_method(D_METHOD("add_entity"), &PropToolEditorPlugin::add_entity); -} diff --git a/prop_tool/prop_tool_editor_plugin.h b/prop_tool/prop_tool_editor_plugin.h deleted file mode 100644 index 494a6c4..0000000 --- a/prop_tool/prop_tool_editor_plugin.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright (c) 2019-2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef PROP_TOOL_EDITOR_PLUGIN_H -#define PROP_TOOL_EDITOR_PLUGIN_H - -#include "editor/editor_node.h" -#include "editor/editor_plugin.h" - -class PropData; -class PropTool; - -class PropToolEditorPlugin : public EditorPlugin { - GDCLASS(PropToolEditorPlugin, EditorPlugin); - -public: - virtual String get_name() const { return "PropData"; } - bool has_main_screen() const { return false; } - virtual void edit(Object *p_object); - virtual bool handles(Object *p_object) const; - virtual void make_visible(bool p_visible); - - String create_or_get_scene_path(const Ref &data); - PropTool *create_or_get_scene(const Ref &data); - Ref create_scene(const Ref &data); - - void on_scene_changed(Node *scene); - void apply_changes(); - void add_light(); - void add_mesh(); - void add_prop(); - void add_scene(); - void add_entity(); - - PropToolEditorPlugin(EditorNode *p_node); - ~PropToolEditorPlugin(); - -protected: - void _notification(int p_what); - static void _bind_methods(); - -private: - ToolButton *light_button; - ToolButton *mesh_button; - ToolButton *prop_button; - ToolButton *scene_button; - ToolButton *entity_button; - - ToolButton *edited_prop; - - EditorNode *editor; - - Ref _edited_prop; -}; - -#endif diff --git a/prop_tool/prop_tool_entity.cpp b/prop_tool/prop_tool_entity.cpp deleted file mode 100644 index d382307..0000000 --- a/prop_tool/prop_tool_entity.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* -Copyright (c) 2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "prop_tool_entity.h" - -#ifdef TOOLS_ENABLED - -#include "../../entity_spell_system/entities/data/entity_data.h" -#include "../../entity_spell_system/entities/entity.h" - -Ref PropToolEntity::get_data() { - if (!is_visible() || !_entity_data.is_valid()) - return Ref(); - - if (!_prop_entity.is_valid()) - _prop_entity.instance(); - - _prop_entity->set_entity_data_id(_entity_data_id); - _prop_entity->set_level(_level); - - return _prop_entity; -} -void PropToolEntity::set_data(const Ref &data) { - _prop_entity = data; - - if (!_prop_entity.is_valid()) - return; - - _entity_data_id = _prop_entity->get_entity_data_id(); - _level = _prop_entity->get_level(); - - /* - TODO generic solution - var dir = Directory.new() - if dir.open("res://data/entities/") == OK: - dir.list_dir_begin() - var file_name = dir.get_next() - - while (file_name != ""): - if not dir.current_is_dir(): - var ed : EntityData = ResourceLoader.load("res://data/entities/" + file_name, "EntityData") - - if ed != null and ed.id == entity_data_id: - set_entity_data(ed) - return - - file_name = dir.get_next() - - print("PropToolEntity: Entity not found!") - */ -} - -Ref PropToolEntity::get_entity_data() { - return _entity_data; -} -void PropToolEntity::set_entity_data(const Ref &data) { - _entity_data = data; - - if (!_entity_data.is_valid()) - return; - - _entity_data_id = _entity_data->get_id(); - - if (_entity == NULL) { - //TODO generic solutiuon - - //var scene : PackedScene = load("res://addons/prop_tool/player/PropToolDisplayPlayer.tscn") - - //_entity = scene.instance() as Entity - - // add_child(_entity) - //_entity.owner = owner - - //_entity.get_node(_entity.character_skeleton_path).owner = owner - //_entity.get_node(_entity.character_skeleton_path).refresh_in_editor = true - //_entity.get_character_skeleton().refresh_in_editor = true - - // _entity.sentity_data = entity_data - - //name = entity_data.text_name - } -} - -int PropToolEntity::get_entity_data_id() const { - return _entity_data_id; -} -void PropToolEntity::set_entity_data_id(const int value) { - _entity_data_id = value; -} - -int PropToolEntity::get_level() const { - return _level; -} -void PropToolEntity::set_level(const int value) { - _level = value; -} - -bool PropToolEntity::evaluate_children() const { - return false; -} - -PropToolEntity::PropToolEntity() { - _entity_data_id = 0; - _level = 1; - - _entity = NULL; -} -PropToolEntity::~PropToolEntity() { - _entity_data.unref(); - _prop_entity.unref(); -} - -void PropToolEntity::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_data"), &PropToolEntity::get_data); - ClassDB::bind_method(D_METHOD("set_data", "value"), &PropToolEntity::set_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "PropDataProp"), "set_data", "get_data"); - - ClassDB::bind_method(D_METHOD("get_entity_data_id"), &PropToolEntity::get_entity_data_id); - ClassDB::bind_method(D_METHOD("set_entity_data_id", "value"), &PropToolEntity::set_entity_data_id); - ADD_PROPERTY(PropertyInfo(Variant::INT, "entity_data_id"), "set_entity_data_id", "get_entity_data_id"); - - ClassDB::bind_method(D_METHOD("get_level"), &PropToolEntity::get_level); - ClassDB::bind_method(D_METHOD("set_level", "value"), &PropToolEntity::set_level); - ADD_PROPERTY(PropertyInfo(Variant::INT, "level"), "set_level", "get_level"); - - ClassDB::bind_method(D_METHOD("get_entity_data"), &PropToolEntity::get_entity_data); - ClassDB::bind_method(D_METHOD("set_entity_data", "value"), &PropToolEntity::set_entity_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "entity_data", PROPERTY_HINT_RESOURCE_TYPE, "EntityData"), "set_entity_data", "get_entity_data"); - - ClassDB::bind_method(D_METHOD("evaluate_children"), &PropToolEntity::evaluate_children); -} - -#endif \ No newline at end of file diff --git a/prop_tool/prop_tool_entity.h b/prop_tool/prop_tool_entity.h deleted file mode 100644 index 31a2d09..0000000 --- a/prop_tool/prop_tool_entity.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright (c) 2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef PROP_TOOL_ENTITY_H -#define PROP_TOOL_ENTITY_H - -#include "scene/3d/spatial.h" - -#include "../props/prop_data.h" -#include "../props/prop_data_entity.h" - -class EntityData; -class Entity; - -class PropToolEntity : public Spatial { - GDCLASS(PropToolEntity, Spatial); - -#ifdef TOOLS_ENABLED -public: - Ref get_data(); - void set_data(const Ref &data); - - Ref get_entity_data(); - void set_entity_data(const Ref &data); - - int get_entity_data_id() const; - void set_entity_data_id(const int value); - - int get_level() const; - void set_level(const int value); - - bool evaluate_children() const; - - PropToolEntity(); - ~PropToolEntity(); - -protected: - static void _bind_methods(); - -private: - Ref _entity_data; - int _entity_data_id; - int _level; - - Ref _prop_entity; - Entity *_entity; -#endif -}; - -#endif diff --git a/prop_tool/prop_tool_light.cpp b/prop_tool/prop_tool_light.cpp deleted file mode 100644 index 274c9c9..0000000 --- a/prop_tool/prop_tool_light.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* -Copyright (c) 2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "prop_tool_light.h" - -#ifdef TOOLS_ENABLED - -Ref PropToolLight::get_data() { - - if (!is_visible()) - return Ref(); - - if (!_prop_light.is_valid()) - _prop_light.instance(); - - _prop_light->set_light_color(get_color()); - _prop_light->set_light_size(get_param(Light::PARAM_RANGE)); - - return _prop_light; -} -void PropToolLight::set_data(const Ref &data) { - _prop_light = data; - - if (!_prop_light.is_valid()) - return; - - set_color(_prop_light->get_light_color()); - set_param(Light::PARAM_RANGE, _prop_light->get_light_size()); - set_param(Light::PARAM_ENERGY, _prop_light->get_light_size()); -} - -bool PropToolLight::get_snap_to_mesh() const { - return _snap_to_mesh; -} -void PropToolLight::set_snap_to_mesh(const bool value) { - _snap_to_mesh = value; -} - -PropToolLight::PropToolLight() { -} -PropToolLight::~PropToolLight() { - _prop_light.unref(); -} - -void PropToolLight::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_data"), &PropToolLight::get_data); - ClassDB::bind_method(D_METHOD("set_data", "value"), &PropToolLight::set_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "PropDataLight"), "set_data", "get_data"); - - ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropToolLight::get_snap_to_mesh); - ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropToolLight::set_snap_to_mesh); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh"); -} - -#endif \ No newline at end of file diff --git a/prop_tool/prop_tool_light.h b/prop_tool/prop_tool_light.h deleted file mode 100644 index 8e9c0ac..0000000 --- a/prop_tool/prop_tool_light.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright (c) 2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef PROP_TOOL_LIGHT_H -#define PROP_TOOL_LIGHT_H - -class EditorNode; -class EditorPlugin; -class PropData; - -#include "../props/prop_data_light.h" -#include "scene/3d/light.h" - -class propData; - -class PropToolLight : public OmniLight { - GDCLASS(PropToolLight, OmniLight); - -#ifdef TOOLS_ENABLED -public: - Ref get_data(); - void set_data(const Ref &data); - - bool get_snap_to_mesh() const; - void set_snap_to_mesh(const bool value); - - PropToolLight(); - ~PropToolLight(); - -protected: - static void _bind_methods(); - -private: - Ref _prop_light; - bool _snap_to_mesh; -#endif -}; - -#endif diff --git a/prop_tool/prop_tool_mesh.cpp b/prop_tool/prop_tool_mesh.cpp deleted file mode 100644 index 33f09cf..0000000 --- a/prop_tool/prop_tool_mesh.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* -Copyright (c) 2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "prop_tool_mesh.h" - -#ifdef TOOLS_ENABLED - -Ref PropToolMesh::get_mesh_data() { - return _mesh_data; -} -void PropToolMesh::set_mesh_data(const Ref &data) { - _mesh_data = data; -} - -Ref PropToolMesh::get_data() { - return _prop_mesh; - - if (!is_visible() || !_mesh_data.is_valid()) - return Ref(); - - if (!_prop_mesh.is_valid()) - _prop_mesh.instance(); - - _prop_mesh->set_mesh(_mesh_data); - _prop_mesh->set_texture(_texture); - _prop_mesh->set_snap_to_mesh(_snap_to_mesh); - _prop_mesh->set_snap_axis(_snap_axis); - - return _prop_mesh; -} -void PropToolMesh::set_data(const Ref &data) { - _prop_mesh = data; - - if (!_prop_mesh.is_valid()) - return; - - _texture = _prop_mesh->get_texture(); - - _snap_to_mesh = _prop_mesh->get_snap_to_mesh(); - _snap_axis = _prop_mesh->get_snap_axis(); - - set_generate(true); -} - -Ref PropToolMesh::get_texture() { - return _texture; -} -void PropToolMesh::set_texture(const Ref &tex) { - _texture = tex; -} - -bool PropToolMesh::get_snap_to_mesh() const { - return _snap_to_mesh; -} -void PropToolMesh::set_snap_to_mesh(const bool value) { - _snap_to_mesh = value; -} - -Vector3 PropToolMesh::get_snap_axis() const { - return _snap_axis; -} -void PropToolMesh::set_snap_axis(const Vector3 &value) { - _snap_axis = value; -} - -Ref PropToolMesh::get_prop_mesh() { - return _prop_mesh; -} -void PropToolMesh::set_prop_mesh(const Ref &data) { - _prop_mesh = data; -} - -void PropToolMesh::generate() { -} - -PropToolMesh::PropToolMesh() { - _snap_to_mesh = false; - _snap_axis = Vector3(0, -1, 0); -} -PropToolMesh::~PropToolMesh() { - _prop_mesh.unref(); - _material.unref(); -} - -void PropToolMesh::set_generate(bool value) { - if (!value) - return; - - if (!_mesh_data.is_valid()) { - mesh.unref(); - return; - } - - Ref m; - m.instance(); - - Array arr; - arr.resize(ArrayMesh::ARRAY_MAX); - - Array mda = _mesh_data->get_array(); - - PoolVector3Array v; - v.append_array(mda[Mesh::ARRAY_VERTEX]); - arr.set(Mesh::ARRAY_VERTEX, v); - - PoolVector3Array norm; - norm.append_array(mda[Mesh::ARRAY_NORMAL]); - arr.set(Mesh::ARRAY_NORMAL, norm); - - PoolVector2Array uv; - uv.append_array(mda[Mesh::ARRAY_TEX_UV]); - arr.set(Mesh::ARRAY_TEX_UV, uv); - - PoolIntArray ind; - ind.append_array(mda[Mesh::ARRAY_INDEX]); - arr.set(Mesh::ARRAY_INDEX, ind); - - m->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arr); - - mesh = m; - - if (_texture.is_valid()) { - if (!_material.is_valid()) - _material.instance(); - - _material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, _texture); - - set_material_override(_material); - } -} - -void PropToolMesh::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_mesh_data"), &PropToolMesh::get_mesh_data); - ClassDB::bind_method(D_METHOD("set_mesh_data", "value"), &PropToolMesh::set_mesh_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh_data", PROPERTY_HINT_RESOURCE_TYPE, "MeshDataResource"), "set_mesh_data", "get_mesh_data"); - - ClassDB::bind_method(D_METHOD("get_data"), &PropToolMesh::get_data); - ClassDB::bind_method(D_METHOD("set_data", "value"), &PropToolMesh::set_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "PropDataMesh"), "set_data", "get_data"); - - ClassDB::bind_method(D_METHOD("get_texture"), &PropToolMesh::get_texture); - ClassDB::bind_method(D_METHOD("set_texture", "value"), &PropToolMesh::set_texture); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); - - ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropToolMesh::get_snap_to_mesh); - ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropToolMesh::set_snap_to_mesh); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh"); - - ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropToolMesh::get_snap_axis); - ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropToolMesh::set_snap_axis); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis"); - - ClassDB::bind_method(D_METHOD("get_prop_mesh"), &PropToolMesh::get_prop_mesh); - ClassDB::bind_method(D_METHOD("set_prop_mesh", "value"), &PropToolMesh::set_prop_mesh); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_mesh", PROPERTY_HINT_RESOURCE_TYPE, "MeshDataResource"), "set_prop_mesh", "get_prop_mesh"); - - ClassDB::bind_method(D_METHOD("generate"), &PropToolMesh::generate); - - ClassDB::bind_method(D_METHOD("get_generate"), &PropToolMesh::get_generate); - ClassDB::bind_method(D_METHOD("set_generate"), &PropToolMesh::set_generate); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "generate"), "set_generate", "get_generate"); -} - -#endif \ No newline at end of file diff --git a/prop_tool/prop_tool_mesh.h b/prop_tool/prop_tool_mesh.h deleted file mode 100644 index 9fa77f5..0000000 --- a/prop_tool/prop_tool_mesh.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -Copyright (c) 2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef PROP_TOOL_MESH_H -#define PROP_TOOL_MESH_H - -#include "core/math/vector3.h" - -#include "../props/prop_data_mesh.h" -#include "scene/3d/mesh_instance.h" - -class PropToolMesh : public MeshInstance { - GDCLASS(PropToolMesh, MeshInstance); - -#ifdef TOOLS_ENABLED -public: - Ref get_mesh_data(); - void set_mesh_data(const Ref &data); - - Ref get_data(); - void set_data(const Ref &data); - - Ref get_texture(); - void set_texture(const Ref &tex); - - bool get_snap_to_mesh() const; - void set_snap_to_mesh(const bool value); - - Vector3 get_snap_axis() const; - void set_snap_axis(const Vector3 &value); - - Ref get_prop_mesh(); - void set_prop_mesh(const Ref &data); - - void generate(); - - PropToolMesh(); - ~PropToolMesh(); - -protected: - bool get_generate() { return false; } - void set_generate(bool value); - - static void _bind_methods(); - -private: - Ref _mesh_data; - Ref _prop_mesh; - Ref _texture; - Ref _material; - bool _snap_to_mesh; - Vector3 _snap_axis; -#endif -}; - -#endif diff --git a/prop_tool/prop_tool_prop.cpp b/prop_tool/prop_tool_prop.cpp deleted file mode 100644 index 5317e55..0000000 --- a/prop_tool/prop_tool_prop.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* -Copyright (c) 2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "prop_tool_prop.h" - -#ifdef TOOLS_ENABLED - -Ref PropToolProp::get_data() { - if (!is_visible() || !_prop_data.is_valid()) - return Ref(); - - if (!_prop_data.is_valid()) - _prop_data.instance(); - - _prop_prop->set_prop(_prop_data); - _prop_prop->set_snap_to_mesh(_snap_to_mesh); - _prop_prop->set_snap_axis(_snap_axis); - - return _prop_prop; -} -void PropToolProp::set_data(const Ref &data) { - _prop_prop = data; - - if (!_prop_prop.is_valid()) - return; - - _prop_data = _prop_prop->get_prop(); - _snap_to_mesh = _prop_prop->get_snap_to_mesh(); - _snap_axis = _prop_prop->get_snap_axis(); -} - -Ref PropToolProp::get_prop_data() { - return _prop_data; -} -void PropToolProp::set_prop_data(const Ref &data) { - _prop_data = data; -} - -bool PropToolProp::get_snap_to_mesh() const { - return _snap_to_mesh; -} -void PropToolProp::set_snap_to_mesh(const bool value) { - _snap_to_mesh = value; -} - -Vector3 PropToolProp::get_snap_axis() const { - return _snap_axis; -} -void PropToolProp::set_snap_axis(const Vector3 &value) { - _snap_axis = value; -} - -PropToolProp::PropToolProp() { - _snap_to_mesh = false; - _snap_axis = Vector3(0, -1, 0); -} -PropToolProp::~PropToolProp() { - _prop_data.unref(); - _prop_prop.unref(); -} - -void PropToolProp::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_data"), &PropToolProp::get_data); - ClassDB::bind_method(D_METHOD("set_data", "value"), &PropToolProp::set_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "PropDataProp"), "set_data", "get_data"); - - ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropToolProp::get_snap_to_mesh); - ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropToolProp::set_snap_to_mesh); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh"); - - ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropToolProp::get_snap_axis); - ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropToolProp::set_snap_axis); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis"); - - ClassDB::bind_method(D_METHOD("get_prop_data"), &PropToolProp::get_prop_data); - ClassDB::bind_method(D_METHOD("set_prop_data", "value"), &PropToolProp::set_prop_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_prop_data", "get_prop_data"); -} - -#endif \ No newline at end of file diff --git a/prop_tool/prop_tool_prop.h b/prop_tool/prop_tool_prop.h deleted file mode 100644 index c3d9d1a..0000000 --- a/prop_tool/prop_tool_prop.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -Copyright (c) 2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef PROP_TOOL_PROP_H -#define PROP_TOOL_PROP_H - -#include "scene/3d/spatial.h" - -#include "../props/prop_data.h" -#include "../props/prop_data_prop.h" - -class PropToolProp : public Spatial { - GDCLASS(PropToolProp, Spatial); - -#ifdef TOOLS_ENABLED -public: - Ref get_data(); - void set_data(const Ref &data); - - Ref get_prop_data(); - void set_prop_data(const Ref &data); - - bool get_snap_to_mesh() const; - void set_snap_to_mesh(const bool value); - - Vector3 get_snap_axis() const; - void set_snap_axis(const Vector3 &value); - - PropToolProp(); - ~PropToolProp(); - -protected: - static void _bind_methods(); - -private: - Ref _prop_data; - bool _snap_to_mesh; - Vector3 _snap_axis; - Ref _prop_prop; -#endif -}; - -#endif diff --git a/prop_tool/prop_tool_scene.cpp b/prop_tool/prop_tool_scene.cpp deleted file mode 100644 index 1e4bf24..0000000 --- a/prop_tool/prop_tool_scene.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* -Copyright (c) 2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#include "prop_tool_scene.h" - -#ifdef TOOLS_ENABLED - -Ref PropToolScene::get_data() { - if (!is_visible() || !_scene_data.is_valid()) - return Ref(); - - if (!_prop_scene.is_valid()) - _prop_scene.instance(); - - _prop_scene->set_scene(_scene_data); - _prop_scene->set_snap_to_mesh(_snap_to_mesh); - _prop_scene->set_snap_axis(_snap_axis); - - return _prop_scene; -} -void PropToolScene::set_data(const Ref &data) { - _prop_scene = data; - - if (!_prop_scene.is_valid()) - return; - - _scene_data = _prop_scene->get_scene(); - _snap_to_mesh = _prop_scene->get_snap_to_mesh(); - _snap_axis = _prop_scene->get_snap_axis(); -} - -Ref PropToolScene::get_scene_data() { - return _scene_data; -} -void PropToolScene::set_scene_data(const Ref &data) { - _scene_data = data; -} - -bool PropToolScene::get_snap_to_mesh() const { - return _snap_to_mesh; -} -void PropToolScene::set_snap_to_mesh(const bool value) { - _snap_to_mesh = value; -} - -Vector3 PropToolScene::get_snap_axis() const { - return _snap_axis; -} -void PropToolScene::set_snap_axis(const Vector3 &value) { - _snap_axis = value; -} - -PropToolScene::PropToolScene() { - _snap_to_mesh = false; - _snap_axis = Vector3(0, -1, 0); -} -PropToolScene::~PropToolScene() { - _scene_data.unref(); - _prop_scene.unref(); -} - -void PropToolScene::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_data"), &PropToolScene::get_data); - ClassDB::bind_method(D_METHOD("set_data", "value"), &PropToolScene::set_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "PropDataScene"), "set_data", "get_data"); - - ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropToolScene::get_snap_to_mesh); - ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropToolScene::set_snap_to_mesh); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh"); - - ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropToolScene::get_snap_axis); - ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropToolScene::set_snap_axis); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis"); - - ClassDB::bind_method(D_METHOD("get_scene_data"), &PropToolScene::get_scene_data); - ClassDB::bind_method(D_METHOD("set_scene_data", "value"), &PropToolScene::set_scene_data); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene_data", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene_data", "get_scene_data"); -} - -#endif \ No newline at end of file diff --git a/prop_tool/prop_tool_scene.h b/prop_tool/prop_tool_scene.h deleted file mode 100644 index 744d43a..0000000 --- a/prop_tool/prop_tool_scene.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -Copyright (c) 2020 Péter Magyar - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ - -#ifndef PROP_TOOL_SCENE_H -#define PROP_TOOL_SCENE_H - -#include "scene/3d/spatial.h" - -#include "../props/prop_data_scene.h" - -class PropToolScene : public Spatial { - GDCLASS(PropToolScene, Spatial); - -#ifdef TOOLS_ENABLED -public: - Ref get_data(); - void set_data(const Ref &data); - - Ref get_scene_data(); - void set_scene_data(const Ref &data); - - bool get_snap_to_mesh() const; - void set_snap_to_mesh(const bool value); - - Vector3 get_snap_axis() const; - void set_snap_axis(const Vector3 &value); - - PropToolScene(); - ~PropToolScene(); - -protected: - static void _bind_methods(); - -private: - Ref _scene_data; - bool _snap_to_mesh; - Vector3 _snap_axis; - Ref _prop_scene; -#endif -}; - -#endif diff --git a/register_types.cpp b/register_types.cpp index 7bf8109..266f3f6 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -30,17 +30,6 @@ SOFTWARE. #include "props/prop_data_prop.h" #include "props/prop_data_scene.h" -#include "prop_tool/prop_tool.h" -#include "prop_tool/prop_tool_entity.h" -#include "prop_tool/prop_tool_light.h" -#include "prop_tool/prop_tool_mesh.h" -#include "prop_tool/prop_tool_prop.h" -#include "prop_tool/prop_tool_scene.h" - -#ifdef TOOLS_ENABLED -#include "prop_tool/prop_tool_editor_plugin.h" -#endif - #include "library/voxel_surface.h" #include "library/voxel_surface_simple.h" @@ -99,13 +88,6 @@ void register_voxelman_types() { ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); @@ -156,7 +138,6 @@ void register_voxelman_types() { #ifdef TOOLS_ENABLED EditorPlugins::add_by_type(); - EditorPlugins::add_by_type(); #endif }