SCED/src/core/PlayAreaSelector.ttslua

81 lines
2.1 KiB
Plaintext
Raw Normal View History

2023-08-26 17:39:52 -04:00
local playAreaApi = require("core/PlayAreaApi")
2023-09-26 10:14:37 -04:00
local controlActive = false
-- parameters for open/close button for reusing
local buttonParameters = {}
buttonParameters.function_owner = self
buttonParameters.click_function = "click_toggleControl"
buttonParameters.height = 1500
buttonParameters.width = 1500
buttonParameters.color = { 1, 1, 1, 0 }
2022-11-12 05:41:37 -05:00
function onLoad()
createOpenCloseButton()
end
-- click function for main button
function click_toggleControl()
self.clearButtons()
self.clearInputs()
controlActive = not controlActive
createOpenCloseButton()
if not controlActive then return end
-- creates the label, input box and apply button
self.createButton({
function_owner = self,
label = "Playmat Image Swapper",
tooltip = "",
click_function = "none",
position = { 0, 0.15, 2.2 },
height = 0,
width = 0,
font_size = 300,
font_color = { 1, 1, 1 }
})
self.createInput({
function_owner = self,
label = "URL",
tooltip = "Enter URL for playmat image",
input_function = "none",
alignment = 3,
position = { 0, 0.15, 3 },
height = 323,
width = 4000,
font_size = 300
})
self.createButton({
function_owner = self,
label = "Apply Image\nTo Playmat",
tooltip = "Left-Click: Apply URL\nRight-Click: Reset to default image",
click_function = "click_applySurface",
position = { 0, 0.15, 4.1 },
height = 460,
width = 1400,
font_size = 200
})
end
-- click function for apply button
function click_applySurface(_, _, isRightClick)
2023-08-26 17:39:52 -04:00
playAreaApi.updateSurface(isRightClick and "" or self.getInputs()[1].value)
end
function updateSurface(newURL)
2023-08-26 17:39:52 -04:00
playAreaApi.updateSurface(newURL)
end
2023-08-24 20:04:14 -04:00
-- input function for the input box
function none() end
-- creates the main button
function createOpenCloseButton()
buttonParameters.tooltip = (controlActive and "Close" or "Open") .. " Playmat Panel"
self.createButton(buttonParameters)
end