Merge pull request #427 from argonui/placeholder
Added placeholder spawning and downloading everything functions
This commit is contained in:
commit
2820b73837
@ -3,7 +3,6 @@
|
||||
"ComponentTags_path": "ComponentTags.json",
|
||||
"CustomUIAssets_path": "CustomUIAssets.json",
|
||||
"DecalPallet_path": "DecalPallet.json",
|
||||
"Decals": [],
|
||||
"GameComplexity": "",
|
||||
"GameMode": "Arkham Horror LCG - Super Complete Edition",
|
||||
"GameType": "",
|
||||
@ -200,6 +199,7 @@
|
||||
"TokenArranger.022907",
|
||||
"ChaosBagManager.023240",
|
||||
"ArkhamSCE330-1092023-Page1.964222",
|
||||
"PlaceholderBoxDummy.a93466",
|
||||
"SoulsofDarkness.a94e6b"
|
||||
],
|
||||
"PlayArea": 1,
|
||||
|
45
objects/PlaceholderBoxDummy.a93466.json
Normal file
45
objects/PlaceholderBoxDummy.a93466.json
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"AltLookAngle": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"Autoraise": true,
|
||||
"ColorDiffuse": {
|
||||
"b": 0.82353,
|
||||
"g": 0.20157,
|
||||
"r": 0
|
||||
},
|
||||
"Description": "This dummy is there to hold the up-to-date script file for placeholder boxes to be available for placeholder box spawning.",
|
||||
"DragSelectable": true,
|
||||
"GMNotes": "",
|
||||
"GUID": "a93466",
|
||||
"Grid": true,
|
||||
"GridProjection": false,
|
||||
"Hands": false,
|
||||
"HideWhenFaceDown": false,
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": true,
|
||||
"LuaScript": "require(\"core/DownloadBox\")",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "BlockRectangle",
|
||||
"Nickname": "Placeholder Box Dummy",
|
||||
"Snap": true,
|
||||
"Sticky": true,
|
||||
"Tooltip": true,
|
||||
"Transform": {
|
||||
"posX": 78,
|
||||
"posY": 1.645,
|
||||
"posZ": -33,
|
||||
"rotX": 0,
|
||||
"rotY": 0,
|
||||
"rotZ": 0,
|
||||
"scaleX": 1,
|
||||
"scaleY": 1,
|
||||
"scaleZ": 1
|
||||
},
|
||||
"Value": 0,
|
||||
"XmlUI": ""
|
||||
}
|
@ -56,6 +56,7 @@ local GuidReferences = {
|
||||
MythosArea = "9f334f",
|
||||
NavigationOverlayHandler = "797ede",
|
||||
OptionPanelSource = "830bd0",
|
||||
PlaceholderBoxDummy = "a93466",
|
||||
PlayArea = "721ba2",
|
||||
PlayAreaZone = "a2f932",
|
||||
PlayerCardPanel = "2d30ee",
|
||||
|
@ -717,6 +717,128 @@ function downloadCoroutine()
|
||||
return 1
|
||||
end
|
||||
|
||||
-- spawns a bag that contains every object from the library
|
||||
function onClick_downloadAll()
|
||||
broadcastToAll("Download initiated - this will take a few minutes!")
|
||||
|
||||
-- hide download window
|
||||
if xmlVisibility.downloadWindow then
|
||||
xmlVisibility.downloadWindow = false
|
||||
UI.hide('downloadWindow')
|
||||
end
|
||||
|
||||
startLuaCoroutine(Global, "coroutineDownloadAll")
|
||||
end
|
||||
|
||||
function coroutineDownloadAll()
|
||||
local JSON = [[
|
||||
{
|
||||
"Name": "Bag",
|
||||
"Transform": {
|
||||
"posX": -39.5,
|
||||
"posY": 2,
|
||||
"posZ": -87,
|
||||
"rotX": 0,
|
||||
"rotY": 270,
|
||||
"rotZ": 0,
|
||||
"scaleX": 1.0,
|
||||
"scaleY": 1.0,
|
||||
"scaleZ": 1.0
|
||||
},
|
||||
"Nickname": "All Downloadable Content",
|
||||
"Bag": {
|
||||
"Order": 0
|
||||
},
|
||||
"ContainedObjects": [
|
||||
]]
|
||||
|
||||
local contained = ""
|
||||
local downloadedItems = 0
|
||||
local skippedItems = 0
|
||||
|
||||
-- loop through the library to add content
|
||||
for contentType, objectList in pairs(library) do
|
||||
broadcastToAll("Downloading " .. contentType .. "...")
|
||||
for _, params in ipairs(objectList) do
|
||||
local request = WebRequest.get(SOURCE_REPO .. '/' .. params.url)
|
||||
local start = os.time()
|
||||
while true do
|
||||
if request.is_done then
|
||||
contained = contained .. request.text .. ","
|
||||
downloadedItems = downloadedItems + 1
|
||||
break
|
||||
-- time-out if item can't be loaded in 5s
|
||||
elseif request.is_error or (os.time() - start) > 5 then
|
||||
skippedItems = skippedItems + 1
|
||||
break
|
||||
end
|
||||
coroutine.yield(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
JSON = JSON .. contained .. "]}"
|
||||
spawnObjectJSON({json = JSON})
|
||||
|
||||
broadcastToAll(downloadedItems .. " objects downloaded.", "Green")
|
||||
broadcastToAll(skippedItems .. " objects had a time-out / error.", "Orange")
|
||||
return 1
|
||||
end
|
||||
|
||||
-- spawns a placeholder box for the selected object
|
||||
function onClick_spawnPlaceholder()
|
||||
-- get object references
|
||||
local item = library[contentToShow][currentListItem]
|
||||
local dummy = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlaceholderBoxDummy")
|
||||
|
||||
-- error handling
|
||||
if not item.boxsize or item.boxsize == "" or not item.boxart or item.boxart == "" then
|
||||
print("Error loading object.")
|
||||
return
|
||||
end
|
||||
|
||||
-- get data for placeholder
|
||||
local spawnPos = {-39.5, 2, -87}
|
||||
|
||||
local meshTable = {
|
||||
big = "https://raw.githubusercontent.com/RobMayer/TTSLibrary/master/advboxes/core_h_MSH.obj",
|
||||
small = "https://raw.githubusercontent.com/RobMayer/TTSLibrary/master/advboxes/tuckbox_h_MSH.obj",
|
||||
wide = "http://pastebin.com/raw.php?i=uWAmuNZ2"
|
||||
}
|
||||
|
||||
local scaleTable = {
|
||||
big = {1.00, 0.14, 1.00},
|
||||
small = {2.21, 0.46, 2.42},
|
||||
wide = {2.00, 0.11, 1.69}
|
||||
}
|
||||
|
||||
local placeholder = spawnObject({
|
||||
type = "Custom_Model",
|
||||
position = spawnPos,
|
||||
rotation = {0, 270, 0},
|
||||
scale = scaleTable[item.boxsize],
|
||||
})
|
||||
|
||||
placeholder.setCustomObject({
|
||||
mesh = meshTable[item.boxsize],
|
||||
diffuse = item.boxart,
|
||||
material = 3
|
||||
})
|
||||
|
||||
placeholder.setColorTint({1, 1, 1, 71/255})
|
||||
placeholder.setName(item.name)
|
||||
placeholder.setDescription("by " .. (item.author or "Unknown"))
|
||||
placeholder.setGMNotes(item.url)
|
||||
placeholder.setLuaScript(dummy.getLuaScript())
|
||||
Player.getPlayers()[1].pingTable(spawnPos)
|
||||
|
||||
-- hide download window
|
||||
if xmlVisibility.downloadWindow then
|
||||
xmlVisibility.downloadWindow = false
|
||||
UI.hide('downloadWindow')
|
||||
end
|
||||
end
|
||||
|
||||
-- toggles the visibility of the respective UI
|
||||
---@param player LuaPlayer Player that triggered this
|
||||
---@param title String Name of the UI to toggle
|
||||
|
@ -12,6 +12,12 @@
|
||||
color="white"/>
|
||||
<Button class="activeTab"
|
||||
color="#ffffff"/>
|
||||
<Button class="windowButton"
|
||||
hoverClass="bGrey"
|
||||
pressClass="bWhite"
|
||||
selectClass="bWhite"
|
||||
color="#888888"
|
||||
font="font_teutonic-arkham"/>
|
||||
</Defaults>
|
||||
|
||||
<!-- window to select downloadable content -->
|
||||
@ -27,13 +33,32 @@
|
||||
<!-- window header -->
|
||||
<Panel preferredHeight="60"
|
||||
padding="10 10 5 5"
|
||||
spacing="10"
|
||||
outlineSize="2 2"
|
||||
outline="#303030"
|
||||
color="black">
|
||||
<Text fontSize="32"
|
||||
font="font_teutonic-arkham"
|
||||
preferredWidth="600"
|
||||
alignment="MiddleLeft">Downloadable Content</Text>
|
||||
<Panel>
|
||||
<Button id="downloadAll_button"
|
||||
class="windowButton"
|
||||
visibility="Black"
|
||||
onClick="onClick_downloadAll"
|
||||
height="30"
|
||||
preferredWidth="110"
|
||||
fontSize="20"
|
||||
tooltip="Very rough estimate: 400 MB"
|
||||
tooltipPosition="Above"
|
||||
tooltipBackgroundColor="rgba(0,0,0,1)">Download Everything</Button>
|
||||
<Button id="spawnPlaceholder_button"
|
||||
class="windowButton"
|
||||
visibility="Black"
|
||||
onClick="onClick_spawnPlaceholder"
|
||||
height="30"
|
||||
preferredWidth="110"
|
||||
fontSize="20">Spawn Placeholder</Button>
|
||||
<Panel preferredWidth="50">
|
||||
<Button rectAlignment="MiddleRight"
|
||||
width="50"
|
||||
color="clear"
|
||||
@ -116,15 +141,11 @@
|
||||
<Panel preferredHeight="60">
|
||||
<!-- download button -->
|
||||
<Button id="download_button"
|
||||
hoverClass="bGrey"
|
||||
pressClass="bWhite"
|
||||
selectClass="bWhite"
|
||||
class="windowButton"
|
||||
onClick="onClick_download"
|
||||
color="#888888"
|
||||
height="50"
|
||||
width="270"
|
||||
fontSize="28"
|
||||
font="font_teutonic-arkham">Download</Button>
|
||||
fontSize="28">Download</Button>
|
||||
<!-- download progress bar -->
|
||||
<ProgressBar id="download_progress"
|
||||
active="false"
|
||||
|
Loading…
Reference in New Issue
Block a user