Portals - Fix UI default

I had forgotten to add a call to update_portal_tools() at the end of the SpatialEditor constructors. This ensures that the portal UI is off by default in normal use without portals.
This commit is contained in:
lawnjelly 2021-08-02 16:01:59 +01:00
parent 73c6ab0215
commit 9e9abe2137
2 changed files with 26 additions and 19 deletions

View file

@ -4319,28 +4319,31 @@ void SpatialEditor::show_advanced_portal_tools(bool p_show) {
} }
void SpatialEditor::update_portal_tools() { void SpatialEditor::update_portal_tools() {
// the view portal culling toggle // just some protection against calling null pointers, hopefully not needed
int view_portal_item_index = view_menu->get_popup()->get_item_index(MENU_VIEW_PORTAL_CULLING); if (view_menu && view_menu->get_popup()) {
if (RoomManager::active_room_manager) { // the view portal culling toggle
view_menu->get_popup()->set_item_disabled(view_portal_item_index, false); int view_portal_item_index = view_menu->get_popup()->get_item_index(MENU_VIEW_PORTAL_CULLING);
if (RoomManager::active_room_manager) {
view_menu->get_popup()->set_item_disabled(view_portal_item_index, false);
bool active = RoomManager::static_rooms_get_active(); bool active = RoomManager::static_rooms_get_active();
view_menu->get_popup()->set_item_checked(view_portal_item_index, active); view_menu->get_popup()->set_item_checked(view_portal_item_index, active);
} else { } else {
view_menu->get_popup()->set_item_disabled(view_portal_item_index, true); view_menu->get_popup()->set_item_disabled(view_portal_item_index, true);
} }
// toolbar button // toolbar button
Button *const button = tool_button[TOOL_CONVERT_ROOMS]; Button *const button = tool_button[TOOL_CONVERT_ROOMS];
if (RoomManager::active_room_manager) { if (RoomManager::active_room_manager) {
button->show(); button->show();
} else { } else {
button->hide(); button->hide();
} }
for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) { for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
viewports[i]->_update_name(); viewports[i]->_update_name();
}
} }
} }
@ -6593,6 +6596,10 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
EDITOR_DEF("editors/3d/navigation/show_viewport_rotation_gizmo", true); EDITOR_DEF("editors/3d/navigation/show_viewport_rotation_gizmo", true);
over_gizmo_handle = -1; over_gizmo_handle = -1;
// make sure the portal tools are off by default
// (when no RoomManager is present)
update_portal_tools();
} }
SpatialEditor::~SpatialEditor() { SpatialEditor::~SpatialEditor() {

View file

@ -652,7 +652,7 @@ private:
MenuButton *transform_menu; MenuButton *transform_menu;
PopupMenu *gizmos_menu; PopupMenu *gizmos_menu;
MenuButton *view_menu; MenuButton *view_menu = nullptr;
AcceptDialog *accept; AcceptDialog *accept;