Skip to content

Commit

Permalink
Fixed the ordering of action points so that it's always in order, Add…
Browse files Browse the repository at this point in the history
…ed Hero Gates to Action Point list
  • Loading branch information
rainlizard committed Apr 9, 2024
1 parent 78723e4 commit e7a14eb
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 14 deletions.
49 changes: 38 additions & 11 deletions Scenes/ActionPointList.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,53 @@ func _ready():

func update_ap_list():
if is_inside_tree() == false: return # Fixes an annoying crash-on-exit.

clear()

var count_ap = 0


var action_points = []
for id in get_tree().get_nodes_in_group("ActionPoint"):
if id.is_queued_for_deletion() == false:
add_item("Action Point " + str(id.pointNumber))
count_ap += 1
action_points.append(id)
action_points.sort_custom(self, "sort_action_points")

var hero_gates = []
for id in get_tree().get_nodes_in_group("Thing"):
if id.is_queued_for_deletion() == false:
if id.is_in_group("HeroGate"):
hero_gates.append(id)
hero_gates.sort_custom(self, "sort_hero_gates")

var lines = clamp(count_ap, 1, lines_to_show)
for id in action_points:
add_item("Action Point " + str(id.pointNumber))
for id in hero_gates:
add_item("Hero Gate " + str(id.herogateNumber))



var lines = clamp(action_points.size(), 1, lines_to_show)
get_parent().get_parent().rect_min_size.y = 9 + (lines * item_height)

yield(get_tree(),'idle_frame')
get_parent().set_deferred("scroll_vertical",1000000)

func sort_action_points(a, b):
return a.pointNumber < b.pointNumber
func sort_hero_gates(a, b):
return a.herogateNumber < b.herogateNumber

func _on_item_selected(idx):
var txt = get_item_text(idx)
txt = txt.replace("Action Point ", "")
for id in get_tree().get_nodes_in_group("ActionPoint"):
if id.pointNumber == int(txt):
oInspector.inspect_something(id)

if txt.begins_with("Action Point "):
txt = txt.replace("Action Point ", "")
for id in get_tree().get_nodes_in_group("ActionPoint"):
if id.pointNumber == int(txt):
oInspector.inspect_something(id)
elif txt.begins_with("Hero Gate "):
txt = txt.replace("Hero Gate ", "")
for id in get_tree().get_nodes_in_group("Thing"):
if id.is_in_group("HeroGate"):
if id.herogateNumber == int(txt):
oInspector.inspect_something(id)

if is_instance_valid(oInspector.inspectingInstance):
oCamera2D.center_camera_on_point(oInspector.inspectingInstance.position)
Expand Down
3 changes: 2 additions & 1 deletion Scenes/Inspector.gd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ func set_inspector_instance(setval):
if is_instance_valid(setval):
setval.instance_was_selected()
oPropertiesWindow.oPropertiesTabs.current_tab = 0
if setval.is_in_group("ActionPoint"):

if setval.is_in_group("ActionPoint") or setval.is_in_group("HeroGate"):
pass
else:
oActionPointList.unselect_all()
Expand Down
4 changes: 2 additions & 2 deletions Scenes/Instances.gd
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ func get_free_index_number():
func get_free_hero_gate_number():
var listOfHeroGateNumbers = []
for id in get_tree().get_nodes_in_group("Thing"):
if id.thingType == Things.TYPE.OBJECT and id.subtype == 49: # Hero gate
if id.is_in_group("HeroGate"):
listOfHeroGateNumbers.append(id.herogateNumber)

var newNumber = 1
Expand Down Expand Up @@ -594,7 +594,7 @@ func return_dungeon_heart(ownership):

func return_hero_gate(number):
for id in get_tree().get_nodes_in_group("Thing"):
if id.thingType == Things.TYPE.OBJECT and id.subtype == 49: # Hero gate
if id.is_in_group("HeroGate"):
if id.herogateNumber == number:
return id
return null
Expand Down
7 changes: 7 additions & 0 deletions Scenes/ThingInstance.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ onready var oInspector = Nodelist.list["oInspector"]
onready var oInstances = Nodelist.list["oInstances"]
onready var oThingDetails = Nodelist.list["oThingDetails"]
onready var oPickThingWindow = Nodelist.list["oPickThingWindow"]
onready var oActionPointList = Nodelist.list["oActionPointList"]

#onready var oSelection = $'../../Selector/Selection'
#onready var oInstanceOwnership = $'../../OverheadOwnership/InstanceOwnership'
Expand Down Expand Up @@ -70,6 +71,12 @@ func _enter_tree():
add_to_group("TreasuryGold")
elif subtype in Things.LIST_OF_SPELLBOOKS:
add_to_group("Spellbook")
elif subtype == 49:
add_to_group("HeroGate")
yield(get_tree(),'idle_frame')
if oActionPointList:
oActionPointList.update_ap_list()

Things.TYPE.CREATURE:
add_to_group("Creature")
var oCamera2D = Nodelist.list["oCamera2D"]
Expand Down

0 comments on commit e7a14eb

Please sign in to comment.