mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-12 08:43:08 +00:00
c6b9a1fb82
* gdformat . * Lint code - Part 1 * Format code - Part 2 * Lint code - Part 2 Trying to fix the max allowed line length errors * Add normal_map_invert_y to the image .import files Because of Godot 3.4 * Do not call private methods outside of the script's scope Lint code - Part 3 * Format code - Part 3 * Fixed more line length exceeded errors - Lint code Part 3 * Export array of licenses - Lint code part 4 * Clean hint_tooltip code from Global Removes a lot of lines of code * Create static-checks.yml * Fix FreeType's license
48 lines
1.6 KiB
GDScript
48 lines
1.6 KiB
GDScript
extends ColorRect
|
|
|
|
|
|
func _ready() -> void:
|
|
update_rect()
|
|
|
|
|
|
func update_rect() -> void:
|
|
rect_size = Global.current_project.size
|
|
if self == Global.transparent_checker:
|
|
fit_rect(Global.current_project.get_tile_mode_rect())
|
|
Global.second_viewport.get_node("Viewport/TransparentChecker").update_rect()
|
|
Global.small_preview_viewport.get_node("Viewport/TransparentChecker").update_rect()
|
|
material.set_shader_param("size", Global.checker_size)
|
|
material.set_shader_param("color1", Global.checker_color_1)
|
|
material.set_shader_param("color2", Global.checker_color_2)
|
|
material.set_shader_param("follow_movement", Global.checker_follow_movement)
|
|
material.set_shader_param("follow_scale", Global.checker_follow_scale)
|
|
|
|
|
|
func update_offset(offset: Vector2, scale: Vector2) -> void:
|
|
material.set_shader_param("offset", offset)
|
|
material.set_shader_param("scale", scale)
|
|
|
|
|
|
func _on_TransparentChecker_resized() -> void:
|
|
material.set_shader_param("rect_size", rect_size)
|
|
|
|
|
|
func fit_rect(rect: Rect2) -> void:
|
|
rect_position = rect.position
|
|
rect_size = rect.size
|
|
|
|
|
|
func transparency(value: float) -> void:
|
|
# first make viewport transparent then background and then viewport
|
|
if value == 1.0:
|
|
get_parent().transparent_bg = false
|
|
get_tree().get_root().set_transparent_background(false)
|
|
else:
|
|
OS.window_per_pixel_transparency_enabled = true
|
|
get_parent().transparent_bg = true
|
|
get_tree().get_root().set_transparent_background(true)
|
|
|
|
# this controls opacity 0 for transparent, 1 or a greater value than 1 is opaque
|
|
# i have set a minimum amount for the fade (We would'nt want the canvas to dissapear now would we?)
|
|
material.set("shader_param/alpha", clamp(value, 0.1, 1))
|