LayerSelector.gd 828 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. extends ItemList
  2. # Declare member variables here. Examples:
  3. # var a = 2
  4. # var b = "text"
  5. onready var GRID = find_parent("GRID")
  6. # Called when the node enters the scene tree for the first time.
  7. func _ready():
  8. add_item("nothing")
  9. for i in CellType.SIGNAL_COUNT:
  10. add_item("signal " + str(i))
  11. connect("item_activated",self,"on_layer_selected")
  12. func on_layer_selected(index):
  13. highlight_layer(index)
  14. func highlight_layer(index):
  15. if index == 0 :
  16. #unhighlighting everything
  17. for i in GRID.visual_cells:
  18. for c in i:
  19. if c:
  20. c.modulate.a = 1
  21. return
  22. var signal_num = index - 1
  23. for i in GRID.visual_cells:
  24. for c in i:
  25. if c and c.cell:
  26. c.modulate.a = (c.cell.field_vector[signal_num] + 1)/2
  27. pass
  28. func highlight_selected():
  29. highlight_layer(get_selected_items()[0] if get_selected_items() else 0)