Skip to content

Commit d255fa0

Browse files
Replace some sliders with Pixelorama's custom ValueSlider, allow the file dialog to be affected by Pixelorama's native file dialog setting
1 parent 115df8b commit d255fa0

File tree

5 files changed

+76
-79
lines changed

5 files changed

+76
-79
lines changed

export_presets.cfg

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,39 @@
33
name="Linux/X11"
44
platform="Linux/X11"
55
runnable=true
6+
dedicated_server=false
67
custom_features=""
78
export_filter="all_resources"
89
include_filter="*json"
9-
exclude_filter="res://src/Extensions/KeyDisplay/ExtensionsApi.gd"
10+
exclude_filter="res://src/Extensions/Voxelorama/ExtensionsApi.gd"
1011
export_path=""
11-
script_export_mode=1
12-
script_encryption_key=""
12+
encryption_include_filters=""
13+
encryption_exclude_filters=""
14+
encrypt_pck=false
15+
encrypt_directory=false
1316

1417
[preset.0.options]
1518

1619
custom_template/debug=""
1720
custom_template/release=""
18-
binary_format/64_bits=true
21+
debug/export_console_wrapper=1
1922
binary_format/embed_pck=false
2023
texture_format/bptc=false
2124
texture_format/s3tc=true
2225
texture_format/etc=false
2326
texture_format/etc2=false
27+
binary_format/architecture="x86_64"
28+
ssh_remote_deploy/enabled=false
29+
ssh_remote_deploy/host="user@host_ip"
30+
ssh_remote_deploy/port="22"
31+
ssh_remote_deploy/extra_args_ssh=""
32+
ssh_remote_deploy/extra_args_scp=""
33+
ssh_remote_deploy/run_script="#!/usr/bin/env bash
34+
export DISPLAY=:0
35+
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\"
36+
\"{temp_dir}/{exe_name}\" {cmd_args}"
37+
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash
38+
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\")
39+
rm -rf \"{temp_dir}\""
40+
binary_format/64_bits=true
2441
texture_format/no_bptc_fallbacks=true

src/Extensions/Voxelorama/Tools/Depth.gd

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,31 @@ var kname: String
55
var tool_slot = null # Tools.Slot
66
var cursor_text := ""
77

8+
var _depth_slider: TextureProgressBar
89
var _cursor := Vector2.INF
910
var _depth_array: Array[PackedFloat32Array] = []
1011
var _depth := 1.0
1112
var _canvas_depth := preload("res://src/Extensions/Voxelorama/Tools/CanvasDepth.tscn")
1213
var _canvas_depth_node: Node2D
13-
1414
var _canvas: Node2D
1515

1616

1717
func _ready() -> void:
18+
_depth_slider = ExtensionsApi.general.create_value_slider()
19+
_depth_slider.custom_minimum_size.y = 24
20+
_depth_slider.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
21+
_depth_slider.value_changed.connect(_on_depth_slider_value_changed)
22+
_depth_slider.min_value = 1
23+
_depth_slider.max_value = 25
24+
_depth_slider.step = 0.5
25+
_depth_slider.value = 1
26+
_depth_slider.allow_greater = true
27+
add_child(_depth_slider)
1828
kname = name.replace(" ", "_").to_lower()
29+
if tool_slot.name == "Left tool":
30+
$ColorRect.color = ExtensionsApi.general.get_global().left_tool_color
31+
else:
32+
$ColorRect.color = ExtensionsApi.general.get_global().right_tool_color
1933
load_config()
2034

2135
_canvas = ExtensionsApi.general.get_canvas()
@@ -49,8 +63,7 @@ func set_config(config: Dictionary) -> void:
4963

5064

5165
func update_config() -> void:
52-
$HBoxContainer/DepthHSlider.value = _depth
53-
$HBoxContainer/DepthSpinBox.value = _depth
66+
_depth_slider.value = _depth
5467

5568

5669
func draw_start(position: Vector2) -> void:
@@ -119,7 +132,7 @@ func _update_array(cel: RefCounted, position: Vector2) -> void:
119132
_canvas_depth_node.queue_redraw()
120133

121134

122-
func _on_DepthHSlider_value_changed(value: float) -> void:
135+
func _on_depth_slider_value_changed(value: float) -> void:
123136
_depth = value
124137
update_config()
125138
save_config()
Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,19 @@
1-
[gd_scene load_steps=2 format=2]
1+
[gd_scene load_steps=2 format=3 uid="uid://xfhcfrlwm1o5"]
22

3-
[ext_resource path="res://src/Extensions/Voxelorama/Tools/Depth.gd" type="Script" id=1]
3+
[ext_resource type="Script" path="res://src/Extensions/Voxelorama/Tools/Depth.gd" id="1"]
44

55
[node name="DepthTool" type="VBoxContainer"]
66
offset_right = 40.0
77
offset_bottom = 40.0
8-
script = ExtResource( 1 )
9-
10-
[node name="Label" type="Label" parent="."]
11-
offset_right = 94.0
12-
offset_bottom = 14.0
13-
text = "Depth"
14-
15-
[node name="HBoxContainer" type="HBoxContainer" parent="."]
16-
offset_top = 18.0
17-
offset_right = 94.0
18-
offset_bottom = 42.0
19-
20-
[node name="DepthHSlider" type="HSlider" parent="HBoxContainer"]
21-
offset_right = 16.0
22-
offset_bottom = 16.0
23-
mouse_default_cursor_shape = 2
248
size_flags_horizontal = 3
25-
min_value = 1.0
26-
max_value = 25.0
27-
step = 0.5
28-
value = 1.0
29-
allow_greater = true
9+
script = ExtResource("1")
3010

31-
[node name="DepthSpinBox" type="SpinBox" parent="HBoxContainer"]
32-
offset_left = 20.0
33-
offset_right = 94.0
34-
offset_bottom = 24.0
35-
mouse_default_cursor_shape = 2
36-
size_flags_horizontal = 3
37-
min_value = 1.0
38-
max_value = 25.0
39-
step = 0.5
40-
value = 1.0
41-
allow_greater = true
11+
[node name="ColorRect" type="ColorRect" parent="."]
12+
custom_minimum_size = Vector2(0, 4)
13+
layout_mode = 2
4214

43-
[connection signal="value_changed" from="HBoxContainer/DepthHSlider" to="." method="_on_DepthHSlider_value_changed"]
44-
[connection signal="value_changed" from="HBoxContainer/DepthSpinBox" to="." method="_on_DepthHSlider_value_changed"]
15+
[node name="Label" type="Label" parent="."]
16+
layout_mode = 2
17+
theme_type_variation = &"HeaderSmall"
18+
text = "Depth"
19+
horizontal_alignment = 1

src/Extensions/Voxelorama/Voxelorama.gd

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ var depth_tool_scene := "res://src/Extensions/Voxelorama/Tools/Depth.tscn"
1111
var unshaded_env := preload("res://assets/environments/unshaded.tres")
1212
var shaded_env := preload("res://assets/environments/shaded.tres")
1313
var voxel_art_gen_script := preload("res://src/Extensions/Voxelorama/VoxelArtGen.gd")
14+
var scale_slider: TextureProgressBar
1415

1516
## Only when used as a Pixelorama extension
1617
var menu_item_index: int
1718

1819
@onready var voxel_art_gen: MeshInstance3D = find_child("VoxelArtGen")
19-
@onready var camera: Camera3D = find_child("Camera3D")
20+
@onready var camera: Camera3D = voxel_art_gen.camera
2021
@onready var file_dialog: FileDialog = find_child("FileDialog")
2122

2223

@@ -25,6 +26,21 @@ func _enter_tree() -> void:
2526
ExtensionsApi.tools.add_tool("Depth", "Depth", depth_tool_scene)
2627

2728

29+
func _ready() -> void:
30+
$FileDialog.use_native_dialog = ExtensionsApi.general.get_global().use_native_file_dialogs
31+
scale_slider = ExtensionsApi.general.create_value_slider()
32+
scale_slider.size_flags_horizontal = Control.SIZE_EXPAND_FILL
33+
scale_slider.custom_minimum_size.y = 24
34+
scale_slider.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
35+
scale_slider.value_changed.connect(_on_scale_value_changed)
36+
scale_slider.min_value = 0.1
37+
scale_slider.max_value = 10
38+
scale_slider.step = 0.1
39+
scale_slider.allow_greater = true
40+
scale_slider.value = 1
41+
%ScaleHBox.add_child(scale_slider)
42+
43+
2844
func _input(event: InputEvent) -> void:
2945
if !viewport_has_focus:
3046
rotate = false
@@ -69,15 +85,15 @@ func _on_Voxelorama_about_to_show():
6985
initiate_generation()
7086

7187

72-
func initiate_generation():
88+
func initiate_generation() -> void:
7389
generate()
7490
if voxel_art_gen.layer_images.size() == 0:
7591
return
7692
var first_layer: Image = voxel_art_gen.layer_images[0].image
7793
if first_layer:
78-
camera.position.y = first_layer.get_size().y / 8
79-
camera.position.x = first_layer.get_size().x / 8
80-
camera.position.z = max(first_layer.get_size().x, first_layer.get_size().y)
94+
camera.position.y = first_layer.get_size().y / 8.0
95+
camera.position.x = first_layer.get_size().x / 8.0
96+
camera.position.z = maxf(first_layer.get_size().x, first_layer.get_size().y)
8197

8298
var project = ExtensionsApi.project.current_project
8399
var global = ExtensionsApi.general.get_global()
@@ -134,10 +150,8 @@ func _on_ViewportContainer_mouse_exited() -> void:
134150
viewport_has_focus = false
135151

136152

137-
func _on_Scale_value_changed(value: float) -> void:
153+
func _on_scale_value_changed(value: float) -> void:
138154
voxel_art_gen.mesh_scale = value
139-
$"%ScaleSlider".value = value
140-
$"%ScaleSpinBox".value = value
141155

142156

143157
func _on_FileDialog_file_selected(path: String) -> void:

src/Extensions/Voxelorama/Voxelorama.tscn

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ stretch = true
4747
[node name="SubViewport" type="SubViewport" parent="VBoxContainer/ViewportAndStatus/Panel/SubViewportContainer"]
4848
transparent_bg = true
4949
handle_input_locally = false
50-
size = Vector2i(572, 450)
50+
size = Vector2i(2, 2)
5151
render_target_update_mode = 0
5252

5353
[node name="VoxeloramaPreview" parent="VBoxContainer/ViewportAndStatus/Panel/SubViewportContainer/SubViewport" instance=ExtResource("2")]
@@ -107,34 +107,13 @@ layout_mode = 2
107107
size_flags_horizontal = 3
108108

109109
[node name="ScaleHBox" type="HBoxContainer" parent="VBoxContainer/Options"]
110+
unique_name_in_owner = true
110111
layout_mode = 2
111112

112113
[node name="Label" type="Label" parent="VBoxContainer/Options/ScaleHBox"]
113114
layout_mode = 2
114115
text = "Scale:"
115116

116-
[node name="ScaleSlider" type="HSlider" parent="VBoxContainer/Options/ScaleHBox"]
117-
unique_name_in_owner = true
118-
layout_mode = 2
119-
size_flags_horizontal = 3
120-
size_flags_vertical = 4
121-
mouse_default_cursor_shape = 2
122-
min_value = 0.1
123-
max_value = 10.0
124-
step = 0.1
125-
value = 1.0
126-
allow_greater = true
127-
128-
[node name="ScaleSpinBox" type="SpinBox" parent="VBoxContainer/Options/ScaleHBox"]
129-
unique_name_in_owner = true
130-
layout_mode = 2
131-
mouse_default_cursor_shape = 2
132-
min_value = 0.1
133-
max_value = 10.0
134-
step = 0.1
135-
value = 1.0
136-
allow_greater = true
137-
138117
[node name="FlagsHeader" type="HBoxContainer" parent="VBoxContainer/Options"]
139118
layout_mode = 2
140119

@@ -191,18 +170,17 @@ layout_mode = 2
191170
mouse_default_cursor_shape = 2
192171
text = "Export"
193172

194-
[node name="FileDialog" type="FileDialog" parent="."]
173+
[node name="FileDialog" type="FileDialog" parent="." groups=["FileDialogs"]]
174+
size = Vector2i(677, 300)
195175
access = 2
196-
filters = PackedStringArray("*.obj", "*.svg")
176+
filters = PackedStringArray("*.obj")
197177
show_hidden_files = true
198178

199179
[connection signal="about_to_popup" from="." to="." method="_on_Voxelorama_about_to_show"]
200180
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
201181
[connection signal="mouse_entered" from="VBoxContainer/ViewportAndStatus/Panel/SubViewportContainer" to="." method="_on_ViewportContainer_mouse_entered"]
202182
[connection signal="mouse_exited" from="VBoxContainer/ViewportAndStatus/Panel/SubViewportContainer" to="." method="_on_ViewportContainer_mouse_exited"]
203183
[connection signal="toggled" from="VBoxContainer/ViewportAndStatus/ShadedPreview" to="." method="_on_ShadedPreview_toggled"]
204-
[connection signal="value_changed" from="VBoxContainer/Options/ScaleHBox/ScaleSlider" to="." method="_on_Scale_value_changed"]
205-
[connection signal="value_changed" from="VBoxContainer/Options/ScaleHBox/ScaleSpinBox" to="." method="_on_Scale_value_changed"]
206184
[connection signal="toggled" from="VBoxContainer/Options/Flags/VBoxContainer/Centered" to="." method="_on_Centered_toggled"]
207185
[connection signal="toggled" from="VBoxContainer/Options/Flags/VBoxContainer/Symmetrical" to="." method="_on_Symmetrical_toggled"]
208186
[connection signal="toggled" from="VBoxContainer/Options/Flags/VBoxContainer/MergeFrames" to="." method="_on_MergeFrames_toggled"]

0 commit comments

Comments
 (0)