godot-third-person-basic-scene/scenes/hud/hud.gd

82 lines
2 KiB
GDScript

extends Control
var git_branch:String
var git_commit:String
var tag_release:String
func _ready():
$MenuTheme.connect("update_theme", update_theme.bind())
var file = File.new()
if file.file_exists("res://commit.txt"):
file.open("res://commit.txt", File.READ)
tag_release = file.get_as_text().strip_escapes()
file.close()
Common.msg_debug("Tag: " + tag_release)
elif file.file_exists("res://.git/HEAD"):
file.open("res://.git/HEAD", File.READ)
var content = file.get_as_text().strip_escapes()
file.close()
git_branch = content.split(' ')[1]
file.open("res://.git/" + git_branch, File.READ)
git_commit = file.get_as_text().strip_escapes()
file.close()
Common.msg_debug("Commit: " + git_commit)
else:
git_branch = "Unknown"
git_commit = "Unknown"
func update_theme():
var select_theme = load(Themes.THEMES_CONTROL[Themes.current_theme])
#$Control.set_theme(Themes.THEMES_CONTROL[Themes.current_theme])
print($Control)
self.set_theme(select_theme)
func _input(_event):
if Input.is_action_just_pressed("ui_menu"):
$Menu.visible = ! $Menu.visible
func _on_timer_timeout():
$Message/Label.visible = false
func _on_quit_pressed():
$ConfirmQuit.popup_centered()
$ConfirmQuit.visible = true
func _on_confirmation_dialog_confirmed():
get_tree().quit()
func _on_languages_pressed():
$MenuLanguage/Window.popup_centered()
$MenuLanguage/Window.visible = true
func _on_keys_pressed():
$MenuControl.configure_control()
$MenuControl/Window.visible = true
func _on_themes_pressed():
$MenuTheme/Window.popup_centered()
$MenuTheme/Window.visible = true
func _on_about_pressed():
var aboutmessage:String
if tag_release.is_empty():
aboutmessage = "Khaganat client test\nBranch: " + git_branch + "\nCommit: " + git_commit
else:
aboutmessage = "Khaganat client test\nVersion: " + tag_release
$AboutMessage.set_text(aboutmessage)
$AboutMessage.popup_centered()
$AboutMessage.visible = true
func _on_music_pressed():
$MusicManager.show_config()