Skip to content

Commit

Permalink
update cfgloader when exporting or deleting slabset filepath
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed Jun 3, 2024
1 parent 23c9124 commit 9baf9d2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Scenes/Main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -3103,7 +3103,7 @@ margin_bottom = 409.0
rect_min_size = Vector2( 300, 105 )
popup_exclusive = true
window_title = "Revert Slabset and delete file"
dialog_text = "Revert all slabs to default and delete map00001.slabset.toml file?"
dialog_text = "<adjusted in code>"
dialog_autowrap = true
script = ExtResource( 61 )

Expand Down
26 changes: 23 additions & 3 deletions Scenes/SlabsetWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ onready var oExportSlabsToml = Nodelist.list["oExportSlabsToml"]
onready var oSlabRevertButton = Nodelist.list["oSlabRevertButton"]
onready var oVarRevertButton = Nodelist.list["oVarRevertButton"]
onready var oSlabsetDeleteButton = Nodelist.list["oSlabsetDeleteButton"]
onready var oConfirmDeleteSlabsetFile = Nodelist.list["oConfirmDeleteSlabsetFile"]
onready var oCfgLoader = Nodelist.list["oCfgLoader"]

enum {
ONE_VARIATION,
Expand Down Expand Up @@ -309,9 +311,17 @@ func _on_ExportColumnsToml_pressed():

func _on_ExportSlabsetTomlDialog_file_selected(filePath):
Slabset.export_toml_slabset(filePath)
for i in 100:

for i in 50:
yield(get_tree(),'idle_frame')
update_slabset_delete_button_state()

var dir = Directory.new()
if dir.file_exists(filePath):
update_slabset_delete_button_state()

if oCfgLoader.paths_loaded[oCfgLoader.LOAD_CFG_CURRENT_MAP].has(filePath) == false:
oCfgLoader.paths_loaded[oCfgLoader.LOAD_CFG_CURRENT_MAP].append(filePath)
oSlabsetPathsLabel.start()

func _on_ExportColumnsetTomlDialog_file_selected(filePath):
Columnset.export_toml_columnset(filePath)
Expand Down Expand Up @@ -840,11 +850,17 @@ func _on_VarButtonsApplyToAllCheckBox_toggled(button_pressed):
oMessage.quick("Copy and paste buttons will affect 1 variation")


onready var oConfirmDeleteSlabsetFile = Nodelist.list["oConfirmDeleteSlabsetFile"]

func _on_SlabsetDeleteButton_pressed():
oConfirmDeleteSlabsetFile.dialog_text = "Revert all slabs to default and delete this file?\n"

var mapName = oCurrentMap.path.get_file().get_basename()
var slabsetFilePath = oCurrentMap.path.get_base_dir().plus_file(mapName + ".slabset.toml")
oConfirmDeleteSlabsetFile.dialog_text += slabsetFilePath
oConfirmDeleteSlabsetFile.rect_min_size.x = 800
Utils.popup_centered(oConfirmDeleteSlabsetFile)


func _on_ConfirmDeleteSlabsetFile_confirmed():
var mapName = oCurrentMap.path.get_file().get_basename()
var slabsetFilePath = oCurrentMap.path.get_base_dir().plus_file(mapName + ".slabset.toml")
Expand All @@ -863,6 +879,10 @@ func _on_ConfirmDeleteSlabsetFile_confirmed():
variations_to_revert.append((slabID * 28) + i)
revert(variations_to_revert)

# Remove from the little box thing of currently loaded files
oCfgLoader.paths_loaded[oCfgLoader.LOAD_CFG_CURRENT_MAP].erase(slabsetFilePath)
oSlabsetPathsLabel.start()

# Update the UI
update_column_spinboxes()
update_objects_ui()
Expand Down

0 comments on commit 9baf9d2

Please sign in to comment.