From 4fa1eb60405a9dcebd5a4c64a43f4f9cf52b937f Mon Sep 17 00:00:00 2001 From: Jorge Parra Date: Mon, 6 Mar 2023 18:36:42 -0500 Subject: [PATCH 1/5] Added in rectangles to select ally/arcane slots for Summoned Servitor #84 --- .../SummonedServitorUpgradeSheet.ttslua | 117 +++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua b/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua index 75ab4600..7a6d0b82 100644 --- a/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua +++ b/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua @@ -31,13 +31,32 @@ existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 } inputBoxes = {} +-- Locations of the skill selectors +local SLOT_ICON_POSITIONS = { + arcane = { x = 0.160, z = 0.65}, + ally = { x = -0.073, z = 0.65} + } + + local selectedSlots = { + arcane = false, + ally = false + } + -- override 'marked boxes' for debugging ('all' or 'none') markDEBUG = "" -- save state when going into bags / decks function onDestroy() self.script_state = onSave() end -function onSave() return JSON.encode({ markedBoxes, inputValues }) end +function onSave() + local slotArray = { } + for slot, isSelected in pairs(selectedSlots) do + if (isSelected) then + table.insert(slotArray, slot) + end + end + return JSON.encode({ markedBoxes, inputValues, slotArray }) + end -- Startup procedure function onLoad(saved_data) @@ -45,6 +64,13 @@ function onLoad(saved_data) local loaded_data = JSON.decode(saved_data) markedBoxes = loaded_data[1] inputValues = loaded_data[2] + log(loaded_data[3]) + for _, slot in ipairs(loaded_data[3]) do + if (slot ~= "") then + log("Slot from load "..slot) + selectedSlots[slot] = true + end + end else markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } inputValues = { "", "", "", "", "" } @@ -52,6 +78,7 @@ function onLoad(saved_data) makeData() createButtonsAndBoxes() + updateSlotDisplay() self.addContextMenuItem("Reset Inputs", function() updateState() end) self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) @@ -63,6 +90,7 @@ function updateState(markedBoxesNew) if markedBoxesNew then markedBoxes = markedBoxesNew end makeData() createButtonsAndBoxes() + updateSlotDisplay() end -- create Data @@ -178,4 +206,91 @@ function createButtonsAndBoxes() value = box_data.value }) end + + makeSlotSelectionButtons() end + +-- Creates the invisible buttons overlaying the skill icons +function makeSlotSelectionButtons() + local buttonPositions = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z } + local buttonData = { + click_function = "click_arcane", + function_owner = self, + position = buttonPositions, + height = 130, + width = 130, + scale = { 1, 1, 1 }, + color = { 0, 0, 0, 0 }, + } + self.createButton(buttonData) + buttonData.click_function = "click_ally" + buttonPositions.x = -1 * SLOT_ICON_POSITIONS.ally.x + buttonData.position = buttonPositions + self.createButton(buttonData) + end + +function click_arcane() + selectedSlots.arcane = not selectedSlots.arcane + updateSlotDisplay() + end + + function click_ally() + selectedSlots.ally = not selectedSlots.ally + updateSlotDisplay() + end + +-- Refresh the vector circles indicating a slot is selected. Since we can only have one table of +-- vectors set, have to refresh all 2 at once +function updateSlotDisplay() + local circles = { } + for slot, isSelected in pairs(selectedSlots) do + if isSelected then + local circle = getCircleVector(SLOT_ICON_POSITIONS[slot], slot) + if circle ~= nil then + table.insert(circles, circle) + end + end + end + self.setVectorLines(circles) + end + + function getCircleVector(center, slot) + -- local diameter = Vector(0, 0, 0.1) + -- local pointOfOrigin = Vector(center.x, 0.3, center.z) + + -- -- Declare Results vectors + -- local vec = Vector(0, 0, 0) + -- local vecList = {} + + -- local arcStep = 5 + -- for i = 0, 360, arcStep do + -- diameter:rotateOver('y', arcStep) + -- vec = pointOfOrigin + diameter + -- vec.y = pointOfOrigin.y + -- table.insert(vecList, vec) + -- end + local vecList = {} + if slot == "arcane" then + vecList = { + Vector(center.x + 0.12, 0.3, center.z + 0.05), + Vector(center.x - 0.12, 0.3, center.z + 0.05), + Vector(center.x - 0.12, 0.3, center.z - 0.05), + Vector(center.x + 0.12, 0.3, center.z - 0.05), + Vector(center.x + 0.12, 0.3, center.z + 0.05), + } + elseif slot == "ally" then + vecList = { + Vector(center.x + 0.07, 0.3, center.z + 0.05), + Vector(center.x - 0.07, 0.3, center.z + 0.05), + Vector(center.x - 0.07, 0.3, center.z - 0.05), + Vector(center.x + 0.07, 0.3, center.z - 0.05), + Vector(center.x + 0.07, 0.3, center.z + 0.05), + } + end + + return { + points = vecList, + color = {0.597, 0.195, 0.796}, + thickness = 0.02, + } + end From c48533ec299ec7533f7a4c79baaaa1d81529b9bd Mon Sep 17 00:00:00 2001 From: Jorge Parra Date: Tue, 7 Mar 2023 11:48:30 -0500 Subject: [PATCH 2/5] Addressed Feedback on Summoned Servitor changes from #227 --- .../SummonedServitorUpgradeSheet.ttslua | 87 +++++++------------ 1 file changed, 31 insertions(+), 56 deletions(-) diff --git a/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua b/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua index 7a6d0b82..18dcc60a 100644 --- a/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua +++ b/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua @@ -31,16 +31,13 @@ existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 } inputBoxes = {} --- Locations of the skill selectors +-- Locations of the slot selectors local SLOT_ICON_POSITIONS = { arcane = { x = 0.160, z = 0.65}, ally = { x = -0.073, z = 0.65} } - local selectedSlots = { - arcane = false, - ally = false - } +local selectedSlot = "" -- override 'marked boxes' for debugging ('all' or 'none') markDEBUG = "" @@ -48,15 +45,7 @@ markDEBUG = "" -- save state when going into bags / decks function onDestroy() self.script_state = onSave() end -function onSave() - local slotArray = { } - for slot, isSelected in pairs(selectedSlots) do - if (isSelected) then - table.insert(slotArray, slot) - end - end - return JSON.encode({ markedBoxes, inputValues, slotArray }) - end +function onSave() return JSON.encode({ markedBoxes, inputValues, selectedSlot }) end -- Startup procedure function onLoad(saved_data) @@ -64,12 +53,10 @@ function onLoad(saved_data) local loaded_data = JSON.decode(saved_data) markedBoxes = loaded_data[1] inputValues = loaded_data[2] - log(loaded_data[3]) - for _, slot in ipairs(loaded_data[3]) do - if (slot ~= "") then - log("Slot from load "..slot) - selectedSlots[slot] = true - end + if #loaded_data > 2 then + selectedSlot = loaded_data[3] + else + selectedSlot = "" end else markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } @@ -210,7 +197,7 @@ function createButtonsAndBoxes() makeSlotSelectionButtons() end --- Creates the invisible buttons overlaying the skill icons +-- Creates the invisible buttons overlaying the slot words function makeSlotSelectionButtons() local buttonPositions = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z } local buttonData = { @@ -230,45 +217,33 @@ function makeSlotSelectionButtons() end function click_arcane() - selectedSlots.arcane = not selectedSlots.arcane - updateSlotDisplay() - end - - function click_ally() - selectedSlots.ally = not selectedSlots.ally - updateSlotDisplay() - end - --- Refresh the vector circles indicating a slot is selected. Since we can only have one table of --- vectors set, have to refresh all 2 at once -function updateSlotDisplay() - local circles = { } - for slot, isSelected in pairs(selectedSlots) do - if isSelected then - local circle = getCircleVector(SLOT_ICON_POSITIONS[slot], slot) - if circle ~= nil then - table.insert(circles, circle) - end - end + if selectedSlot ~= "arcane" then + selectedSlot = "arcane" + else + selectedSlot = "" end - self.setVectorLines(circles) + updateSlotDisplay() end - function getCircleVector(center, slot) - -- local diameter = Vector(0, 0, 0.1) - -- local pointOfOrigin = Vector(center.x, 0.3, center.z) +function click_ally() + if selectedSlot ~= "ally" then + selectedSlot = "ally" + else + selectedSlot = "" + end + updateSlotDisplay() +end + +-- Refresh the vector circles indicating a slot is selected. +function updateSlotDisplay() + local box = {} + if selectedSlot ~= "" then + box = getBoxVector(SLOT_ICON_POSITIONS[selectedSlot], selectedSlot) + end + self.setVectorLines({box}) + end - -- -- Declare Results vectors - -- local vec = Vector(0, 0, 0) - -- local vecList = {} - - -- local arcStep = 5 - -- for i = 0, 360, arcStep do - -- diameter:rotateOver('y', arcStep) - -- vec = pointOfOrigin + diameter - -- vec.y = pointOfOrigin.y - -- table.insert(vecList, vec) - -- end + function getBoxVector(center, slot) local vecList = {} if slot == "arcane" then vecList = { From da2dd6696635ea00bd412b889161b1722348c48d Mon Sep 17 00:00:00 2001 From: Jorge Parra Date: Wed, 15 Mar 2023 17:13:08 -0400 Subject: [PATCH 3/5] Modified SS script state, added transparent indicator buttons, and cleaned up requested code logic --- .../SummonedServitorUpgradeSheet.5397a6.json | 2 +- .../SummonedServitorUpgradeSheet.ttslua | 67 ++++++++++--------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.json b/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.json index dfd159a1..bd29b481 100644 --- a/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.json +++ b/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.json @@ -34,7 +34,7 @@ "LayoutGroupSortIndex": 0, "Locked": false, "LuaScript": "require(\"playercards/customizable/SummonedServitorUpgradeSheet\")", - "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"]]", + "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"],\"\"]", "MeasureMovement": false, "Name": "CardCustom", "Nickname": "Summoned Servitor Upgrade Sheet", diff --git a/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua b/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua index 18dcc60a..8bad5c1e 100644 --- a/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua +++ b/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua @@ -237,35 +237,42 @@ end -- Refresh the vector circles indicating a slot is selected. function updateSlotDisplay() local box = {} - if selectedSlot ~= "" then - box = getBoxVector(SLOT_ICON_POSITIONS[selectedSlot], selectedSlot) - end - self.setVectorLines({box}) - end - - function getBoxVector(center, slot) - local vecList = {} - if slot == "arcane" then - vecList = { - Vector(center.x + 0.12, 0.3, center.z + 0.05), - Vector(center.x - 0.12, 0.3, center.z + 0.05), - Vector(center.x - 0.12, 0.3, center.z - 0.05), - Vector(center.x + 0.12, 0.3, center.z - 0.05), - Vector(center.x + 0.12, 0.3, center.z + 0.05), - } - elseif slot == "ally" then - vecList = { - Vector(center.x + 0.07, 0.3, center.z + 0.05), - Vector(center.x - 0.07, 0.3, center.z + 0.05), - Vector(center.x - 0.07, 0.3, center.z - 0.05), - Vector(center.x + 0.07, 0.3, center.z - 0.05), - Vector(center.x + 0.07, 0.3, center.z + 0.05), - } + local center = {} + center = SLOT_ICON_POSITIONS["arcane"] + local arcaneVecList = { + Vector(center.x + 0.12, 0.3, center.z + 0.05), + Vector(center.x - 0.12, 0.3, center.z + 0.05), + Vector(center.x - 0.12, 0.3, center.z - 0.05), + Vector(center.x + 0.12, 0.3, center.z - 0.05), + Vector(center.x + 0.12, 0.3, center.z + 0.05), + } + center = SLOT_ICON_POSITIONS["ally"] + local allyVecList = { + Vector(center.x + 0.07, 0.3, center.z + 0.05), + Vector(center.x - 0.07, 0.3, center.z + 0.05), + Vector(center.x - 0.07, 0.3, center.z - 0.05), + Vector(center.x + 0.07, 0.3, center.z - 0.05), + Vector(center.x + 0.07, 0.3, center.z + 0.05), + } + local arcaneVecColor = {0.5, 0.5, 0.5, 0.75} + local allyVecColor = {0.5, 0.5, 0.5, 0.75} + if selectedSlot == "arcane" then + arcaneVecColor = {0.597, 0.195, 0.796} + elseif selectedSlot == "ally" then + allyVecColor = {0.597, 0.195, 0.796} end - return { - points = vecList, - color = {0.597, 0.195, 0.796}, - thickness = 0.02, - } - end + self.setVectorLines({ + { + points = arcaneVecList, + color = arcaneVecColor, + thickness = 0.02, + }, + { + points = allyVecList, + color = allyVecColor, + thickness = 0.02, + }, + + }) +end From ed9d8c2614af93120c32af26ae476744ee6071db Mon Sep 17 00:00:00 2001 From: Jorge Parra Date: Thu, 16 Mar 2023 15:27:33 -0400 Subject: [PATCH 4/5] Added ArkhamDB Importer support for SS upgrade sheet changes, and minor refactor on code logic for the same --- .../SummonedServitorUpgradeSheet.5397a6.json | 2 +- src/arkhamdb/DeckImporterMain.ttslua | 20 ++++++++-- .../SummonedServitorUpgradeSheet.ttslua | 40 +++++++++---------- 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.json b/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.json index bd29b481..81677ad4 100644 --- a/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.json +++ b/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.json @@ -34,7 +34,7 @@ "LayoutGroupSortIndex": 0, "Locked": false, "LuaScript": "require(\"playercards/customizable/SummonedServitorUpgradeSheet\")", - "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\",\"\",\"\",\"\",\"\"],\"\"]", + "LuaScriptState": "[[0,0,0,0,0,0,0,0,0,0],[\"\"]]", "MeasureMovement": false, "Name": "CardCustom", "Nickname": "Summoned Servitor Upgrade Sheet", diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index 8d981451..d3ca73c0 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -5,7 +5,7 @@ local playAreaApi = require("core/PlayAreaApi") local arkhamDb = require("arkhamdb/ArkhamDb") local zones = require("playermat/Zones") -local DEBUG = false +local DEBUG = true local ALL_CARDS_GUID = "15bb07" @@ -30,6 +30,11 @@ customizationRowsWithFields["09079"].inputMap = {} customizationRowsWithFields["09079"].inputMap[1] = 1 customizationRowsWithFields["09079"].inputMap[5] = 2 customizationRowsWithFields["09079"].inputMap[6] = 3 +-- Summoned Servitor +customizationRowsWithFields["09080"] = {} +customizationRowsWithFields["09080"].inputCount = 1 +customizationRowsWithFields["09080"].inputMap = {} +customizationRowsWithFields["09080"].inputMap[6] = 1 -- Grizzled customizationRowsWithFields["09101"] = {} customizationRowsWithFields["09101"].inputCount = 3 @@ -372,6 +377,9 @@ function handleCustomizableUpgrades(cardList, customizations) table.insert(inputValues, "") end end + for key, value in pairs(inputValues) do + log("Key " .. key.." Value " .. value) + end local inputCount = 0 for _, entry in ipairs(index_xp) do local counter = 0 @@ -389,15 +397,19 @@ function handleCustomizableUpgrades(cardList, customizations) inputValues[customizationRowsWithFields[baseId].inputMap[index]] = convertRavenQuillSelections(str) elseif customizationRowsWithFields[baseId] ~= nil then inputValues[customizationRowsWithFields[baseId].inputMap[index]] = str + log(str) end end end end -- remove first entry in markedBoxes if row 0 has textbox - if customizationRowsWithFields[baseId] ~= nil - and customizationRowsWithFields[baseId].inputCount > 0 then - table.remove(markedBoxes, 1) + if customizationRowsWithFields[baseId] ~= nil and customizationRowsWithFields[baseId].inputCount > 0 then + if (baseId == "09080" and markedBoxes[6] == 2 and inputValues[customizationRowsWithFields[baseId].inputMap[6]] == "") then + inputValues[customizationRowsWithFields[baseId].inputMap[6]] = "0" + else + table.remove(markedBoxes, 1) + end end -- write the loaded values to the save_data of the sheets diff --git a/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua b/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua index 8bad5c1e..11bcf950 100644 --- a/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua +++ b/src/playercards/customizable/SummonedServitorUpgradeSheet.ttslua @@ -35,9 +35,12 @@ inputBoxes = {} local SLOT_ICON_POSITIONS = { arcane = { x = 0.160, z = 0.65}, ally = { x = -0.073, z = 0.65} - } - -local selectedSlot = "" +} + +-- These match with ArkhamDB's way of storing the data in the dropdown menu +local slotIndices = {arcane = "1", ally = "0", none = ""} + +local selectedSlot = slotIndices.none -- override 'marked boxes' for debugging ('all' or 'none') markDEBUG = "" @@ -45,22 +48,17 @@ markDEBUG = "" -- save state when going into bags / decks function onDestroy() self.script_state = onSave() end -function onSave() return JSON.encode({ markedBoxes, inputValues, selectedSlot }) end +function onSave() return JSON.encode({ markedBoxes, {selectedSlot} }) end -- Startup procedure function onLoad(saved_data) if saved_data ~= "" and markDEBUG == "" then local loaded_data = JSON.decode(saved_data) markedBoxes = loaded_data[1] - inputValues = loaded_data[2] - if #loaded_data > 2 then - selectedSlot = loaded_data[3] - else - selectedSlot = "" - end + selectedSlot = loaded_data[2][1] else markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } + selectedSlot = "" end makeData() @@ -214,22 +212,22 @@ function makeSlotSelectionButtons() buttonPositions.x = -1 * SLOT_ICON_POSITIONS.ally.x buttonData.position = buttonPositions self.createButton(buttonData) - end +end function click_arcane() - if selectedSlot ~= "arcane" then - selectedSlot = "arcane" + if selectedSlot == slotIndices.arcane then + selectedSlot = slotIndices.none else - selectedSlot = "" + selectedSlot = slotIndices.arcane end updateSlotDisplay() - end +end function click_ally() - if selectedSlot ~= "ally" then - selectedSlot = "ally" + if selectedSlot == slotIndices.ally then + selectedSlot = slotIndices.none else - selectedSlot = "" + selectedSlot = slotIndices.ally end updateSlotDisplay() end @@ -256,9 +254,9 @@ function updateSlotDisplay() } local arcaneVecColor = {0.5, 0.5, 0.5, 0.75} local allyVecColor = {0.5, 0.5, 0.5, 0.75} - if selectedSlot == "arcane" then + if selectedSlot == slotIndices.arcane then arcaneVecColor = {0.597, 0.195, 0.796} - elseif selectedSlot == "ally" then + elseif selectedSlot == slotIndices.ally then allyVecColor = {0.597, 0.195, 0.796} end From 901db1045a352a5c116444c1a622d3ea5f7f1576 Mon Sep 17 00:00:00 2001 From: Jorge Parra Date: Thu, 16 Mar 2023 15:30:18 -0400 Subject: [PATCH 5/5] Forgot to turn off debug messages, fixed now --- src/arkhamdb/DeckImporterMain.ttslua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index d3ca73c0..1bbb3d7e 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -5,7 +5,7 @@ local playAreaApi = require("core/PlayAreaApi") local arkhamDb = require("arkhamdb/ArkhamDb") local zones = require("playermat/Zones") -local DEBUG = true +local DEBUG = false local ALL_CARDS_GUID = "15bb07"