Merge pull request #123 from argonui/optionpanel-6

Option Panel: Part 6 - Addition of "load defaults" functionality
This commit is contained in:
Chr1Z 2022-12-22 13:26:19 +01:00 committed by GitHub
commit 7ff2c77118
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 67 additions and 24 deletions

View File

@ -22,7 +22,7 @@
}, },
"Lighting_path": "Lighting.json", "Lighting_path": "Lighting.json",
"LuaScript": "require(\"core/Global\")", "LuaScript": "require(\"core/Global\")",
"LuaScriptState": "{\"optionPanel\":{\"showDrawButton\":false,\"showHandHelper\":[],\"useClueClickers\":false,\"useSnapTags\":true}}", "LuaScriptState_path": "LuaScriptState.luascriptstate",
"MusicPlayer_path": "MusicPlayer.json", "MusicPlayer_path": "MusicPlayer.json",
"Note": "", "Note": "",
"ObjectStates_order": [ "ObjectStates_order": [

View File

@ -0,0 +1 @@
{"optionPanel":{"showChaosBagManager":false,"showCleanUpHelper":false,"showDrawButton":false,"showHandHelper":{},"showNavigationOverlay":false,"showTokenArranger":false,"useClueClickers":false,"useSnapTags":true}}

View File

@ -273,7 +273,7 @@
"IgnoreFoW": false, "IgnoreFoW": false,
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": true, "Locked": true,
"LuaScriptState": "{\"activeInvestigatorId\":\"00000\",\"playerColor\":\"White\",\"zoneID\":\"7af2cf\"}", "LuaScriptState_path": "Playermat1White.8b081b.luascriptstate",
"LuaScript_path": "Playermat1White.8b081b.ttslua", "LuaScript_path": "Playermat1White.8b081b.ttslua",
"MeasureMovement": false, "MeasureMovement": false,
"Name": "Custom_Tile", "Name": "Custom_Tile",

View File

@ -0,0 +1 @@
{"activeInvestigatorId":"00000","isDrawButtonVisible":false,"playerColor":"White","zoneID":"7af2cf"}

View File

@ -273,7 +273,7 @@
"IgnoreFoW": false, "IgnoreFoW": false,
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": true, "Locked": true,
"LuaScriptState": "{\"activeInvestigatorId\":\"00000\",\"playerColor\":\"Orange\",\"zoneID\":\"b047f8\"}", "LuaScriptState_path": "Playermat2Orange.bd0ff4.luascriptstate",
"LuaScript_path": "Playermat2Orange.bd0ff4.ttslua", "LuaScript_path": "Playermat2Orange.bd0ff4.ttslua",
"MeasureMovement": false, "MeasureMovement": false,
"Name": "Custom_Tile", "Name": "Custom_Tile",

View File

@ -0,0 +1 @@
{"activeInvestigatorId":"00000","isDrawButtonVisible":false,"playerColor":"Orange","zoneID":"b047f8"}

View File

@ -273,7 +273,7 @@
"IgnoreFoW": false, "IgnoreFoW": false,
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": true, "Locked": true,
"LuaScriptState": "{\"activeInvestigatorId\":\"00000\",\"playerColor\":\"Green\",\"zoneID\":\"fb28e1\"}", "LuaScriptState_path": "Playermat3Green.383d8b.luascriptstate",
"LuaScript_path": "Playermat3Green.383d8b.ttslua", "LuaScript_path": "Playermat3Green.383d8b.ttslua",
"MeasureMovement": false, "MeasureMovement": false,
"Name": "Custom_Tile", "Name": "Custom_Tile",

View File

@ -0,0 +1 @@
{"activeInvestigatorId":"00000","isDrawButtonVisible":false,"playerColor":"Green","zoneID":"fb28e1"}

View File

@ -273,7 +273,7 @@
"IgnoreFoW": false, "IgnoreFoW": false,
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": true, "Locked": true,
"LuaScriptState": "{\"activeInvestigatorId\":\"00000\",\"playerColor\":\"Red\",\"zoneID\":\"18538f\"}", "LuaScriptState_path": "Playermat4Red.0840d5.luascriptstate",
"LuaScript_path": "Playermat4Red.0840d5.ttslua", "LuaScript_path": "Playermat4Red.0840d5.ttslua",
"MeasureMovement": false, "MeasureMovement": false,
"Name": "Custom_Tile", "Name": "Custom_Tile",

View File

@ -0,0 +1 @@
{"activeInvestigatorId":"00000","isDrawButtonVisible":false,"playerColor":"Red","zoneID":"18538f"}

View File

@ -787,11 +787,6 @@ end
-- Option Panel related functionality -- Option Panel related functionality
--------------------------------------------------------- ---------------------------------------------------------
-- loads the default options
function onClick_defaultSettings()
print("Dummy: Load default settings")
end
-- called by toggling an option -- called by toggling an option
function onClick_toggleOption(_, id) function onClick_toggleOption(_, id)
local state = self.UI.getAttribute(id, "isOn") local state = self.UI.getAttribute(id, "isOn")
@ -814,6 +809,8 @@ function updateOptionPanelState()
or (type(enabled) == "string" and enabled) or (type(enabled) == "string" and enabled)
or (type(enabled) == "table" and #enabled ~= 0) then or (type(enabled) == "table" and #enabled ~= 0) then
self.UI.setAttribute(id, "isOn", true) self.UI.setAttribute(id, "isOn", true)
else
self.UI.setAttribute(id, "isOn", "False")
end end
end end
end end
@ -888,26 +885,40 @@ end
---@param name String Name of the object that should be copied ---@param name String Name of the object that should be copied
---@param position Position Desired position of the object ---@param position Position Desired position of the object
function spawnHelperObject(name, position, rotation, color) function spawnHelperObject(name, position, rotation, color)
for _, obj in ipairs(getObjectFromGUID(BARREL_GUID).getData().ContainedObjects) do local barrel = getObjectFromGUID(BARREL_GUID)
if obj["Nickname"] == name then
return spawnObjectData({ -- error handling for missing barrel
data = obj, if not barrel then
broadcastToAll("'Barrel' with fan-made accessories could not be found!", "Red")
return
end
local spawnTable = {
position = position, position = position,
rotation = rotation or {0, 270, 0},
callback_function = function(object) callback_function = function(object)
if name == "Hand Helper" then if name == "Hand Helper" then
Wait.time(function() object.call("externalColorChange", color) end, 1) Wait.time(function() object.call("externalColorChange", color) end, 0.1)
elseif name == "Token Arranger" then elseif name == "Token Arranger" then
Wait.time(function() object.call("layout") end, 1) Wait.time(function() object.call("layout") end, 0.1)
end end
end end
}) }
-- only overrride rotation if there is one provided (object's rotation used instead)
if rotation then
spawnTable.rotation = rotation
end
for _, obj in ipairs(barrel.getData().ContainedObjects) do
if obj["Nickname"] == name then
spawnTable.data = obj
return spawnObjectData(spawnTable)
end end
end end
end end
-- removes the specified tool (by name) -- removes the specified tool (by name)
---@param name String Name of the object that should be removed ---@param name String Object that should be removed
function removeHelperObject(name) function removeHelperObject(name)
-- links objects name to the respective option name (to grab the GUID for removal) -- links objects name to the respective option name (to grab the GUID for removal)
local referenceTable = { local referenceTable = {
@ -933,3 +944,30 @@ function removeHelperObject(name)
end end
end end
end end
-- loads the default options
function onClick_defaultSettings()
for id, _ in pairs(optionPanel) do
local state = false
-- override for settings that are enabled by default
if id == "useSnapTags" then
state = true
end
applyOptionPanelChange(id, state)
end
-- clean reset of variable
optionPanel = {
useSnapTags = true,
showDrawButton = false,
useClueClickers = false,
showTokenArranger = false,
showCleanUpHelper = false,
showHandHelper = {},
showChaosBagManager = false,
showNavigationOverlay = false
}
-- update UI
updateOptionPanelState()
end