extends RichTextLabel class_name GameMenuButton signal pressed # Style properties var normal_color: Color = Color(1, 1, 1, 1) # White var hover_color: Color = Color(1, 1, 0, 1) # Yellow var font_size: int = 28 func _ready(): # Make this label clickable mouse_filter = Control.MOUSE_FILTER_STOP # Prevent text wrapping autowrap_mode = TextServer.AUTOWRAP_OFF fit_content = true # Set size flags to expand horizontally size_flags_horizontal = SIZE_EXPAND_FILL # Remove default padding/margin add_theme_constant_override("margin_top", 0) add_theme_constant_override("margin_bottom", 0) add_theme_constant_override("margin_left", 0) add_theme_constant_override("margin_right", 0) # Remove line spacing add_theme_constant_override("line_separation", 0) # Set up base styling add_theme_font_size_override("normal_font_size", font_size) add_theme_color_override("default_color", normal_color) # Make text bold bbcode_enabled = true text = "[b]" + text + "[/b]" # Connect the gui_input signal to our own handler connect("gui_input", Callable(self, "_on_gui_input")) # Connect hover signals for better user experience connect("mouse_entered", Callable(self, "_on_mouse_entered")) connect("mouse_exited", Callable(self, "_on_mouse_exited")) func _on_gui_input(event): if event is InputEventMouseButton: if event.button_index == MOUSE_BUTTON_LEFT and event.pressed: emit_signal("pressed") get_viewport().set_input_as_handled() func _on_mouse_entered(): # Change appearance when mouse hovers add_theme_color_override("default_color", hover_color) # Scale up slightly on hover (optional) var tween = create_tween() tween.tween_property(self, "scale", Vector2(1.05, 1.05), 0.1) func _on_mouse_exited(): # Restore original appearance add_theme_color_override("default_color", normal_color) # Scale back to normal (optional) var tween = create_tween() tween.tween_property(self, "scale", Vector2(1.0, 1.0), 0.1)