Compare commits
No commits in common. "f942c91cf68e3dc0e67838ee71a67ce09e6ae121" and "ba3e2751ddece1ca1bad7f1383d7408db7f72aea" have entirely different histories.
f942c91cf6
...
ba3e2751dd
@ -1,4 +1,5 @@
|
||||
extends Resource
|
||||
class_name GroupListMetadata
|
||||
|
||||
@export var groups: Array[GroupMetadata]
|
||||
@export var order: Array[String]
|
||||
@export var uncollapsed_groups: Array[String]
|
||||
|
@ -1,11 +1,7 @@
|
||||
extends Resource
|
||||
class_name GroupMetadata
|
||||
|
||||
@export var name: String
|
||||
@export var icon_path: String
|
||||
@export var description: String
|
||||
@export var installs: Array[Dictionary]
|
||||
@export var installs: Array[InstallMetadata]
|
||||
@export var settings_overrides: Dictionary
|
||||
@export var index: int
|
||||
|
||||
signal save_request
|
||||
|
@ -1,59 +0,0 @@
|
||||
extends Node
|
||||
|
||||
const GROUPS_BASE_FOLDER := "user://groups"
|
||||
const METADATA_FILENAME := "meta.tres"
|
||||
|
||||
# key: GroupMetadata
|
||||
# value: String = UUID
|
||||
var groups: Dictionary = {}
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
DirAccess.make_dir_absolute(GROUPS_BASE_FOLDER)
|
||||
|
||||
var d := DirAccess.open(GROUPS_BASE_FOLDER)
|
||||
d.list_dir_begin()
|
||||
var current_folder := d.get_next()
|
||||
while current_folder != "":
|
||||
var res_path := GROUPS_BASE_FOLDER.path_join(current_folder).path_join(METADATA_FILENAME)
|
||||
var gm: GroupMetadata = ResourceLoader.load(res_path, "GroupMetadata")
|
||||
groups[gm] = current_folder
|
||||
current_folder = d.get_next()
|
||||
|
||||
|
||||
func create_group_folder(gm: GroupMetadata) -> void:
|
||||
if gm in groups:
|
||||
return
|
||||
|
||||
var folder_name := UUID.v4()
|
||||
var d := DirAccess.open(GROUPS_BASE_FOLDER)
|
||||
d.make_dir(folder_name)
|
||||
|
||||
groups[gm] = folder_name
|
||||
gm.save_request.connect(group_metadata_should_save.bind(gm))
|
||||
|
||||
|
||||
func delete_group_folder(gm: GroupMetadata) -> void:
|
||||
if !groups.has(gm):
|
||||
return
|
||||
|
||||
var path := ProjectSettings.globalize_path(GROUPS_BASE_FOLDER.path_join(groups[gm]))
|
||||
OS.move_to_trash(path)
|
||||
groups.erase(gm)
|
||||
|
||||
|
||||
func group_metadata_should_save(gm: GroupMetadata) -> void:
|
||||
var path := GROUPS_BASE_FOLDER.path_join(groups[gm]).path_join(METADATA_FILENAME)
|
||||
var save_err := ResourceSaver.save(gm, path)
|
||||
if save_err != OK:
|
||||
print("couldn't save resource, error ", save_err)
|
||||
|
||||
|
||||
func get_all_group_metadatas() -> Array[GroupMetadata]:
|
||||
var res: Array[GroupMetadata]
|
||||
res.assign(groups.keys())
|
||||
res.sort_custom(
|
||||
func(a: GroupMetadata, b: GroupMetadata):
|
||||
return a.index < b.index
|
||||
)
|
||||
return res
|
@ -1,30 +1,7 @@
|
||||
extends Resource
|
||||
class_name InstallMetadata
|
||||
|
||||
var name: String
|
||||
var icon_path: String
|
||||
var binary_path: String
|
||||
var local_overrides: Dictionary
|
||||
var pids: Array[int] = []
|
||||
var index: int = 0
|
||||
|
||||
|
||||
func to_d() -> Dictionary:
|
||||
return {
|
||||
"name": name,
|
||||
"icon_path": icon_path,
|
||||
"binary_path": binary_path,
|
||||
"local_overrides": local_overrides,
|
||||
"pids": pids,
|
||||
"index": index,
|
||||
}
|
||||
|
||||
|
||||
static func from_d(d: Dictionary) -> InstallMetadata:
|
||||
var res := InstallMetadata.new()
|
||||
res.name = d.get("name", "")
|
||||
res.icon_path = d.get("icon_path", "")
|
||||
res.binary_path = d.get("binary_path", "")
|
||||
res.local_overrides = d.get("local_overrides", {})
|
||||
res.pids = d.get("pids", [])
|
||||
res.index = d.get("index", 0)
|
||||
return res
|
||||
@export var name: String
|
||||
@export var icon_path: String
|
||||
@export var binary_path: String
|
||||
@export var local_overrides: Dictionary
|
||||
|
@ -322,7 +322,7 @@ func get_version_metadata(version: String) -> ReleaseMetadata:
|
||||
|
||||
|
||||
func get_installed_versions() -> Dictionary:
|
||||
var res: Dictionary = {}
|
||||
var res: Dictionary
|
||||
for version in releases.releases:
|
||||
if is_version_installed(version):
|
||||
res[version] = releases.releases[version]
|
||||
|
@ -1,88 +0,0 @@
|
||||
# MIT License
|
||||
#
|
||||
# Copyright (c) 2023 Xavier Sellier
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
# Note: The code might not be as pretty it could be, since it's written
|
||||
# in a way that maximizes performance. Methods are inlined and loops are avoided.
|
||||
class_name UUID
|
||||
const BYTE_MASK: int = 0b11111111
|
||||
|
||||
|
||||
static func uuidbin() -> Array:
|
||||
randomize()
|
||||
# 16 random bytes with the bytes on index 6 and 8 modified
|
||||
return [
|
||||
randi() & BYTE_MASK, randi() & BYTE_MASK, randi() & BYTE_MASK, randi() & BYTE_MASK,
|
||||
randi() & BYTE_MASK, randi() & BYTE_MASK, ((randi() & BYTE_MASK) & 0x0f) | 0x40, randi() & BYTE_MASK,
|
||||
((randi() & BYTE_MASK) & 0x3f) | 0x80, randi() & BYTE_MASK, randi() & BYTE_MASK, randi() & BYTE_MASK,
|
||||
randi() & BYTE_MASK, randi() & BYTE_MASK, randi() & BYTE_MASK, randi() & BYTE_MASK,
|
||||
]
|
||||
|
||||
static func uuidbinrng(rng: RandomNumberGenerator) -> Array:
|
||||
rng.randomize()
|
||||
return [
|
||||
rng.randi() & BYTE_MASK, rng.randi() & BYTE_MASK, rng.randi() & BYTE_MASK, rng.randi() & BYTE_MASK,
|
||||
rng.randi() & BYTE_MASK, rng.randi() & BYTE_MASK, ((rng.randi() & BYTE_MASK) & 0x0f) | 0x40, rng.randi() & BYTE_MASK,
|
||||
((rng.randi() & BYTE_MASK) & 0x3f) | 0x80, rng.randi() & BYTE_MASK, rng.randi() & BYTE_MASK, rng.randi() & BYTE_MASK,
|
||||
rng.randi() & BYTE_MASK, rng.randi() & BYTE_MASK, rng.randi() & BYTE_MASK, rng.randi() & BYTE_MASK,
|
||||
]
|
||||
|
||||
static func v4() -> String:
|
||||
# 16 random bytes with the bytes on index 6 and 8 modified
|
||||
var b = uuidbin()
|
||||
|
||||
return '%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x' % [
|
||||
# low
|
||||
b[0], b[1], b[2], b[3],
|
||||
|
||||
# mid
|
||||
b[4], b[5],
|
||||
|
||||
# hi
|
||||
b[6], b[7],
|
||||
|
||||
# clock
|
||||
b[8], b[9],
|
||||
|
||||
# clock
|
||||
b[10], b[11], b[12], b[13], b[14], b[15]
|
||||
]
|
||||
|
||||
static func v4_rng(rng: RandomNumberGenerator) -> String:
|
||||
# 16 random bytes with the bytes on index 6 and 8 modified
|
||||
var b = uuidbinrng(rng)
|
||||
|
||||
return '%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x' % [
|
||||
# low
|
||||
b[0], b[1], b[2], b[3],
|
||||
|
||||
# mid
|
||||
b[4], b[5],
|
||||
|
||||
# hi
|
||||
b[6], b[7],
|
||||
|
||||
# clock
|
||||
b[8], b[9],
|
||||
|
||||
# clock
|
||||
b[10], b[11], b[12], b[13], b[14], b[15]
|
||||
]
|
@ -25,6 +25,8 @@ var group_metadata: GroupMetadata
|
||||
signal add_install_button_pressed
|
||||
|
||||
signal edit_group_button_pressed
|
||||
signal delete_button_pressed
|
||||
signal header_text_changed(new_text: String, old_text: String)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@ -38,7 +40,7 @@ func _ready() -> void:
|
||||
install_edit_dialog.canceled.connect(install_edit_dialog.clear_ok_button_connections)
|
||||
# edit_group_button.pressed.connect(setup_rename)
|
||||
edit_group_button.pressed.connect(func(): edit_group_button_pressed.emit())
|
||||
delete_group_button.pressed.connect(_on_delete_button_pressed)
|
||||
delete_group_button.pressed.connect(func(): delete_button_pressed.emit())
|
||||
|
||||
header_text_label.gui_input.connect(_on_header_text_label_gui_input)
|
||||
|
||||
@ -52,25 +54,14 @@ func add_new_install() -> void:
|
||||
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(im)
|
||||
install_item.setup_from_metadata(install_edit_dialog.get_install_metadata())
|
||||
install_item.edit_item_button_pressed.connect(edit_install.bind(install_item))
|
||||
im.index = group_metadata.installs.size()
|
||||
group_metadata.installs.append(im.to_d())
|
||||
group_metadata.save_request.emit()
|
||||
install_item.about_to_delete.connect(_on_install_item_about_to_delete)
|
||||
group_metadata.installs.append(install_edit_dialog.get_install_metadata())
|
||||
, CONNECT_ONE_SHOT)
|
||||
|
||||
install_edit_dialog.show()
|
||||
|
||||
|
||||
func add_install_from_metadata(im: InstallMetadata) -> void:
|
||||
var install_item: InstallItem = ITEM_SCENE.instantiate()
|
||||
child_container.add_child(install_item)
|
||||
install_item.setup_from_metadata(im)
|
||||
install_item.about_to_delete.connect(_on_install_item_about_to_delete)
|
||||
install_item.edit_item_button_pressed.connect(edit_install.bind(install_item))
|
||||
|
||||
|
||||
func edit_install(install_item: InstallItem) -> void:
|
||||
install_edit_dialog.clear()
|
||||
install_edit_dialog.ok_button_text = "OK"
|
||||
@ -125,9 +116,8 @@ func set_children_visible(p_visible: bool) -> void:
|
||||
child_container.visible = p_visible
|
||||
add_install_button_container.visible = p_visible
|
||||
inner_separator.visible = p_visible
|
||||
|
||||
description_label.visible = p_visible && !description_label.text.is_empty()
|
||||
group_metadata.set_meta("collapsed", !p_visible)
|
||||
group_metadata.save_request.emit()
|
||||
|
||||
|
||||
func add_custom(control: Control) -> void:
|
||||
@ -153,9 +143,9 @@ func setup_rename() -> void:
|
||||
|
||||
l.text_submitted.connect(
|
||||
func(new_text: String):
|
||||
var old_text: = header_text_label.text
|
||||
header_text_label.text = new_text
|
||||
group_metadata.name = new_text
|
||||
group_metadata.save_request.emit()
|
||||
header_text_changed.emit(new_text, old_text)
|
||||
|
||||
reenable.call()
|
||||
)
|
||||
@ -163,17 +153,11 @@ func setup_rename() -> void:
|
||||
l.grab_focus()
|
||||
|
||||
|
||||
func setup_from_metadata(p_group_metadata: GroupMetadata) -> void:
|
||||
func setup_from_metadata(header_text: String, p_group_metadata: GroupMetadata) -> void:
|
||||
group_metadata = p_group_metadata
|
||||
set_text(p_group_metadata.name)
|
||||
set_text(header_text)
|
||||
set_description(group_metadata.description)
|
||||
set_children_visible(!group_metadata.get_meta("collapsed", false))
|
||||
group_metadata.index = get_index()
|
||||
|
||||
# add installs
|
||||
for i in group_metadata.installs:
|
||||
add_install_from_metadata(InstallMetadata.from_d(i))
|
||||
|
||||
# TODO: add installs
|
||||
# TODO: add icon
|
||||
|
||||
|
||||
@ -184,16 +168,3 @@ func _on_header_text_label_gui_input(event: InputEvent) -> void:
|
||||
get_viewport().set_input_as_handled()
|
||||
setup_rename()
|
||||
|
||||
|
||||
func _on_delete_button_pressed() -> void:
|
||||
GroupsInstallsManager.delete_group_folder(group_metadata)
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_install_item_about_to_delete(im: InstallMetadata) -> void:
|
||||
group_metadata.installs.remove_at(im.index)
|
||||
for i in group_metadata.installs.size():
|
||||
group_metadata.installs[i]["index"] = i
|
||||
(child_container.get_child(i) as InstallItem).install_metadata.index = i
|
||||
|
||||
group_metadata.save_request.emit()
|
||||
|
@ -47,13 +47,11 @@ layout_mode = 2
|
||||
[node name="EditGroupButton" type="Button" parent="HeaderContainer/HeaderCustomControlContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "Edit"
|
||||
text = "E"
|
||||
|
||||
[node name="DeleteGroupButton" type="Button" parent="HeaderContainer/HeaderCustomControlContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "Delete"
|
||||
text = "X"
|
||||
|
||||
[node name="DescriptionLabel" type="Label" parent="."]
|
||||
|
@ -10,15 +10,15 @@ class_name InstallItem
|
||||
var install_metadata: InstallMetadata
|
||||
|
||||
signal edit_item_button_pressed
|
||||
signal delete_item_button_pressed
|
||||
signal launch_item_button_pressed
|
||||
signal about_to_delete(install_metadata: InstallMetadata)
|
||||
|
||||
signal name_changed(new_name: String)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
edit_item_button.pressed.connect(func(): edit_item_button_pressed.emit())
|
||||
delete_item_button.pressed.connect(_on_delete_button_pressed)
|
||||
delete_item_button.pressed.connect(func(): delete_item_button_pressed.emit())
|
||||
|
||||
name_label.gui_input.connect(_on_name_label_gui_input)
|
||||
|
||||
@ -51,7 +51,6 @@ func setup_rename() -> void:
|
||||
func(new_text: String):
|
||||
name_label.text = new_text
|
||||
name_changed.emit(new_text)
|
||||
install_metadata.name = new_text
|
||||
|
||||
name_label.visible = true
|
||||
)
|
||||
@ -71,8 +70,3 @@ func setup_from_metadata(p_metadata: InstallMetadata) -> void:
|
||||
install_metadata = p_metadata
|
||||
set_text(install_metadata.name)
|
||||
# TODO: add icon
|
||||
|
||||
|
||||
func _on_delete_button_pressed() -> void:
|
||||
about_to_delete.emit(install_metadata)
|
||||
queue_free()
|
||||
|
@ -10,7 +10,6 @@ script = ExtResource("1_sh2ev")
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="Indent" type="MarginContainer" parent="."]
|
||||
custom_minimum_size = Vector2(30, 0)
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 6
|
||||
|
||||
@ -32,20 +31,18 @@ clip_text = true
|
||||
[node name="EditItemButton" type="Button" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "Edit"
|
||||
text = "E"
|
||||
|
||||
[node name="DeleteItemButton" type="Button" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "Delete"
|
||||
text = "X"
|
||||
|
||||
[node name="LaunchItemButton" type="Button" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "Launch"
|
||||
text = "Launch"
|
||||
text = ">"
|
||||
|
||||
[node name="Indent2" type="MarginContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
@ -21,15 +21,12 @@ func get_group_metadata() -> GroupMetadata:
|
||||
group_metadata.icon_path = icon_path_line_edit.text
|
||||
group_metadata.description = description_text_edit.text
|
||||
group_metadata.settings_overrides = override_editor_settings_menu.get_overrides()
|
||||
group_metadata.name = name_line_edit.text
|
||||
|
||||
group_metadata.save_request.emit()
|
||||
|
||||
return group_metadata
|
||||
|
||||
|
||||
func fill_from_group_metadata() -> void:
|
||||
name_line_edit.text = group_metadata.name
|
||||
func fill_from_group_metadata(p_name: String) -> void:
|
||||
name_line_edit.text = p_name
|
||||
icon_path_line_edit.text = group_metadata.icon_path
|
||||
description_text_edit.text = group_metadata.description
|
||||
override_editor_settings_menu.fill_from_dictionary(group_metadata.settings_overrides)
|
||||
|
@ -16,9 +16,6 @@ func _ready() -> void:
|
||||
|
||||
group_edit_dialog.canceled.connect(group_edit_dialog.clear_ok_button_connections)
|
||||
|
||||
for gm in GroupsInstallsManager.get_all_group_metadatas():
|
||||
add_group_from_metadata(gm)
|
||||
|
||||
|
||||
func add_new_group() -> void:
|
||||
group_edit_dialog.clear()
|
||||
@ -28,13 +25,14 @@ func add_new_group() -> void:
|
||||
func():
|
||||
var gm := group_edit_dialog.get_group_metadata()
|
||||
|
||||
# TODO: hack, redo later
|
||||
var group_name := group_edit_dialog.name_line_edit.text
|
||||
|
||||
var group_menu: GroupMenu = GROUP_MENU_SCENE.instantiate()
|
||||
group_menus_container.add_child(group_menu)
|
||||
group_menu.setup_from_metadata(gm)
|
||||
group_menu.setup_from_metadata(group_name, gm)
|
||||
|
||||
group_menu.edit_group_button_pressed.connect(edit_group.bind(group_menu))
|
||||
GroupsInstallsManager.create_group_folder(gm)
|
||||
GroupsInstallsManager.group_metadata_should_save(gm)
|
||||
|
||||
, CONNECT_ONE_SHOT)
|
||||
|
||||
@ -45,20 +43,13 @@ func edit_group(group_menu: GroupMenu) -> void:
|
||||
group_edit_dialog.clear()
|
||||
group_edit_dialog.ok_button_text = "OK"
|
||||
|
||||
var group_name := group_menu.get_text()
|
||||
group_edit_dialog.group_metadata = group_menu.group_metadata
|
||||
group_edit_dialog.fill_from_group_metadata()
|
||||
group_edit_dialog.fill_from_group_metadata(group_name)
|
||||
|
||||
group_edit_dialog.confirmed.connect(
|
||||
func():
|
||||
group_menu.setup_from_metadata(group_edit_dialog.get_group_metadata())
|
||||
group_menu.setup_from_metadata(group_name, group_edit_dialog.get_group_metadata())
|
||||
, CONNECT_ONE_SHOT)
|
||||
|
||||
group_edit_dialog.show()
|
||||
|
||||
|
||||
func add_group_from_metadata(gm: GroupMetadata) -> void:
|
||||
var group_menu: GroupMenu = GROUP_MENU_SCENE.instantiate()
|
||||
group_menus_container.add_child(group_menu)
|
||||
group_menu.setup_from_metadata(gm)
|
||||
|
||||
group_menu.edit_group_button_pressed.connect(edit_group.bind(group_menu))
|
||||
|
@ -1,27 +0,0 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://0wv6qt367nml"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bf464y0q4l67h" path="res://UI/Main/GroupsView.tscn" id="1_qdj8e"]
|
||||
[ext_resource type="PackedScene" uid="uid://irfav51b5hf6" path="res://UI/Main/ReleasesView.tscn" id="2_sif55"]
|
||||
|
||||
[node name="Main" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="HSplitContainer" type="HSplitContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
split_offset = 400
|
||||
|
||||
[node name="ReleasesView" parent="HSplitContainer" instance=ExtResource("2_sif55")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GroupsView" parent="HSplitContainer" instance=ExtResource("1_qdj8e")]
|
||||
layout_mode = 2
|
@ -11,7 +11,7 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="yagvm"
|
||||
run/main_scene="res://UI/Main/Main.tscn"
|
||||
run/main_scene="res://UI/Main/GroupsView.tscn"
|
||||
config/use_custom_user_dir=true
|
||||
config/custom_user_dir_name="yagvm"
|
||||
config/features=PackedStringArray("4.0", "Forward Plus")
|
||||
@ -21,7 +21,6 @@ config/icon="res://icon.svg"
|
||||
|
||||
DotEnv="*res://Classes/DotEnv.gd"
|
||||
ReleasesManager="*res://Classes/ReleasesManager.gd"
|
||||
GroupsInstallsManager="*res://Classes/GroupsInstallsManager.gd"
|
||||
|
||||
[display]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user