81 lines
2.1 KiB
Plaintext
81 lines
2.1 KiB
Plaintext
local playAreaApi = require("core/PlayAreaApi")
|
|
|
|
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 }
|
|
|
|
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)
|
|
playAreaApi.updateSurface(isRightClick and "" or self.getInputs()[1].value)
|
|
end
|
|
|
|
function updateSurface(newURL)
|
|
playAreaApi.updateSurface(newURL)
|
|
end
|
|
|
|
-- 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
|