Исправления работы entry и конвертации в String

This commit is contained in:
MaD_CaT
2023-07-31 08:31:22 +03:00
parent d57ddc2f63
commit 6e4b2fce41
12 changed files with 636 additions and 635 deletions

View File

@@ -1,12 +1,12 @@
[gd_scene load_steps=5 format=3 uid="uid://87gtvqd7bbje"] [gd_scene load_steps=5 format=3 uid="uid://87gtvqd7bbje"]
[ext_resource type="Script" path="res://main.gd" id="1_kt06w"] [ext_resource type="Script" path="res://main.gd" id="1_qcx24"]
[ext_resource type="Script" path="res://table.gd" id="2_k7rc6"] [ext_resource type="Script" path="res://table.gd" id="2_y3x5h"]
[ext_resource type="Texture2D" uid="uid://cex4jiu1pcj3x" path="res://edit-add-0.png" id="3_pruca"] [ext_resource type="Texture2D" uid="uid://cex4jiu1pcj3x" path="res://edit-add-0.png" id="3_5pb81"]
[ext_resource type="Texture2D" uid="uid://cx746np1wexnd" path="res://edit-add-1.png" id="4_3d2wd"] [ext_resource type="Texture2D" uid="uid://cx746np1wexnd" path="res://edit-add-1.png" id="4_i1fqu"]
[node name="main" type="Node2D"] [node name="main" type="Node2D"]
script = ExtResource("1_kt06w") script = ExtResource("1_qcx24")
[node name="tabs" type="TabContainer" parent="."] [node name="tabs" type="TabContainer" parent="."]
offset_right = 1594.0 offset_right = 1594.0
@@ -22,14 +22,14 @@ anchor_bottom = 1.0
offset_top = 100.0 offset_top = 100.0
offset_right = 1.0 offset_right = 1.0
offset_bottom = 10.0 offset_bottom = 10.0
script = ExtResource("2_k7rc6") script = ExtResource("2_y3x5h")
[node name="header_t" type="GridContainer" parent="tabs/threats"] [node name="header_t" type="GridContainer" parent="tabs/threats"]
layout_mode = 0 layout_mode = 0
offset_top = 57.0 offset_top = 57.0
offset_right = 1584.0 offset_right = 1584.0
offset_bottom = 96.0 offset_bottom = 96.0
script = ExtResource("2_k7rc6") script = ExtResource("2_y3x5h")
[node name="btn_add" type="TextureButton" parent="tabs/threats"] [node name="btn_add" type="TextureButton" parent="tabs/threats"]
layout_mode = 0 layout_mode = 0
@@ -37,8 +37,8 @@ offset_left = 1533.0
offset_top = -2.0 offset_top = -2.0
offset_right = 1581.0 offset_right = 1581.0
offset_bottom = 46.0 offset_bottom = 46.0
texture_normal = ExtResource("3_pruca") texture_normal = ExtResource("3_5pb81")
texture_pressed = ExtResource("4_3d2wd") texture_pressed = ExtResource("4_i1fqu")
[node name="btn_del" type="TextureButton" parent="tabs/threats"] [node name="btn_del" type="TextureButton" parent="tabs/threats"]
layout_mode = 0 layout_mode = 0
@@ -56,11 +56,11 @@ layout_mode = 0
offset_top = 100.0 offset_top = 100.0
offset_right = 1587.0 offset_right = 1587.0
offset_bottom = 861.0 offset_bottom = 861.0
script = ExtResource("2_k7rc6") script = ExtResource("2_y3x5h")
[node name="header_p" type="GridContainer" parent="tabs/pomehi"] [node name="header_p" type="GridContainer" parent="tabs/pomehi"]
layout_mode = 0 layout_mode = 0
offset_top = 57.0 offset_top = 57.0
offset_right = 32.0 offset_right = 32.0
offset_bottom = 96.0 offset_bottom = 96.0
script = ExtResource("2_k7rc6") script = ExtResource("2_y3x5h")

View File

@@ -17,11 +17,11 @@ config/icon="res://icon.png"
[autoload] [autoload]
Table="*res://table.gd"
Consts="*res://consts.gd" Consts="*res://consts.gd"
Threats="*res://threats.gd" Threats="*res://threats.gd"
Pomehi="*res://pomehi.gd" Pomehi="*res://pomehi.gd"
Tools="*res://tools.gd" Tools="*res://tools.gd"
Table="*res://table.gd"
[display] [display]
@@ -40,4 +40,5 @@ common/enable_pause_aware_picking=true
[rendering] [rendering]
renderer/rendering_method="gl_compatibility"
environment/defaults/default_environment="res://main.tres" environment/defaults/default_environment="res://main.tres"

View File

@@ -4,6 +4,8 @@ var id_array: Array # Массив id целей
var treats : Dictionary # Словарь целей var treats : Dictionary # Словарь целей
var msg_counter : int = 0 # Счётчик отправленных пакетов var msg_counter : int = 0 # Счётчик отправленных пакетов
var g_table: GridContainer
const TableCellType1 = preload('res://ячейка-1.tscn') const TableCellType1 = preload('res://ячейка-1.tscn')
const TableCellType2 = preload('res://кнопка-3.tscn') const TableCellType2 = preload('res://кнопка-3.tscn')
const TableCellType3 = preload('res://кнопка-4.tscn') const TableCellType3 = preload('res://кнопка-4.tscn')
@@ -242,19 +244,19 @@ class Threat:
return value return value
func set_tmod(val): func set_tmod(val):
var value = String(val) var value = str(val)
row.tmod[0] = value row.tmod[0] = value
row.tmod[1] = false if value == '<неопр.>' else true row.tmod[1] = false if value == '<неопр.>' else true
return value return value
func set_freqm(val): func set_freqm(val):
var value = String(val) var value = str(val)
row.freqm[0] = value row.freqm[0] = value
row.freqm[1] = false if value == '<неопр.>' else true row.freqm[1] = false if value == '<неопр.>' else true
return value return value
func set_proto(val): func set_proto(val):
var value = String(val) var value = str(val)
row.proto[0] = value row.proto[0] = value
row.proto[1] = false if value == '<неопр.>' else true row.proto[1] = false if value == '<неопр.>' else true
return value return value
@@ -268,10 +270,11 @@ func init_treats(header, table, btn_add, btn_del): # Инициализац
on_btn_add(table) on_btn_add(table)
init_table(header, TABLE_COLUMN_SIZES) init_table(header, TABLE_COLUMN_SIZES)
init_table(table, TABLE_COLUMN_SIZES) init_table(table, TABLE_COLUMN_SIZES)
g_table = table
table.align_to_left_bottom(header, Vector2(0, 2)) table.align_to_left_bottom(header, Vector2(0, 2))
table.connect('row_pressed', Callable(self, 'on_row_pressed').bind(table)) table.connect('row_pressed', Callable(self, 'on_row_pressed').bind(table))
table.set_callbacks(self, 'text_submitted', 'on_edit_entry', TABLE_ENTRY_COLUMNS, [table]) table.set_callbacks(self, 'text_submitted', 'on_edit_entry', TABLE_ENTRY_COLUMNS, [])
table.set_callbacks(self, 'item_selected', 'on_item_selected', COLUMN_OPT_BTN, [table]) table.set_callbacks(self, 'item_selected', 'on_item_selected', COLUMN_OPT_BTN, [])
btn_add.connect('button_up', Callable(self, 'on_btn_add').bind(table)) btn_add.connect('button_up', Callable(self, 'on_btn_add').bind(table))
btn_del.connect('button_up', Callable(self, 'on_btn_del').bind(table)) btn_del.connect('button_up', Callable(self, 'on_btn_del').bind(table))
@@ -296,22 +299,22 @@ func init_opt_btns(row : int, table):
cell.select(0) cell.select(0)
func on_item_selected(item_num, node, table): func on_item_selected(item_num, node):
var optbtn_text = node.text var optbtn_text = node.text
var indexis = table.get_key_indexes(node.name) var indexis = g_table.get_key_indexes(node.name)
var row_i = indexis[1] var row_i = indexis[1]
var col_i = indexis[0] var col_i = indexis[0]
var cell = table.get_node2(0,row_i) var cell = g_table.get_node2(0,row_i)
var value = set_value(optbtn_text, cell.text, col_i) var value = set_value(optbtn_text, cell.text, col_i)
func on_edit_entry(text : String, entry, table): func on_edit_entry(text : String, entry):
var indexis = table.get_key_indexes(entry.name) var indexis = g_table.get_key_indexes(entry[0].name)
var row_i = indexis[1] var row_i = indexis[1]
var col_i = indexis[0] var col_i = indexis[0]
var cell = table.get_node2(0,row_i) var cell = g_table.get_node2(0,row_i)
var value = set_value(text, cell.text, col_i) var value = set_value(text, cell.text, col_i)
entry.text = String(value) entry[0].text = str(value)
func set_value(val : String, treat_id : String, column : int): func set_value(val : String, treat_id : String, column : int):

View File

@@ -22,7 +22,8 @@ func check_len(val, value):
return value return value
func check_empty(val): func check_empty(val):
if String(val) == '':
if str(val) == '':
return false return false
else: else:
return true return true

View File

@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=2] [gd_scene load_steps=2 format=3 uid="uid://c15amg0flhafs"]
[sub_resource type="StyleBoxFlat" id=1] [sub_resource type="StyleBoxFlat" id="1"]
bg_color = Color(1, 0.596078, 0.4, 1) bg_color = Color(1, 0.596078, 0.4, 1)
[node name="heder" type="Label"] [node name="heder" type="Label"]
@@ -9,7 +9,5 @@ offset_bottom = 30.0
size_flags_horizontal = 15 size_flags_horizontal = 15
size_flags_vertical = 15 size_flags_vertical = 15
theme_override_colors/font_color = Color(0.0313726, 0.105882, 0.184314, 1) theme_override_colors/font_color = Color(0.0313726, 0.105882, 0.184314, 1)
theme_override_styles/normal = SubResource( 1 ) theme_override_styles/normal = SubResource("1")
align = 1
valign = 1
clip_text = true clip_text = true

View File

@@ -1,7 +1,7 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=3 format=3 uid="uid://ccxre8mwhndjk"]
[ext_resource path="res://индикатор-1-1.png" type="Texture2D" id=1] [ext_resource type="Texture2D" uid="uid://b3ext3w4ftgg2" path="res://индикатор-1-1.png" id="1"]
[ext_resource path="res://индикатор-1-0.png" type="Texture2D" id=2] [ext_resource type="Texture2D" uid="uid://dag8n0gknjwak" path="res://индикатор-1-0.png" id="2"]
[node name="indicator_1" type="TextureButton"] [node name="indicator_1" type="TextureButton"]
modulate = Color(1, 0.596078, 0.4, 1) modulate = Color(1, 0.596078, 0.4, 1)
@@ -9,5 +9,5 @@ offset_right = 35.0
offset_bottom = 29.0 offset_bottom = 29.0
toggle_mode = true toggle_mode = true
button_mask = 0 button_mask = 0
texture_normal = ExtResource( 2 ) texture_normal = ExtResource("2")
texture_pressed = ExtResource( 1 ) texture_pressed = ExtResource("1")

View File

@@ -1,4 +1,4 @@
[gd_scene format=2] [gd_scene format=3 uid="uid://rao4t6hjy61n"]
[node name="OptionButton" type="OptionButton"] [node name="OptionButton" type="OptionButton"]
offset_right = 80.0 offset_right = 80.0

View File

@@ -1,9 +1,7 @@
[gd_scene format=2] [gd_scene format=3 uid="uid://cpnb6807byw0v"]
[node name="Label" type="Label"] [node name="Label" type="Label"]
offset_right = 122.0 offset_right = 122.0
offset_bottom = 34.0 offset_bottom = 34.0
theme_override_colors/font_color = Color(1, 0.596078, 0.4, 1) theme_override_colors/font_color = Color(1, 0.596078, 0.4, 1)
align = 1
valign = 1
clip_text = true clip_text = true

View File

@@ -1,4 +1,4 @@
[gd_scene format=2] [gd_scene format=3 uid="uid://i1udkl6ij2pf"]
[node name="LineEdit" type="LineEdit"] [node name="LineEdit" type="LineEdit"]
offset_right = 82.0 offset_right = 82.0