mirror of
https://github.com/Insality/druid.git
synced 2025-11-26 19:00:50 +01:00
Update
This commit is contained in:
@@ -45,7 +45,7 @@ function M.open_asset_store(store_url)
|
||||
-- State management
|
||||
local all_items = editor.ui.use_state(initial_items)
|
||||
local filtered_items, set_filtered_items = editor.ui.use_state(initial_items)
|
||||
local install_folder, set_install_folder = editor.ui.use_state(installer.get_install_folder())
|
||||
local install_folder, set_install_folder = editor.ui.use_state(editor.prefs.get("druid.asset_install_folder") or installer.get_install_folder())
|
||||
local search_query, set_search_query = editor.ui.use_state("")
|
||||
local install_status, set_install_status = editor.ui.use_state("")
|
||||
|
||||
@@ -76,7 +76,10 @@ function M.open_asset_store(store_url)
|
||||
|
||||
editor.ui.string_field({
|
||||
value = install_folder,
|
||||
on_value_changed = set_install_folder,
|
||||
on_value_changed = function(new_folder)
|
||||
set_install_folder(new_folder)
|
||||
editor.prefs.set("druid.asset_install_folder", new_folder)
|
||||
end,
|
||||
title = "Installation Folder:",
|
||||
tooltip = "The folder to install the assets to",
|
||||
}),
|
||||
@@ -99,6 +102,7 @@ function M.open_asset_store(store_url)
|
||||
end,
|
||||
title = "Search:",
|
||||
tooltip = "Search for widgets by title, author, or description",
|
||||
grow = true
|
||||
})
|
||||
},
|
||||
}))
|
||||
@@ -134,6 +138,10 @@ function M.open_asset_store(store_url)
|
||||
children = content_children
|
||||
}),
|
||||
buttons = {
|
||||
editor.ui.dialog_button({
|
||||
text = "Info",
|
||||
result = "info_assets_store",
|
||||
}),
|
||||
editor.ui.dialog_button({
|
||||
text = "Close",
|
||||
cancel = true
|
||||
@@ -142,7 +150,13 @@ function M.open_asset_store(store_url)
|
||||
})
|
||||
end)
|
||||
|
||||
return editor.ui.show_dialog(dialog_component({}))
|
||||
local result = editor.ui.show_dialog(dialog_component({}))
|
||||
|
||||
if result and result == "info_assets_store" then
|
||||
editor.browse("https://github.com/Insality/core/blob/main/druid_widget_store.md")
|
||||
end
|
||||
|
||||
return {}
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,6 @@ local base64 = require("druid.editor_scripts.core.base64")
|
||||
|
||||
local M = {}
|
||||
|
||||
local DEFAULT_INSTALL_FOLDER = "/widget"
|
||||
|
||||
---@class druid.core.item_info
|
||||
---@field id string
|
||||
---@field version string
|
||||
@@ -103,7 +101,7 @@ end
|
||||
---Get installation folder
|
||||
---@return string - Installation folder path
|
||||
function M.get_install_folder()
|
||||
return editor.prefs.get("druid.asset_install_folder") or DEFAULT_INSTALL_FOLDER
|
||||
return editor.prefs.get("druid.asset_install_folder")
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -175,10 +175,6 @@ function M.create_widget_item(item, is_installed, on_install)
|
||||
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
|
||||
@@ -214,11 +210,8 @@ function M.create_widget_item(item, is_installed, on_install)
|
||||
}))
|
||||
end
|
||||
|
||||
table.insert(widget_details_children, editor.ui.separator({
|
||||
orientation = editor.ui.ORIENTATION.HORIZONTAL,
|
||||
}))
|
||||
|
||||
local widget_buttons = {
|
||||
-- Create button row at the bottom
|
||||
local button_children = {
|
||||
editor.ui.button({
|
||||
text = "Install",
|
||||
on_pressed = on_install,
|
||||
@@ -227,7 +220,7 @@ function M.create_widget_item(item, is_installed, on_install)
|
||||
}
|
||||
|
||||
if item.api ~= nil then
|
||||
table.insert(widget_buttons, editor.ui.button({
|
||||
table.insert(button_children, editor.ui.button({
|
||||
text = "API",
|
||||
on_pressed = function() internal.open_url(item.api) end,
|
||||
enabled = item.api ~= nil
|
||||
@@ -235,28 +228,41 @@ function M.create_widget_item(item, is_installed, on_install)
|
||||
end
|
||||
|
||||
if item.example_url ~= nil then
|
||||
table.insert(widget_buttons, editor.ui.button({
|
||||
table.insert(button_children, editor.ui.button({
|
||||
text = "Example",
|
||||
on_pressed = function() internal.open_url(item.example_url) end,
|
||||
enabled = item.example_url ~= nil
|
||||
}))
|
||||
end
|
||||
|
||||
-- Add spacer to push Author button to the right
|
||||
table.insert(button_children, editor.ui.horizontal({ grow = true }))
|
||||
|
||||
if item.author_url ~= nil then
|
||||
table.insert(widget_buttons, editor.ui.button({
|
||||
table.insert(button_children, editor.ui.label({
|
||||
text = "Author",
|
||||
color = editor.ui.COLOR.HINT
|
||||
}))
|
||||
table.insert(button_children, editor.ui.button({
|
||||
text = item.author or "Author",
|
||||
on_pressed = function() internal.open_url(item.author_url) end,
|
||||
enabled = item.author_url ~= nil
|
||||
}))
|
||||
end
|
||||
|
||||
-- Add button row to widget details
|
||||
table.insert(widget_details_children, editor.ui.horizontal({
|
||||
spacing = editor.ui.SPACING.SMALL,
|
||||
children = button_children
|
||||
}))
|
||||
|
||||
return editor.ui.horizontal({
|
||||
spacing = editor.ui.SPACING.NONE,
|
||||
padding = editor.ui.PADDING.SMALL,
|
||||
children = {
|
||||
-- Widget icon placeholder
|
||||
editor.ui.label({
|
||||
text = "📦",
|
||||
text = "•••",
|
||||
color = editor.ui.COLOR.HINT
|
||||
}),
|
||||
|
||||
@@ -266,13 +272,6 @@ function M.create_widget_item(item, is_installed, on_install)
|
||||
grow = true,
|
||||
children = widget_details_children
|
||||
}),
|
||||
|
||||
-- Action buttons
|
||||
editor.ui.vertical({
|
||||
spacing = editor.ui.SPACING.MEDIUM,
|
||||
grow = true,
|
||||
children = widget_buttons
|
||||
}),
|
||||
}
|
||||
})
|
||||
end
|
||||
@@ -284,7 +283,7 @@ end
|
||||
---@return userdata - UI component
|
||||
function M.create_widget_list(items, on_install)
|
||||
local widget_items = {}
|
||||
local install_folder = installer.get_install_folder()
|
||||
local install_folder = editor.prefs.get("druid.asset_install_folder") or installer.get_install_folder()
|
||||
|
||||
for _, item in ipairs(items) do
|
||||
local is_installed = installer.is_widget_installed(item, install_folder)
|
||||
|
||||
@@ -8,6 +8,7 @@ local M = {}
|
||||
|
||||
local DEFAULT_WIDGET_TEMPLATE_PATH = "/druid/templates/widget_full.lua.template"
|
||||
local DEFAULT_GUI_SCRIPT_TEMPLATE_PATH = "/druid/templates/druid.gui_script.template"
|
||||
local DEFAULT_ASSET_INSTALL_FOLDER = "/widget"
|
||||
|
||||
---Define preferences schema
|
||||
function M.get_prefs_schema()
|
||||
@@ -21,7 +22,7 @@ function M.get_prefs_schema()
|
||||
scope = editor.prefs.SCOPE.PROJECT
|
||||
}),
|
||||
["druid.asset_install_folder"] = editor.prefs.schema.string({
|
||||
default = "/widget",
|
||||
default = DEFAULT_ASSET_INSTALL_FOLDER,
|
||||
scope = editor.prefs.SCOPE.PROJECT
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user