master
PJ568 6 months ago
parent 15b273f40d
commit 8626bc24e1

@ -15,204 +15,203 @@ var 已键入第二数 := false ## 若为是,则按下运算符按键将触发
# 初始化
func _ready():
for Buttons in .get_children():
for btn in Buttons.get_children():
if btn.name.is_valid_int():
btn.pressed.connect(Callable(self, "_number_buttons").bind(btn))
print(.text, , )
for Buttons in .get_children():
for btn in Buttons.get_children():
if btn.name.is_valid_int():
btn.pressed.connect(Callable(self, "_number_buttons").bind(btn))
@warning_ignore("unused_parameter")
func _unhandled_input(event) -> void:
if Input.is_action_pressed("ui_text_backspace") or Input.is_action_pressed("ui_cancel"):
退()
if Input.is_action_pressed("1"):
("1")
if Input.is_action_pressed("2"):
("2")
if Input.is_action_pressed("3"):
("3")
if Input.is_action_pressed("4"):
("4")
if Input.is_action_pressed("5"):
("5")
if Input.is_action_pressed("6"):
("6")
if Input.is_action_pressed("7"):
("7")
if Input.is_action_pressed("8"):
("8")
if Input.is_action_pressed("9"):
("9")
if Input.is_action_pressed("0"):
("0")
if Input.is_action_pressed(""):
()
if Input.is_action_pressed("归零") or Input.is_action_pressed("ui_menu") or Input.is_action_pressed("ui_home"):
_on_clear_pressed()
if Input.is_action_pressed(""):
()
if Input.is_action_pressed(""):
()
if Input.is_action_pressed(""):
()
if Input.is_action_pressed(""):
()
if Input.is_action_pressed("等于") or Input.is_action_pressed("ui_accept"):
()
if Input.is_action_pressed("取反"):
()
if Input.is_action_pressed("关于"):
_on__pressed()
if Input.is_action_pressed("ui_text_backspace") or Input.is_action_pressed("ui_cancel"):
退()
if Input.is_action_pressed("1"):
("1")
if Input.is_action_pressed("2"):
("2")
if Input.is_action_pressed("3"):
("3")
if Input.is_action_pressed("4"):
("4")
if Input.is_action_pressed("5"):
("5")
if Input.is_action_pressed("6"):
("6")
if Input.is_action_pressed("7"):
("7")
if Input.is_action_pressed("8"):
("8")
if Input.is_action_pressed("9"):
("9")
if Input.is_action_pressed("0"):
("0")
if Input.is_action_pressed(""):
()
if Input.is_action_pressed("归零") or Input.is_action_pressed("ui_menu") or Input.is_action_pressed("ui_home"):
_on_clear_pressed()
if Input.is_action_pressed(""):
()
if Input.is_action_pressed(""):
()
if Input.is_action_pressed(""):
()
if Input.is_action_pressed(""):
()
if Input.is_action_pressed("等于") or Input.is_action_pressed("ui_accept"):
()
if Input.is_action_pressed("取反"):
()
if Input.is_action_pressed("关于"):
_on__pressed()
func ():
if not 使:
.text =
if :
= true
使 = true
else:
.text +=
if not 使:
.text =
if :
= true
使 = true
else:
.text +=
func _number_buttons(btn):
if not 使:
.text = btn.name
if :
= true
使 = true
else:
.text += btn.name
if not 使:
.text = btn.name
if :
= true
使 = true
else:
.text += btn.name
func _on_clear_pressed():
使 = false
= false
= false
.text = ""
.text = "0"
= 0
= 0
= ""
= false
使 = false
= false
= false
.text = ""
.text = "0"
= 0
= 0
= ""
= false
func ():
if str(.text.to_float()) != "0":
.text = str(- .text.to_float())
使 = true
if str(.text.to_float()) != "0":
.text = str(- .text.to_float())
使 = true
func 退():
if 使:
if .text.length() >= 2:
.text = .text.left(-1)
return
.text = "0"
使 = false
= false
if 使:
if .text.length() >= 2:
.text = .text.left(-1)
return
.text = "0"
使 = false
= false
func ():
if :
()
.text = .text
= .text.to_float()
= "/"
.text = str() +
使 = false
= false
= true
if :
()
.text = .text
= .text.to_float()
= "/"
.text = str() +
使 = false
= false
= true
func ():
if :
()
.text = .text
= .text.to_float()
= "*"
.text = str() +
使 = false
= false
= true
if :
()
.text = .text
= .text.to_float()
= "*"
.text = str() +
使 = false
= false
= true
func ():
if :
()
.text = .text
= .text.to_float()
= "-"
.text = str() +
使 = false
= false
= true
if :
()
.text = .text
= .text.to_float()
= "-"
.text = str() +
使 = false
= false
= true
func ():
if :
()
.text = .text
= .text.to_float()
= "+"
.text = str() +
使 = false
= false
= true
if :
()
.text = .text
= .text.to_float()
= "+"
.text = str() +
使 = false
= false
= true
func ():
if == false:
if 使 == true:
.text += "."
= true
else:
.text = "0."
使 = true
= true
if == false:
if 使 == true:
.text += "."
= true
else:
.text = "0."
使 = true
= true
func ():
使 = false
var : float
if .text.right(1) == "=" and != "":
= .text.to_float()
else:
= .text.to_float()
match :
"+":
= +
"-":
= -
"*":
= *
"/":
= /
"":
=
.text = (str() + + str() + "=")
.text = str(snappedf(, 0.0000001))
= false
= false
= false
使 = false
var : float
if .text.right(1) == "=" and != "":
= .text.to_float()
else:
= .text.to_float()
match :
"+":
= +
"-":
= -
"*":
= *
"/":
= /
"":
=
.text = (str() + + str() + "=")
.text = str(snappedf(, 0.0000001))
= false
= false
= false
func _on__pressed():
get_tree().change_scene_to_file("res://关于.tscn")
get_tree().change_scene_to_file("res://关于.tscn")
func _on__pressed():
get_tree().change_scene_to_file("res://设置.tscn")
get_tree().change_scene_to_file("res://设置.tscn")
func (str1:String) -> String:
if str1:
if str1[0] == "0":
if str1[1] == "0" or (str1[1] != "." and str1[1] != "=" and str1[1] != "+" and str1[1] != "-" and str1[1] != "*" and str1[1] != "/"):
return (str1.substr(1))
return str1
if str1:
if str1[0] == "0":
if str1[1] == "0" or (str1[1] != "." and str1[1] != "=" and str1[1] != "+" and str1[1] != "-" and str1[1] != "*" and str1[1] != "/"):
return (str1.substr(1))
return str1
func ():
get_tree().quit()
get_tree().quit()

@ -7,88 +7,88 @@ const CONFIG_PATH := "user://settings.cfg"
func _ready():
()
()
()
()
func (index):
if index == 0:
return ()
elif index == 1:
TranslationServer.set_locale("zh")
elif index == 2:
TranslationServer.set_locale("zht")
elif index == 3:
TranslationServer.set_locale("en")
elif index == 4:
TranslationServer.set_locale("jp")
elif index == 5:
TranslationServer.set_locale("es")
else:
push_error("切换语言时,选项“%d”不存在!" % index)
TranslationServer.set_locale("en")
return index
if index == 0:
return ()
elif index == 1:
TranslationServer.set_locale("zh")
elif index == 2:
TranslationServer.set_locale("zht")
elif index == 3:
TranslationServer.set_locale("en")
elif index == 4:
TranslationServer.set_locale("jp")
elif index == 5:
TranslationServer.set_locale("es")
else:
push_error("切换语言时,选项“%d”不存在!" % index)
TranslationServer.set_locale("en")
return index
func (index):
var file := ConfigFile.new()
file.set_value("General", "Language", index)
var error := file.save(CONFIG_PATH)
if error != OK:
push_error("Failed to save config: %d" % error)
var file := ConfigFile.new()
file.set_value("General", "Language", index)
var error := file.save(CONFIG_PATH)
if error != OK:
push_error("Failed to save config: %d" % error)
func (index):
return ((index))
return ((index))
func ():
var file := ConfigFile.new()
if FileAccess.file_exists(CONFIG_PATH):
var error := file.load(CONFIG_PATH)
if error == OK:
return file.get_value("General", "Language", 0)
else:
push_warning("Failed to load config: %d", error)
return ()
var file := ConfigFile.new()
if FileAccess.file_exists(CONFIG_PATH):
var error := file.load(CONFIG_PATH)
if error == OK:
return file.get_value("General", "Language", 0)
else:
push_warning("Failed to load config: %d", error)
return ()
func ():
return (())
return (())
func ():
var locale := OS.get_locale()
if locale == "zh_CN":
(1)
elif locale == "zh_TW":
(2)
elif locale == "en":
(3)
elif locale == "jp":
(4)
elif locale == "es":
(5)
else:
(3)
return 0
var locale := OS.get_locale()
if locale == "zh_CN":
(1)
elif locale == "zh_TW":
(2)
elif locale == "en":
(3)
elif locale == "jp":
(4)
elif locale == "es":
(5)
else:
(3)
return 0
func ():
return (0)
return (0)
#func 根据语言切换主题(index):
#if index == 1 or index == 3 or index == 5:
#应该使用字体 = true
##propagate_call(“update”)
#else:
#应该使用字体 = false
#if index == 1 or index == 3 or index == 5:
#应该使用字体 = true
##propagate_call(“update”)
#else:
#应该使用字体 = false
func ():
# 获取系统类型
var sys_name := OS.get_name()
# 根据系统类型判断是否调整窗口DPI
if sys_name == "Windows" or sys_name == "macOS" or sys_name == "Linux" or sys_name == "BSD":
get_viewport().size = Vector2(DisplayServer.screen_get_dpi() * 3.5, DisplayServer.screen_get_dpi() * 6.2)
# 获取系统类型
var sys_name := OS.get_name()
# 根据系统类型判断是否调整窗口DPI
if sys_name == "Windows" or sys_name == "macOS" or sys_name == "Linux" or sys_name == "BSD":
get_viewport().size = Vector2(DisplayServer.screen_get_dpi() * 3.5, DisplayServer.screen_get_dpi() * 6.2)

@ -5,14 +5,14 @@ extends Control
#func _ready():
#本场景.set("theme", "res://Assets/样式/得意黑字体.tres")
#本场景.set("theme", "res://Assets/样式/得意黑字体.tres")
@warning_ignore("unused_parameter")
func _unhandled_input(event) -> void:
if Input.is_action_pressed("归零") or Input.is_action_pressed("ui_menu") or Input.is_action_pressed("ui_home") or Input.is_action_pressed("ui_text_backspace") or Input.is_action_pressed("关于") or Input.is_action_pressed("ui_cancel"):
_on__pressed()
if Input.is_action_pressed("归零") or Input.is_action_pressed("ui_menu") or Input.is_action_pressed("ui_home") or Input.is_action_pressed("ui_text_backspace") or Input.is_action_pressed("关于") or Input.is_action_pressed("ui_cancel"):
_on__pressed()
func _on__pressed():
get_tree ().change_scene_to_file("res://主界面.tscn")
get_tree ().change_scene_to_file("res://主界面.tscn")

@ -7,18 +7,18 @@ extends Control
@warning_ignore("unused_parameter")
func _unhandled_input(event) -> void:
if Input.is_action_pressed("归零") or Input.is_action_pressed("ui_menu") or Input.is_action_pressed("ui_home") or Input.is_action_pressed("ui_text_backspace") or Input.is_action_pressed("关于") or Input.is_action_pressed("ui_cancel"):
_on__pressed()
if Input.is_action_pressed("归零") or Input.is_action_pressed("ui_menu") or Input.is_action_pressed("ui_home") or Input.is_action_pressed("ui_text_backspace") or Input.is_action_pressed("关于") or Input.is_action_pressed("ui_cancel"):
_on__pressed()
func _ready():
#本场景.set("theme", "res://Assets/样式/得意黑字体.tres")
.selected = Global.()
#本场景.set("theme", "res://Assets/样式/得意黑字体.tres")
.selected = Global.()
func _on__pressed():
get_tree ().change_scene_to_file("res://主界面.tscn")
get_tree ().change_scene_to_file("res://主界面.tscn")
func _on__item_selected(index):
Global.(index)
Global.(index)

Loading…
Cancel
Save