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.

55 lines
1.2 KiB

  1. extends Tabs
  2. var locale
  3. signal locale_changed()
  4. func _ready():
  5. find_node("server_addr").set_text(game_server.get_server_addr())
  6. find_node("api_addr").set_text(game_server.get_api_addr())
  7. _init_locales()
  8. func apply():
  9. config.set_value("system","locale",locale)
  10. var server_addr = find_node("server_addr").get_text()
  11. if server_addr.empty():
  12. server_addr = game_server.SERVER_ADDR
  13. config.set_value("system","server_addr",server_addr)
  14. var api_addr = find_node("api_addr").get_text()
  15. if api_addr.empty():
  16. api_addr = game_server.API_ADDR
  17. config.set_value("system","api_addr",api_addr)
  18. func _on_locales_item_selected(index):
  19. match index:
  20. 0:
  21. locale = "en"
  22. 1:
  23. locale = "de"
  24. _:
  25. locale = "en"
  26. TranslationServer.set_locale(locale)
  27. emit_signal("locale_changed")
  28. func _init_locales():
  29. var locales = find_node("locales")
  30. locales.clear()
  31. locales.add_item(tr("LOCALE_EN"))
  32. locales.add_item(tr("LOCALE_DE"))
  33. locale = config.get_value("system","locale","en")
  34. match locale:
  35. "en":
  36. locales.select(0)
  37. _on_locales_item_selected(0)
  38. "de":
  39. locales.select(1)
  40. _on_locales_item_selected(1)
  41. func _on_system_settings_menu_tree_exiting():
  42. config_apply.apply_locale()