Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion w-engine/plugin.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id = "tadomika_ari/w-engine"
name = "W Engine"
version = "1.2.0"
version = "1.3.0"
# Tile and control callbacks are Luau closures rather than named globals, which
# the host resolves from plugin API 9 onwards.
plugin_api = 9
Expand Down
93 changes: 92 additions & 1 deletion w-engine/start.luau
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ local lastNonce = nil
local workshopRoot = nil
local rngState = 0

-- Get All output for all fonctionnality --

local allOutputs = nil
local isAllOutputs = false

local function getAllOutput()
local outputs = {}
for index, output in ipairs(noctalia.outputs()) do
table.insert(outputs, output.name)
end
return outputs
end

allOutputs = getAllOutput()

local function tr(key, subst)
if subst then
return noctalia.tr(key, subst)
Expand Down Expand Up @@ -593,20 +608,54 @@ local function handleRequest(request)
end
lastNonce = request.nonce

local output = request.output
local output = request.output -- here
if type(output) ~= "string" or output == "" then
output = noctalia.focusedOutputName()
end
if type(output) ~= "string" or output == "" then
return
end

if output == "All" then
isAllOutputs = true
end
if output ~= "All" then
isAllOutputs = false
end

local action = request.action
if action == "apply" then
if isAllOutputs then -- loop for All Output
for _, outputForAll in ipairs(allOutputs) do
setCycle(outputForAll, false)
apply(outputForAll, request.id)
end
return
end
-- A one-shot pick takes over from any cycle on that output.
setCycle(output, false)
apply(output, request.id)

elseif action == "select" then

if isAllOutputs then -- loop for All Output
for _, outputForAll in ipairs(allOutputs) do
local ids = {}
if type(request.ids) == "table" then
for _, id in ipairs(request.ids) do
if type(id) == "string" and id ~= "" then
table.insert(ids, id)
end
end
end
data.selection[outputForAll] = ids
shuffled[outputForAll] = nil
saveData()
publishStatus()
end
return
end

local ids = {}
if type(request.ids) == "table" then
for _, id in ipairs(request.ids) do
Expand All @@ -619,7 +668,34 @@ local function handleRequest(request)
shuffled[output] = nil
saveData()
publishStatus()

elseif action == "cycle" then

if isAllOutputs then -- loop for All Output
for _, outputForAll in ipairs(allOutputs) do
setCycle(outputForAll, request.enabled, request.minutes, request.order)
local cycle = cycleFor(outputForAll)
if cycle.enabled then
local ids = selectionFor(outputForAll)
if #ids == 0 then
setCycle(outputForAll, false)
noctalia.notify(tr("panel.title"), tr("panel.cycle_needs_selection"))
else
-- Start on the first pick straight away rather than leaving the
-- previous wallpaper up for a whole interval.
local first = cycle.order == "random" and nextRandom(outputForAll, ids) or ids[1]
apply(outputForAll, first)
noctalia.notify(
tr("panel.title"),
tr("panel.cycle_started", { count = #ids, minutes = cycle.minutes })
)
end
end
publishStatus()
end
return
end

setCycle(output, request.enabled, request.minutes, request.order)
local cycle = cycleFor(output)
if cycle.enabled then
Expand All @@ -640,6 +716,21 @@ local function handleRequest(request)
end
publishStatus()
elseif action == "stop" then

if isAllOutputs then
for _, outputForAll in ipairs(allOutputs) do

setCycle(outputForAll, false)
data.current[outputForAll] = nil
saveData()
stopProcess(outputForAll, nil)
restoreShellWallpaper(outputForAll)
publishStatus()

end
return
end

setCycle(output, false)
data.current[output] = nil
saveData()
Expand Down
30 changes: 28 additions & 2 deletions w-engine/w-engine-panel.luau
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ local function tr(key, subst)
return noctalia.tr(key)
end

-- Get All output for all fonctionnality --


-- ── Workshop discovery ───────────────────────────────────────────────────────

local function candidateRoots()
Expand Down Expand Up @@ -216,6 +219,26 @@ local function outputStatus()
return type(entry) == "table" and entry or {}
end


local function hasStopState() -- check for render stop button
if outputName ~= "All" then
local state = outputStatus()
return state.current ~= nil or state.restorable == true
end

local outputs = type(status) == "table" and status.outputs or nil
if type(outputs) ~= "table" then
return false
end

for _, entry in pairs(outputs) do
if type(entry) == "table" and (entry.current ~= nil or entry.restorable == true) then
return true
end
end
return false
end

local function storedDefaults()
return asTable(asTable(status.defaults).engine)
end
Expand Down Expand Up @@ -553,7 +576,6 @@ local ENGINE_TOGGLES = {
-- ── Rendering ────────────────────────────────────────────────────────────────

local function header()
local state = outputStatus()
local children = {
ui.label({
text = tr("panel.title"),
Expand All @@ -575,7 +597,7 @@ local function header()
}),
}

if state.current or state.restorable then
if hasStopState() then
table.insert(
children,
ui.button({
Expand All @@ -597,6 +619,10 @@ local function header()
selectedIndex = index - 1
end
end
table.insert(outputs, "All")
if outputName == "All" then
selectedIndex = #outputs - 1
end
table.insert(children, ui.select({ options = outputs, selectedIndex = selectedIndex, onChange = "outputSelected" }))
table.insert(
children,
Expand Down