3535#include " core/input/input.h"
3636#include " core/license.gen.h"
3737#include " core/string/string_builder.h"
38+ #include " editor/editor_node.h"
3839#include " editor/editor_string_names.h"
3940#include " editor/themes/editor_scale.h"
4041#include " scene/gui/box_container.h"
@@ -88,13 +89,23 @@ String CreditsRoll::_build_string(const char *const *p_from) const {
8889 return sb.as_string ();
8990}
9091
92+ void CreditsRoll::_visibility_changed () {
93+ if (!is_visible ()) {
94+ mouse_enabled = false ;
95+ set_process_internal (false );
96+ set_process_input (false );
97+ }
98+ }
99+
100+ void CreditsRoll::input (const Ref<InputEvent> &p_event) {
101+ // Block inputs from going elsewhere while the credits roll.
102+ get_tree ()->get_root ()->set_input_as_handled ();
103+ }
104+
91105void CreditsRoll::_notification (int p_what) {
92106 switch (p_what) {
93- case NOTIFICATION_VISIBILITY_CHANGED: {
94- if (!is_visible ()) {
95- set_process_internal (false );
96- mouse_enabled = false ;
97- }
107+ case NOTIFICATION_POSTINITIALIZE: {
108+ connect (" visibility_changed" , callable_mp (this , &CreditsRoll::_visibility_changed));
98109 } break ;
99110
100111 case NOTIFICATION_TRANSLATION_CHANGED: {
@@ -103,18 +114,14 @@ void CreditsRoll::_notification(int p_what) {
103114 }
104115 } break ;
105116
106- case NOTIFICATION_WM_GO_BACK_REQUEST: {
107- hide ();
108- } break ;
109-
110117 case NOTIFICATION_INTERNAL_PROCESS: {
111118 const Vector2 pos = content->get_position ();
112119 if (pos.y < -content->get_size ().y - 30 ) {
113- hide ();
120+ hide (); // No more credits left, show's over.
114121 break ;
115122 }
116123
117- if (Input::get_singleton ()->is_mouse_button_pressed (MouseButton::RIGHT)) {
124+ if (Input::get_singleton ()->is_mouse_button_pressed (MouseButton::RIGHT) || Input::get_singleton ()-> is_action_pressed ( SNAME ( " ui_cancel " )) ) {
118125 hide ();
119126 break ;
120127 }
@@ -136,13 +143,13 @@ void CreditsRoll::_notification(int p_what) {
136143
137144void CreditsRoll::roll_credits () {
138145 if (!project_manager) {
139- font_size_normal = get_theme_font_size (" main_size" , EditorStringName (EditorFonts)) * 2 ;
146+ font_size_normal = EditorNode::get_singleton ()-> get_editor_theme ()-> get_font_size (" main_size" , EditorStringName (EditorFonts)) * 2 ;
140147 font_size_header = font_size_normal + 10 * EDSCALE;
141148 font_size_big_header = font_size_header + 20 * EDSCALE;
142- bold_font = get_theme_font (" bold" , EditorStringName (EditorFonts));
149+ bold_font = EditorNode::get_singleton ()-> get_editor_theme ()-> get_font (" bold" , EditorStringName (EditorFonts));
143150
144151 {
145- const Ref<Texture2D> logo_texture = get_editor_theme_icon ( " Logo" );
152+ const Ref<Texture2D> logo_texture = EditorNode::get_singleton ()-> get_editor_theme ()-> get_icon ( " Logo" , EditorStringName (EditorIcons) );
146153
147154 TextureRect *logo = memnew (TextureRect);
148155 logo->set_custom_minimum_size (Vector2 (0 , logo_texture->get_height () * 3 ));
@@ -220,28 +227,22 @@ void CreditsRoll::roll_credits() {
220227 _create_nothing (400 * EDSCALE);
221228 _create_label (TTRC (" Thank you for choosing Godot Engine!" ), LabelSize::BIG_HEADER);
222229 }
230+ // Needs to be set here, so it stays centered even if the window is resized.
231+ content->set_anchors_and_offsets_preset (Control::PRESET_VCENTER_WIDE);
223232
224233 Window *root = get_tree ()->get_root ();
225234 content->set_position (Vector2 (content->get_position ().x , root->get_size ().y + 30 ));
226235
227- set_position (root->get_position ());
228- set_size (root->get_size ());
229-
230- popup ();
231236 set_process_internal (true );
237+ set_process_input (true );
232238}
233239
234240CreditsRoll::CreditsRoll () {
235- set_wrap_controls (false );
236-
237- {
238- ColorRect *background = memnew (ColorRect);
239- background->set_color (Color (0 , 0 , 0 , 1 ));
240- background->set_anchors_and_offsets_preset (Control::PRESET_FULL_RECT);
241- add_child (background);
242- }
241+ ColorRect *background = memnew (ColorRect);
242+ background->set_color (Color (0 , 0 , 0 , 1 ));
243+ background->set_anchors_and_offsets_preset (Control::PRESET_FULL_RECT);
244+ add_child (background);
243245
244246 content = memnew (VBoxContainer);
245- content->set_anchors_and_offsets_preset (Control::PRESET_FULL_RECT);
246247 add_child (content);
247248}
0 commit comments