From f2a24aaffd5662d520a1e64628227536559d5d4e Mon Sep 17 00:00:00 2001 From: Manolis Papadeas <35376950+OverloadedOrama@users.noreply.github.com> Date: Fri, 11 Mar 2022 01:48:50 +0200 Subject: [PATCH] Set grayscale vision node properties instead of in code --- src/Autoload/Global.gd | 1 - src/UI/TopMenuContainer.gd | 6 +++--- src/UI/UI.gd | 9 +-------- src/UI/UI.tscn | 3 +++ 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Autoload/Global.gd b/src/Autoload/Global.gd index 84774100b..055b8f77f 100644 --- a/src/Autoload/Global.gd +++ b/src/Autoload/Global.gd @@ -122,7 +122,6 @@ onready var cameras := [camera, camera2, camera_preview] onready var horizontal_ruler: BaseButton = control.find_node("HorizontalRuler") onready var vertical_ruler: BaseButton = control.find_node("VerticalRuler") onready var transparent_checker: ColorRect = control.find_node("TransparentChecker") -onready var greyscale_vision: ColorRect = control.find_node("GreyscaleVision") onready var preview_zoom_slider: VSlider = control.find_node("PreviewZoomSlider") onready var tool_panel: ScrollContainer = control.find_node("Tools") diff --git a/src/UI/TopMenuContainer.gd b/src/UI/TopMenuContainer.gd index 43ffb019e..596024ef5 100644 --- a/src/UI/TopMenuContainer.gd +++ b/src/UI/TopMenuContainer.gd @@ -57,6 +57,7 @@ onready var select_menu_button: MenuButton = find_node("SelectMenu") onready var help_menu_button: MenuButton = find_node("HelpMenu") onready var ui: Container = Global.control.find_node("DockableContainer") +onready var greyscale_vision: ColorRect = ui.find_node("GreyscaleVision") onready var new_image_dialog: ConfirmationDialog = Global.control.find_node("CreateNewImage") onready var window_opacity_dialog: AcceptDialog = Global.control.find_node("WindowOpacityDialog") onready var tile_mode_submenu := PopupMenu.new() @@ -498,8 +499,7 @@ func set_layout(id: int) -> void: var is_hidden: bool = ui.is_control_hidden(ui_elements[i]) panels_submenu.set_item_checked(i, !is_hidden) - # Turn zen mode off - if zen_mode: + if zen_mode: # Turn zen mode off Global.control.find_node("TabsContainer").visible = true zen_mode = false window_menu.set_item_checked(WindowMenuId.ZEN_MODE, false) @@ -507,7 +507,7 @@ func set_layout(id: int) -> void: func _toggle_greyscale_view() -> void: Global.greyscale_view = !Global.greyscale_view - Global.greyscale_vision.visible = Global.greyscale_view + greyscale_vision.visible = Global.greyscale_view view_menu.set_item_checked(ViewMenuId.GREYSCALE_VIEW, Global.greyscale_view) diff --git a/src/UI/UI.gd b/src/UI/UI.gd index 0e0384d83..8bb061e26 100644 --- a/src/UI/UI.gd +++ b/src/UI/UI.gd @@ -7,13 +7,6 @@ onready var main_canvas_container = Global.main_canvas_container func _ready() -> void: update_transparent_shader() - # Set anchors for ShaderVision - Global.greyscale_vision.visible = false - Global.greyscale_vision.anchor_left = ANCHOR_BEGIN - Global.greyscale_vision.anchor_top = ANCHOR_BEGIN - Global.greyscale_vision.anchor_right = ANCHOR_END - Global.greyscale_vision.anchor_bottom = ANCHOR_END - func _on_main_canvas_item_rect_changed() -> void: update_transparent_shader() @@ -27,4 +20,4 @@ func update_transparent_shader() -> void: # Works independently of the transparency feature material.set("shader_param/screen_resolution", get_viewport().size) material.set("shader_param/position", main_canvas_container.rect_global_position) - material.set("shader_param/size", main_canvas_container.rect_size) + material.set("shader_param/size", main_canvas_container.rect_size - Vector2.ONE * 2) diff --git a/src/UI/UI.tscn b/src/UI/UI.tscn index 02e27a0ae..ff620725d 100644 --- a/src/UI/UI.tscn +++ b/src/UI/UI.tscn @@ -302,7 +302,10 @@ script = ExtResource( 7 ) [node name="CanvasLayer" type="CanvasLayer" parent="DockableContainer/Main Canvas/ViewportandVerticalRuler/ViewportContainer/Viewport"] [node name="GreyscaleVision" type="ColorRect" parent="DockableContainer/Main Canvas/ViewportandVerticalRuler/ViewportContainer/Viewport/CanvasLayer"] +visible = false material = SubResource( 27 ) +anchor_right = 1.0 +anchor_bottom = 1.0 margin_right = 40.0 margin_bottom = 40.0 mouse_filter = 2