diff --git a/Autoload/Columnset.gd b/Autoload/Columnset.gd index 4643a885..c7a8859c 100644 --- a/Autoload/Columnset.gd +++ b/Autoload/Columnset.gd @@ -10,6 +10,8 @@ var height = [] var cubes = [] var floorTexture = [] +var default_data = {} + # Strangely, slabs.clm is missing the second 4 bytes. # map0000x.clm : 49,160 bytes. first 4 bytes contains 2048, second 4 bytes are ???, then comes the column data. # slabs.clm : 49,156 bytes. first 4 bytes contains 2048, then comes the column data. @@ -18,7 +20,6 @@ func load_default_columnset(): var CODETIME_START = OS.get_ticks_msec() clear_all_column_data() # Important, for reloading/refreshing slabs.clm - var filePath = oGame.get_precise_filepath(oGame.DK_DATA_DIRECTORY, "SLABS.CLM") var buffer = Filetypes.file_path_to_buffer(filePath) @@ -48,7 +49,17 @@ func load_default_columnset(): cubes[entry][cubeNumber] = buffer.get_u16() # 8-23 print('Created Columnset : '+str(OS.get_ticks_msec()-CODETIME_START)+'ms') + store_default_data() +func store_default_data(): + default_data["utilized"] = utilized.duplicate(true) + default_data["orientation"] = orientation.duplicate(true) + default_data["solidMask"] = solidMask.duplicate(true) + default_data["permanent"] = permanent.duplicate(true) + default_data["lintel"] = lintel.duplicate(true) + default_data["height"] = height.duplicate(true) + default_data["cubes"] = cubes.duplicate(true) + default_data["floorTexture"] = floorTexture.duplicate(true) func create_cfg_columns(filePath): #"res://columns.cfg" var oMessage = Nodelist.list["oMessage"] diff --git a/Scenes/AddCustomObjectWindow.gd b/Scenes/AddCustomObjectWindow.gd index a9bb77e6..32b0daa8 100644 --- a/Scenes/AddCustomObjectWindow.gd +++ b/Scenes/AddCustomObjectWindow.gd @@ -144,7 +144,7 @@ func _on_CustomObjectHelpButton_pressed(): helptext += "\n\n" helptext += "After adding one, right click on its portrait within the thing selection window to remove custom things from the editor." #helptext += "\n\n" - #helptext += "For now, placing a custom slab on a new/different map than the one you created it on, will not carry over the exact same column data." + #helptext += "For now, placing a Fake Slab on a new/different map than the one you created it on, will not carry over the exact same column data." oMessage.big("Help",helptext) diff --git a/Scenes/ClmControls.gd b/Scenes/ClmControls.gd index af56a1d1..7be856ca 100644 --- a/Scenes/ClmControls.gd +++ b/Scenes/ClmControls.gd @@ -138,6 +138,7 @@ func _on_ColumnIndexSpinBox_value_changed(value): nodeID.set_block_signals(false) oCustomTooltip.visible = false # Tooltip becomes incorrect when changing column index so just turn it off until you hover your mouse over it again + adjust_ui_color_if_different() func _on_cube_value_changed(value, cubeNumber): # signal connected by GDScript if nodeClm == oDataClm: @@ -150,6 +151,7 @@ func _on_cube_value_changed(value, cubeNumber): # signal connected by GDScript oSolidMaskSpinBox.value = nodeClm.calculate_solid_mask(nodeClm.cubes[clmIndex]) _on_cube_mouse_entered(cubeNumber) # Update tooltip + adjust_ui_color_if_different() func _on_FloorTextureSpinBox_value_changed(value): if nodeClm == oDataClm: @@ -157,8 +159,8 @@ func _on_FloorTextureSpinBox_value_changed(value): var clmIndex = int(oColumnIndexSpinBox.value) nodeClm.floorTexture[clmIndex] = int(value) nodeVoxelView.update_column_view() - _on_floortexture_mouse_entered() # Update tooltip + adjust_ui_color_if_different() func _on_LintelSpinBox_value_changed(value): if nodeClm == oDataClm: @@ -166,6 +168,7 @@ func _on_LintelSpinBox_value_changed(value): var clmIndex = int(oColumnIndexSpinBox.value) nodeClm.lintel[clmIndex] = int(value) nodeVoxelView.update_column_view() + adjust_ui_color_if_different() func _on_PermanentSpinBox_value_changed(value): if nodeClm == oDataClm: @@ -173,7 +176,7 @@ func _on_PermanentSpinBox_value_changed(value): var clmIndex = int(oColumnIndexSpinBox.value) nodeClm.permanent[clmIndex] = int(value) nodeVoxelView.update_column_view() - + adjust_ui_color_if_different() func _on_OrientationSpinBox_value_changed(value): if nodeClm == oDataClm: @@ -181,6 +184,7 @@ func _on_OrientationSpinBox_value_changed(value): var clmIndex = int(oColumnIndexSpinBox.value) nodeClm.orientation[clmIndex] = int(value) nodeVoxelView.update_column_view() + adjust_ui_color_if_different() func _on_HeightSpinBox_value_changed(value): if nodeClm == oDataClm: @@ -188,6 +192,7 @@ func _on_HeightSpinBox_value_changed(value): var clmIndex = int(oColumnIndexSpinBox.value) nodeClm.height[clmIndex] = int(value) nodeVoxelView.update_column_view() + adjust_ui_color_if_different() func _on_SolidMaskSpinBox_value_changed(value): if nodeClm == oDataClm: @@ -195,7 +200,7 @@ func _on_SolidMaskSpinBox_value_changed(value): var clmIndex = int(oColumnIndexSpinBox.value) nodeClm.solidMask[clmIndex] = int(value) nodeVoxelView.update_column_view() - + adjust_ui_color_if_different() func _on_UtilizedSpinBox_value_changed(value): if nodeClm == oDataClm: @@ -203,6 +208,7 @@ func _on_UtilizedSpinBox_value_changed(value): var clmIndex = int(oColumnIndexSpinBox.value) nodeClm.utilized[clmIndex] = int(value) nodeVoxelView.update_column_view() + adjust_ui_color_if_different() func _on_ColumnFirstUnusedButton_pressed(): var findUnusedIndex = nodeClm.find_cubearray_index([0,0,0,0, 0,0,0,0], 0) @@ -229,3 +235,33 @@ func _on_ColumnViewDeleteButton_pressed(): func _on_CheckboxShowAll_toggled(checkboxValue): oGridAdvancedValues.visible = checkboxValue + +# Main function to adjust the color of UI elements for a specific column index +func adjust_ui_color_if_different(): + if name != "ColumnsetControls": return + + var column_index = int(oColumnIndexSpinBox.value) + adjust_spinbox_color(oUtilizedSpinBox, is_property_different("utilized", column_index)) + adjust_spinbox_color(oOrientationSpinBox, is_property_different("orientation", column_index)) + adjust_spinbox_color(oSolidMaskSpinBox, is_property_different("solidMask", column_index)) + adjust_spinbox_color(oPermanentSpinBox, is_property_different("permanent", column_index)) + adjust_spinbox_color(oLintelSpinBox, is_property_different("lintel", column_index)) + adjust_spinbox_color(oHeightSpinBox, is_property_different("height", column_index)) + adjust_spinbox_color(oFloorTextureSpinBox, is_property_different("floorTexture", column_index)) + + # Adjust the color for each cube SpinBox + for i in range(8): + var cube_spinbox = cubeSpinBoxArray[i] + var cube_is_different = nodeClm["cubes"][column_index][i] != Columnset.default_data["cubes"][column_index][i] + adjust_spinbox_color(cube_spinbox, cube_is_different) + +# Function to check if a property is different from its default value +func is_property_different(property_name, column_index): + return nodeClm[property_name][column_index] != Columnset.default_data[property_name][column_index] + +# Function to adjust the color of a SpinBox based on property differences +func adjust_spinbox_color(spinbox, is_different): + if is_different == true: + spinbox.modulate = Color(1.4,1.4,1.7) + else: + spinbox.modulate = Color(1,1,1) diff --git a/Scenes/CurrentMap.gd b/Scenes/CurrentMap.gd index fbdd6134..80f21884 100644 --- a/Scenes/CurrentMap.gd +++ b/Scenes/CurrentMap.gd @@ -19,7 +19,7 @@ onready var oMain = Nodelist.list["oMain"] onready var oMessage = Nodelist.list["oMessage"] onready var oDataScript = Nodelist.list["oDataScript"] onready var oScriptHelpers = Nodelist.list["oScriptHelpers"] -onready var oDataCustomSlab = Nodelist.list["oDataCustomSlab"] +onready var oDataFakeSlab = Nodelist.list["oDataFakeSlab"] onready var oSlabPlacement = Nodelist.list["oSlabPlacement"] onready var oMenu = Nodelist.list["oMenu"] onready var oDataLof = Nodelist.list["oDataLof"] @@ -94,7 +94,7 @@ func clear_map(): #"TXT" oDataScript.data = "" # "UNE" - oDataCustomSlab.clear() + oDataFakeSlab.clear() oScriptHelpers.clear() diff --git a/Scenes/CustomSlabSystem.gd b/Scenes/CustomSlabSystem.gd index 4ce61f42..a7c5f94f 100644 --- a/Scenes/CustomSlabSystem.gd +++ b/Scenes/CustomSlabSystem.gd @@ -61,7 +61,7 @@ func load_file(): add_custom_slab(newID, slabName, recognizedAs, liquidType, wibbleType, wibbleEdges, slabCubeData, slabFloorData) -# The purpose of this function is so I don't have to index the columns into clm for simply displaying within the slab window. Only index when PLACING the custom slab. +# The purpose of this function is so I don't have to index the columns into clm for simply displaying within the slab window. Only index when PLACING the Fake Slab. func get_top_cube_face(indexIn3x3, slabID): var cubesArray = data[slabID][CUBE_DATA][indexIn3x3] var get_height = oDataClm.get_real_height(cubesArray) @@ -74,9 +74,9 @@ func get_top_cube_face(indexIn3x3, slabID): return Cube.tex[cubeID][Cube.SIDE_TOP] func remove_custom_slab(slabID): - if slabID < 1000: return # means it's not a custom slab + if slabID < 1000: return # means it's not a Fake Slab - print('Attempting to remove custom slab:' + str(slabID)) + print('Attempting to remove Custom Slab:' + str(slabID)) oPickSlabWindow.set_selection(null) if data.has(slabID): diff --git a/Scenes/Main.tscn b/Scenes/Main.tscn index e1c0e426..7659fff8 100644 --- a/Scenes/Main.tscn +++ b/Scenes/Main.tscn @@ -415,7 +415,7 @@ script = ExtResource( 117 ) [node name="DataLof" type="Node" parent="CurrentMap"] script = ExtResource( 141 ) -[node name="DataCustomSlab" type="TileMap" parent="CurrentMap"] +[node name="DataFakeSlab" type="TileMap" parent="CurrentMap"] format = 1 [node name="OpenMap" type="Node" parent="."] @@ -2154,13 +2154,10 @@ margin_right = 1216.0 margin_bottom = -76.0 rect_min_size = Vector2( 300, 105 ) popup_exclusive = true -window_title = "Confirm delete" -dialog_text = "Delete this custom slab?" +window_title = "Confirm remove" +dialog_text = "Remove this Custom Slab?" dialog_autowrap = true script = ExtResource( 61 ) -__meta__ = { -"_edit_use_anchors_": false -} [node name="ConfirmSaveBeforeQuit" type="WindowDialog" parent="Ui/UiSystem"] visible = true @@ -5388,33 +5385,33 @@ margin_right = 218.0 margin_bottom = 128.0 columns = 2 -[node name="VarDuplicateButton" type="Button" parent="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2"] +[node name="VarCopyButton" type="Button" parent="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2"] margin_right = 107.0 margin_bottom = 27.0 size_flags_horizontal = 3 -text = "Duplicate" +text = "Copy" -[node name="VarRotateButton" type="Button" parent="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2"] +[node name="VarPasteButton" type="Button" parent="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2"] margin_left = 111.0 margin_right = 218.0 margin_bottom = 27.0 size_flags_horizontal = 3 -text = "Rotate" +text = "Paste" -[node name="VarRevertButton" type="Button" parent="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2"] +[node name="VarRotateButton" type="Button" parent="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2"] margin_top = 31.0 margin_right = 107.0 margin_bottom = 58.0 size_flags_horizontal = 3 -text = "Revert" +text = "Rotate" -[node name="VarDeleteButton" type="Button" parent="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2"] +[node name="VarRevertButton" type="Button" parent="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2"] margin_left = 111.0 margin_top = 31.0 margin_right = 218.0 margin_bottom = 58.0 size_flags_horizontal = 3 -text = "Delete" +text = "Revert" [node name="PanelContainer" type="PanelContainer" parent="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer"] margin_top = 150.0 @@ -6294,7 +6291,7 @@ margin_top = 198.0 margin_right = 242.0 margin_bottom = 227.0 group = ExtResource( 155 ) -text = "Custom Slabs (.une)" +text = "Fake Slabs (.une)" [node name="UiMessages" type="Control" parent="Ui"] anchor_right = 1.0 @@ -6902,10 +6899,10 @@ script = SubResource( 20 ) [connection signal="value_changed" from="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer/SlabsetIDSpinBox" to="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/DkSlabsetVoxelView" method="_on_SlabsetIDSpinBox_value_changed"] [connection signal="value_changed" from="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer/VariationNumberSpinBox" to="Ui/UiSystem/SlabsetWindow" method="_on_VariationNumberSpinBox_value_changed"] [connection signal="value_changed" from="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer/VariationNumberSpinBox" to="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/DkSlabsetVoxelView" method="_on_VariationNumberSpinBox_value_changed"] -[connection signal="pressed" from="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2/VarDuplicateButton" to="Ui/UiSystem/SlabsetWindow" method="_on_VarDuplicateButton_pressed"] +[connection signal="pressed" from="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2/VarCopyButton" to="Ui/UiSystem/SlabsetWindow" method="_on_VarCopyButton_pressed"] +[connection signal="pressed" from="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2/VarPasteButton" to="Ui/UiSystem/SlabsetWindow" method="_on_VarPasteButton_pressed"] [connection signal="pressed" from="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2/VarRotateButton" to="Ui/UiSystem/SlabsetWindow" method="_on_VarRotateButton_pressed"] [connection signal="pressed" from="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2/VarRevertButton" to="Ui/UiSystem/SlabsetWindow" method="_on_VarRevertButton_pressed"] -[connection signal="pressed" from="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer2/VBoxContainer/GridContainer2/VarDeleteButton" to="Ui/UiSystem/SlabsetWindow" method="_on_VarDeleteButton_pressed"] [connection signal="pressed" from="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer3/VBoxContainer/HBoxContainer/ObjAddButton" to="Ui/UiSystem/SlabsetWindow" method="_on_ObjAddButton_pressed"] [connection signal="pressed" from="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer3/VBoxContainer/HBoxContainer/ObjDeleteButton" to="Ui/UiSystem/SlabsetWindow" method="_on_ObjDeleteButton_pressed"] [connection signal="value_changed" from="Ui/UiSystem/SlabsetWindow/SlabsetTabs/TabSlabset/VBoxContainer/ScrollContainer/VBoxContainer/PanelContainer3/VBoxContainer/SlabsetObjectSection/VBoxContainer/PanelContainer/GridContainer2/ObjObjectIndexSpinBox" to="Ui/UiSystem/SlabsetWindow" method="_on_ObjObjectIndexSpinBox_value_changed"] diff --git a/Scenes/PickSlabWindow.gd b/Scenes/PickSlabWindow.gd index 0adb4eef..293fa0ad 100644 --- a/Scenes/PickSlabWindow.gd +++ b/Scenes/PickSlabWindow.gd @@ -104,7 +104,7 @@ func add_slabs(): for i in 9: columnArray[i] = Slabset.fetch_column_index(slabVariation, i) else: - # Custom slab + # Fake Slab pass id.set_meta("ID_of_slab", slabID) id.panelView = Slabs.data[slabID][Slabs.PANEL_VIEW] @@ -140,7 +140,7 @@ func custom_slab_add_new_button(): func _on_pressed_add_new_custom_slab(): Utils.popup_centered(oColumnEditor) - oColumnEditorTabs.current_tab = 1 # Select tab containing Custom Slab Editor + oColumnEditorTabs.current_tab = 1 # Select tab containing Fake Slab Editor func pressed(id): var setValue = id.get_meta("ID_of_slab") diff --git a/Scenes/ReadData.gd b/Scenes/ReadData.gd index 825c47ba..ebf0e510 100644 --- a/Scenes/ReadData.gd +++ b/Scenes/ReadData.gd @@ -11,7 +11,7 @@ onready var oDataLiquid = Nodelist.list["oDataLiquid"] onready var oDataSlx = Nodelist.list["oDataSlx"] onready var oDataMapName = Nodelist.list["oDataMapName"] onready var oDataScript = Nodelist.list["oDataScript"] -onready var oDataCustomSlab = Nodelist.list["oDataCustomSlab"] +onready var oDataFakeSlab = Nodelist.list["oDataFakeSlab"] onready var oDataLof = Nodelist.list["oDataLof"] onready var oMessage = Nodelist.list["oMessage"] @@ -124,11 +124,11 @@ func read_une(buffer): for ySlab in M.ySize: for xSlab in M.xSize: value = buffer.get_u16() - oDataCustomSlab.set_cell(xSlab,ySlab,value) + oDataFakeSlab.set_cell(xSlab,ySlab,value) func new_une(): for ySlab in M.ySize: for xSlab in M.xSize: - oDataCustomSlab.set_cell(xSlab,ySlab,0) + oDataFakeSlab.set_cell(xSlab,ySlab,0) func read_wlb(buffer): buffer.seek(0) diff --git a/Scenes/Selection.gd b/Scenes/Selection.gd index eb27446b..472c65f6 100644 --- a/Scenes/Selection.gd +++ b/Scenes/Selection.gd @@ -22,7 +22,7 @@ onready var oRectangleSelection = Nodelist.list["oRectangleSelection"] onready var oOnlyOwnership = Nodelist.list["oOnlyOwnership"] onready var oInspector = Nodelist.list["oInspector"] onready var oCustomSlabsTab = Nodelist.list["oCustomSlabsTab"] -onready var oDataCustomSlab = Nodelist.list["oDataCustomSlab"] +onready var oDataFakeSlab = Nodelist.list["oDataFakeSlab"] onready var oScriptHelpers = Nodelist.list["oScriptHelpers"] onready var oEditingTools = Nodelist.list["oEditingTools"] onready var oMirrorPlacementCheckBox = Nodelist.list["oMirrorPlacementCheckBox"] @@ -227,7 +227,7 @@ func construct_shape_for_placement(constructType): oSlabPlacement.generate_slabs_based_on_id(shapePositionArray, updateNearby) func some_manual_placements_dont_update_nearby(): - # Custom slabs don't update the surroundings + # Fake Slabs don't update the surroundings if oCustomSlabsTab.visible == true and oPickSlabWindow.oSelectedRect.visible == true: return false elif Slabs.doors.has(paintSlab): # Doors don't update the surroundings diff --git a/Scenes/Selector.gd b/Scenes/Selector.gd index 486695fb..e9f95472 100644 --- a/Scenes/Selector.gd +++ b/Scenes/Selector.gd @@ -24,7 +24,7 @@ onready var oEditingTools = Nodelist.list["oEditingTools"] onready var oRectangleSelection = Nodelist.list["oRectangleSelection"] onready var oPlacingSettings = Nodelist.list["oPlacingSettings"] onready var oDataSlab = Nodelist.list["oDataSlab"] -onready var oDataCustomSlab = Nodelist.list["oDataCustomSlab"] +onready var oDataFakeSlab = Nodelist.list["oDataFakeSlab"] onready var oQuickMapPreview = Nodelist.list["oQuickMapPreview"] onready var oColumnEditor = Nodelist.list["oColumnEditor"] onready var oColumnEditorTabs = Nodelist.list["oColumnEditorTabs"] @@ -204,7 +204,7 @@ func mouse_button_on_field(): if Input.is_action_pressed("mouse_right"): if visible == true: if oColumnEditor.visible == true and oColumnEditorTabs.current_tab == 1: - #oMessage.quick("Sent column indexes to Custom Slab window") + #oMessage.quick("Sent column indexes to Fake Slab window") oTabCustomSlabs.get_column_indexes_on_tile(cursorTile) @@ -354,7 +354,7 @@ func position_meeting(checkPos, checkGroup): return false func get_slabID_at_pos(pos): - var customSlabID = oDataCustomSlab.get_cellv(pos) + var customSlabID = oDataFakeSlab.get_cellv(pos) if customSlabID > 0: return customSlabID else: diff --git a/Scenes/SlabColumnEditor.gd b/Scenes/SlabColumnEditor.gd index 88d892e1..8248d544 100644 --- a/Scenes/SlabColumnEditor.gd +++ b/Scenes/SlabColumnEditor.gd @@ -13,7 +13,7 @@ onready var oEditor = Nodelist.list["oEditor"] func _ready(): oColumnEditorTabs.set_tab_title(0, "Name is set below") - oColumnEditorTabs.set_tab_title(1, "Add custom slab") + oColumnEditorTabs.set_tab_title(1, "Add fake slab") # When re-opening window or opening for first time func _on_ColumnEditor_visibility_changed(): diff --git a/Scenes/SlabPalette.gd b/Scenes/SlabPalette.gd index e0580c35..17376ee1 100644 --- a/Scenes/SlabPalette.gd +++ b/Scenes/SlabPalette.gd @@ -542,4 +542,4 @@ func start(): # # Put that column index inside the slabPal. # Slabset.dat[i][subtile] = newClmIndex # -# # Add extra sets here for custom slabs +# # Add extra sets here for Fake Slabs diff --git a/Scenes/SlabPlacement.gd b/Scenes/SlabPlacement.gd index 51175e87..70cc9998 100644 --- a/Scenes/SlabPlacement.gd +++ b/Scenes/SlabPlacement.gd @@ -18,7 +18,7 @@ onready var oDataLiquid = Nodelist.list["oDataLiquid"] onready var oOwnableNaturalTerrain = Nodelist.list["oOwnableNaturalTerrain"] onready var oBridgesOnlyOnLiquidCheckbox = Nodelist.list["oBridgesOnlyOnLiquidCheckbox"] onready var oCustomSlabSystem = Nodelist.list["oCustomSlabSystem"] -onready var oDataCustomSlab = Nodelist.list["oDataCustomSlab"] +onready var oDataFakeSlab = Nodelist.list["oDataFakeSlab"] onready var oMirrorOptions = Nodelist.list["oMirrorOptions"] onready var oMirrorPlacementCheckBox = Nodelist.list["oMirrorPlacementCheckBox"] onready var oMirrorFlipCheckBox = Nodelist.list["oMirrorFlipCheckBox"] @@ -102,9 +102,9 @@ func mirror_placement(shapePositionArray, mirrorWhat): calculateOwner = true oDataSlab.set_cellv(toPos, slabID) if slabID < 1000: - oDataCustomSlab.set_cellv(toPos, 0) + oDataFakeSlab.set_cellv(toPos, 0) else: - oDataCustomSlab.set_cellv(toPos, slabID) + oDataFakeSlab.set_cellv(toPos, slabID) MIRROR_STYLE: pass MIRROR_ONLY_OWNERSHIP: @@ -170,9 +170,9 @@ func place_shape_of_slab_id(shapePositionArray, slabID, ownership): oDataOwnership.set_cellv(pos, ownership) if slabID < 1000: - oDataCustomSlab.set_cellv(pos, 0) + oDataFakeSlab.set_cellv(pos, 0) else: - oDataCustomSlab.set_cellv(pos, slabID) + oDataFakeSlab.set_cellv(pos, slabID) match slabID: Slabs.BRIDGE: @@ -328,13 +328,13 @@ func do_slab(xSlab, ySlab, slabID, ownership): elif slabID == Slabs.EARTH: slabID = auto_earth(xSlab, ySlab, slabID, surrID) - if slabID >= 1000: # Custom Slab IDs + if slabID >= 1000: # Fake Slab IDs if oCustomSlabSystem.data.has(slabID): slab_place_custom(xSlab, ySlab, slabID, ownership, surrID) return - # Do not update custom slabs - if oDataCustomSlab.get_cell(xSlab, ySlab) > 0: + # Do not update Fake Slabs + if oDataFakeSlab.get_cell(xSlab, ySlab) > 0: return # WIB (wibble) @@ -1262,7 +1262,7 @@ const slab_temple_odd = [ ] func update_wibble(xSlab, ySlab, slabID, includeNearby): - # I'm using surrounding wibble to update this slab's wibble, instead of using surrounding slabID, this is for the sake of custom slabs + # I'm using surrounding wibble to update this slab's wibble, instead of using surrounding slabID, this is for the sake of Fake Slabs var myWibble = Slabs.data[slabID][Slabs.WIBBLE_TYPE] diff --git a/Scenes/SlabsetWindow.gd b/Scenes/SlabsetWindow.gd index 94e4e5fc..026391c8 100644 --- a/Scenes/SlabsetWindow.gd +++ b/Scenes/SlabsetWindow.gd @@ -35,6 +35,11 @@ onready var oObjThingTypeLabel = Nodelist.list["oObjThingTypeLabel"] onready var oObjNameLabel = Nodelist.list["oObjNameLabel"] onready var oImportSlabsetCfgDialog = Nodelist.list["oImportSlabsetCfgDialog"] +var clipboard = { + "dat": [], + "tng": [] +} + onready var object_field_nodes = [ oObjIsLightCheckBox, # [0] IsLight null, # [1] Variation @@ -143,7 +148,7 @@ func variation_changed(localVariation): constructString += "Near water" oVariationInfoLabel.text = constructString - update_slabthings() + update_objects_ui() #enum dir { # s = 0 @@ -323,7 +328,7 @@ func adjust_object_color_if_different(variation): if id == null: continue if id.modulate.a != 0: # ThingType can be zero alpha if Light is checked if Slabset.is_tng_object_different(variation, objectIndex, property): - id.modulate = Color(1.8,1.8,1.9) + id.modulate = Color(1.4,1.4,1.7) else: id.modulate = Color(1, 1, 1) # White color for unedited fields @@ -333,13 +338,13 @@ func adjust_column_color_if_different(variation): var spinbox = id.get_node("CustomSpinBox") var shortcut = id.get_node("ButtonShortcut") if Slabset.is_dat_column_different(variation, subtile) == true: - spinbox.modulate = Color(1.8,1.8,1.9) + spinbox.modulate = Color(1.4,1.4,1.7) shortcut.modulate = Color(1.4,1.4,1.5) else: spinbox.modulate = Color(1,1,1) shortcut.modulate = Color(1,1,1) -func update_slabthings(): +func update_objects_ui(): var variation = get_current_variation() adjust_column_color_if_different(variation) @@ -404,7 +409,7 @@ func update_obj_name(): func _on_ObjAddButton_pressed(): var variation = get_current_variation() add_new_object_to_variation(variation) - update_slabthings() + update_objects_ui() func add_new_object_to_variation(variation): #update_object_property(Slabset.obj.VARIATION, variation) @@ -430,7 +435,7 @@ func _on_ObjDeleteButton_pressed(): listOfObjects.remove(objectIndex) - update_slabthings() + update_objects_ui() oMessage.quick("Deleted object") func _on_ObjThingTypeSpinBox_value_changed(value:int): @@ -479,45 +484,119 @@ func update_object_property(the_property, new_value): listOfObjects[object_index][the_property] = new_value adjust_object_color_if_different(variation) - -func _on_VarDuplicateButton_pressed(): - # Find the next free variation space - var current_variation = get_current_variation() - var next_free_variation = find_next_free_variation(current_variation) - - if next_free_variation == -1: - oMessage.quick("No free variation spaces available.") +func _on_VarCopyButton_pressed(): + var variation = get_current_variation() + clipboard["dat"] = Slabset.dat[variation].duplicate(true) + clipboard["tng"] = Slabset.tng[variation].duplicate(true) + var slabID = variation / 28 + var localVariation = variation % 28 + oMessage.quick("Copied variation to clipboard") + +func _on_VarPasteButton_pressed(): + if clipboard["dat"].empty() and clipboard["tng"].empty(): + oMessage.quick("Clipboard is empty.") return - # Duplicate the 'dat' for the current variation - ensure_dat_array_has_space(next_free_variation) - Slabset.dat[next_free_variation] = Slabset.dat[current_variation].duplicate() - - # Duplicate the 'tng' for the current variation - ensure_tng_array_has_space(next_free_variation) - Slabset.tng[next_free_variation] = Slabset.tng[current_variation].duplicate(true) # true for deep copy if needed - - # Update UI to reflect the new duplicated variation - update_columns_ui() # Assuming this updates the UI with new column data - update_slabthings() # Assuming this updates the UI with new things/objects - oMessage.quick("Variation duplicated into SlabID: " + str(next_free_variation/28) + ", Variation: " + str(next_free_variation % 28)) + var variation = get_current_variation() + ensure_dat_array_has_space(variation) + ensure_tng_array_has_space(variation) + + Slabset.dat[variation] = clipboard["dat"].duplicate(true) + Slabset.tng[variation] = clipboard["tng"].duplicate(true) - oSlabsetIDSpinBox.value = next_free_variation/28 - oVariationNumberSpinBox.value = next_free_variation % 28 + update_columns_ui() + update_objects_ui() oDkSlabsetVoxelView._on_SlabsetIDSpinBox_value_changed(oSlabsetIDSpinBox.value) + oMessage.quick("Pasted variation") -func find_next_free_variation(current_variation): - for i in range(current_variation+1, 255*28): - if (i >= Slabset.dat.size() or Slabset.dat[i].empty() or Slabset.dat[i] == [0,0,0, 0,0,0, 0,0,0]) and (i >= Slabset.tng.size() or Slabset.tng[i].empty()): - return i -# if Slabset.dat[i] == [0,0,0, 0,0,0, 0,0,0] and Slabset.tng[i].empty(): -# return i - return -1 # Return -1 if no free space is found +const ROTATION_POSITIONS = [ # New positions for subtiles after rotation + 6, 3, 0, + 7, 4, 1, + 8, 5, 2, +] +const ROTATION_MAP = { + 0: 6, 1: 3, 2: 0, + 3: 7, 4: 4, 5: 1, + 6: 8, 7: 5, 8: 2 +} func _on_VarRotateButton_pressed(): - pass # Replace with function body. + var variation = get_current_variation() + ensure_dat_array_has_space(variation) + + # Rotate the 'dat' array by reassigning using the ROTATION_MAP + var new_dat = [] + for i in range(9): + new_dat.append(Slabset.dat[variation][ROTATION_MAP[i]]) + Slabset.dat[variation] = new_dat + + # Rotate the object positions within the slab + for obj in Slabset.tng[variation]: + var new_x = obj[Slabset.obj.RELATIVE_Y] + var new_y = -obj[Slabset.obj.RELATIVE_X] + obj[Slabset.obj.RELATIVE_X] = new_x + obj[Slabset.obj.RELATIVE_Y] = new_y + obj[Slabset.obj.SUBTILE] = ROTATION_MAP[obj[Slabset.obj.SUBTILE]] + + # Update the UI + update_columns_ui() + update_objects_ui() + oMessage.quick("Rotated variation") + func _on_VarRevertButton_pressed(): - pass # Replace with function body. -func _on_VarDeleteButton_pressed(): - pass # Replace with function body. + var variation = get_current_variation() + + # Revert the 'dat' array for the variation if default data is available + if variation < Slabset.default_data["dat"].size(): + Slabset.dat[variation] = Slabset.default_data["dat"][variation].duplicate() + else: + if variation < Slabset.dat.size(): + Slabset.dat.remove(variation) + + # Revert the 'tng' array for the variation if default data is available + if variation < Slabset.default_data["tng"].size(): + Slabset.tng[variation] = Slabset.default_data["tng"][variation].duplicate(true) # deep copy if it contains objects + else: + if variation < Slabset.tng.size(): + Slabset.tng.remove(variation) + + update_columns_ui() # Update UI for columns + update_objects_ui() # Update UI for objects + oMessage.quick("Variation reverted") + + + +#func _on_VarDuplicateButton_pressed(): +# # Find the next free variation space +# var current_variation = get_current_variation() +# var next_free_variation = find_next_free_variation(current_variation) +# +# if next_free_variation == -1: +# oMessage.quick("No free variation spaces available.") +# return +# +# # Duplicate the 'dat' for the current variation +# ensure_dat_array_has_space(next_free_variation) +# Slabset.dat[next_free_variation] = Slabset.dat[current_variation].duplicate() +# +# # Duplicate the 'tng' for the current variation +# ensure_tng_array_has_space(next_free_variation) +# Slabset.tng[next_free_variation] = Slabset.tng[current_variation].duplicate(true) # true for deep copy if needed +# +# # Update UI to reflect the new duplicated variation +# update_columns_ui() # Assuming this updates the UI with new column data +# update_objects_ui() # Assuming this updates the UI with new things/objects +# oMessage.quick("Variation duplicated into SlabID: " + str(next_free_variation/28) + ", Variation: " + str(next_free_variation % 28)) +# +# oSlabsetIDSpinBox.value = next_free_variation/28 +# oVariationNumberSpinBox.value = next_free_variation % 28 +# oDkSlabsetVoxelView._on_SlabsetIDSpinBox_value_changed(oSlabsetIDSpinBox.value) +# +#func find_next_free_variation(current_variation): +# for i in range(current_variation+1, 255*28): +# if (i >= Slabset.dat.size() or Slabset.dat[i].empty() or Slabset.dat[i] == [0,0,0, 0,0,0, 0,0,0]) and (i >= Slabset.tng.size() or Slabset.tng[i].empty()): +# return i +## if Slabset.dat[i] == [0,0,0, 0,0,0, 0,0,0] and Slabset.tng[i].empty(): +## return i +# return -1 # Return -1 if no free space is found diff --git a/Scenes/TabCustomSlabs.gd b/Scenes/TabCustomSlabs.gd index b486e81e..1cd92cc0 100644 --- a/Scenes/TabCustomSlabs.gd +++ b/Scenes/TabCustomSlabs.gd @@ -50,8 +50,8 @@ func _on_SlabRecognizedAs_value_changed(value): func _on_AddCustomSlabButton_pressed(): - var newID = 1000 # We'll say custom slabs are ID 1000 and up - while true: # Find an unused ID within the custom data dictionary + var newID = 1000 # We'll say fake slabs are ID 1000 and up + while true: # Find an unused ID within the fake data dictionary if oCustomSlabSystem.data.has(newID) == false: break else: @@ -79,11 +79,11 @@ func _on_AddCustomSlabButton_pressed(): func _on_HelpCustomSlabsButton_pressed(): var helptext = "" - helptext += "With a few exceptions, most custom slabs will reset their appearance in-game when placing or claiming an adjacent slab. To avoid this, set 'Recognized as' to one of the following: Slab 50, Impenetrable Rock, Gold, Bridge, Gems, Guard post, Doors (without door object). Needs further testing." + helptext += "With a few exceptions, most Fake Slabs will reset their appearance in-game when placing or claiming an adjacent slab. To avoid this, set 'Recognized as' to one of the following: Slab 50, Impenetrable Rock, Gold, Bridge, Gems, Guard post, Doors (without door object). Needs further testing." helptext += "\n\n" - helptext += "After adding one, right click on its portrait within the slab selection window to remove custom slabs from the editor." + helptext += "After adding one, right click on its portrait within the slab selection window to remove Fake Slabs from the editor." helptext += "\n\n" - helptext += "Right click on the map while the custom slab menu is open to copy column index numbers into the window." + helptext += "Right click on the map while the Fake Slab menu is open to copy column index numbers into the window." oMessage.big("Help",helptext) diff --git a/Scenes/VoxelViewer.gd b/Scenes/VoxelViewer.gd index 0caef79a..91733aa2 100644 --- a/Scenes/VoxelViewer.gd +++ b/Scenes/VoxelViewer.gd @@ -130,7 +130,7 @@ func do_all(): - if displayingType == DK_SLABSET: # This is not for custom slab, this is for dynamic slabs + if displayingType == DK_SLABSET: # This is not for fake slab, this is for slabset slabs var slabID = oSlabsetIDSpinBox.value var separation = 0 var variationStart = slabID * 28 @@ -184,7 +184,7 @@ func do_one(): oSelectedPivotPoint.translation.z = (viewObject * 2) oSelectedPivotPoint.translation.x = (viewObject * 2) - if displayingType == DK_SLABSET: # This is not for custom slab, this is for dynamic slabs + if displayingType == DK_SLABSET: # This is not for fake slab, this is for slabset slabs # var slabID = oSlabsetIDSpinBox.value # var variationStart = (slabID * 28) diff --git a/Scenes/WriteData.gd b/Scenes/WriteData.gd index d7d11a03..e114a892 100644 --- a/Scenes/WriteData.gd +++ b/Scenes/WriteData.gd @@ -11,7 +11,7 @@ onready var oDataLiquid = Nodelist.list["oDataLiquid"] onready var oDataMapName = Nodelist.list["oDataMapName"] onready var oCurrentMap = Nodelist.list["oCurrentMap"] onready var oDataScript = Nodelist.list["oDataScript"] -onready var oDataCustomSlab = Nodelist.list["oDataCustomSlab"] +onready var oDataFakeSlab = Nodelist.list["oDataFakeSlab"] onready var oDataLof = Nodelist.list["oDataLof"] onready var oCurrentFormat = Nodelist.list["oCurrentFormat"] @@ -64,7 +64,7 @@ func write_txt(buffer): func write_une(buffer): for ySlab in M.ySize: for xSlab in M.xSize: - value = oDataCustomSlab.get_cell(xSlab,ySlab) + value = oDataFakeSlab.get_cell(xSlab,ySlab) buffer.put_16(value) func write_wlb(buffer): diff --git a/Scenes/oAnalyzeGrids.gd b/Scenes/oAnalyzeGrids.gd index 210b59e9..22e6b4a8 100644 --- a/Scenes/oAnalyzeGrids.gd +++ b/Scenes/oAnalyzeGrids.gd @@ -5,7 +5,7 @@ onready var oDataLiquid = Nodelist.list["oDataLiquid"] onready var oDataSlab = Nodelist.list["oDataSlab"] onready var oDataOwnership = Nodelist.list["oDataOwnership"] onready var oDataClmPos = Nodelist.list["oDataClmPos"] -onready var oDataCustomSlab = Nodelist.list["oDataCustomSlab"] +onready var oDataFakeSlab = Nodelist.list["oDataFakeSlab"] onready var oDataSlx = Nodelist.list["oDataSlx"] onready var oGridDataCheckBox1 = Nodelist.list["oGridDataCheckBox1"] onready var oGridDataCheckBox2 = Nodelist.list["oGridDataCheckBox2"] @@ -23,7 +23,7 @@ onready var tilemap_data = { "Slab": {"extension": ".slb", "grid_type": "TILE", "node": oDataSlab}, "Ownership": {"extension": ".own", "grid_type": "TILE", "node": oDataOwnership}, "Column Positions": {"extension": ".dat", "grid_type": "SUBTILE", "node": oDataClmPos}, - "Custom Slabs": {"extension": ".une", "grid_type": "TILE", "node": oDataCustomSlab}, + "Fake Slabs": {"extension": ".une", "grid_type": "TILE", "node": oDataFakeSlab}, "Style": {"extension": ".slx", "grid_type": "TILE", "node": oDataSlx} } @@ -42,7 +42,7 @@ func _ready(): oGridDataCheckBox4.connect("pressed", self, "_on_checkbox", [oGridDataCheckBox4,"Wibble"]) oGridDataCheckBox5.connect("pressed", self, "_on_checkbox", [oGridDataCheckBox5,"Liquid"]) oGridDataCheckBox6.connect("pressed", self, "_on_checkbox", [oGridDataCheckBox6,"Style"]) - oGridDataCheckBox7.connect("pressed", self, "_on_checkbox", [oGridDataCheckBox7,"Custom Slabs"]) + oGridDataCheckBox7.connect("pressed", self, "_on_checkbox", [oGridDataCheckBox7,"Fake Slabs"]) func _on_checkbox(checkboxNodeThatWasPressed, pressedString): for i in [oGridDataCheckBox1, oGridDataCheckBox2, oGridDataCheckBox3, oGridDataCheckBox4, oGridDataCheckBox5, oGridDataCheckBox6, oGridDataCheckBox7]: