Skip to content

Commit

Permalink
refactor: uses namespace for editor related classes
Browse files Browse the repository at this point in the history
  • Loading branch information
OctoD committed Jan 15, 2024
1 parent 4b6446a commit a82c275
Show file tree
Hide file tree
Showing 19 changed files with 229 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
#include "system/attribute/attribute_container.h"

using namespace ggs;
using namespace ggs::editor_plugin;

void GGSAttributeContainerInspector::_bind_methods()
void AttributeContainerInspector::_bind_methods()
{

}

bool GGSAttributeContainerInspector::_can_handle(Object *p_object) const
bool AttributeContainerInspector::_can_handle(Object *p_object) const
{
if (p_object == nullptr)
{
Expand All @@ -21,11 +22,11 @@ bool GGSAttributeContainerInspector::_can_handle(Object *p_object) const
return AttributeContainer::get_class_static() == p_object->get_class();
}

bool GGSAttributeContainerInspector::_parse_property(Object *object, Variant::Type type, const String &name, PropertyHint hint_type, const String &hint_string, BitField<PropertyUsageFlags> usage_flags, bool wide)
bool AttributeContainerInspector::_parse_property(Object *object, Variant::Type type, const String &name, PropertyHint hint_type, const String &hint_string, BitField<PropertyUsageFlags> usage_flags, bool wide)
{
if (name == "attributes" && object->get_class() == AttributeContainer::get_class_static())
{
GGSAttributeContainerInspectorEditor *editor = memnew(GGSAttributeContainerInspectorEditor);
AttributeContainerInspectorEditor *editor = memnew(AttributeContainerInspectorEditor);

editor->set_attribute_container(static_cast<AttributeContainer *>(object));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

using namespace godot;

namespace ggs
namespace ggs::editor_plugin
{
class GGSAttributeContainerInspector : public EditorInspectorPlugin
class AttributeContainerInspector : public EditorInspectorPlugin
{
GDCLASS(GGSAttributeContainerInspector, EditorInspectorPlugin);
GDCLASS(AttributeContainerInspector, EditorInspectorPlugin);

protected:
static void _bind_methods();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#include "system/attribute/attribute_manager.h"

using namespace ggs;
using namespace ggs::editor_plugin;

void GGSAttributeContainerInspectorEditor::_bind_methods()
void AttributeContainerInspectorEditor::_bind_methods()
{
ClassDB::bind_method(D_METHOD("_handle_item_edited"), &GGSAttributeContainerInspectorEditor::_handle_item_edited);
ClassDB::bind_method(D_METHOD("_handle_dictionary_changed", "previous", "current"), &GGSAttributeContainerInspectorEditor::_handle_dictionary_changed);
ClassDB::bind_method(D_METHOD("_handle_item_edited"), &AttributeContainerInspectorEditor::_handle_item_edited);
ClassDB::bind_method(D_METHOD("_handle_dictionary_changed", "previous", "current"), &AttributeContainerInspectorEditor::_handle_dictionary_changed);
}

void GGSAttributeContainerInspectorEditor::_handle_item_edited()
void AttributeContainerInspectorEditor::_handle_item_edited()
{
TreeItem *item = get_edited();

Expand All @@ -28,13 +29,13 @@ void GGSAttributeContainerInspectorEditor::_handle_item_edited()
}
}

void GGSAttributeContainerInspectorEditor::_handle_dictionary_changed(TagDictionary *previous, TagDictionary *current)
void AttributeContainerInspectorEditor::_handle_dictionary_changed(TagDictionary *previous, TagDictionary *current)
{
clear();
_ready();
}

void GGSAttributeContainerInspectorEditor::_ready()
void AttributeContainerInspectorEditor::_ready()
{
if (attribute_container == nullptr)
{
Expand Down Expand Up @@ -91,7 +92,7 @@ void GGSAttributeContainerInspectorEditor::_ready()
}
}

void GGSAttributeContainerInspectorEditor::set_attribute_container(AttributeContainer *p_attribute_container)
void AttributeContainerInspectorEditor::set_attribute_container(AttributeContainer *p_attribute_container)
{
attribute_container = p_attribute_container;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

using namespace godot;

namespace ggs
namespace ggs::editor_plugin
{
class GGSAttributeContainerInspectorEditor : public Tree
class AttributeContainerInspectorEditor : public Tree
{
GDCLASS(GGSAttributeContainerInspectorEditor, Tree);
GDCLASS(AttributeContainerInspectorEditor, Tree);

private:
AttributeContainer *attribute_container;
Expand Down
29 changes: 15 additions & 14 deletions src/editor_plugin/docks/tag/tag_docks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
#include "system/tag/tag_manager.h"

using namespace ggs;
using namespace ggs::editor_plugin;

GGSTagDocks::GGSTagDocks()
TagDocks::TagDocks()
{
}

GGSTagDocks::~GGSTagDocks()
TagDocks::~TagDocks()
{
}

void GGSTagDocks::_ready()
void TagDocks::_ready()
{
/// the hardest part:
set_name("Tag Manager");
Expand All @@ -38,14 +39,14 @@ void GGSTagDocks::_ready()
render();
}

void GGSTagDocks::_bind_methods()
void TagDocks::_bind_methods()
{
ClassDB::bind_method(D_METHOD("_on_selection_changed"), &GGSTagDocks::_on_selection_changed);
ClassDB::bind_method(D_METHOD("_handle_tags_deselected"), &GGSTagDocks::_handle_tags_deselected);
ClassDB::bind_method(D_METHOD("_handle_tags_selected"), &GGSTagDocks::_handle_tags_selected);
ClassDB::bind_method(D_METHOD("_on_selection_changed"), &TagDocks::_on_selection_changed);
ClassDB::bind_method(D_METHOD("_handle_tags_deselected"), &TagDocks::_handle_tags_deselected);
ClassDB::bind_method(D_METHOD("_handle_tags_selected"), &TagDocks::_handle_tags_selected);
}

void GGSTagDocks::render()
void TagDocks::render()
{
for (int i = 0; i < tag_trees_container->get_child_count(); i++)
{
Expand All @@ -68,7 +69,7 @@ void GGSTagDocks::render()
}
}

VBoxContainer *GGSTagDocks::render_node_tags(Node *p_node, TagDictionary *p_all_tags)
VBoxContainer *TagDocks::render_node_tags(Node *p_node, TagDictionary *p_all_tags)
{
VBoxContainer *container = memnew(VBoxContainer);
PackedStringArray tags_used_by = TagManager::get_singleton()->get_tags(p_node);
Expand All @@ -92,22 +93,22 @@ VBoxContainer *GGSTagDocks::render_node_tags(Node *p_node, TagDictionary *p_all_
return container;
}

void GGSTagDocks::_handle_tags_deselected(PackedStringArray p_tags)
void TagDocks::_handle_tags_deselected(PackedStringArray p_tags)
{
_set_tags_selected(p_tags, false);
}

void GGSTagDocks::_handle_tags_selected(PackedStringArray p_tags)
void TagDocks::_handle_tags_selected(PackedStringArray p_tags)
{
_set_tags_selected(p_tags, true);
}

void GGSTagDocks::_on_selection_changed()
void TagDocks::_on_selection_changed()
{
render();
}

void GGSTagDocks::_set_tags_selected(PackedStringArray p_tags, bool selected)
void TagDocks::_set_tags_selected(PackedStringArray p_tags, bool selected)
{
TypedArray<Node> selected_nodes = EditorInterface::get_singleton()->get_selection()->get_selected_nodes();
EditorInterface *editor_interface = EditorInterface::get_singleton();
Expand All @@ -130,7 +131,7 @@ void GGSTagDocks::_set_tags_selected(PackedStringArray p_tags, bool selected)
editor_interface->save_scene();
}

void GGSTagDocks::_handle_check_propagated_to_item(TreeItem *p_tree_item, int column)
void TagDocks::_handle_check_propagated_to_item(TreeItem *p_tree_item, int column)
{
WARN_PRINT("GGSTagDocks::_handle_check_propagated_to_item() is not implemented yet.");
}
10 changes: 5 additions & 5 deletions src/editor_plugin/docks/tag/tag_docks.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@

using namespace godot;

namespace ggs
namespace ggs::editor_plugin
{
class GGSTagDocks : public VBoxContainer
class TagDocks : public VBoxContainer
{
GDCLASS(GGSTagDocks, VBoxContainer);
GDCLASS(TagDocks, VBoxContainer);

public:
GGSTagDocks();
~GGSTagDocks();
TagDocks();
~TagDocks();

void _ready() override;

Expand Down
13 changes: 7 additions & 6 deletions src/editor_plugin/ggs_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
#include "ggs_editor_plugin.h"

using namespace ggs;
using namespace ggs::editor_plugin;

static GGSMainScene *ggs_tag_main_scene = nullptr;
static GGSTagDocks *ggs_tag_docks = nullptr;
static GGSAttributeContainerInspector *ggs_attribute_container_inspector = nullptr;
static MainScene *ggs_tag_main_scene = nullptr;
static TagDocks *ggs_tag_docks = nullptr;
static AttributeContainerInspector *ggs_attribute_container_inspector = nullptr;

GGSEditorPlugin::GGSEditorPlugin()
{
Expand All @@ -25,9 +26,9 @@ GGSEditorPlugin::~GGSEditorPlugin()

void GGSEditorPlugin::_enter_tree()
{
ggs_tag_main_scene = memnew(GGSMainScene);
ggs_tag_docks = memnew(GGSTagDocks);
ggs_attribute_container_inspector = memnew(GGSAttributeContainerInspector);
ggs_tag_main_scene = memnew(MainScene);
ggs_tag_docks = memnew(TagDocks);
ggs_attribute_container_inspector = memnew(AttributeContainerInspector);

EditorInterface::get_singleton()->get_editor_main_screen()->add_child(ggs_tag_main_scene);

Expand Down
2 changes: 1 addition & 1 deletion src/editor_plugin/ggs_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

using namespace godot;

namespace ggs
namespace ggs::editor_plugin
{
class GGSEditorPlugin : public EditorPlugin
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,25 @@
#include "system/tag/tag_manager.h"

using namespace ggs;
using namespace ggs::editor_plugin;

void GGSAttributeMainScene::_bind_methods()
void AttributeMainScene::_bind_methods()
{
/// binds methods
ClassDB::bind_method(D_METHOD("_handle_dictionary_selected", "p_item_index"), &GGSAttributeMainScene::_handle_dictionary_selected);
ClassDB::bind_method(D_METHOD("render"), &GGSAttributeMainScene::render);
ClassDB::bind_method(D_METHOD("_handle_dictionary_selected", "p_item_index"), &AttributeMainScene::_handle_dictionary_selected);
ClassDB::bind_method(D_METHOD("render"), &AttributeMainScene::render);
}

GGSAttributeMainScene::GGSAttributeMainScene()
AttributeMainScene::AttributeMainScene()
{
tag_dictionary = memnew(TagDictionary);
}

GGSAttributeMainScene::~GGSAttributeMainScene()
AttributeMainScene::~AttributeMainScene()
{
}

void GGSAttributeMainScene::_ready()
void AttributeMainScene::_ready()
{
set_anchors_and_offsets_preset(PRESET_FULL_RECT);

Expand Down Expand Up @@ -61,7 +62,7 @@ void GGSAttributeMainScene::_ready()
add_child(selected_tags_tree);
}

void GGSAttributeMainScene::_handle_dictionary_selected(int p_item_index)
void AttributeMainScene::_handle_dictionary_selected(int p_item_index)
{
TypedArray<TagDictionary> *items = TagManager::get_singleton()->dictionaries;
Variant variant = items->operator[](p_item_index);
Expand All @@ -78,7 +79,7 @@ void GGSAttributeMainScene::_handle_dictionary_selected(int p_item_index)
}
}

void GGSAttributeMainScene::render()
void AttributeMainScene::render()
{
TypedArray<TagDictionary> *items = TagManager::get_singleton()->dictionaries;
String current_value = AttributeProjectSettings::get_attribute_resource_path();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
#include "system/tag/tag_tree.h"

using namespace godot;
using namespace ggs;

namespace ggs
namespace ggs::editor_plugin
{
class TagDictionary;

class GGSAttributeMainScene : public VBoxContainer
class AttributeMainScene : public VBoxContainer
{
GDCLASS(GGSAttributeMainScene, VBoxContainer)
GDCLASS(AttributeMainScene, VBoxContainer)

protected:
static void _bind_methods();
Expand All @@ -27,8 +26,8 @@ namespace ggs
TagTree *selected_tags_tree;

public:
GGSAttributeMainScene();
~GGSAttributeMainScene();
AttributeMainScene();
~AttributeMainScene();

void _ready() override;
void _handle_dictionary_selected(int p_item_index);
Expand Down
13 changes: 7 additions & 6 deletions src/editor_plugin/main_scene/ggs_main_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
#include "ggs_main_scene.h"

using namespace ggs;
using namespace ggs::editor_plugin;

GGSMainScene::GGSMainScene()
MainScene::MainScene()
{
}

GGSMainScene::~GGSMainScene()
MainScene::~MainScene()
{
}

void GGSMainScene::_ready()
void MainScene::_ready()
{
ability_panel = memnew(Panel);
attributes_panel = memnew(Panel);
Expand All @@ -31,13 +32,13 @@ void GGSMainScene::_ready()
attributes_panel->set_name(attributes_panel->tr("Attributes"));
ability_panel->set_name(ability_panel->tr("Ability"));

GGSAttributeMainScene *attribute_main_scene = memnew(GGSAttributeMainScene);
GGSTagMainScene *tag_main_scene = memnew(GGSTagMainScene);
AttributeMainScene *attribute_main_scene = memnew(AttributeMainScene);
TagMainScene *tag_main_scene = memnew(TagMainScene);

attributes_panel->add_child(attribute_main_scene);
tag_manager_panel->add_child(tag_main_scene);
}

void GGSMainScene::_bind_methods()
void MainScene::_bind_methods()
{
}
10 changes: 5 additions & 5 deletions src/editor_plugin/main_scene/ggs_main_scene.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

using namespace godot;

namespace ggs
namespace ggs::editor_plugin
{
class GGSMainScene : public Control
class MainScene : public Control
{
enum GGSMainSceneTab
{
Expand All @@ -18,11 +18,11 @@ namespace ggs
TAG_MANAGER,
};

GDCLASS(GGSMainScene, Control);
GDCLASS(MainScene, Control);

public:
GGSMainScene();
~GGSMainScene();
MainScene();
~MainScene();

void _ready() override;

Expand Down
Loading

0 comments on commit a82c275

Please sign in to comment.