mouse_button_textures.gd 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (C) 2022-2023 John Pennycook
  2. # SPDX-License-Identifier: MIT
  3. @tool
  4. class_name MouseButtonTextures
  5. extends Resource
  6. ## Textures used by a [MouseButtonPrompt] or [ActionPrompt].
  7. ##
  8. ## Textures used by a [MouseButtonPrompt] or [ActionPrompt]. Stores a texture
  9. ## for each mouse button index.
  10. ## Texture for Left Mouse Button.
  11. @export var button_1: Texture2D = null
  12. ## Texture for Right Mouse Button.
  13. @export var button_2: Texture2D = null
  14. ## Texture for Middle Mouse Button.
  15. @export var button_3: Texture2D = null
  16. ## Texture for Mouse Wheel Up.
  17. @export var button_4: Texture2D = null
  18. ## Texture for Mouse Wheel Down.
  19. @export var button_5: Texture2D = null
  20. ## Texture for Mouse Wheel Left.
  21. @export var button_6: Texture2D = null
  22. ## Texture for Mouse Wheel Right.
  23. @export var button_7: Texture2D = null
  24. ## Texture for Mouse Thumb Button 1.
  25. @export var button_8: Texture2D = null
  26. ## Texture for Mouse Thumb Button 2.
  27. @export var button_9: Texture2D = null
  28. ## Return the [Texture2D] associated with the specified [InputEvent], or null.
  29. func get_texture(event: InputEvent) -> Texture2D:
  30. if not event is InputEventMouseButton:
  31. return null
  32. var mouse_event := event as InputEventMouseButton
  33. var button := mouse_event.button_index
  34. return get("button_" + str(button))