Автоматическое сохранение настроек, убраны излишние обводки при фокусе.
This commit is contained in:
@@ -90,7 +90,8 @@ const COLOR_THEME = 57 ## Цвет темы
|
||||
var name_to_line_index: = {} ## Для преобразования названия параметра в номер строки
|
||||
var table_color_instance: Node ## Нода цвета кнопки подавления
|
||||
|
||||
func on_checkbutton_pressed(i_row: int): on_row_pressed(i_row)
|
||||
func on_checkbutton_pressed(i_row: int):
|
||||
on_row_pressed(i_row)
|
||||
|
||||
|
||||
## Вызывается, когда узел впервые попадает в дерево сцены.
|
||||
@@ -107,28 +108,34 @@ func on_external_cu_btn_pressed(btn) -> void:
|
||||
ProjectSettings.set_setting('application/config/Внешнее управление', btn.button_pressed)
|
||||
if btn.button_pressed:
|
||||
signaller.emit_signal('interfer_off_all')
|
||||
_autosave_now()
|
||||
|
||||
|
||||
func on_trassa_btn_pressed(btn) -> void:
|
||||
ProjectSettings.set_setting('application/config/Внешнее указание Трасса', btn.button_pressed)
|
||||
_autosave_now()
|
||||
|
||||
|
||||
func on_vk_pressed(btn) -> void:
|
||||
signaller.emit_signal('kb_pressed', btn.button_pressed)
|
||||
_autosave_now()
|
||||
|
||||
|
||||
func on_gos_pressed(btn) -> void:
|
||||
ProjectSettings.set_setting('application/config/Включить работу по своим целям', btn.button_pressed)
|
||||
_autosave_now()
|
||||
|
||||
|
||||
func on_ems2_pressed(btn) -> void:
|
||||
var state = btn.button_pressed
|
||||
signaller.emit_signal('ems2_hide_pressed', state)
|
||||
_autosave_now()
|
||||
|
||||
|
||||
func on_debag_control_pressed(btn) -> void:
|
||||
var state = btn.button_pressed
|
||||
signaller.emit_signal("debag_control_pressed", state)
|
||||
_autosave_now()
|
||||
|
||||
|
||||
func on_row_pressed(i_row: int):
|
||||
@@ -201,6 +208,7 @@ func setting_tab():
|
||||
child.connect('pressed', Callable(self, 'on_checkbutton_pressed').bind(i))
|
||||
var val = ProjectSettings.get_setting('application/config/%s' % param_name, true)
|
||||
child.set_pressed(val)
|
||||
child.pressed.connect(_autosave_now)
|
||||
else:
|
||||
if settings_data.has(param_name):
|
||||
var val = settings_data[param_name]
|
||||
@@ -209,7 +217,7 @@ func setting_tab():
|
||||
if edit_node:
|
||||
if edit_node is LineEdit:
|
||||
$scroll_set/table.set_node_control(1, i, true)
|
||||
edit_node.connect("text_submitted", Callable(self, "_on_line_edit_enter_pressed").bind(i))
|
||||
edit_node.focus_exited.connect(_autosave_now)
|
||||
$scroll_set/table.set_node_editable(1, COMMIT, false)
|
||||
$scroll_set/table.set_columns_min_size([600, 950])
|
||||
$scroll_set/table.set_columns_alignments(ALIGNMENT)
|
||||
@@ -280,6 +288,7 @@ func button_settings():
|
||||
func on_theme_toggle_pressed(btn: CheckButton) -> void:
|
||||
var is_light = btn.button_pressed
|
||||
ProjectSettings.set_setting("application/config/Цвет темы программы", is_light)
|
||||
_autosave_now()
|
||||
|
||||
func _update_theme_colors():
|
||||
var color_white = $scroll_set/table.get_node2(1, COLOR_WHITE)
|
||||
@@ -292,21 +301,25 @@ func on_color_closed_w(color_white: ColorPickerButton):
|
||||
var col_w = [color_white.color.r, color_white.color.g, color_white.color.b, color_white.color.a]
|
||||
color_white.text = JSON.stringify(col_w)
|
||||
ProjectSettings.set_setting('application/config/%s' % 'Цвет фона схемы', color_white.text)
|
||||
_autosave_now()
|
||||
|
||||
|
||||
func on_color_closed_b(color_black: ColorPickerButton):
|
||||
var col_b = [color_black.color.r, color_black.color.g, color_black.color.b, color_black.color.a]
|
||||
color_black.text = JSON.stringify(col_b)
|
||||
ProjectSettings.set_setting('application/config/%s' % 'Цвет схемы', color_black.text)
|
||||
_autosave_now()
|
||||
|
||||
|
||||
func on_color_closed(color_btn_act: ColorPickerButton):
|
||||
var col = [color_btn_act.color.r, color_btn_act.color.g, color_btn_act.color.b, color_btn_act.color.a]
|
||||
color_btn_act.text = JSON.stringify(col)
|
||||
ProjectSettings.set_setting('application/config/%s' % 'Цвет кнопки \"Подавление\"', color_btn_act.text)
|
||||
_autosave_now()
|
||||
|
||||
|
||||
func _on_btn_save_settings_pressed():
|
||||
func _autosave_now() -> void:
|
||||
print("AUTOSAVE")
|
||||
var json_data = {}
|
||||
for i in SETTING_TABLE.size():
|
||||
var parameter = SETTING_TABLE[i][0]
|
||||
@@ -351,10 +364,3 @@ func _on_btn_save_settings_pressed():
|
||||
if file.store_string(json_string):
|
||||
log.info('Настройки сохранены в файл \"%s\"' % abs_path)
|
||||
file.close()
|
||||
|
||||
|
||||
func _on_line_edit_enter_pressed(new_text: String, row_index: int) -> void:
|
||||
var parameter = SETTING_TABLE[row_index][0]
|
||||
ProjectSettings.set_setting("application/config/%s" % parameter, new_text)
|
||||
_on_btn_save_settings_pressed()
|
||||
get_viewport().gui_release_focus()
|
||||
|
||||
@@ -1,21 +1,7 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://bnptm4rlp60dq"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://bnptm4rlp60dq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dabpum5iqxc7y" path="res://scenes/настройки/настройки.gd" id="1_60bya"]
|
||||
[ext_resource type="Script" uid="uid://c5pq0hbrij34d" path="res://table/table.gd" id="2_6sx73"]
|
||||
[ext_resource type="Texture2D" uid="uid://csnts8f155sf7" path="res://data/save1.png" id="3_dbpks"]
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_pyq6h"]
|
||||
texture = ExtResource("3_dbpks")
|
||||
modulate_color = Color(0.8, 0.533333, 0.27451, 1)
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_l5g3r"]
|
||||
texture = ExtResource("3_dbpks")
|
||||
expand_margin_left = 20.0
|
||||
expand_margin_top = 20.0
|
||||
modulate_color = Color(0.8, 0.533333, 0.27451, 1)
|
||||
|
||||
[sub_resource type="StyleBoxTexture" id="StyleBoxTexture_tbxk6"]
|
||||
texture = ExtResource("3_dbpks")
|
||||
|
||||
[node name="Настройки" type="Panel"]
|
||||
script = ExtResource("1_60bya")
|
||||
@@ -33,26 +19,8 @@ layout_mode = 0
|
||||
offset_left = 16.0
|
||||
offset_top = 44.0
|
||||
offset_right = 1584.0
|
||||
offset_bottom = 988.0
|
||||
offset_bottom = 1144.0
|
||||
|
||||
[node name="table" type="GridContainer" parent="scroll_set"]
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_6sx73")
|
||||
|
||||
[node name="btn_save" type="Button" parent="."]
|
||||
layout_mode = 0
|
||||
offset_left = 1523.0
|
||||
offset_top = 1057.0
|
||||
offset_right = 2035.0
|
||||
offset_bottom = 1569.0
|
||||
scale = Vector2(0.1, 0.1)
|
||||
tooltip_text = "Сохранить настройки"
|
||||
focus_mode = 0
|
||||
theme_override_styles/focus = SubResource("StyleBoxTexture_pyq6h")
|
||||
theme_override_styles/disabled = SubResource("StyleBoxTexture_pyq6h")
|
||||
theme_override_styles/hover_pressed = SubResource("StyleBoxTexture_pyq6h")
|
||||
theme_override_styles/hover = SubResource("StyleBoxTexture_pyq6h")
|
||||
theme_override_styles/pressed = SubResource("StyleBoxTexture_l5g3r")
|
||||
theme_override_styles/normal = SubResource("StyleBoxTexture_tbxk6")
|
||||
|
||||
[connection signal="pressed" from="btn_save" to="." method="_on_btn_save_settings_pressed"]
|
||||
|
||||
Reference in New Issue
Block a user