first Prototype
This commit is contained in:
parent
e11825c698
commit
35ce267482
481 changed files with 17315 additions and 1 deletions
|
|
@ -0,0 +1,92 @@
|
|||
# Locale UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _locale
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _selection_ui = $HBox/Selection as CheckBox
|
||||
@onready var _locale_ui = $HBox/Locale as Label
|
||||
@onready var _eye_ui = $HBox/Eye as TextureButton
|
||||
|
||||
const IconOpen = preload("res://addons/localization_editor/icons/Open.svg")
|
||||
const IconClose = preload("res://addons/localization_editor/icons/Close.svg")
|
||||
|
||||
func locale():
|
||||
return _locale
|
||||
|
||||
func set_data(locale, data: LocalizationData) -> void:
|
||||
_locale = locale
|
||||
_data = data
|
||||
_draw_view()
|
||||
_init_connections()
|
||||
|
||||
func _draw_view() -> void:
|
||||
_selection_ui.text = _locale
|
||||
_locale_ui.text = LocalizationLocalesList.label_by_code(_locale)
|
||||
_selection_ui_state()
|
||||
_eye_ui_state()
|
||||
|
||||
func _selection_ui_state() -> void:
|
||||
_selection_ui.set_pressed(_data.find_locale(_locale) != null)
|
||||
|
||||
func _eye_ui_state() -> void:
|
||||
_eye_ui.set_pressed(not _data.is_locale_visible(_locale))
|
||||
_update_view_eye(_selection_ui.is_pressed())
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _selection_ui.is_connected("toggled", _on_selection_changed):
|
||||
assert(_selection_ui.toggled.connect(_on_selection_changed) == OK)
|
||||
if not _eye_ui.is_connected("toggled", _on_eye_changed):
|
||||
assert(_eye_ui.toggled.connect(_on_eye_changed) == OK)
|
||||
|
||||
func _on_selection_changed(value) -> void:
|
||||
if value == true:
|
||||
_data.add_locale(_locale)
|
||||
_update_view_eye(value)
|
||||
else:
|
||||
_show_confirm_dialog()
|
||||
|
||||
func _show_confirm_dialog() -> void:
|
||||
var root = get_tree().get_root()
|
||||
var confirm_dialog = ConfirmationDialog.new()
|
||||
confirm_dialog.title = "Confirm"
|
||||
confirm_dialog.dialog_text = "Are you sure to delete locale with all translations and remaps?"
|
||||
confirm_dialog.confirmed.connect(_on_confirm_dialog_ok.bind(root, confirm_dialog))
|
||||
confirm_dialog.cancelled.connect(_on_confirm_dialog_cancelled.bind(root, confirm_dialog))
|
||||
root.add_child(confirm_dialog)
|
||||
confirm_dialog.popup_centered()
|
||||
|
||||
func _on_confirm_dialog_ok(root, confirm_dialog) -> void:
|
||||
_data.del_locale(_locale)
|
||||
_update_view_eye(false)
|
||||
_confirm_dialog_remove(root, confirm_dialog)
|
||||
|
||||
func _on_confirm_dialog_cancelled(root, confirm_dialog) -> void:
|
||||
_selection_ui.set_pressed(true)
|
||||
_confirm_dialog_remove(root, confirm_dialog)
|
||||
|
||||
func _confirm_dialog_remove(root, confirm_dialog) -> void:
|
||||
root.remove_child(confirm_dialog)
|
||||
confirm_dialog.queue_free()
|
||||
|
||||
func _update_view_eye(value: bool) -> void:
|
||||
if value:
|
||||
_eye_ui.show()
|
||||
_update_visible_icon_from_data()
|
||||
else:
|
||||
_eye_ui.hide()
|
||||
|
||||
func _update_visible_icon_from_data() -> void:
|
||||
_update_visible_icon(_data.is_locale_visible(_locale))
|
||||
|
||||
func _on_eye_changed(value) -> void:
|
||||
if value:
|
||||
_data.setting_locales_visibility_put(_locale)
|
||||
else:
|
||||
_data.setting_locales_visibility_del(_locale)
|
||||
_update_visible_icon(!value)
|
||||
|
||||
func _update_visible_icon(value: bool) -> void:
|
||||
_eye_ui.texture_normal = IconOpen if value else IconClose
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://crfl2nduqv6fy
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://c8jdbet30gbuk"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/locales/LocalizationLocale.gd" id="2"]
|
||||
|
||||
[node name="Locale" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_right = 3
|
||||
theme_override_constants/margin_top = 3
|
||||
theme_override_constants/margin_left = 3
|
||||
script = ExtResource( "2" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="."]
|
||||
offset_left = 3.0
|
||||
offset_top = 3.0
|
||||
offset_right = 1021.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Selection" type="CheckBox" parent="HBox"]
|
||||
offset_right = 80.0
|
||||
offset_bottom = 31.0
|
||||
rect_min_size = Vector2(80, 0)
|
||||
hint_tooltip = "Select language for translation"
|
||||
size_flags_vertical = 0
|
||||
text = "en"
|
||||
|
||||
[node name="Locale" type="Label" parent="HBox"]
|
||||
offset_left = 84.0
|
||||
offset_right = 994.0
|
||||
offset_bottom = 26.0
|
||||
rect_min_size = Vector2(0, 24)
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
text = "English"
|
||||
|
||||
[node name="Eye" type="TextureButton" parent="HBox"]
|
||||
offset_left = 998.0
|
||||
offset_right = 1018.0
|
||||
offset_bottom = 20.0
|
||||
rect_min_size = Vector2(20, 20)
|
||||
size_flags_vertical = 0
|
||||
toggle_mode = true
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# Locales UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _locales_ui = $Panel/Scroll/VBox as VBoxContainer
|
||||
|
||||
const LocalizationLocale = preload("res://addons/localization_editor/scenes/locales/LocalizationLocale.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_view()
|
||||
_draw_view()
|
||||
|
||||
func _clear_view() -> void:
|
||||
for child in _locales_ui.get_children():
|
||||
_locales_ui.remove_child(child)
|
||||
child.queue_free()
|
||||
|
||||
func _draw_view() -> void:
|
||||
for locale in LocalizationLocalesList.LOCALES:
|
||||
if _is_locale_to_show(locale):
|
||||
var locale_ui = LocalizationLocale.instantiate()
|
||||
_locales_ui.add_child(locale_ui)
|
||||
locale_ui.set_data(locale, _data)
|
||||
|
||||
func _is_locale_to_show(locale) -> bool:
|
||||
if not _is_locale_to_show_by_selection(locale):
|
||||
return false
|
||||
return _is_locale_to_show_by_filter(locale)
|
||||
|
||||
func _is_locale_to_show_by_selection(locale) -> bool:
|
||||
return !_data.locales_selected() or _data.find_locale(locale) != null
|
||||
|
||||
func _is_locale_to_show_by_filter(locale) -> bool:
|
||||
var filter = _data.locales_filter()
|
||||
return filter == "" or filter in locale or filter in LocalizationLocalesList.label_by_code(locale)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b6clr41xvv4yr
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://6ma47o0u2v2l"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/locales/LocalizationLocales.gd" id="1"]
|
||||
|
||||
[node name="LocalizationLocales" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( "1" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="Panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="Panel/Scroll"]
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Locales view for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
|
||||
@onready var _filter_ui = $Filter
|
||||
@onready var _locales_ui = $Locales
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_filter_ui.set_data(data)
|
||||
_locales_ui.set_data(data)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://df2ql0j1qx2ag
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bikmkc3ntiugr"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/locales/LocalizationLocalesEditorView.gd" id="1"]
|
||||
[ext_resource type="PackedScene" path="res://addons/localization_editor/scenes/locales/LocalizationLocalesFilter.tscn" id="2"]
|
||||
[ext_resource type="PackedScene" uid="uid://6ma47o0u2v2l" path="res://addons/localization_editor/scenes/locales/LocalizationLocales.tscn" id="3"]
|
||||
|
||||
[node name="LocalizationLocalesEditorView" type="VBoxContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( "1" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Filter" parent="." instance=ExtResource( "2" )]
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 33.0
|
||||
|
||||
[node name="Locales" parent="." instance=ExtResource( "3" )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_top = 37.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# Locales filter for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _filter_ui = $HBox/Filter as LineEdit
|
||||
@onready var _selected_ui = $HBox/Selected as CheckBox
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
_init_connections()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _filter_ui.is_connected("text_changed", _on_filter_changed):
|
||||
assert(_filter_ui.text_changed.connect(_on_filter_changed) == OK)
|
||||
if not _selected_ui.is_connected("toggled", _on_selected_changed):
|
||||
assert(_selected_ui.toggled.connect(_on_selected_changed) == OK)
|
||||
|
||||
func _on_filter_changed(text: String) -> void:
|
||||
_data.set_locales_filter(text)
|
||||
|
||||
func _on_selected_changed(value) -> void:
|
||||
_data.set_locales_selected(value)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://d2wo8kjq5u2t
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/locales/LocalizationLocalesFilter.gd" type="Script" id=1]
|
||||
|
||||
[node name="LocalizationLocalesFilter" type="MarginContainer"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 38.0
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="."]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 38.0
|
||||
|
||||
[node name="Filter" type="LineEdit" parent="HBox"]
|
||||
margin_right = 937.0
|
||||
margin_bottom = 38.0
|
||||
hint_tooltip = "Enter text to filter locales"
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Filter"
|
||||
|
||||
[node name="Selected" type="CheckBox" parent="HBox"]
|
||||
margin_left = 941.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 38.0
|
||||
hint_tooltip = "Check to view only selected locales"
|
||||
text = "Selected"
|
||||
Loading…
Add table
Add a link
Reference in a new issue