Refactor customizable card upgrade sheets

- Unify UI definition into a single table
- Make input (text) fields associate with the row
- Separate UI and data
- Enhance button click to select up to the clicked column
This commit is contained in:
Buhallin 2023-06-02 02:44:18 -07:00
parent fb8c9c83c5
commit 867471221a
No known key found for this signature in database
GPG Key ID: DB3C362823852294
17 changed files with 957 additions and 164 deletions

View File

@ -22,4 +22,49 @@ posZ = {
existingBoxes = { 1, 1, 1, 1, 2, 4, 5 } existingBoxes = { 1, 1, 1, 1, 2, 4, 5 }
inputBoxes = {} inputBoxes = {}
customizations = {
[1] = {
checkboxes = {
posZ = -0.892,
count = 1,
}
},
[2] = {
checkboxes = {
posZ = -0.665,
count = 1,
}
},
[3] = {
checkboxes = {
posZ = -0.43,
count = 1,
}
},
[4] = {
checkboxes = {
posZ = -0.092,
count = 2,
}
},
[5] = {
checkboxes = {
posZ = 0.142,
count = 2,
},
},
[6] = {
checkboxes = {
posZ = 0.376,
count = 4,
}
},
[7] = {
checkboxes = {
posZ = 0.815,
count = 5,
}
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -21,4 +21,43 @@ posZ = {
existingBoxes = { 1, 2, 2, 3, 3, 4 } existingBoxes = { 1, 2, 2, 3, 3, 4 }
inputBoxes = {} inputBoxes = {}
customizations = {
[1] = {
checkboxes = {
posZ = -0.895,
count = 1,
}
},
[2] = {
checkboxes = {
posZ = -0.455,
count = 2,
}
},
[3] = {
checkboxes = {
posZ = -0.215,
count = 2,
}
},
[4] = {
checkboxes = {
posZ = 0.115,
count = 3,
}
},
[5] = {
checkboxes = {
posZ = 0.453,
count = 3,
},
},
[6] = {
checkboxes = {
posZ = 0.794,
count = 4,
}
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -21,4 +21,42 @@ posZ = {
existingBoxes = { 1, 2, 2, 3, 3, 4 } existingBoxes = { 1, 2, 2, 3, 3, 4 }
inputBoxes = {} inputBoxes = {}
customizations = {
[1] = {
checkboxes = {
posZ = -0.925,
count = 1,
}
},
[2] = {
checkboxes = {
posZ = -0.475,
count = 2,
}
},
[3] = {
checkboxes = {
posZ = -0.25,
count = 2,
}
},
[4] = {
checkboxes = {
posZ = -0.01,
count = 3,
}
},
[5] = {
checkboxes = {
posZ = 0.428,
count = 3,
},
},
[6] = {
checkboxes = {
posZ = 0.772,
count = 4,
}
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -23,4 +23,54 @@ posZ = {
existingBoxes = { 1, 1, 1, 1, 2, 2, 3, 4 } existingBoxes = { 1, 1, 1, 1, 2, 2, 3, 4 }
inputBoxes = {} inputBoxes = {}
customizations = {
[1] = {
checkboxes = {
posZ = -0.905,
count = 1,
}
},
[2] = {
checkboxes = {
posZ = -0.7,
count = 1,
}
},
[3] = {
checkboxes = {
posZ = -0.505,
count = 1,
}
},
[4] = {
checkboxes = {
posZ = -0.3,
count = 1,
}
},
[5] = {
checkboxes = {
posZ = -0.09,
count = 2,
},
},
[6] = {
checkboxes = {
posZ = 0.3,
count = 2,
}
},
[7] = {
checkboxes = {
posZ = 0.592,
count = 3,
},
},
[8] = {
checkboxes = {
posZ = 0.888,
count = 4,
}
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -25,4 +25,58 @@ inputBoxes = { 1, 1 }
inputWidth = { 640, 290 } inputWidth = { 640, 290 }
inputPos = { { 0.275, 0.25, -0.91 }, { 0.6295, 0.25, -0.44 } } inputPos = { { 0.275, 0.25, -0.91 }, { 0.6295, 0.25, -0.44 } }
customizations = {
[1] = {
textField = {
position = { 0.275, 0.25, -0.91 },
width = 640
}
},
[2] = {
checkboxes = {
posZ = -0.725,
count = 1,
}
},
[3] = {
checkboxes = {
posZ = -0.44,
count = 2,
}
},
[4] = {
checkboxes = {
posZ = -0.05,
count = 2,
},
textField = {
position = { 0.6295, 0.25, -0.44 },
width = 290
}
},
[5] = {
checkboxes = {
posZ = 0.25,
count = 2,
}
},
[6] = {
checkboxes = {
posZ = 0.545,
count = 2,
},
},
[7] = {
checkboxes = {
posZ = 0.75,
count = 3,
}
},
[8] = {
checkboxes = {
posZ = 0.95,
count = 3,
}
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -22,5 +22,50 @@ existingBoxes = { 1, 2, 3, 4, 5 }
inputBoxes = { 1, 1, 1 } inputBoxes = { 1, 1, 1 }
inputWidth = { 600, 875, 875 } inputWidth = { 600, 875, 875 }
inputPos = { { 0.3, 0.25, -0.91 }, { 0.005, 0.25, -0.58 }, { 0.005, 0.25, -0.32 } } inputPos = { { 0.3, 0.25, -0.91 }, { 0.005, 0.25, -0.58 }, { 0.005, 0.25, -0.32 } }
customizations = {
[1] = {
textField = {
position = { 0.3, 0.25, -0.91 },
width = 600
}
},
[2] = {
checkboxes = {
posZ = -0.71,
count = 1,
},
textField = {
position = { 0.005, 0.25, -0.58 },
width = 875
}
},
[3] = {
checkboxes = {
posZ = -0.458,
count = 2,
},
textField = {
position = { 0.005, 0.25, -0.32 },
width = 875
}
},
[4] = {
checkboxes = {
posZ = -0.205,
count = 3,
}
},
[5] = {
checkboxes = {
posZ = 0.362,
count = 4,
},
},
[5] = {
checkboxes = {
posZ = 0.82,
count = 5,
},
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -23,4 +23,55 @@ posZ = {
existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 } existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 }
inputBoxes = {} inputBoxes = {}
customizations = {
[1] = {
checkboxes = {
posZ = -0.905,
count = 1,
}
},
[2] = {
checkboxes = {
posZ = -0.705,
count = 1,
}
},
[3] = {
checkboxes = {
posZ = -0.5,
count = 1,
}
},
[4] = {
checkboxes = {
posZ = -0.29,
count = 1,
}
},
[5] = {
checkboxes = {
posZ = -0.09,
count = 1,
},
},
[6] = {
checkboxes = {
posZ = 0.12,
count = 2,
}
},
[7] = {
checkboxes = {
posZ = 0.325,
count = 3,
},
},
[8] = {
checkboxes = {
posZ = 0.62,
count = 5,
}
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -22,4 +22,48 @@ posZ = {
existingBoxes = { 1, 2, 2, 2, 2, 3, 3 } existingBoxes = { 1, 2, 2, 2, 2, 3, 3 }
inputBoxes = {} inputBoxes = {}
customizations = {
[1] = {
checkboxes = {
posZ = -0.892,
count = 1,
}
},
[2] = {
checkboxes = {
posZ = -0.560,
count = 2,
}
},
[3] = {
checkboxes = {
posZ = -0.220,
count = 2,
}
},
[4] = {
checkboxes = {
posZ = -0.092,
count = 2,
}
},
[5] = {
checkboxes = {
posZ = 0.047,
count = 2,
},
},
[6] = {
checkboxes = {
posZ = 0.376,
count = 3,
}
},
[7] = {
checkboxes = {
posZ = 0.820,
count = 3,
},
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -22,4 +22,49 @@ posZ = {
existingBoxes = { 2, 2, 2, 2, 2, 4, 4 } existingBoxes = { 2, 2, 2, 2, 2, 4, 4 }
inputBoxes = {} inputBoxes = {}
customizations = {
[1] = {
checkboxes = {
posZ = -0.9,
count = 2,
}
},
[2] = {
checkboxes = {
posZ = -0.615,
count = 2,
}
},
[3] = {
checkboxes = {
posZ = -0.237,
count = 2,
}
},
[4] = {
checkboxes = {
posZ = 0.232,
count = 2,
}
},
[5] = {
checkboxes = {
posZ = 0.61,
count = 2,
},
},
[6] = {
checkboxes = {
posZ = 0.988,
count = 4,
}
},
[7] = {
checkboxes = {
posZ = 1.185,
count = 4,
},
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -30,4 +30,50 @@ SKILL_ICON_POSITIONS = {
agility = { x = -0.74, z = -0.88 }, agility = { x = -0.74, z = -0.88 },
} }
customizations = {
[1] = { }, -- Empty placeholder for skill selection row, handled by custom skill display
[2] = {
checkboxes = {
posZ = -0.69,
count = 1,
}
},
[3] = {
checkboxes = {
posZ = -0.355,
count = 1,
}
},
[4] = {
checkboxes = {
posZ = 0.0855,
count = 2,
}
},
[5] = {
checkboxes = {
posZ = 0.425,
count = 2,
}
},
[6] = {
checkboxes = {
posZ = 0.555,
count = 3,
},
},
[7] = {
checkboxes = {
posZ = 0.685,
count = 3,
}
},
[8] = {
checkboxes = {
posZ = 1.02,
count = 3,
},
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -22,4 +22,49 @@ posZ = {
existingBoxes = { 1, 1, 2, 2, 2, 3, 4 } existingBoxes = { 1, 1, 2, 2, 2, 3, 4 }
inputBoxes = {} inputBoxes = {}
customizations = {
[1] = {
checkboxes = {
posZ = -0.889,
count = 1,
}
},
[2] = {
checkboxes = {
posZ = -0.655,
count = 1,
}
},
[3] = {
checkboxes = {
posZ = -0.325,
count = 2,
}
},
[4] = {
checkboxes = {
posZ = -0.085,
count = 2,
}
},
[5] = {
checkboxes = {
posZ = 0.252,
count = 2,
},
},
[6] = {
checkboxes = {
posZ = 0.585,
count = 3,
}
},
[7] = {
checkboxes = {
posZ = 0.927,
count = 4,
},
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -22,4 +22,48 @@ posZ = {
existingBoxes = { 1, 1, 2, 2, 2, 3, 4 } existingBoxes = { 1, 1, 2, 2, 2, 3, 4 }
inputBoxes = {} inputBoxes = {}
customizations = {
[1] = {
checkboxes = {
posZ = -0.892,
count = 1,
}
},
[2] = {
checkboxes = {
posZ = -0.560,
count = 1,
}
},
[3] = {
checkboxes = {
posZ = -0.326,
count = 2,
}
},
[4] = {
checkboxes = {
posZ = -0.092,
count = 2,
}
},
[5] = {
checkboxes = {
posZ = 0.142,
count = 2,
},
},
[6] = {
checkboxes = {
posZ = 0.376,
count = 3,
}
},
[7] = {
checkboxes = {
posZ = 0.610,
count = 4,
},
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -23,4 +23,55 @@ posZ = {
existingBoxes = { 1, 1, 1, 1, 2, 3, 3, 3 } existingBoxes = { 1, 1, 1, 1, 2, 3, 3, 3 }
inputBoxes = {} inputBoxes = {}
customizations = {
[1] = {
checkboxes = {
posZ = -0.905,
count = 1,
}
},
[2] = {
checkboxes = {
posZ = -0.6,
count = 1,
}
},
[3] = {
checkboxes = {
posZ = -0.32,
count = 1,
}
},
[4] = {
checkboxes = {
posZ = -0.02,
count = 1,
}
},
[5] = {
checkboxes = {
posZ = 0.28,
count = 2,
},
},
[6] = {
checkboxes = {
posZ = 0.48,
count = 3,
}
},
[7] = {
checkboxes = {
posZ = 0.775,
count = 3,
},
},
[8] = {
checkboxes = {
posZ = 0.975,
count = 3,
},
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -23,4 +23,55 @@ posZ = {
existingBoxes = { 1, 1, 1, 1, 1, 3, 3, 4 } existingBoxes = { 1, 1, 1, 1, 1, 3, 3, 4 }
inputBoxes = {} inputBoxes = {}
customizations = {
[1] = {
checkboxes = {
posZ = -0.92,
count = 1,
}
},
[2] = {
checkboxes = {
posZ = -0.715,
count = 1,
}
},
[3] = {
checkboxes = {
posZ = -0.415,
count = 1,
}
},
[4] = {
checkboxes = {
posZ = -0.018,
count = 1,
}
},
[5] = {
checkboxes = {
posZ = 0.265,
count = 1,
},
},
[6] = {
checkboxes = {
posZ = 0.66,
count = 3,
}
},
[7] = {
checkboxes = {
posZ = 0.86,
count = 3,
},
},
[8] = {
checkboxes = {
posZ = 1.065,
count = 4,
},
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -31,6 +31,59 @@ SLOT_ICON_POSITIONS = {
-- These match with ArkhamDB's way of storing the data in the dropdown menu -- These match with ArkhamDB's way of storing the data in the dropdown menu
SLOT_INDICES = { arcane = "1", ally = "0", none = "" } SLOT_INDICES = { arcane = "1", ally = "0", none = "" }
selectedSlot = SLOT_INDICES.none --selectedSlot = SLOT_INDICES.none
customizations = {
[1] = {
checkboxes = {
posZ = -0.92,
count = 1,
}
},
[2] = {
checkboxes = {
posZ = -0.625,
count = 1,
}
},
[3] = {
checkboxes = {
posZ = -0.33,
count = 1,
}
},
[4] = {
checkboxes = {
posZ = 0.055,
count = 1,
}
},
[5] = {
checkboxes = {
posZ = 0.26,
count = 1,
},
},
[6] = {
checkboxes = {
posZ = 0.56,
count = 2,
}
-- Row 6 includes the selection of Arcane/Ally slot, presented with buttons but stored
-- as a text field
},
[7] = {
checkboxes = {
posZ = 0.765,
count = 3,
},
},
[8] = {
checkboxes = {
posZ = 1.06,
count = 5,
},
},
}
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -8,21 +8,59 @@ inputFontsize = 38
x_1 = -0.935 x_1 = -0.935
x_offset = 0.0705 x_offset = 0.0705
-- z-values (lines on the sheet) customizations = {
posZ = { [1] = {
-0.72, textField = {
-0.52, position = { 0.5, 0.25, -0.905 },
-0.305, width = 425
-0.105, }
0.1, },
0.4, [2] = {
0.695 checkboxes = {
posZ = -0.72,
count = 1,
}
},
[3] = {
checkboxes = {
posZ = -0.52,
count = 1,
}
},
[4] = {
checkboxes = {
posZ = -0.305,
count = 2,
}
},
[5] = {
checkboxes = {
posZ = -0.105,
count = 2,
},
textField = {
position = { 0.125, 0.25, 0 },
width = 775
}
},
[6] = {
checkboxes = {
posZ = 0.1,
count = 2,
}
},
[7] = {
checkboxes = {
posZ = 0.4,
count = 3,
}
},
[8] = {
checkboxes = {
posZ = 0.695,
count = 4,
}
},
} }
-- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 1, 2, 2, 2, 3, 4 }
inputBoxes = { 1, 1 }
inputWidth = { 425, 775 }
inputPos = { { 0.5, 0.25, -0.905 }, { 0.125, 0.25, 0 } }
require("playercards/customizable/UpgradeSheetLibrary") require("playercards/customizable/UpgradeSheetLibrary")

View File

@ -15,148 +15,86 @@ SLOT_INDICES = { arcane = "1", ally = "0", none = "" }
-- override 'marked boxes' for debugging ('all' or 'none') -- override 'marked boxes' for debugging ('all' or 'none')
DEBUG = "" DEBUG = ""
local rowCheckboxFirstIndex = { }
local rowInputIndex = { }
local selectedUpgrades = { }
-- save state when going into bags / decks -- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end function onDestroy() self.script_state = onSave() end
function onSave() function onSave()
-- Living Ink custom save function return JSON.encode({
if selfId == "09079-c" then selections = selectedUpgrades
inputValues = {} })
for skill, isSelected in pairs(selectedSkills) do
if isSelected then
table.insert(inputValues, skill)
end
end
end
return JSON.encode({ markedBoxes, inputValues })
end end
-- Startup procedure -- Startup procedure
function onLoad(savedData) function onLoad(savedData)
if savedData ~= "" and DEBUG == "" then if savedData ~= "" and DEBUG == "" then
local loadedData = JSON.decode(savedData) local loadedData = JSON.decode(savedData)
markedBoxes = loadedData[1] if loadedData.selections ~= nil then
inputValues = loadedData[2] selectedUpgrades = loadedData.selections
else end
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end end
selfId = getSelfId() selfId = getSelfId()
makeData() maybeLoadLivingInkSkills()
maybeLoadSkills() createUi()
createButtonsAndBoxes() maybeUpdateLivingInkSkillDisplay()
maybeUpdateSkillDisplay() maybeUpdateServitorSlotDisplay()
maybeUpdateSlotDisplay()
self.addContextMenuItem("Reset Inputs", self.addContextMenuItem("Clear Selections", function() resetSelections() end)
function() updateState({ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { "", "", "", "", "" }) end)
self.addContextMenuItem("Reload savestate", function() updateState() end)
self.addContextMenuItem("Scale: 1x", function() self.setScale({ 1, 1, 1 }) end) self.addContextMenuItem("Scale: 1x", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: 2x", function() self.setScale({ 2, 1, 2 }) end) self.addContextMenuItem("Scale: 2x", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: 3x", function() self.setScale({ 3, 1, 3 }) end) self.addContextMenuItem("Scale: 3x", function() self.setScale({ 3, 1, 3 }) end)
end end
-- grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor) -- Grabs the ID from the metadata for special functions (Living Ink, Summoned Servitor)
function getSelfId() function getSelfId()
local metadata = JSON.decode(self.getGMNotes()) local metadata = JSON.decode(self.getGMNotes())
return metadata.id return metadata.id
end end
-- this can set the checkbox and inputfield data or reset it function resetSelections()
function updateState(markedBoxesNew, inputValuesNew) selectedUpgrades = { }
if markedBoxesNew then markedBoxes = markedBoxesNew end updateDisplay()
if inputValuesNew then inputValues = inputValuesNew end
makeData()
maybeLoadSkills()
createButtonsAndBoxes()
maybeUpdateSkillDisplay()
maybeUpdateSlotDisplay()
end end
-- creates the table "Data" based on the saved state, which is the backbone for UI creation function createUi()
function makeData() if customizations == nil then
Data = { checkbox = {}, textbox = {} } return
end
-- repeat this for each entry (= line) in existingBoxes for i = 1, #customizations do
local totalCount = 0 if customizations[i].checkboxes ~= nil then
for i = 1, #existingBoxes do createRowCheckboxes(i)
-- repeat this for each checkbox per line end
for j = 1, existingBoxes[i] do if customizations[i].textField ~= nil then
totalCount = totalCount + 1 createRowTextField(i)
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (DEBUG == "all") or (markedBoxes[i] >= j and DEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = Y_VISIBLE
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = Y_INVISIBLE
Data.checkbox[totalCount].state = false
end end
end end
maybeMakeLivingInkSkillSelectionButtons()
maybeMakeServitorSlotSelectionButtons()
updateDisplay()
end end
-- repeat this for each entry (= line) in inputBoxes function createRowCheckboxes(rowIndex)
local totalCount = 0 local checkboxes = customizations[rowIndex].checkboxes
for i = 1, #inputBoxes do rowCheckboxFirstIndex[rowIndex] = 0
-- repeat this for each textbox per line local previousButtons = self.getButtons()
for j = 1, inputBoxes[i] do if previousButtons ~= nil then
totalCount = totalCount + 1 rowCheckboxFirstIndex[rowIndex] = #previousButtons
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end end
end for col = 1, checkboxes.count do
end local funcName = "checkboxRow" .. rowIndex .. "Col" .. col
local func = function() clickCheckbox(rowIndex, col) end
-- toggles the state for the clicked checkbox
function clickCheckbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state then
Data.checkbox[tableIndex].pos.y = Y_INVISIBLE
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = Y_VISIBLE
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function clickTextbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
-- handles all button, input and skill/slot selection creation
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, checkbox in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() clickCheckbox(i) end
self.setVar(funcName, func) self.setVar(funcName, func)
local checkboxPos = getCheckboxPosition(rowIndex, col)
self.createButton({ self.createButton({
click_function = funcName, click_function = funcName,
function_owner = self, function_owner = self,
position = checkbox.pos, position = checkboxPos,
height = boxSize * 10, height = boxSize * 10,
width = boxSize * 10, width = boxSize * 10,
font_size = 1000, font_size = 1000,
@ -165,10 +103,26 @@ function createButtonsAndBoxes()
font_color = { 0, 0, 0 } font_color = { 0, 0, 0 }
}) })
end end
end
for i, inputfield in ipairs(Data.textbox) do function getCheckboxPosition(row, col)
local funcName = "textbox" .. i return {
local func = function(_, _, val, sel) clickTextbox(i, val, sel) end x = x_1 + col * x_offset,
y = Y_VISIBLE,
z = customizations[row].checkboxes.posZ
}
end
function createRowTextField(rowIndex)
local textField = customizations[rowIndex].textField
rowInputIndex[rowIndex] = 0
local previousInputs = self.getInputs()
if previousInputs ~= nil then
rowInputIndex[rowIndex] = #previousInputs
end
local funcName = "textbox" .. rowIndex
local func = function(_, _, val, sel) clickTextbox(rowIndex, val, sel) end
self.setVar(funcName, func) self.setVar(funcName, func)
self.createInput({ self.createInput({
@ -176,18 +130,88 @@ function createButtonsAndBoxes()
function_owner = self, function_owner = self,
label = "Click to type", label = "Click to type",
alignment = 2, alignment = 2,
position = inputfield.pos, position = textField.position,
scale = { 0.1, 0.1, 0.1 }, scale = { 0.1, 0.1, 0.1 },
width = inputfield.width * 10, width = textField.width * 10,
height = inputFontsize * 10 + 75, height = inputFontsize * 10 + 75,
font_size = inputFontsize * 10.5, font_size = inputFontsize * 10.5,
color = "White", color = "White",
value = " " .. inputfield.value -- empty space to create a small indent value = ""
}) })
end end
maybeMakeSkillSelectionButtons() function updateDisplay()
maybeMakeSlotSelectionButtons() for i = 1, #customizations do
updateRowDisplay(i)
end
maybeUpdateLivingInkSkillDisplay()
maybeUpdateServitorSlotDisplay()
end
function updateRowDisplay(rowIndex)
if customizations[rowIndex].checkboxes ~= nil then
updateCheckboxes(rowIndex)
end
if customizations[rowIndex].textField ~= nil then
updateTextField(rowIndex)
end
end
function updateCheckboxes(rowIndex)
local checkboxCount = customizations[rowIndex].checkboxes.count
local selected = 0
if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].xp ~= nil then
selected = selectedUpgrades[rowIndex].xp
end
local checkboxIndex = rowCheckboxFirstIndex[rowIndex]
for col = 1, checkboxCount do
local pos = getCheckboxPosition(rowIndex, col)
if col <= selected then
pos.y = Y_VISIBLE
else
pos.y = Y_INVISIBLE
end
self.editButton({
index = checkboxIndex,
position = pos
})
checkboxIndex = checkboxIndex + 1
end
end
function updateTextField(rowIndex)
local inputIndex = rowInputIndex[rowIndex]
if selectedUpgrades[rowIndex] ~= nil and selectedUpgrades[rowIndex].text ~= nil then
self.editInput({
index = inputIndex,
value = " " .. selectedUpgrades[rowIndex].text
})
end
end
function clickCheckbox(row, col, buttonIndex)
if selectedUpgrades[row] == nil then
selectedUpgrades[row] = { }
selectedUpgrades[row].xp = 0
end
if selectedUpgrades[row].xp == col then
selectedUpgrades[row].xp = col - 1
else
selectedUpgrades[row].xp = col
end
updateCheckboxes(row)
end
-- updates saved value for given text box
function clickTextbox(rowIndex, value, selected)
if selected == false then
if selectedUpgrades[rowIndex] == nil then
selectedUpgrades[rowIndex] = { }
end
selectedUpgrades[rowIndex].text = value:gsub("^%s*(.-)%s*$", "%1")
-- Editing isn't actually done yet, and will block the update. Wait a frame so it's finished
Wait.frames(function() updateRowDisplay(rowIndex) end, 1)
end
end end
--------------------------------------------------------- ---------------------------------------------------------
@ -195,7 +219,7 @@ end
--------------------------------------------------------- ---------------------------------------------------------
-- loads the skill selection from the "inputValues" table -- loads the skill selection from the "inputValues" table
function maybeLoadSkills() function maybeLoadLivingInkSkills()
if selfId ~= "09079-c" then return end if selfId ~= "09079-c" then return end
selectedSkills = { selectedSkills = {
willpower = false, willpower = false,
@ -203,8 +227,11 @@ function maybeLoadSkills()
combat = false, combat = false,
agility = false agility = false
} }
for _, skill in ipairs(inputValues) do log("Parsing skills")
if skill ~= "" then if selectedUpgrades[1] ~= nil and selectedUpgrades[1].text ~= nil then
log("In loop with " .. selectedUpgrades[1].text)
for skill in string.gmatch(selectedUpgrades[1].text, "([^,]+)") do
log("Skill -" .. skill .. "- set true")
selectedSkills[skill] = true selectedSkills[skill] = true
end end
end end
@ -213,11 +240,12 @@ end
-- toggles the clicked skill -- toggles the clicked skill
function clickSkill(skillname) function clickSkill(skillname)
selectedSkills[skillname] = not selectedSkills[skillname] selectedSkills[skillname] = not selectedSkills[skillname]
maybeUpdateSkillDisplay() maybeUpdateLivingInkSkillDisplay()
updateSelectedLivingInkSkillText()
end end
-- Creates the invisible buttons overlaying the skill icons -- Creates the invisible buttons overlaying the skill icons
function maybeMakeSkillSelectionButtons() function maybeMakeLivingInkSkillSelectionButtons()
if selfId ~= "09079-c" then return end if selfId ~= "09079-c" then return end
local buttonData = { local buttonData = {
@ -239,9 +267,29 @@ function maybeMakeSkillSelectionButtons()
end end
end end
function updateSelectedLivingInkSkillText()
local skillString = ""
if selectedSkills.willpower then
skillString = skillString .. "willpower" .. ","
end
if selectedSkills.intellect then
skillString = skillString .. "intellect" .. ","
end
if selectedSkills.combat then
skillString = skillString .. "combat" .. ","
end
if selectedSkills.agility then
skillString = skillString .. "agility" .. ","
end
if selectedUpgrades[1] == nil then
selectedUpgrades[1] = { }
end
selectedUpgrades[1].text = skillString
end
-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of -- Refresh the vector circles indicating a skill is selected. Since we can only have one table of
-- vectors set, have to refresh all 4 at once -- vectors set, have to refresh all 4 at once
function maybeUpdateSkillDisplay() function maybeUpdateLivingInkSkillDisplay()
if selfId ~= "09079-c" then return end if selfId ~= "09079-c" then return end
local circles = {} local circles = {}
for skill, isSelected in pairs(selectedSkills) do for skill, isSelected in pairs(selectedSkills) do
@ -280,7 +328,7 @@ end
--------------------------------------------------------- ---------------------------------------------------------
-- Creates the invisible buttons overlaying the slot words -- Creates the invisible buttons overlaying the slot words
function maybeMakeSlotSelectionButtons() function maybeMakeServitorSlotSelectionButtons()
if selfId ~= "09080-c" then return end if selfId ~= "09080-c" then return end
local buttonData = { local buttonData = {
@ -300,26 +348,32 @@ end
-- toggles the clicked slot -- toggles the clicked slot
function clickArcane() function clickArcane()
if inputValues[1] == SLOT_INDICES.arcane then if selectedUpgrades[6] == nil then
inputValues[1] = SLOT_INDICES.none selectedUpgrades[6] = { }
else
inputValues[1] = SLOT_INDICES.arcane
end end
maybeUpdateSlotDisplay() if selectedUpgrades[6].text == SLOT_INDICES.arcane then
selectedUpgrades[6].text = SLOT_INDICES.none
else
selectedUpgrades[6].text = SLOT_INDICES.arcane
end
maybeUpdateServitorSlotDisplay()
end end
-- toggles the clicked slot -- toggles the clicked slot
function clickAlly() function clickAlly()
if inputValues[1] == SLOT_INDICES.ally then if selectedUpgrades[6] == nil then
inputValues[1] = SLOT_INDICES.none selectedUpgrades[6] = { }
else
inputValues[1] = SLOT_INDICES.ally
end end
maybeUpdateSlotDisplay() if selectedUpgrades[6].text == SLOT_INDICES.ally then
selectedUpgrades[6].text = SLOT_INDICES.none
else
selectedUpgrades[6].text = SLOT_INDICES.ally
end
maybeUpdateServitorSlotDisplay()
end end
-- Refresh the vector circles indicating a slot is selected. -- Refresh the vector circles indicating a slot is selected.
function maybeUpdateSlotDisplay() function maybeUpdateServitorSlotDisplay()
if selfId ~= "09080-c" then return end if selfId ~= "09080-c" then return end
local center = SLOT_ICON_POSITIONS["arcane"] local center = SLOT_ICON_POSITIONS["arcane"]
@ -343,9 +397,9 @@ function maybeUpdateSlotDisplay()
local arcaneVecColor = VECTOR_COLOR.unselected local arcaneVecColor = VECTOR_COLOR.unselected
local allyVecColor = VECTOR_COLOR.unselected local allyVecColor = VECTOR_COLOR.unselected
if inputValues[1] == SLOT_INDICES.arcane then if selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SLOT_INDICES.arcane then
arcaneVecColor = VECTOR_COLOR.mystic arcaneVecColor = VECTOR_COLOR.mystic
elseif inputValues[1] == SLOT_INDICES.ally then elseif selectedUpgrades[6] ~= nil and selectedUpgrades[6].text == SLOT_INDICES.ally then
allyVecColor = VECTOR_COLOR.mystic allyVecColor = VECTOR_COLOR.mystic
end end