first Prototype
This commit is contained in:
parent
e11825c698
commit
35ce267482
481 changed files with 17315 additions and 1 deletions
|
|
@ -0,0 +1,49 @@
|
|||
# Translation UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _key
|
||||
var _locale
|
||||
var _translation
|
||||
var _data: LocalizationData
|
||||
|
||||
var _translation_ui_style_empty: StyleBoxFlat
|
||||
|
||||
@onready var _translation_ui = $HBox/Translation
|
||||
|
||||
func set_data(key, translation, locale, data: LocalizationData) -> void:
|
||||
_key = key
|
||||
_translation = translation
|
||||
_locale = locale
|
||||
_data = data
|
||||
_draw_view()
|
||||
|
||||
func _ready() -> void:
|
||||
_init_styles()
|
||||
_init_connections()
|
||||
|
||||
func _init_styles() -> void:
|
||||
var style_box = _translation_ui.get_theme_stylebox("normal", "LineEdit")
|
||||
_translation_ui_style_empty = style_box.duplicate()
|
||||
_translation_ui_style_empty.set_bg_color(Color("#661c1c"))
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _translation_ui.is_connected("text_changed", _on_text_changed):
|
||||
assert(_translation_ui.text_changed.connect(_on_text_changed) == OK)
|
||||
|
||||
func _draw_view() -> void:
|
||||
_translation_ui.text = _translation.value
|
||||
_check_translation_ui()
|
||||
|
||||
func _on_text_changed(new_text) -> void:
|
||||
_translation.value = new_text
|
||||
_check_translation_ui()
|
||||
|
||||
func _check_translation_ui() -> void:
|
||||
if _translation_ui.text.length() <= 0:
|
||||
_translation_ui.add_theme_stylebox_override("normal", _translation_ui_style_empty)
|
||||
_translation_ui.tooltip_text = "Please enter value for your translation"
|
||||
else:
|
||||
_translation_ui.remove_theme_stylebox_override("normal")
|
||||
_translation_ui.tooltip_text = ""
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cfsaie5x0otef
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://bnkc2ox5vcdkq"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/translations/LocalizationTranslation.gd" id="1"]
|
||||
|
||||
[node name="LocalizationTranslation" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_min_size = Vector2(0, 33)
|
||||
theme_override_constants/margin_right = 3
|
||||
theme_override_constants/margin_left = 3
|
||||
theme_override_constants/margin_bottom = 3
|
||||
script = ExtResource( "1" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="."]
|
||||
offset_left = 3.0
|
||||
offset_right = 1021.0
|
||||
offset_bottom = 597.0
|
||||
rect_min_size = Vector2(0, 24)
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Translation" type="LineEdit" parent="HBox"]
|
||||
offset_right = 1018.0
|
||||
offset_bottom = 597.0
|
||||
rect_min_size = Vector2(0, 24)
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
# Translations UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends Panel
|
||||
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _translations_ui = $Scroll/Translations
|
||||
|
||||
const LocalizationTranslationsList = preload("res://addons/localization_editor/scenes/translations/LocalizationTranslationsList.tscn")
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
_init_connections()
|
||||
_update_view()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _data.is_connected("data_changed", _update_view):
|
||||
assert(_data.data_changed.connect(_update_view) == OK)
|
||||
|
||||
func _update_view() -> void:
|
||||
_clear_ui_translations()
|
||||
_add_ui_translations()
|
||||
_view_ui_translations()
|
||||
_update_ui_translations()
|
||||
|
||||
func _clear_ui_translations() -> void:
|
||||
var translations_ui = _translations_ui.get_children()
|
||||
for translation_ui in translations_ui:
|
||||
if translation_ui.has_method("get_locale"):
|
||||
var locale = translation_ui.get_locale()
|
||||
if _data.find_locale(locale) == null:
|
||||
translations_ui.erase(translation_ui)
|
||||
translation_ui.queue_free()
|
||||
|
||||
func _add_ui_translations() -> void:
|
||||
var locales = _data.locales()
|
||||
for locale in locales:
|
||||
if not _ui_translation_exists(locale):
|
||||
_add_ui_translation(locale)
|
||||
|
||||
func _ui_translation_exists(locale) -> bool:
|
||||
for translation_ui in _translations_ui.get_children():
|
||||
if translation_ui.has_method("get_locale"):
|
||||
if translation_ui.get_locale() == locale:
|
||||
return true
|
||||
return false
|
||||
|
||||
func _add_ui_translation(locale: String) -> void:
|
||||
var ui_translation = LocalizationTranslationsList.instantiate()
|
||||
_translations_ui.add_child(ui_translation)
|
||||
ui_translation.set_data(locale, _data)
|
||||
|
||||
func _view_ui_translations() -> void:
|
||||
for translation_ui in _translations_ui.get_children():
|
||||
if translation_ui.has_method("get_locale"):
|
||||
var locale = translation_ui.get_locale()
|
||||
var serarator_ui = _separator_after_translation_ui(translation_ui)
|
||||
if _data.is_locale_visible(locale):
|
||||
translation_ui.show()
|
||||
if serarator_ui != null:
|
||||
serarator_ui.show()
|
||||
else:
|
||||
translation_ui.hide()
|
||||
if serarator_ui != null:
|
||||
serarator_ui.hide()
|
||||
|
||||
func _separator_after_translation_ui(translation_ui: Node) -> Node:
|
||||
var index = translation_ui.get_index()
|
||||
var count = _translations_ui.get_child_count()
|
||||
if index + 1 < count:
|
||||
return _translations_ui.get_child(index + 1)
|
||||
return null
|
||||
|
||||
func _update_ui_translations() -> void:
|
||||
for translation_ui in _translations_ui.get_children():
|
||||
if translation_ui.has_method("update_view"):
|
||||
translation_ui.update_view()
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://c4l5sfsibw527
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://dfykqid37nnvl"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/translations/LocalizationTranslations.gd" id="1"]
|
||||
|
||||
[node name="LocalizationTranslations" type="Panel"]
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( "1" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Translations" type="HBoxContainer" parent="Scroll"]
|
||||
offset_right = 12.0
|
||||
offset_bottom = 12.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
# Translations view for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
|
||||
var _data: LocalizationData
|
||||
var _split_viewport_size = 0
|
||||
var _scroll_position = 0
|
||||
|
||||
@onready var _split_ui = $Split
|
||||
@onready var _keys_ui = $Split/Keys
|
||||
@onready var _translations_ui = $Split/Translations
|
||||
@onready var _translations_list_ui = $Split/Translations/Scroll/Translations
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
_keys_ui.set_data(data)
|
||||
_translations_ui.set_data(data)
|
||||
_init_connections()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _split_ui.is_connected("dragged", _on_split_dragged):
|
||||
assert(_split_ui.dragged.connect(_on_split_dragged) == OK)
|
||||
|
||||
func _process(delta):
|
||||
if _split_viewport_size != size.x:
|
||||
_split_viewport_size = size.x
|
||||
_init_split_offset()
|
||||
_update_scrolls()
|
||||
|
||||
func _init_split_offset() -> void:
|
||||
var offset = 350
|
||||
if _data:
|
||||
offset = _data.setting_translations_split_offset()
|
||||
_split_ui.set_split_offset(-size.x / 2 + offset)
|
||||
|
||||
func _on_split_dragged(offset: int) -> void:
|
||||
if _data != null:
|
||||
var value = -(-size.x / 2 - offset)
|
||||
_data.setting_translations_split_offset_put(value)
|
||||
|
||||
# Workaround for https://github.com/godotengine/godot/issues/22936
|
||||
func _update_scrolls() -> void:
|
||||
var sc = _new_scrolls_position()
|
||||
if _scroll_position != sc:
|
||||
_scroll_position = sc
|
||||
_keys_ui.set_v_scroll(_scroll_position)
|
||||
for child in _translations_list_ui.get_children():
|
||||
if child.has_method("set_v_scroll"):
|
||||
child.set_v_scroll(_scroll_position)
|
||||
|
||||
func _new_scrolls_position() -> int:
|
||||
if _keys_ui == null:
|
||||
return 0
|
||||
var v_1 = [_keys_ui.get_v_scroll()]
|
||||
var v_2 = []
|
||||
for child in _translations_list_ui.get_children():
|
||||
if child.has_method("get_v_scroll"):
|
||||
var v_child = child.get_v_scroll()
|
||||
if v_1[0] == v_child:
|
||||
v_1.append(v_child)
|
||||
else:
|
||||
v_2.append(v_child)
|
||||
if v_2.size() == 0:
|
||||
return v_1[0]
|
||||
if v_1.size() == 1:
|
||||
return v_1[0]
|
||||
return v_2[0]
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://80r1f854w4ml
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bchlj4dnjh8j5"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dfykqid37nnvl" path="res://addons/localization_editor/scenes/translations/LocalizationTranslations.tscn" id="1"]
|
||||
[ext_resource type="PackedScene" path="res://addons/localization_editor/scenes/translations/LocalizationTranslationsKeys.tscn" id="2"]
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/translations/LocalizationTranslationsEditorView.gd" id="3"]
|
||||
|
||||
[node name="LocalizationTranslationsEditorView" type="VBoxContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("3")
|
||||
|
||||
[node name="Split" type="HSplitContainer" parent="."]
|
||||
offset_right = 1920.0
|
||||
offset_bottom = 1080.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
split_offset = -610
|
||||
|
||||
[node name="Keys" parent="Split" instance=ExtResource("2")]
|
||||
offset_right = 344.0
|
||||
offset_bottom = 1080.0
|
||||
|
||||
[node name="Translations" parent="Split" instance=ExtResource("1")]
|
||||
offset_left = 356.0
|
||||
offset_right = 1920.0
|
||||
offset_bottom = 1080.0
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
# Translations head UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
|
||||
var _type: String
|
||||
var _data: LocalizationData
|
||||
|
||||
var _filter = ""
|
||||
|
||||
@onready var _title_ui = $TitleMargin/HBox/Title
|
||||
@onready var _filter_ui = $FilterMargin/HBox/Filter
|
||||
|
||||
func set_data(type: String, data: LocalizationData):
|
||||
_type = type
|
||||
_data = data
|
||||
_filter = _data.data_filter_by_type(_type)
|
||||
_init_connections()
|
||||
_draw_view()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _filter_ui.is_connected("text_changed", _filter_changed_action):
|
||||
assert(_filter_ui.text_changed.connect(_filter_changed_action) == OK)
|
||||
|
||||
func _draw_view() -> void:
|
||||
_filter_ui.text = _filter
|
||||
|
||||
func _filter_changed_action(filter) -> void:
|
||||
_filter = filter
|
||||
_data.data_filter_put(_type, _filter)
|
||||
|
||||
func set_title(text: String) -> void:
|
||||
_title_ui.text = text
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://dsx7p1egydm77
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/translations/LocalizationTranslationsHead.gd" type="Script" id=1]
|
||||
|
||||
[node name="LocalizationHead" type="VBoxContainer"]
|
||||
margin_right = 344.0
|
||||
margin_bottom = 57.0
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TitleMargin" type="MarginContainer" parent="."]
|
||||
margin_right = 344.0
|
||||
margin_bottom = 26.0
|
||||
rect_min_size = Vector2( 0, 26 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
custom_constants/margin_right = 3
|
||||
custom_constants/margin_top = 3
|
||||
custom_constants/margin_left = 3
|
||||
custom_constants/margin_bottom = 0
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="TitleMargin"]
|
||||
margin_left = 3.0
|
||||
margin_top = 3.0
|
||||
margin_right = 341.0
|
||||
margin_bottom = 26.0
|
||||
|
||||
[node name="Title" type="Label" parent="TitleMargin/HBox"]
|
||||
margin_top = 4.0
|
||||
margin_right = 338.0
|
||||
margin_bottom = 18.0
|
||||
size_flags_horizontal = 3
|
||||
text = "KEYS"
|
||||
align = 1
|
||||
|
||||
[node name="FilterMargin" type="MarginContainer" parent="."]
|
||||
margin_top = 30.0
|
||||
margin_right = 344.0
|
||||
margin_bottom = 57.0
|
||||
rect_min_size = Vector2( 0, 26 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
custom_constants/margin_right = 3
|
||||
custom_constants/margin_top = 3
|
||||
custom_constants/margin_left = 3
|
||||
custom_constants/margin_bottom = 0
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="FilterMargin"]
|
||||
margin_left = 3.0
|
||||
margin_top = 3.0
|
||||
margin_right = 341.0
|
||||
margin_bottom = 27.0
|
||||
|
||||
[node name="Filter" type="LineEdit" parent="FilterMargin/HBox"]
|
||||
margin_right = 338.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Filter"
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
# Translations key UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _key
|
||||
var _data: LocalizationData
|
||||
|
||||
var _key_ui_style_empty: StyleBoxFlat
|
||||
var _key_ui_style_double: StyleBoxFlat
|
||||
|
||||
@onready var _add_ui = $HBoxContainer/Add as Button
|
||||
@onready var _del_ui = $HBoxContainer/Del as Button
|
||||
@onready var _key_ui = $HBoxContainer/Key as LineEdit
|
||||
|
||||
func key():
|
||||
return _key
|
||||
|
||||
func set_data(key, data: LocalizationData):
|
||||
_key = key
|
||||
_data = data
|
||||
_init_styles()
|
||||
_init_connections()
|
||||
_draw_view()
|
||||
|
||||
func _init_styles() -> void:
|
||||
var style_box = _key_ui.get_theme_stylebox("normal", "LineEdit")
|
||||
_key_ui_style_empty = style_box.duplicate()
|
||||
_key_ui_style_empty.set_bg_color(Color("#661c1c"))
|
||||
_key_ui_style_double = style_box.duplicate()
|
||||
_key_ui_style_double.set_bg_color(Color("#192e59"))
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _add_ui.is_connected("pressed", _add_pressed):
|
||||
assert(_add_ui.connect("pressed", _add_pressed) == OK)
|
||||
if not _del_ui.is_connected("pressed", _del_pressed):
|
||||
assert(_del_ui.connect("pressed", _del_pressed) == OK)
|
||||
if not _key_ui.is_connected("text_changed", _key_value_changed):
|
||||
assert(_key_ui.text_changed.connect(_key_value_changed) == OK)
|
||||
if not _data.is_connected("data_key_value_changed", _check_key_ui):
|
||||
assert(_data.connect("data_key_value_changed", _check_key_ui) == OK)
|
||||
|
||||
func _draw_view() -> void:
|
||||
_key_ui.text = _key.value
|
||||
_check_key_ui()
|
||||
_update_del_view()
|
||||
|
||||
func _update_del_view():
|
||||
_del_ui.disabled = _data.keys().size() == 1
|
||||
|
||||
func _add_pressed() -> void:
|
||||
_data.add_key_new_after_uuid(_key.uuid)
|
||||
|
||||
func _del_pressed() -> void:
|
||||
_data.del_key(_key.uuid)
|
||||
|
||||
func _key_value_changed(key_value) -> void:
|
||||
_data.key_value_change(_key, key_value)
|
||||
|
||||
func _check_key_ui_text() -> void:
|
||||
if _key_ui.text != _key.value:
|
||||
_key_ui.text = _key.value
|
||||
|
||||
func _check_key_ui() -> void:
|
||||
_key_ui.remove_theme_stylebox_override("normal")
|
||||
if _key_ui.text.length() <= 0:
|
||||
_key_ui.add_theme_stylebox_override("normal", _key_ui_style_empty)
|
||||
_key_ui.tooltip_text = "Please enter a key name"
|
||||
elif _data.is_key_value_double(_key_ui.text):
|
||||
_key_ui.tooltip_text = "Keyname already exists"
|
||||
_key_ui.add_theme_stylebox_override("normal", _key_ui_style_double)
|
||||
else:
|
||||
_key_ui.tooltip_text = ""
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bwn2f1jmnte55
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cwkkxosymxglr"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cbf54t7aak7dy" path="res://addons/localization_editor/icons/Add.svg" id="2_l10x2"]
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/translations/LocalizationTranslationsKey.gd" id="3"]
|
||||
[ext_resource type="Texture2D" uid="uid://caiapkr8oaqe6" path="res://addons/localization_editor/icons/Del.svg" id="3_c34cs"]
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_min_size = Vector2(0, 33)
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
theme_override_constants/margin_right = 3
|
||||
theme_override_constants/margin_left = 3
|
||||
theme_override_constants/margin_bottom = 3
|
||||
script = ExtResource( "3" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
offset_left = 3.0
|
||||
offset_right = 1021.0
|
||||
offset_bottom = 597.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Add" type="Button" parent="HBoxContainer"]
|
||||
offset_right = 28.0
|
||||
offset_bottom = 597.0
|
||||
rect_min_size = Vector2(20, 20)
|
||||
hint_tooltip = "Add translation"
|
||||
size_flags_vertical = 3
|
||||
icon = ExtResource( "2_l10x2" )
|
||||
icon_alignment = 1
|
||||
|
||||
[node name="Del" type="Button" parent="HBoxContainer"]
|
||||
offset_left = 32.0
|
||||
offset_right = 60.0
|
||||
offset_bottom = 597.0
|
||||
rect_min_size = Vector2(20, 20)
|
||||
hint_tooltip = "Del translation"
|
||||
size_flags_vertical = 3
|
||||
icon = ExtResource( "3_c34cs" )
|
||||
|
||||
[node name="Key" type="LineEdit" parent="HBoxContainer"]
|
||||
offset_left = 64.0
|
||||
offset_right = 1018.0
|
||||
offset_bottom = 597.0
|
||||
rect_min_size = Vector2(0, 24)
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
# Translations keys UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends Panel
|
||||
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _head_ui = $VBox/Head
|
||||
@onready var _scroll_ui = $VBox/Scroll
|
||||
@onready var _keys_ui = $VBox/Scroll/Keys
|
||||
|
||||
const LocalizationKey = preload("res://addons/localization_editor/scenes/translations/LocalizationTranslationsKey.tscn")
|
||||
|
||||
func get_v_scroll() -> int:
|
||||
return _scroll_ui.get_v_scroll()
|
||||
|
||||
func set_v_scroll(value: int) -> void:
|
||||
_scroll_ui.set_v_scroll(value)
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
_head_ui.set_data("keys", _data)
|
||||
_init_connections()
|
||||
_update_view()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _data.is_connected("data_changed", _update_view):
|
||||
assert(_data.data_changed.connect(_update_view) == OK)
|
||||
|
||||
func _update_view() -> void:
|
||||
_clear_view()
|
||||
_draw_view()
|
||||
|
||||
func _clear_view() -> void:
|
||||
for key_ui in _keys_ui.get_children():
|
||||
_keys_ui.remove_child(key_ui)
|
||||
key_ui.queue_free()
|
||||
|
||||
func _draw_view() -> void:
|
||||
for key in _data.keys_filtered():
|
||||
_draw_key(key)
|
||||
|
||||
func _draw_key(key) -> void:
|
||||
var key_ui = LocalizationKey.instantiate()
|
||||
_keys_ui.add_child(key_ui)
|
||||
key_ui.set_data(key, _data)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bbm2ytsohxag8
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://gmpsh88x1lgp"]
|
||||
|
||||
[ext_resource type="PackedScene" path="res://addons/localization_editor/scenes/translations/LocalizationTranslationsHead.tscn" id="1"]
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/translations/LocalizationTranslationsKeys.gd" id="2"]
|
||||
|
||||
[node name="LocalizationTranslationsKeys" type="Panel"]
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("2")
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Head" parent="VBox" instance=ExtResource("1")]
|
||||
offset_right = 67.0
|
||||
offset_bottom = 61.0
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="VBox"]
|
||||
offset_top = 65.0
|
||||
offset_right = 67.0
|
||||
offset_bottom = 65.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Keys" type="VBoxContainer" parent="VBox/Scroll"]
|
||||
offset_right = 67.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
# Translations list UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends HBoxContainer
|
||||
|
||||
var _locale: String
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _separator_ui = $Separator
|
||||
@onready var _head_ui = $VBox/Head
|
||||
@onready var _scroll_ui = $VBox/Scroll
|
||||
@onready var _translations_ui = $VBox/Scroll/TranslationsList
|
||||
|
||||
const LocalizationTranslation = preload("res://addons/localization_editor/scenes/translations/LocalizationTranslation.tscn")
|
||||
|
||||
func set_data(locale: String, data: LocalizationData) -> void:
|
||||
_locale = locale
|
||||
_data = data
|
||||
_head_ui.set_data(_locale, _data)
|
||||
update_view()
|
||||
|
||||
func get_locale() -> String:
|
||||
return _locale
|
||||
|
||||
func get_v_scroll() -> int:
|
||||
if _scroll_ui == null:
|
||||
return 0
|
||||
return _scroll_ui.get_v_scroll()
|
||||
|
||||
func set_v_scroll(value: int) -> void:
|
||||
_scroll_ui.set_v_scroll(value)
|
||||
|
||||
func update_view() -> void:
|
||||
if get_index() == 0:
|
||||
_separator_ui.hide()
|
||||
_head_ui.set_title(LocalizationLocalesList.label_by_code(_locale))
|
||||
_add_translations()
|
||||
|
||||
func _add_translations() -> void:
|
||||
_clear_translations()
|
||||
for key in _data.keys_filtered():
|
||||
for translation in key.translations:
|
||||
if translation.locale == _locale:
|
||||
_add_translation(key, translation)
|
||||
|
||||
func _clear_translations() -> void:
|
||||
for translation_ui in _translations_ui.get_children():
|
||||
_translations_ui.remove_child(translation_ui)
|
||||
translation_ui.queue_free()
|
||||
|
||||
func _add_translation(key, translation) -> void:
|
||||
var translation_ui = LocalizationTranslation.instantiate()
|
||||
_translations_ui.add_child(translation_ui)
|
||||
translation_ui.set_data(key, translation, _locale, _data)
|
||||
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cu5pu2j20libw
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/translations/LocalizationTranslationsHead.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://addons/localization_editor/scenes/translations/LocalizationTranslationsList.gd" type="Script" id=2]
|
||||
|
||||
[node name="LocalizationTranslationsList" type="HBoxContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_min_size = Vector2( 250, 0 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Separator" type="VSeparator" parent="."]
|
||||
margin_right = 4.0
|
||||
margin_bottom = 600.0
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="."]
|
||||
margin_left = 8.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Head" parent="VBox" instance=ExtResource( 1 )]
|
||||
margin_right = 1016.0
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="VBox"]
|
||||
margin_top = 61.0
|
||||
margin_right = 1016.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="TranslationsList" type="VBoxContainer" parent="VBox/Scroll"]
|
||||
margin_right = 1016.0
|
||||
margin_bottom = 539.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
Loading…
Add table
Add a link
Reference in a new issue