Compare commits
11
Commits
v1.0
..
d4e568f17c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4e568f17c | ||
|
|
eaa3c39b11 | ||
|
|
71ba8eadb4 | ||
|
|
61dda6fa0d | ||
|
|
0da38fde76 | ||
|
|
f65ad365c5 | ||
|
|
94d8dc96b7 | ||
|
|
3775bd00e1 | ||
|
|
78c925d372 | ||
|
|
d25aae8428 | ||
|
|
7233a3ca4d |
No files matched your search
@@ -0,0 +1,52 @@
|
|||||||
|
name: Create Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*.*' # Triggers on version tags like v1.0
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write # Required to create releases
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Get version from tag
|
||||||
|
id: get_version
|
||||||
|
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Get tag message
|
||||||
|
id: tag_message
|
||||||
|
run: |
|
||||||
|
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
||||||
|
echo "MESSAGE<<EOF" >> $GITHUB_OUTPUT
|
||||||
|
git tag -l --format='%(contents)' ${GITHUB_REF#refs/tags/} >> $GITHUB_OUTPUT
|
||||||
|
echo "EOF" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create release directory
|
||||||
|
run: mkdir -p release_temp/addons/screenshots
|
||||||
|
|
||||||
|
- name: Copy plugin files
|
||||||
|
run: |
|
||||||
|
cp -r addons/screenshots/* release_temp/addons/screenshots/
|
||||||
|
cp LICENSE.md release_temp/addons/screenshots/
|
||||||
|
|
||||||
|
- name: Create ZIP archive
|
||||||
|
run: |
|
||||||
|
cd release_temp
|
||||||
|
zip -r ../godot-screenshots-${{ steps.get_version.outputs.VERSION }}.zip addons
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
files: godot-screenshots-${{ steps.get_version.outputs.VERSION }}.zip
|
||||||
|
body: ${{ steps.tag_message.outputs.MESSAGE }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
File renamed without changes.
@@ -68,7 +68,7 @@ Fires after the burst is completed. Use it to unhide debug UI elements.
|
|||||||
Tested on Godot 4.5 (Linux and macOS)
|
Tested on Godot 4.5 (Linux and macOS)
|
||||||
|
|
||||||
## Support
|
## Support
|
||||||
Questions? Email hello@pumpkintree.games
|
For bugs and feature requests, please open an issue. Additional questions? Email [hello@pumpkintree.games](mailto:hello@pumpkintree.games)
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
- Developed by [Davide Di Staso](http://www.pumpkintree.games)
|
- Developed by [Davide Di Staso](http://www.pumpkintree.games)
|
||||||
|
|||||||
@@ -16,22 +16,39 @@ signal burst_ended
|
|||||||
var _input_action: String
|
var _input_action: String
|
||||||
|
|
||||||
func _ready() -> void:
|
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)
|
||||||
|
|
||||||
|
if only_run_in_editor and not OS.has_feature("editor"):
|
||||||
|
queue_free()
|
||||||
|
return
|
||||||
|
|
||||||
visible = _local_data.settings.load_value("misc", "ShowShutterCheckBox", true)
|
visible = _local_data.settings.load_value("misc", "ShowShutterCheckBox", true)
|
||||||
_input_action = _local_data.settings.load_value("misc", "InputActionLineEdit", "")
|
_input_action = _local_data.settings.load_value("misc", "InputActionLineEdit", "")
|
||||||
%ShutterButton.pressed.connect(take_burst)
|
%ShutterButton.pressed.connect(take_burst)
|
||||||
close_requested.connect(_on_close_requested)
|
close_requested.connect(_on_close_requested)
|
||||||
|
|
||||||
|
|
||||||
func _on_close_requested() -> void:
|
func _on_close_requested() -> void:
|
||||||
hide()
|
hide()
|
||||||
|
|
||||||
|
var old_position : Vector2i
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
|
if old_position != position:
|
||||||
|
_local_data.settings.save("misc", "ShutterWindowPosition", position)
|
||||||
|
old_position = position
|
||||||
if not InputMap.has_action(_input_action):
|
if not InputMap.has_action(_input_action):
|
||||||
return
|
return
|
||||||
if event.is_action_pressed(_input_action):
|
if event.is_action_pressed(_input_action):
|
||||||
take_burst()
|
take_burst()
|
||||||
|
|
||||||
|
|
||||||
## Takes one or more screenshots (a burst) using settings specified in the Debugger panel
|
## Takes one or more screenshots (a burst) using settings specified in the Debugger panel
|
||||||
func take_burst() -> void:
|
func take_burst() -> void:
|
||||||
|
var old_position = position
|
||||||
_local_data.settings.load_config()
|
_local_data.settings.load_config()
|
||||||
burst_starting.emit()
|
burst_starting.emit()
|
||||||
var pause_game = _local_data.settings.load_value("misc", "PausesGameCheckBox", true)
|
var pause_game = _local_data.settings.load_value("misc", "PausesGameCheckBox", true)
|
||||||
@@ -46,7 +63,7 @@ func take_burst() -> void:
|
|||||||
if pause_game:
|
if pause_game:
|
||||||
tree.paused = true
|
tree.paused = true
|
||||||
var prev_size = DisplayServer.window_get_size()
|
var prev_size = DisplayServer.window_get_size()
|
||||||
var timestamp = Time.get_time_string_from_system()
|
|
||||||
|
|
||||||
|
|
||||||
# Take screenshots for each configured size
|
# Take screenshots for each configured size
|
||||||
@@ -55,28 +72,95 @@ func take_burst() -> void:
|
|||||||
await get_tree().create_timer(0.01).timeout
|
await get_tree().create_timer(0.01).timeout
|
||||||
|
|
||||||
for locale in locales:
|
for locale in locales:
|
||||||
if not locale == "none":
|
var locale_to_set = locale
|
||||||
TranslationServer.set_locale(locale)
|
|
||||||
await get_tree().process_frame
|
|
||||||
|
|
||||||
_send_viewport_texture_to_debugger(timestamp, TranslationServer.get_locale())
|
if locale == "none":
|
||||||
|
locale_to_set = previous_locale
|
||||||
|
|
||||||
|
TranslationServer.set_locale(locale_to_set)
|
||||||
|
await get_tree().process_frame
|
||||||
|
save_image()
|
||||||
|
|
||||||
TranslationServer.set_locale(previous_locale)
|
TranslationServer.set_locale(previous_locale)
|
||||||
DisplayServer.window_set_size(prev_size)
|
DisplayServer.window_set_size(prev_size)
|
||||||
|
|
||||||
# Print clickable paths
|
|
||||||
print_rich("[color=green][Screenshots] Done! (%s)[/color]" % timestamp)
|
|
||||||
|
|
||||||
tree.paused = game_was_paused
|
tree.paused = game_was_paused
|
||||||
visible = shutter_was_visible
|
visible = shutter_was_visible
|
||||||
burst_ended.emit()
|
burst_ended.emit()
|
||||||
|
print_rich("[color=green][Screenshots] Done![/color]")
|
||||||
|
position = old_position
|
||||||
|
|
||||||
func _send_viewport_texture_to_debugger(timestamp: String, locale: String) -> void:
|
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)
|
var play_shutter_sounds = _local_data.settings.load_value("misc", "ShutterSoundsCheckBox", true)
|
||||||
# Save the screenshot
|
# Save the screenshot
|
||||||
var image = get_parent().get_viewport().get_texture().get_image()
|
var image = get_parent().get_viewport().get_texture().get_image()
|
||||||
EngineDebugger.send_message("screenshot:take", [image.save_png_to_buffer(), timestamp, locale])
|
|
||||||
image_captured.emit(image)
|
image_captured.emit(image)
|
||||||
|
|
||||||
if play_shutter_sounds:
|
if play_shutter_sounds:
|
||||||
%AudioStreamPlayer.play()
|
%AudioStreamPlayer.play()
|
||||||
|
var save_folder: String = _local_data.settings.load_value("misc", "PathLineEdit", "user://screenshots")
|
||||||
|
var project_title = ProjectSettings.get_setting("application/config/name")
|
||||||
|
var screenshot_size = image.get_size()
|
||||||
|
|
||||||
|
# Build the save path with optional subfolders
|
||||||
|
var target_folder = save_folder
|
||||||
|
if _local_data.settings.load_value("misc", "UseSubFoldersCheckBox", false):
|
||||||
|
# Create subfolder structure: Project_timestamp/locale/resolution
|
||||||
|
var timestamp_folder = "%s_%s" % [project_title, timestamp.replace(":", "-")]
|
||||||
|
var locale_folder = locale
|
||||||
|
var resolution_folder = "%dx%d" % [screenshot_size.x, screenshot_size.y]
|
||||||
|
|
||||||
|
target_folder = save_folder.path_join(timestamp_folder).path_join(locale_folder).path_join(resolution_folder)
|
||||||
|
|
||||||
|
# Ensure target folder exists
|
||||||
|
if not DirAccess.dir_exists_absolute(target_folder):
|
||||||
|
DirAccess.make_dir_recursive_absolute(target_folder)
|
||||||
|
|
||||||
|
var formats = {
|
||||||
|
"PNGCheckBox": ["png", image.save_png, true],
|
||||||
|
"JPGCheckBox": ["jpg", image.save_jpg, false],
|
||||||
|
"WEBPCheckBox": ["webp", image.save_webp, false]
|
||||||
|
}
|
||||||
|
|
||||||
|
for setting_key in formats:
|
||||||
|
var default = formats[setting_key][2]
|
||||||
|
if _local_data.settings.load_value("misc", setting_key, default):
|
||||||
|
var extension = formats[setting_key][0]
|
||||||
|
var save_method = formats[setting_key][1]
|
||||||
|
|
||||||
|
var filename: String
|
||||||
|
if _local_data.settings.load_value("misc", "UseSubFoldersCheckBox", false):
|
||||||
|
filename = "%s_%s" % [project_title, timestamp.replace(":", "-")]
|
||||||
|
else:
|
||||||
|
filename = "%s_%s_%s_%dx%d" % [project_title, timestamp.replace(":", "-"), locale, screenshot_size.x, screenshot_size.y]
|
||||||
|
|
||||||
|
var file_path = target_folder.path_join("%s.%s" % [filename, extension])
|
||||||
|
|
||||||
|
# Get unique filepath to avoid overwriting
|
||||||
|
file_path = get_unique_filepath(file_path)
|
||||||
|
|
||||||
|
save_method.call(file_path)
|
||||||
|
EngineDebugger.send_message("screenshot:taken", [file_path, timestamp, locale])
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
var dir = base_path.get_base_dir()
|
||||||
|
var filename = base_path.get_file().get_basename()
|
||||||
|
var extension = base_path.get_extension()
|
||||||
|
|
||||||
|
var counter = 1
|
||||||
|
var new_path = "%s/%s_%d.%s" % [dir, filename, counter, extension]
|
||||||
|
|
||||||
|
while FileAccess.file_exists(new_path):
|
||||||
|
counter += 1
|
||||||
|
new_path = "%s/%s_%d.%s" % [dir, filename, counter, extension]
|
||||||
|
|
||||||
|
return new_path
|
||||||
|
|
||||||
@@ -41,11 +41,7 @@ func on_session_started() -> void:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
func on_editor_debugger_plugin_capture(p_message, p_data) -> bool:
|
func on_editor_debugger_plugin_capture(p_message, p_data) -> bool:
|
||||||
if p_message == "screenshot:take":
|
if p_message == "screenshot:taken":
|
||||||
var buffer: PackedByteArray = p_data[0]
|
%CameraRoll.add_preview(p_data[0], p_data[1], p_data[2])
|
||||||
var img := Image.new()
|
|
||||||
var err := img.load_png_from_buffer(buffer)
|
|
||||||
if err == OK:
|
|
||||||
%CameraRoll.save_image(img, p_data[1], p_data[2])
|
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=11 format=3 uid="uid://b2ktx6dty0dq4"]
|
[gd_scene load_steps=12 format=3 uid="uid://b2ktx6dty0dq4"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://culd18vnvt4ej" path="res://addons/screenshots/debugger/bottom_panel/bottom_panel.gd" id="1_7ct7k"]
|
[ext_resource type="Script" uid="uid://culd18vnvt4ej" path="res://addons/screenshots/debugger/bottom_panel/bottom_panel.gd" id="1_7ct7k"]
|
||||||
[ext_resource type="Script" uid="uid://bq5amyoktrfo4" path="res://addons/screenshots/debugger/bottom_panel/settings.gd" id="2_ivg3g"]
|
[ext_resource type="Script" uid="uid://bq5amyoktrfo4" path="res://addons/screenshots/debugger/bottom_panel/settings.gd" id="2_ivg3g"]
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
[ext_resource type="Script" uid="uid://c034i367kogf6" path="res://addons/screenshots/debugger/bottom_panel/locales.gd" id="6_m7syr"]
|
[ext_resource type="Script" uid="uid://c034i367kogf6" path="res://addons/screenshots/debugger/bottom_panel/locales.gd" id="6_m7syr"]
|
||||||
[ext_resource type="Script" uid="uid://jfpjg1put47h" path="res://addons/screenshots/debugger/bottom_panel/save_folder.gd" id="7_q2ypf"]
|
[ext_resource type="Script" uid="uid://jfpjg1put47h" path="res://addons/screenshots/debugger/bottom_panel/save_folder.gd" id="7_q2ypf"]
|
||||||
[ext_resource type="Script" uid="uid://cvvxb0tom0wc" path="res://addons/screenshots/debugger/bottom_panel/camera_roll.gd" id="8_6oft3"]
|
[ext_resource type="Script" uid="uid://cvvxb0tom0wc" path="res://addons/screenshots/debugger/bottom_panel/camera_roll.gd" id="8_6oft3"]
|
||||||
|
[ext_resource type="Script" uid="uid://x5sotkduu1be" path="res://addons/screenshots/debugger/bottom_panel/directory_watcher.gd" id="8_2337e"]
|
||||||
[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://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"]
|
[ext_resource type="Script" uid="uid://cx82rfmwl8gk0" path="res://addons/screenshots/screenshots_local_data.gd" id="9_ke0xa"]
|
||||||
|
|
||||||
@@ -36,7 +37,7 @@ grow_vertical = 2
|
|||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
size_flags_vertical = 3
|
size_flags_vertical = 3
|
||||||
script = ExtResource("1_7ct7k")
|
script = ExtResource("1_7ct7k")
|
||||||
nodes_to_save = [NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer4/PausesGameCheckBox"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer2/ShowShutterCheckBox"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer3/ShutterSoundsCheckBox"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer/InputActionLineEdit"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/FormatsContainers/PNGCheckBox"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/FormatsContainers/JPGCheckBox"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/FormatsContainers/WEBPCheckBox"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/HBoxContainer/PathLineEdit"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/HBoxContainer2/UseSubFoldersCheckBox")]
|
nodes_to_save = [NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer4/PausesGameCheckBox"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer2/ShowShutterCheckBox"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer3/ShutterSoundsCheckBox"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer/InputActionLineEdit"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/FormatsContainers/PNGCheckBox"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/FormatsContainers/JPGCheckBox"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/FormatsContainers/WEBPCheckBox"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/HBoxContainer/PathLineEdit"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/HBoxContainer2/UseSubFoldersCheckBox"), NodePath("HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer5/OnlyRunInEditorCheckBox")]
|
||||||
|
|
||||||
[node name="LocalData" type="Node" parent="."]
|
[node name="LocalData" type="Node" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
@@ -92,20 +93,6 @@ title = "Shutter"
|
|||||||
visible = false
|
visible = false
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
[node name="HBoxContainer4" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer"]
|
|
||||||
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
|
|
||||||
text = "Pauses game"
|
|
||||||
|
|
||||||
[node name="PausesGameCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer4"]
|
|
||||||
unique_name_in_owner = true
|
|
||||||
layout_mode = 2
|
|
||||||
button_pressed = true
|
|
||||||
text = "On"
|
|
||||||
|
|
||||||
[node name="HBoxContainer2" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer"]
|
[node name="HBoxContainer2" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
@@ -120,6 +107,33 @@ layout_mode = 2
|
|||||||
button_pressed = true
|
button_pressed = true
|
||||||
text = "On"
|
text = "On"
|
||||||
|
|
||||||
|
[node name="HBoxContainer5" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer"]
|
||||||
|
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
|
||||||
|
text = "Only run in Editor"
|
||||||
|
|
||||||
|
[node name="OnlyRunInEditorCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer5"]
|
||||||
|
layout_mode = 2
|
||||||
|
button_pressed = true
|
||||||
|
text = "On"
|
||||||
|
|
||||||
|
[node name="HBoxContainer4" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer"]
|
||||||
|
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
|
||||||
|
text = "Pauses game"
|
||||||
|
|
||||||
|
[node name="PausesGameCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer/HBoxContainer4"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
button_pressed = true
|
||||||
|
text = "On"
|
||||||
|
|
||||||
[node name="HBoxContainer3" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer"]
|
[node name="HBoxContainer3" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/Shutter/VBoxContainer"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
|
||||||
@@ -255,11 +269,11 @@ text = "PNG"
|
|||||||
|
|
||||||
[node name="JPGCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/FormatsContainers"]
|
[node name="JPGCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/FormatsContainers"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
button_pressed = true
|
|
||||||
text = "JPG"
|
text = "JPG"
|
||||||
|
|
||||||
[node name="WEBPCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/FormatsContainers"]
|
[node name="WEBPCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer/FormatsContainers"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
button_pressed = true
|
||||||
text = "WEBP"
|
text = "WEBP"
|
||||||
|
|
||||||
[node name="HBoxContainer2" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer"]
|
[node name="HBoxContainer2" type="HBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/Settings/SaveFolder/VBoxContainer"]
|
||||||
@@ -323,6 +337,10 @@ unique_name_in_owner = true
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_constants/v_separation = 20
|
theme_override_constants/v_separation = 20
|
||||||
|
|
||||||
|
[node name="DirectoryWatcher" type="Node" parent="HSplitContainer/VBoxContainer2/ScrollContainer2/CameraRoll"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
script = ExtResource("8_2337e")
|
||||||
|
|
||||||
[node name="CameraRollBottomButtons" type="HBoxContainer" parent="HSplitContainer/VBoxContainer2"]
|
[node name="CameraRollBottomButtons" type="HBoxContainer" parent="HSplitContainer/VBoxContainer2"]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
alignment = 2
|
alignment = 2
|
||||||
|
|||||||
@@ -6,105 +6,42 @@ extends VBoxContainer
|
|||||||
|
|
||||||
const SCREENSHOT_PREVIEW = preload("res://addons/screenshots/debugger/bottom_panel/screenshot_preview/screenshot_preview.tscn")
|
const SCREENSHOT_PREVIEW = preload("res://addons/screenshots/debugger/bottom_panel/screenshot_preview/screenshot_preview.tscn")
|
||||||
|
|
||||||
|
var roll_directory : String
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
%RollPanelContainer.add_theme_stylebox_override("panel", get_theme_stylebox("panel", "ItemListSecondary"))
|
%RollPanelContainer.add_theme_stylebox_override("panel", get_theme_stylebox("panel", "ItemListSecondary"))
|
||||||
%CameraRollIcon.texture = get_theme_icon("CameraTexture", "EditorIcons")
|
%CameraRollIcon.texture = get_theme_icon("CameraTexture", "EditorIcons")
|
||||||
for filepath in local_data.settings.load_value("misc", "CameraRollPreviews", []):
|
roll_directory = local_data.settings.load_value("misc", "PathLineEdit", "user://screenshots")
|
||||||
var img = Image.new()
|
%DirectoryWatcher.add_scan_directory(roll_directory)
|
||||||
img = img.load_from_file(filepath)
|
local_data.settings.value_changed.connect(_on_local_data_changed)
|
||||||
|
%DirectoryWatcher.files_deleted.connect(_on_files_deleted)
|
||||||
|
|
||||||
if img == null:
|
func _on_files_deleted(files: PackedStringArray) -> void:
|
||||||
continue
|
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
|
||||||
|
|
||||||
|
%DirectoryWatcher.remove_scan_directory(roll_directory)
|
||||||
|
roll_directory = new_value
|
||||||
|
%DirectoryWatcher.add_scan_directory(roll_directory)
|
||||||
|
|
||||||
|
|
||||||
|
func add_preview(file_path: String, timestamp: String, locale: String) -> void:
|
||||||
var s = SCREENSHOT_PREVIEW.instantiate()
|
var s = SCREENSHOT_PREVIEW.instantiate()
|
||||||
s.texture = ImageTexture.create_from_image(img)
|
var image = Image.load_from_file(file_path)
|
||||||
s.path = filepath
|
var texture = ImageTexture.create_from_image(image)
|
||||||
s.locale = ""
|
s.texture = texture
|
||||||
|
|
||||||
|
s.path = file_path
|
||||||
|
s.locale = locale
|
||||||
previews_container.add_child(s)
|
previews_container.add_child(s)
|
||||||
|
|
||||||
local_data.settings.save("misc", "CameraRollPreviews", get_all_previews_paths())
|
|
||||||
previews_container.child_entered_tree.connect(_on_preview_added)
|
|
||||||
previews_container.child_exiting_tree.connect(_on_preview_removed)
|
|
||||||
|
|
||||||
func _on_preview_added(preview: Node) -> void:
|
|
||||||
local_data.settings.save("misc", "CameraRollPreviews", get_all_previews_paths())
|
|
||||||
pass
|
|
||||||
|
|
||||||
func _on_preview_removed(preview: Node) -> void:
|
|
||||||
await preview.tree_exited
|
|
||||||
local_data.settings.save("misc", "CameraRollPreviews", get_all_previews_paths())
|
|
||||||
pass
|
|
||||||
|
|
||||||
func get_all_previews_paths() -> Array[String]:
|
func get_all_previews_paths() -> Array[String]:
|
||||||
var arr : Array[String] = []
|
var arr : Array[String] = []
|
||||||
for preview in previews_container.get_children():
|
for preview in previews_container.get_children():
|
||||||
arr.append(preview.path)
|
arr.append(preview.path)
|
||||||
return arr
|
return arr
|
||||||
|
|
||||||
func get_unique_filepath(base_path: String) -> String:
|
|
||||||
if not FileAccess.file_exists(base_path):
|
|
||||||
return base_path
|
|
||||||
|
|
||||||
var dir = base_path.get_base_dir()
|
|
||||||
var filename = base_path.get_file().get_basename()
|
|
||||||
var extension = base_path.get_extension()
|
|
||||||
|
|
||||||
var counter = 1
|
|
||||||
var new_path = "%s/%s_%d.%s" % [dir, filename, counter, extension]
|
|
||||||
|
|
||||||
while FileAccess.file_exists(new_path):
|
|
||||||
counter += 1
|
|
||||||
new_path = "%s/%s_%d.%s" % [dir, filename, counter, extension]
|
|
||||||
|
|
||||||
return new_path
|
|
||||||
|
|
||||||
func save_image(image: Image, timestamp: String, locale: String) -> void:
|
|
||||||
var save_folder: String = %PathLineEdit.text
|
|
||||||
var project_title = ProjectSettings.get_setting("application/config/name")
|
|
||||||
var screenshot_size = image.get_size()
|
|
||||||
|
|
||||||
# Build the save path with optional subfolders
|
|
||||||
var target_folder = save_folder
|
|
||||||
if local_data.settings.load_value("misc", "UseSubFoldersCheckBox", false):
|
|
||||||
# Create subfolder structure: Project_timestamp/locale/resolution
|
|
||||||
var timestamp_folder = "%s_%s" % [project_title, timestamp.replace(":", "-")]
|
|
||||||
var locale_folder = locale
|
|
||||||
var resolution_folder = "%dx%d" % [screenshot_size.x, screenshot_size.y]
|
|
||||||
|
|
||||||
target_folder = save_folder.path_join(timestamp_folder).path_join(locale_folder).path_join(resolution_folder)
|
|
||||||
|
|
||||||
# Ensure target folder exists
|
|
||||||
if not DirAccess.dir_exists_absolute(target_folder):
|
|
||||||
DirAccess.make_dir_recursive_absolute(target_folder)
|
|
||||||
|
|
||||||
var formats = {
|
|
||||||
"PNGCheckBox": ["png", image.save_png, true],
|
|
||||||
"JPGCheckBox": ["jpg", image.save_jpg, false],
|
|
||||||
"WEBPCheckBox": ["webp", image.save_webp, false]
|
|
||||||
}
|
|
||||||
|
|
||||||
for setting_key in formats:
|
|
||||||
var default = formats[setting_key][2]
|
|
||||||
if local_data.settings.load_value("misc", setting_key, default):
|
|
||||||
var extension = formats[setting_key][0]
|
|
||||||
var save_method = formats[setting_key][1]
|
|
||||||
|
|
||||||
var filename: String
|
|
||||||
if local_data.settings.load_value("misc", "UseSubFoldersCheckBox", false):
|
|
||||||
filename = "%s_%s" % [project_title, timestamp.replace(":", "-")]
|
|
||||||
else:
|
|
||||||
filename = "%s_%s_%s_%dx%d" % [project_title, timestamp.replace(":", "-"), locale, screenshot_size.x, screenshot_size.y]
|
|
||||||
|
|
||||||
var file_path = target_folder.path_join("%s.%s" % [filename, extension])
|
|
||||||
|
|
||||||
# Get unique filepath to avoid overwriting
|
|
||||||
file_path = get_unique_filepath(file_path)
|
|
||||||
|
|
||||||
save_method.call(file_path)
|
|
||||||
|
|
||||||
var s = SCREENSHOT_PREVIEW.instantiate()
|
|
||||||
s.texture = ImageTexture.create_from_image(image)
|
|
||||||
s.path = file_path
|
|
||||||
s.locale = locale
|
|
||||||
previews_container.add_child(s)
|
|
||||||
print_rich("[Screenshots] Saved at: [url=%s]%s[/url]" % [ProjectSettings.globalize_path(file_path.get_base_dir()), file_path])
|
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
@tool
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
## Scans the provided directory (or directories) and informs about file changes. The scan is done periodically with configurable speed.
|
||||||
|
|
||||||
|
class WatchedDirectory:
|
||||||
|
var first_scan := true
|
||||||
|
var new: PackedStringArray
|
||||||
|
var modified: PackedStringArray
|
||||||
|
var current: Dictionary#[String, int]
|
||||||
|
var previous: Dictionary#[String, int]
|
||||||
|
|
||||||
|
var _directory := DirAccess.open(".")
|
||||||
|
|
||||||
|
var _directory_list: Dictionary#[String, WatchedDirectory]
|
||||||
|
var _directory_cache: Array[String]
|
||||||
|
var _to_delete: Array
|
||||||
|
|
||||||
|
var _current_directory_index: int
|
||||||
|
var _current_directory_name: String
|
||||||
|
var _remaining_steps: int
|
||||||
|
var _current_delay: float
|
||||||
|
|
||||||
|
## Delay between directory scans (in seconds).
|
||||||
|
var scan_delay: float = 1
|
||||||
|
## Files scanned per frame.
|
||||||
|
var scan_step := 50
|
||||||
|
|
||||||
|
## Emitted when files are created in the scanned directories.
|
||||||
|
signal files_created(files: PackedStringArray)
|
||||||
|
## Emitted when files are modified in the scanned directories (based on modified time).
|
||||||
|
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 ;_;")
|
||||||
|
return
|
||||||
|
|
||||||
|
if _current_delay > 0:
|
||||||
|
_current_delay -= delta
|
||||||
|
return
|
||||||
|
|
||||||
|
while _remaining_steps > 0:
|
||||||
|
if _current_directory_name.is_empty():
|
||||||
|
_current_directory_name = _directory_cache[_current_directory_index]
|
||||||
|
_directory.change_dir(_current_directory_name)
|
||||||
|
_directory.list_dir_begin()
|
||||||
|
|
||||||
|
var directory: WatchedDirectory = _directory_list[_current_directory_name]
|
||||||
|
|
||||||
|
var file := _directory.get_next()
|
||||||
|
if file.is_empty():
|
||||||
|
_current_directory_index += 1
|
||||||
|
_current_directory_name = ""
|
||||||
|
|
||||||
|
if directory.first_scan:
|
||||||
|
directory.new.clear()
|
||||||
|
directory.modified.clear()
|
||||||
|
directory.first_scan = false
|
||||||
|
else:
|
||||||
|
if not directory.new.is_empty():
|
||||||
|
files_created.emit(directory.new)
|
||||||
|
directory.new.clear()
|
||||||
|
|
||||||
|
if not directory.modified.is_empty():
|
||||||
|
files_modified.emit(directory.modified)
|
||||||
|
directory.modified.clear()
|
||||||
|
|
||||||
|
var deleted: PackedStringArray
|
||||||
|
for path in directory.previous:
|
||||||
|
if not path in directory.current:
|
||||||
|
deleted.append(_directory.get_current_dir().path_join(path))
|
||||||
|
|
||||||
|
if not deleted.is_empty():
|
||||||
|
files_deleted.emit(deleted)
|
||||||
|
|
||||||
|
directory.previous = directory.current
|
||||||
|
directory.current = {}
|
||||||
|
|
||||||
|
if _current_directory_index == _directory_list.size():
|
||||||
|
if not _to_delete.is_empty():
|
||||||
|
for dir in _to_delete:
|
||||||
|
_directory_list.erase(dir)
|
||||||
|
|
||||||
|
_current_directory_index = 0
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
if _directory.current_is_dir():
|
||||||
|
continue
|
||||||
|
var full_file := _directory.get_current_dir().path_join(file)
|
||||||
|
|
||||||
|
directory.current[file] = FileAccess.get_modified_time(full_file)
|
||||||
|
if directory.previous.get(file, -1) == -1:
|
||||||
|
directory.new.append(full_file)
|
||||||
|
elif directory.current[file] > directory.previous[file]:
|
||||||
|
directory.modified.append(full_file)
|
||||||
|
|
||||||
|
_remaining_steps -= 1
|
||||||
|
|
||||||
|
_remaining_steps = scan_step
|
||||||
|
_current_delay = scan_delay
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://x5sotkduu1be
|
||||||
@@ -3,5 +3,5 @@
|
|||||||
name="Screenshots"
|
name="Screenshots"
|
||||||
description="Takes screenshots of all sizes and locales with a single click."
|
description="Takes screenshots of all sizes and locales with a single click."
|
||||||
author="Davide Di Staso"
|
author="Davide Di Staso"
|
||||||
version="1.0"
|
version="1.1"
|
||||||
script="plugin.gd"
|
script="plugin.gd"
|
||||||
@@ -6,10 +6,21 @@ 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 m_editor_debugger_plugin : EditorDebuggerPlugin = preload("res://addons/screenshots/debugger/editor_debugger_plugin.gd").new()
|
||||||
var bottom_panel : Control
|
var bottom_panel : Control
|
||||||
|
|
||||||
func _enter_tree():
|
func _enable_plugin() -> void:
|
||||||
add_debugger_plugin(m_editor_debugger_plugin)
|
|
||||||
add_autoload_singleton("Screenshots", SHUTTER_WINDOW)
|
add_autoload_singleton("Screenshots", SHUTTER_WINDOW)
|
||||||
|
pass
|
||||||
|
|
||||||
func _exit_tree():
|
|
||||||
remove_debugger_plugin(m_editor_debugger_plugin)
|
func _disable_plugin() -> void:
|
||||||
remove_autoload_singleton("Screenshots")
|
remove_autoload_singleton("Screenshots")
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func _enter_tree() -> void:
|
||||||
|
add_debugger_plugin(m_editor_debugger_plugin)
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func _exit_tree() -> void:
|
||||||
|
remove_debugger_plugin(m_editor_debugger_plugin)
|
||||||
|
pass
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
@tool
|
@tool
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var settings: LocalFile
|
var settings: LocalFile
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
settings = LocalFile.new("res://addons/screenshots/settings.cfg")
|
settings = LocalFile.new("res://addons/screenshots/settings.cfg")
|
||||||
|
|
||||||
class LocalFile:
|
class LocalFile:
|
||||||
|
signal value_changed(section: String, key: String, new_value)
|
||||||
|
|
||||||
var config: ConfigFile
|
var config: ConfigFile
|
||||||
var file_path: String
|
var file_path: String
|
||||||
|
|
||||||
@@ -23,10 +24,20 @@ class LocalFile:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
func save(section: String, key: String, value):
|
func save(section: String, key: String, value):
|
||||||
|
var old_value = null
|
||||||
|
var has_existing_key = config.has_section_key(section, key)
|
||||||
|
|
||||||
|
if has_existing_key:
|
||||||
|
old_value = config.get_value(section, key)
|
||||||
|
|
||||||
|
# Only save and emit if the value is different
|
||||||
|
if not has_existing_key or old_value != value:
|
||||||
config.set_value(section, key, value)
|
config.set_value(section, key, value)
|
||||||
var err = config.save(file_path)
|
var err = config.save(file_path)
|
||||||
if err != OK:
|
if err != OK:
|
||||||
push_error("Failed to save config file " + file_path + ": " + str(err))
|
push_error("Failed to save config file " + file_path + ": " + str(err))
|
||||||
|
else:
|
||||||
|
value_changed.emit(section, key, value)
|
||||||
|
|
||||||
func load_value(section: String, key: String, default_value = null):
|
func load_value(section: String, key: String, default_value = null):
|
||||||
# Check if the key exists first to avoid C++ errors
|
# Check if the key exists first to avoid C++ errors
|
||||||
|
|||||||
+1
-1
@@ -20,4 +20,4 @@ Screenshots="*res://addons/screenshots/autoload/shutter_window/shutter_window.ts
|
|||||||
|
|
||||||
[editor_plugins]
|
[editor_plugins]
|
||||||
|
|
||||||
enabled=PackedStringArray("res://addons/screenshots/plugin.cfg")
|
enabled=PackedStringArray("res://addons/kenyoni/plugin_reloader/plugin.cfg", "res://addons/screenshots/plugin.cfg")
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
Reference in new issue
Block a user