-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement and simplify layout switching
- Loading branch information
1 parent
942a342
commit 342f640
Showing
3 changed files
with
37 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,39 @@ | ||
-- LAYOUT SWITCHING | ||
-- change layout depending on options | ||
|
||
local currentLayoutNum = 1 -- standard | ||
|
||
function apLayoutChange1() | ||
local progBreaker = Tracker:FindObjectForCode("progbreakerLayout") | ||
if (string.find(Tracker.ActiveVariantUID, "standard")) then | ||
if progBreaker.Active then | ||
Tracker:AddLayouts("layouts/items_only_progbreaker.json") | ||
--Tracker:AddLayouts("layouts/broadcast_horizontal_AP.json") -- ADD LATER | ||
else | ||
Tracker:AddLayouts("layouts/items_standard.json") | ||
end | ||
function updateLayout() | ||
if pauseLayoutUpdate then -- global set from AP autotracking to pause updating | ||
return -- update deferred | ||
end | ||
end | ||
|
||
function apLayoutChange2() | ||
local progSlide = Tracker:FindObjectForCode("progslideLayout") | ||
if (string.find(Tracker.ActiveVariantUID, "standard")) then | ||
if progSlide.Active then | ||
Tracker:AddLayouts("layouts/items_only_progslide.json") | ||
--Tracker:AddLayouts("layouts/broadcast_horizontal_AP.json") -- ADD LATER | ||
else | ||
Tracker:AddLayouts("layouts/items_standard.json") | ||
end | ||
end | ||
end | ||
|
||
function apLayoutChange3() | ||
local splitKick = Tracker:FindObjectForCode("splitkickLayout") | ||
if (string.find(Tracker.ActiveVariantUID, "standard")) then | ||
if splitKick.Active then | ||
Tracker:AddLayouts("layouts/items_only_splitkick.json") | ||
--Tracker:AddLayouts("layouts/broadcast_horizontal_AP.json") -- ADD LATER | ||
else | ||
Tracker:AddLayouts("layouts/items_standard.json") | ||
end | ||
end | ||
end | ||
|
||
function apLayoutChange4() | ||
local progBprogS = Tracker:FindObjectForCode("progbreakerprogslideLayout") | ||
if (string.find(Tracker.ActiveVariantUID, "standard")) then | ||
if progBprogS.Active then | ||
Tracker:AddLayouts("layouts/items_progbreaker_and_progslide.json") | ||
--Tracker:AddLayouts("layouts/broadcast_horizontal_AP.json") -- ADD LATER | ||
else | ||
Tracker:AddLayouts("layouts/items_standard.json") | ||
end | ||
end | ||
end | ||
|
||
function apLayoutChange5() | ||
local progBsplitK = Tracker:FindObjectForCode("progbreakersplitkickLayout") | ||
if (string.find(Tracker.ActiveVariantUID, "standard")) then | ||
if progBsplitK.Active then | ||
Tracker:AddLayouts("layouts/items_progbreaker_and_splitkick.json") | ||
--Tracker:AddLayouts("layouts/broadcast_horizontal_AP.json") -- ADD LATER | ||
else | ||
Tracker:AddLayouts("layouts/items_standard.json") | ||
end | ||
end | ||
end | ||
|
||
function apLayoutChange6() | ||
local progSsplitK = Tracker:FindObjectForCode("progslidesplitkickLayout") | ||
if (string.find(Tracker.ActiveVariantUID, "standard")) then | ||
if progSsplitK.Active then | ||
Tracker:AddLayouts("layouts/items_progslide_and_splitkick.json") | ||
--Tracker:AddLayouts("layouts/broadcast_horizontal_AP.json") -- ADD LATER | ||
else | ||
Tracker:AddLayouts("layouts/items_standard.json") | ||
end | ||
end | ||
end | ||
|
||
function apLayoutChange7() | ||
local progBSsplitK = Tracker:FindObjectForCode("progsandsplitLayout") | ||
if (string.find(Tracker.ActiveVariantUID, "standard")) then | ||
if progBSsplitK.Active then | ||
Tracker:AddLayouts("layouts/items_progs_and_split.json") | ||
--Tracker:AddLayouts("layouts/broadcast_horizontal_AP.json") -- ADD LATER | ||
else | ||
Tracker:AddLayouts("layouts/items_standard.json") | ||
end | ||
-- read toggles | ||
local progBreaker = Tracker:ProviderCountForCode("op_progbreaker") > 0 | ||
local progSlide = Tracker:ProviderCountForCode("op_progslide") > 0 | ||
local splitKicks = Tracker:ProviderCountForCode("op_splitkick_on") > 0 | ||
-- encode 3 toggles into a 3 bit integer (8 states), +1 for Lua array starting at 1 | ||
local layoutNum = 1 + (progBreaker and 1 or 0) + (progSlide and 2 or 0) + (splitKicks and 4 or 0) | ||
print(tostring(currentLayoutNum) .. " -> " .. tostring(layoutNum)) | ||
if layoutNum == currentLayoutNum then | ||
return -- unchanged | ||
end | ||
-- select layout from number | ||
local layoutNames = { | ||
"layouts/items_standard.json", | ||
"layouts/items_only_progbreaker.json", | ||
"layouts/items_only_progslide.json", | ||
"layouts/items_progbreaker_and_progslide.json", | ||
"layouts/items_only_splitkick.json", | ||
"layouts/items_progbreaker_and_splitkick.json", | ||
"layouts/items_progslide_and_splitkick.json", | ||
"layouts/items_progs_and_split.json", | ||
} | ||
local layoutName = layoutNames[layoutNum] | ||
-- load layout | ||
Tracker:AddLayouts(layoutName) | ||
currentLayoutNum = layoutNum -- remember what is currently loaded | ||
end | ||
|
||
ScriptHost:AddWatchForCode("useApLayout1", "progbreakerLayout", apLayoutChange1) | ||
ScriptHost:AddWatchForCode("useApLayout2", "progslideLayout", apLayoutChange2) | ||
ScriptHost:AddWatchForCode("useApLayout3", "splitkickLayout", apLayoutChange3) | ||
ScriptHost:AddWatchForCode("useApLayout4", "progbreakerprogslideLayout", apLayoutChange4) | ||
ScriptHost:AddWatchForCode("useApLayout5", "progbreakersplitkickLayout", apLayoutChange5) | ||
ScriptHost:AddWatchForCode("useApLayout6", "progslidesplitkickLayout", apLayoutChange6) | ||
ScriptHost:AddWatchForCode("useApLayout7", "progsandsplitLayout", apLayoutChange7) | ||
ScriptHost:AddWatchForCode("op_progbreaker", "op_progbreaker", updateLayout) | ||
ScriptHost:AddWatchForCode("op_progslide", "op_progslide", updateLayout) | ||
ScriptHost:AddWatchForCode("op_splitkick", "op_splitkick", updateLayout) |