Public repository for MUR pre alpha
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

115 lines
3.2 KiB

  1. extends Control
  2. onready var player_settings = find_node("settings_player")
  3. onready var game_tab = find_node("game")
  4. onready var controls_tab = find_node("controls")
  5. onready var graphics_tab = find_node("graphics")
  6. onready var system_tab = find_node("system")
  7. var locale
  8. func _ready():
  9. get_node("menu/back").connect("pressed",self,"_on_back_pressed")
  10. # game
  11. find_node("bots").set_pressed(config.get_value("game","bots", true))
  12. # graphics
  13. find_node("fullscreen").set_pressed(config.get_value("graphics","fullscreen", true))
  14. find_node("light").set_pressed(config.get_value("graphics","light", false))
  15. find_node("shadows").set_pressed(config.get_value("graphics","shadows", false))
  16. find_node("shadows").set_disabled(not find_node("light").is_pressed())
  17. for resolution in config.RESOLUTIONS:
  18. find_node("resolution").add_item(str(resolution.x) + " * " + str(resolution.y))
  19. find_node("resolution").select(config.RESOLUTIONS.find(config.get_value("graphics","resolution", config.RESOLUTIONS[0])))
  20. # system
  21. find_node("server_addr").set_text(game_server.get_server_addr())
  22. find_node("api_addr").set_text(game_server.get_api_addr())
  23. _init_locales()
  24. func _draw():
  25. game_tab.grab_focus()
  26. func _on_back_pressed():
  27. queue_free()
  28. get_tree().get_root().get_node("main_menu").show()
  29. func _on_locales_item_selected(index):
  30. match index:
  31. 0:
  32. locale = "en"
  33. 1:
  34. locale = "de"
  35. _:
  36. locale = "en"
  37. TranslationServer.set_locale(locale)
  38. game_tab.set_name(tr("GAME"))
  39. controls_tab.set_name(tr("CONTROLS"))
  40. graphics_tab.set_name(tr("GRAPHICS"))
  41. system_tab.set_name(tr("SYSTEM"))
  42. func _init_locales():
  43. var locales = find_node("locales")
  44. locales.clear()
  45. locales.add_item(tr("LOCALE_EN"))
  46. locales.add_item(tr("LOCALE_DE"))
  47. locale = config.get_value("system","locale","en")
  48. match locale:
  49. "en":
  50. locales.select(0)
  51. _on_locales_item_selected(0)
  52. "de":
  53. locales.select(1)
  54. _on_locales_item_selected(1)
  55. func _on_locales_tree_exiting():
  56. config_apply.apply_locale()
  57. func _on_save_pressed():
  58. _on_apply_pressed()
  59. _on_back_pressed()
  60. func _on_apply_pressed():
  61. # game
  62. config.set_value("game","player_name",player_settings.get_name_node().get_text())
  63. config.set_value("game","player_color",player_settings.get_color_node().color)
  64. config.set_value("game","bots",find_node("bots").is_pressed())
  65. # graphics
  66. config.set_value("graphics","resolution",config.RESOLUTIONS[find_node("resolution").get_selected()])
  67. config.set_value("graphics","fullscreen",find_node("fullscreen").is_pressed())
  68. config.set_value("graphics","light",find_node("light").is_pressed())
  69. config.set_value("graphics","shadows",find_node("shadows").is_pressed())
  70. # controls
  71. config.set_value("controls","mapping",find_node("settings_controls").new_inputs)
  72. # system
  73. config.set_value("system","locale",locale)
  74. var server_addr = find_node("server_addr").get_text()
  75. if server_addr.empty():
  76. server_addr = game_server.SERVER_ADDR
  77. config.set_value("system","server_addr",server_addr)
  78. var api_addr = find_node("api_addr").get_text()
  79. if api_addr.empty():
  80. api_addr = game_server.API_ADDR
  81. config.set_value("system","api_addr",api_addr)
  82. config.save()
  83. config_apply.apply_settings()
  84. func _on_light_toggled(button_pressed):
  85. find_node("shadows").set_disabled(not button_pressed)