Skip to content

Commit 702bb4e

Browse files
committed
Add $resolution for preview2d/3d filepath param
1 parent a6f76d5 commit 702bb4e

File tree

5 files changed

+28
-6
lines changed

5 files changed

+28
-6
lines changed

material_maker/globals.gd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func propagate_shortcuts(control : Control, event : InputEvent):
181181
do_propagate_shortcuts(control, event)
182182

183183

184-
func interpret_file_name(file_name: String, path:="", file_extension:="",additional_identifiers:={}) -> String:
184+
func interpret_file_name(file_name: String, path:="", file_extension:="",additional_identifiers:={}, resolution="") -> String:
185185
for i in additional_identifiers:
186186
file_name = file_name.replace(i, additional_identifiers[i])
187187

@@ -194,6 +194,9 @@ func interpret_file_name(file_name: String, path:="", file_extension:="",additio
194194
if file_extension != "" and not file_name.ends_with(file_extension):
195195
file_name += file_extension
196196

197+
if resolution:
198+
file_name = file_name.replace("$resolution", resolution)
199+
197200
if "$idx" in file_name:
198201
if path:
199202
var idx := 1

material_maker/panels/preview_2d/export_menu.gd

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ func _on_resolution_item_selected(index: int) -> void:
9797
if index != RESOLUTION_CUSTOM:
9898
%CustomResolutionX.set_value(64 << index)
9999
%CustomResolutionY.set_value(64 << index)
100+
update()
100101

101102

102103
func get_export_resolution() -> Vector2i:
@@ -177,5 +178,19 @@ func interpret_file_name(file_name: String, path:="") -> String:
177178
match %FileType.selected:
178179
0: extension += ".png"
179180
1: extension += ".exr"
181+
182+
var resolution : String
183+
if %CustomResolutionSection.visible:
184+
resolution = "%sx%s" % [ int(%CustomResolutionX.value), int(%CustomResolutionY.value) ]
185+
else:
186+
resolution = str(64 << %Resolution.selected)
187+
188+
return mm_globals.interpret_file_name(file_name, path, extension, additional_ids, resolution)
180189

181-
return mm_globals.interpret_file_name(file_name, path, extension, additional_ids)
190+
191+
func _on_custom_resolution_x_value_changed(value: Variant) -> void:
192+
update()
193+
194+
195+
func _on_custom_resolution_y_value_changed(value: Variant) -> void:
196+
update()

material_maker/panels/preview_2d/preview_2d_panel.tscn

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ layout_mode = 2
593593
size_flags_horizontal = 3
594594
tooltip_text = "The file-name to use.
595595
596-
You can use $project, $node and $idx to make the file-name auto-adjust."
596+
You can use $project, $node, $idx and $resolution to make the file-name auto-adjust."
597597
theme_override_font_sizes/font_size = 15
598598
text = "$project_$node"
599599

@@ -755,6 +755,8 @@ layout_mode = 2
755755
[connection signal="text_changed" from="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel/VBox/Grid/ExportFile/BoxContainer/ExportFile" to="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel" method="_on_export_file_text_changed"]
756756
[connection signal="item_selected" from="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel/VBox/Grid/ExportFile/BoxContainer/FileType" to="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel" method="_on_file_type_item_selected"]
757757
[connection signal="item_selected" from="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel/VBox/Grid/ResolutionSection/Resolution" to="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel" method="_on_resolution_item_selected"]
758+
[connection signal="value_changed" from="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel/VBox/Grid/ResolutionSection/CustomResolutionSection/CustomResolutionX" to="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel" method="_on_custom_resolution_x_value_changed"]
759+
[connection signal="value_changed" from="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel/VBox/Grid/ResolutionSection/CustomResolutionSection/CustomResolutionY" to="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel" method="_on_custom_resolution_y_value_changed"]
758760
[connection signal="pressed" from="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel/VBox/Grid/BoxContainer/Image" to="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel" method="_on_image_pressed"]
759761
[connection signal="pressed" from="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel/VBox/Grid/BoxContainer/Reference" to="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel" method="_on_reference_pressed"]
760762
[connection signal="pressed" from="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel/VBox/Grid/BoxContainer/Animation" to="MenuBar/HBox/MainMenu/HBox/ExportMenu/ExportMenuPanel" method="_on_animation_pressed"]

material_maker/panels/preview_3d/export_menu.gd

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func _on_map_export_file_text_changed(new_text: String) -> void:
7474

7575
func _on_map_resolution_item_selected(index: int) -> void:
7676
mm_globals.set_config(SETTING_GENERATE_MAP_RESOLUTION, index)
77+
update_generate_map_file_label()
7778

7879

7980
func update_generate_map_file_label() -> void:
@@ -91,9 +92,10 @@ func interpret_map_file_name(file_name: String, path:="") -> String:
9192
match MapFileType.selected:
9293
0: extension += ".png"
9394
1: extension += ".exr"
95+
96+
var resolution := str(256 << MapResolution.selected)
9497

95-
return mm_globals.interpret_file_name(file_name, path, extension, additional_ids)
96-
98+
return mm_globals.interpret_file_name(file_name, path, extension, additional_ids, resolution)
9799

98100
func _on_map_file_type_item_selected(_index: int) -> void:
99101
update_generate_map_file_label()

material_maker/panels/preview_3d/preview_3d.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ unique_name_in_owner = true
412412
layout_mode = 2
413413
size_flags_horizontal = 3
414414
tooltip_text = "The file-name to use.
415-
Use $project, $type and $idx to make it auto-adjust."
415+
Use $project, $type, $idx and $resolution to make it auto-adjust."
416416
theme_override_font_sizes/font_size = 15
417417
text = "$project_$type_map"
418418

0 commit comments

Comments
 (0)