about summary refs log tree commit diff stats
path: root/apworld/client/textclient.gd
diff options
context:
space:
mode:
Diffstat (limited to 'apworld/client/textclient.gd')
-rw-r--r--apworld/client/textclient.gd102
1 files changed, 86 insertions, 16 deletions
diff --git a/apworld/client/textclient.gd b/apworld/client/textclient.gd index f785a03..ce28a3a 100644 --- a/apworld/client/textclient.gd +++ b/apworld/client/textclient.gd
@@ -16,6 +16,8 @@ var tracker_loc_tree_item_by_id = {}
16var tracker_port_tree_item_by_id = {} 16var tracker_port_tree_item_by_id = {}
17var tracker_goal_tree_item = null 17var tracker_goal_tree_item = null
18var tracker_object_by_index = {} 18var tracker_object_by_index = {}
19var tracker_object_by_ignored_index = {}
20var tracker_ignored_group = null
19 21
20var worldports_tab 22var worldports_tab
21var worldports_tree 23var worldports_tree
@@ -99,7 +101,7 @@ func _ready():
99 tabs.add_child(tracker_margins) 101 tabs.add_child(tracker_margins)
100 102
101 tracker_tree = Tree.new() 103 tracker_tree = Tree.new()
102 tracker_tree.columns = 3 104 tracker_tree.columns = 4
103 tracker_tree.hide_root = true 105 tracker_tree.hide_root = true
104 tracker_tree.add_theme_font_size_override("font_size", 24) 106 tracker_tree.add_theme_font_size_override("font_size", 24)
105 tracker_tree.add_theme_color_override("font_color", Color(0.8, 0.8, 0.8, 1)) 107 tracker_tree.add_theme_color_override("font_color", Color(0.8, 0.8, 0.8, 1))
@@ -108,7 +110,9 @@ func _ready():
108 tracker_tree.set_column_expand(0, false) 110 tracker_tree.set_column_expand(0, false)
109 tracker_tree.set_column_expand(1, true) 111 tracker_tree.set_column_expand(1, true)
110 tracker_tree.set_column_expand(2, false) 112 tracker_tree.set_column_expand(2, false)
113 tracker_tree.set_column_expand(3, false)
111 tracker_tree.set_column_custom_minimum_width(2, 200) 114 tracker_tree.set_column_custom_minimum_width(2, 200)
115 tracker_tree.set_column_custom_minimum_width(3, 200)
112 tracker_margins.add_child(tracker_tree) 116 tracker_margins.add_child(tracker_tree)
113 117
114 worldports_tab = MarginContainer.new() 118 worldports_tab = MarginContainer.new()
@@ -208,6 +212,8 @@ func update_locations(reset_locations = true):
208 "name": location_name, 212 "name": location_name,
209 "type": kLocation, 213 "type": kLocation,
210 "id": location_id, 214 "id": location_id,
215 "ignored": ap._ignored_locations.has(location_id),
216 "hint": ap.client._hinted_locations.has(location_id),
211 } 217 }
212 ) 218 )
213 ) 219 )
@@ -222,11 +228,13 @@ func update_locations(reset_locations = true):
222 "name": port_name, 228 "name": port_name,
223 "type": kWorldport, 229 "type": kWorldport,
224 "id": port_id, 230 "id": port_id,
231 "ignored": false,
232 "hint": false,
225 } 233 }
226 ) 234 )
227 ) 235 )
228 236
229 locations.sort_custom(func(a, b): return a["name"] < b["name"]) 237 locations.sort_custom(_cmp_tracker_objects)
230 238
231 if ap.client._goal_accessible: 239 if ap.client._goal_accessible:
232 var location_name = gamedata.ending_display_name_by_name[ap.kEndingNameByVictoryValue[ 240 var location_name = gamedata.ending_display_name_by_name[ap.kEndingNameByVictoryValue[
@@ -238,14 +246,18 @@ func update_locations(reset_locations = true):
238 { 246 {
239 "name": location_name, 247 "name": location_name,
240 "type": kGoal, 248 "type": kGoal,
249 "ignored": false,
250 "hint": false,
241 } 251 }
242 ) 252 )
243 ) 253 )
244 254
245 var count = 0 255 var count = 0
246 for location in locations: 256 for location in locations:
247 if count < 18: 257 if count < 18 and not location["ignored"]:
248 locations_overlay.push_paragraph(HORIZONTAL_ALIGNMENT_RIGHT) 258 locations_overlay.push_paragraph(HORIZONTAL_ALIGNMENT_RIGHT)
259 if location["hint"]:
260 locations_overlay.push_color(Color("#fafad2"))
249 locations_overlay.append_text(location["name"]) 261 locations_overlay.append_text(location["name"])
250 locations_overlay.append_text(" ") 262 locations_overlay.append_text(" ")
251 if location["type"] == kLocation: 263 if location["type"] == kLocation:
@@ -254,6 +266,8 @@ func update_locations(reset_locations = true):
254 locations_overlay.add_image(worldport_texture) 266 locations_overlay.add_image(worldport_texture)
255 elif location["type"] == kGoal: 267 elif location["type"] == kGoal:
256 locations_overlay.add_image(goal_texture) 268 locations_overlay.add_image(goal_texture)
269 if location["hint"]:
270 locations_overlay.pop()
257 locations_overlay.pop() 271 locations_overlay.pop()
258 count += 1 272 count += 1
259 273
@@ -266,17 +280,43 @@ func update_locations(reset_locations = true):
266 var root_ti = tracker_tree.create_item(null) 280 var root_ti = tracker_tree.create_item(null)
267 281
268 for location in locations: 282 for location in locations:
269 var loc_row = root_ti.create_child() 283 var loc_row
284
285 if location["ignored"]:
286 if tracker_ignored_group == null:
287 tracker_ignored_group = root_ti.create_child()
288 tracker_ignored_group.set_text(1, "Ignored Locations")
289 tracker_ignored_group.set_selectable(0, false)
290 tracker_ignored_group.set_selectable(1, false)
291 tracker_ignored_group.set_selectable(2, false)
292 tracker_ignored_group.set_selectable(3, false)
293
294 loc_row = tracker_ignored_group.create_child()
295 else:
296 loc_row = root_ti.create_child()
297
270 loc_row.set_cell_mode(0, TreeItem.CELL_MODE_ICON) 298 loc_row.set_cell_mode(0, TreeItem.CELL_MODE_ICON)
271 loc_row.set_selectable(0, false) 299 loc_row.set_selectable(0, false)
272 loc_row.set_text(1, location["name"]) 300 loc_row.set_text(1, location["name"])
273 loc_row.set_selectable(1, false) 301 loc_row.set_selectable(1, false)
302 if location["hint"]:
303 loc_row.set_custom_color(1, Color("#fafad2"))
274 loc_row.set_cell_mode(2, TreeItem.CELL_MODE_CUSTOM) 304 loc_row.set_cell_mode(2, TreeItem.CELL_MODE_CUSTOM)
275 loc_row.set_text(2, "Show Path") 305 loc_row.set_text(2, "Show Path")
276 loc_row.set_custom_as_button(2, true) 306 loc_row.set_custom_as_button(2, true)
277 loc_row.set_editable(2, true) 307 loc_row.set_editable(2, true)
278 loc_row.set_selectable(2, false) 308 loc_row.set_selectable(2, false)
279 loc_row.set_text_alignment(2, HORIZONTAL_ALIGNMENT_CENTER) 309 loc_row.set_text_alignment(2, HORIZONTAL_ALIGNMENT_CENTER)
310 loc_row.set_selectable(3, false)
311 if location["type"] == kLocation:
312 loc_row.set_cell_mode(3, TreeItem.CELL_MODE_CUSTOM)
313 if location["ignored"]:
314 loc_row.set_text(3, "Unignore")
315 else:
316 loc_row.set_text(3, "Ignore")
317 loc_row.set_custom_as_button(3, true)
318 loc_row.set_editable(3, true)
319 loc_row.set_text_alignment(3, HORIZONTAL_ALIGNMENT_CENTER)
280 320
281 if location["type"] == kLocation: 321 if location["type"] == kLocation:
282 loc_row.set_icon(0, location_texture) 322 loc_row.set_icon(0, location_texture)
@@ -288,7 +328,10 @@ func update_locations(reset_locations = true):
288 loc_row.set_icon(0, goal_texture) 328 loc_row.set_icon(0, goal_texture)
289 tracker_goal_tree_item = loc_row 329 tracker_goal_tree_item = loc_row
290 330
291 tracker_object_by_index[loc_row.get_index()] = location 331 if location["ignored"]:
332 tracker_object_by_ignored_index[loc_row.get_index()] = location
333 else:
334 tracker_object_by_index[loc_row.get_index()] = location
292 else: 335 else:
293 for loc_row in tracker_tree.get_root().get_children(): 336 for loc_row in tracker_tree.get_root().get_children():
294 loc_row.visible = false 337 loc_row.visible = false
@@ -310,6 +353,18 @@ func update_locations(reset_locations = true):
310 if tracker_goal_tree_item != null and ap.client._goal_accessible: 353 if tracker_goal_tree_item != null and ap.client._goal_accessible:
311 tracker_goal_tree_item.visible = true 354 tracker_goal_tree_item.visible = true
312 355
356 if tracker_ignored_group != null:
357 tracker_ignored_group.visible = true
358
359
360func _cmp_tracker_objects(a, b) -> bool:
361 if a["ignored"] != b["ignored"]:
362 return !a["ignored"]
363 elif a["hint"] != b["hint"]:
364 return a["hint"]
365 else:
366 return a["name"] < b["name"]
367
313 368
314func update_locations_visibility(): 369func update_locations_visibility():
315 var ap = global.get_node("Archipelago") 370 var ap = global.get_node("Archipelago")
@@ -317,20 +372,33 @@ func update_locations_visibility():
317 372
318 373
319func _on_tracker_button_clicked(): 374func _on_tracker_button_clicked():
375 var ap = global.get_node("Archipelago")
376
320 var edited_item = tracker_tree.get_edited() 377 var edited_item = tracker_tree.get_edited()
321 var edited_index = edited_item.get_index() 378 var edited_index = edited_item.get_index()
322 379
323 if tracker_object_by_index.has(edited_index): 380 if edited_item.get_parent() == tracker_tree.get_root():
324 var tracker_object = tracker_object_by_index[edited_index] 381 if tracker_object_by_index.has(edited_index):
325 var ap = global.get_node("Archipelago") 382 var tracker_object = tracker_object_by_index[edited_index]
326 var type_str = "" 383 if tracker_tree.get_edited_column() == 2:
327 if tracker_object["type"] == kLocation: 384 var type_str = ""
328 type_str = "location" 385 if tracker_object["type"] == kLocation:
329 elif tracker_object["type"] == kWorldport: 386 type_str = "location"
330 type_str = "worldport" 387 elif tracker_object["type"] == kWorldport:
331 elif tracker_object["type"] == kGoal: 388 type_str = "worldport"
332 type_str = "goal" 389 elif tracker_object["type"] == kGoal:
333 ap.client.getLogicalPath(type_str, tracker_object.get("id", null)) 390 type_str = "goal"
391 ap.client.getLogicalPath(type_str, tracker_object.get("id", null))
392 elif tracker_tree.get_edited_column() == 3:
393 ap.toggle_ignored_location(tracker_object["id"])
394 elif edited_item.get_parent() == tracker_ignored_group:
395 # This is the ignored locations group.
396 if (
397 tracker_object_by_ignored_index.has(edited_index)
398 and tracker_tree.get_edited_column() == 3
399 ):
400 var tracker_object = tracker_object_by_ignored_index[edited_index]
401 ap.toggle_ignored_location(tracker_object["id"])
334 402
335 403
336func display_logical_path(object_type, object_id, paths): 404func display_logical_path(object_type, object_id, paths):
@@ -435,4 +503,6 @@ func reset_tracker_tab():
435 tracker_port_tree_item_by_id.clear() 503 tracker_port_tree_item_by_id.clear()
436 tracker_goal_tree_item = null 504 tracker_goal_tree_item = null
437 tracker_object_by_index.clear() 505 tracker_object_by_index.clear()
506 tracker_object_by_ignored_index.clear()
507 tracker_ignored_group = null
438 tracker_tree.clear() 508 tracker_tree.clear()