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