Browse Source
resolution settings, clean up
resolution settings, clean up
35 changed files with 272 additions and 138 deletions
-
10project.godot
-
3scenes/menus/DirectHostMenu.tscn
-
3scenes/menus/DirectJoinMenu.tscn
-
3scenes/menus/IngameMenu.tscn
-
3scenes/menus/LobbyMenu.tscn
-
3scenes/menus/MainMenu.tscn
-
3scenes/menus/MultiplayerMenu.tscn
-
3scenes/menus/ServerCreateGameMenu.tscn
-
3scenes/menus/SettingsControlsMenu.tscn
-
65scenes/menus/SettingsMenu.tscn
-
3scenes/menus/SettingsPlayerMenu.tscn
-
47scenes/menus/SettingsSystemMenu.tscn
-
1scenes/player/Player.tscn
-
2scenes/road/roadCornerLarge.tscn
-
4scenes/road/roadCornerLargeFlipped.tscn
-
4scenes/road/roadCornerLarger.tscn
-
4scenes/road/roadCornerLargerFlipped.tscn
-
4scenes/road/roadCornerSmall.tscn
-
4scenes/road/roadCornerSmallFlipped.tscn
-
64scripts/game/local_storage.gd
-
94scripts/game/settings.gd
-
2scripts/menus/direct_host_menu.gd
-
0scripts/menus/direct_join_menu.gd
-
0scripts/menus/ingame_menu.gd
-
0scripts/menus/lobby_menu.gd
-
2scripts/menus/local_game.gd
-
0scripts/menus/main_menu.gd
-
4scripts/menus/server_create_menu.gd
-
0scripts/menus/server_menu.gd
-
0scripts/menus/settings_controls_menu.gd
-
38scripts/menus/settings_menu.gd
-
14scripts/menus/settings_player.gd
-
14scripts/menus/settings_player_menu.gd
-
1scripts/player/player.gd
-
5scripts/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,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() |
@ -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) |
@ -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(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") |
Write
Preview
Loading…
Cancel
Save
Reference in new issue