plugin.gd 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # Copyright (C) 2022-2023 John Pennycook
  2. # SPDX-License-Identifier: MIT
  3. @tool
  4. extends EditorPlugin
  5. var inspector_plugin = preload("res://addons/input_prompts/inspector_plugin.gd").new()
  6. func _enter_tree():
  7. add_autoload_singleton("PromptManager", "res://addons/input_prompts/input_prompt_manager.gd")
  8. add_inspector_plugin(inspector_plugin)
  9. if Engine.is_editor_hint():
  10. var deadzone_setting := "addons/input_prompts/joypad_detection_deadzone"
  11. if not ProjectSettings.has_setting(deadzone_setting):
  12. ProjectSettings.set_setting(deadzone_setting, 0.5)
  13. ProjectSettings.set_initial_value(deadzone_setting, 0.5)
  14. ProjectSettings.set_as_basic(deadzone_setting, true)
  15. ProjectSettings.add_property_info(
  16. {
  17. "name": deadzone_setting,
  18. "type": TYPE_FLOAT,
  19. "hint": PROPERTY_HINT_RANGE,
  20. "hint_string": "0,1"
  21. }
  22. )
  23. var icon_settings = {
  24. "addons/input_prompts/icons/keyboard":
  25. "res://addons/input_prompts/key_prompt/keys.tres",
  26. "addons/input_prompts/icons/mouse_buttons":
  27. "res://addons/input_prompts/mouse_button_prompt/buttons.tres",
  28. "addons/input_prompts/icons/joypad_buttons/nintendo":
  29. "res://addons/input_prompts/joypad_button_prompt/nintendo.tres",
  30. "addons/input_prompts/icons/joypad_buttons/sony":
  31. "res://addons/input_prompts/joypad_button_prompt/sony.tres",
  32. "addons/input_prompts/icons/joypad_buttons/xbox":
  33. "res://addons/input_prompts/joypad_button_prompt/xbox.tres",
  34. "addons/input_prompts/icons/joypad_motion/nintendo":
  35. "res://addons/input_prompts/joypad_motion_prompt/nintendo.tres",
  36. "addons/input_prompts/icons/joypad_motion/sony":
  37. "res://addons/input_prompts/joypad_motion_prompt/sony.tres",
  38. "addons/input_prompts/icons/joypad_motion/xbox":
  39. "res://addons/input_prompts/joypad_motion_prompt/xbox.tres",
  40. }
  41. for setting in icon_settings.keys():
  42. var value = icon_settings[setting]
  43. if not ProjectSettings.has_setting(setting):
  44. ProjectSettings.set_setting(setting, value)
  45. ProjectSettings.set_initial_value(setting, value)
  46. ProjectSettings.add_property_info(
  47. {
  48. "name": setting,
  49. "type": TYPE_STRING,
  50. "hint": PROPERTY_HINT_FILE,
  51. "hint_string": "*.tres,*.res"
  52. }
  53. )
  54. ProjectSettings.save()
  55. func _exit_tree():
  56. remove_inspector_plugin(inspector_plugin)
  57. remove_autoload_singleton("PromptManager")