No commits in common. '86a12fd6fd7df13d16b2f1527e26cbb70077a9ae' and 'cafd838dfccbc6f0a3de27c4b0eec0aadaaabee8' have entirely different histories.
86a12fd6fd
...
cafd838dfc
63 changed files with 1058 additions and 591 deletions
-
2.gitignore
-
42ext/server.py
-
33project.godot
-
138resources/ui/i18n.csv
-
BINresources/ui/i18n.de.translation
-
BINresources/ui/i18n.en.translation
-
9resources/ui/theme.tres
-
15scenes/menus/BaseMenu.tscn
-
12scenes/menus/DirectHostMenu.tscn
-
3scenes/menus/DirectJoinMenu.tscn
-
20scenes/menus/IngameMenu.tscn
-
8scenes/menus/LobbyMenu.tscn
-
22scenes/menus/LocalGameMenu.tscn
-
38scenes/menus/MainMenu.tscn
-
24scenes/menus/MultiplayerMenu.tscn
-
11scenes/menus/ServerCreateGameMenu.tscn
-
34scenes/menus/SettingsControlsMenu.tscn
-
163scenes/menus/SettingsMenu.tscn
-
13scenes/menus/SettingsPlayerMenu.tscn
-
47scenes/menus/SettingsSystemMenu.tscn
-
24scenes/player/HumanPlayer.tscn
-
1scenes/player/Player.tscn
-
2scenes/road/roadCornerLarge.tscn
-
4scenes/road/roadCornerLargeFlipped.tscn
-
4scenes/road/roadCornerLarger.tscn
-
4scenes/road/roadCornerLargerFlipped.tscn
-
6scenes/road/roadCornerSmall.tscn
-
6scenes/road/roadCornerSmallFlipped.tscn
-
2scenes/road/roadRamp.tscn
-
2scenes/road/roadRampFlipped.tscn
-
4scenes/road/roadRampLong.tscn
-
2scenes/road/roadRampLongCurved.tscn
-
2scenes/road/roadRampLongFlipped.tscn
-
30scripts/Util.gd
-
28scripts/game/config.gd
-
62scripts/game/config_apply.gd
-
3scripts/game/game.gd
-
58scripts/game/local_storage.gd
-
3scripts/game/route.gd
-
2scripts/menus/direct_host_menu.gd
-
0scripts/menus/direct_join_menu.gd
-
8scripts/menus/ingame_menu.gd
-
0scripts/menus/lobby_menu.gd
-
2scripts/menus/local_game.gd
-
2scripts/menus/main_menu.gd
-
8scripts/menus/server_create_menu.gd
-
2scripts/menus/server_menu.gd
-
67scripts/menus/settings.gd
-
89scripts/menus/settings_controls.gd
-
124scripts/menus/settings_controls_menu.gd
-
116scripts/menus/settings_menu.gd
-
14scripts/menus/settings_player.gd
-
14scripts/menus/settings_player_menu.gd
-
31scripts/networking/game_server.gd
-
8scripts/networking/game_server_requests.gd
-
19scripts/networking/server.gd
-
18scripts/player/base_inventory.gd
-
57scripts/player/bot_controls.gd
-
11scripts/player/human_controls.gd
-
4scripts/player/human_inventory.gd
-
7scripts/player/player.gd
-
15scripts/road/road.gd
@ -0,0 +1,47 @@ |
|||
[gd_scene format=2] |
|||
|
|||
[node name="GridContainer" type="GridContainer"] |
|||
margin_left = 12.0 |
|||
margin_top = 8.0 |
|||
margin_right = 907.0 |
|||
margin_bottom = 124.0 |
|||
columns = 2 |
|||
|
|||
[node name="locale_label" type="Label" parent="."] |
|||
margin_right = 88.0 |
|||
margin_bottom = 14.0 |
|||
text = "LOCALE" |
|||
valign = 1 |
|||
|
|||
[node name="locales" type="ItemList" parent="."] |
|||
margin_left = 92.0 |
|||
margin_right = 895.0 |
|||
margin_bottom = 14.0 |
|||
size_flags_horizontal = 3 |
|||
auto_height = true |
|||
|
|||
[node name="server_addr_label" type="Label" parent="."] |
|||
margin_top = 23.0 |
|||
margin_right = 88.0 |
|||
margin_bottom = 37.0 |
|||
text = "SERVER_ADDR" |
|||
valign = 1 |
|||
|
|||
[node name="server_addr" type="LineEdit" parent="."] |
|||
margin_left = 92.0 |
|||
margin_top = 18.0 |
|||
margin_right = 895.0 |
|||
margin_bottom = 42.0 |
|||
|
|||
[node name="api_addr_label" type="Label" parent="."] |
|||
margin_top = 51.0 |
|||
margin_right = 88.0 |
|||
margin_bottom = 65.0 |
|||
text = "API_ADDR" |
|||
valign = 1 |
|||
|
|||
[node name="api_addr" type="LineEdit" parent="."] |
|||
margin_left = 92.0 |
|||
margin_top = 46.0 |
|||
margin_right = 895.0 |
|||
margin_bottom = 70.0 |
@ -1,12 +1,36 @@ |
|||
extends Node |
|||
|
|||
class_name Util |
|||
var random_number_generator:RandomNumberGenerator = RandomNumberGenerator.new() |
|||
|
|||
|
|||
static func clear_node(node:Node): |
|||
func _ready(): |
|||
random_number_generator.randomize() |
|||
|
|||
|
|||
func randf(): |
|||
return random_number_generator.randf() |
|||
|
|||
|
|||
func randf_range (from:float, to:float ): |
|||
return random_number_generator.randf_range(from,to) |
|||
|
|||
|
|||
func randfn (mean:float=0.0, deviation:float=1.0 ): |
|||
return random_number_generator.randfn(mean, deviation) |
|||
|
|||
|
|||
func randi(): |
|||
return random_number_generator.randi() |
|||
|
|||
|
|||
func randi_range ( from:int, to:int ): |
|||
return random_number_generator.randi_range( from, to) |
|||
|
|||
|
|||
func clear_node(node:Node): |
|||
for idx in range(node.get_child_count()): |
|||
node.remove_child(node.get_child(0)) |
|||
|
|||
|
|||
static func curve_get_last_point(curve:Curve3D): |
|||
func curve_get_last_point(curve:Curve3D): |
|||
return curve.get_point_position(curve.get_point_count() - 1) |
@ -0,0 +1,28 @@ |
|||
extends Node |
|||
|
|||
const FILE_PATH = "user://local_storage" |
|||
|
|||
const RESOLUTIONS = [Vector2(1920,1080),Vector2(1600,900),Vector2(1366,758),Vector2(1280,720),Vector2(1136,640),Vector2(1024,576)] |
|||
|
|||
const CONTROL_ACTIONS = ["controls_thrust", "controls_break", "controls_add_road", "controls_next_road_type", "controls_prev_road_type", "controls_next_road_variant", "controls_prev_road_variant", "controls_reset", "controls_menu"] |
|||
|
|||
const INPUT_UI_MAPPING = {"ui_accept" : "controls_add_road", "ui_select" : "controls_add_road", "ui_up" : "controls_next_road_variant", "ui_down" : "controls_prev_road_variant", "ui_left" : "controls_prev_road_type", "ui_right" : "controls_next_road_type"} |
|||
|
|||
var config_file:ConfigFile = ConfigFile.new() |
|||
|
|||
|
|||
|
|||
func _ready(): |
|||
config_file.load(FILE_PATH) |
|||
|
|||
|
|||
func save(): |
|||
config_file.save(FILE_PATH) |
|||
|
|||
|
|||
func get_value(section:String, key:String, default = null): |
|||
return config_file.get_value(section,key,default) |
|||
|
|||
|
|||
func set_value(section:String, key:String, value): |
|||
config_file.set_value(section,key,value) |
@ -0,0 +1,62 @@ |
|||
extends Node |
|||
|
|||
const FILE_PATH = "user://local_storage" |
|||
|
|||
|
|||
|
|||
func _ready(): |
|||
apply_settings() |
|||
|
|||
|
|||
func apply_settings(): |
|||
apply_locale() |
|||
apply_game_server() |
|||
apply_resolution() |
|||
apply_controls() |
|||
|
|||
|
|||
func apply_locale(): |
|||
TranslationServer.set_locale(config.get_value("system","locale","en")) |
|||
|
|||
|
|||
func apply_game_server(): |
|||
var server_addr = config.get_value("game_server", "server_addr") |
|||
if server_addr != null && not server_addr.empty(): |
|||
game_server.set_server_addr(server_addr) |
|||
var api_addr = config.get_value("game_server","api_addr") |
|||
if api_addr != null && not api_addr.empty(): |
|||
game_server.set_api_addr(api_addr) |
|||
|
|||
|
|||
func apply_resolution(): |
|||
var view_port = get_tree().get_root() |
|||
OS.set_window_fullscreen(config.get_value("graphics","fullscreen", true)) |
|||
|
|||
var resolution = config.get_value("graphics","resolution",config.RESOLUTIONS[0]) |
|||
if OS.is_window_fullscreen(): |
|||
var base_size = Vector2(1920, 1080) |
|||
var scale= base_size.x / resolution.x |
|||
get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_2D,SceneTree.STRETCH_ASPECT_EXPAND,base_size,scale) |
|||
else: |
|||
OS.set_window_size(resolution) |
|||
get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_VIEWPORT,SceneTree.STRETCH_ASPECT_IGNORE,OS.get_window_size(),1) |
|||
|
|||
|
|||
func apply_controls(): |
|||
InputMap.load_from_globals() |
|||
var control_map = config.get_value("controls","mapping",{}) |
|||
for action in InputMap.get_actions(): |
|||
if control_map.has(action): |
|||
for event in InputMap.get_action_list(action): |
|||
if event is InputEventKey && control_map[action].has("key"): |
|||
InputMap.action_erase_event(action, event) |
|||
event.set_scancode(OS.find_scancode_from_string(control_map[action]["key"])) |
|||
InputMap.action_add_event(action,event) |
|||
elif event is InputEventJoypadButton && control_map[action].has("joypad"): |
|||
InputMap.action_erase_event(action, event) |
|||
event.set_button_index(control_map[action]["joypad"]) |
|||
InputMap.action_add_event(action,event) |
|||
|
|||
for ui_mapping in config.INPUT_UI_MAPPING: |
|||
for event in InputMap.get_action_list(config.INPUT_UI_MAPPING[ui_mapping]): |
|||
InputMap.action_add_event(ui_mapping, event) |
@ -1,58 +0,0 @@ |
|||
extends Node |
|||
|
|||
const FILE_PATH = "user://local_storage" |
|||
|
|||
|
|||
func _ready(): |
|||
TranslationServer.set_locale(read_value("locale","en")) |
|||
|
|||
|
|||
func read_content(): |
|||
var f = File.new() |
|||
var err = f.open(FILE_PATH, File.READ) |
|||
var content = {} |
|||
if err == OK: |
|||
content = parse_json(f.get_as_text()) |
|||
f.close() |
|||
if content == null: |
|||
content = {} |
|||
return content |
|||
|
|||
|
|||
func write_content(content:Dictionary): |
|||
var f = File.new() |
|||
var err = f.open(FILE_PATH, File.WRITE) |
|||
#var err = f.open_encrypted_with_pass(FILE_PATH, File.WRITE, OS.get_unique_id()) |
|||
f.store_string(to_json(content)) |
|||
f.close() |
|||
|
|||
|
|||
func write_value(key:String, value): |
|||
var content = read_content() |
|||
content[key] = value |
|||
write_content(content) |
|||
|
|||
|
|||
func read_value(key:String, default = null): |
|||
var content = read_content() |
|||
if content.has(key) && content.get(key) != null: |
|||
return content.get(key) |
|||
else: |
|||
return default |
|||
|
|||
|
|||
func delete_value(key:String): |
|||
var content = read_content() |
|||
content.erase(key) |
|||
write_content(content) |
|||
|
|||
|
|||
func write_values(new_content:Dictionary): |
|||
var content = read_content() |
|||
for key in new_content: |
|||
content[key] = new_content[key] |
|||
write_content(content) |
|||
|
|||
|
|||
func read_values(): |
|||
return read_content() |
@ -1,67 +0,0 @@ |
|||
extends Control |
|||
|
|||
onready var player_settings = find_node("settings_player") |
|||
onready var game_tab = find_node("game") |
|||
onready var controls_tab = find_node("controls") |
|||
onready var graphics_tab = find_node("graphics") |
|||
onready var system_tab = find_node("system") |
|||
|
|||
var locale |
|||
|
|||
|
|||
func _ready(): |
|||
get_node("menu/back").connect("pressed",self,"_on_back_pressed") |
|||
find_node("bots").set_pressed(local_storage.read_value("bots", true)) |
|||
game_tab.set_name(tr("GAME")) |
|||
controls_tab.set_name(tr("CONTROLS")) |
|||
graphics_tab.set_name(tr("GRAPHICS")) |
|||
system_tab.set_name(tr("SYSTEM")) |
|||
|
|||
|
|||
func _on_back_pressed(): |
|||
queue_free() |
|||
get_tree().get_root().get_node("main_menu").show() |
|||
|
|||
|
|||
func _on_locales_item_selected(index): |
|||
match index: |
|||
0: |
|||
locale = "en" |
|||
1: |
|||
locale = "de" |
|||
_: |
|||
locale = "en" |
|||
TranslationServer.set_locale(locale) |
|||
game_tab.set_name(tr("GAME")) |
|||
controls_tab.set_name(tr("CONTROLS")) |
|||
graphics_tab.set_name(tr("GRAPHICS")) |
|||
system_tab.set_name(tr("SYSTEM")) |
|||
|
|||
|
|||
func _init_locales(): |
|||
var locales = find_node("locales") |
|||
locales.clear() |
|||
locales.add_item(tr("LOCALE_EN")) |
|||
locales.add_item(tr("LOCALE_DE")) |
|||
locale = local_storage.read_value("locale","en") |
|||
match locale: |
|||
"en": |
|||
locales.select(0) |
|||
_on_locales_item_selected(0) |
|||
"de": |
|||
locales.select(1) |
|||
_on_locales_item_selected(1) |
|||
|
|||
|
|||
func _on_locales_tree_exiting(): |
|||
TranslationServer.set_locale(local_storage.read_value("locale","en")) |
|||
|
|||
|
|||
func _on_save_pressed(): |
|||
var values = {} |
|||
values['player_name'] = player_settings.get_name_node().text |
|||
values['player_color'] = player_settings.get_color_node().color.to_html() |
|||
values['bots'] = find_node("bots").is_pressed() |
|||
values['locale'] = locale |
|||
local_storage.write_values(values) |
|||
_on_back_pressed() |
@ -1,89 +0,0 @@ |
|||
tool |
|||
|
|||
extends Control |
|||
|
|||
onready var grid = find_node("grid") |
|||
onready var key_dialog = get_node("key_dialog") |
|||
|
|||
const INPUT_TYPE_KEY = 0 |
|||
const INPUT_TYPE_JOYPAD = 1 |
|||
|
|||
var last_action:String |
|||
var last_event:InputEvent |
|||
|
|||
var new_inputs = {} |
|||
|
|||
func _ready(): |
|||
init_mapping() |
|||
|
|||
|
|||
func init_mapping(): |
|||
new_inputs = {} |
|||
for action in InputMap.get_actions(): |
|||
if action.begins_with("controls_"): |
|||
var action_label = Label.new() |
|||
action_label.set_name(action + "_label") |
|||
action_label.set_text(action) |
|||
grid.add_child(action_label) |
|||
|
|||
var key_action_button = Button.new() |
|||
key_action_button.set_h_size_flags(SIZE_SHRINK_CENTER) |
|||
key_action_button.set_flat(true) |
|||
key_action_button.set_meta("action",action) |
|||
key_action_button.set_button_icon(get_node("icons/key").get_button_icon()) |
|||
|
|||
var joypad_action_button = Button.new() |
|||
joypad_action_button.set_h_size_flags(SIZE_SHRINK_CENTER) |
|||
joypad_action_button.set_flat(true) |
|||
joypad_action_button.set_meta("action",action) |
|||
|
|||
for mapping in InputMap.get_action_list(action): |
|||
if mapping is InputEventKey: |
|||
key_action_button.set_text(mapping.as_text()) |
|||
key_action_button.set_tooltip(mapping.as_text()) |
|||
elif mapping is InputEventJoypadButton: |
|||
joypad_action_button.set_tooltip(str(mapping.button_index)) |
|||
if has_node("icons/joypad/" + str(mapping.button_index)): |
|||
joypad_action_button.set_button_icon(get_node("icons/joypad/" + str(mapping.button_index)).get_button_icon()) |
|||
else: |
|||
joypad_action_button.set_button_icon(get_node("icons/joypad/other").get_button_icon()) |
|||
joypad_action_button.set_text(str(mapping.button_index)) |
|||
|
|||
grid.add_child(key_action_button) |
|||
key_action_button.connect("pressed",self,"_on_button_pressed",[action, INPUT_TYPE_KEY]) |
|||
|
|||
grid.add_child(joypad_action_button) |
|||
joypad_action_button.connect("pressed",self,"_on_button_pressed",[action, INPUT_TYPE_JOYPAD]) |
|||
|
|||
func _unhandled_input(event): |
|||
if key_dialog.is_visible_in_tree(): |
|||
if key_dialog.get_meta("type") == INPUT_TYPE_KEY && event is InputEventKey: |
|||
last_event = event |
|||
key_dialog.set_text(tr(last_event.as_text())) |
|||
key_dialog.get_ok().set_disabled(false) |
|||
elif key_dialog.get_meta("type") == INPUT_TYPE_JOYPAD && event is InputEventJoypadButton: |
|||
last_event = event |
|||
key_dialog.set_text(last_event.as_text()) |
|||
key_dialog.get_ok().set_disabled(false) |
|||
|
|||
|
|||
func _on_button_pressed(action, type): |
|||
last_action = action |
|||
last_event = null |
|||
key_dialog.set_text(tr("PRESS_KEY")) |
|||
key_dialog.set_meta("type", type) |
|||
key_dialog.connect("confirmed",self,"_on_dialog_confirmed") |
|||
key_dialog.get_ok().set_disabled(true) |
|||
key_dialog.popup_centered() |
|||
|
|||
|
|||
func _on_dialog_confirmed(type): |
|||
if not new_inputs.has(last_action): |
|||
new_inputs[last_action] = {} |
|||
match key_dialog.get_meta("type"): |
|||
INPUT_TYPE_KEY: |
|||
if last_event is InputEventKey: |
|||
new_inputs[last_action]["key"] = OS.get_scancode_string(last_event.scancode) |
|||
INPUT_TYPE_JOYPAD: |
|||
if last_event is InputEventJoypadButton: |
|||
new_inputs[last_action]["joypad"] = last_event.button_index |
@ -0,0 +1,124 @@ |
|||
extends Control |
|||
|
|||
onready var grid = find_node("grid") |
|||
onready var key_dialog = get_node("key_dialog") |
|||
|
|||
const INPUT_TYPE_KEY = 0 |
|||
const INPUT_TYPE_JOYPAD = 1 |
|||
|
|||
var last_action:String |
|||
var last_event:InputEvent |
|||
|
|||
var new_inputs = {} |
|||
|
|||
|
|||
func _ready(): |
|||
init_mapping() |
|||
|
|||
|
|||
func init_mapping(): |
|||
new_inputs = {} |
|||
for action in config.CONTROL_ACTIONS: |
|||
var action_label = Label.new() |
|||
action_label.set_name(action + "_label") |
|||
action_label.set_text(action) |
|||
grid.add_child(action_label) |
|||
|
|||
var key_action_button = Button.new() |
|||
key_action_button.set_h_size_flags(SIZE_SHRINK_CENTER) |
|||
key_action_button.set_flat(true) |
|||
key_action_button.set_meta("action",action) |
|||
key_action_button.set_button_icon(get_node("icons/key").get_button_icon()) |
|||
|
|||
var joypad_action_button = Button.new() |
|||
joypad_action_button.set_h_size_flags(SIZE_SHRINK_CENTER) |
|||
joypad_action_button.set_flat(true) |
|||
joypad_action_button.set_meta("action",action) |
|||
|
|||
for event in InputMap.get_action_list(action): |
|||
if event is InputEventKey: |
|||
key_action_button.set_text(event.as_text()) |
|||
key_action_button.set_tooltip(event.as_text()) |
|||
elif event is InputEventJoypadButton: |
|||
joypad_action_button.set_tooltip(str(event.button_index)) |
|||
if has_node("icons/joypad/" + str(event.button_index)): |
|||
joypad_action_button.set_button_icon(get_node("icons/joypad/" + str(event.button_index)).get_button_icon()) |
|||
else: |
|||
joypad_action_button.set_button_icon(get_node("icons/joypad/other").get_button_icon()) |
|||
joypad_action_button.set_text(str(event.button_index)) |
|||
|
|||
grid.add_child(key_action_button) |
|||
key_action_button.connect("pressed",self,"_on_button_pressed",[key_action_button, INPUT_TYPE_KEY]) |
|||
|
|||
grid.add_child(joypad_action_button) |
|||
joypad_action_button.connect("pressed",self,"_on_button_pressed",[joypad_action_button, INPUT_TYPE_JOYPAD]) |
|||
|
|||
|
|||
func _unhandled_input(event): |
|||
if key_dialog.is_visible_in_tree(): |
|||
var action_button = key_dialog.find_node("action_button") |
|||
var check_usage = false |
|||
if key_dialog.get_meta("type") == INPUT_TYPE_KEY && event is InputEventKey: |
|||
check_usage = true |
|||
last_event = event |
|||
action_button.set_button_icon(get_node("icons/key").get_button_icon()) |
|||
action_button.set_text(event.as_text()) |
|||
action_button.set_tooltip(event.as_text()) |
|||
elif key_dialog.get_meta("type") == INPUT_TYPE_JOYPAD && event is InputEventJoypadButton: |
|||
check_usage = true |
|||
last_event = event |
|||
action_button.set_tooltip(str(event.button_index)) |
|||
if has_node("icons/joypad/" + str(event.button_index)): |
|||
action_button.set_text("") |
|||
action_button.set_button_icon(get_node("icons/joypad/" + str(event.button_index)).get_button_icon()) |
|||
else: |
|||
action_button.set_button_icon(get_node("icons/joypad/other").get_button_icon()) |
|||
action_button.set_text(str(event.button_index)) |
|||
|
|||
if check_usage: |
|||
var has_event = "" |
|||
for action in config.CONTROL_ACTIONS: |
|||
if InputMap.event_is_action(event, action): |
|||
has_event = action |
|||
|
|||
if not has_event == "" && not has_event == last_action: |
|||
key_dialog.set_text(tr("KEY_ALREADY_TAKEN") + '\n\'' + tr(has_event) + '\'') |
|||
key_dialog.get_ok().set_disabled(true) |
|||
else: |
|||
key_dialog.set_text(tr("PRESS_KEY")) |
|||
key_dialog.get_ok().set_disabled(false) |
|||
|
|||
|
|||
func _on_button_pressed(button, type): |
|||
last_action = button.get_meta("action") |
|||
last_event = null |
|||
|
|||
var action_button = key_dialog.find_node("action_button") |
|||
action_button.set_text("") |
|||
action_button.set_button_icon(null) |
|||
key_dialog.set_text(tr("PRESS_KEY")) |
|||
key_dialog.set_meta("type", type) |
|||
key_dialog.connect("confirmed",self,"_on_dialog_confirmed",[button]) |
|||
key_dialog.get_ok().set_disabled(true) |
|||
key_dialog.get_label().set_align(HALIGN_CENTER) |
|||
key_dialog.popup_centered() |
|||
|
|||
|
|||
func _on_dialog_confirmed(button): |
|||
if not new_inputs.has(last_action): |
|||
new_inputs[last_action] = {} |
|||
match key_dialog.get_meta("type"): |
|||
INPUT_TYPE_KEY: |
|||
if last_event is InputEventKey: |
|||
new_inputs[last_action]["key"] = OS.get_scancode_string(last_event.scancode) |
|||
button.set_text(last_event.as_text()) |
|||
button.set_tooltip(last_event.as_text()) |
|||
INPUT_TYPE_JOYPAD: |
|||
if last_event is InputEventJoypadButton: |
|||
new_inputs[last_action]["joypad"] = last_event.button_index |
|||
button.set_tooltip(str(last_event.button_index)) |
|||
if has_node("icons/joypad/" + str(last_event.button_index)): |
|||
button.set_button_icon(get_node("icons/joypad/" + str(last_event.button_index)).get_button_icon()) |
|||
else: |
|||
button.set_button_icon(get_node("icons/joypad/other").get_button_icon()) |
|||
button.set_text(str(last_event.button_index)) |
@ -0,0 +1,116 @@ |
|||
extends Control |
|||
|
|||
onready var player_settings = find_node("settings_player") |
|||
onready var game_tab = find_node("game") |
|||
onready var controls_tab = find_node("controls") |
|||
onready var graphics_tab = find_node("graphics") |
|||
onready var system_tab = find_node("system") |
|||
|
|||
var locale |
|||
|
|||
|
|||
func _ready(): |
|||
get_node("menu/back").connect("pressed",self,"_on_back_pressed") |
|||
|
|||
# game |
|||
find_node("bots").set_pressed(config.get_value("game","bots", true)) |
|||
|
|||
# graphics |
|||
find_node("fullscreen").set_pressed(config.get_value("graphics","fullscreen", true)) |
|||
find_node("light").set_pressed(config.get_value("graphics","light", false)) |
|||
find_node("shadows").set_pressed(config.get_value("graphics","shadows", false)) |
|||
find_node("shadows").set_disabled(not find_node("light").is_pressed()) |
|||
|
|||
for resolution in config.RESOLUTIONS: |
|||
find_node("resolution").add_item(str(resolution.x) + " * " + str(resolution.y)) |
|||
|
|||
find_node("resolution").select(config.RESOLUTIONS.find(config.get_value("graphics","resolution", config.RESOLUTIONS[0]))) |
|||
|
|||
# system |
|||
find_node("server_addr").set_text(game_server.get_server_addr()) |
|||
find_node("api_addr").set_text(game_server.get_api_addr()) |
|||
_init_locales() |
|||
|
|||
|
|||
func _draw(): |
|||
game_tab.grab_focus() |
|||
|
|||
|
|||
func _on_back_pressed(): |
|||
queue_free() |
|||
get_tree().get_root().get_node("main_menu").show() |
|||
|
|||
|
|||
func _on_locales_item_selected(index): |
|||
match index: |
|||
0: |
|||
locale = "en" |
|||
1: |
|||
locale = "de" |
|||
_: |
|||
locale = "en" |
|||
TranslationServer.set_locale(locale) |
|||
game_tab.set_name(tr("GAME")) |
|||
controls_tab.set_name(tr("CONTROLS")) |
|||
graphics_tab.set_name(tr("GRAPHICS")) |
|||
system_tab.set_name(tr("SYSTEM")) |
|||
|
|||
|
|||
func _init_locales(): |
|||
var locales = find_node("locales") |
|||
locales.clear() |
|||
locales.add_item(tr("LOCALE_EN")) |
|||
locales.add_item(tr("LOCALE_DE")) |
|||
locale = config.get_value("system","locale","en") |
|||
match locale: |
|||
"en": |
|||
locales.select(0) |
|||
_on_locales_item_selected(0) |
|||
"de": |
|||
locales.select(1) |
|||
_on_locales_item_selected(1) |
|||
|
|||
|
|||
func _on_locales_tree_exiting(): |
|||
config_apply.apply_locale() |
|||
|
|||
|
|||
func _on_save_pressed(): |
|||
_on_apply_pressed() |
|||
_on_back_pressed() |
|||
|
|||
|
|||
func _on_apply_pressed(): |
|||
# game |
|||
config.set_value("game","player_name",player_settings.get_name_node().get_text()) |
|||
config.set_value("game","player_color",player_settings.get_color_node().color) |
|||
config.set_value("game","bots",find_node("bots").is_pressed()) |
|||
|
|||
# graphics |
|||
config.set_value("graphics","resolution",config.RESOLUTIONS[find_node("resolution").get_selected()]) |
|||
config.set_value("graphics","fullscreen",find_node("fullscreen").is_pressed()) |
|||
config.set_value("graphics","light",find_node("light").is_pressed()) |
|||
config.set_value("graphics","shadows",find_node("shadows").is_pressed()) |
|||
|
|||
# controls |
|||
config.set_value("controls","mapping",find_node("settings_controls").new_inputs) |
|||
|
|||
# system |
|||
config.set_value("system","locale",locale) |
|||
var server_addr = find_node("server_addr").get_text() |
|||
if server_addr.empty(): |
|||
server_addr = game_server.SERVER_ADDR |
|||
config.set_value("system","server_addr",server_addr) |
|||
|
|||
var api_addr = find_node("api_addr").get_text() |
|||
if api_addr.empty(): |
|||
api_addr = game_server.API_ADDR |
|||
config.set_value("system","api_addr",api_addr) |
|||
|
|||
config.save() |
|||
|
|||
config_apply.apply_settings() |
|||
|
|||
|
|||
func _on_light_toggled(button_pressed): |
|||
find_node("shadows").set_disabled(not button_pressed) |
@ -1,14 +0,0 @@ |
|||
extends Control |
|||
|
|||
|
|||
func _ready(): |
|||
get_name_node().set_text(local_storage.read_value("player_name", "Player")) |
|||
get_color_node().set_pick_color(Color(local_storage.read_value("player_color", "#000000"))) |
|||
|
|||
|
|||
func get_name_node(): |
|||
return find_node("name") |
|||
|
|||
|
|||
func get_color_node(): |
|||
return find_node("color") |
@ -0,0 +1,14 @@ |
|||
extends Control |
|||
|
|||
|
|||
func _ready(): |
|||
get_name_node().set_text(config.get_value("game","player_name", "Player")) |
|||
get_color_node().set_pick_color(config.get_value("game","player_color", Color.black)) |
|||
|
|||
|
|||
func get_name_node(): |
|||
return find_node("name") |
|||
|
|||
|
|||
func get_color_node(): |
|||
return find_node("color") |
Write
Preview
Loading…
Cancel
Save
Reference in new issue