Guest User

Untitled

a guest
Jun 19th, 2024
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends Control
  2.  
  3. var item: String
  4. var icon: String
  5. var available: bool = false
  6.  
  7. var is_focused: bool = false
  8.  
  9. # Set the icon and item name for other nodes to refrence
  10. func _ready():
  11.     if item in Inventory.recipies_dict:
  12.         %TextureRect.texture = load(Inventory.item_dict[item]["Icon"])
  13.  
  14.     else:
  15.         self.queue_free()
  16.  
  17.     if !available:
  18.         $"Panel".theme = load("res://Assets/UI/Ui_Theme_Inactive.tres")
  19.  
  20. func _process(delta):
  21.     # print(is_focused)
  22.     if is_focused:
  23.         self.get_parent().owner._set_craftable(item)
  24.         self.scale = Vector2(1.08, 1.08)
  25.     else:
  26.         self.scale = Vector2.ONE
  27. # Detect Focus
  28.     # TODO: Fix border color change, currently crashes. maybe use animation?
  29.     # $"Panel".add_theme_stylebox_override("Panel/styles/panel", Globals.Color_NearWhite)
  30.     # $"Panel".add_theme_stylebox_override("border_color", Globals.Color_NearBlack)
  31.  
  32. func _on_focus_entered():
  33.     is_focused = true
  34.     print(item + " Is focused")
  35.  
  36. func _on_focus_exited():
  37.     print(item + " unfocused")
  38.     is_focused = false
  39.  
  40. func _on_mouse_entered():
  41.     self.grab_focus()
  42.    
  43.  
Advertisement
Add Comment
Please, Sign In to add comment