From ce38acca4f22eba8c9560b3e2435e473a6fda476 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 19 Oct 2023 17:47:59 +0200 Subject: [PATCH 1/4] ui changes --- src/core/Global.ttslua | 10 ++++++++++ xml/Global/DownloadWindow.xml | 35 ++++++++++++++++++++++++++++------- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 9ebbbdf7..6cbea48a 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -717,6 +717,16 @@ function downloadCoroutine() return 1 end +-- spawns a bag that contains every object from the library +function onClick_downloadAll() + +end + +-- spawns a placeholder box for the selected object +function onClick_spawnPlaceholder() + +end + -- toggles the visibility of the respective UI ---@param player LuaPlayer Player that triggered this ---@param title String Name of the UI to toggle diff --git a/xml/Global/DownloadWindow.xml b/xml/Global/DownloadWindow.xml index 8b11460b..49583b87 100644 --- a/xml/Global/DownloadWindow.xml +++ b/xml/Global/DownloadWindow.xml @@ -12,6 +12,12 @@ color="white"/> + + + fontSize="28">Download Date: Thu, 19 Oct 2023 18:20:16 +0200 Subject: [PATCH 2/4] spawn placeholder function completed --- config.json | 2 +- objects/PlaceholderBoxDummy.a93466.json | 45 ++++++++++++++ src/core/GUIDReferenceHandler.ttslua | 1 + src/core/Global.ttslua | 79 ++++++++++++++++++++----- 4 files changed, 111 insertions(+), 16 deletions(-) create mode 100644 objects/PlaceholderBoxDummy.a93466.json diff --git a/config.json b/config.json index 1b0ebb1b..741b5115 100644 --- a/config.json +++ b/config.json @@ -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, diff --git a/objects/PlaceholderBoxDummy.a93466.json b/objects/PlaceholderBoxDummy.a93466.json new file mode 100644 index 00000000..f20cff4f --- /dev/null +++ b/objects/PlaceholderBoxDummy.a93466.json @@ -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": "" +} \ No newline at end of file diff --git a/src/core/GUIDReferenceHandler.ttslua b/src/core/GUIDReferenceHandler.ttslua index b770c057..53b3c7d9 100644 --- a/src/core/GUIDReferenceHandler.ttslua +++ b/src/core/GUIDReferenceHandler.ttslua @@ -56,6 +56,7 @@ local GuidReferences = { MythosArea = "9f334f", NavigationOverlayHandler = "797ede", OptionPanelSource = "830bd0", + PlaceholderBoxDummy = "a93466", PlayArea = "721ba2", PlayAreaZone = "a2f932", PlayerCardPanel = "2d30ee", diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 6cbea48a..b7ba459b 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -724,7 +724,56 @@ 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 @@ -764,25 +813,25 @@ function updatePreviewWindow() local maskData = {} if item.boxsize == "big" then maskData = { - image = "box-cover-mask-big", - width = "870", - height = "435", - offsetXY = "154 60" - } + image = "box-cover-mask-big", + width = "870", + height = "435", + offsetXY = "154 60" + } elseif item.boxsize == "small" then maskData = { - image = "box-cover-mask-small", - width = "792", - height = "594", - offsetXY = "135 13" - } + image = "box-cover-mask-small", + width = "792", + height = "594", + offsetXY = "135 13" + } elseif item.boxsize == "wide" then maskData = { - image = "box-cover-mask-wide", - width = "756", - height = "630", - offsetXY = "-190 -70" - } + image = "box-cover-mask-wide", + width = "756", + height = "630", + offsetXY = "-190 -70" + } end -- loading empty image as placeholder until real image is loaded From 2189cf83af785f9facf426e580ce1c6cfb43c6e6 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 19 Oct 2023 18:47:19 +0200 Subject: [PATCH 3/4] download everything WIP --- src/core/Global.ttslua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index b7ba459b..0236fc55 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -719,7 +719,43 @@ end -- spawns a bag that contains every object from the library function onClick_downloadAll() + startLuaCoroutine(Global, "multiDownload") +end +function multiDownload() + local data = { + Name = "Bag", + Nickname = "All Downloadable Content", + Transform = { + posX = -39.5, + posY = 2, + posZ = -87, + rotX = 0, + rotY = 270, + rotZ = 0, + scaleX = 1, + scaleY = 1, + scaleZ = 1 + }, + ContainedObjects = {} + } + + -- loop through the library to add content + --for contentType, objectList in pairs(library) do + --for _, params in ipairs(objectList) do + local params = library[contentToShow][currentListItem] + WebRequest.get(SOURCE_REPO .. '/' .. params.url, function (request) + table.insert(data.ContainedObjects, request.text) + spawnObjectData({data = data}) -- need spawnObjectJson + end) + --end + --end + + -- hide download window + if xmlVisibility.downloadWindow then + xmlVisibility.downloadWindow = false + UI.hide('downloadWindow') + end end -- spawns a placeholder box for the selected object From d4d63097782479873c9ffedb484461387cb2ec39 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 19 Oct 2023 23:20:46 +0200 Subject: [PATCH 4/4] added download all function --- src/core/Global.ttslua | 89 +++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 31 deletions(-) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 0236fc55..92e088bf 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -719,43 +719,70 @@ end -- spawns a bag that contains every object from the library function onClick_downloadAll() - startLuaCoroutine(Global, "multiDownload") -end - -function multiDownload() - local data = { - Name = "Bag", - Nickname = "All Downloadable Content", - Transform = { - posX = -39.5, - posY = 2, - posZ = -87, - rotX = 0, - rotY = 270, - rotZ = 0, - scaleX = 1, - scaleY = 1, - scaleZ = 1 - }, - ContainedObjects = {} - } - - -- loop through the library to add content - --for contentType, objectList in pairs(library) do - --for _, params in ipairs(objectList) do - local params = library[contentToShow][currentListItem] - WebRequest.get(SOURCE_REPO .. '/' .. params.url, function (request) - table.insert(data.ContainedObjects, request.text) - spawnObjectData({data = data}) -- need spawnObjectJson - end) - --end - --end + 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