diff --git a/project.godot b/project.godot index 506edfd..d5628ae 100644 --- a/project.godot +++ b/project.godot @@ -86,9 +86,17 @@ client="*res://scripts/networking/client.gd" server="*res://scripts/networking/server.gd" game_server="*res://scripts/networking/game_server.gd" roads_factory="*res://scripts/road/roads_factory.gd" -local_storage="*res://scripts/game/local_storage.gd" +settings="*res://scripts/game/settings.gd" Util="*res://scripts/Util.gd" +[display] + +window/size/width=1920 +window/size/height=1080 +window/size/resizable=false +window/stretch/mode="2d" +window/stretch/aspect="expand" + [input] ui_cancel={ diff --git a/scenes/menus/DirectHostMenu.tscn b/scenes/menus/DirectHostMenu.tscn index 361bc0f..1b380bc 100644 --- a/scenes/menus/DirectHostMenu.tscn +++ b/scenes/menus/DirectHostMenu.tscn @@ -1,11 +1,12 @@ [gd_scene load_steps=6 format=2] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] -[ext_resource path="res://scripts/menus/direct_host.gd" type="Script" id=2] +[ext_resource path="res://scripts/menus/direct_host_menu.gd" type="Script" id=2] [ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=3] [ext_resource path="res://assets/icons/exitRight.png" type="Texture" id=4] [ext_resource path="res://assets/icons/return.png" type="Texture" id=5] + [node name="direct_host_menu" type="Control"] anchor_left = 0.5 anchor_top = 0.5 diff --git a/scenes/menus/DirectJoinMenu.tscn b/scenes/menus/DirectJoinMenu.tscn index cfd6fb2..0fa3f78 100644 --- a/scenes/menus/DirectJoinMenu.tscn +++ b/scenes/menus/DirectJoinMenu.tscn @@ -1,11 +1,12 @@ [gd_scene load_steps=6 format=2] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] -[ext_resource path="res://scripts/menus/direct_join.gd" type="Script" id=2] +[ext_resource path="res://scripts/menus/direct_join_menu.gd" type="Script" id=2] [ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=3] [ext_resource path="res://assets/icons/exitRight.png" type="Texture" id=4] [ext_resource path="res://assets/icons/return.png" type="Texture" id=5] + [node name="direct_join_menu" type="Control"] anchor_left = 0.5 anchor_top = 0.5 diff --git a/scenes/menus/IngameMenu.tscn b/scenes/menus/IngameMenu.tscn index b4804c9..293f188 100644 --- a/scenes/menus/IngameMenu.tscn +++ b/scenes/menus/IngameMenu.tscn @@ -1,11 +1,12 @@ [gd_scene load_steps=6 format=2] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] -[ext_resource path="res://scripts/menus/ingame.gd" type="Script" id=2] +[ext_resource path="res://scripts/menus/ingame_menu.gd" type="Script" id=2] [ext_resource path="res://assets/icons/open.png" type="Texture" id=3] [ext_resource path="res://assets/icons/wrench.png" type="Texture" id=4] [ext_resource path="res://assets/icons/arrowLeft.png" type="Texture" id=5] + [node name="ingame_menu" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 diff --git a/scenes/menus/LobbyMenu.tscn b/scenes/menus/LobbyMenu.tscn index 1f28f51..fb6f5ca 100644 --- a/scenes/menus/LobbyMenu.tscn +++ b/scenes/menus/LobbyMenu.tscn @@ -1,13 +1,14 @@ [gd_scene load_steps=9 format=2] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] -[ext_resource path="res://scripts/menus/lobby.gd" type="Script" id=2] +[ext_resource path="res://scripts/menus/lobby_menu.gd" type="Script" id=2] [ext_resource path="res://scenes/menus/BaseMenu.tscn" type="PackedScene" id=3] [ext_resource path="res://assets/icons/checkmark.png" type="Texture" id=4] [ext_resource path="res://assets/icons/question.png" type="Texture" id=5] [ext_resource path="res://scenes/menus/SettingsPlayerMenu.tscn" type="PackedScene" id=6] [ext_resource path="res://assets/fonts/Kenney Future Narrow.ttf" type="DynamicFontData" id=7] + [sub_resource type="DynamicFont" id=1] size = 100 font_data = ExtResource( 7 ) diff --git a/scenes/menus/MainMenu.tscn b/scenes/menus/MainMenu.tscn index a46b137..6fe01eb 100644 --- a/scenes/menus/MainMenu.tscn +++ b/scenes/menus/MainMenu.tscn @@ -1,13 +1,14 @@ [gd_scene load_steps=8 format=2] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] -[ext_resource path="res://scripts/menus/main.gd" type="Script" id=2] +[ext_resource path="res://scripts/menus/main_menu.gd" type="Script" id=2] [ext_resource path="res://assets/icons/massiveMultiplayer.png" type="Texture" id=3] [ext_resource path="res://assets/icons/singleplayer.png" type="Texture" id=4] [ext_resource path="res://assets/icons/wrench.png" type="Texture" id=5] [ext_resource path="res://assets/icons/power.png" type="Texture" id=6] [ext_resource path="res://assets/icons/question.png" type="Texture" id=7] + [node name="main_menu" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 diff --git a/scenes/menus/MultiplayerMenu.tscn b/scenes/menus/MultiplayerMenu.tscn index 8ffcabf..6a0e8d8 100644 --- a/scenes/menus/MultiplayerMenu.tscn +++ b/scenes/menus/MultiplayerMenu.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=11 format=2] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] -[ext_resource path="res://scripts/menus/server.gd" type="Script" id=2] +[ext_resource path="res://scripts/menus/server_menu.gd" type="Script" id=2] [ext_resource path="res://scenes/menus/BaseMenu.tscn" type="PackedScene" id=3] [ext_resource path="res://assets/icons/cpu.png" type="Texture" id=4] [ext_resource path="res://assets/icons/exitRight.png" type="Texture" id=5] @@ -11,6 +11,7 @@ [ext_resource path="res://assets/icons/massiveMultiplayer.png" type="Texture" id=9] [ext_resource path="res://assets/icons/fistPlus.png" type="Texture" id=10] + [node name="multiplayer_menu" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 diff --git a/scenes/menus/ServerCreateGameMenu.tscn b/scenes/menus/ServerCreateGameMenu.tscn index 5b6da4b..c096d46 100644 --- a/scenes/menus/ServerCreateGameMenu.tscn +++ b/scenes/menus/ServerCreateGameMenu.tscn @@ -1,11 +1,12 @@ [gd_scene load_steps=6 format=2] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] -[ext_resource path="res://scripts/menus/server_create.gd" type="Script" id=2] +[ext_resource path="res://scripts/menus/server_create_menu.gd" type="Script" id=2] [ext_resource path="res://resources/ui/font.tres" type="DynamicFont" id=3] [ext_resource path="res://assets/icons/fistPlus.png" type="Texture" id=4] [ext_resource path="res://assets/icons/return.png" type="Texture" id=5] + [node name="server_create_menu" type="Control"] anchor_left = 0.5 anchor_top = 0.5 diff --git a/scenes/menus/SettingsControlsMenu.tscn b/scenes/menus/SettingsControlsMenu.tscn index 8530964..3a22a31 100644 --- a/scenes/menus/SettingsControlsMenu.tscn +++ b/scenes/menus/SettingsControlsMenu.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=20 format=2] -[ext_resource path="res://scripts/menus/settings_controls.gd" type="Script" id=1] +[ext_resource path="res://scripts/menus/settings_controls_menu.gd" type="Script" id=1] [ext_resource path="res://assets/icons/keySmall_3d.png" type="Texture" id=2] [ext_resource path="res://assets/icons/buttonA.png" type="Texture" id=3] [ext_resource path="res://assets/icons/buttonB.png" type="Texture" id=4] @@ -20,6 +20,7 @@ [ext_resource path="res://assets/icons/DPAD_right.png" type="Texture" id=18] [ext_resource path="res://assets/icons/fightJ.png" type="Texture" id=19] + [node name="settings_controls_menu" type="Control"] margin_left = 12.0 margin_top = 8.0 diff --git a/scenes/menus/SettingsMenu.tscn b/scenes/menus/SettingsMenu.tscn index 1ac41f7..dbf78c3 100644 --- a/scenes/menus/SettingsMenu.tscn +++ b/scenes/menus/SettingsMenu.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=8 format=2] [ext_resource path="res://resources/ui/theme.tres" type="Theme" id=1] -[ext_resource path="res://scripts/menus/settings.gd" type="Script" id=2] +[ext_resource path="res://scripts/menus/settings_menu.gd" type="Script" id=2] [ext_resource path="res://scenes/menus/BaseMenu.tscn" type="PackedScene" id=3] [ext_resource path="res://scenes/menus/SettingsPlayerMenu.tscn" type="PackedScene" id=4] [ext_resource path="res://scenes/menus/SettingsControlsMenu.tscn" type="PackedScene" id=5] @@ -94,7 +94,6 @@ margin_right = -4.0 margin_bottom = -4.0 [node name="settings_controls" parent="menu/tabs/controls" instance=ExtResource( 5 )] -editor/display_folded = true [node name="empty" parent="menu/tabs/controls/settings_controls/ScrollContainer/grid" index="0"] margin_bottom = 27.0 @@ -106,6 +105,7 @@ margin_bottom = 27.0 margin_bottom = 27.0 [node name="graphics" type="Tabs" parent="menu/tabs"] +editor/display_folded = true visible = false anchor_right = 1.0 anchor_bottom = 1.0 @@ -114,8 +114,33 @@ margin_top = 45.0 margin_right = -4.0 margin_bottom = -4.0 +[node name="VBoxContainer" type="VBoxContainer" parent="menu/tabs/graphics"] +margin_right = 40.0 +margin_bottom = 40.0 + +[node name="resolution" type="OptionButton" parent="menu/tabs/graphics/VBoxContainer"] +margin_right = 248.0 +margin_bottom = 33.0 + +[node name="fullscreen" type="CheckButton" parent="menu/tabs/graphics/VBoxContainer"] +margin_top = 37.0 +margin_right = 248.0 +margin_bottom = 77.0 +text = "FULLSCREEN" + +[node name="light" type="CheckButton" parent="menu/tabs/graphics/VBoxContainer"] +margin_top = 81.0 +margin_right = 248.0 +margin_bottom = 121.0 +text = "LIGHT" + +[node name="shadows" type="CheckButton" parent="menu/tabs/graphics/VBoxContainer"] +margin_top = 125.0 +margin_right = 248.0 +margin_bottom = 165.0 +text = "SHADOWS" + [node name="system" type="Tabs" parent="menu/tabs"] -editor/display_folded = true visible = false anchor_right = 1.0 anchor_bottom = 1.0 @@ -132,45 +157,46 @@ margin_bottom = 124.0 columns = 2 [node name="locale_label" type="Label" parent="menu/tabs/system/GridContainer"] -margin_right = 190.0 -margin_bottom = 27.0 +margin_right = 88.0 +margin_bottom = 14.0 text = "LOCALE" valign = 1 [node name="locales" type="ItemList" parent="menu/tabs/system/GridContainer"] -margin_left = 194.0 +margin_left = 92.0 margin_right = 895.0 -margin_bottom = 27.0 +margin_bottom = 14.0 size_flags_horizontal = 3 auto_height = true [node name="server_addr_label" type="Label" parent="menu/tabs/system/GridContainer"] -margin_top = 36.0 -margin_right = 190.0 -margin_bottom = 63.0 +margin_top = 23.0 +margin_right = 88.0 +margin_bottom = 37.0 text = "SERVER_ADDR" valign = 1 [node name="server_addr" type="LineEdit" parent="menu/tabs/system/GridContainer"] -margin_left = 194.0 -margin_top = 31.0 +margin_left = 92.0 +margin_top = 18.0 margin_right = 895.0 -margin_bottom = 68.0 +margin_bottom = 42.0 [node name="api_addr_label" type="Label" parent="menu/tabs/system/GridContainer"] -margin_top = 77.0 -margin_right = 190.0 -margin_bottom = 104.0 +margin_top = 51.0 +margin_right = 88.0 +margin_bottom = 65.0 text = "API_ADDR" valign = 1 [node name="api_addr" type="LineEdit" parent="menu/tabs/system/GridContainer"] -margin_left = 194.0 -margin_top = 72.0 +margin_left = 92.0 +margin_top = 46.0 margin_right = 895.0 -margin_bottom = 109.0 +margin_bottom = 70.0 [node name="HBoxContainer" type="HBoxContainer" parent="menu"] +editor/display_folded = true anchor_left = 1.0 anchor_top = 1.0 anchor_right = 1.0 @@ -209,7 +235,6 @@ flat = true align = 0 [connection signal="item_selected" from="menu/tabs/system/GridContainer/locales" to="." method="_on_locales_item_selected"] [connection signal="tree_exiting" from="menu/tabs/system/GridContainer/locales" to="." method="_on_locales_tree_exiting"] -[connection signal="visibility_changed" from="menu/tabs/system/GridContainer/locales" to="." method="_init_locales"] [connection signal="pressed" from="menu/HBoxContainer/apply" to="." method="_on_apply_pressed"] [connection signal="pressed" from="menu/HBoxContainer/save" to="." method="_on_save_pressed"] diff --git a/scenes/menus/SettingsPlayerMenu.tscn b/scenes/menus/SettingsPlayerMenu.tscn index 160c5b1..1b6c074 100644 --- a/scenes/menus/SettingsPlayerMenu.tscn +++ b/scenes/menus/SettingsPlayerMenu.tscn @@ -1,6 +1,7 @@ [gd_scene load_steps=2 format=2] -[ext_resource path="res://scripts/menus/settings_player.gd" type="Script" id=1] +[ext_resource path="res://scripts/menus/settings_player_menu.gd" type="Script" id=1] + [node name="settings_player_menu" type="Control"] margin_left = 513.0 diff --git a/scenes/menus/SettingsSystemMenu.tscn b/scenes/menus/SettingsSystemMenu.tscn new file mode 100644 index 0000000..9e3bf4a --- /dev/null +++ b/scenes/menus/SettingsSystemMenu.tscn @@ -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 diff --git a/scenes/player/Player.tscn b/scenes/player/Player.tscn index 3ece485..95c6d67 100644 --- a/scenes/player/Player.tscn +++ b/scenes/player/Player.tscn @@ -31,7 +31,6 @@ rotation_mode = 4 loop = false [node name="raceCar" type="KinematicBody" parent="Path/PathFollow"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ) collision_layer = 31 collision_mask = 31 script = ExtResource( 2 ) diff --git a/scenes/road/roadCornerLarge.tscn b/scenes/road/roadCornerLarge.tscn index cbd6b15..5784ef3 100644 --- a/scenes/road/roadCornerLarge.tscn +++ b/scenes/road/roadCornerLarge.tscn @@ -13,7 +13,7 @@ script = ExtResource( 2 ) end_rotation = Vector3( 0, -1.571, 0 ) speed_constrains = PoolVector3Array( 0.2, 0.6, 0.13, 0.6, 1.5, 0.1, 1.5, 2.36, 0.13 ) force_penalties = PoolVector3Array( 2, 0, 8 ) -torque_penalties = PoolVector3Array( 0.5, 0.1, 0.1 ) +torque_penalties = PoolVector3Array( 0.1, 0.1, -0.5 ) [node name="Path" type="Path" parent="."] curve = ExtResource( 3 ) diff --git a/scenes/road/roadCornerLargeFlipped.tscn b/scenes/road/roadCornerLargeFlipped.tscn index 495a527..44ddc78 100644 --- a/scenes/road/roadCornerLargeFlipped.tscn +++ b/scenes/road/roadCornerLargeFlipped.tscn @@ -12,8 +12,8 @@ material/2 = null script = ExtResource( 2 ) end_rotation = Vector3( 0, 1.571, 0 ) speed_constrains = PoolVector3Array( 0.2, 0.6, 0.13, 0.6, 1.5, 0.1, 1.5, 2.36, 0.13 ) -force_penalties = PoolVector3Array( 1, 0, 5 ) -torque_penalties = PoolVector3Array( 0, 1, 1.5 ) +force_penalties = PoolVector3Array( 2, 0, 8 ) +torque_penalties = PoolVector3Array( 0.1, 0.1, 0.5 ) [node name="Path" type="Path" parent="."] curve = ExtResource( 3 ) diff --git a/scenes/road/roadCornerLarger.tscn b/scenes/road/roadCornerLarger.tscn index 9d10b68..72e1385 100644 --- a/scenes/road/roadCornerLarger.tscn +++ b/scenes/road/roadCornerLarger.tscn @@ -12,8 +12,8 @@ material/2 = null script = ExtResource( 2 ) end_rotation = Vector3( 0, -1.571, 0 ) speed_constrains = PoolVector3Array( 0.3, 1, 0.16, 1, 2.7, 0.13, 2.7, 3.93, 0.16 ) -force_penalties = PoolVector3Array( 0, 0, 5 ) -torque_penalties = PoolVector3Array( 0, 0, 1 ) +force_penalties = PoolVector3Array( 2, 0, 8 ) +torque_penalties = PoolVector3Array( 0.1, 0.1, -0.5 ) [node name="Path" type="Path" parent="."] curve = ExtResource( 3 ) diff --git a/scenes/road/roadCornerLargerFlipped.tscn b/scenes/road/roadCornerLargerFlipped.tscn index 9862dce..3723019 100644 --- a/scenes/road/roadCornerLargerFlipped.tscn +++ b/scenes/road/roadCornerLargerFlipped.tscn @@ -12,8 +12,8 @@ material/2 = null script = ExtResource( 2 ) end_rotation = Vector3( 0, 1.571, 0 ) speed_constrains = PoolVector3Array( 0.3, 1, 0.16, 1, 2.7, 0.13, 2.7, 3.93, 0.16 ) -force_penalties = PoolVector3Array( 0, 0, 5 ) -torque_penalties = PoolVector3Array( 0, 0, -1 ) +force_penalties = PoolVector3Array( 2, 0, 8 ) +torque_penalties = PoolVector3Array( 0.1, 0.1, 0.5 ) [node name="Path" type="Path" parent="."] curve = ExtResource( 3 ) diff --git a/scenes/road/roadCornerSmall.tscn b/scenes/road/roadCornerSmall.tscn index 00935f2..23f786a 100644 --- a/scenes/road/roadCornerSmall.tscn +++ b/scenes/road/roadCornerSmall.tscn @@ -12,8 +12,8 @@ material/2 = null script = ExtResource( 2 ) end_rotation = Vector3( 0, -1.571, 0 ) speed_constrains = PoolVector3Array( 0.1, 0.79, 0.08 ) -force_penalties = PoolVector3Array( 0, 0, 5 ) -torque_penalties = PoolVector3Array( 0, 0, 1 ) +force_penalties = PoolVector3Array( 2, 0, 8 ) +torque_penalties = PoolVector3Array( 0.1, 0.1, -0.5 ) [node name="Path" type="Path" parent="."] curve = ExtResource( 3 ) diff --git a/scenes/road/roadCornerSmallFlipped.tscn b/scenes/road/roadCornerSmallFlipped.tscn index 4b6ffb9..8bf4ea1 100644 --- a/scenes/road/roadCornerSmallFlipped.tscn +++ b/scenes/road/roadCornerSmallFlipped.tscn @@ -12,8 +12,8 @@ material/2 = null script = ExtResource( 2 ) end_rotation = Vector3( 0, 1.571, 0 ) speed_constrains = PoolVector3Array( 0.1, 0.79, 0.08 ) -force_penalties = PoolVector3Array( 0, 0, 5 ) -torque_penalties = PoolVector3Array( 0, 0, -1 ) +force_penalties = PoolVector3Array( 2, 0, 8 ) +torque_penalties = PoolVector3Array( 0.1, 0.1, 0.5 ) [node name="Path" type="Path" parent="."] curve = ExtResource( 3 ) diff --git a/scripts/game/local_storage.gd b/scripts/game/local_storage.gd deleted file mode 100644 index 1979419..0000000 --- a/scripts/game/local_storage.gd +++ /dev/null @@ -1,64 +0,0 @@ -extends Node - -const FILE_PATH = "user://local_storage" - - -func _ready(): - TranslationServer.set_locale(read_value("locale","en")) - var server_addr = read_value("server_addr") - if server_addr != null && not server_addr.empty(): - game_server.set_server_addr(server_addr) - var api_addr = read_value("api_addr") - if api_addr != null && not api_addr.empty(): - game_server.set_api_addr(api_addr) - - -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() \ No newline at end of file diff --git a/scripts/game/settings.gd b/scripts/game/settings.gd new file mode 100644 index 0000000..da89ec7 --- /dev/null +++ b/scripts/game/settings.gd @@ -0,0 +1,94 @@ +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)] + +onready var view_port = get_tree().get_root() + + +func _ready(): + apply_settings() + + +func read_config(): + var f = File.new() + var err = f.open(FILE_PATH, File.READ) + var config = {} + if err == OK: + config = parse_json(f.get_as_text()) + f.close() + if config == null: + config = {} + return config + + +func write_config(config: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(config)) + f.close() + + +func write_value(key:String, value): + var config = read_config() + config[key] = value + write_config(config) + + +func read_value(key:String, default = null): + var config = read_config() + if config.has(key) && config.get(key) != null: + return config.get(key) + else: + return default + + +func delete_value(key:String): + var config = read_config() + config.erase(key) + write_config(config) + + +func write_values(new_config:Dictionary): + var config = read_config() + for key in new_config: + config[key] = new_config[key] + write_config(config) + + +func read_values(): + return read_config() + + +func apply_settings(): + apply_locale() + apply_game_server() + apply_resolution() + + +func apply_locale(): + TranslationServer.set_locale(read_value("locale","en")) + + +func apply_game_server(): + var server_addr = read_value("server_addr") + if server_addr != null && not server_addr.empty(): + game_server.set_server_addr(server_addr) + var api_addr = read_value("api_addr") + if api_addr != null && not api_addr.empty(): + game_server.set_api_addr(api_addr) + + +func apply_resolution(): + OS.set_window_fullscreen(read_value("fullscreen", true)) + + if OS.is_window_fullscreen(): + var base_size = Vector2(1920, 1080) + var scale= base_size.x / RESOLUTIONS[read_value("resolution",0)].x + + get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_2D,SceneTree.STRETCH_ASPECT_EXPAND,base_size,scale) + else: + OS.set_window_size(RESOLUTIONS[read_value("resolution",0)]) + get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_VIEWPORT,SceneTree.STRETCH_ASPECT_IGNORE,OS.get_window_size(),1) \ No newline at end of file diff --git a/scripts/menus/direct_host.gd b/scripts/menus/direct_host_menu.gd similarity index 90% rename from scripts/menus/direct_host.gd rename to scripts/menus/direct_host_menu.gd index 316bba8..71470fd 100644 --- a/scripts/menus/direct_host.gd +++ b/scripts/menus/direct_host_menu.gd @@ -4,7 +4,7 @@ var LobbyMenu = preload("res://scenes/menus/LobbyMenu.tscn") func _ready(): - find_node("bots").set_pressed(local_storage.read_value("bots", true)) + find_node("bots").set_pressed(settings.read_value("bots", true)) func _draw(): diff --git a/scripts/menus/direct_join.gd b/scripts/menus/direct_join_menu.gd similarity index 100% rename from scripts/menus/direct_join.gd rename to scripts/menus/direct_join_menu.gd diff --git a/scripts/menus/ingame.gd b/scripts/menus/ingame_menu.gd similarity index 100% rename from scripts/menus/ingame.gd rename to scripts/menus/ingame_menu.gd diff --git a/scripts/menus/lobby.gd b/scripts/menus/lobby_menu.gd similarity index 100% rename from scripts/menus/lobby.gd rename to scripts/menus/lobby_menu.gd diff --git a/scripts/menus/local_game.gd b/scripts/menus/local_game.gd index 0078915..bfc2b2f 100644 --- a/scripts/menus/local_game.gd +++ b/scripts/menus/local_game.gd @@ -4,7 +4,7 @@ onready var player_settings = find_node("player_settings") func _ready(): - find_node("bots").set_pressed(local_storage.read_value("bots", true)) + find_node("bots").set_pressed(settings.read_value("bots", true)) func _draw(): diff --git a/scripts/menus/main.gd b/scripts/menus/main_menu.gd similarity index 100% rename from scripts/menus/main.gd rename to scripts/menus/main_menu.gd diff --git a/scripts/menus/server_create.gd b/scripts/menus/server_create_menu.gd similarity index 89% rename from scripts/menus/server_create.gd rename to scripts/menus/server_create_menu.gd index b4793c5..9dc4d7c 100644 --- a/scripts/menus/server_create.gd +++ b/scripts/menus/server_create_menu.gd @@ -2,12 +2,12 @@ extends Control func _ready(): - var player_name = local_storage.read_value("player_name", false) + var player_name = settings.read_value("player_name", false) var game_title = "New Game" if player_name: game_title += " by " + player_name find_node("name").set_text(game_title) - find_node("bots").set_pressed(local_storage.read_value("bots", true)) + find_node("bots").set_pressed(settings.read_value("bots", true)) func _draw(): diff --git a/scripts/menus/server.gd b/scripts/menus/server_menu.gd similarity index 100% rename from scripts/menus/server.gd rename to scripts/menus/server_menu.gd diff --git a/scripts/menus/settings_controls.gd b/scripts/menus/settings_controls_menu.gd similarity index 100% rename from scripts/menus/settings_controls.gd rename to scripts/menus/settings_controls_menu.gd diff --git a/scripts/menus/settings.gd b/scripts/menus/settings_menu.gd similarity index 69% rename from scripts/menus/settings.gd rename to scripts/menus/settings_menu.gd index ebcf116..505327e 100644 --- a/scripts/menus/settings.gd +++ b/scripts/menus/settings_menu.gd @@ -11,13 +11,22 @@ 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 + find_node("bots").set_pressed(settings.read_value("bots", true)) + + # graphics + find_node("fullscreen").set_pressed(settings.read_value("fullscreen", true)) + + for resolution in settings.RESOLUTIONS: + find_node("resolution").add_item(str(resolution.x) + " * " + str(resolution.y)) + + find_node("resolution").select(settings.read_value("resolution", 0)) + + # system find_node("server_addr").set_text(game_server.get_server_addr()) find_node("api_addr").set_text(game_server.get_api_addr()) - game_tab.set_name(tr("GAME")) - controls_tab.set_name(tr("CONTROLS")) - graphics_tab.set_name(tr("GRAPHICS")) - system_tab.set_name(tr("SYSTEM")) + _init_locales() func _on_back_pressed(): @@ -45,7 +54,7 @@ func _init_locales(): locales.clear() locales.add_item(tr("LOCALE_EN")) locales.add_item(tr("LOCALE_DE")) - locale = local_storage.read_value("locale","en") + locale = settings.read_value("locale","en") match locale: "en": locales.select(0) @@ -56,7 +65,7 @@ func _init_locales(): func _on_locales_tree_exiting(): - TranslationServer.set_locale(local_storage.read_value("locale","en")) + settings.apply_locale() func _on_save_pressed(): @@ -66,11 +75,20 @@ func _on_save_pressed(): func _on_apply_pressed(): var values = {} + + # game values['player_name'] = player_settings.get_name_node().get_text() values['player_color'] = player_settings.get_color_node().color.to_html() values['bots'] = find_node("bots").is_pressed() values['locale'] = locale + # graphics + values['resolution'] = find_node("resolution").get_selected() + values['fullscreen'] = find_node("fullscreen").is_pressed() + values['light'] = find_node("fullscreen").is_pressed() + values['shadows'] = find_node("fullscreen").is_pressed() + + # system var server_addr = find_node("server_addr").get_text() if server_addr.empty(): server_addr = game_server.SERVER_ADDR @@ -80,7 +98,7 @@ func _on_apply_pressed(): if api_addr.empty(): api_addr = game_server.API_ADDR values['api_addr'] = api_addr - local_storage.write_values(values) - game_server.set_server_addr(server_addr) - game_server.set_api_addr(local_storage.read_value("api_addr",game_server.API_ADDR)) + settings.write_values(values) + + settings.apply_settings() diff --git a/scripts/menus/settings_player.gd b/scripts/menus/settings_player.gd deleted file mode 100644 index d75dcb4..0000000 --- a/scripts/menus/settings_player.gd +++ /dev/null @@ -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") \ No newline at end of file diff --git a/scripts/menus/settings_player_menu.gd b/scripts/menus/settings_player_menu.gd new file mode 100644 index 0000000..a04f3f9 --- /dev/null +++ b/scripts/menus/settings_player_menu.gd @@ -0,0 +1,14 @@ +extends Control + + +func _ready(): + get_name_node().set_text(settings.read_value("player_name", "Player")) + get_color_node().set_pick_color(Color(settings.read_value("player_color", "#000000"))) + + +func get_name_node(): + return find_node("name") + + +func get_color_node(): + return find_node("color") \ No newline at end of file diff --git a/scripts/player/player.gd b/scripts/player/player.gd index f84ac45..5024285 100644 --- a/scripts/player/player.gd +++ b/scripts/player/player.gd @@ -116,6 +116,7 @@ func _physics_process(delta): check_position() else: + var road = get_road() race_car.get_node("ray").set_enabled(false) if force_penalty.length() != 0: race_car.move_and_slide(force_penalty * current_speed + Vector3(0,-0.5,0)) diff --git a/scripts/road/road.gd b/scripts/road/road.gd index df33cbd..1860c00 100644 --- a/scripts/road/road.gd +++ b/scripts/road/road.gd @@ -98,10 +98,7 @@ func get_torque_penalty(index:int): if index >= 0: if torque_penalties.size() < (index + 1): return get_torque_penalty(index - 1) - if get_rotation().length() != 0: - return torque_penalties[index].rotated(get_rotation().normalized(), get_rotation().length()) - else: - return torque_penalties[index] + return torque_penalties[index] return Vector3(0,0,0)