diff --git a/src/Main.tscn b/src/Main.tscn index f5cae27e7..e7e285a81 100644 --- a/src/Main.tscn +++ b/src/Main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=17 format=3 uid="uid://dbylw5k04ulp8"] +[gd_scene load_steps=16 format=3 uid="uid://dbylw5k04ulp8"] [ext_resource type="Theme" uid="uid://cngbvfpwjoimv" path="res://assets/themes/dark/theme.tres" id="1"] [ext_resource type="Script" path="res://src/Main.gd" id="2"] @@ -8,7 +8,6 @@ [ext_resource type="PackedScene" uid="uid://c5x85ysdouh4t" path="res://src/UI/Buttons/BrushesPopup.tscn" id="6"] [ext_resource type="PackedScene" uid="uid://cltlo2whtiejd" path="res://src/UI/Dialogs/SaveSpriteHTML5.tscn" id="8"] [ext_resource type="PackedScene" uid="uid://bs3dnnvnxyp68" path="res://src/UI/Timeline/FrameProperties.tscn" id="9"] -[ext_resource type="PackedScene" uid="uid://bcdt0pa7rojy5" path="res://src/UI/Dialogs/WindowOpacityDialog.tscn" id="10"] [ext_resource type="PackedScene" uid="uid://d4euwo633u33b" path="res://src/UI/Dialogs/SaveSprite.tscn" id="11"] [ext_resource type="PackedScene" uid="uid://b3aeqj2k58wdk" path="res://src/UI/Dialogs/OpenSprite.tscn" id="12"] [ext_resource type="PackedScene" uid="uid://c0nuukjakmai2" path="res://src/UI/Dialogs/TileModeOffsetsDialog.tscn" id="14"] @@ -91,8 +90,6 @@ dialog_autowrap = true [node name="FrameProperties" parent="Dialogs" instance=ExtResource("9")] -[node name="WindowOpacityDialog" parent="Dialogs" instance=ExtResource("10")] - [node name="TileModeOffsetsDialog" parent="Dialogs" instance=ExtResource("14")] [node name="Extensions" type="Control" parent="."] diff --git a/src/UI/Dialogs/WindowOpacityDialog.gd b/src/UI/Dialogs/WindowOpacityDialog.gd index d429a4c3b..e8f0524a3 100644 --- a/src/UI/Dialogs/WindowOpacityDialog.gd +++ b/src/UI/Dialogs/WindowOpacityDialog.gd @@ -13,11 +13,8 @@ func _ready() -> void: func _on_WindowOpacityDialog_about_to_show() -> void: get_tree().root.transparent = true get_tree().root.transparent_bg = true - slider.editable = !( - (get_window().mode == Window.MODE_EXCLUSIVE_FULLSCREEN) - or (get_window().mode == Window.MODE_FULLSCREEN) - ) - fullscreen_warning.visible = !slider.editable + slider.editable = not is_fullscreen() + fullscreen_warning.visible = not slider.editable func _recalculate_opacity() -> void: @@ -25,13 +22,9 @@ func _recalculate_opacity() -> void: func set_window_opacity(value: float) -> void: - if ( - (get_window().mode == Window.MODE_EXCLUSIVE_FULLSCREEN) - or (get_window().mode == Window.MODE_FULLSCREEN) - ): + if is_fullscreen(): value = 100.0 slider.value = value - value = value / 100.0 # Find the TabContainer that has the Main Canvas panel for container: Control in Global.control.main_ui._panel_container.get_children(): @@ -44,3 +37,10 @@ func set_window_opacity(value: float) -> void: func _on_visibility_changed() -> void: Global.dialog_open(false) + + +func is_fullscreen() -> bool: + return ( + (get_parent().get_window().mode == Window.MODE_EXCLUSIVE_FULLSCREEN) + or (get_parent().get_window().mode == Window.MODE_FULLSCREEN) + ) diff --git a/src/UI/TopMenuContainer/TopMenuContainer.gd b/src/UI/TopMenuContainer/TopMenuContainer.gd index db88691e2..f137cd697 100644 --- a/src/UI/TopMenuContainer/TopMenuContainer.gd +++ b/src/UI/TopMenuContainer/TopMenuContainer.gd @@ -30,6 +30,7 @@ var gradient_map_dialog := Dialog.new("res://src/UI/Dialogs/ImageEffects/Gradien var posterize_dialog := Dialog.new("res://src/UI/Dialogs/ImageEffects/Posterize.tscn") var shader_effect_dialog := Dialog.new("res://src/UI/Dialogs/ImageEffects/ShaderEffect.tscn") var manage_layouts_dialog := Dialog.new("res://src/UI/Dialogs/ManageLayouts.tscn") +var window_opacity_dialog := Dialog.new("res://src/UI/Dialogs/WindowOpacityDialog.tscn") var about_dialog := Dialog.new("res://src/UI/Dialogs/AboutDialog.tscn") @onready var main_ui := Global.control.find_child("DockableContainer") as DockableContainer @@ -43,7 +44,6 @@ var about_dialog := Dialog.new("res://src/UI/Dialogs/AboutDialog.tscn") @onready var help_menu: PopupMenu = $MenuBar/Help @onready var greyscale_vision: ColorRect = main_ui.find_child("GreyscaleVision") -@onready var window_opacity_dialog: AcceptDialog = Global.control.find_child("WindowOpacityDialog") @onready var tile_mode_submenu := PopupMenu.new() @onready var snap_to_submenu := PopupMenu.new() @onready var panels_submenu := PopupMenu.new() @@ -534,7 +534,7 @@ func view_menu_id_pressed(id: int) -> void: func window_menu_id_pressed(id: int) -> void: match id: Global.WindowMenu.WINDOW_OPACITY: - _popup_dialog(window_opacity_dialog) + window_opacity_dialog.popup() Global.WindowMenu.MOVABLE_PANELS: main_ui.tabs_visible = !main_ui.tabs_visible window_menu.set_item_checked(id, main_ui.tabs_visible) @@ -682,26 +682,13 @@ func _toggle_zen_mode() -> void: func _toggle_fullscreen() -> void: - get_window().mode = ( - Window.MODE_EXCLUSIVE_FULLSCREEN - if (!( - (get_window().mode == Window.MODE_EXCLUSIVE_FULLSCREEN) - or (get_window().mode == Window.MODE_FULLSCREEN) - )) - else Window.MODE_WINDOWED - ) - window_menu.set_item_checked( - Global.WindowMenu.FULLSCREEN_MODE, - ( - (get_window().mode == Window.MODE_EXCLUSIVE_FULLSCREEN) - or (get_window().mode == Window.MODE_FULLSCREEN) - ) - ) - if ( + var is_fullscreen := ( (get_window().mode == Window.MODE_EXCLUSIVE_FULLSCREEN) or (get_window().mode == Window.MODE_FULLSCREEN) - ): # If window is fullscreen then reset transparency - window_opacity_dialog.set_window_opacity(100.0) + ) + get_window().mode = Window.MODE_EXCLUSIVE_FULLSCREEN if !is_fullscreen else Window.MODE_WINDOWED + is_fullscreen = not is_fullscreen + window_menu.set_item_checked(Global.WindowMenu.FULLSCREEN_MODE, is_fullscreen) func image_menu_id_pressed(id: int) -> void: