Add version info to the game
parent
cf3685415a
commit
4b496071fc
|
@ -4,6 +4,10 @@ extends Panel
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
# gdlint: ignore=max-line-length
|
# gdlint: ignore=max-line-length
|
||||||
$MarginContainer/VSplitContainer/VSplitContainer/CenterContainer/VBoxContainer/SingleplayerButton.grab_focus()
|
$MarginContainer/VSplitContainer/VSplitContainer/CenterContainer/VBoxContainer/SingleplayerButton.grab_focus()
|
||||||
|
$MarginContainer/VSplitContainer/VBoxContainer/VersionLabel.text = (
|
||||||
|
"Version: %s"
|
||||||
|
% GlobalSettings.get_version_string()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
func _on_SingleplayerButton_pressed() -> void:
|
func _on_SingleplayerButton_pressed() -> void:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=10 format=2]
|
[gd_scene load_steps=11 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://assets/fonts/kenney-future-narrow.ttf" type="DynamicFontData" id=1]
|
[ext_resource path="res://assets/fonts/kenney-future-narrow.ttf" type="DynamicFontData" id=1]
|
||||||
[ext_resource path="res://menu/main_menu.gd" type="Script" id=2]
|
[ext_resource path="res://menu/main_menu.gd" type="Script" id=2]
|
||||||
|
@ -12,6 +12,9 @@
|
||||||
size = 64
|
size = 64
|
||||||
font_data = ExtResource( 1 )
|
font_data = ExtResource( 1 )
|
||||||
|
|
||||||
|
[sub_resource type="DynamicFont" id=3]
|
||||||
|
font_data = ExtResource( 1 )
|
||||||
|
|
||||||
[sub_resource type="DynamicFont" id=2]
|
[sub_resource type="DynamicFont" id=2]
|
||||||
size = 32
|
size = 32
|
||||||
font_data = ExtResource( 1 )
|
font_data = ExtResource( 1 )
|
||||||
|
@ -41,7 +44,11 @@ margin_right = 984.0
|
||||||
margin_bottom = 560.0
|
margin_bottom = 560.0
|
||||||
dragger_visibility = 1
|
dragger_visibility = 1
|
||||||
|
|
||||||
[node name="Title" type="Label" parent="MarginContainer/VSplitContainer"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VSplitContainer"]
|
||||||
|
margin_right = 984.0
|
||||||
|
margin_bottom = 98.0
|
||||||
|
|
||||||
|
[node name="Title" type="Label" parent="MarginContainer/VSplitContainer/VBoxContainer"]
|
||||||
margin_right = 984.0
|
margin_right = 984.0
|
||||||
margin_bottom = 72.0
|
margin_bottom = 72.0
|
||||||
custom_colors/font_color = Color( 0.419608, 0.0117647, 0.0117647, 1 )
|
custom_colors/font_color = Color( 0.419608, 0.0117647, 0.0117647, 1 )
|
||||||
|
@ -50,8 +57,19 @@ text = "Bugged Racing"
|
||||||
align = 1
|
align = 1
|
||||||
valign = 1
|
valign = 1
|
||||||
|
|
||||||
|
[node name="VersionLabel" type="Label" parent="MarginContainer/VSplitContainer/VBoxContainer"]
|
||||||
|
margin_top = 80.0
|
||||||
|
margin_right = 984.0
|
||||||
|
margin_bottom = 98.0
|
||||||
|
custom_fonts/font = SubResource( 3 )
|
||||||
|
text = "Version:"
|
||||||
|
align = 1
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
[node name="VSplitContainer" type="VSplitContainer" parent="MarginContainer/VSplitContainer"]
|
[node name="VSplitContainer" type="VSplitContainer" parent="MarginContainer/VSplitContainer"]
|
||||||
margin_top = 96.0
|
margin_top = 122.0
|
||||||
margin_right = 984.0
|
margin_right = 984.0
|
||||||
margin_bottom = 560.0
|
margin_bottom = 560.0
|
||||||
split_offset = 973
|
split_offset = 973
|
||||||
|
@ -59,16 +77,16 @@ dragger_visibility = 1
|
||||||
|
|
||||||
[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VSplitContainer/VSplitContainer"]
|
[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VSplitContainer/VSplitContainer"]
|
||||||
margin_right = 984.0
|
margin_right = 984.0
|
||||||
margin_bottom = 376.0
|
margin_bottom = 350.0
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VSplitContainer/VSplitContainer/CenterContainer"]
|
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VSplitContainer/VSplitContainer/CenterContainer"]
|
||||||
margin_left = 348.0
|
margin_left = 348.0
|
||||||
margin_top = 52.0
|
margin_top = 39.0
|
||||||
margin_right = 636.0
|
margin_right = 636.0
|
||||||
margin_bottom = 324.0
|
margin_bottom = 311.0
|
||||||
|
|
||||||
[node name="SingleplayerButton" type="Button" parent="MarginContainer/VSplitContainer/VSplitContainer/CenterContainer/VBoxContainer"]
|
[node name="SingleplayerButton" type="Button" parent="MarginContainer/VSplitContainer/VSplitContainer/CenterContainer/VBoxContainer"]
|
||||||
margin_right = 288.0
|
margin_right = 288.0
|
||||||
|
@ -103,9 +121,9 @@ margin_bottom = 272.0
|
||||||
text = "Exit"
|
text = "Exit"
|
||||||
|
|
||||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VSplitContainer/VSplitContainer"]
|
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VSplitContainer/VSplitContainer"]
|
||||||
margin_top = 400.0
|
margin_top = 374.0
|
||||||
margin_right = 984.0
|
margin_right = 984.0
|
||||||
margin_bottom = 464.0
|
margin_bottom = 438.0
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,3 +4,35 @@ var auto_clutch: bool = false
|
||||||
var automatic_transmission: bool = true
|
var automatic_transmission: bool = true
|
||||||
var selected_camera: int = 0
|
var selected_camera: int = 0
|
||||||
var multiplayer_name: String = "Player"
|
var multiplayer_name: String = "Player"
|
||||||
|
|
||||||
|
var _config: Dictionary
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
_config = read_json_file("res://info.json")
|
||||||
|
|
||||||
|
|
||||||
|
func read_json_file(file_path: String) -> Dictionary:
|
||||||
|
var file = File.new()
|
||||||
|
if not file.file_exists(file_path):
|
||||||
|
print("File not found: %s" % file_path)
|
||||||
|
return Dictionary()
|
||||||
|
file.open(file_path, File.READ)
|
||||||
|
var content_as_text = file.get_as_text()
|
||||||
|
var content_as_dictionary = parse_json(content_as_text)
|
||||||
|
return content_as_dictionary
|
||||||
|
|
||||||
|
|
||||||
|
func save_json_file(file_path: String, contents: Dictionary) -> void:
|
||||||
|
var file = File.new()
|
||||||
|
file.open(file_path, File.WRITE)
|
||||||
|
file.store_line(to_json(contents))
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
|
||||||
|
func get_version_string() -> String:
|
||||||
|
var version = _config["version"]
|
||||||
|
var major = version["major"]
|
||||||
|
var minor = version["minor"]
|
||||||
|
var patch = version["patch"]
|
||||||
|
return "%d.%d.%d" % [major, minor, patch]
|
||||||
|
|
Loading…
Reference in New Issue