Skip to content

Commit

Permalink
Make the rendering method dropdown also affect mobile if compatible
Browse files Browse the repository at this point in the history
This prevents visual discrepancies between desktop and mobile platforms
after switching rendering methods using this dropdown.

The restart dialog now displays which rendering methods will be used,
and the dropdown tooltip also lists caveats related to specific platforms.
  • Loading branch information
Calinou committed Jan 3, 2024
1 parent fbaab3c commit 57f3bdb
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3012,6 +3012,16 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case SET_RENDERER_NAME_SAVE_AND_RESTART: {
ProjectSettings::get_singleton()->set("rendering/renderer/rendering_method", renderer_request);
if (renderer_request == "mobile" || renderer_request == "gl_compatibility") {
// Also change the mobile override if changing to a compatible rendering method.
// This prevents visual discrepancies between desktop and mobile platforms.
ProjectSettings::get_singleton()->set("rendering/renderer/rendering_method.mobile", renderer_request);
} else if (renderer_request == "forward_plus") {
// Use the equivalent mobile rendering method. This prevents the rendering method from staying
// on its old choice if moving from `gl_compatibility` to `forward_plus`.
ProjectSettings::get_singleton()->set("rendering/renderer/rendering_method.mobile", "mobile");
}

ProjectSettings::get_singleton()->save();

save_all_scenes();
Expand Down Expand Up @@ -6575,6 +6585,9 @@ void EditorNode::_renderer_selected(int p_which) {
}

renderer_request = rendering_method;
video_restart_dialog->set_text(
vformat(TTR("Changing the renderer requires restarting the editor.\n\nChoosing Save & Restart will change the rendering method to:\n- Desktop platforms: %s\n- Mobile platforms: %s\n- Web platform: gl_compatibility"),
renderer_request, renderer_request.replace("forward_plus", "mobile")));
video_restart_dialog->popup_centered();
renderer->select(renderer_current);
_update_renderer_color();
Expand Down Expand Up @@ -7552,7 +7565,7 @@ EditorNode::EditorNode() {
renderer->set_focus_mode(Control::FOCUS_NONE);
renderer->add_theme_font_override("font", theme->get_font(SNAME("bold"), EditorStringName(EditorFonts)));
renderer->add_theme_font_size_override("font_size", theme->get_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)));
renderer->set_tooltip_text(TTR("Choose a renderer."));
renderer->set_tooltip_text(TTR("Choose a rendering method.\n\nNotes:\n- On mobile platforms, the Mobile rendering method is used if Forward+ is selected here.\n- On the web platform, the Compatibility rendering method is always used."));

right_menu_hb->add_child(renderer);

Expand Down Expand Up @@ -7594,7 +7607,6 @@ EditorNode::EditorNode() {
_update_renderer_color();

video_restart_dialog = memnew(ConfirmationDialog);
video_restart_dialog->set_text(TTR("Changing the renderer requires restarting the editor."));
video_restart_dialog->set_ok_button_text(TTR("Save & Restart"));
video_restart_dialog->connect("confirmed", callable_mp(this, &EditorNode::_menu_option).bind(SET_RENDERER_NAME_SAVE_AND_RESTART));
gui_base->add_child(video_restart_dialog);
Expand Down

0 comments on commit 57f3bdb

Please sign in to comment.