From 736521246d930adeb0f2bb3c45148155ad307411 Mon Sep 17 00:00:00 2001 From: OverloadedOrama <35376950+OverloadedOrama@users.noreply.github.com> Date: Fri, 5 Jun 2020 16:21:19 +0300 Subject: [PATCH] Change guides when switching project --- project.godot | 2 +- src/Classes/Project.gd | 10 +++++++++- src/UI/Rulers/Guides.gd | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/project.godot b/project.godot index d18916260..be35ebfc4 100644 --- a/project.godot +++ b/project.godot @@ -89,7 +89,7 @@ boot_splash/bg_color=Color( 0.145098, 0.145098, 0.164706, 1 ) config/icon="res://assets/graphics/icons/icon.png" config/macos_native_icon="res://assets/graphics/icons/icon.icns" config/windows_native_icon="res://assets/graphics/icons/icon.ico" -config/Version="v0.7.1" +config/Version="v0.8-dev" [autoload] diff --git a/src/Classes/Project.gd b/src/Classes/Project.gd index 925ecfd6a..d7b6ef99a 100644 --- a/src/Classes/Project.gd +++ b/src/Classes/Project.gd @@ -12,7 +12,7 @@ var layers := [] setget layers_changed # Array of Layers var current_frame := 0 setget frame_changed var current_layer := 0 setget layer_changed var animation_tags := [] setget animation_tags_changed # Array of AnimationTags -#var guides := [] # Array of Guides +var guides := [] # Array of Guides var brushes := [] # Array of Images var brush_images := [Image.new(), Image.new()] @@ -91,6 +91,7 @@ func change_project() -> void: self.animation_tags = animation_tags + # Change the selection rectangle if selected_pixels.size() != 0: Global.selection_rectangle.polygon[0] = Vector2(x_min, y_min) Global.selection_rectangle.polygon[1] = Vector2(x_max, y_min) @@ -102,6 +103,13 @@ func change_project() -> void: Global.selection_rectangle.polygon[2] = Vector2.ZERO Global.selection_rectangle.polygon[3] = Vector2.ZERO + for guide in Global.canvas.get_children(): + if guide is Guide: + if guide in guides: + guide.visible = true + else: + guide.visible = false + func frames_changed(value : Array) -> void: frames = value diff --git a/src/UI/Rulers/Guides.gd b/src/UI/Rulers/Guides.gd index af6840306..62552f663 100644 --- a/src/UI/Rulers/Guides.gd +++ b/src/UI/Rulers/Guides.gd @@ -13,6 +13,7 @@ var type = Types.HORIZONTAL func _ready() -> void: width = 0.1 default_color = Global.guide_color + Global.current_project.guides.append(self) func _input(_event : InputEvent): @@ -31,7 +32,7 @@ func _input(_event : InputEvent): has_focus = true Global.has_focus = false update() - if has_focus: + if has_focus and visible: if Input.is_action_just_pressed("left_mouse"): previous_points = points if Input.is_action_pressed("left_mouse"):