Fix duplicate event bug
This commit is contained in:
		
							parent
							
								
									2d736173e5
								
							
						
					
					
						commit
						f47399a131
					
				| 
						 | 
					@ -7,7 +7,7 @@ custom_features=""
 | 
				
			||||||
export_filter="all_resources"
 | 
					export_filter="all_resources"
 | 
				
			||||||
include_filter=""
 | 
					include_filter=""
 | 
				
			||||||
exclude_filter=""
 | 
					exclude_filter=""
 | 
				
			||||||
export_path="build/ld48-gravity_limbo.html"
 | 
					export_path="build/html/ld48-gravity_limbo.html"
 | 
				
			||||||
patch_list=PoolStringArray(  )
 | 
					patch_list=PoolStringArray(  )
 | 
				
			||||||
script_export_mode=1
 | 
					script_export_mode=1
 | 
				
			||||||
script_encryption_key=""
 | 
					script_encryption_key=""
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -566,7 +566,7 @@ func goto_scene(scene, current = null, free = true):
 | 
				
			||||||
	call_deferred("_deferred_goto_scene", scene, current, free)
 | 
						call_deferred("_deferred_goto_scene", scene, current, free)
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
func _deferred_goto_scene(scene, current = null, free = true):
 | 
					func _deferred_goto_scene(scene, current = null, free = true):
 | 
				
			||||||
	get_tree().get_root().print_tree_pretty()
 | 
						#get_tree().get_root().print_tree_pretty()
 | 
				
			||||||
	if current:
 | 
						if current:
 | 
				
			||||||
		if free:
 | 
							if free:
 | 
				
			||||||
			current.free()
 | 
								current.free()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,7 @@ func _on_choice_made(index):
 | 
				
			||||||
	var result_indices = self.data["choices"][index]["results"].keys()
 | 
						var result_indices = self.data["choices"][index]["results"].keys()
 | 
				
			||||||
	var result = null
 | 
						var result = null
 | 
				
			||||||
	var chance = GameState.rng.randi_range(0, 100)
 | 
						var chance = GameState.rng.randi_range(0, 100)
 | 
				
			||||||
	print(chance)
 | 
						#print(chance)
 | 
				
			||||||
	var i = len(result_indices) - 1 
 | 
						var i = len(result_indices) - 1 
 | 
				
			||||||
	while i >= 0:
 | 
						while i >= 0:
 | 
				
			||||||
		if chance >= result_indices[i]:
 | 
							if chance >= result_indices[i]:
 | 
				
			||||||
| 
						 | 
					@ -56,7 +56,7 @@ func _on_choice_made(index):
 | 
				
			||||||
			break
 | 
								break
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			i -= 1
 | 
								i -= 1
 | 
				
			||||||
	print(result)
 | 
						#print(result)
 | 
				
			||||||
	#print(self.data["choices"][index]["results"][result])
 | 
						#print(self.data["choices"][index]["results"][result])
 | 
				
			||||||
	var action = self.data["choices"][index]["results"][result]
 | 
						var action = self.data["choices"][index]["results"][result]
 | 
				
			||||||
	if action.has("stat_changes"):
 | 
						if action.has("stat_changes"):
 | 
				
			||||||
| 
						 | 
					@ -65,24 +65,23 @@ func _on_choice_made(index):
 | 
				
			||||||
		GameState.update_orbit(action["orbit_changes"])
 | 
							GameState.update_orbit(action["orbit_changes"])
 | 
				
			||||||
	if action.has("crew_changes"):
 | 
						if action.has("crew_changes"):
 | 
				
			||||||
		GameState.update_crew(action["crew_changes"])
 | 
							GameState.update_crew(action["crew_changes"])
 | 
				
			||||||
	print(action)
 | 
						#print(action)
 | 
				
			||||||
	var t = RichTextLabel.new()
 | 
						var t = RichTextLabel.new()
 | 
				
			||||||
	t.set_use_bbcode(true)
 | 
						t.set_use_bbcode(true)
 | 
				
			||||||
	var text = self.data["choices"][index]["then"]
 | 
						var text = self.data["choices"][index]["then"]
 | 
				
			||||||
	if action.has("text"):
 | 
						if action.has("text"):
 | 
				
			||||||
		text += "\n\n" + action['text']
 | 
							text += "\n\n" + action['text']
 | 
				
			||||||
		if action.has("stat_changes") and action["stat_changes"]:
 | 
							if action.has("stat_changes") and action["stat_changes"]:
 | 
				
			||||||
			print("yes")
 | 
					 | 
				
			||||||
			text += "\n\n[center]Effects:[/center]\n"
 | 
								text += "\n\n[center]Effects:[/center]\n"
 | 
				
			||||||
			for k in action["stat_changes"].keys():
 | 
								for k in action["stat_changes"].keys():
 | 
				
			||||||
				print(k)
 | 
									#print(k)
 | 
				
			||||||
				var value = action["stat_changes"][k]
 | 
									var value = action["stat_changes"][k]
 | 
				
			||||||
				var color = "green"
 | 
									var color = "green"
 | 
				
			||||||
				if value < 0:
 | 
									if value < 0:
 | 
				
			||||||
					color = "red"
 | 
										color = "red"
 | 
				
			||||||
				print(color)
 | 
									#print(color)
 | 
				
			||||||
				var addition = k + ": [color=" + color + "]" + str(value) + "[/color]\n"
 | 
									var addition = k + ": [color=" + color + "]" + str(value) + "[/color]\n"
 | 
				
			||||||
				print(addition)
 | 
									#print(addition)
 | 
				
			||||||
				text += addition
 | 
									text += addition
 | 
				
			||||||
	t.set_bbcode(text)
 | 
						t.set_bbcode(text)
 | 
				
			||||||
	t.set_fit_content_height(true)
 | 
						t.set_fit_content_height(true)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,31 +9,42 @@ signal encounter_choice_changed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var choices = 3
 | 
					var choices = 3
 | 
				
			||||||
var level = 0
 | 
					var level = 0
 | 
				
			||||||
var buttonNames = [
 | 
					
 | 
				
			||||||
	"Option0",
 | 
					 | 
				
			||||||
	"Option1",
 | 
					 | 
				
			||||||
	"Option2",
 | 
					 | 
				
			||||||
]
 | 
					 | 
				
			||||||
# Called when the node enters the scene tree for the first time.
 | 
					# Called when the node enters the scene tree for the first time.
 | 
				
			||||||
func _ready():
 | 
					func _ready():
 | 
				
			||||||
	# Bind button callbacks
 | 
						# Bind button callbacks
 | 
				
			||||||
	for n in buttonNames:
 | 
						#for n in buttonNames:
 | 
				
			||||||
		var button = self.find_node(n)
 | 
						#	var button = self.find_node(n)
 | 
				
			||||||
		if button:
 | 
						#	if button:
 | 
				
			||||||
			button.connect("toggled", self, "_on_option_button_pressed", [n])
 | 
						#		button.connect("toggled", self, "_on_option_button_pressed", [n])
 | 
				
			||||||
 | 
						pass
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func initialize(l = null, nOptions = null):
 | 
					func initialize(l = null, nOptions = null):
 | 
				
			||||||
	self.level = l
 | 
						self.level = l
 | 
				
			||||||
	if nOptions != null:
 | 
						print("Intializing choices for level " + str(l) + " with " + str(nOptions) + " options")
 | 
				
			||||||
 | 
						if nOptions == null:
 | 
				
			||||||
 | 
							nOptions = 3
 | 
				
			||||||
	self.choices = nOptions
 | 
						self.choices = nOptions
 | 
				
			||||||
	var x = 0
 | 
						var x = 0
 | 
				
			||||||
		while x < 3:
 | 
						while x < nOptions:
 | 
				
			||||||
			self.find_node("Option" + str(x)).visible = x < nOptions
 | 
							var s = get_node("Spot" + str(x))
 | 
				
			||||||
 | 
							var n = TextureButton.new()
 | 
				
			||||||
 | 
							if s:
 | 
				
			||||||
 | 
								n.set_position(s.get_position())
 | 
				
			||||||
 | 
							n.set_name("Option" + str(x))
 | 
				
			||||||
 | 
							n.add_to_group("EncounterOptions")
 | 
				
			||||||
 | 
							n.set_toggle_mode(true)
 | 
				
			||||||
 | 
							#print("Adding option with name: " + n.get_name())
 | 
				
			||||||
 | 
							n.connect("toggled", self, "_on_option_button_pressed", [n.get_name()])
 | 
				
			||||||
 | 
							n.set_normal_texture(ResourceLoader.load("res://assets/encounterPlaceholder0.png"))
 | 
				
			||||||
 | 
							n.set_pressed_texture(ResourceLoader.load("res://assets/encounterIconPlaceholder0_pressed.png"))
 | 
				
			||||||
 | 
							add_child(n, true)
 | 
				
			||||||
 | 
							print("Adding texture button: Option" + str(x))
 | 
				
			||||||
 | 
							#self.find_node("Option" + str(x)).visible = x < nOptions
 | 
				
			||||||
		x += 1
 | 
							x += 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func activate_options():
 | 
					func activate_options():
 | 
				
			||||||
	if self.choices > 1:
 | 
						for c in get_my_options():
 | 
				
			||||||
		for c in self.get_children():
 | 
					 | 
				
			||||||
		if c.visible:
 | 
							if c.visible:
 | 
				
			||||||
			c.set_disabled(false)
 | 
								c.set_disabled(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,19 +60,28 @@ func active_visited():
 | 
				
			||||||
	return GameState.encounters[self.level][i]['visited']
 | 
						return GameState.encounters[self.level][i]['visited']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func disable_options():
 | 
					func disable_options():
 | 
				
			||||||
	for c in self.get_children():
 | 
						for c in get_my_options():
 | 
				
			||||||
		if c.visible:
 | 
							if c.visible:
 | 
				
			||||||
			c.set_disabled(true)
 | 
								c.set_disabled(true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func get_active_option_index():
 | 
					func get_active_option_index():
 | 
				
			||||||
	var x = 0
 | 
						var x = 0
 | 
				
			||||||
	for c in self.get_children():
 | 
						print("Checking for active index of level " + str(level))
 | 
				
			||||||
		if not c.is_visible():
 | 
						for c in get_my_options():
 | 
				
			||||||
 | 
							var i = int(c.get_name()[-1])
 | 
				
			||||||
 | 
							if GameState.encounters[self.level][i]['visited']:
 | 
				
			||||||
 | 
								print(c.get_name() + " is visited, skipping")
 | 
				
			||||||
			x += 1
 | 
								x += 1
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		if c.is_pressed():
 | 
							if not c.is_visible():
 | 
				
			||||||
 | 
								print(c.get_name() + " is not visible, skipping")
 | 
				
			||||||
 | 
								x += 1
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							if c.is_pressed() or GameState.encounters[self.level][i]['selected']:
 | 
				
			||||||
 | 
								print(c.get_name() + " is pressed")
 | 
				
			||||||
			return x
 | 
								return x
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
 | 
								print(c.get_name() + " is not pressed, skipping")
 | 
				
			||||||
			x += 1
 | 
								x += 1
 | 
				
			||||||
	return null
 | 
						return null
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
| 
						 | 
					@ -77,16 +97,28 @@ func get_active_position():
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func has_active():
 | 
					func has_active():
 | 
				
			||||||
	var active = false
 | 
						var active = false
 | 
				
			||||||
	for n in buttonNames:
 | 
						for n in get_my_options():
 | 
				
			||||||
		if get_node(n):
 | 
								active = active or (n.is_pressed() and n.is_visible())
 | 
				
			||||||
			active = active or (self.get_node(n).is_pressed() and self.get_node(n).is_visible())
 | 
					 | 
				
			||||||
	return active
 | 
						return active
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func get_my_options():
 | 
				
			||||||
 | 
						var n = []
 | 
				
			||||||
 | 
						if not get_tree():
 | 
				
			||||||
 | 
							return n
 | 
				
			||||||
 | 
						for o in get_tree().get_nodes_in_group("EncounterOptions"):
 | 
				
			||||||
 | 
							if o.get_parent() != self:
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							n.append(o)
 | 
				
			||||||
 | 
						return n
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func _on_option_button_pressed(state, buttonName):
 | 
					func _on_option_button_pressed(state, buttonName):
 | 
				
			||||||
	for n in buttonNames:
 | 
						# Map calls this before we have buttons. Or before we exist?
 | 
				
			||||||
		if n != buttonName:
 | 
						#print(buttonName + " has state: " + str(state))
 | 
				
			||||||
			if state and get_node(n):
 | 
						for n in get_my_options():
 | 
				
			||||||
				self.get_node(n).set_pressed(false)
 | 
							#print(n.get_name())
 | 
				
			||||||
 | 
							if n.get_name() != buttonName:
 | 
				
			||||||
 | 
								if state :
 | 
				
			||||||
 | 
									n.set_pressed(false)
 | 
				
			||||||
	emit_signal("encounter_choice_changed")
 | 
						emit_signal("encounter_choice_changed")
 | 
				
			||||||
	#for n in buttonNames:
 | 
						#for n in buttonNames:
 | 
				
			||||||
	#	if self.find_node(n).is_pressed():
 | 
						#	if self.find_node(n).is_pressed():
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,52 +1,16 @@
 | 
				
			||||||
[gd_scene load_steps=8 format=2]
 | 
					[gd_scene load_steps=2 format=2]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[ext_resource path="res://src/ui/EncounterChoice.gd" type="Script" id=1]
 | 
					[ext_resource path="res://src/ui/EncounterChoice.gd" type="Script" id=1]
 | 
				
			||||||
[ext_resource path="res://assets/encounterPlaceholder2.png" type="Texture" id=2]
 | 
					 | 
				
			||||||
[ext_resource path="res://assets/encounterPlaceholder0.png" type="Texture" id=3]
 | 
					 | 
				
			||||||
[ext_resource path="res://assets/encounterPlaceholder1.png" type="Texture" id=4]
 | 
					 | 
				
			||||||
[ext_resource path="res://assets/encounterIconPlaceholder0_pressed.png" type="Texture" id=5]
 | 
					 | 
				
			||||||
[ext_resource path="res://assets/encounterIconPlaceholder1_pressed.png" type="Texture" id=6]
 | 
					 | 
				
			||||||
[ext_resource path="res://assets/encounterIconPlaceholder2_pressed.png" type="Texture" id=7]
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="EncounterChoice" type="Node2D"]
 | 
					[node name="EncounterChoice" type="Node2D"]
 | 
				
			||||||
position = Vector2( -0.5, 0.5 )
 | 
					position = Vector2( -0.5, 0.5 )
 | 
				
			||||||
script = ExtResource( 1 )
 | 
					script = ExtResource( 1 )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="Option0" type="TextureButton" parent="."]
 | 
					[node name="Spot0" type="Node2D" parent="."]
 | 
				
			||||||
margin_left = -28.8286
 | 
					position = Vector2( 37.0812, -38.6704 )
 | 
				
			||||||
margin_top = 14.3104
 | 
					 | 
				
			||||||
margin_right = 11.1714
 | 
					 | 
				
			||||||
margin_bottom = 54.3104
 | 
					 | 
				
			||||||
hint_tooltip = "Option 0"
 | 
					 | 
				
			||||||
toggle_mode = true
 | 
					 | 
				
			||||||
texture_normal = ExtResource( 3 )
 | 
					 | 
				
			||||||
texture_pressed = ExtResource( 5 )
 | 
					 | 
				
			||||||
__meta__ = {
 | 
					 | 
				
			||||||
"_edit_use_anchors_": false
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="Option1" type="TextureButton" parent="."]
 | 
					[node name="Spot1" type="Node2D" parent="."]
 | 
				
			||||||
margin_left = 24.2782
 | 
					position = Vector2( 31.7839, 10.5946 )
 | 
				
			||||||
margin_top = 16.5904
 | 
					 | 
				
			||||||
margin_right = 64.2782
 | 
					 | 
				
			||||||
margin_bottom = 56.5904
 | 
					 | 
				
			||||||
hint_tooltip = "Option 1"
 | 
					 | 
				
			||||||
toggle_mode = true
 | 
					 | 
				
			||||||
texture_normal = ExtResource( 4 )
 | 
					 | 
				
			||||||
texture_pressed = ExtResource( 6 )
 | 
					 | 
				
			||||||
__meta__ = {
 | 
					 | 
				
			||||||
"_edit_use_anchors_": false
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="Option2" type="TextureButton" parent="."]
 | 
					[node name="Spot2" type="Node2D" parent="."]
 | 
				
			||||||
margin_left = 17.7514
 | 
					position = Vector2( -15.3622, 38.1406 )
 | 
				
			||||||
margin_top = -36.9294
 | 
					 | 
				
			||||||
margin_right = 57.7514
 | 
					 | 
				
			||||||
margin_bottom = 3.07064
 | 
					 | 
				
			||||||
hint_tooltip = "Option 2"
 | 
					 | 
				
			||||||
toggle_mode = true
 | 
					 | 
				
			||||||
texture_normal = ExtResource( 2 )
 | 
					 | 
				
			||||||
texture_pressed = ExtResource( 7 )
 | 
					 | 
				
			||||||
__meta__ = {
 | 
					 | 
				
			||||||
"_edit_use_anchors_": false
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,11 +30,17 @@ func _on_ship_arrived():
 | 
				
			||||||
	#
 | 
						#
 | 
				
			||||||
	if GameState.current_state != 5 and GameState.current_state != 8:
 | 
						if GameState.current_state != 5 and GameState.current_state != 8:
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
 | 
						# Work around a duplicate event bug
 | 
				
			||||||
 | 
						if GameState.current_state == 8 and self.direction == 1:
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
	var index = get_node("Map/Level" + str(GameState.current_depth)).get_active_option_index()
 | 
						var index = get_node("Map/Level" + str(GameState.current_depth)).get_active_option_index()
 | 
				
			||||||
 | 
						if index == null:
 | 
				
			||||||
 | 
							var n = get_node("Map/Level" + str(GameState.current_depth))
 | 
				
			||||||
 | 
							print(GameState.encounters[GameState.current_depth])
 | 
				
			||||||
 | 
						print("Got index for level " + str(GameState.current_depth) + ": " + str(index))
 | 
				
			||||||
	GameState.encounters[GameState.current_depth][index]['visited'] = true
 | 
						GameState.encounters[GameState.current_depth][index]['visited'] = true
 | 
				
			||||||
	get_node("Map").draw_course()
 | 
						get_node("Map").draw_course()
 | 
				
			||||||
	var e = GameState.encounters[GameState.current_depth]
 | 
						var e = GameState.encounters[GameState.current_depth]
 | 
				
			||||||
	print(e[index])
 | 
					 | 
				
			||||||
	var instance = GameState.generate_encounter_instance(e, GameState.current_depth, index)
 | 
						var instance = GameState.generate_encounter_instance(e, GameState.current_depth, index)
 | 
				
			||||||
	instance.add_to_group("Encounters")
 | 
						instance.add_to_group("Encounters")
 | 
				
			||||||
	self.add_child(instance)
 | 
						self.add_child(instance)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,7 +22,7 @@ func _ready():
 | 
				
			||||||
	self.get_node("Planet").set_texture(ResourceLoader.load(GameState.get_difficulty_data("planet")))
 | 
						self.get_node("Planet").set_texture(ResourceLoader.load(GameState.get_difficulty_data("planet")))
 | 
				
			||||||
	var encounterChoice = ResourceLoader.load("res://src/ui/EncounterChoice.tscn")
 | 
						var encounterChoice = ResourceLoader.load("res://src/ui/EncounterChoice.tscn")
 | 
				
			||||||
	for level in GameState.encounters.keys():
 | 
						for level in GameState.encounters.keys():
 | 
				
			||||||
		print(level)
 | 
							#print(level)
 | 
				
			||||||
		var name = "Level" + str(level)
 | 
							var name = "Level" + str(level)
 | 
				
			||||||
		var choice = encounterChoice.instance()
 | 
							var choice = encounterChoice.instance()
 | 
				
			||||||
		choice.set_name(name)
 | 
							choice.set_name(name)
 | 
				
			||||||
| 
						 | 
					@ -33,14 +33,15 @@ func _ready():
 | 
				
			||||||
		var x = 0
 | 
							var x = 0
 | 
				
			||||||
		while x < len(GameState.encounters[level]):
 | 
							while x < len(GameState.encounters[level]):
 | 
				
			||||||
			# Fixes the rotation of the individual buttons
 | 
								# Fixes the rotation of the individual buttons
 | 
				
			||||||
			var n  = choice.find_node("Option" + str(x))
 | 
								var n  = choice.get_node("Option" + str(x))
 | 
				
			||||||
			if not n:
 | 
								if not n:
 | 
				
			||||||
 | 
									x += 1
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			n.set_rotation(
 | 
								n.set_rotation(
 | 
				
			||||||
				-(find_node("Level" + str(level) + "Location").get_global_rotation())
 | 
									-(find_node("Level" + str(level) + "Location").get_global_rotation())
 | 
				
			||||||
				)
 | 
									)
 | 
				
			||||||
			# Set icon and tooltip
 | 
								# Set icon and tooltip
 | 
				
			||||||
			print("Checking for icons related to '" + GameState.encounters[level][x]["type"] + "'")
 | 
								#print("Checking for icons related to '" + GameState.encounters[level][x]["type"] + "'")
 | 
				
			||||||
			var texture = ResourceLoader.load("res://assets/encounterIcon" + GameState.encounters[level][x]["type"] + ".png")
 | 
								var texture = ResourceLoader.load("res://assets/encounterIcon" + GameState.encounters[level][x]["type"] + ".png")
 | 
				
			||||||
			var texture_pressed = ResourceLoader.load("res://assets/encounterIcon" + GameState.encounters[level][x]["type"] + "_pressed.png")
 | 
								var texture_pressed = ResourceLoader.load("res://assets/encounterIcon" + GameState.encounters[level][x]["type"] + "_pressed.png")
 | 
				
			||||||
			if texture:
 | 
								if texture:
 | 
				
			||||||
| 
						 | 
					@ -52,7 +53,7 @@ func _ready():
 | 
				
			||||||
			if GameState.encounters[level][x]["selected"] or (x == 0 and started_ourselves):
 | 
								if GameState.encounters[level][x]["selected"] or (x == 0 and started_ourselves):
 | 
				
			||||||
				# The texture change is used since when disabled the normal_texture is shown regardless of press state.
 | 
									# The texture change is used since when disabled the normal_texture is shown regardless of press state.
 | 
				
			||||||
				n.set_pressed(true)
 | 
									n.set_pressed(true)
 | 
				
			||||||
				choice._on_option_button_pressed(true, "Option" + str(x))
 | 
									#choice._on_option_button_pressed(true, "Option" + str(x))
 | 
				
			||||||
				#n.set_normal_texture(n.get_pressed_texture())
 | 
									#n.set_normal_texture(n.get_pressed_texture())
 | 
				
			||||||
			if GameState.encounters[level][x]["visited"]:
 | 
								if GameState.encounters[level][x]["visited"]:
 | 
				
			||||||
				n.set_visible(false)
 | 
									n.set_visible(false)
 | 
				
			||||||
| 
						 | 
					@ -88,7 +89,7 @@ func _on_encounter_choice_changed():
 | 
				
			||||||
func draw_course():
 | 
					func draw_course():
 | 
				
			||||||
	# A bit brutal
 | 
						# A bit brutal
 | 
				
			||||||
	for p in get_tree().get_nodes_in_group("Course"):
 | 
						for p in get_tree().get_nodes_in_group("Course"):
 | 
				
			||||||
		print(p.get_name())
 | 
							#print(p.get_name())
 | 
				
			||||||
		p.set_visible(false)
 | 
							p.set_visible(false)
 | 
				
			||||||
		p.call_deferred("free")
 | 
							p.call_deferred("free")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -97,18 +98,21 @@ func draw_course():
 | 
				
			||||||
	while x < (len(GameState.encounters) - 1):
 | 
						while x < (len(GameState.encounters) - 1):
 | 
				
			||||||
		pairs.append([x, x+1])
 | 
							pairs.append([x, x+1])
 | 
				
			||||||
		x += 1
 | 
							x += 1
 | 
				
			||||||
	print(pairs)
 | 
						#print(pairs)
 | 
				
			||||||
	for p in pairs:
 | 
						for p in pairs:
 | 
				
			||||||
		var first = get_node("Level" + str(p[0]))
 | 
							var first = get_node("Level" + str(p[0]))
 | 
				
			||||||
		var second = get_node("Level" + str(p[1]))
 | 
							var second = get_node("Level" + str(p[1]))
 | 
				
			||||||
		if not first or not second:
 | 
							if not first or not second:
 | 
				
			||||||
			print("One is null: " + str(p))
 | 
								#print("One is null: " + str(p))
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		if not first.has_active() or not second.has_active():
 | 
							#if not first.has_active() or not second.has_active():
 | 
				
			||||||
			print("One has no active: " + str(p))
 | 
							#	print("One has no active: " + str(p))
 | 
				
			||||||
			continue
 | 
							#	continue
 | 
				
			||||||
		if second.active_visited():
 | 
							#if second.active_visited():
 | 
				
			||||||
			print("Second has a visited active choice: " + str(p))
 | 
							#	print("Second has a visited active choice: " + str(p))
 | 
				
			||||||
 | 
							#	continue
 | 
				
			||||||
 | 
							if not first.get_active_position() or not second.get_active_position():
 | 
				
			||||||
 | 
								#print("One has no posiion: " + str(p))
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		var l = Line2D.new()
 | 
							var l = Line2D.new()
 | 
				
			||||||
		l.add_point(first.get_active_position())
 | 
							l.add_point(first.get_active_position())
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@ rotation = 2.79253
 | 
				
			||||||
scale = Vector2( 1.05, 1.05 )
 | 
					scale = Vector2( 1.05, 1.05 )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="Level5Location" type="Node2D" parent="."]
 | 
					[node name="Level5Location" type="Node2D" parent="."]
 | 
				
			||||||
position = Vector2( 506.488, 220.486 )
 | 
					position = Vector2( 462.041, 252.234 )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[node name="Ship" type="Sprite" parent="."]
 | 
					[node name="Ship" type="Sprite" parent="."]
 | 
				
			||||||
position = Vector2( 1.5874, 3.96851 )
 | 
					position = Vector2( 1.5874, 3.96851 )
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue