Skip to content

Commit

Permalink
Fixed ownership drop-down (inspector) list incorrectly containing ext…
Browse files Browse the repository at this point in the history
…ra players in Classic Format
  • Loading branch information
rainlizard committed May 8, 2024
1 parent 04be7e0 commit 49a5de5
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 18 deletions.
4 changes: 4 additions & 0 deletions Autoload/Constants.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ enum {
WRITE = 1
}

const ClassicFormat = 0
const KfxFormat = 1


const TEXTURE_MAP_NAMES = {
0: "Standard",
1: "Ancient",
Expand Down
4 changes: 2 additions & 2 deletions Scenes/Buffers.gd
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ func get_buffer_for_extension(EXT, filePath):
"UNE": return oWriteData.write_une()

func should_process_file_type(EXT):
if oCurrentFormat.selected == 0: # Classic format
if oCurrentFormat.selected == Constants.ClassicFormat:
if ["LOF", "TNGFX", "APTFX", "LGTFX"].has(EXT):
return false
elif oCurrentFormat.selected == 1: # KFX format
elif oCurrentFormat.selected == Constants.KfxFormat:
if ["LIF", "TNG", "APT", "LGT"].has(EXT):
return false
return true
Expand Down
2 changes: 1 addition & 1 deletion Scenes/Instances.gd
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func spawn_attached(xSlab, ySlab, slabID, ownership, subtile, tngObj): # Spawns
2: id.subtype = 121 # Green
3: id.subtype = 122 # Yellow
4:
if oCurrentFormat.selected == 0: # Classic
if oCurrentFormat.selected == Constants.ClassicFormat:
kill_instance(id) # White
else:
id.subtype = 162 # White
Expand Down
2 changes: 1 addition & 1 deletion Scenes/Menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func _on_MenuButtonSettings_pressed():


func _on_PlayButton_pressed(): # Use normal Button instead of MenuButton in combination with OS.execute otherwise a Godot bug occurs
if oCurrentFormat.selected == 1: # KFX Format
if oCurrentFormat.selected == Constants.KfxFormat:
if oGame.running_keeperfx() == false:
oMessage.big("Incompatible", "Your map format is set to KFX format, but your game executable is not set to keeperfx.exe")
return
Expand Down
2 changes: 1 addition & 1 deletion Scenes/OnlyOwnership.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func update_grid_items():
i.free()

var owner_order
if oCurrentFormat.selected == 0: # Classic format
if oCurrentFormat.selected == Constants.ClassicFormat:
owner_order = [0,1,2,3,4,5]
else:
owner_order = [0,1,2,3,6,7,8,4,5]
Expand Down
2 changes: 1 addition & 1 deletion Scenes/OwnerSelection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func update_ownership_head_icons():
var iconSize
var owner_order
var setMargin
if oCurrentFormat.selected == 0: # Classic format
if oCurrentFormat.selected == Constants.ClassicFormat:
owner_order = [0,1,2,3,4,5]
oOwnershipGridContainer.columns = 6
#oOwnershipGridContainer.set("custom_constants/hseparation", 4)
Expand Down
2 changes: 1 addition & 1 deletion Scenes/ResizeCurrentMapSize.gd
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ onready var oDataSlab = Nodelist.list["oDataSlab"]

# The main function that calls all the helper functions
func _on_ResizeApplyButton_pressed():
if oCurrentFormat.selected == 0: # Classic format
if oCurrentFormat.selected == Constants.ClassicFormat:
oMessage.big("Error", "Cannot resize your map, because is in Classic format. Switch to KFX format first.")
return

Expand Down
4 changes: 2 additions & 2 deletions Scenes/SaveMap.gd
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ func delete_existing_files(map):
fileTypesToDelete = oBuffers.FILE_TYPES
else:
# If switching formats, then it's important to delete files of the other format (TNG and TNGFX shouldn't exist at the same time)
if oCurrentFormat.selected == 0: # Classic format
if oCurrentFormat.selected == Constants.ClassicFormat:
# Do not delete LOF because Classic format can be used with LOF multiplayer levels
fileTypesToDelete = ["TNGFX", "APTFX", "LGTFX"]
elif oCurrentFormat.selected == 1: # KFX format
elif oCurrentFormat.selected == Constants.KfxFormat:
fileTypesToDelete = ["LIF", "TNG", "APT", "LGT"]

var baseDirectory = map.get_base_dir()
Expand Down
2 changes: 1 addition & 1 deletion Scenes/ScriptGenerator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func _ready():
# Utils.popup_centered(Nodelist.list["oMapSettingsWindow"])

func update_options_based_on_mapformat():
if oCurrentFormat.selected == 0: # classic format
if oCurrentFormat.selected == Constants.ClassicFormat:
oPurpleAICheckBox.visible = false
oBlackAICheckBox.visible = false
oOrangeAICheckBox.visible = false
Expand Down
10 changes: 5 additions & 5 deletions Scenes/ThingDetails.gd
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,23 @@ func thing_details(id):
11:
description = "Health %"
value = id.creatureInitialHealth
if oCurrentFormat.selected == 0: value = null # Classic format
if oCurrentFormat.selected == Constants.ClassicFormat: value = null
12:
description = "Gold held"
value = id.creatureGold
if oCurrentFormat.selected == 0: value = null # Classic format
if oCurrentFormat.selected == Constants.ClassicFormat: value = null
13:
description = "Name" # Creature name
value = id.creatureName
if oCurrentFormat.selected == 0: value = null # Classic format
if oCurrentFormat.selected == Constants.ClassicFormat: value = null
14:
description = "Gold value"
value = id.goldValue
if oCurrentFormat.selected == 0: value = null # Classic format
if oCurrentFormat.selected == Constants.ClassicFormat: value = null
15:
description = "Orientation"
value = id.orientation
if oCurrentFormat.selected == 0: value = null # Classic format
if oCurrentFormat.selected == Constants.ClassicFormat: value = null

if value != null:
oThingListData.add_item(description, str(value))
Expand Down
8 changes: 5 additions & 3 deletions Scenes/TwoColumnData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ onready var oMirrorOptions = Nodelist.list["oMirrorOptions"]
onready var oMirrorPlacementCheckBox = Nodelist.list["oMirrorPlacementCheckBox"]
onready var oInstances = Nodelist.list["oInstances"]
onready var oMessage = Nodelist.list["oMessage"]
onready var oCurrentFormat = Nodelist.list["oCurrentFormat"]


const columnLeftSize = 120
Expand Down Expand Up @@ -53,9 +54,10 @@ func add_item(leftString, rightString):
nodeRightColumn.add_item("Yellow")
nodeRightColumn.add_item("White")
nodeRightColumn.add_item("None")
nodeRightColumn.add_item("Purple")
nodeRightColumn.add_item("Black")
nodeRightColumn.add_item("Orange")
if oCurrentFormat.selected == Constants.KfxFormat:
nodeRightColumn.add_item("Purple")
nodeRightColumn.add_item("Black")
nodeRightColumn.add_item("Orange")

# print(nodeRightColumn.get_popup().mouse_filter)

Expand Down

0 comments on commit 49a5de5

Please sign in to comment.