Skip to content

Commit

Permalink
column editor revert button
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Nov 19, 2023
1 parent fa981d7 commit 45e9915
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Scenes/ClmControls.gd
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ func _on_CheckboxShowAll_toggled(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))
Expand All @@ -232,12 +231,12 @@ func adjust_ui_color_if_different():
# 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]
var cube_is_different = nodeClm["cubes"][column_index][i] != nodeClm.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]
return nodeClm[property_name][column_index] != nodeClm.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):
Expand Down
5 changes: 5 additions & 0 deletions Scenes/ClmControls.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ unique_name_in_owner = true
margin_left = 132.0
margin_right = 206.0
margin_bottom = 24.0
hint_tooltip = "This is how many times this column appears on the map."
size_flags_horizontal = 10
theme = SubResource( 1 )
max_value = 99999.0
Expand Down Expand Up @@ -145,6 +146,7 @@ unique_name_in_owner = true
margin_left = 132.0
margin_right = 206.0
margin_bottom = 24.0
hint_tooltip = "Top cube"
size_flags_horizontal = 10
max_value = 1e+09
script = ExtResource( 1 )
Expand Down Expand Up @@ -278,6 +280,7 @@ margin_left = 132.0
margin_top = 196.0
margin_right = 206.0
margin_bottom = 220.0
hint_tooltip = "Bottom cube"
size_flags_horizontal = 10
max_value = 1e+09
script = ExtResource( 1 )
Expand All @@ -297,6 +300,7 @@ margin_left = 132.0
margin_top = 224.0
margin_right = 206.0
margin_bottom = 248.0
hint_tooltip = "This is the flat texture which is lower than the bottom cube"
size_flags_horizontal = 10
max_value = 1e+09
script = ExtResource( 1 )
Expand All @@ -306,6 +310,7 @@ margin_top = 384.0
margin_right = 206.0
margin_bottom = 408.0
rect_min_size = Vector2( 24, 24 )
hint_tooltip = "You don't need to manually edit these"
text = "Show all"

[node name="GridAdvancedValues" type="GridContainer" parent="ScrollContainer/VBoxContainer"]
Expand Down
10 changes: 10 additions & 0 deletions Scenes/DataClm.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ var height = []
var cubes = []
var floorTexture = []

var 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)

#var testingSpecialByte = []

Expand Down
2 changes: 2 additions & 0 deletions Scenes/OpenMap.gd
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ func finish_opening_map(map):
oEditor.mapHasBeenEdited = true
oMessage.quick("Fixed column index 0, re-save your map.")

oDataClm.store_default_data()

if oGame.running_keeperfx() == true:
if oCurrentFormat.selected == 1: # KFX format
if oGame.KEEPERFX_VERSION_INT != 500: # Skip worrying about the compiled versions (0.5.0.0)
Expand Down
2 changes: 2 additions & 0 deletions Scenes/SaveMap.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ onready var oDataScript = Nodelist.list["oDataScript"]
onready var oScriptEditor = Nodelist.list["oScriptEditor"]
onready var oMenu = Nodelist.list["oMenu"]
onready var oCurrentFormat = Nodelist.list["oCurrentFormat"]
onready var oDataClm = Nodelist.list["oDataClm"]

var queueExit = false

Expand Down Expand Up @@ -63,6 +64,7 @@ func save_map(filePath): # auto opens other files
oCurrentMap.set_path_and_title(filePath)
oEditor.mapHasBeenEdited = false
oScriptEditor.set_script_as_edited(false)
oDataClm.store_default_data() # This makes it so the map Column Editor's default columns are now reflected as "what's saved"
oMapSettingsWindow.visible = false
# This goes last. Queued from when doing "save before quitting" and "save as" before quitting.
if queueExit == true:
Expand Down

0 comments on commit 45e9915

Please sign in to comment.