mirror of
https://github.com/Insality/druid.git
synced 2025-11-26 10:50:52 +01:00
Update
This commit is contained in:
@@ -28,38 +28,6 @@ local function handle_install(item, install_folder, on_success, on_error)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---Show installation status dialog
|
|
||||||
---@param success boolean - Whether installation was successful
|
|
||||||
---@param message string - Status message
|
|
||||||
local function show_install_status(success, message)
|
|
||||||
local dialog_component = editor.ui.component(function()
|
|
||||||
return editor.ui.dialog({
|
|
||||||
title = success and "Installation Successful" or "Installation Failed",
|
|
||||||
content = editor.ui.vertical({
|
|
||||||
spacing = editor.ui.SPACING.MEDIUM,
|
|
||||||
padding = editor.ui.PADDING.MEDIUM,
|
|
||||||
children = {
|
|
||||||
editor.ui.label({
|
|
||||||
text = message,
|
|
||||||
color = success and editor.ui.COLOR.TEXT or editor.ui.COLOR.ERROR,
|
|
||||||
alignment = editor.ui.ALIGNMENT.LEFT
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
buttons = {
|
|
||||||
editor.ui.dialog_button({
|
|
||||||
text = "OK",
|
|
||||||
default = true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end)
|
|
||||||
|
|
||||||
editor.ui.show_dialog(dialog_component({}))
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---Open the asset store dialog
|
---Open the asset store dialog
|
||||||
function M.open_asset_store(store_url)
|
function M.open_asset_store(store_url)
|
||||||
print("Opening Druid Asset Store from:", store_url)
|
print("Opening Druid Asset Store from:", store_url)
|
||||||
@@ -86,11 +54,9 @@ function M.open_asset_store(store_url)
|
|||||||
handle_install(item, install_folder,
|
handle_install(item, install_folder,
|
||||||
function(message)
|
function(message)
|
||||||
set_install_status("Success: " .. message)
|
set_install_status("Success: " .. message)
|
||||||
show_install_status(true, message)
|
|
||||||
end,
|
end,
|
||||||
function(message)
|
function(message)
|
||||||
set_install_status("Error: " .. message)
|
set_install_status("Error: " .. message)
|
||||||
show_install_status(false, message)
|
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -163,13 +163,65 @@ function M.create_widget_item(item, is_installed, on_install)
|
|||||||
deps_text = "Depends: " .. table.concat(item.depends, ", ")
|
deps_text = "Depends: " .. table.concat(item.depends, ", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local widget_details_children = {
|
||||||
|
editor.ui.horizontal({
|
||||||
|
spacing = editor.ui.SPACING.SMALL,
|
||||||
|
children = {
|
||||||
|
editor.ui.label({
|
||||||
|
text = item.title or item.id,
|
||||||
|
color = editor.ui.COLOR.OVERRIDE
|
||||||
|
}),
|
||||||
|
editor.ui.label({
|
||||||
|
text = version_text,
|
||||||
|
color = editor.ui.COLOR.WARNING
|
||||||
|
}),
|
||||||
|
editor.ui.label({
|
||||||
|
text = "• by " .. (item.author or "Unknown"),
|
||||||
|
color = editor.ui.COLOR.HINT
|
||||||
|
}),
|
||||||
|
editor.ui.label({
|
||||||
|
text = "• " .. size_text,
|
||||||
|
color = editor.ui.COLOR.HINT
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
-- Description
|
||||||
|
editor.ui.paragraph({
|
||||||
|
text = item.description or "No description available",
|
||||||
|
color = editor.ui.COLOR.TEXT
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
|
||||||
|
if tags_text ~= "" then
|
||||||
|
table.insert(widget_details_children, editor.ui.label({
|
||||||
|
text = tags_text,
|
||||||
|
color = editor.ui.COLOR.HINT
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
|
if deps_text ~= "" then
|
||||||
|
table.insert(widget_details_children, editor.ui.label({
|
||||||
|
text = deps_text,
|
||||||
|
color = editor.ui.COLOR.HINT
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
|
if is_installed then
|
||||||
|
table.insert(widget_details_children, editor.ui.label({
|
||||||
|
text = "✓ Already installed",
|
||||||
|
color = editor.ui.COLOR.WARNING
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
|
table.insert(widget_details_children, editor.ui.separator({
|
||||||
|
orientation = editor.ui.ORIENTATION.HORIZONTAL,
|
||||||
|
}))
|
||||||
|
|
||||||
return editor.ui.horizontal({
|
return editor.ui.horizontal({
|
||||||
spacing = editor.ui.SPACING.NONE,
|
spacing = editor.ui.SPACING.NONE,
|
||||||
padding = editor.ui.PADDING.SMALL,
|
padding = editor.ui.PADDING.SMALL,
|
||||||
children = {
|
children = {
|
||||||
editor.ui.separator({
|
|
||||||
orientation = editor.ui.ORIENTATION.HORIZONTAL,
|
|
||||||
}),
|
|
||||||
-- Widget icon placeholder
|
-- Widget icon placeholder
|
||||||
editor.ui.label({
|
editor.ui.label({
|
||||||
text = "📦",
|
text = "📦",
|
||||||
@@ -180,54 +232,7 @@ function M.create_widget_item(item, is_installed, on_install)
|
|||||||
editor.ui.vertical({
|
editor.ui.vertical({
|
||||||
spacing = editor.ui.SPACING.SMALL,
|
spacing = editor.ui.SPACING.SMALL,
|
||||||
grow = true,
|
grow = true,
|
||||||
children = {
|
children = widget_details_children
|
||||||
-- Title and author
|
|
||||||
editor.ui.horizontal({
|
|
||||||
spacing = editor.ui.SPACING.SMALL,
|
|
||||||
children = {
|
|
||||||
editor.ui.label({
|
|
||||||
text = item.title or item.id,
|
|
||||||
color = editor.ui.COLOR.OVERRIDE
|
|
||||||
}),
|
|
||||||
editor.ui.label({
|
|
||||||
text = version_text,
|
|
||||||
color = editor.ui.COLOR.WARNING
|
|
||||||
}),
|
|
||||||
editor.ui.label({
|
|
||||||
text = "• by " .. (item.author or "Unknown"),
|
|
||||||
color = editor.ui.COLOR.HINT
|
|
||||||
}),
|
|
||||||
editor.ui.label({
|
|
||||||
text = "• " .. size_text,
|
|
||||||
color = editor.ui.COLOR.HINT
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
-- Description
|
|
||||||
editor.ui.label({
|
|
||||||
text = item.description or "No description available",
|
|
||||||
color = editor.ui.COLOR.TEXT
|
|
||||||
}),
|
|
||||||
|
|
||||||
-- Tags
|
|
||||||
tags_text ~= "" and editor.ui.label({
|
|
||||||
text = tags_text,
|
|
||||||
color = editor.ui.COLOR.HINT
|
|
||||||
}) or nil,
|
|
||||||
|
|
||||||
-- Dependencies
|
|
||||||
deps_text ~= "" and editor.ui.label({
|
|
||||||
text = deps_text,
|
|
||||||
color = editor.ui.COLOR.HINT
|
|
||||||
}) or nil,
|
|
||||||
|
|
||||||
-- Installation status
|
|
||||||
is_installed and editor.ui.label({
|
|
||||||
text = "✓ Already installed",
|
|
||||||
color = editor.ui.COLOR.HINT
|
|
||||||
}) or nil
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
-- Action buttons
|
-- Action buttons
|
||||||
@@ -235,10 +240,9 @@ function M.create_widget_item(item, is_installed, on_install)
|
|||||||
spacing = editor.ui.SPACING.MEDIUM,
|
spacing = editor.ui.SPACING.MEDIUM,
|
||||||
children = {
|
children = {
|
||||||
editor.ui.button({
|
editor.ui.button({
|
||||||
|
|
||||||
text = "Install",
|
text = "Install",
|
||||||
on_pressed = on_install,
|
on_pressed = on_install,
|
||||||
enabled = is_installed == false
|
enabled = not is_installed
|
||||||
}),
|
}),
|
||||||
editor.ui.button({
|
editor.ui.button({
|
||||||
text = "API",
|
text = "API",
|
||||||
@@ -260,13 +264,11 @@ function M.create_widget_list(items, on_install)
|
|||||||
local widget_items = {}
|
local widget_items = {}
|
||||||
local install_folder = installer.get_install_folder()
|
local install_folder = installer.get_install_folder()
|
||||||
|
|
||||||
for index = 1, 9 do
|
for _, item in ipairs(items) do
|
||||||
for _, item in ipairs(items) do
|
local is_installed = installer.is_widget_installed(item, install_folder)
|
||||||
local is_installed = installer.is_widget_installed(item, install_folder)
|
table.insert(widget_items, M.create_widget_item(item, is_installed,
|
||||||
table.insert(widget_items, M.create_widget_item(item, is_installed,
|
function() on_install(item) end
|
||||||
function() on_install(item) end
|
))
|
||||||
))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return editor.ui.scroll({
|
return editor.ui.scroll({
|
||||||
|
|||||||
Reference in New Issue
Block a user