Skip to content

Commit

Permalink
slabset export, added Secret Door sprite
Browse files Browse the repository at this point in the history
  • Loading branch information
rainlizard committed May 31, 2024
1 parent 5fbec47 commit a9275e4
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 101 deletions.
13 changes: 6 additions & 7 deletions Autoload/Columnset.gd
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,15 @@ func store_default_data():
default_data["floorTexture"] = floorTexture.duplicate(true)


func export_toml_columnset(filePath, fullExport): #"res://columnset.toml"
func export_toml_columnset(filePath): #"res://columnset.toml"
var oMessage = Nodelist.list["oMessage"]

# Find differences if not a full export
var column_diffs = []
if fullExport == false:
column_diffs = find_all_different_columns()
if column_diffs.size() == 0:
oMessage.big("File wasn't saved", "You've made zero changes, so the file wasn't saved.")
return
column_diffs = find_all_different_columns()
if column_diffs.size() == 0:
oMessage.big("File wasn't saved", "You've made zero changes, so the file wasn't saved.")
return

var textFile = File.new()
if textFile.open(filePath, File.WRITE) != OK:
Expand All @@ -108,7 +107,7 @@ func export_toml_columnset(filePath, fullExport): #"res://columnset.toml"

for i in 2048:
# If this is a partial export, then skip this column if it is the same as default.
if fullExport == false and column_diffs.has(i) == false:
if column_diffs.has(i) == false:
continue

textFile.store_line('[column' + str(i) +']')
Expand Down
2 changes: 1 addition & 1 deletion Autoload/Graphics.gd
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ var sprite_id = {
"BRACED" : preload("res://dk_images/trapdoor_64/door_pers_braced_std.png"),
"STEEL" : preload("res://dk_images/trapdoor_64/door_pers_iron_std.png"),
"MAGIC" : preload("res://dk_images/trapdoor_64/door_pers_magic_std.png"),
"SECRET" : preload("res://dk_images/trapdoor_64/door_pers_magic_std.png"),
"SECRET" : preload("res://extra_images/secret_door.png"),
# EffectGens
"EFFECTGENERATOR_LAVA" : preload("res://edited_images/GUIEDIT-1/PIC27.png"),
"EFFECTGENERATOR_DRIPPING_WATER" : preload("res://edited_images/GUIEDIT-1/PIC28.png"),
Expand Down
164 changes: 81 additions & 83 deletions Autoload/Slabset.gd
Original file line number Diff line number Diff line change
Expand Up @@ -230,111 +230,108 @@ enum { # BitFlags
SKIP_COLUMNS = 1,
SKIP_OBJECTS = 2,
}

func export_toml_slabset(filePath, fullExport): #"res://slabset.toml"
func export_toml_slabset(filePath):
var CODETIME_START = OS.get_ticks_msec()

# Find differences if not a full export
var dat_diffs = []
var tng_diffs = []
if fullExport == false:
dat_diffs = find_all_dat_differences()
tng_diffs = find_all_tng_differences()
if tng_diffs.size() == 0 and dat_diffs.size() == 0:
oMessage.big("File wasn't saved", "You've made zero changes, so the file wasn't saved.")
return
dat_diffs = find_all_dat_differences()
tng_diffs = find_all_tng_differences()
if tng_diffs.size() == 0 and dat_diffs.size() == 0:
oMessage.big("File wasn't saved", "You've made zero changes, so the file wasn't saved.")
return


# Print differences for debugging

# # Print differences for debugging
for i in tng_diffs:
print("---------TNG differences---------")
print("Current: ", tng[i])
if i < default_data["tng"].size():
print("Default: ", default_data["tng"][i])
else:
print("Default: Beyond array size")
#
# # Print differences for debugging
# for i in dat_diffs:
# print("---------DAT differences---------")
# print("Current: ", dat[i])
# if i < default_data["dat"].size():
# print("Default: ", default_data["dat"][i])
# else:
# print("Default: Beyond array size")

# Print differences for debugging
for i in dat_diffs:
print("---------DAT differences---------")
print("Current: ", dat[i])
if i < default_data["dat"].size():
print("Default: ", default_data["dat"][i])
else:
print("Default: Beyond array size")


var lines = PoolStringArray()
var totalSlabs = max(dat.size(), tng.size()) / 28
for slabID in totalSlabs:
var hasChanges = false

# Check if there are any changes within the 28 variations
for variationNumber in 28:
var variation = slabID * 28 + variationNumber
if dat_diffs.has(variation) or tng_diffs.has(variation):
hasChanges = true
break

if hasChanges == true:
lines.append("[slab" + str(slabID) + "]")

for variationNumber in 28:
var variation = slabID * 28 + variationNumber
var dirText = dir_texts[variationNumber]

lines.append("[slab" + str(slabID) + "." + dirText + "]")

lines.append("Columns = " + str(dat[variation]))

for object in tng[variation]:
lines.append("")
lines.append("[[slab" + str(slabID) + "." + dirText + "_objects" + "]]")
for z in 9:
var propertyName
var value
match z:
0:
propertyName = "IsLight"
value = object[z]
2:
propertyName = "Subtile"
value = object[z]
3:
propertyName = "RelativePosition"
value = [ object[3], object[4], object[5] ]
6:
propertyName = "ThingType"
value = object[z]
7:
propertyName = "Subtype"
value = object[z]
8:
propertyName = "EffectRange"
value = object[z]
if propertyName:
lines.append(propertyName + " = " + str(value))
if tng[variation].size() == 0:
lines.append("Objects = []")

lines.append("")
lines.append("")

var textFile = File.new()
if textFile.open(filePath, File.WRITE) != OK:
oMessage.big("Error", "Couldn't save file, maybe try saving to another directory.")
return

var biggest_array = max(dat.size(), tng.size())
for variation in biggest_array:
# If both are empty then skip writing this slab
if (variation >= dat.size() or dat[variation] == [0,0,0, 0,0,0, 0,0,0]) and (variation >= tng.size() or tng[variation] == []):
continue

# Skip differences
var skip = SKIP_NONE
if fullExport == false:
if dat_diffs.has(variation) == false:
skip += SKIP_COLUMNS
if tng_diffs.has(variation) == false:
skip += SKIP_OBJECTS
if skip == SKIP_COLUMNS + SKIP_OBJECTS:
continue # skip both

var slabID = int(variation / 28)
var variationNumber = variation % 28
var dirText = dir_texts[variationNumber]

if variationNumber == 0:
textFile.store_line("[slab" + str(slabID) + "]")
textFile.store_line("[slab" + str(slabID) + "." + dirText + "]")

if skip != SKIP_COLUMNS:
textFile.store_line("Columns = " + str(dat[variation]))

if skip != SKIP_OBJECTS:
for object in tng[variation]:
textFile.store_line("\r")
textFile.store_line("[[slab" + str(slabID) + "." + dirText + "_objects" + "]]")
for z in 9:
var propertyName
var value
# 1 = Variation, 4 = RelativeY, 5 = RelativeZ
match z:
0:
propertyName = "IsLight"
value = object[z]
2:
propertyName = "Subtile"
value = object[z]
3:
propertyName = "RelativePosition"
value = [ object[3], object[4], object[5] ]
6:
propertyName = "ThingType"
value = object[z]
7:
propertyName = "Subtype"
value = object[z]
8:
propertyName = "EffectRange"
value = object[z]
if propertyName:
textFile.store_line(propertyName + " = " + str(value))
if tng[variation].size() == 0:
textFile.store_line("Objects = []")

textFile.store_line("\r")

textFile.store_string("\n".join(lines))
textFile.close()
oMessage.quick("Saved: " + filePath)

oMessage.quick("Saved: " + filePath)
print('Exported in: ' + str(OS.get_ticks_msec() - CODETIME_START) + 'ms')



func find_all_dat_differences():
var diff_indices = []
for variation in dat.size():
Expand Down Expand Up @@ -362,10 +359,11 @@ func is_dat_variation_different(variation):


func is_tng_variation_different(variation):
if variation >= tng.size() or tng[variation].empty(): # This function should not have been called
return false
if tng[variation] == [0,0,0, 0,0,0, 0,0,0]: # If it's got nothing on it, then skip it
#or tng[variation].empty()
if variation >= tng.size(): # This function should not have been called
return false
# if tng[variation] == [0,0,0, 0,0,0, 0,0,0]: # If it's got nothing on it, then skip it
# return false
if variation >= default_data["tng"].size() or tng[variation] != default_data["tng"][variation]: # If 'default' is shorter, or the current and default elements differ
return true
return false
Expand Down
16 changes: 10 additions & 6 deletions Scenes/SlabsetWindow.gd
Original file line number Diff line number Diff line change
Expand Up @@ -232,26 +232,30 @@ func _on_SlabsetCopyValues_pressed():
# oExportSlabsetClmDialog.current_path = oGame.GAME_DIRECTORY.plus_file("")
# oExportSlabsetClmDialog.current_file = "slabs.clm"


func _on_ExportSlabsToml_pressed():
Utils.popup_centered(oExportSlabsetTomlDialog)
oExportSlabsetTomlDialog.current_dir = oCurrentMap.path.get_base_dir().plus_file("")
oExportSlabsetTomlDialog.current_path = oCurrentMap.path.get_base_dir().plus_file("")
oExportSlabsetTomlDialog.current_file = oCurrentMap.path.get_file().get_basename()+".slabset.toml"

yield(get_tree(),'idle_frame') # Important if there's another toml file there
oExportSlabsetTomlDialog.get_line_edit().text = oCurrentMap.path.get_file().get_basename()+".slabset.toml"


func _on_ExportColumnsToml_pressed():
Utils.popup_centered(oExportColumnsetTomlDialog)
oExportColumnsetTomlDialog.current_dir = oCurrentMap.path.get_base_dir().plus_file("")
oExportColumnsetTomlDialog.current_path = oCurrentMap.path.get_base_dir().plus_file("")
oExportColumnsetTomlDialog.current_file = oCurrentMap.path.get_file().get_basename()+".columnset.toml"

yield(get_tree(),'idle_frame') # Important if there's another toml file there
oExportColumnsetTomlDialog.get_line_edit().text = oCurrentMap.path.get_file().get_basename()+".columnset.toml"


func _on_ExportSlabsetTomlDialog_file_selected(filePath):
var fullExport = false
Slabset.export_toml_slabset(filePath, fullExport)
Slabset.export_toml_slabset(filePath)

func _on_ExportColumnsetTomlDialog_file_selected(filePath):
var fullExport = false
Columnset.export_toml_columnset(filePath, fullExport)
Columnset.export_toml_columnset(filePath)


#func _on_ImportSlabsetTomlDialog_file_selected(filePath):
Expand Down
21 changes: 17 additions & 4 deletions Scenes/ThingInstance.gd
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,13 @@ func set_creatureName(setval):
#setval = Utils.strip_special_chars_from_string(setval)
creatureName = setval


func set_herogateNumber(setval):
data14 = null
herogateNumber = setval
$GateNumber.text = str(herogateNumber)


func set_texture_based_on_thingtype():
var tex = Things.fetch_sprite(thingType, subtype)
match thingType:
Expand Down Expand Up @@ -246,10 +248,20 @@ func set_texture_based_on_thingtype():
func set_grow_direction():
# Change Grow Direction so the art pokes out from the base.
var texpath = $ThingTexture.texture.get_path()
if "trapdoor_64" in texpath or "keepower_64" in texpath or "room_64" in texpath:
pass
else:
$ThingTexture.grow_vertical = Control.GROW_DIRECTION_BEGIN

# Return if we want to grow from center
if thingType == Things.TYPE.OBJECT:
if Things.DATA_OBJECT.has(subtype):
if Things.DATA_OBJECT[subtype][Things.EDITOR_TAB] == Things.TAB_SPELL:
return
elif thingType == Things.TYPE.TRAP:
return
elif thingType == Things.TYPE.DOOR:
return

# Grow from base instead of center
$ThingTexture.grow_vertical = Control.GROW_DIRECTION_BEGIN


func _on_MouseDetection_mouse_entered():
if oSelection.cursorOnInstancesArray.has(self) == false:
Expand All @@ -261,6 +273,7 @@ func _on_MouseDetection_mouse_entered():
$TextNameLabel.modulate = Color(1,1,1,1)
z_index = baseZindex+1


func _on_MouseDetection_mouse_exited():
if oSelection.cursorOnInstancesArray.has(self):
oSelection.cursorOnInstancesArray.erase(self)
Expand Down
Binary file added extra_images/secret_door.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions extra_images/secret_door.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/secret_door.png-c23a6961874f1b19383f55fa08c1ba2e.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://extra_images/secret_door.png"
dest_files=[ "res://.import/secret_door.png-c23a6961874f1b19383f55fa08c1ba2e.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=true
flags/anisotropic=true
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

0 comments on commit a9275e4

Please sign in to comment.