update and improve ui
This commit was merged in pull request #36.
This commit is contained in:
@@ -29,6 +29,11 @@ var is_loaded: bool = false
|
||||
func _ready() -> void:
|
||||
load_game()
|
||||
apply_video_settings()
|
||||
apply_train_colors()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not get_tree().paused and is_loaded:
|
||||
save_data.total_time_played_seconds += delta
|
||||
|
||||
func apply_video_settings() -> void:
|
||||
get_viewport().use_taa = save_data.anti_aliasing
|
||||
@@ -36,6 +41,16 @@ func apply_video_settings() -> void:
|
||||
get_viewport().msaa_3d = msaa_mode
|
||||
get_viewport().msaa_2d = msaa_mode
|
||||
|
||||
func apply_train_colors() -> void:
|
||||
if not save_data.train_color_1.is_empty():
|
||||
var mat1: ShaderMaterial = load("res://tgcc/train/Color1_train.tres")
|
||||
if mat1:
|
||||
mat1.set_shader_parameter("albedo_color", Color(save_data.train_color_1))
|
||||
if not save_data.train_color_2.is_empty():
|
||||
var mat2: ShaderMaterial = load("res://tgcc/train/Color2_train.tres")
|
||||
if mat2:
|
||||
mat2.set_shader_parameter("albedo_color", Color(save_data.train_color_2))
|
||||
|
||||
match save_data.window_mode_index:
|
||||
0:
|
||||
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN)
|
||||
|
||||
@@ -9,6 +9,13 @@ var anti_aliasing: bool = true
|
||||
var window_mode_index: int = 0
|
||||
var resolution_x: int = 1920
|
||||
var resolution_y: int = 1080
|
||||
var train_color_1: String = ""
|
||||
var train_color_2: String = ""
|
||||
var train_color_1_index: int = 0
|
||||
var train_color_2_index: int = 0
|
||||
|
||||
var total_distance_km: float = 0.0
|
||||
var total_time_played_seconds: float = 0.0
|
||||
|
||||
func to_dictionary() -> Dictionary:
|
||||
var serialized_collectible_ids: Array[String] = []
|
||||
@@ -23,6 +30,12 @@ func to_dictionary() -> Dictionary:
|
||||
"window_mode_index": window_mode_index,
|
||||
"resolution_x": resolution_x,
|
||||
"resolution_y": resolution_y,
|
||||
"train_color_1": train_color_1,
|
||||
"train_color_2": train_color_2,
|
||||
"train_color_1_index": train_color_1_index,
|
||||
"train_color_2_index": train_color_2_index,
|
||||
"total_distance_km": total_distance_km,
|
||||
"total_time_played_seconds": total_time_played_seconds,
|
||||
}
|
||||
|
||||
static func from_dictionary(data: Dictionary) -> SaveGameData:
|
||||
@@ -52,4 +65,22 @@ static func from_dictionary(data: Dictionary) -> SaveGameData:
|
||||
if data.has("resolution_y"):
|
||||
save_game_data.resolution_y = int(data["resolution_y"])
|
||||
|
||||
if data.has("train_color_1"):
|
||||
save_game_data.train_color_1 = str(data["train_color_1"])
|
||||
|
||||
if data.has("train_color_2"):
|
||||
save_game_data.train_color_2 = str(data["train_color_2"])
|
||||
|
||||
if data.has("train_color_1_index"):
|
||||
save_game_data.train_color_1_index = int(data["train_color_1_index"])
|
||||
|
||||
if data.has("train_color_2_index"):
|
||||
save_game_data.train_color_2_index = int(data["train_color_2_index"])
|
||||
|
||||
if data.has("total_distance_km"):
|
||||
save_game_data.total_distance_km = float(data["total_distance_km"])
|
||||
|
||||
if data.has("total_time_played_seconds"):
|
||||
save_game_data.total_time_played_seconds = float(data["total_time_played_seconds"])
|
||||
|
||||
return save_game_data
|
||||
|
||||
Reference in New Issue
Block a user