1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

Portals - lift roomlist restrictions and fix link bug

Allows users to have the RoomManager as the roomlist.

Fixes a couple of bugs dealing with situations where users attempt to link Portals to Rooms outside the roomlist.

Adds a PortalEditorPlugin allowing you to flip individual portals.
This commit is contained in:
lawnjelly
2021-07-16 09:15:14 +01:00
parent 06d66488c2
commit 83f1377a8f
7 changed files with 197 additions and 65 deletions

View File

@@ -170,3 +170,53 @@ RoomEditorPlugin::RoomEditorPlugin(EditorNode *p_node) {
RoomEditorPlugin::~RoomEditorPlugin() {
}
///////////////////////
void PortalEditorPlugin::_flip_portal() {
if (_portal) {
_portal->flip();
_portal->_changed();
}
}
void PortalEditorPlugin::edit(Object *p_object) {
Portal *p = Object::cast_to<Portal>(p_object);
if (!p) {
return;
}
_portal = p;
}
bool PortalEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("Portal");
}
void PortalEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
button_flip->show();
} else {
button_flip->hide();
}
}
void PortalEditorPlugin::_bind_methods() {
ClassDB::bind_method("_flip_portal", &PortalEditorPlugin::_flip_portal);
}
PortalEditorPlugin::PortalEditorPlugin(EditorNode *p_node) {
editor = p_node;
button_flip = memnew(ToolButton);
button_flip->set_icon(editor->get_gui_base()->get_icon("Portal", "EditorIcons"));
button_flip->set_text(TTR("Flip Portal"));
button_flip->hide();
button_flip->connect("pressed", this, "_flip_portal");
add_control_to_container(CONTAINER_SPATIAL_EDITOR_MENU, button_flip);
_portal = nullptr;
}
PortalEditorPlugin::~PortalEditorPlugin() {
}