add and edit installs
This commit is contained in:
parent
db5700b62d
commit
040a9ad1af
@ -321,11 +321,11 @@ func get_version_metadata(version: String) -> ReleaseMetadata:
|
|||||||
return releases.releases.get(version)
|
return releases.releases.get(version)
|
||||||
|
|
||||||
|
|
||||||
func get_installed_versions() -> Array[ReleaseMetadata]:
|
func get_installed_versions() -> Dictionary:
|
||||||
var res: Array[ReleaseMetadata] = []
|
var res: Dictionary
|
||||||
for version in releases.releases:
|
for version in releases.releases:
|
||||||
if is_version_installed(version):
|
if is_version_installed(version):
|
||||||
res.append(releases.releases[version])
|
res[version] = releases.releases[version]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
extends VBoxContainer
|
extends VBoxContainer
|
||||||
class_name GroupMenu
|
class_name GroupMenu
|
||||||
|
|
||||||
|
const ITEM_SCENE := preload("res://UI/Components/InstallItem.tscn")
|
||||||
|
|
||||||
@onready var collapse_button: Button = %CollapseButton
|
@onready var collapse_button: Button = %CollapseButton
|
||||||
@onready var header_icon: TextureRect = %HeaderIcon
|
@onready var header_icon: TextureRect = %HeaderIcon
|
||||||
@onready var header_text_label: Label = %HeaderTextLabel
|
@onready var header_text_label: Label = %HeaderTextLabel
|
||||||
@ -16,6 +18,8 @@ class_name GroupMenu
|
|||||||
|
|
||||||
@onready var header_container: HBoxContainer = %HeaderContainer
|
@onready var header_container: HBoxContainer = %HeaderContainer
|
||||||
|
|
||||||
|
@onready var install_edit_dialog: InstallEditDialog = %InstallEditDialog
|
||||||
|
|
||||||
var group_metadata: GroupMetadata
|
var group_metadata: GroupMetadata
|
||||||
|
|
||||||
signal add_install_button_pressed
|
signal add_install_button_pressed
|
||||||
@ -32,8 +36,8 @@ func _ready() -> void:
|
|||||||
set_children_visible(b.button_pressed)
|
set_children_visible(b.button_pressed)
|
||||||
)
|
)
|
||||||
|
|
||||||
add_install_button.pressed.connect(func(): add_install_button_pressed.emit())
|
add_install_button.pressed.connect(add_new_install)
|
||||||
|
install_edit_dialog.canceled.connect(install_edit_dialog.clear_ok_button_connections)
|
||||||
# edit_group_button.pressed.connect(setup_rename)
|
# edit_group_button.pressed.connect(setup_rename)
|
||||||
edit_group_button.pressed.connect(func(): edit_group_button_pressed.emit())
|
edit_group_button.pressed.connect(func(): edit_group_button_pressed.emit())
|
||||||
delete_group_button.pressed.connect(func(): delete_button_pressed.emit())
|
delete_group_button.pressed.connect(func(): delete_button_pressed.emit())
|
||||||
@ -41,9 +45,33 @@ func _ready() -> void:
|
|||||||
header_text_label.gui_input.connect(_on_header_text_label_gui_input)
|
header_text_label.gui_input.connect(_on_header_text_label_gui_input)
|
||||||
|
|
||||||
|
|
||||||
func add(item: InstallItem) -> int:
|
func add_new_install() -> void:
|
||||||
child_container.add_child(item)
|
install_edit_dialog.clear()
|
||||||
return child_container.get_child_count()
|
install_edit_dialog.ok_button_text = "Create"
|
||||||
|
|
||||||
|
install_edit_dialog.confirmed.connect(
|
||||||
|
func():
|
||||||
|
var im := install_edit_dialog.get_install_metadata()
|
||||||
|
var install_item: InstallItem = ITEM_SCENE.instantiate()
|
||||||
|
child_container.add_child(install_item)
|
||||||
|
install_item.setup_from_metadata(install_edit_dialog.get_install_metadata())
|
||||||
|
install_item.edit_item_button_pressed.connect(edit_install.bind(install_item))
|
||||||
|
, CONNECT_ONE_SHOT)
|
||||||
|
|
||||||
|
install_edit_dialog.show()
|
||||||
|
|
||||||
|
|
||||||
|
func edit_install(install_item: InstallItem) -> void:
|
||||||
|
install_edit_dialog.clear()
|
||||||
|
install_edit_dialog.ok_button_text = "OK"
|
||||||
|
install_edit_dialog.install_metadata = install_item.install_metadata
|
||||||
|
install_edit_dialog.fill_from_install_metadata()
|
||||||
|
|
||||||
|
install_edit_dialog.confirmed.connect(
|
||||||
|
func():
|
||||||
|
install_item.setup_from_metadata(install_edit_dialog.get_install_metadata())
|
||||||
|
, CONNECT_ONE_SHOT)
|
||||||
|
install_edit_dialog.show()
|
||||||
|
|
||||||
|
|
||||||
func free_item(at_idx: int) -> void:
|
func free_item(at_idx: int) -> void:
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
[gd_scene load_steps=3 format=3 uid="uid://bh1nf1xrowlpv"]
|
[gd_scene load_steps=4 format=3 uid="uid://bh1nf1xrowlpv"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://UI/Components/GroupMenu.gd" id="1_h3o1w"]
|
[ext_resource type="Script" path="res://UI/Components/GroupMenu.gd" id="1_h3o1w"]
|
||||||
[ext_resource type="Texture2D" uid="uid://de57eeeobflp4" path="res://icon.svg" id="2_crg6a"]
|
[ext_resource type="Texture2D" uid="uid://de57eeeobflp4" path="res://icon.svg" id="2_crg6a"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://u0de32p0bb61" path="res://UI/Dialogs/InstallEditDialog.tscn" id="3_bapn7"]
|
||||||
|
|
||||||
[node name="GroupMenu" type="VBoxContainer"]
|
[node name="GroupMenu" type="VBoxContainer"]
|
||||||
offset_right = 299.0
|
offset_right = 299.0
|
||||||
@ -78,3 +79,6 @@ text = "New Install"
|
|||||||
[node name="HSeparator3" type="HSeparator" parent="."]
|
[node name="HSeparator3" type="HSeparator" parent="."]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_constants/separation = 16
|
theme_override_constants/separation = 16
|
||||||
|
|
||||||
|
[node name="InstallEditDialog" parent="." instance=ExtResource("3_bapn7")]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
@ -27,6 +27,10 @@ func set_icon(icon: Texture2D) -> void:
|
|||||||
item_icon.texture = icon
|
item_icon.texture = icon
|
||||||
|
|
||||||
|
|
||||||
|
func set_text(n: String) -> void:
|
||||||
|
name_label.text = n
|
||||||
|
|
||||||
|
|
||||||
func set_icon_visible(p_visible: bool) -> void:
|
func set_icon_visible(p_visible: bool) -> void:
|
||||||
item_icon.visible = p_visible
|
item_icon.visible = p_visible
|
||||||
|
|
||||||
@ -60,3 +64,9 @@ func _on_name_label_gui_input(event: InputEvent) -> void:
|
|||||||
(event as InputEventMouseButton).button_index == MOUSE_BUTTON_LEFT:
|
(event as InputEventMouseButton).button_index == MOUSE_BUTTON_LEFT:
|
||||||
get_viewport().set_input_as_handled()
|
get_viewport().set_input_as_handled()
|
||||||
setup_rename()
|
setup_rename()
|
||||||
|
|
||||||
|
|
||||||
|
func setup_from_metadata(p_metadata: InstallMetadata) -> void:
|
||||||
|
install_metadata = p_metadata
|
||||||
|
set_text(install_metadata.name)
|
||||||
|
# TODO: add icon
|
||||||
|
@ -41,6 +41,7 @@ text = "X"
|
|||||||
[node name="LaunchItemButton" type="Button" parent="."]
|
[node name="LaunchItemButton" type="Button" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
tooltip_text = "Launch"
|
||||||
text = ">"
|
text = ">"
|
||||||
|
|
||||||
[node name="Indent2" type="MarginContainer" parent="."]
|
[node name="Indent2" type="MarginContainer" parent="."]
|
||||||
|
@ -14,6 +14,7 @@ text = "Editor Settings overrides"
|
|||||||
[node name="OverrideItemContainer" type="VBoxContainer" parent="."]
|
[node name="OverrideItemContainer" type="VBoxContainer" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
|
||||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
|
53
UI/Dialogs/InstallEditDialog.gd
Normal file
53
UI/Dialogs/InstallEditDialog.gd
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
extends ConfirmationDialog
|
||||||
|
class_name InstallEditDialog
|
||||||
|
|
||||||
|
@onready var name_line_edit: LineEdit = %NameLineEdit
|
||||||
|
@onready var icon_path_line_edit: LineEdit = %IconPathLineEdit
|
||||||
|
@onready var open_icon_file_dialog_button: Button = %OpenIconFileDialogButton
|
||||||
|
@onready var override_editor_settings_menu: OverrideEditorSettingsMenu = %OverrideEditorSettingsMenu
|
||||||
|
@onready var version_selector: OptionButton = %VersionSelector
|
||||||
|
|
||||||
|
var install_metadata: InstallMetadata
|
||||||
|
|
||||||
|
|
||||||
|
func clear() -> void:
|
||||||
|
name_line_edit.clear()
|
||||||
|
icon_path_line_edit.clear()
|
||||||
|
override_editor_settings_menu.clear()
|
||||||
|
install_metadata = InstallMetadata.new()
|
||||||
|
|
||||||
|
version_selector.clear()
|
||||||
|
for version in ReleasesManager.get_installed_versions():
|
||||||
|
version_selector.add_item(version)
|
||||||
|
version_selector.set_item_metadata(
|
||||||
|
version_selector.get_item_count() - 1,
|
||||||
|
ReleasesManager.get_version_metadata(version).binary_path)
|
||||||
|
|
||||||
|
|
||||||
|
func get_install_metadata() -> InstallMetadata:
|
||||||
|
install_metadata.name = name_line_edit.text
|
||||||
|
install_metadata.icon_path = icon_path_line_edit.text
|
||||||
|
install_metadata.local_overrides = override_editor_settings_menu.get_overrides()
|
||||||
|
install_metadata.binary_path = version_selector.get_selected_metadata()
|
||||||
|
|
||||||
|
return install_metadata
|
||||||
|
|
||||||
|
|
||||||
|
func fill_from_install_metadata() -> void:
|
||||||
|
name_line_edit.text = install_metadata.name
|
||||||
|
icon_path_line_edit.text = install_metadata.icon_path
|
||||||
|
override_editor_settings_menu.fill_from_dictionary(install_metadata.local_overrides)
|
||||||
|
var item_id: int = -1
|
||||||
|
for i in version_selector.get_item_count():
|
||||||
|
if version_selector.get_item_metadata(i) == install_metadata.binary_path:
|
||||||
|
item_id = i
|
||||||
|
break
|
||||||
|
version_selector.select(item_id)
|
||||||
|
|
||||||
|
|
||||||
|
func clear_ok_button_connections() -> void:
|
||||||
|
for connection in get_signal_connection_list("confirmed"):
|
||||||
|
var callable := connection["callable"] as Callable
|
||||||
|
var _signal := connection["signal"] as Signal
|
||||||
|
|
||||||
|
_signal.disconnect(callable)
|
77
UI/Dialogs/InstallEditDialog.tscn
Normal file
77
UI/Dialogs/InstallEditDialog.tscn
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
[gd_scene load_steps=3 format=3 uid="uid://u0de32p0bb61"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://UI/Dialogs/InstallEditDialog.gd" id="1_qfdve"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://ig4wkr1lxvbv" path="res://UI/Components/OverrideEditorSettingsMenu/OverrideEditorSettingsMenu.tscn" id="2_elqgy"]
|
||||||
|
|
||||||
|
[node name="InstallEditDialog" type="ConfirmationDialog"]
|
||||||
|
initial_position = 1
|
||||||
|
title = "Edit Install"
|
||||||
|
size = Vector2i(678, 419)
|
||||||
|
script = ExtResource("1_qfdve")
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||||
|
offset_left = 8.0
|
||||||
|
offset_top = 8.0
|
||||||
|
offset_right = 670.0
|
||||||
|
offset_bottom = 370.0
|
||||||
|
|
||||||
|
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Name"
|
||||||
|
|
||||||
|
[node name="NameLineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer2"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Icon"
|
||||||
|
|
||||||
|
[node name="IconPathLineEdit" type="LineEdit" parent="VBoxContainer/HBoxContainer2"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
placeholder_text = "Optional"
|
||||||
|
|
||||||
|
[node name="OpenIconFileDialogButton" type="Button" parent="VBoxContainer/HBoxContainer2"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
text = "F"
|
||||||
|
|
||||||
|
[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer3"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Godot Version"
|
||||||
|
|
||||||
|
[node name="VersionSelector" type="OptionButton" parent="VBoxContainer/HBoxContainer3"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
|
||||||
|
custom_minimum_size = Vector2(0, 150)
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_vertical = 3
|
||||||
|
horizontal_scroll_mode = 0
|
||||||
|
|
||||||
|
[node name="OverrideEditorSettingsMenu" parent="VBoxContainer/ScrollContainer" instance=ExtResource("2_elqgy")]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
size_flags_horizontal = 3
|
||||||
|
|
||||||
|
[node name="CenterContainer" type="CenterContainer" parent="VBoxContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="VBoxContainer/CenterContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
text = "Install overrides take precedence over group overrides."
|
||||||
|
horizontal_alignment = 1
|
Loading…
Reference in New Issue
Block a user