Skip to content

Commit b7f34ca

Browse files
committed
Update
1 parent 15c9bd5 commit b7f34ca

File tree

4 files changed

+40
-28
lines changed

4 files changed

+40
-28
lines changed

druid/editor_scripts/core/asset_store.lua

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function M.open_asset_store(store_url)
4545
-- State management
4646
local all_items = editor.ui.use_state(initial_items)
4747
local filtered_items, set_filtered_items = editor.ui.use_state(initial_items)
48-
local install_folder, set_install_folder = editor.ui.use_state(installer.get_install_folder())
48+
local install_folder, set_install_folder = editor.ui.use_state(editor.prefs.get("druid.asset_install_folder") or installer.get_install_folder())
4949
local search_query, set_search_query = editor.ui.use_state("")
5050
local install_status, set_install_status = editor.ui.use_state("")
5151

@@ -76,7 +76,10 @@ function M.open_asset_store(store_url)
7676

7777
editor.ui.string_field({
7878
value = install_folder,
79-
on_value_changed = set_install_folder,
79+
on_value_changed = function(new_folder)
80+
set_install_folder(new_folder)
81+
editor.prefs.set("druid.asset_install_folder", new_folder)
82+
end,
8083
title = "Installation Folder:",
8184
tooltip = "The folder to install the assets to",
8285
}),
@@ -99,6 +102,7 @@ function M.open_asset_store(store_url)
99102
end,
100103
title = "Search:",
101104
tooltip = "Search for widgets by title, author, or description",
105+
grow = true
102106
})
103107
},
104108
}))
@@ -134,6 +138,10 @@ function M.open_asset_store(store_url)
134138
children = content_children
135139
}),
136140
buttons = {
141+
editor.ui.dialog_button({
142+
text = "Info",
143+
result = "info_assets_store",
144+
}),
137145
editor.ui.dialog_button({
138146
text = "Close",
139147
cancel = true
@@ -142,7 +150,13 @@ function M.open_asset_store(store_url)
142150
})
143151
end)
144152

145-
return editor.ui.show_dialog(dialog_component({}))
153+
local result = editor.ui.show_dialog(dialog_component({}))
154+
155+
if result and result == "info_assets_store" then
156+
editor.browse("https://github.com/Insality/core/blob/main/druid_widget_store.md")
157+
end
158+
159+
return {}
146160
end
147161

148162

druid/editor_scripts/core/installer.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ local base64 = require("druid.editor_scripts.core.base64")
55

66
local M = {}
77

8-
local DEFAULT_INSTALL_FOLDER = "/widget"
9-
108
---@class druid.core.item_info
119
---@field id string
1210
---@field version string
@@ -103,7 +101,7 @@ end
103101
---Get installation folder
104102
---@return string - Installation folder path
105103
function M.get_install_folder()
106-
return editor.prefs.get("druid.asset_install_folder") or DEFAULT_INSTALL_FOLDER
104+
return editor.prefs.get("druid.asset_install_folder")
107105
end
108106

109107

druid/editor_scripts/core/ui_components.lua

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,6 @@ function M.create_widget_item(item, is_installed, on_install)
175175
text = version_text,
176176
color = editor.ui.COLOR.WARNING
177177
}),
178-
editor.ui.label({
179-
text = "• by " .. (item.author or "Unknown"),
180-
color = editor.ui.COLOR.HINT
181-
}),
182178
editor.ui.label({
183179
text = "" .. size_text,
184180
color = editor.ui.COLOR.HINT
@@ -214,11 +210,8 @@ function M.create_widget_item(item, is_installed, on_install)
214210
}))
215211
end
216212

217-
table.insert(widget_details_children, editor.ui.separator({
218-
orientation = editor.ui.ORIENTATION.HORIZONTAL,
219-
}))
220-
221-
local widget_buttons = {
213+
-- Create button row at the bottom
214+
local button_children = {
222215
editor.ui.button({
223216
text = "Install",
224217
on_pressed = on_install,
@@ -227,36 +220,49 @@ function M.create_widget_item(item, is_installed, on_install)
227220
}
228221

229222
if item.api ~= nil then
230-
table.insert(widget_buttons, editor.ui.button({
223+
table.insert(button_children, editor.ui.button({
231224
text = "API",
232225
on_pressed = function() internal.open_url(item.api) end,
233226
enabled = item.api ~= nil
234227
}))
235228
end
236229

237230
if item.example_url ~= nil then
238-
table.insert(widget_buttons, editor.ui.button({
231+
table.insert(button_children, editor.ui.button({
239232
text = "Example",
240233
on_pressed = function() internal.open_url(item.example_url) end,
241234
enabled = item.example_url ~= nil
242235
}))
243236
end
244237

238+
-- Add spacer to push Author button to the right
239+
table.insert(button_children, editor.ui.horizontal({ grow = true }))
240+
245241
if item.author_url ~= nil then
246-
table.insert(widget_buttons, editor.ui.button({
242+
table.insert(button_children, editor.ui.label({
247243
text = "Author",
244+
color = editor.ui.COLOR.HINT
245+
}))
246+
table.insert(button_children, editor.ui.button({
247+
text = item.author or "Author",
248248
on_pressed = function() internal.open_url(item.author_url) end,
249249
enabled = item.author_url ~= nil
250250
}))
251251
end
252252

253+
-- Add button row to widget details
254+
table.insert(widget_details_children, editor.ui.horizontal({
255+
spacing = editor.ui.SPACING.SMALL,
256+
children = button_children
257+
}))
258+
253259
return editor.ui.horizontal({
254260
spacing = editor.ui.SPACING.NONE,
255261
padding = editor.ui.PADDING.SMALL,
256262
children = {
257263
-- Widget icon placeholder
258264
editor.ui.label({
259-
text = "📦",
265+
text = "•••",
260266
color = editor.ui.COLOR.HINT
261267
}),
262268

@@ -266,13 +272,6 @@ function M.create_widget_item(item, is_installed, on_install)
266272
grow = true,
267273
children = widget_details_children
268274
}),
269-
270-
-- Action buttons
271-
editor.ui.vertical({
272-
spacing = editor.ui.SPACING.MEDIUM,
273-
grow = true,
274-
children = widget_buttons
275-
}),
276275
}
277276
})
278277
end
@@ -284,7 +283,7 @@ end
284283
---@return userdata - UI component
285284
function M.create_widget_list(items, on_install)
286285
local widget_items = {}
287-
local install_folder = installer.get_install_folder()
286+
local install_folder = editor.prefs.get("druid.asset_install_folder") or installer.get_install_folder()
288287

289288
for _, item in ipairs(items) do
290289
local is_installed = installer.is_widget_installed(item, install_folder)

druid/editor_scripts/druid.editor_script

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ local M = {}
88

99
local DEFAULT_WIDGET_TEMPLATE_PATH = "/druid/templates/widget_full.lua.template"
1010
local DEFAULT_GUI_SCRIPT_TEMPLATE_PATH = "/druid/templates/druid.gui_script.template"
11+
local DEFAULT_ASSET_INSTALL_FOLDER = "/widget"
1112

1213
---Define preferences schema
1314
function M.get_prefs_schema()
@@ -21,7 +22,7 @@ function M.get_prefs_schema()
2122
scope = editor.prefs.SCOPE.PROJECT
2223
}),
2324
["druid.asset_install_folder"] = editor.prefs.schema.string({
24-
default = "/widget",
25+
default = DEFAULT_ASSET_INSTALL_FOLDER,
2526
scope = editor.prefs.SCOPE.PROJECT
2627
})
2728
}

0 commit comments

Comments
 (0)