Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6e384e221 | ||
|
|
c4ee699d49 | ||
|
|
dfe34fb698 | ||
|
|
74056af39a | ||
|
|
cf1c3ceba4 | ||
|
|
5484be0028 | ||
|
|
5a06cbaf65 | ||
|
|
34f60a1bbe | ||
|
|
feec70d2ab | ||
|
|
141c62952c |
No files matched your search
@@ -1,5 +1,4 @@
|
||||
extends Window
|
||||
|
||||
## Godot addon that lets you rapidly take screenshots. Supports taking bursts in multiple resolutions, locales, and formats.
|
||||
|
||||
@export var _local_data: Node
|
||||
@@ -15,18 +14,20 @@ signal burst_ended
|
||||
|
||||
var _input_action: String
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var saved_position = _local_data.settings.load_value("misc", "ShutterWindowPosition")
|
||||
if saved_position:
|
||||
position = saved_position
|
||||
old_position = position
|
||||
var only_run_in_editor = _local_data.settings.load_value("misc", "OnlyRunInEditorCheckBox", true)
|
||||
visible = _local_data.settings.load_value("misc", "ShowShutterCheckBox", true)
|
||||
|
||||
if only_run_in_editor and not OS.has_feature("editor"):
|
||||
queue_free()
|
||||
set_process_input(false)
|
||||
hide()
|
||||
return
|
||||
|
||||
visible = _local_data.settings.load_value("misc", "ShowShutterCheckBox", true)
|
||||
_input_action = _local_data.settings.load_value("misc", "InputActionLineEdit", "")
|
||||
%ShutterButton.pressed.connect(take_burst)
|
||||
close_requested.connect(_on_close_requested)
|
||||
@@ -35,7 +36,10 @@ func _ready() -> void:
|
||||
func _on_close_requested() -> void:
|
||||
hide()
|
||||
|
||||
|
||||
var old_position: Vector2i
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if old_position != position:
|
||||
_local_data.settings.save("misc", "ShutterWindowPosition", position)
|
||||
@@ -51,9 +55,17 @@ func take_burst() -> void:
|
||||
var old_position = position
|
||||
_local_data.settings.load_config()
|
||||
burst_starting.emit()
|
||||
|
||||
var stretch_mode = get_tree().root.content_scale_mode
|
||||
var is_embedded = Engine.is_embedded_in_editor()
|
||||
|
||||
var pause_game = _local_data.settings.load_value("misc", "PausesGameCheckBox", true)
|
||||
var shutter_was_visible = visible
|
||||
var sizes = _local_data.settings.load_value("misc", "Sizes", [])
|
||||
|
||||
var def_width = ProjectSettings.get_setting("display/window/size/viewport_width")
|
||||
var def_height = ProjectSettings.get_setting("display/window/size/viewport_height")
|
||||
|
||||
var sizes = _local_data.settings.load_value("misc", "Sizes", [Vector2i(def_width, def_height)])
|
||||
var locales = _local_data.settings.load_value("misc", "Locales", ["none"])
|
||||
var previous_locale = TranslationServer.get_locale()
|
||||
hide()
|
||||
@@ -64,12 +76,13 @@ func take_burst() -> void:
|
||||
tree.paused = true
|
||||
var prev_size = DisplayServer.window_get_size()
|
||||
|
||||
|
||||
if stretch_mode == CONTENT_SCALE_MODE_VIEWPORT:
|
||||
prev_size = get_tree().root.get_viewport().content_scale_size
|
||||
|
||||
# Take screenshots for each configured size
|
||||
for s in sizes:
|
||||
DisplayServer.window_set_size(s)
|
||||
await get_tree().create_timer(0.01).timeout
|
||||
set_resolution(s, stretch_mode)
|
||||
await RenderingServer.frame_post_draw
|
||||
|
||||
for locale in locales:
|
||||
var locale_to_set = locale
|
||||
@@ -78,12 +91,11 @@ func take_burst() -> void:
|
||||
locale_to_set = previous_locale
|
||||
|
||||
TranslationServer.set_locale(locale_to_set)
|
||||
await get_tree().process_frame
|
||||
await RenderingServer.frame_post_draw
|
||||
save_image()
|
||||
|
||||
TranslationServer.set_locale(previous_locale)
|
||||
DisplayServer.window_set_size(prev_size)
|
||||
|
||||
set_resolution(prev_size, stretch_mode)
|
||||
|
||||
tree.paused = game_was_paused
|
||||
visible = shutter_was_visible
|
||||
@@ -91,12 +103,27 @@ func take_burst() -> void:
|
||||
print_rich("[color=green][Screenshots] Done![/color]")
|
||||
position = old_position
|
||||
|
||||
func set_resolution(resolution: Vector2i, stretch_mode: ContentScaleMode) -> void:
|
||||
var screen_resolution = DisplayServer.screen_get_size()
|
||||
match stretch_mode:
|
||||
CONTENT_SCALE_MODE_VIEWPORT:
|
||||
get_tree().root.get_viewport().content_scale_size = resolution
|
||||
_:
|
||||
if resolution > screen_resolution:
|
||||
print_rich("[color=yellow][Screenshots] Warning! You are trying to take a screenshot at %dx%d, but your screen size is %dx%d" % [resolution.x, resolution.y, screen_resolution.x, screen_resolution.y])
|
||||
print("[color=yellow][Screenshots] To take a screenshot larger than your screen size, use the 'viewport' stretch mode (Project Settings > Stretch > Mode)")
|
||||
DisplayServer.window_set_size(resolution)
|
||||
|
||||
func save_image() -> void:
|
||||
var locale = TranslationServer.get_locale()
|
||||
var timestamp = Time.get_time_string_from_system()
|
||||
var play_shutter_sounds = _local_data.settings.load_value("misc", "ShutterSoundsCheckBox", true)
|
||||
# Save the screenshot
|
||||
var image = get_parent().get_viewport().get_texture().get_image()
|
||||
var image = get_tree().root.get_viewport().get_texture().get_image()
|
||||
if get_tree().root.get_viewport().use_hdr_2d:
|
||||
if image.get_format() != Image.FORMAT_RGB8:
|
||||
image.convert(Image.FORMAT_RGB8)
|
||||
image.linear_to_srgb()
|
||||
image_captured.emit(image)
|
||||
|
||||
if play_shutter_sounds:
|
||||
@@ -122,7 +149,7 @@ func save_image() -> void:
|
||||
var formats = {
|
||||
"PNGCheckBox": ["png", image.save_png, true],
|
||||
"JPGCheckBox": ["jpg", image.save_jpg, false],
|
||||
"WEBPCheckBox": ["webp", image.save_webp, false]
|
||||
"WEBPCheckBox": ["webp", image.save_webp, false],
|
||||
}
|
||||
|
||||
for setting_key in formats:
|
||||
@@ -147,6 +174,7 @@ func save_image() -> void:
|
||||
|
||||
print_rich("[Screenshots] Saved at: [url=%s]%s[/url]" % [ProjectSettings.globalize_path(file_path.get_base_dir()), file_path])
|
||||
|
||||
|
||||
func get_unique_filepath(base_path: String) -> String:
|
||||
if not FileAccess.file_exists(base_path):
|
||||
return base_path
|
||||
@@ -163,4 +191,3 @@ func get_unique_filepath(base_path: String) -> String:
|
||||
new_path = "%s/%s_%d.%s" % [dir, filename, counter, extension]
|
||||
|
||||
return new_path
|
||||
|
||||
@@ -3,10 +3,12 @@ extends Control
|
||||
|
||||
@export var nodes_to_save: Array[Node]
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
load_nodes_from_config(nodes_to_save)
|
||||
setup_auto_save(nodes_to_save)
|
||||
|
||||
|
||||
func save_nodes_to_config(p_nodes_to_save: Array[Node]) -> void:
|
||||
for node in p_nodes_to_save:
|
||||
var key = node.name
|
||||
@@ -20,6 +22,7 @@ func save_nodes_to_config(p_nodes_to_save: Array[Node]) -> void:
|
||||
value = node.text
|
||||
%LocalData.settings.save("misc", key, value)
|
||||
|
||||
|
||||
func load_nodes_from_config(p_nodes_to_load: Array[Node]) -> void:
|
||||
for node in p_nodes_to_load:
|
||||
var value = %LocalData.settings.load_value("misc", node.name)
|
||||
@@ -30,6 +33,7 @@ func load_nodes_from_config(p_nodes_to_load: Array[Node]) -> void:
|
||||
if node is LineEdit:
|
||||
node.text = value
|
||||
|
||||
|
||||
func setup_auto_save(nodes: Array[Node]) -> void:
|
||||
for node in nodes:
|
||||
if node is CheckBox:
|
||||
@@ -37,9 +41,11 @@ func setup_auto_save(nodes: Array[Node]) -> void:
|
||||
if node is LineEdit:
|
||||
node.text_changed.connect(func(_new_text): save_nodes_to_config([node]))
|
||||
|
||||
|
||||
func on_session_started() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func on_editor_debugger_plugin_capture(p_message, p_data) -> bool:
|
||||
if p_message == "screenshot:taken":
|
||||
%CameraRoll.add_preview(p_data[0], p_data[1], p_data[2])
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
[ext_resource type="Script" uid="uid://c5poruw4iu2ve" path="res://addons/screenshots/debugger/bottom_panel/camera_roll_bottom_buttons.gd" id="8_epjix"]
|
||||
[ext_resource type="Script" uid="uid://cx82rfmwl8gk0" path="res://addons/screenshots/screenshots_local_data.gd" id="9_ke0xa"]
|
||||
|
||||
[sub_resource type="DPITexture" id="DPITexture_q8tfr"]
|
||||
[sub_resource type="DPITexture" id="DPITexture_2337e"]
|
||||
_source = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\"><path fill=\"#ff5d5d\" d=\"M2 1v8.586l1.293-1.293a1 1 0 0 1 1.414 0L7 10.587l2.293-2.293a1 1 0 0 1 1.414 0L13 10.586l1-1V6H9V1H2zm8 0v4h4zm-6 9.414-2 2V15h12v-2.586l-.293.293a1 1 0 0 1-1.414 0L10 10.414l-2.293 2.293a1 1 0 0 1-1.414 0L4 10.414z\"/></svg>
|
||||
"
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_2337e"]
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ua4ux"]
|
||||
content_margin_left = 4.0
|
||||
content_margin_top = 4.0
|
||||
content_margin_right = 4.0
|
||||
@@ -64,7 +64,7 @@ alignment = 1
|
||||
[node name="SettingsIcon" type="TextureRect" parent="HSplitContainer/VBoxContainer/PanelContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
texture = SubResource("DPITexture_q8tfr")
|
||||
texture = SubResource("DPITexture_2337e")
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="Label" type="Label" parent="HSplitContainer/VBoxContainer/PanelContainer/HBoxContainer"]
|
||||
@@ -99,6 +99,8 @@ layout_mode = 2
|
||||
[node name="Label" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer2"]
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Toggle shutter visibility"
|
||||
mouse_filter = 1
|
||||
text = "Show shutter"
|
||||
|
||||
[node name="ShowShutterCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer2"]
|
||||
@@ -113,6 +115,8 @@ layout_mode = 2
|
||||
[node name="Label" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer5"]
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
tooltip_text = "If the game is running outside the editor, hide the shutter and disable input processing"
|
||||
mouse_filter = 1
|
||||
text = "Only run in Editor"
|
||||
|
||||
[node name="OnlyRunInEditorCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer5"]
|
||||
@@ -126,6 +130,8 @@ layout_mode = 2
|
||||
[node name="Label" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer4"]
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Pause execution while taking screenshots. Useful for ensuring consistency across burst captures."
|
||||
mouse_filter = 1
|
||||
text = "Pauses game"
|
||||
|
||||
[node name="PausesGameCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer4"]
|
||||
@@ -140,6 +146,8 @@ layout_mode = 2
|
||||
[node name="Label" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer3"]
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Whether to play shutter sound effect"
|
||||
mouse_filter = 1
|
||||
text = "Shutter sounds"
|
||||
|
||||
[node name="ShutterSoundsCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer3"]
|
||||
@@ -153,6 +161,8 @@ layout_mode = 2
|
||||
[node name="Label" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer"]
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Set an Input Action to trigger a screenshot"
|
||||
mouse_filter = 1
|
||||
text = "Input Action"
|
||||
|
||||
[node name="InputActionLineEdit" type="LineEdit" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer"]
|
||||
@@ -209,13 +219,13 @@ layout_mode = 2
|
||||
[node name="SelectAll" type="Button" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Locales/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Select all"
|
||||
icon = SubResource("DPITexture_q8tfr")
|
||||
icon = SubResource("DPITexture_2337e")
|
||||
flat = true
|
||||
|
||||
[node name="DeselectAll" type="Button" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Locales/VBoxContainer/HBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Deselect all"
|
||||
icon = SubResource("DPITexture_q8tfr")
|
||||
icon = SubResource("DPITexture_2337e")
|
||||
flat = true
|
||||
|
||||
[node name="SaveFolder" type="FoldableContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings" node_paths=PackedStringArray("local_data")]
|
||||
@@ -255,7 +265,7 @@ text = "user://screenshots"
|
||||
[node name="PickFolderButton" type="Button" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
icon = SubResource("DPITexture_q8tfr")
|
||||
icon = SubResource("DPITexture_2337e")
|
||||
|
||||
[node name="FormatsContainers" type="HFlowContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
@@ -273,7 +283,6 @@ text = "JPG"
|
||||
|
||||
[node name="WEBPCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/FormatsContainers"]
|
||||
layout_mode = 2
|
||||
button_pressed = true
|
||||
text = "WEBP"
|
||||
|
||||
[node name="HBoxContainer2" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer"]
|
||||
@@ -282,10 +291,13 @@ layout_mode = 2
|
||||
[node name="Label" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/HBoxContainer2"]
|
||||
custom_minimum_size = Vector2(250, 0)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Organize bursts into folders with this structure [projectname_timestamp/locale/resolution]"
|
||||
mouse_filter = 1
|
||||
text = "Use subfolders"
|
||||
|
||||
[node name="UseSubFoldersCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/HBoxContainer2"]
|
||||
layout_mode = 2
|
||||
button_pressed = true
|
||||
text = "On"
|
||||
|
||||
[node name="VBoxContainer2" type="VBoxContainer" parent="HSplitContainer"]
|
||||
@@ -301,7 +313,7 @@ alignment = 1
|
||||
[node name="CameraRollIcon" type="TextureRect" parent="HSplitContainer/VBoxContainer2/PanelContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
texture = SubResource("DPITexture_q8tfr")
|
||||
texture = SubResource("DPITexture_2337e")
|
||||
stretch_mode = 3
|
||||
|
||||
[node name="Label" type="Label" parent="HSplitContainer/VBoxContainer2/PanelContainer/HBoxContainer"]
|
||||
@@ -330,7 +342,7 @@ unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_2337e")
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_ua4ux")
|
||||
|
||||
[node name="RollHFlowContainer" type="HFlowContainer" parent="HSplitContainer/VBoxContainer2/ScrollContainer2/CameraRoll/RollPanelContainer"]
|
||||
unique_name_in_owner = true
|
||||
@@ -350,11 +362,11 @@ script = ExtResource("8_epjix")
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Delete all"
|
||||
icon = SubResource("DPITexture_q8tfr")
|
||||
icon = SubResource("DPITexture_2337e")
|
||||
|
||||
[node name="OpenFolderButton" type="Button" parent="HSplitContainer/VBoxContainer2/CameraRollBottomButtons"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
text = "Open in File Manager"
|
||||
icon = SubResource("DPITexture_q8tfr")
|
||||
icon = SubResource("DPITexture_2337e")
|
||||
@@ -7,6 +7,8 @@ extends VBoxContainer
|
||||
const SCREENSHOT_PREVIEW = preload("res://addons/screenshots/debugger/bottom_panel/screenshot_preview/screenshot_preview.tscn")
|
||||
|
||||
var roll_directory: String
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
%RollPanelContainer.add_theme_stylebox_override("panel", get_theme_stylebox("panel", "ItemListSecondary"))
|
||||
%CameraRollIcon.texture = get_theme_icon("CameraTexture", "EditorIcons")
|
||||
@@ -15,12 +17,14 @@ func _ready() -> void:
|
||||
local_data.settings.value_changed.connect(_on_local_data_changed)
|
||||
%DirectoryWatcher.files_deleted.connect(_on_files_deleted)
|
||||
|
||||
|
||||
func _on_files_deleted(files: PackedStringArray) -> void:
|
||||
for file in files:
|
||||
for preview in previews_container.get_children():
|
||||
if ProjectSettings.globalize_path(preview.path) == ProjectSettings.localize_path(file):
|
||||
preview.queue_free()
|
||||
|
||||
|
||||
func _on_local_data_changed(section: String, key: String, new_value) -> void:
|
||||
if not key == "PathLineEdit":
|
||||
return
|
||||
@@ -40,6 +44,7 @@ func add_preview(file_path: String, timestamp: String, locale: String) -> void:
|
||||
s.locale = locale
|
||||
previews_container.add_child(s)
|
||||
|
||||
|
||||
func get_all_previews_paths() -> Array[String]:
|
||||
var arr: Array[String] = []
|
||||
for preview in previews_container.get_children():
|
||||
|
||||
@@ -8,9 +8,11 @@ func _ready() -> void:
|
||||
%OpenFolderButton.icon = get_theme_icon("Filesystem", "EditorIcons")
|
||||
%OpenFolderButton.pressed.connect(_on_open_folder_button_pressed)
|
||||
|
||||
|
||||
func _on_open_folder_button_pressed() -> void:
|
||||
OS.shell_open(ProjectSettings.globalize_path(%PathLineEdit.text))
|
||||
|
||||
|
||||
func _on_delete_all_button_pressed() -> void:
|
||||
for c in %RollHFlowContainer.get_children():
|
||||
var path = c.path
|
||||
|
||||
@@ -1,6 +1,34 @@
|
||||
#============================================================================
|
||||
# |
|
||||
#============================================================================
|
||||
# This file is part of: |
|
||||
# MIT License |
|
||||
# https://github.com/KoBeWi/Godot-Directory-Watcher |
|
||||
#============================================================================
|
||||
# Copyright (c) 2019 Tomek |
|
||||
# |
|
||||
# Permission is hereby granted, free of charge, to any person obtaining |
|
||||
# a copy of this software and associated documentation files (the |
|
||||
# "Software"), to deal in the Software without restriction, including |
|
||||
# without limitation the rights to use, copy, modify, merge, publish, |
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to |
|
||||
# permit persons to whom the Software is furnished to do so, subject to |
|
||||
# the following conditions: |
|
||||
# |
|
||||
# The above copyright notice and this permission notice shall be |
|
||||
# included in all copies or substantial portions of the Software. |
|
||||
# |
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
||||
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|
||||
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|
||||
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|
||||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
||||
#============================================================================
|
||||
|
||||
@tool
|
||||
extends Node
|
||||
|
||||
## Scans the provided directory (or directories) and informs about file changes. The scan is done periodically with configurable speed.
|
||||
|
||||
class WatchedDirectory:
|
||||
@@ -10,6 +38,7 @@ class WatchedDirectory:
|
||||
var current: Dictionary #[String, int]
|
||||
var previous: Dictionary #[String, int]
|
||||
|
||||
|
||||
var _directory := DirAccess.open(".")
|
||||
|
||||
var _directory_list: Dictionary #[String, WatchedDirectory]
|
||||
@@ -33,22 +62,26 @@ signal files_modified(files: PackedStringArray)
|
||||
## Emitted when files are deleted in the scanned directories.
|
||||
signal files_deleted(files: PackedStringArray)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_current_delay = scan_delay
|
||||
_remaining_steps = scan_step
|
||||
_directory.include_hidden = true
|
||||
|
||||
|
||||
## Adds a directory that will be scanned. You can add more than 1. Only supports absolute paths and res://, user://.
|
||||
func add_scan_directory(directory: String):
|
||||
directory = ProjectSettings.globalize_path(directory)
|
||||
_directory_list[directory] = WatchedDirectory.new()
|
||||
_directory_cache.assign(_directory_list.keys())
|
||||
|
||||
|
||||
## Removes a scanned directory. Does nothing if the directory wasn't added.
|
||||
func remove_scan_directory(directory: String):
|
||||
directory = ProjectSettings.globalize_path(directory)
|
||||
_to_delete.append(directory)
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if _directory_list.is_empty():
|
||||
push_error("No directory to watch. Please kill me ;_;")
|
||||
|
||||
@@ -6,6 +6,7 @@ extends FoldableContainer
|
||||
@export var select_all_button: Button
|
||||
@export var deselect_all_button: Button
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var saved_locales = local_data.settings.load_value("misc", "Locales", ["none"])
|
||||
for l in TranslationServer.get_loaded_locales():
|
||||
@@ -23,6 +24,7 @@ func _ready() -> void:
|
||||
select_all_button.icon = get_theme_icon("ThemeSelectAll", "EditorIcons")
|
||||
deselect_all_button.icon = get_theme_icon("ThemeDeselectAll", "EditorIcons")
|
||||
|
||||
|
||||
func get_locales() -> Array[String]:
|
||||
var arr: Array[String] = []
|
||||
for child: CheckBox in locales_container.get_children():
|
||||
@@ -30,10 +32,12 @@ func get_locales() -> Array[String]:
|
||||
arr.append(child.text)
|
||||
return arr
|
||||
|
||||
|
||||
func _set_all_locales_pressed(pressed: bool) -> void:
|
||||
for l: CheckBox in locales_container.get_children():
|
||||
l.button_pressed = pressed
|
||||
|
||||
|
||||
func _on_locale_toggled(_toggled_on: bool) -> void:
|
||||
var has_pressed := false
|
||||
var has_unpressed := false
|
||||
@@ -53,5 +57,6 @@ func _on_locale_toggled(_toggled_on: bool) -> void:
|
||||
select_all_button.disabled = not has_unpressed
|
||||
_save_to_config()
|
||||
|
||||
|
||||
func _save_to_config() -> void:
|
||||
local_data.settings.save("misc", "Locales", get_locales())
|
||||
@@ -1,5 +1,6 @@
|
||||
@tool
|
||||
extends FoldableContainer
|
||||
|
||||
const SIZE = preload("res://addons/screenshots/debugger/bottom_panel/size/size.tscn")
|
||||
@onready var local_data = %LocalData
|
||||
@export var sizes_container: FlowContainer
|
||||
@@ -42,9 +43,11 @@ func _on_size_added(node: Node) -> void:
|
||||
_save_to_config()
|
||||
sizes_container.get_child(-1).set_add_button_visibility(true)
|
||||
|
||||
|
||||
func _save_to_config() -> void:
|
||||
local_data.settings.save("misc", "Sizes", get_sizes())
|
||||
|
||||
|
||||
func get_sizes() -> Array[Vector2i]:
|
||||
var arr: Array[Vector2i] = []
|
||||
for child in sizes_container.get_children():
|
||||
|
||||
@@ -3,6 +3,7 @@ extends FoldableContainer
|
||||
|
||||
@export var local_data: Node
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
%PickFolderButton.icon = get_theme_icon("FolderBrowse", "EditorIcons")
|
||||
%PickFolderButton.pressed.connect(func(): %FileDialog.show())
|
||||
@@ -12,9 +13,11 @@ func _ready() -> void:
|
||||
for c in %FormatsContainers.get_children():
|
||||
c.toggled.connect(_on_format_toggled)
|
||||
|
||||
|
||||
func _on_dir_selected(path: String) -> void:
|
||||
%PathLineEdit.text = path
|
||||
|
||||
|
||||
func _on_format_toggled(_toggled_on: bool) -> void:
|
||||
var has_pressed := false
|
||||
var has_unpressed := false
|
||||
@@ -28,6 +31,7 @@ func _on_format_toggled(_toggled_on: bool) -> void:
|
||||
if not has_pressed:
|
||||
%PNGCheckBox.button_pressed = true
|
||||
|
||||
|
||||
func get_formats() -> Array[String]:
|
||||
var arr: Array[String] = []
|
||||
for child: CheckBox in %FormatsContainers.get_children():
|
||||
|
||||
@@ -5,6 +5,7 @@ extends VBoxContainer
|
||||
@export var locale: String
|
||||
@export var path: String
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
$Button.icon = texture
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
@tool
|
||||
extends HBoxContainer
|
||||
|
||||
signal resolution_edited
|
||||
@export var preset_option_button: OptionButton
|
||||
|
||||
var presets: Dictionary[String, Vector2i] = {
|
||||
"iPhone 6.9\" (portrait)": Vector2i(1320, 2868),
|
||||
"iPhone 6.9\" (landscape)": Vector2i(2868, 1320),
|
||||
|
||||
"iPad 13\" (portrait)": Vector2i(2064, 2752),
|
||||
"iPad 13\" (landscape)" : Vector2i(2752, 2064)
|
||||
"iPad 13\" (landscape)": Vector2i(2752, 2064),
|
||||
}
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var i = 0
|
||||
preset_option_button.clear()
|
||||
@@ -36,20 +37,25 @@ func _ready() -> void:
|
||||
%TrashButton.pressed.connect(_on_trash_button_pressed)
|
||||
%TrashButton.icon = get_theme_icon("Remove", "EditorIcons")
|
||||
|
||||
|
||||
func _on_trash_button_pressed() -> void:
|
||||
queue_free()
|
||||
|
||||
|
||||
func set_trash_button_disabled(p_disabled: bool) -> void:
|
||||
%TrashButton.disabled = p_disabled
|
||||
|
||||
|
||||
func set_add_button_visibility(p_visible: bool) -> void:
|
||||
%AddButton.visible = p_visible
|
||||
|
||||
|
||||
func _on_add_button_pressed() -> void:
|
||||
var size_panel = load("res://addons/screenshots/debugger/bottom_panel/size/size.tscn")
|
||||
get_parent().add_child(size_panel.instantiate())
|
||||
$AddButton.hide()
|
||||
|
||||
|
||||
func _on_preset_selected(idx: int) -> void:
|
||||
var resolution: Vector2i = preset_option_button.get_item_metadata(idx)
|
||||
if not resolution:
|
||||
@@ -59,11 +65,13 @@ func _on_preset_selected(idx: int) -> void:
|
||||
%YLineEdit.text = str(resolution.y)
|
||||
resolution_edited.emit()
|
||||
|
||||
|
||||
func set_resolution(p_resolution: Vector2i) -> void:
|
||||
%XLineEdit.text = str(p_resolution.x)
|
||||
%YLineEdit.text = str(p_resolution.y)
|
||||
select_preset_option(p_resolution)
|
||||
|
||||
|
||||
func select_preset_option(resolution: Vector2i) -> void:
|
||||
if not is_node_ready():
|
||||
await ready
|
||||
@@ -74,12 +82,14 @@ func select_preset_option(resolution: Vector2i) -> void:
|
||||
idx = i
|
||||
preset_option_button.select(idx)
|
||||
|
||||
|
||||
func get_resolution() -> Vector2i:
|
||||
var res: Vector2i
|
||||
res.x = int(%XLineEdit.text)
|
||||
res.y = int(%YLineEdit.text)
|
||||
return res
|
||||
|
||||
|
||||
func _on_resolution_edited(new_text: String, axis: String) -> void:
|
||||
# Remove all non-digit characters
|
||||
var filtered := ""
|
||||
|
||||
@@ -3,6 +3,7 @@ extends EditorDebuggerPlugin
|
||||
|
||||
var session_id_to_editor_panel: Dictionary = { }
|
||||
|
||||
|
||||
func _setup_session(p_session_id: int) -> void:
|
||||
var editor_panel: Control = preload("res://addons/screenshots/debugger/bottom_panel/bottom_panel.tscn").instantiate()
|
||||
var editor_debugger_session: EditorDebuggerSession = get_session(p_session_id)
|
||||
@@ -11,9 +12,11 @@ func _setup_session(p_session_id : int) -> void:
|
||||
editor_debugger_session.add_session_tab(editor_panel)
|
||||
session_id_to_editor_panel[p_session_id] = editor_panel
|
||||
|
||||
|
||||
func _has_capture(p_prefix: String) -> bool:
|
||||
return p_prefix == "screenshot"
|
||||
|
||||
|
||||
func _capture(p_message: String, p_data: Array, p_session_id: int) -> bool:
|
||||
var editor_panel: Control = session_id_to_editor_panel[p_session_id]
|
||||
return editor_panel.on_editor_debugger_plugin_capture(p_message, p_data)
|
||||
+1
-1
@@ -3,5 +3,5 @@
|
||||
name="Screenshots"
|
||||
description="Takes screenshots of all sizes and locales with a single click."
|
||||
author="Davide Di Staso"
|
||||
version="1.0"
|
||||
version="1.2"
|
||||
script="plugin.gd"
|
||||
@@ -6,6 +6,7 @@ const SHUTTER_WINDOW = "res://addons/screenshots/autoload/shutter_window/shutter
|
||||
var m_editor_debugger_plugin: EditorDebuggerPlugin = preload("res://addons/screenshots/debugger/editor_debugger_plugin.gd").new()
|
||||
var bottom_panel: Control
|
||||
|
||||
|
||||
func _enable_plugin() -> void:
|
||||
add_autoload_singleton("Screenshots", SHUTTER_WINDOW)
|
||||
pass
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
@tool
|
||||
extends Node
|
||||
|
||||
var settings: LocalFile
|
||||
|
||||
|
||||
func _ready():
|
||||
settings = LocalFile.new("res://addons/screenshots/settings.cfg")
|
||||
settings.value_changed.connect(_on_settings_changed)
|
||||
|
||||
func _on_settings_changed(section: String, key: String, new_value):
|
||||
print("Setting changed: [%s] %s = %s" % [section, key, new_value])
|
||||
|
||||
class LocalFile:
|
||||
signal value_changed(section: String, key: String, new_value)
|
||||
@@ -15,11 +14,13 @@ class LocalFile:
|
||||
var config: ConfigFile
|
||||
var file_path: String
|
||||
|
||||
|
||||
func _init(path: String):
|
||||
file_path = path
|
||||
config = ConfigFile.new()
|
||||
load_config()
|
||||
|
||||
|
||||
func load_config():
|
||||
var err = config.load(file_path)
|
||||
if err != OK:
|
||||
@@ -27,6 +28,7 @@ class LocalFile:
|
||||
# We'll create it when we first save
|
||||
pass
|
||||
|
||||
|
||||
func save(section: String, key: String, value):
|
||||
var old_value = null
|
||||
var has_existing_key = config.has_section_key(section, key)
|
||||
@@ -43,6 +45,7 @@ class LocalFile:
|
||||
else:
|
||||
value_changed.emit(section, key, value)
|
||||
|
||||
|
||||
func load_value(section: String, key: String, default_value = null):
|
||||
# Check if the key exists first to avoid C++ errors
|
||||
if config.has_section_key(section, key):
|
||||
@@ -57,19 +60,23 @@ class LocalFile:
|
||||
func has_key(section: String, key: String) -> bool:
|
||||
return config.has_section_key(section, key)
|
||||
|
||||
|
||||
func has_section(section: String) -> bool:
|
||||
return config.has_section(section)
|
||||
|
||||
|
||||
# Get all values from a section
|
||||
func get_section(section: String) -> Dictionary:
|
||||
if config.has_section(section):
|
||||
return config.get_section_values(section)
|
||||
return { }
|
||||
|
||||
|
||||
# Get all sections
|
||||
func get_sections() -> PackedStringArray:
|
||||
return config.get_sections()
|
||||
|
||||
|
||||
# Remove a key
|
||||
func remove_key(section: String, key: String):
|
||||
config.erase_section_key(section, key)
|
||||
@@ -77,6 +84,7 @@ class LocalFile:
|
||||
if err != OK:
|
||||
push_error("Failed to save config file " + file_path + ": " + str(err))
|
||||
|
||||
|
||||
# Remove an entire section
|
||||
func remove_section(section: String):
|
||||
config.erase_section(section)
|
||||
@@ -84,6 +92,7 @@ class LocalFile:
|
||||
if err != OK:
|
||||
push_error("Failed to save config file " + file_path + ": " + str(err))
|
||||
|
||||
|
||||
# Clear entire file
|
||||
func clear_all():
|
||||
config.clear()
|
||||
|
||||
Reference in new issue
Block a user