55 lines
1.1 KiB
GDScript
55 lines
1.1 KiB
GDScript
extends Control
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
pass # Replace with function body.
|
|
|
|
func read_news(key):
|
|
var file = File.new()
|
|
var filenews = ""
|
|
if key.empty():
|
|
filenews = "res://NEWS"
|
|
else:
|
|
filenews = "res://NEWS_" + key
|
|
|
|
if file.file_exists(filenews):
|
|
#print(filenews + " exist ! ")
|
|
file.open(filenews, File.READ)
|
|
var content = file.get_as_text()
|
|
file.close()
|
|
#print(content)
|
|
#$accept_dialog.dialog_text = content
|
|
$window_dialog/margin_container/v_box_container/text_edit.text = content
|
|
return true
|
|
return false
|
|
|
|
|
|
func load_news():
|
|
var current_locale = TranslationServer.get_locale()
|
|
var root_language = current_locale.split('_')[0]
|
|
if read_news(current_locale):
|
|
pass
|
|
elif read_news(root_language):
|
|
pass
|
|
elif read_news(""):
|
|
pass
|
|
|
|
|
|
func _on_accept_dialog_visibility_changed():
|
|
if $accept_dialog.visible:
|
|
print("show")
|
|
load_news()
|
|
|
|
|
|
func _on_accept_dialog_hide():
|
|
$accept_dialog.dialog_text = ""
|
|
|
|
|
|
func _on_button_pressed():
|
|
$window_dialog.hide()
|
|
|
|
|
|
func _on_window_dialog_visibility_changed():
|
|
if $window_dialog.visible:
|
|
load_news()
|