diff --git a/.gitignore b/.gitignore index 5088a2e4..63d8ad9f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,12 @@ settings.cfg unearthcustomslabs.cfg -unearthdata/tmapa0* +custom_slabs.cfg + +custom_objects.cfg +unearthdata/tmapa0* +textures ### Godot ### .import/ diff --git a/AutoLoad/Settings.gd b/AutoLoad/Settings.gd index 19a977bd..4eac58e7 100644 --- a/AutoLoad/Settings.gd +++ b/AutoLoad/Settings.gd @@ -15,12 +15,12 @@ var config = ConfigFile.new() var listOfSettings = [ "REMEMBER_TMAPA_PATHS", - "custom_objects", "executable_path", "save_path", "file_viewer_window_size", "file_viewer_window_position", "vsync", + "framerate_limit", "always_decompress", "msaa", "dk_commands", @@ -145,10 +145,6 @@ func game_setting(doWhat,string,value): var oTextureCache = $'../Main/TextureCache' if doWhat == SET: oTextureCache.LOAD_TMAPA_PATHS_FROM_SETTINGS(value) if doWhat == GET: return oTextureCache.REMEMBER_TMAPA_PATHS - "custom_objects": - var oCustomData = $'../Main/CustomData' - if doWhat == SET: oCustomData.load_custom_objects(value) - if doWhat == GET: return oCustomData.CUSTOM_OBJECTS "executable_path": var oGame = $'../Main/Game' if doWhat == SET: oGame.set_paths(value) @@ -168,6 +164,9 @@ func game_setting(doWhat,string,value): "vsync": if doWhat == SET: OS.vsync_enabled = value if doWhat == GET: return OS.vsync_enabled + "framerate_limit": + if doWhat == SET: Engine.target_fps = value + if doWhat == GET: return Engine.target_fps "always_decompress": var oOpenMap = $'../Main/OpenMap' if doWhat == SET: oOpenMap.ALWAYS_DECOMPRESS = value diff --git a/AutoLoad/Things.gd b/AutoLoad/Things.gd index db0286d9..54790b16 100644 --- a/AutoLoad/Things.gd +++ b/AutoLoad/Things.gd @@ -235,25 +235,46 @@ var DATA_OBJECT = { 136 : ["Gold Bag (100)", preload("res://dk_images/valuables/gold_sack_tp/r1frame01.png"), null, TAB_GOLD], } -enum { - SPELLBOOK_HAND = 11 - SPELLBOOK_SLAP = 14 - SPELLBOOK_POSSESS = 135 - SPELLBOOK_IMP = 12 - SPELLBOOK_SIGHT = 15 - SPELLBOOK_SPEED = 21 - SPELLBOOK_OBEY = 13 - SPELLBOOK_CALL_TO_ARMS = 16 - SPELLBOOK_CONCEAL = 23 - SPELLBOOK_HOLD_AUDIENCE = 19 - SPELLBOOK_CAVE_IN = 17 - SPELLBOOK_HEAL_CREATURE = 18 - SPELLBOOK_LIGHTNING = 20 - SPELLBOOK_PROTECT = 22 - SPELLBOOK_CHICKEN = 46 - SPELLBOOK_DISEASE = 45 - SPELLBOOK_ARMAGEDDON = 134 - SPELLBOOK_DESTROY_WALLS = 47 +var LIST_OF_SPELLBOOKS = [ +SPELLBOOK.HAND, +SPELLBOOK.SLAP, +SPELLBOOK.POSSESS, +SPELLBOOK.IMP, +SPELLBOOK.SIGHT, +SPELLBOOK.SPEED, +SPELLBOOK.OBEY, +SPELLBOOK.CALL_TO_ARMS, +SPELLBOOK.CONCEAL, +SPELLBOOK.HOLD_AUDIENCE, +SPELLBOOK.CAVE_IN, +SPELLBOOK.HEAL_CREATURE, +SPELLBOOK.LIGHTNING, +SPELLBOOK.PROTECT, +SPELLBOOK.CHICKEN, +SPELLBOOK.DISEASE, +SPELLBOOK.ARMAGEDDON, +SPELLBOOK.DESTROY_WALLS, +] + +enum SPELLBOOK { + HAND = 11 + SLAP = 14 + POSSESS = 135 + IMP = 12 + SIGHT = 15 + SPEED = 21 + OBEY = 13 + CALL_TO_ARMS = 16 + CONCEAL = 23 + HOLD_AUDIENCE = 19 + CAVE_IN = 17 + HEAL_CREATURE = 18 + LIGHTNING = 20 + PROTECT = 22 + CHICKEN = 46 + DISEASE = 45 + ARMAGEDDON = 134 + DESTROY_WALLS = 47 } # diff --git a/Scenes/AddCustomObjectWindow.gd b/Scenes/AddCustomObjectWindow.gd index 4d96ae1a..4a0609d2 100644 --- a/Scenes/AddCustomObjectWindow.gd +++ b/Scenes/AddCustomObjectWindow.gd @@ -7,7 +7,7 @@ onready var oNewObjectType = Nodelist.list["oNewObjectType"] onready var oMessage = Nodelist.list["oMessage"] onready var oSelector = Nodelist.list["oSelector"] onready var oThingTabs = Nodelist.list["oThingTabs"] -onready var oCustomData = Nodelist.list["oCustomData"] +onready var oCustomObjectSystem = Nodelist.list["oCustomObjectSystem"] onready var oWarningIdInUse = Nodelist.list["oWarningIdInUse"] var tab = Things.TAB_CREATURE @@ -24,10 +24,7 @@ func _process(delta): if visible == false: return var value = int(oNewObjectSubtypeID.text) - if value <= thing_list_size(get_thingType()): - oWarningIdInUse.visible = true - else: - oWarningIdInUse.visible = false + oWarningIdInUse.visible = thinglist_has_subtype(get_thingType(), value) func _on_AddCustomObjectButton_pressed(): var givenName = oNewObjectName.text @@ -41,18 +38,14 @@ func _on_AddCustomObjectButton_pressed(): var tabToPlaceIn = oNewObjectTab.get_item_metadata(oNewObjectTab.selected) - var array = [ + oCustomObjectSystem.add_object([ + get_thingType(), # thingType + int(oNewObjectSubtypeID.text), # subtype givenName, # Name - null, # Image - null, # Portrait + "", # Image + "", # Portrait tabToPlaceIn, - ] - - var subtype = int(oNewObjectSubtypeID.text) - - var thingType = get_thingType() - - oCustomData.add_object(thingType, subtype, array) + ]) # Close window visible = false @@ -75,6 +68,21 @@ func _on_NewObjectSubtypeID_focus_exited(): oNewObjectSubtypeID.text = str(value) + +func _on_NewObjectType_item_selected(index): + auto_fill_subtype_field() + + +func _on_AddCustomObjectWindow_visibility_changed(): + if visible == true: + auto_fill_subtype_field() + +func auto_fill_subtype_field(): + var theNextEmptySubtypeID = get_empty_entry_thinglist(get_thingType()) + oNewObjectSubtypeID.text = str(theNextEmptySubtypeID) + + + func get_thingType(): match oNewObjectType.selected: 0: return Things.TYPE.OBJECT @@ -83,22 +91,29 @@ func get_thingType(): 3: return Things.TYPE.TRAP 4: return Things.TYPE.DOOR -func thing_list_size(type): - match type: - Things.TYPE.OBJECT: return Things.DATA_OBJECT.size() - Things.TYPE.CREATURE: return Things.DATA_CREATURE.size() - Things.TYPE.EFFECT: return Things.DATA_EFFECT.size() - Things.TYPE.TRAP: return Things.DATA_TRAP.size() - Things.TYPE.DOOR: return Things.DATA_DOOR.size() - Things.TYPE.EXTRA: return Things.DATA_EXTRA.size() - -func _on_NewObjectType_item_selected(index): - autoFillSubtypeField() - -func autoFillSubtypeField(): - var theNextEmptySubtypeID = thing_list_size(get_thingType()) + 1 - oNewObjectSubtypeID.text = str(theNextEmptySubtypeID) +func thinglist_has_subtype(thingType, subtype): + if subtype == 0: return true # Don't allow 0 to be recognized as empty + + match thingType: + Things.TYPE.OBJECT: return Things.DATA_OBJECT.has(subtype) + Things.TYPE.CREATURE: return Things.DATA_CREATURE.has(subtype) + Things.TYPE.EFFECT: return Things.DATA_EFFECT.has(subtype) + Things.TYPE.TRAP: return Things.DATA_TRAP.has(subtype) + Things.TYPE.DOOR: return Things.DATA_DOOR.has(subtype) + Things.TYPE.EXTRA: return Things.DATA_EXTRA.has(subtype) -func _on_AddCustomObjectWindow_visibility_changed(): - if visible == true: - autoFillSubtypeField() +func get_empty_entry_thinglist(thingType): + var db + match thingType: + Things.TYPE.OBJECT: db = Things.DATA_OBJECT + Things.TYPE.CREATURE: db = Things.DATA_CREATURE + Things.TYPE.EFFECT: db = Things.DATA_EFFECT + Things.TYPE.TRAP: db = Things.DATA_TRAP + Things.TYPE.DOOR: db = Things.DATA_DOOR + Things.TYPE.EXTRA: db = Things.DATA_EXTRA + + var i = 1 # These arrays don't start at 0 + while true: + if db.has(i) == false: + return i + i += 1 diff --git a/Scenes/Camera2D.gd b/Scenes/Camera2D.gd index 2bd64ace..c2377db6 100644 --- a/Scenes/Camera2D.gd +++ b/Scenes/Camera2D.gd @@ -32,6 +32,7 @@ func reset_camera(): desired_zoom = zoom func _process(delta): + if OS.is_window_focused() == false: return if current == false: return #View is 3D if zoom != desired_zoom: @@ -40,20 +41,15 @@ func _process(delta): desired_offset += panDirectionMouse * DIRECTIONAL_PAN_SPEED * (zoom/Settings.UI_SCALE.x) * delta desired_offset += panDirectionKeyboard * DIRECTIONAL_PAN_SPEED * (zoom/Settings.UI_SCALE.x) * delta - var fieldSize = Vector2(32*255,32*255) - var halfViewSize = ((get_viewport().size/Settings.UI_SCALE) * 0.5) * desired_zoom - # The point of this is just so you can't move the map COMPLETELY off the screen var allowLittleExtraVisible = halfViewSize * 0.10 - desired_offset.x = clamp(desired_offset.x, -(halfViewSize.x-allowLittleExtraVisible.x), fieldSize.x+(halfViewSize.x-allowLittleExtraVisible.x)) desired_offset.y = clamp(desired_offset.y, -(halfViewSize.y-allowLittleExtraVisible.y), fieldSize.y+(halfViewSize.y-allowLittleExtraVisible.y)) offset = lerp(offset, desired_offset, clamp(SMOOTHING_RATE * delta, 0.0, 1.0)) - if OS.is_window_focused() == true: if MOUSE_EDGE_PANNING == true and oUi.mouseOnUi == false and mouseIsMoving == true and middleMousePanning == false: mouse_edge_pan() @@ -66,6 +62,15 @@ func _process(delta): keyboard_pan() else: panDirectionKeyboard = Vector2(0,0) + + # Close enough + if (offset-desired_offset).abs() < Vector2(0.0001,0.0001): + offset = desired_offset + if (zoom-desired_zoom).abs() < Vector2(0.0001,0.0001): + zoom = desired_zoom + +# print('offset : ' + str((offset-desired_offset).abs())) +# print('zoom : ' + str((zoom-desired_zoom).abs())) func _unhandled_input(event): if oSettingsWindow.visible == true: return diff --git a/Scenes/CustomObjectSystem.gd b/Scenes/CustomObjectSystem.gd new file mode 100644 index 00000000..be42d28d --- /dev/null +++ b/Scenes/CustomObjectSystem.gd @@ -0,0 +1,71 @@ +extends Node +onready var oPickThingWindow = Nodelist.list["oPickThingWindow"] + +var objectsFile = ConfigFile.new() + +func _init(): + load_file() + +func add_object(array): + print("Objected added: " + str(array)) + var section = 'OBJECT:' + str(array[0]) + ':' + str(array[1]) + objectsFile.set_value(section,"NAME", array[2]) + objectsFile.set_value(section,"IMAGE", array[3]) + objectsFile.set_value(section,"PORTRAIT", array[4]) + objectsFile.set_value(section,"TAB", array[5]) + + objectsFile.save(Settings.unearthdata.plus_file("custom_objects.cfg")) + load_file() + oPickThingWindow.initialize_thing_grid_items() + +func load_file(): + objectsFile.load(Settings.unearthdata.plus_file("custom_objects.cfg")) + + for sectionName in objectsFile.get_sections(): + var sectionNameArray = sectionName.split(":") + var objThingType = int(sectionNameArray[1]) + var objSubtype = int(sectionNameArray[2]) + + var objName = objectsFile.get_value(sectionName, "NAME", "") + var objImage = objectsFile.get_value(sectionName, "IMAGE", "") + var objPortrait = objectsFile.get_value(sectionName, "PORTRAIT", "") + var objTab = objectsFile.get_value(sectionName, "TAB", 0) + if objImage == "": objImage = null # This is to prevent an annoying line in the Debugger + if objPortrait == "": objPortrait = null + + var constructArray = [ + objName, + objImage, + objPortrait, + objTab, + ] + match objThingType: + Things.TYPE.OBJECT: Things.DATA_OBJECT[objSubtype] = constructArray + Things.TYPE.CREATURE: Things.DATA_CREATURE[objSubtype] = constructArray + Things.TYPE.EFFECT: Things.DATA_EFFECT[objSubtype] = constructArray + Things.TYPE.TRAP: Things.DATA_TRAP[objSubtype] = constructArray + Things.TYPE.DOOR: Things.DATA_DOOR[objSubtype] = constructArray + + #print(Things.DATA_OBJECT[objSubtype]) + + print('Custom objects loaded into memory') + +func remove_object(thingType, subtype): + oPickThingWindow.set_selection(null, null) + print('Attempting to remove thingType:' + str(thingType) + ', subtype:'+str(subtype)) + + var section = 'OBJECT:'+str(thingType)+':'+str(subtype) + if objectsFile.has_section(section): + objectsFile.erase_section(section) + print('Removed custom object type: '+str(thingType) + ' subtype: '+ str(subtype)) + + match thingType: + Things.TYPE.OBJECT: Things.DATA_OBJECT.erase(subtype) + Things.TYPE.CREATURE: Things.DATA_CREATURE.erase(subtype) + Things.TYPE.EFFECT: Things.DATA_EFFECT.erase(subtype) + Things.TYPE.TRAP: Things.DATA_TRAP.erase(subtype) + Things.TYPE.DOOR: Things.DATA_DOOR.erase(subtype) + + objectsFile.save(Settings.unearthdata.plus_file("custom_objects.cfg")) + load_file() + oPickThingWindow.initialize_thing_grid_items() diff --git a/Scenes/CustomSlabData.gd b/Scenes/CustomSlabSystem.gd similarity index 100% rename from Scenes/CustomSlabData.gd rename to Scenes/CustomSlabSystem.gd diff --git a/Scenes/CustomStuff.gd b/Scenes/CustomStuff.gd deleted file mode 100644 index 4ffa4a91..00000000 --- a/Scenes/CustomStuff.gd +++ /dev/null @@ -1,51 +0,0 @@ -extends Node -onready var oPickThingWindow = Nodelist.list["oPickThingWindow"] - -var CUSTOM_OBJECTS = {} - -func load_custom_objects(NEW_CUSTOM_OBJECTS): - - CUSTOM_OBJECTS = NEW_CUSTOM_OBJECTS - - for thingType in CUSTOM_OBJECTS: - for subtype in CUSTOM_OBJECTS[thingType]: - var array = CUSTOM_OBJECTS[thingType][subtype] - - match thingType: - Things.TYPE.OBJECT: Things.DATA_OBJECT[subtype] = array - Things.TYPE.CREATURE: Things.DATA_CREATURE[subtype] = array - Things.TYPE.EFFECT: Things.DATA_EFFECT[subtype] = array - Things.TYPE.TRAP: Things.DATA_TRAP[subtype] = array - Things.TYPE.DOOR: Things.DATA_DOOR[subtype] = array - print('Custom objects loaded into memory') - - -func add_object(thingType, subtype, array): - # Initialize a new dictionary for subtypes if thingType hasn't been added before. - if CUSTOM_OBJECTS.has(thingType) == false: - CUSTOM_OBJECTS[thingType] = {} - - CUSTOM_OBJECTS[thingType][subtype] = array - - Settings.set_setting("custom_objects", CUSTOM_OBJECTS) - oPickThingWindow.initialize_thing_grid_items() - -func remove_object(thingType, subtype): - oPickThingWindow.set_selection(null, null) - print('Attempting to remove thingType:' + str(thingType) + ', subtype:'+str(subtype)) - - if CUSTOM_OBJECTS.has(thingType) and CUSTOM_OBJECTS[thingType].has(subtype): - CUSTOM_OBJECTS[thingType].erase(subtype) - - match thingType: - Things.TYPE.OBJECT: Things.DATA_OBJECT.erase(subtype) - Things.TYPE.CREATURE: Things.DATA_CREATURE.erase(subtype) - Things.TYPE.EFFECT: Things.DATA_EFFECT.erase(subtype) - Things.TYPE.TRAP: Things.DATA_TRAP.erase(subtype) - Things.TYPE.DOOR: Things.DATA_DOOR.erase(subtype) - - Settings.set_setting("custom_objects", CUSTOM_OBJECTS) - oPickThingWindow.initialize_thing_grid_items() - print('Removed custom object type: '+str(thingType) + ' subtype: '+ str(subtype)) - else: - print('Object not found in Custom Objects dictionary') diff --git a/Scenes/Editor.gd b/Scenes/Editor.gd index a8ebdb97..843ec02b 100644 --- a/Scenes/Editor.gd +++ b/Scenes/Editor.gd @@ -65,6 +65,10 @@ func _notification(what): Utils.popup_centered(oConfirmQuit) else: get_tree().quit() +# elif what == MainLoop.NOTIFICATION_WM_FOCUS_IN: +# Engine.target_fps = 0 +# elif what == MainLoop.NOTIFICATION_WM_FOCUS_OUT: +# Engine.target_fps = 12 func just_opened_editor(): yield(get_tree(),'idle_frame') diff --git a/Scenes/Instances.gd b/Scenes/Instances.gd index 7c374ded..84553fe0 100644 --- a/Scenes/Instances.gd +++ b/Scenes/Instances.gd @@ -200,13 +200,21 @@ func delete_all_objects_on_slab(xSlab, ySlab): if id.locationX >= xSlab*3 and id.locationX < (xSlab+1) * 3 and id.locationY >= ySlab*3 and id.locationY < (ySlab+1) * 3: id.queue_free() -func get_node_of_group_on_subtile(nodegroup, xSubtile, ySubtile): +func get_node_on_subtile(nodegroup, xSubtile, ySubtile): for id in get_tree().get_nodes_in_group(nodegroup): if id.is_queued_for_deletion() == false: if id.locationX >= floor(xSubtile) and id.locationX < floor(xSubtile)+1 and id.locationY >= floor(ySubtile) and id.locationY < floor(ySubtile)+1: return id return null +#func get_all_on_slab(nodegroup, xSlab, ySlab): +# var array = [] +# for id in get_tree().get_nodes_in_group(nodegroup): +# if id.is_queued_for_deletion() == false: +# if id.locationX >= xSlab*3 and id.locationX < (xSlab+1) * 3 and id.locationY >= ySlab*3 and id.locationY < (ySlab+1) * 3: +# array.append(id) +# return array + #func delete_objects_on_subtile(xSubtile,ySubtile): # for id in get_tree().get_nodes_in_group("Thing"): # if id.locationX >= floor(xSubtile) and id.locationX < ceil(xSubtile) and id.locationY >= floor(ySubtile) and id.locationY < ceil(ySubtile): diff --git a/Scenes/Main.tscn b/Scenes/Main.tscn index fcf2120f..9510c091 100644 --- a/Scenes/Main.tscn +++ b/Scenes/Main.tscn @@ -91,7 +91,7 @@ [ext_resource path="res://Scenes/LineEditFloat.gd" type="Script" id=89] [ext_resource path="res://Scenes/SlabNameDisplay.gd" type="Script" id=90] [ext_resource path="res://Scenes/AddCustomObjectWindow.gd" type="Script" id=91] -[ext_resource path="res://Scenes/CustomStuff.gd" type="Script" id=92] +[ext_resource path="res://Scenes/CustomObjectSystem.gd" type="Script" id=92] [ext_resource path="res://Scenes/SlabOwnerCheckBox.gd" type="Script" id=93] [ext_resource path="res://Scenes/Inspector.gd" type="Script" id=94] [ext_resource path="res://Shaders/cursorMat.tres" type="Material" id=95] @@ -126,7 +126,7 @@ [ext_resource path="res://Scenes/ScriptEditor.gd" type="Script" id=124] [ext_resource path="res://Scenes/ScriptWindow.gd" type="Script" id=125] [ext_resource path="res://Scenes/TextureEditingWindow.gd" type="Script" id=126] -[ext_resource path="res://Scenes/CustomSlabData.gd" type="Script" id=127] +[ext_resource path="res://Scenes/CustomSlabSystem.gd" type="Script" id=127] [ext_resource path="res://Scenes/TabColumnVoxels.gd" type="Script" id=128] [ext_resource path="res://Scenes/CustomTooltip.gd" type="Script" id=129] [ext_resource path="res://Theme/StyleBoxThinnerPanel.tres" type="StyleBox" id=130] @@ -386,10 +386,10 @@ script = ExtResource( 32 ) [node name="DeleteMap" type="Node" parent="."] script = ExtResource( 36 ) -[node name="CustomData" type="Node" parent="."] +[node name="CustomObjectSystem" type="Node" parent="."] script = ExtResource( 92 ) -[node name="CustomSlabSystem" type="Node" parent="CustomData"] +[node name="CustomSlabSystem" type="Node" parent="."] script = ExtResource( 127 ) [node name="Game3D" type="Spatial" parent="."] @@ -2139,6 +2139,13 @@ margin_right = 577.0 margin_bottom = 60.0 text = "Vsync" +[node name="FramerateLimit" parent="Ui/UiSystem/SettingsWindow/VBoxContainer/TabSettings/TabGraphics/VBoxContainer" instance=ExtResource( 16 )] +margin_left = -0.793701 +margin_top = 31.0 +margin_right = 46.2063 +margin_bottom = 31.0 +settingText = "Framerate limit" + [node name="CheckBoxDisplayFPS" type="CheckBox" parent="Ui/UiSystem/SettingsWindow/VBoxContainer/TabSettings/TabGraphics/VBoxContainer"] margin_top = 64.0 margin_right = 577.0 diff --git a/Scenes/OverheadOwnership.gd b/Scenes/OverheadOwnership.gd index be87b7f7..09c9334f 100644 --- a/Scenes/OverheadOwnership.gd +++ b/Scenes/OverheadOwnership.gd @@ -4,6 +4,7 @@ onready var oSelector = Nodelist.list["oSelector"] onready var oDataOwnership = Nodelist.list["oDataOwnership"] onready var oColorRectSlabOwner = Nodelist.list["oColorRectSlabOwner"] onready var oInstanceOwnership = Nodelist.list["oInstanceOwnership"] +onready var oInstances = Nodelist.list["oInstances"] onready var oMain = Nodelist.list["oMain"] var OWNERSHIP_ALPHA = 0.5 setget set_ownership_alpha_graphics @@ -65,6 +66,13 @@ func ownership_update_shape(shapePositionArray, ownership): slabOwnershipTexture.set_data(slabOwnershipImage) +func ownership_update_things(shapePositionArray, paintOwnership): + # Change ownership of spellbooks when placing slab ownership (Ownership tab) + for id in get_tree().get_nodes_in_group("Spellbook"): + var slabPos = Vector2(int(id.locationX/3),int(id.locationY/3)) + if slabPos in shapePositionArray: + id.ownership = paintOwnership + #func ownership_update_rect(rectStart, rectEnd, ownership): # rectStart = Vector2(clamp(rectStart.x, 0, 84), clamp(rectStart.y, 0, 84)) # rectEnd = Vector2(clamp(rectEnd.x, 0, 84), clamp(rectEnd.y, 0, 84)) diff --git a/Scenes/PickThingWindow.gd b/Scenes/PickThingWindow.gd index 4e55dc81..119b60c1 100644 --- a/Scenes/PickThingWindow.gd +++ b/Scenes/PickThingWindow.gd @@ -4,7 +4,7 @@ onready var oSelection = Nodelist.list["oSelection"] onready var oThingTabs = Nodelist.list["oThingTabs"] onready var oActionPointOptions = Nodelist.list["oActionPointOptions"] onready var oThingDetails = Nodelist.list["oThingDetails"] -onready var oCustomData = Nodelist.list["oCustomData"] +onready var oCustomObjectSystem = Nodelist.list["oCustomObjectSystem"] onready var oGridFunctions = Nodelist.list["oGridFunctions"] onready var oPropertiesWindow = Nodelist.list["oPropertiesWindow"] onready var oPlacingSettings = Nodelist.list["oPlacingSettings"] @@ -219,4 +219,4 @@ func remove_all_grid_items(): func _on_thing_portrait_gui_input(event, id): if event.is_action_pressed("mouse_right"): oPropertiesWindow.oPropertiesTabs.current_tab = 0 - oCustomData.remove_object(id.get_meta("thingType"), id.get_meta("thingSubtype")) + oCustomObjectSystem.remove_object(id.get_meta("thingType"), id.get_meta("thingSubtype")) diff --git a/Scenes/PlaceThingWithSlab.gd b/Scenes/PlaceThingWithSlab.gd index 5771c358..c130ac26 100644 --- a/Scenes/PlaceThingWithSlab.gd +++ b/Scenes/PlaceThingWithSlab.gd @@ -34,7 +34,7 @@ func place_slab_objects(xSlab, ySlab, slabID, ownership, slabVariation, bitmask, func create_door_thing(xSlab, ySlab, ownership): var createAtPos = Vector3((xSlab*3)+1.5, (ySlab*3)+1.5, 5) - var doorID = oInstances.get_node_of_group_on_subtile("Door", createAtPos.x, createAtPos.y) + var doorID = oInstances.get_node_on_subtile("Door", createAtPos.x, createAtPos.y) if is_instance_valid(doorID) == false: oInstances.place_new_thing(Things.TYPE.DOOR, 0, createAtPos, ownership) #subtype determined in oInstances diff --git a/Scenes/ScriptGenerator.gd b/Scenes/ScriptGenerator.gd index 473bd8bb..b6b32d67 100644 --- a/Scenes/ScriptGenerator.gd +++ b/Scenes/ScriptGenerator.gd @@ -68,24 +68,24 @@ var listCreature = [ #[31, "FLOATING_SPIRIT", 0], var listMagic = [ -[Things.SPELLBOOK_HAND, "POWER_HAND", 1], -[Things.SPELLBOOK_SLAP, "POWER_SLAP", 1], -[Things.SPELLBOOK_POSSESS, "POWER_POSSESS", 1], -[Things.SPELLBOOK_IMP, "POWER_IMP", 1], -[Things.SPELLBOOK_SIGHT, "POWER_SIGHT", 0], -[Things.SPELLBOOK_SPEED, "POWER_SPEED", 0], -[Things.SPELLBOOK_OBEY, "POWER_OBEY", 0], -[Things.SPELLBOOK_CALL_TO_ARMS, "POWER_CALL_TO_ARMS", 0], -[Things.SPELLBOOK_CONCEAL, "POWER_CONCEAL", 0], -[Things.SPELLBOOK_HOLD_AUDIENCE, "POWER_HOLD_AUDIENCE", 0], -[Things.SPELLBOOK_CAVE_IN, "POWER_CAVE_IN", 0], -[Things.SPELLBOOK_HEAL_CREATURE, "POWER_HEAL_CREATURE", 0], -[Things.SPELLBOOK_LIGHTNING, "POWER_LIGHTNING", 0], -[Things.SPELLBOOK_PROTECT, "POWER_PROTECT", 0], -[Things.SPELLBOOK_CHICKEN, "POWER_CHICKEN", 0], -[Things.SPELLBOOK_DISEASE, "POWER_DISEASE", 0], -[Things.SPELLBOOK_ARMAGEDDON, "POWER_ARMAGEDDON", 0], -[Things.SPELLBOOK_DESTROY_WALLS, "POWER_DESTROY_WALLS", 0], +[Things.SPELLBOOK.HAND, "POWER_HAND", 1], +[Things.SPELLBOOK.SLAP, "POWER_SLAP", 1], +[Things.SPELLBOOK.POSSESS, "POWER_POSSESS", 1], +[Things.SPELLBOOK.IMP, "POWER_IMP", 1], +[Things.SPELLBOOK.SIGHT, "POWER_SIGHT", 0], +[Things.SPELLBOOK.SPEED, "POWER_SPEED", 0], +[Things.SPELLBOOK.OBEY, "POWER_OBEY", 0], +[Things.SPELLBOOK.CALL_TO_ARMS, "POWER_CALL_TO_ARMS", 0], +[Things.SPELLBOOK.CONCEAL, "POWER_CONCEAL", 0], +[Things.SPELLBOOK.HOLD_AUDIENCE, "POWER_HOLD_AUDIENCE", 0], +[Things.SPELLBOOK.CAVE_IN, "POWER_CAVE_IN", 0], +[Things.SPELLBOOK.HEAL_CREATURE, "POWER_HEAL_CREATURE", 0], +[Things.SPELLBOOK.LIGHTNING, "POWER_LIGHTNING", 0], +[Things.SPELLBOOK.PROTECT, "POWER_PROTECT", 0], +[Things.SPELLBOOK.CHICKEN, "POWER_CHICKEN", 0], +[Things.SPELLBOOK.DISEASE, "POWER_DISEASE", 0], +[Things.SPELLBOOK.ARMAGEDDON, "POWER_ARMAGEDDON", 0], +[Things.SPELLBOOK.DESTROY_WALLS, "POWER_DESTROY_WALLS", 0], ] var listTrap = [ @@ -123,38 +123,38 @@ enum { IS_ROOM } var listResearchOrder = [ -[IS_MAGIC, Things.SPELLBOOK_HAND , 250], -[IS_MAGIC, Things.SPELLBOOK_SLAP , 500], -[IS_MAGIC, Things.SPELLBOOK_POSSESS , 500], -[IS_MAGIC, Things.SPELLBOOK_IMP , 1000], +[IS_MAGIC, Things.SPELLBOOK.HAND , 250], +[IS_MAGIC, Things.SPELLBOOK.SLAP , 500], +[IS_MAGIC, Things.SPELLBOOK.POSSESS , 500], +[IS_MAGIC, Things.SPELLBOOK.IMP , 1000], [IS_ROOM , Slabs.TREASURE_ROOM , 1000], [IS_ROOM , Slabs.LAIR , 1000], [IS_ROOM , Slabs.HATCHERY , 1000], [IS_ROOM , Slabs.TRAINING_ROOM , 1000], [IS_ROOM , Slabs.LIBRARY , 1000], -[IS_MAGIC, Things.SPELLBOOK_SIGHT , 3800], +[IS_MAGIC, Things.SPELLBOOK.SIGHT , 3800], [IS_ROOM , Slabs.BRIDGE , 4600], -[IS_MAGIC, Things.SPELLBOOK_SPEED , 5700], -[IS_MAGIC, Things.SPELLBOOK_OBEY , 6000], +[IS_MAGIC, Things.SPELLBOOK.SPEED , 5700], +[IS_MAGIC, Things.SPELLBOOK.OBEY , 6000], [IS_ROOM , Slabs.GUARD_POST , 6700], -[IS_MAGIC, Things.SPELLBOOK_CALL_TO_ARMS , 7400], +[IS_MAGIC, Things.SPELLBOOK.CALL_TO_ARMS , 7400], [IS_ROOM , Slabs.WORKSHOP , 9000], -[IS_MAGIC, Things.SPELLBOOK_CONCEAL , 9400], +[IS_MAGIC, Things.SPELLBOOK.CONCEAL , 9400], [IS_ROOM , Slabs.BARRACKS , 12000], -[IS_MAGIC, Things.SPELLBOOK_HOLD_AUDIENCE, 11000], +[IS_MAGIC, Things.SPELLBOOK.HOLD_AUDIENCE, 11000], [IS_ROOM , Slabs.PRISON , 20000], -[IS_MAGIC, Things.SPELLBOOK_CAVE_IN , 25000], +[IS_MAGIC, Things.SPELLBOOK.CAVE_IN , 25000], [IS_ROOM , Slabs.TORTURE_CHAMBER , 20000], -[IS_MAGIC, Things.SPELLBOOK_HEAL_CREATURE, 14000], +[IS_MAGIC, Things.SPELLBOOK.HEAL_CREATURE, 14000], [IS_ROOM , Slabs.TEMPLE , 25000], -[IS_MAGIC, Things.SPELLBOOK_LIGHTNING , 15000], +[IS_MAGIC, Things.SPELLBOOK.LIGHTNING , 15000], [IS_ROOM , Slabs.GRAVEYARD , 25000], -[IS_MAGIC, Things.SPELLBOOK_PROTECT , 15000], +[IS_MAGIC, Things.SPELLBOOK.PROTECT , 15000], [IS_ROOM , Slabs.SCAVENGER_ROOM , 27500], -[IS_MAGIC, Things.SPELLBOOK_CHICKEN , 20000], -[IS_MAGIC, Things.SPELLBOOK_DISEASE , 20000], -[IS_MAGIC, Things.SPELLBOOK_ARMAGEDDON , 100000], -[IS_MAGIC, Things.SPELLBOOK_DESTROY_WALLS, 750000], +[IS_MAGIC, Things.SPELLBOOK.CHICKEN , 20000], +[IS_MAGIC, Things.SPELLBOOK.DISEASE , 20000], +[IS_MAGIC, Things.SPELLBOOK.ARMAGEDDON , 100000], +[IS_MAGIC, Things.SPELLBOOK.DESTROY_WALLS, 750000], ] func _ready(): diff --git a/Scenes/Selection.gd b/Scenes/Selection.gd index 74ea8392..09b1f1f3 100644 --- a/Scenes/Selection.gd +++ b/Scenes/Selection.gd @@ -148,7 +148,8 @@ func place_shape(beginTile,endTile): oDataSlx.set_tileset_shape(shapePositionArray) elif oOnlyOwnership.visible == true: oOverheadOwnership.ownership_update_shape(shapePositionArray, paintOwnership) - oSlabPlacement.generate_slabs_based_on_id(rectStart, rectEnd) + oOverheadOwnership.ownership_update_things(shapePositionArray, paintOwnership) + oSlabPlacement.generate_slabs_based_on_id(rectStart, rectEnd, true) else: # Slab placement var useOwner = paintOwnership diff --git a/Scenes/SettingsWindow.gd b/Scenes/SettingsWindow.gd index 01661b60..af820cd6 100644 --- a/Scenes/SettingsWindow.gd +++ b/Scenes/SettingsWindow.gd @@ -25,6 +25,8 @@ onready var oSciptIconMaxZoom = Nodelist.list["oSciptIconMaxZoom"] onready var oPickSlabWindow = Nodelist.list["oPickSlabWindow"] onready var oPickThingWindow = Nodelist.list["oPickThingWindow"] onready var oUiScale = Nodelist.list["oUiScale"] +onready var oFramerateLimit = Nodelist.list["oFramerateLimit"] + #onready var oTabEditor = Nodelist.list["oTabEditor"] #onready var oTabGraphics = Nodelist.list["oTabGraphics"] @@ -67,6 +69,7 @@ func _on_SettingsWindow_about_to_show(): oSmoothingRate.line.text = str(Settings.get_setting("smoothing_rate")).pad_decimals(2) oMouseSensitivity.line.text = str(Settings.get_setting("mouse_sensitivity")).pad_decimals(2) oFieldOfView.line.text = str(Settings.get_setting("fov")) + oFramerateLimit.line.text = str(Settings.get_setting("framerate_limit")) oCheckBoxDisplay3dInfo.pressed = Settings.get_setting("display_3d_info") oUiScale.line.text = str(Settings.get_setting("ui_scale")).pad_decimals(2) oSlabWindowScale.line.text = str(Settings.get_setting("slab_window_scale")).pad_decimals(2) @@ -127,6 +130,10 @@ func edited_MouseSensitivity(new_text): func edited_FieldOfView(new_text): Settings.set_setting("fov", float(new_text)) +func edited_FramerateLimit(new_text): + oFramerateLimit.line.text = str(int(new_text)) + Settings.set_setting("framerate_limit", int(new_text)) + func edited_UiScale(new_text): Settings.set_setting("ui_scale", float(new_text)) diff --git a/Scenes/ThingInstance.gd b/Scenes/ThingInstance.gd index e30c6944..3183b668 100644 --- a/Scenes/ThingInstance.gd +++ b/Scenes/ThingInstance.gd @@ -51,6 +51,8 @@ func _enter_tree(): Things.TYPE.OBJECT: if subtype == 44: # Spinning Key add_to_group("Key") + if subtype in Things.LIST_OF_SPELLBOOKS: + add_to_group("Spellbook") # if subtype == 49: # var oCamera2D = Nodelist.list["oCamera2D"] # oCamera2D.connect("zoom_level_changed",self,"_on_zoom_level_changed") @@ -190,7 +192,7 @@ func toggle_spinning_key(): # Called when you manually change the lock state # If door has no key, then create a key. # If door has key, then destroy the key. - var keyID = oInstances.get_node_of_group_on_subtile("Key", locationX, locationY) + var keyID = oInstances.get_node_on_subtile("Key", locationX, locationY) if is_instance_valid(keyID) == true: if doorLocked == 0: keyID.queue_free() diff --git a/Shaders/SlabDisplayMat.tres b/Shaders/SlabDisplayMat.tres index 1c0d40c7..8e0a34e9 100644 --- a/Shaders/SlabDisplayMat.tres +++ b/Shaders/SlabDisplayMat.tres @@ -6,7 +6,6 @@ [resource] resource_local_to_scene = true shader = ExtResource( 1 ) -shader_param/useFullSizeMap = true shader_param/showOnlySpecificStyle = 77777777 -shader_param/numberOfTextures = Vector2( 3, 3 ) +shader_param/fieldSizeInSubtiles = Vector2( 255, 255 ) shader_param/animationDatabase = ExtResource( 2 ) diff --git a/Shaders/cursor.shader b/Shaders/cursor.shader index 2f983c10..f171d91c 100644 --- a/Shaders/cursor.shader +++ b/Shaders/cursor.shader @@ -2,12 +2,14 @@ shader_type canvas_item; uniform float zoom = 1.00; +const float animationRate = 0.15; + void fragment() { float textureWidth = float(textureSize(TEXTURE,0).x); float textureHeight = float(textureSize(TEXTURE,0).y); vec2 texel = vec2(1.0/textureWidth, 1.0/textureHeight); - vec4 baseCol = texture(TEXTURE, UV + (TIME*0.15)); + vec4 baseCol = texture(TEXTURE, UV + (TIME*animationRate)); baseCol.a = 0.0;