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

83 lines
2 KiB
GDScript3
Raw Normal View History

2022-02-12 19:45:44 +00:00
extends Control
2022-03-30 20:32:56 +00:00
var git_branch:String
var git_commit:String
2022-04-15 07:53:44 +00:00
var tag_release:String
2022-02-12 19:45:44 +00:00
2022-02-15 22:21:57 +00:00
func _ready():
$MenuTheme.connect("update_theme", update_theme.bind())
2022-03-30 20:32:56 +00:00
var file = File.new()
2022-04-15 07:53:44 +00:00
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"
2022-02-15 22:21:57 +00:00
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)
2022-02-12 22:15:01 +00:00
func _input(_event):
if Input.is_action_just_pressed("ui_menu"):
2022-02-12 19:45:44 +00:00
$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():
2022-06-15 20:53:34 +00:00
#$MenuLanguage/Window.popup_centered()
$MenuLanguage/Window.set_visible(true)
2022-02-12 22:15:01 +00:00
func _on_keys_pressed():
2022-02-24 22:08:03 +00:00
$MenuControl.configure_control()
$MenuControl/Window.visible = true
2022-02-15 22:21:57 +00:00
func _on_themes_pressed():
$MenuTheme/Window.popup_centered()
$MenuTheme/Window.visible = true
2022-03-30 20:32:56 +00:00
func _on_about_pressed():
2022-04-15 07:53:44 +00:00
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
2022-03-30 20:32:56 +00:00
$AboutMessage.set_text(aboutmessage)
$AboutMessage.popup_centered()
$AboutMessage.visible = true
2022-04-15 07:53:44 +00:00
func _on_music_pressed():
$MusicManager.show_config()