From 960771ba0edbf475c030f30f546df24127314987 Mon Sep 17 00:00:00 2001 From: rainlizard Date: Sun, 26 Nov 2023 16:21:57 +1100 Subject: [PATCH] automatically load slabset.cfg and columnset.cfg from /fxdata/ directory --- Autoload/Columnset.gd | 19 +++++- Autoload/Slabs.gd | 68 ++++++++++----------- Autoload/Slabset.gd | 108 +++++++++++++++++++--------------- Scenes/AddCustomSlabWindow.gd | 10 ---- Scenes/CustomSlabSystem.gd | 2 +- Scenes/Main.tscn | 17 ++---- Scenes/OpenMap.gd | 4 +- Scenes/OwnedColumns.gd | 1 - Scenes/PickSlabWindow.gd | 1 - Scenes/SlabPalette.gd | 5 +- Scenes/SlabPlacement.gd | 1 - Scenes/SlabsetWindow.gd | 1 - 12 files changed, 121 insertions(+), 116 deletions(-) diff --git a/Autoload/Columnset.gd b/Autoload/Columnset.gd index 501348b1..6797ab94 100644 --- a/Autoload/Columnset.gd +++ b/Autoload/Columnset.gd @@ -16,10 +16,25 @@ var default_data = {} # 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. + func load_default_columnset(): var CODETIME_START = OS.get_ticks_msec() clear_all_column_data() # Important, for reloading/refreshing slabs.clm + # Decide which one to load + var filePath = oGame.get_precise_filepath(oGame.DK_FXDATA_DIRECTORY, "COLUMNSET.CFG") + if filePath != "": + # Load columnset.cfg file + import_cfg_columnset(filePath, true) + else: + # Load slabs.clm file + load_default_original_columnset() + + store_default_data() + print('Created Columnset : '+str(OS.get_ticks_msec()-CODETIME_START)+'ms') + + +func load_default_original_columnset(): var filePath = oGame.get_precise_filepath(oGame.DK_DATA_DIRECTORY, "SLABS.CLM") var buffer = Filetypes.file_path_to_buffer(filePath) @@ -47,9 +62,7 @@ func load_default_columnset(): cubes[entry].resize(8) for cubeNumber in 8: 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) diff --git a/Autoload/Slabs.gd b/Autoload/Slabs.gd index e1a55081..54da37a9 100644 --- a/Autoload/Slabs.gd +++ b/Autoload/Slabs.gd @@ -94,7 +94,7 @@ var doors = {42:null,43:null,44:null,45:null,46:null,47:null,48:null,49:null} # These are just to make it easier to read const NOT_OWNABLE = false const OWNABLE = true -const FLOOR_SLAB = false +const EMPTY_SLAB = false const BLOCK_SLAB = true enum { BITMASK_FLOOR = 0 @@ -147,54 +147,54 @@ var data = { WALL_WITH_WOMAN: ["Woman Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 4, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 7 WALL_WITH_PAIR: ["Pair Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 4, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 8 WALL_DAMAGED: ["Damaged Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 4, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 9 - PATH: ["Dirt Path", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 10 - CLAIMED_GROUND: ["Claimed Area", FLOOR_SLAB, BITMASK_CLAIMED, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 11 - LAVA: ["Lava", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ANIMATED, REMEMBER_LAVA, NOT_OWNABLE], # 12 - WATER: ["Water", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ANIMATED, REMEMBER_WATER, NOT_OWNABLE], # 13 - PORTAL: ["Portal", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 14 + PATH: ["Dirt Path", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 10 + CLAIMED_GROUND: ["Claimed Area", EMPTY_SLAB, BITMASK_CLAIMED, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 11 + LAVA: ["Lava", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ANIMATED, REMEMBER_LAVA, NOT_OWNABLE], # 12 + WATER: ["Water", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ANIMATED, REMEMBER_WATER, NOT_OWNABLE], # 13 + PORTAL: ["Portal", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 14 PORTAL_WALL: ["Portal Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 15 - TREASURE_ROOM: ["Treasure Room", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 16 + TREASURE_ROOM: ["Treasure Room", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 16 TREASURE_ROOM_WALL: ["Treasure Room Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 17 - LIBRARY: ["Library", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 18 + LIBRARY: ["Library", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 18 LIBRARY_WALL: ["Library Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 19 - PRISON: ["Prison", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 20 + PRISON: ["Prison", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 20 PRISON_WALL: ["Prison Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 21 - TORTURE_CHAMBER: ["Torture Chamber", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 22 + TORTURE_CHAMBER: ["Torture Chamber", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 22 TORTURE_CHAMBER_WALL:["Torture Chamber Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 4, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 23 - TRAINING_ROOM: ["Training Room", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 24 + TRAINING_ROOM: ["Training Room", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 24 TRAINING_ROOM_WALL: ["Training Room Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 25 - DUNGEON_HEART: ["Heart Room", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 26 + DUNGEON_HEART: ["Heart Room", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 26 DUNGEON_HEART_WALL: ["Heart Room Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 27 - WORKSHOP: ["Workshop", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 28 + WORKSHOP: ["Workshop", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 28 WORKSHOP_WALL: ["Workshop Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 29 - SCAVENGER_ROOM: ["Scavenger Room", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 30 + SCAVENGER_ROOM: ["Scavenger Room", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 30 SCAVENGER_ROOM_WALL: ["Scavenger Room Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 31 - TEMPLE: ["Temple", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 32 + TEMPLE: ["Temple", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 32 TEMPLE_WALL: ["Temple Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 33 - GRAVEYARD: ["Graveyard", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 34 + GRAVEYARD: ["Graveyard", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 34 GRAVEYARD_WALL: ["Graveyard Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 35 - HATCHERY: ["Hatchery", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 36 + HATCHERY: ["Hatchery", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 36 HATCHERY_WALL: ["Hatchery Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 37 - LAIR: ["Lair", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 38 + LAIR: ["Lair", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 38 LAIR_WALL: ["Lair Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 39 - BARRACKS: ["Barracks", FLOOR_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 40 + BARRACKS: ["Barracks", EMPTY_SLAB, BITMASK_FLOOR, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 40 BARRACKS_WALL: ["Barracks Wall", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_SIDE_VIEW, 3, TAB_OTHER, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 41 - WOODEN_DOOR_1: ["Wooden Door", FLOOR_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_NONE, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 42 - WOODEN_DOOR_2: ["Wooden Door", FLOOR_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 43 - BRACED_DOOR_1: ["Braced Door", FLOOR_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_NONE, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 44 - BRACED_DOOR_2: ["Braced Door", FLOOR_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 45 - IRON_DOOR_1: ["Iron Door", FLOOR_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_NONE, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 46 - IRON_DOOR_2: ["Iron Door", FLOOR_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 47 - MAGIC_DOOR_1: ["Magic Door", FLOOR_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_NONE, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 48 - MAGIC_DOOR_2: ["Magic Door", FLOOR_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 49 - SLAB_50: ["Slab 50", FLOOR_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 3, TAB_OTHER, WIBBLE_OFF, REMEMBER_PATH, OWNABLE], # 50 - BRIDGE: ["Bridge", FLOOR_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 51 + WOODEN_DOOR_1: ["Wooden Door", EMPTY_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_NONE, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 42 + WOODEN_DOOR_2: ["Wooden Door", EMPTY_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 43 + BRACED_DOOR_1: ["Braced Door", EMPTY_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_NONE, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 44 + BRACED_DOOR_2: ["Braced Door", EMPTY_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 45 + IRON_DOOR_1: ["Iron Door", EMPTY_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_NONE, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 46 + IRON_DOOR_2: ["Iron Door", EMPTY_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 47 + MAGIC_DOOR_1: ["Magic Door", EMPTY_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_NONE, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 48 + MAGIC_DOOR_2: ["Magic Door", EMPTY_SLAB, BITMASK_OTHER, PANEL_DOOR_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 49 + SLAB_50: ["Slab 50", EMPTY_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 3, TAB_OTHER, WIBBLE_OFF, REMEMBER_PATH, OWNABLE], # 50 + BRIDGE: ["Bridge", EMPTY_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 51 GEMS: ["Gems", BLOCK_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, NOT_OWNABLE], # 52 - GUARD_POST: ["Guard Post", FLOOR_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 53 - PURPLE_PATH: ["Purple Path", FLOOR_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 0, TAB_OTHER, WIBBLE_OFF, REMEMBER_PATH, NOT_OWNABLE], # 54 -# PURPLE_PATH2: ["Purple Path 2", FLOOR_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_OFF, REMEMBER_PATH, OWNABLE], # 55 -# PURPLE_PATH3: ["Purple Path 3", FLOOR_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_OFF, REMEMBER_PATH, OWNABLE], # 56 -# PURPLE_PATH4: ["Purple Path 4", FLOOR_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_OFF, REMEMBER_PATH, OWNABLE], # 57 + GUARD_POST: ["Guard Post", EMPTY_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 3, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 53 + PURPLE_PATH: ["Purple Path", EMPTY_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 0, TAB_OTHER, WIBBLE_OFF, REMEMBER_PATH, NOT_OWNABLE], # 54 +# PURPLE_PATH2: ["Purple Path 2", EMPTY_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_OFF, REMEMBER_PATH, OWNABLE], # 55 +# PURPLE_PATH3: ["Purple Path 3", EMPTY_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_OFF, REMEMBER_PATH, OWNABLE], # 56 +# PURPLE_PATH4: ["Purple Path 4", EMPTY_SLAB, BITMASK_OTHER, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_OFF, REMEMBER_PATH, OWNABLE], # 57 WALL_AUTOMATIC: ["Wall Automatic", BLOCK_SLAB, BITMASK_REINFORCED, PANEL_TOP_VIEW, 0, TAB_MAINSLAB, WIBBLE_ON, REMEMBER_PATH, OWNABLE], # 99999 } var icons = { diff --git a/Autoload/Slabset.gd b/Autoload/Slabset.gd index 0e88734f..67f07efc 100644 --- a/Autoload/Slabset.gd +++ b/Autoload/Slabset.gd @@ -1,4 +1,7 @@ extends Node +onready var oGame = Nodelist.list["oGame"] +onready var oMessage = Nodelist.list["oMessage"] + var tng = [] var dat = [] var default_data = {} @@ -34,9 +37,66 @@ enum dir { # import_cfg_slabset("D:/AI/slabset.cfg", true) # print('Import Codetime: ' + str(OS.get_ticks_msec() - CODETIME_START) + 'ms') +func load_default_slabset(): + var CODETIME_START = OS.get_ticks_msec() + tng = [] + dat = [] + + # Decide which one to load + var filePath = oGame.get_precise_filepath(oGame.DK_FXDATA_DIRECTORY, "SLABSET.CFG") + if filePath != "": + # Load slabset.cfg file + import_cfg_slabset(filePath, true) + else: + # Load slabs.dat and slabs.tng files + load_default_original_slabset() + + print('Created Slabset : '+str(OS.get_ticks_msec()-CODETIME_START)+'ms') + store_default_data() + + +func load_default_original_slabset(): + + var dat_buffer = Filetypes.file_path_to_buffer(oGame.get_precise_filepath(oGame.DK_DATA_DIRECTORY, "SLABS.DAT")) + var tng_buffer = Filetypes.file_path_to_buffer(oGame.get_precise_filepath(oGame.DK_DATA_DIRECTORY, "SLABS.TNG")) + + var object_info = create_object_list(tng_buffer) + if object_info.size() == 0: + oMessage.quick("Failed to load objects") + return + + var totalSlabs = 42 + 16 + var totalVariations = totalSlabs * 28 + tng.resize(totalVariations) + dat.resize(totalVariations) + tng_buffer.seek(2) + dat_buffer.seek(2) + + for variation in dat.size(): + tng[variation] = [] + dat[variation] = [0,0,0, 0,0,0, 0,0,0] + if variation < 42*28 or (variation % 28) < 8: # Handle the longslabs and the shortslabs + + for subtile in 9: + dat[variation][subtile] = 65536 - dat_buffer.get_u16() + + var getObjectIndex = tng_buffer.get_u16() + + while getObjectIndex < object_info.size(): # Continue until "break" + var objectStuff = object_info[getObjectIndex] + if objectStuff[1] != variation: + break + tng[variation].append(objectStuff) + getObjectIndex += 1 + + + +func store_default_data(): + default_data["dat"] = dat.duplicate(true) + default_data["tng"] = tng.duplicate(true) + func import_cfg_slabset(filePath, fullImport): - var oMessage = Nodelist.list["oMessage"] var processed_string = preprocess_cfg_file(filePath) if processed_string == null: oMessage.quick("Failed to open file: " + str(filePath)) @@ -138,52 +198,6 @@ func preprocess_cfg_file(filePath): # 7ms # textFile.store_string(processed_string) # textFile.close() -func load_default_slabset(): - tng = [] - dat = [] - var CODETIME_START = OS.get_ticks_msec() - var oGame = Nodelist.list["oGame"] - var oMessage = Nodelist.list["oMessage"] - - var dat_buffer = Filetypes.file_path_to_buffer(oGame.get_precise_filepath(oGame.DK_DATA_DIRECTORY, "SLABS.DAT")) - var tng_buffer = Filetypes.file_path_to_buffer(oGame.get_precise_filepath(oGame.DK_DATA_DIRECTORY, "SLABS.TNG")) - - var object_info = create_object_list(tng_buffer) - if object_info.size() == 0: - oMessage.quick("Failed to load objects") - return - - var totalSlabs = 42 + 16 - var totalVariations = totalSlabs * 28 - tng.resize(totalVariations) - dat.resize(totalVariations) - tng_buffer.seek(2) - dat_buffer.seek(2) - - for variation in dat.size(): - tng[variation] = [] - dat[variation] = [0,0,0, 0,0,0, 0,0,0] - if variation < 42*28 or (variation % 28) < 8: # Handle the longslabs and the shortslabs - - for subtile in 9: - dat[variation][subtile] = 65536 - dat_buffer.get_u16() - - var getObjectIndex = tng_buffer.get_u16() - - while getObjectIndex < object_info.size(): # Continue until "break" - var objectStuff = object_info[getObjectIndex] - if objectStuff[1] != variation: - break - tng[variation].append(objectStuff) - getObjectIndex += 1 - - print('Created Slabset : '+str(OS.get_ticks_msec()-CODETIME_START)+'ms') - store_default_data() - -func store_default_data(): - default_data["dat"] = dat.duplicate(true) - default_data["tng"] = tng.duplicate(true) - func create_object_list(tng_buffer): tng_buffer.seek(0) var numberOfThings = tng_buffer.get_u16() # It says 359, however there are actually 362 entries in the file. diff --git a/Scenes/AddCustomSlabWindow.gd b/Scenes/AddCustomSlabWindow.gd index f345ae45..8ea73a45 100644 --- a/Scenes/AddCustomSlabWindow.gd +++ b/Scenes/AddCustomSlabWindow.gd @@ -168,13 +168,3 @@ func _on_HelpCustomSlabsButton_pressed(): var helptext = "" helptext += "After adding a custom slab, right click on its portrait within the slab selection window to remove it from the editor." oMessage.big("Help",helptext) - - -func _on_SlabIsSolidOptionButton_item_selected(index): - pass # Replace with function body. - -func _on_SlabOwnableOptionButton_item_selected(index): - pass # Replace with function body. - -func _on_SlabBitmaskOptionButton_item_selected(index): - pass # Replace with function body. diff --git a/Scenes/CustomSlabSystem.gd b/Scenes/CustomSlabSystem.gd index 79dba086..d23da7be 100644 --- a/Scenes/CustomSlabSystem.gd +++ b/Scenes/CustomSlabSystem.gd @@ -44,7 +44,7 @@ func load_file(): "cube_data": slabCubeData, "floor_data": slabFloorData, "bitmask": cfg.get_value(section, "bitmask", Slabs.BITMASK_FLOOR), - "is_solid": cfg.get_value(section, "is_solid", Slabs.FLOOR_SLAB), + "is_solid": cfg.get_value(section, "is_solid", Slabs.EMPTY_SLAB), "ownable": cfg.get_value(section, "ownable", Slabs.OWNABLE) } diff --git a/Scenes/Main.tscn b/Scenes/Main.tscn index 45b5ed56..cb741b84 100644 --- a/Scenes/Main.tscn +++ b/Scenes/Main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=180 format=2] +[gd_scene load_steps=179 format=2] [ext_resource path="res://Scenes/SlabStyle.gd" type="Script" id=1] [ext_resource path="res://Scenes/SlabPlacement.gd" type="Script" id=2] @@ -64,7 +64,6 @@ [ext_resource path="res://Scenes/SettingsWindow.gd" type="Script" id=62] [ext_resource path="res://Scenes/OptionButtonMSAA.gd" type="Script" id=63] [ext_resource path="res://Scenes/OverheadGraphics.gd" type="Script" id=64] -[ext_resource path="res://Scenes/SlabPalette.gd" type="Script" id=65] [ext_resource path="res://Art/HelpIconPressed.png" type="Texture" id=66] [ext_resource path="res://Scenes/ChooseDkExe.gd" type="Script" id=67] [ext_resource path="res://Scenes/PickSlabWindow.gd" type="Script" id=68] @@ -375,9 +374,6 @@ script = ExtResource( 158 ) [node name="PlaceThingWithSlab" type="Node" parent="SlabPlacement"] script = ExtResource( 80 ) -[node name="SlabPalette" type="Node" parent="."] -script = ExtResource( 65 ) - [node name="CurrentMap" type="Node" parent="."] script = ExtResource( 100 ) @@ -5297,7 +5293,7 @@ __meta__ = { margin_top = 191.0 margin_right = 175.0 margin_bottom = 212.0 -text = "Type" +text = "Solidity" [node name="SlabIsSolidOptionButton" type="OptionButton" parent="Ui/UiSystem/AddCustomSlabWindow/MarginContainer/HBoxContainer/VBoxContainer2/PanelContainer/VBoxContainer/GridContainer"] margin_left = 179.0 @@ -5307,9 +5303,9 @@ margin_bottom = 215.0 rect_min_size = Vector2( 150, 0 ) hint_tooltip = "Editor placement rules" size_flags_horizontal = 10 -text = "Block" -items = [ "Floor", null, false, 0, null, "Block", null, false, 1, null ] -selected = 1 +text = "Empty" +items = [ "Empty", null, false, 0, null, "Block", null, false, 1, null ] +selected = 0 [node name="Label7" type="Label" parent="Ui/UiSystem/AddCustomSlabWindow/MarginContainer/HBoxContainer/VBoxContainer2/PanelContainer/VBoxContainer/GridContainer"] margin_top = 222.0 @@ -7104,9 +7100,6 @@ script = SubResource( 20 ) [connection signal="pressed" from="Ui/UiSystem/AddCustomSlabWindow/MarginContainer/HBoxContainer/VBoxContainer2/PanelContainer2/GridContainer/FakeSlabHelpButton" to="Ui/UiSystem/AddCustomSlabWindow" method="_on_FakeSlabHelpButton_pressed"] [connection signal="value_changed" from="Ui/UiSystem/AddCustomSlabWindow/MarginContainer/HBoxContainer/VBoxContainer2/PanelContainer/VBoxContainer/GridContainer/CustomSlabID" to="Ui/UiSystem/AddCustomSlabWindow" method="_on_CustomSlabID_value_changed"] [connection signal="item_selected" from="Ui/UiSystem/AddCustomSlabWindow/MarginContainer/HBoxContainer/VBoxContainer2/PanelContainer/VBoxContainer/GridContainer/SlabWibbleOptionButton" to="Ui/UiSystem/AddCustomSlabWindow" method="_on_SlabWibbleOptionButton_item_selected"] -[connection signal="item_selected" from="Ui/UiSystem/AddCustomSlabWindow/MarginContainer/HBoxContainer/VBoxContainer2/PanelContainer/VBoxContainer/GridContainer/SlabBitmaskOptionButton" to="Ui/UiSystem/AddCustomSlabWindow" method="_on_SlabBitmaskOptionButton_item_selected"] -[connection signal="item_selected" from="Ui/UiSystem/AddCustomSlabWindow/MarginContainer/HBoxContainer/VBoxContainer2/PanelContainer/VBoxContainer/GridContainer/SlabIsSolidOptionButton" to="Ui/UiSystem/AddCustomSlabWindow" method="_on_SlabIsSolidOptionButton_item_selected"] -[connection signal="item_selected" from="Ui/UiSystem/AddCustomSlabWindow/MarginContainer/HBoxContainer/VBoxContainer2/PanelContainer/VBoxContainer/GridContainer/SlabOwnableOptionButton" to="Ui/UiSystem/AddCustomSlabWindow" method="_on_SlabOwnableOptionButton_item_selected"] [connection signal="pressed" from="Ui/UiSystem/AddCustomSlabWindow/MarginContainer/HBoxContainer/VBoxContainer2/PanelContainer3/AddCustomSlabButton" to="Ui/UiSystem/AddCustomSlabWindow" method="_on_AddCustomSlabButton_pressed"] [connection signal="pressed" from="Ui/UiSystem/AddCustomSlabWindow/MarginContainer/HBoxContainer/VBoxContainer2/PanelContainer3/HelpCustomSlabsButton" to="Ui/UiSystem/AddCustomSlabWindow" method="_on_HelpCustomSlabsButton_pressed"] [connection signal="visibility_changed" from="Ui/UiSystem/SlabsetWindow" to="Ui/UiSystem/SlabsetWindow" method="_on_SlabsetWindow_visibility_changed"] diff --git a/Scenes/OpenMap.gd b/Scenes/OpenMap.gd index 65b454b9..a45e4fd8 100644 --- a/Scenes/OpenMap.gd +++ b/Scenes/OpenMap.gd @@ -11,7 +11,6 @@ onready var oGame = Nodelist.list["oGame"] onready var oOverheadOwnership = Nodelist.list["oOverheadOwnership"] onready var oDataLevelStyle = Nodelist.list["oDataLevelStyle"] onready var oCamera2D = Nodelist.list["oCamera2D"] -onready var oSlabPalette = Nodelist.list["oSlabPalette"] onready var oDataClm = Nodelist.list["oDataClm"] onready var oTextureCache = Nodelist.list["oTextureCache"] onready var oUiTools = Nodelist.list["oUiTools"] @@ -206,7 +205,8 @@ func finish_opening_map(map): oScriptHelpers.start() oCamera2D.reset_camera(M.xSize, M.ySize) - oSlabPalette.start() + if Slabset.dat.empty() == true: Slabset.load_default_slabset() + if Columnset.cubes.empty() == true: Columnset.load_default_columnset() oOverheadGraphics.update_map_overhead_2d_textures() oPickSlabWindow.add_slabs() diff --git a/Scenes/OwnedColumns.gd b/Scenes/OwnedColumns.gd index 9081bb7e..130cdb56 100644 --- a/Scenes/OwnedColumns.gd +++ b/Scenes/OwnedColumns.gd @@ -1,6 +1,5 @@ extends Node onready var oDataClm = Nodelist.list["oDataClm"] -onready var oSlabPalette = Nodelist.list["oSlabPalette"] #enum { # COLUMN_FLOOR_MARKER = 0 diff --git a/Scenes/PickSlabWindow.gd b/Scenes/PickSlabWindow.gd index 92685179..ac869cca 100644 --- a/Scenes/PickSlabWindow.gd +++ b/Scenes/PickSlabWindow.gd @@ -5,7 +5,6 @@ onready var oSlabTabs = Nodelist.list["oSlabTabs"] onready var oDataClm = Nodelist.list["oDataClm"] onready var oTextureCache = Nodelist.list["oTextureCache"] onready var oGridFunctions = Nodelist.list["oGridFunctions"] -onready var oSlabPalette = Nodelist.list["oSlabPalette"] onready var oSlabStyle = Nodelist.list["oSlabStyle"] onready var oPlacingSettings = Nodelist.list["oPlacingSettings"] onready var oOnlyOwnership = Nodelist.list["oOnlyOwnership"] diff --git a/Scenes/SlabPalette.gd b/Scenes/SlabPalette.gd index c2cb4acd..45dbfeb2 100644 --- a/Scenes/SlabPalette.gd +++ b/Scenes/SlabPalette.gd @@ -1,9 +1,8 @@ extends Node -func start(): +#func start(): # Do this only once. - if Slabset.dat.empty() == true: Slabset.load_default_slabset() - if Columnset.cubes.empty() == true: Columnset.load_default_columnset() + #func test_write_to_file(data): # print('WRITING TO CLM.TXT') diff --git a/Scenes/SlabPlacement.gd b/Scenes/SlabPlacement.gd index c8308702..80dabe43 100644 --- a/Scenes/SlabPlacement.gd +++ b/Scenes/SlabPlacement.gd @@ -3,7 +3,6 @@ onready var oReadData = Nodelist.list["oReadData"] onready var oDataSlab = Nodelist.list["oDataSlab"] onready var oDataClm = Nodelist.list["oDataClm"] onready var oDataClmPos = Nodelist.list["oDataClmPos"] -onready var oSlabPalette = Nodelist.list["oSlabPalette"] onready var oOverheadGraphics = Nodelist.list["oOverheadGraphics"] onready var oDataOwnership = Nodelist.list["oDataOwnership"] onready var oOverheadOwnership = Nodelist.list["oOverheadOwnership"] diff --git a/Scenes/SlabsetWindow.gd b/Scenes/SlabsetWindow.gd index 8537e450..fc76a14b 100644 --- a/Scenes/SlabsetWindow.gd +++ b/Scenes/SlabsetWindow.gd @@ -7,7 +7,6 @@ onready var oSlabsetIDSpinBox = Nodelist.list["oSlabsetIDSpinBox"] onready var oSlabsetIDLabel = Nodelist.list["oSlabsetIDLabel"] onready var oGridContainerDynamicColumns3x3 = Nodelist.list["oGridContainerDynamicColumns3x3"] onready var oVariationNumberSpinBox = Nodelist.list["oVariationNumberSpinBox"] -onready var oSlabPalette = Nodelist.list["oSlabPalette"] onready var oMessage = Nodelist.list["oMessage"] onready var oExportSlabsetDatDialog = Nodelist.list["oExportSlabsetDatDialog"] onready var oGame = Nodelist.list["oGame"]