Skip to content

Commit

Permalink
Simplified Texture Editing
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed May 20, 2024
1 parent bfc063c commit f32b206
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 155 deletions.
2 changes: 1 addition & 1 deletion Autoload/Version.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends Node

var major_minor = "0.46"
var major_minor = "0.47"
var patch = "0000"
var full = ""
var unearth_map_format_version:float = 1.05
Expand Down
17 changes: 8 additions & 9 deletions Scenes/CurrentTextures.gd
Original file line number Diff line number Diff line change
Expand Up @@ -160,33 +160,32 @@ func save_image_as_png(img, inputPath):


func load_cache_filename(path):
var fileName = path.get_file().get_basename().to_lower()


var cachePath = Settings.unearthdata.plus_file(fileName + ".png")
var tmapNumber = int(fileName.to_int())
var baseName = path.get_file().get_basename().to_lower()
var tmapNumber = int(baseName.to_int())
var cachePath = Settings.unearthdata.plus_file(baseName + ".png")

if File.new().file_exists(cachePath) == true:
var img = Image.new()
img.load(cachePath)
load_image_into_cache(img, tmapNumber, fileName)
load_image_into_cache(img, tmapNumber, baseName)
return OK
else:
print('Cache file not found: ' + cachePath)
cachedTextures.clear()
return FAILED


func load_image_into_cache(img, tmapNumber, fileName):
func load_image_into_cache(img, tmapNumber, baseName):

while cachedTextures.size() <= tmapNumber: # Fill all array positions, in case a tmapa00#.dat file inbetween is deleted
cachedTextures.append([null, null, null, null])

var twoArrays = convert_img_to_two_texture_arrays(img)

if fileName.begins_with("tmapa"):
if baseName.to_lower().begins_with("tmapa"):
cachedTextures[tmapNumber][0] = twoArrays[0]
cachedTextures[tmapNumber][1] = twoArrays[1]
elif fileName.begins_with("tmapb"):
elif baseName.to_lower().begins_with("tmapb"):
cachedTextures[tmapNumber][2] = twoArrays[0]
cachedTextures[tmapNumber][3] = twoArrays[1]

Expand Down
2 changes: 1 addition & 1 deletion Scenes/LineEditFloat.gd
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ func _ready():
connect("focus_exited", self, "_on_focus_exited")

func _on_focus_exited():
text = String(int(text))
text = String(float(text))
#text = text.pad_decimals(2)
205 changes: 98 additions & 107 deletions Scenes/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -5001,21 +5001,6 @@ reset_on_save = false
anims/Flash = SubResource( 17 )
anims/RESET = SubResource( 18 )

[node name="ChooseFileListFileDialog" type="FileDialog" parent="Ui/UiSystem"]
visible = true
margin_left = -2004.0
margin_top = 1631.0
margin_right = -1324.0
margin_bottom = 2191.0
rect_min_size = Vector2( 250, 87.5 )
window_title = "Open a File"
resizable = true
dialog_text = "Find and select filelist_tmapa*.txt (must have accompanying pack* folder)"
mode = 0
access = 2
filters = PoolStringArray( "*.txt" )
show_hidden_files = true

[node name="ChooseTmapaFileDialog" type="FileDialog" parent="Ui/UiSystem"]
visible = true
margin_left = -1278.0
Expand Down Expand Up @@ -5055,9 +5040,10 @@ show_hidden_files = true
visible = true
margin_left = -1273.0
margin_top = 954.0
margin_right = -741.0
margin_bottom = 1389.0
window_title = "Tileset editing"
margin_right = -989.0
margin_bottom = 1202.0
rect_min_size = Vector2( 284, 248 )
window_title = "Create a tileset"
resizable = true
script = ExtResource( 126 )

Expand All @@ -5069,106 +5055,111 @@ margin_top = 10.0
margin_right = -10.0
margin_bottom = -10.0

[node name="CreateFilelistButton" type="Button" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer"]
margin_right = 512.0
margin_bottom = 27.0
text = "Convert tmapa*.dat file to filelist pack"

[node name="LoadFilelistButton" type="Button" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer"]
margin_top = 31.0
margin_right = 512.0
margin_bottom = 58.0
text = "Load filelist pack"

[node name="ReloaderContainer" type="VBoxContainer" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer"]
margin_top = 62.0
margin_right = 512.0
margin_bottom = 384.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="GridContainer" type="GridContainer" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer"]
margin_right = 264.0
margin_bottom = 89.0
columns = 2

[node name="ScrollContainer" type="ScrollContainer" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ReloaderContainer"]
margin_right = 512.0
margin_bottom = 21.0
scroll_vertical_enabled = false
[node name="Label" type="Label" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/GridContainer"]
margin_top = 3.0
margin_right = 50.0
margin_bottom = 24.0
rect_min_size = Vector2( 50, 0 )
text = "1."
align = 1

[node name="ReloaderPathLabel" type="Label" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ReloaderContainer/ScrollContainer"]
margin_right = 14.0
margin_bottom = 21.0
text = "<>"
[node name="CreateFilelistButton" type="Button" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/GridContainer"]
margin_left = 54.0
margin_right = 229.0
margin_bottom = 27.0
rect_min_size = Vector2( 175, 0 )
size_flags_horizontal = 0
text = "Load tileset"

[node name="Spacing3" type="Control" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ReloaderContainer"]
margin_top = 25.0
margin_right = 512.0
margin_bottom = 49.0
rect_min_size = Vector2( 24, 24 )
[node name="Label2" type="Label" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/GridContainer"]
margin_top = 34.0
margin_right = 50.0
margin_bottom = 55.0
rect_min_size = Vector2( 50, 0 )
text = "2."
align = 1

[node name="HBoxContainer" type="HBoxContainer" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ReloaderContainer"]
margin_top = 53.0
margin_right = 512.0
margin_bottom = 84.0
[node name="ModifyTexturesButton" type="Button" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/GridContainer"]
margin_left = 54.0
margin_top = 31.0
margin_right = 229.0
margin_bottom = 58.0
rect_min_size = Vector2( 175, 0 )
size_flags_horizontal = 4
text = "Modify textures"

[node name="label" type="Label" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ReloaderContainer/HBoxContainer"]
margin_top = 5.0
margin_right = 114.0
margin_bottom = 26.0
text = "Reload every"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label3" type="Label" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/GridContainer"]
margin_top = 65.0
margin_right = 50.0
margin_bottom = 86.0
rect_min_size = Vector2( 50, 0 )
text = "3."
align = 1

[node name="ReloadEveryLineEdit" type="LineEdit" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ReloaderContainer/HBoxContainer"]
margin_left = 118.0
margin_right = 176.0
margin_bottom = 31.0
text = "0.25"
script = ExtResource( 89 )
[node name="ExportTmapaButton" type="Button" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/GridContainer"]
margin_left = 54.0
margin_top = 62.0
margin_right = 229.0
margin_bottom = 89.0
rect_min_size = Vector2( 175, 0 )
size_flags_horizontal = 0
text = "Save tileset"
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Label2" type="Label" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ReloaderContainer/HBoxContainer"]
margin_left = 180.0
margin_top = 5.0
margin_right = 250.0
margin_bottom = 26.0
text = "seconds"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Spacing" type="Control" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer"]
margin_top = 93.0
margin_right = 264.0
margin_bottom = 105.0
rect_min_size = Vector2( 0, 12 )

[node name="Spacing" type="Control" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ReloaderContainer"]
margin_top = 88.0
margin_right = 512.0
margin_bottom = 112.0
rect_min_size = Vector2( 24, 24 )
[node name="Label" type="Label" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer"]
margin_top = 109.0
margin_right = 264.0
margin_bottom = 130.0
text = "Currently loaded:"

[node name="ScrollContainer" type="ScrollContainer" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer"]
margin_top = 134.0
margin_right = 264.0
margin_bottom = 180.0
scroll_vertical_enabled = false

[node name="ReloaderLoopLabel" type="Label" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ReloaderContainer"]
margin_top = 116.0
margin_right = 512.0
margin_bottom = 281.0
text = "Now actively reloading files from filelist pack folder, this means as you edit and save those .PNGs, any changes you make will be shown realtime in Unearth (in the 3D view too).
[node name="VBoxContainer" type="VBoxContainer" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ScrollContainer"]
margin_right = 264.0
margin_bottom = 46.0
size_flags_horizontal = 3
size_flags_vertical = 3

Your Tileset in Map settings has been set to the texture pack # you're editing."
autowrap = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ReloaderPathLabel" type="Label" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ScrollContainer/VBoxContainer"]
margin_right = 264.0
margin_bottom = 21.0
text = "<>"

[node name="Spacing2" type="Control" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ReloaderContainer"]
margin_top = 285.0
margin_right = 512.0
margin_bottom = 309.0
rect_min_size = Vector2( 24, 24 )
[node name="ReloaderPathPackLabel" type="Label" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ScrollContainer/VBoxContainer"]
margin_top = 25.0
margin_right = 264.0
margin_bottom = 46.0
text = "<>"

[node name="ExportTmapaButton" type="Button" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer"]
margin_top = 388.0
margin_right = 512.0
margin_bottom = 415.0
text = "Export as tmapa*.dat"
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TextureEditingHelpButton" type="TextureButton" parent="Ui/UiSystem/TextureEditingWindow/VBoxContainer"]
margin_left = 232.0
margin_top = 184.0
margin_right = 264.0
margin_bottom = 216.0
rect_min_size = Vector2( 32, 32 )
size_flags_horizontal = 8
texture_normal = ExtResource( 156 )
texture_pressed = ExtResource( 66 )
texture_hover = ExtResource( 128 )
expand = true
stretch_mode = 4

[node name="ColumnEditor" type="WindowDialog" parent="Ui/UiSystem"]
visible = true
Expand Down Expand Up @@ -7489,12 +7480,12 @@ script = SubResource( 20 )
[connection signal="text_changed" from="Ui/UiSystem/MapSettingsWindow/MapSettingsTabs/ScriptEditor/VBoxContainer/ScriptTextEdit" to="Ui/UiSystem/MapSettingsWindow/MapSettingsTabs/ScriptEditor" method="_on_ScriptTextEdit_text_changed"]
[connection signal="visibility_changed" from="Ui/UiSystem/MapSettingsWindow/MapSettingsTabs/ScriptEditor/VBoxContainer/ScriptTextEdit" to="Ui/UiSystem/MapSettingsWindow/MapSettingsTabs/ScriptEditor" method="_on_ScriptTextEdit_visibility_changed"]
[connection signal="pressed" from="Ui/UiSystem/MapSettingsWindow/MapSettingsTabs/ScriptEditor/HelpButtonPosition/UNNEEDEDScriptHelpButton" to="Ui/UiSystem/MapSettingsWindow/MapSettingsTabs/ScriptEditor" method="_on_ScriptHelpButton_pressed"]
[connection signal="file_selected" from="Ui/UiSystem/ChooseFileListFileDialog" to="Ui/UiSystem/TextureEditingWindow" method="_on_ChooseFileListFileDialog_file_selected"]
[connection signal="file_selected" from="Ui/UiSystem/ChooseTmapaFileDialog" to="Ui/UiSystem/TextureEditingWindow" method="_on_ChooseTmapaFileDialog_file_selected"]
[connection signal="file_selected" from="Ui/UiSystem/ExportTmapaDatDialog" to="Ui/UiSystem/TextureEditingWindow" method="_on_ExportTmapaDatDialog_file_selected"]
[connection signal="pressed" from="Ui/UiSystem/TextureEditingWindow/VBoxContainer/CreateFilelistButton" to="Ui/UiSystem/TextureEditingWindow" method="_on_CreateFilelistButton_pressed"]
[connection signal="pressed" from="Ui/UiSystem/TextureEditingWindow/VBoxContainer/LoadFilelistButton" to="Ui/UiSystem/TextureEditingWindow" method="_on_LoadFilelistButton_pressed"]
[connection signal="pressed" from="Ui/UiSystem/TextureEditingWindow/VBoxContainer/ExportTmapaButton" to="Ui/UiSystem/TextureEditingWindow" method="_on_ExportTmapaButton_pressed"]
[connection signal="pressed" from="Ui/UiSystem/TextureEditingWindow/VBoxContainer/GridContainer/CreateFilelistButton" to="Ui/UiSystem/TextureEditingWindow" method="_on_CreateFilelistButton_pressed"]
[connection signal="pressed" from="Ui/UiSystem/TextureEditingWindow/VBoxContainer/GridContainer/ModifyTexturesButton" to="Ui/UiSystem/TextureEditingWindow" method="_on_ModifyTexturesButton_pressed"]
[connection signal="pressed" from="Ui/UiSystem/TextureEditingWindow/VBoxContainer/GridContainer/ExportTmapaButton" to="Ui/UiSystem/TextureEditingWindow" method="_on_ExportTmapaButton_pressed"]
[connection signal="pressed" from="Ui/UiSystem/TextureEditingWindow/VBoxContainer/TextureEditingHelpButton" to="Ui/UiSystem/TextureEditingWindow" method="_on_TextureEditingHelpButton_pressed"]
[connection signal="visibility_changed" from="Ui/UiSystem/ColumnEditor" to="Ui/UiSystem/ColumnEditor" method="_on_ColumnEditor_visibility_changed"]
[connection signal="pressed" from="Ui/UiSystem/ColumnEditor/MarginContainer/HBoxContainer/VBoxContainer2/HBoxContainer2/ColumnEditorClearUnusedButton" to="Ui/UiSystem/ColumnEditor" method="_on_ColumnEditorClearUnusedButton_pressed"]
[connection signal="pressed" from="Ui/UiSystem/ColumnEditor/MarginContainer/HBoxContainer/VBoxContainer2/HBoxContainer2/ColumnEditorSortButton" to="Ui/UiSystem/ColumnEditor" method="_on_ColumnEditorSortButton_pressed"]
Expand Down
2 changes: 1 addition & 1 deletion Scenes/Menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func add_edit_menu_items():
edit_popup.add_item("Resize map", 3)
edit_popup.add_item("Update all slabs", 4)
edit_popup.add_separator()
edit_popup.add_item("Make a tileset", 5)
edit_popup.add_item("Create a tileset", 5)
edit_popup.add_item("Slabset", 6)

func update_undo_availability():
Expand Down
21 changes: 20 additions & 1 deletion Scenes/PlacingSettings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ var lightRange = 10
var lightIntensity = 32
var pointRange = 5
var boxNumber = 0

var creatureName = ""
var creatureGold = 0
var creatureInitialHealth = 100
Expand Down Expand Up @@ -56,6 +55,26 @@ func _on_PropertiesTabs_tab_changed(tab):
if tab == 1:
set_placing_tab_and_update_it()


func replicate_instance_settings(node):
if node.get("effectRange"): effectRange = node.effectRange
if node.get("creatureLevel"): creatureLevel = node.creatureLevel
if node.get("doorLocked"): doorLocked = node.doorLocked
if node.get("ownership"): ownership = node.ownership
if node.get("lightRange"): lightRange = node.lightRange
if node.get("lightIntensity"): lightIntensity = node.lightIntensity
if node.get("pointRange"): pointRange = node.pointRange
if node.get("boxNumber"): boxNumber = node.boxNumber

if node.get("creatureName"): creatureName = node.creatureName
if node.get("creatureName") == "": creatureName = node.creatureName

if node.get("creatureGold"): creatureGold = node.creatureGold
if node.get("creatureInitialHealth"): creatureInitialHealth = node.creatureInitialHealth
if node.get("orientation"): orientation = node.orientation
if node.get("goldValue"): goldValue = node.goldValue


func set_placing_tab_and_update_it():
oPropertiesTabs.current_tab = 1
update_placing_tab()
Expand Down
2 changes: 2 additions & 0 deletions Scenes/Selection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ onready var oBrushPreview = Nodelist.list["oBrushPreview"]
onready var oPlaceThingsAnywhere = Nodelist.list["oPlaceThingsAnywhere"]
onready var oSlabSideViewer = Nodelist.list["oSlabSideViewer"]
onready var oUseSlabOwnerCheckBox = Nodelist.list["oUseSlabOwnerCheckBox"]
onready var oPlacingSettings = Nodelist.list["oPlacingSettings"]

enum {
CONSTRUCT_BRUSH
Expand Down Expand Up @@ -132,6 +133,7 @@ func update_paint():
paintThingType = cursorOnInstancesArray[0].thingType
paintSubtype = cursorOnInstancesArray[0].subtype
oPickThingWindow.set_selection(paintThingType, paintSubtype)
oPlacingSettings.replicate_instance_settings(cursorOnInstancesArray[0])


func construct_shape_for_placement(constructType):
Expand Down
2 changes: 1 addition & 1 deletion Scenes/Selector.gd
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ func mouse_button_on_field():
change_mode(MODE_SUBTILE)
else:
change_mode(MODE_TILE)
oPlacingSettings.set_placing_tab_and_update_it()
oSelection.update_paint()
oPlacingSettings.set_placing_tab_and_update_it()

if Input.is_action_pressed("mouse_right"):
if visible == true:
Expand Down
Loading

0 comments on commit f32b206

Please sign in to comment.