From 97b3dd4ce5d876aa5af0344ee409f8e828bbba76 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 24 Nov 2022 16:44:04 +0100 Subject: [PATCH 1/6] use require, optimize --- ...icalDistillationUpgradeSheet.156166.ttslua | 182 ++--------------- ...tomModificationsUpgradeSheet.4104bf.ttslua | 179 +---------------- ...DamningTestimonyUpgradeSheet.dc4a62.ttslua | 179 +---------------- ...iricalHypothesisUpgradeSheet.0c46a7.ttslua | 183 ++--------------- ...iendsinLowPlacesUpgradeSheet.9fb3b9.ttslua | 185 ++---------------- .../GrizzledUpgradeSheet.ef8f08.ttslua | 181 ++--------------- .../HonedInstinctUpgradeSheet.ba0e34.ttslua | 183 ++--------------- .../HuntersArmorUpgradeSheet.d2d01b.ttslua | 181 ++--------------- ...ysicalShotcasterUpgradeSheet.a4eec2.ttslua | 181 ++--------------- .../LivingLinkUpgradeSheet.19a05b.ttslua | 180 ----------------- .../MakeshiftTrapUpgradeSheet.64dfce.ttslua | 181 ++--------------- .../PocketMultiToolUpgradeSheet.d706e7.ttslua | 181 ++--------------- .../PowerWordUpgradeSheet.0d9481.ttslua | 183 ++--------------- .../RunicAxeUpgradeSheet.be427d.ttslua | 183 ++--------------- ...SummonedServitorUpgradeSheet.5397a6.ttslua | 183 ++--------------- .../TheRavenQuillUpgradeSheet.23b96a.ttslua | 185 ++---------------- .../customizable/UpgradeSheet.ttslua | 125 ++++++++++++ 17 files changed, 297 insertions(+), 2738 deletions(-) delete mode 100644 objects/AllPlayerCards.15bb07/LivingLinkUpgradeSheet.19a05b.ttslua create mode 100644 src/playercards/customizable/UpgradeSheet.ttslua diff --git a/objects/AllPlayerCards.15bb07/AlchemicalDistillationUpgradeSheet.156166.ttslua b/objects/AllPlayerCards.15bb07/AlchemicalDistillationUpgradeSheet.156166.ttslua index 95ecd11f..99be303a 100644 --- a/objects/AllPlayerCards.15bb07/AlchemicalDistillationUpgradeSheet.156166.ttslua +++ b/objects/AllPlayerCards.15bb07/AlchemicalDistillationUpgradeSheet.156166.ttslua @@ -1,181 +1,21 @@ -- Customizable Cards: Alchemical Distillation --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - - --- Color information for buttons -boxSize = 40 - --- static values -x_1 = -0.933 -x_offset = 0.075 -y_visible = 0.25 -y_invisible = -0.5 +boxSize = 40 +x_1 = -0.933 +x_offset = 0.075 -- z-values (lines on the sheet) posZ = { - -0.892, - -0.665, - -0.430, - -0.092, - 0.142, - 0.376, - 0.815 + -0.892, + -0.665, + -0.430, + -0.092, + 0.142, + 0.376, + 0.815 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 1, 1, 2, 4, 5 } - inputBoxes = {} --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/CustomModificationsUpgradeSheet.4104bf.ttslua b/objects/AllPlayerCards.15bb07/CustomModificationsUpgradeSheet.4104bf.ttslua index 1e0e5350..8417fdf5 100644 --- a/objects/AllPlayerCards.15bb07/CustomModificationsUpgradeSheet.4104bf.ttslua +++ b/objects/AllPlayerCards.15bb07/CustomModificationsUpgradeSheet.4104bf.ttslua @@ -1,179 +1,20 @@ -- Customizable Cards: Custom Modifications --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons -boxSize = 38 - --- static values -x_1 = -0.935 -x_offset = 0.0735 -y_visible = 0.25 -y_invisible = -0.5 +boxSize = 38 +x_1 = -0.935 +x_offset = 0.0735 -- z-values (lines on the sheet) posZ = { - -0.895, - -0.455, - -0.215, - 0.115, - 0.453, - 0.794 + -0.895, + -0.455, + -0.215, + 0.115, + 0.453, + 0.794 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 2, 2, 3, 3, 4 } - inputBoxes = {} --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/DamningTestimonyUpgradeSheet.dc4a62.ttslua b/objects/AllPlayerCards.15bb07/DamningTestimonyUpgradeSheet.dc4a62.ttslua index 77255bfb..4a43861a 100644 --- a/objects/AllPlayerCards.15bb07/DamningTestimonyUpgradeSheet.dc4a62.ttslua +++ b/objects/AllPlayerCards.15bb07/DamningTestimonyUpgradeSheet.dc4a62.ttslua @@ -1,179 +1,20 @@ -- Customizable Cards: Damning Testimony --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons -boxSize = 40 - --- static values -x_1 = -0.935 -x_offset = 0.075 -y_visible = 0.25 -y_invisible = -0.5 +boxSize = 40 +x_1 = -0.935 +x_offset = 0.075 -- z-values (lines on the sheet) posZ = { - -0.925, - -0.475, - -0.25, - -0.01, - 0.428, - 0.772 + -0.925, + -0.475, + -0.25, + -0.01, + 0.428, + 0.772 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 2, 2, 3, 3, 4 } - inputBoxes = {} --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/EmpiricalHypothesisUpgradeSheet.0c46a7.ttslua b/objects/AllPlayerCards.15bb07/EmpiricalHypothesisUpgradeSheet.0c46a7.ttslua index b3123175..a2497ba8 100644 --- a/objects/AllPlayerCards.15bb07/EmpiricalHypothesisUpgradeSheet.0c46a7.ttslua +++ b/objects/AllPlayerCards.15bb07/EmpiricalHypothesisUpgradeSheet.0c46a7.ttslua @@ -1,181 +1,22 @@ -- Customizable Cards: Empirical Hypothesis --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons -boxSize = 37 - --- static values -x_1 = -0.935 -x_offset = 0.069 -y_visible = 0.25 -y_invisible = -0.5 +boxSize = 37 +x_1 = -0.935 +x_offset = 0.069 -- z-values (lines on the sheet) posZ = { - -0.905, - -0.7, - -0.505, - -0.3, - -0.09, - 0.3, - 0.592, - 0.888 + -0.905, + -0.7, + -0.505, + -0.3, + -0.09, + 0.3, + 0.592, + 0.888 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 1, 1, 2, 2, 3, 4 } - inputBoxes = {} --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/FriendsinLowPlacesUpgradeSheet.9fb3b9.ttslua b/objects/AllPlayerCards.15bb07/FriendsinLowPlacesUpgradeSheet.9fb3b9.ttslua index 8f1cae92..e6e6a1ad 100644 --- a/objects/AllPlayerCards.15bb07/FriendsinLowPlacesUpgradeSheet.9fb3b9.ttslua +++ b/objects/AllPlayerCards.15bb07/FriendsinLowPlacesUpgradeSheet.9fb3b9.ttslua @@ -1,183 +1,24 @@ -- Customizable Cards: Friends in Low Places --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons and input boxes boxSize = 36 inputFontsize = 50 - --- static values -x_1 = -0.935 -x_offset = 0.0685 -y_visible = 0.25 -y_invisible = -0.5 +x_1 = -0.935 +x_offset = 0.0685 -- z-values (lines on the sheet) posZ = { - -0.725, - -0.44, - -0.05, - 0.25, - 0.545, - 0.75, - 0.95 + -0.725, + -0.44, + -0.05, + 0.25, + 0.545, + 0.75, + 0.95 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 2, 2, 2, 2, 3, 3 } +inputBoxes = { 1, 1 } +inputWidth = { 640, 290 } +inputPos = { { 0.275, 0.25, -0.91 }, { 0.6295, 0.25, -0.44 } } -inputBoxes = { 1, 1 } -inputWidth = { 640, 290 } -inputPos = { { 0.275, 0.25, -0.91 }, { 0.6295, 0.25, -0.44 } } - --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/GrizzledUpgradeSheet.ef8f08.ttslua b/objects/AllPlayerCards.15bb07/GrizzledUpgradeSheet.ef8f08.ttslua index 39a5a906..23ed6192 100644 --- a/objects/AllPlayerCards.15bb07/GrizzledUpgradeSheet.ef8f08.ttslua +++ b/objects/AllPlayerCards.15bb07/GrizzledUpgradeSheet.ef8f08.ttslua @@ -1,181 +1,22 @@ -- Customizable Cards: Grizzled --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons and input boxes boxSize = 40 inputFontsize = 50 - --- static values -x_1 = -0.933 -x_offset = 0.075 -y_visible = 0.25 -y_invisible = -0.5 +x_1 = -0.933 +x_offset = 0.075 -- z-values (lines on the sheet) posZ = { - -0.71, - -0.458, - -0.205, - 0.362, - 0.82 + -0.71, + -0.458, + -0.205, + 0.362, + 0.82 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 2, 3, 4, 5 } +inputBoxes = { 1, 1, 1 } +inputWidth = { 600, 875, 875 } +inputPos = { { 0.3, 0.25, -0.91 }, { 0.005, 0.25, -0.58 }, { 0.005, 0.25, -0.32 } } -inputBoxes = { 1, 1, 1 } -inputWidth = { 600, 875, 875 } -inputPos = { { 0.3, 0.25, -0.91 }, { 0.005, 0.25, -0.58 }, { 0.005, 0.25, -0.32 } } - --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/HonedInstinctUpgradeSheet.ba0e34.ttslua b/objects/AllPlayerCards.15bb07/HonedInstinctUpgradeSheet.ba0e34.ttslua index bde1a713..7cf218de 100644 --- a/objects/AllPlayerCards.15bb07/HonedInstinctUpgradeSheet.ba0e34.ttslua +++ b/objects/AllPlayerCards.15bb07/HonedInstinctUpgradeSheet.ba0e34.ttslua @@ -1,181 +1,22 @@ -- Customizable Cards: Honed Instinct --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons -boxSize = 38 - --- static values -x_1 = -0.935 -x_offset = 0.069 -y_visible = 0.25 -y_invisible = -0.5 +boxSize = 38 +x_1 = -0.935 +x_offset = 0.069 -- z-values (lines on the sheet) posZ = { - -0.905, - -0.705, - -0.5, - -0.29, - -0.09, - 0.12, - 0.325, - 0.62 + -0.905, + -0.705, + -0.5, + -0.29, + -0.09, + 0.12, + 0.325, + 0.62 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 } - inputBoxes = {} --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/HuntersArmorUpgradeSheet.d2d01b.ttslua b/objects/AllPlayerCards.15bb07/HuntersArmorUpgradeSheet.d2d01b.ttslua index b2ed3fda..6b64b6f0 100644 --- a/objects/AllPlayerCards.15bb07/HuntersArmorUpgradeSheet.d2d01b.ttslua +++ b/objects/AllPlayerCards.15bb07/HuntersArmorUpgradeSheet.d2d01b.ttslua @@ -1,180 +1,21 @@ -- Customizable Cards: Hunter's Armor --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons -boxSize = 40 - --- static values -x_1 = -0.933 -x_offset = 0.075 -y_visible = 0.25 -y_invisible = -0.5 +boxSize = 40 +x_1 = -0.933 +x_offset = 0.075 -- z-values (lines on the sheet) posZ = { - -0.892, - -0.560, - -0.220, - -0.092, - 0.047, - 0.376, - 0.820 + -0.892, + -0.560, + -0.220, + -0.092, + 0.047, + 0.376, + 0.820 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 2, 2, 2, 2, 3, 3 } - inputBoxes = {} --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/HyperphysicalShotcasterUpgradeSheet.a4eec2.ttslua b/objects/AllPlayerCards.15bb07/HyperphysicalShotcasterUpgradeSheet.a4eec2.ttslua index fb094979..8ce32945 100644 --- a/objects/AllPlayerCards.15bb07/HyperphysicalShotcasterUpgradeSheet.a4eec2.ttslua +++ b/objects/AllPlayerCards.15bb07/HyperphysicalShotcasterUpgradeSheet.a4eec2.ttslua @@ -1,180 +1,21 @@ -- Customizable Cards: Hyperphysical Shotcaster --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons -boxSize = 38 - --- static values -x_1 = -0.935 -x_offset = 0.069 -y_visible = 0.25 -y_invisible = -0.5 +boxSize = 38 +x_1 = -0.935 +x_offset = 0.069 -- z-values (lines on the sheet) posZ = { - -0.9, - -0.615, - -0.237, - 0.232, - 0.61, - 0.988, - 1.185 + -0.9, + -0.615, + -0.237, + 0.232, + 0.61, + 0.988, + 1.185 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 2, 2, 2, 2, 2, 4, 4 } - inputBoxes = {} --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/LivingLinkUpgradeSheet.19a05b.ttslua b/objects/AllPlayerCards.15bb07/LivingLinkUpgradeSheet.19a05b.ttslua deleted file mode 100644 index 7599137e..00000000 --- a/objects/AllPlayerCards.15bb07/LivingLinkUpgradeSheet.19a05b.ttslua +++ /dev/null @@ -1,180 +0,0 @@ --- Customizable Cards: Living Ink --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons -boxSize = 40 - --- static values -x_1 = -0.935 -x_offset = 0.075 -y_visible = 0.25 -y_invisible = -0.5 - --- z-values (lines on the sheet) -posZ = { - -0.69, - -0.355, - 0.0855, - 0.425, - 0.555, - 0.685, - 1.02 -} - --- box setup (amount of boxes per line and amount of marked boxes in that line) -existingBoxes = { 1, 1, 2, 2, 3, 3, 3 } - -inputBoxes = {} - --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end diff --git a/objects/AllPlayerCards.15bb07/MakeshiftTrapUpgradeSheet.64dfce.ttslua b/objects/AllPlayerCards.15bb07/MakeshiftTrapUpgradeSheet.64dfce.ttslua index f43f200c..c785f0bf 100644 --- a/objects/AllPlayerCards.15bb07/MakeshiftTrapUpgradeSheet.64dfce.ttslua +++ b/objects/AllPlayerCards.15bb07/MakeshiftTrapUpgradeSheet.64dfce.ttslua @@ -1,180 +1,21 @@ -- Customizable Cards: Makeshift Trap --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons -boxSize = 39 - --- static values -x_1 = -0.935 -x_offset = 0.0735 -y_visible = 0.25 -y_invisible = -0.5 +boxSize = 39 +x_1 = -0.935 +x_offset = 0.0735 -- z-values (lines on the sheet) posZ = { - -0.889, - -0.655, - -0.325, - -0.085, - 0.252, - 0.585, - 0.927 + -0.889, + -0.655, + -0.325, + -0.085, + 0.252, + 0.585, + 0.927 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 2, 2, 2, 3, 4 } - inputBoxes = {} --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/PocketMultiToolUpgradeSheet.d706e7.ttslua b/objects/AllPlayerCards.15bb07/PocketMultiToolUpgradeSheet.d706e7.ttslua index 24c8e8ca..c65728b0 100644 --- a/objects/AllPlayerCards.15bb07/PocketMultiToolUpgradeSheet.d706e7.ttslua +++ b/objects/AllPlayerCards.15bb07/PocketMultiToolUpgradeSheet.d706e7.ttslua @@ -1,180 +1,21 @@ -- Customizable Cards: Pocket Multi Tool --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons -boxSize = 40 - --- static values -x_1 = -0.933 -x_offset = 0.075 -y_visible = 0.25 -y_invisible = -0.5 +boxSize = 40 +x_1 = -0.933 +x_offset = 0.075 -- z-values (lines on the sheet) posZ = { - -0.892, - -0.560, - -0.326, - -0.092, - 0.142, - 0.376, - 0.610 + -0.892, + -0.560, + -0.326, + -0.092, + 0.142, + 0.376, + 0.610 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 2, 2, 2, 3, 4 } - inputBoxes = {} --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/PowerWordUpgradeSheet.0d9481.ttslua b/objects/AllPlayerCards.15bb07/PowerWordUpgradeSheet.0d9481.ttslua index 9d19459b..d6a3870d 100644 --- a/objects/AllPlayerCards.15bb07/PowerWordUpgradeSheet.0d9481.ttslua +++ b/objects/AllPlayerCards.15bb07/PowerWordUpgradeSheet.0d9481.ttslua @@ -1,181 +1,22 @@ -- Customizable Cards: Power Word --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons -boxSize = 38 - --- static values -x_1 = -0.933 -x_offset = 0.069 -y_visible = 0.25 -y_invisible = -0.5 +boxSize = 38 +x_1 = -0.933 +x_offset = 0.069 -- z-values (lines on the sheet) posZ = { - -0.905, - -0.6, - -0.32, - -0.02, - 0.28, - 0.48, - 0.775, - 0.975 + -0.905, + -0.6, + -0.32, + -0.02, + 0.28, + 0.48, + 0.775, + 0.975 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 1, 1, 2, 3, 3, 3 } - inputBoxes = {} --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/RunicAxeUpgradeSheet.be427d.ttslua b/objects/AllPlayerCards.15bb07/RunicAxeUpgradeSheet.be427d.ttslua index 3a365ef0..29bcc4b5 100644 --- a/objects/AllPlayerCards.15bb07/RunicAxeUpgradeSheet.be427d.ttslua +++ b/objects/AllPlayerCards.15bb07/RunicAxeUpgradeSheet.be427d.ttslua @@ -1,181 +1,22 @@ -- Customizable Cards: Runic Axe --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons -boxSize = 38 - --- static values -x_1 = -0.935 -x_offset = 0.0705 -y_visible = 0.25 -y_invisible = -0.5 +boxSize = 38 +x_1 = -0.935 +x_offset = 0.0705 -- z-values (lines on the sheet) posZ = { - -0.92, - -0.715, - -0.415, - -0.018, - 0.265, - 0.66, - 0.86, - 1.065 + -0.92, + -0.715, + -0.415, + -0.018, + 0.265, + 0.66, + 0.86, + 1.065 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 1, 1, 1, 3, 3, 4 } - inputBoxes = {} --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.ttslua b/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.ttslua index 75ab4600..d78b8af6 100644 --- a/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.ttslua +++ b/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.ttslua @@ -1,181 +1,22 @@ -- Customizable Cards: Summoned Servitor --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons -boxSize = 35 - --- static values -x_1 = -0.935 -x_offset = 0.068 -y_visible = 0.25 -y_invisible = -0.5 +boxSize = 35 +x_1 = -0.935 +x_offset = 0.068 -- z-values (lines on the sheet) posZ = { - -0.92, - -0.625, - -0.33, - 0.055, - 0.26, - 0.56, - 0.765, - 1.06 + -0.92, + -0.625, + -0.33, + 0.055, + 0.26, + 0.56, + 0.765, + 1.06 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 } - inputBoxes = {} --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/objects/AllPlayerCards.15bb07/TheRavenQuillUpgradeSheet.23b96a.ttslua b/objects/AllPlayerCards.15bb07/TheRavenQuillUpgradeSheet.23b96a.ttslua index e213bf7c..aa21945e 100644 --- a/objects/AllPlayerCards.15bb07/TheRavenQuillUpgradeSheet.23b96a.ttslua +++ b/objects/AllPlayerCards.15bb07/TheRavenQuillUpgradeSheet.23b96a.ttslua @@ -1,183 +1,24 @@ -- Customizable Cards: The Raven Quill --- by Chr1Z -information = { - version = "1.7", - last_updated = "12.10.2022" -} - --- Color information for buttons and input boxes boxSize = 37 inputFontsize = 38 - --- static values -x_1 = -0.935 -x_offset = 0.0705 -y_visible = 0.25 -y_invisible = -0.5 +x_1 = -0.935 +x_offset = 0.0705 -- z-values (lines on the sheet) posZ = { - -0.72, - -0.52, - -0.305, - -0.105, - 0.1, - 0.4, - 0.695 + -0.72, + -0.52, + -0.305, + -0.105, + 0.1, + 0.4, + 0.695 } -- 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 } } -inputBoxes = { 1, 1 } -inputWidth = { 425, 775 } -inputPos = { { 0.5, 0.25, -0.905 }, { 0.125, 0.25, 0 } } - --- 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 - --- 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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - -function updateState(markedBoxesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data -function makeData() - Data = {} - Data.checkbox = {} - Data.textbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - totalCount = totalCount + 1 - 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each textbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.textbox[totalCount] = {} - Data.textbox[totalCount].pos = inputPos[totalCount] - Data.textbox[totalCount].width = inputWidth[totalCount] - Data.textbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function click_checkbox(tableIndex) - local row = Data.checkbox[tableIndex].row - - if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) - if selected == false then - inputValues[i] = value - end -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - local func = function() click_checkbox(i) end - self.setVar(funcName, func) - - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - scale = { 1, 1, 1 }, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - for i, box_data in ipairs(Data.textbox) do - local funcName = "textbox" .. i - local func = function(_, _, val, sel) click_textbox(i, val, sel) end - self.setVar(funcName, func) - - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - scale = buttonScale, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - font_color = buttonFontColor, - value = box_data.value - }) - end -end +require("playercards/customizable/Upgradesheet") diff --git a/src/playercards/customizable/UpgradeSheet.ttslua b/src/playercards/customizable/UpgradeSheet.ttslua new file mode 100644 index 00000000..e5809755 --- /dev/null +++ b/src/playercards/customizable/UpgradeSheet.ttslua @@ -0,0 +1,125 @@ +-- override 'marked boxes' for debugging ('all' or 'none') +local markDEBUG = "" + +-- save state when going into bags / decks +function onDestroy() self.script_state = onSave() end + +function onSave() return JSON.encode({ markedBoxes, inputValues }) end + +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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +-- can be called to set the state to 'markedBoxesNew' / 'inputValuesNew' +function updateState(markedBoxesNew, inputValuesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + if inputValuesNew then inputValues = inputValuesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data (mainly positions of boxes) +function makeData() + Data = {} + Data.checkbox = {} + Data.inputbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + local state = (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") + totalCount = totalCount + 1 + Data.checkbox[totalCount] = {} + Data.checkbox[totalCount].state = state + Data.checkbox[totalCount].pos = { x = x_1 + j * x_offset, y = state and 0.25 or -0.5, z = posZ[i] } + Data.checkbox[totalCount].row = i + end + end + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each inputbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.inputbox[totalCount] = {} + Data.inputbox[totalCount].pos = inputPos[totalCount] + Data.inputbox[totalCount].width = inputWidth[totalCount] + Data.inputbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function clickCheckbox(tableIndex) + local row = Data.checkbox[tableIndex].row + local state = Data.checkbox[tableIndex].state + + Data.checkbox[tableIndex].state = not state + Data.checkbox[tableIndex].pos.y = state and -0.5 or 0.25 + markedBoxes[row] = markedBoxes[row] + (state and -1 or 1) + + 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 then return end + inputValues[i] = value +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + -- create checkboxes + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + self.setVar(funcName, function() clickCheckbox(i) end) + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + -- create inputboxes + for i, box_data in ipairs(Data.inputbox) do + local funcName = "inputbox" .. i + self.setVar(funcName, function(_, _, val, sel) clickTextbox(i, val, sel) end) + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + value = box_data.value + }) + end +end From b03aee593deda8b21ce9603623c5dd3776982e04 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 6 Dec 2022 11:09:47 +0100 Subject: [PATCH 2/6] bugfix for 'dominance' --- src/arkhamdb/DeckImporterMain.ttslua | 41 ++++++++++++++-------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index 738f131b..7be0b5e3 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -2,32 +2,32 @@ require("playermat/Zones") require("arkhamdb/LoaderUi") require("playercards/PlayerCardSpawner") -local bondedList = { } -local customizationRowsWithFields = { } +local bondedList = {} +local customizationRowsWithFields = {} -- inputMap maps from (our 1-indexes) customization row index to inputValue table index -- The Raven Quill -customizationRowsWithFields["09042"] = { } +customizationRowsWithFields["09042"] = {} customizationRowsWithFields["09042"].inputCount = 2 -customizationRowsWithFields["09042"].inputMap = { } +customizationRowsWithFields["09042"].inputMap = {} customizationRowsWithFields["09042"].inputMap[1] = 1 customizationRowsWithFields["09042"].inputMap[5] = 2 -- Friends in Low Places -customizationRowsWithFields["09060"] = { } +customizationRowsWithFields["09060"] = {} customizationRowsWithFields["09060"].inputCount = 2 -customizationRowsWithFields["09060"].inputMap = { } +customizationRowsWithFields["09060"].inputMap = {} customizationRowsWithFields["09060"].inputMap[1] = 1 customizationRowsWithFields["09060"].inputMap[3] = 2 -- Living Ink -customizationRowsWithFields["09079"] = { } +customizationRowsWithFields["09079"] = {} customizationRowsWithFields["09079"].inputCount = 3 -customizationRowsWithFields["09079"].inputMap = { } +customizationRowsWithFields["09079"].inputMap = {} customizationRowsWithFields["09079"].inputMap[1] = 1 customizationRowsWithFields["09079"].inputMap[5] = 2 customizationRowsWithFields["09079"].inputMap[6] = 3 -- Grizzled -customizationRowsWithFields["09101"] = { } +customizationRowsWithFields["09101"] = {} customizationRowsWithFields["09101"].inputCount = 3 -customizationRowsWithFields["09101"].inputMap = { } +customizationRowsWithFields["09101"].inputMap = {} customizationRowsWithFields["09101"].inputMap[1] = 1 customizationRowsWithFields["09101"].inputMap[2] = 2 customizationRowsWithFields["09101"].inputMap[3] = 3 @@ -235,7 +235,7 @@ function maybeAddCustomizeUpgradeSheets(slots, configuration) -- upgrade sheets for customizable cards local upgradesheet = allCardsBag.call("getCardById", { id = cardId .. "-c" }) if upgradesheet ~= nil then - slots[cardId.."-c"] = 1 + slots[cardId .. "-c"] = 1 end end end @@ -388,11 +388,11 @@ function loadCards(slots, investigatorId, customizations, playerColor, commandMa spreadCallback = function(deck) deck.spread(spreadDistance) end end Spawner.spawnCards( - zoneCards, - deckPos, - Zones.getDefaultCardRotation(playerColor, zone), - true, -- Sort deck - spreadCallback) + zoneCards, + deckPos, + Zones.getDefaultCardRotation(playerColor, zone), + true, -- Sort deck + spreadCallback) coroutine.yield(0) end @@ -438,7 +438,7 @@ function convertRavenQuillSelections(selectionString) if (string.len(selectionString) == 5) then return getCardName(selectionString) elseif (string.len(selectionString) == 11) then - return getCardName(string.sub(selectionString, 1, 5))..", "..getCardName(string.sub(selectionString, 7)) + return getCardName(string.sub(selectionString, 1, 5)) .. ", " .. getCardName(string.sub(selectionString, 7)) end end @@ -465,7 +465,7 @@ function buildZoneLists(cards) local zoneList = {} for _, card in ipairs(cards) do if zoneList[card.zone] == nil then - zoneList[card.zone] = { } + zoneList[card.zone] = {} end table.insert(zoneList[card.zone], card) end @@ -657,9 +657,8 @@ function handleCustomizableUpgrades(cardList, customizations) markedBoxes[index] = tonumber(str) elseif counter == 3 and str ~= "" then if (baseId == "09042") then - inputValues[customizationRowsWithFields[baseId].inputMap[index]] = - convertRavenQuillSelections(str) - else + inputValues[customizationRowsWithFields[baseId].inputMap[index]] = convertRavenQuillSelections(str) + elseif customizationRowsWithFields[baseId] ~= nil then inputValues[customizationRowsWithFields[baseId].inputMap[index]] = str end end From 33a33ebbe1dca62d231a3a9ffaa451174b29792a Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 6 Dec 2022 11:16:00 +0100 Subject: [PATCH 3/6] Revert "use require, optimize" This reverts commit 97b3dd4ce5d876aa5af0344ee409f8e828bbba76. --- ...icalDistillationUpgradeSheet.156166.ttslua | 182 +++++++++++++++-- ...tomModificationsUpgradeSheet.4104bf.ttslua | 179 ++++++++++++++++- ...DamningTestimonyUpgradeSheet.dc4a62.ttslua | 179 ++++++++++++++++- ...iricalHypothesisUpgradeSheet.0c46a7.ttslua | 183 +++++++++++++++-- ...iendsinLowPlacesUpgradeSheet.9fb3b9.ttslua | 185 ++++++++++++++++-- .../GrizzledUpgradeSheet.ef8f08.ttslua | 181 +++++++++++++++-- .../HonedInstinctUpgradeSheet.ba0e34.ttslua | 183 +++++++++++++++-- .../HuntersArmorUpgradeSheet.d2d01b.ttslua | 181 +++++++++++++++-- ...ysicalShotcasterUpgradeSheet.a4eec2.ttslua | 181 +++++++++++++++-- .../LivingLinkUpgradeSheet.19a05b.ttslua | 180 +++++++++++++++++ .../MakeshiftTrapUpgradeSheet.64dfce.ttslua | 181 +++++++++++++++-- .../PocketMultiToolUpgradeSheet.d706e7.ttslua | 181 +++++++++++++++-- .../PowerWordUpgradeSheet.0d9481.ttslua | 183 +++++++++++++++-- .../RunicAxeUpgradeSheet.be427d.ttslua | 183 +++++++++++++++-- ...SummonedServitorUpgradeSheet.5397a6.ttslua | 183 +++++++++++++++-- .../TheRavenQuillUpgradeSheet.23b96a.ttslua | 185 ++++++++++++++++-- .../customizable/UpgradeSheet.ttslua | 125 ------------ 17 files changed, 2738 insertions(+), 297 deletions(-) create mode 100644 objects/AllPlayerCards.15bb07/LivingLinkUpgradeSheet.19a05b.ttslua delete mode 100644 src/playercards/customizable/UpgradeSheet.ttslua diff --git a/objects/AllPlayerCards.15bb07/AlchemicalDistillationUpgradeSheet.156166.ttslua b/objects/AllPlayerCards.15bb07/AlchemicalDistillationUpgradeSheet.156166.ttslua index 99be303a..95ecd11f 100644 --- a/objects/AllPlayerCards.15bb07/AlchemicalDistillationUpgradeSheet.156166.ttslua +++ b/objects/AllPlayerCards.15bb07/AlchemicalDistillationUpgradeSheet.156166.ttslua @@ -1,21 +1,181 @@ -- Customizable Cards: Alchemical Distillation -boxSize = 40 -x_1 = -0.933 -x_offset = 0.075 +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + + +-- Color information for buttons +boxSize = 40 + +-- static values +x_1 = -0.933 +x_offset = 0.075 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.892, - -0.665, - -0.430, - -0.092, - 0.142, - 0.376, - 0.815 + -0.892, + -0.665, + -0.430, + -0.092, + 0.142, + 0.376, + 0.815 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 1, 1, 2, 4, 5 } + inputBoxes = {} -require("playercards/customizable/Upgradesheet") +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/CustomModificationsUpgradeSheet.4104bf.ttslua b/objects/AllPlayerCards.15bb07/CustomModificationsUpgradeSheet.4104bf.ttslua index 8417fdf5..1e0e5350 100644 --- a/objects/AllPlayerCards.15bb07/CustomModificationsUpgradeSheet.4104bf.ttslua +++ b/objects/AllPlayerCards.15bb07/CustomModificationsUpgradeSheet.4104bf.ttslua @@ -1,20 +1,179 @@ -- Customizable Cards: Custom Modifications -boxSize = 38 -x_1 = -0.935 -x_offset = 0.0735 +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons +boxSize = 38 + +-- static values +x_1 = -0.935 +x_offset = 0.0735 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.895, - -0.455, - -0.215, - 0.115, - 0.453, - 0.794 + -0.895, + -0.455, + -0.215, + 0.115, + 0.453, + 0.794 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 2, 2, 3, 3, 4 } + inputBoxes = {} -require("playercards/customizable/Upgradesheet") +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/DamningTestimonyUpgradeSheet.dc4a62.ttslua b/objects/AllPlayerCards.15bb07/DamningTestimonyUpgradeSheet.dc4a62.ttslua index 4a43861a..77255bfb 100644 --- a/objects/AllPlayerCards.15bb07/DamningTestimonyUpgradeSheet.dc4a62.ttslua +++ b/objects/AllPlayerCards.15bb07/DamningTestimonyUpgradeSheet.dc4a62.ttslua @@ -1,20 +1,179 @@ -- Customizable Cards: Damning Testimony -boxSize = 40 -x_1 = -0.935 -x_offset = 0.075 +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons +boxSize = 40 + +-- static values +x_1 = -0.935 +x_offset = 0.075 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.925, - -0.475, - -0.25, - -0.01, - 0.428, - 0.772 + -0.925, + -0.475, + -0.25, + -0.01, + 0.428, + 0.772 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 2, 2, 3, 3, 4 } + inputBoxes = {} -require("playercards/customizable/Upgradesheet") +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/EmpiricalHypothesisUpgradeSheet.0c46a7.ttslua b/objects/AllPlayerCards.15bb07/EmpiricalHypothesisUpgradeSheet.0c46a7.ttslua index a2497ba8..b3123175 100644 --- a/objects/AllPlayerCards.15bb07/EmpiricalHypothesisUpgradeSheet.0c46a7.ttslua +++ b/objects/AllPlayerCards.15bb07/EmpiricalHypothesisUpgradeSheet.0c46a7.ttslua @@ -1,22 +1,181 @@ -- Customizable Cards: Empirical Hypothesis -boxSize = 37 -x_1 = -0.935 -x_offset = 0.069 +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons +boxSize = 37 + +-- static values +x_1 = -0.935 +x_offset = 0.069 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.905, - -0.7, - -0.505, - -0.3, - -0.09, - 0.3, - 0.592, - 0.888 + -0.905, + -0.7, + -0.505, + -0.3, + -0.09, + 0.3, + 0.592, + 0.888 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 1, 1, 2, 2, 3, 4 } + inputBoxes = {} -require("playercards/customizable/Upgradesheet") +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/FriendsinLowPlacesUpgradeSheet.9fb3b9.ttslua b/objects/AllPlayerCards.15bb07/FriendsinLowPlacesUpgradeSheet.9fb3b9.ttslua index e6e6a1ad..8f1cae92 100644 --- a/objects/AllPlayerCards.15bb07/FriendsinLowPlacesUpgradeSheet.9fb3b9.ttslua +++ b/objects/AllPlayerCards.15bb07/FriendsinLowPlacesUpgradeSheet.9fb3b9.ttslua @@ -1,24 +1,183 @@ -- Customizable Cards: Friends in Low Places +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons and input boxes boxSize = 36 inputFontsize = 50 -x_1 = -0.935 -x_offset = 0.0685 + +-- static values +x_1 = -0.935 +x_offset = 0.0685 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.725, - -0.44, - -0.05, - 0.25, - 0.545, - 0.75, - 0.95 + -0.725, + -0.44, + -0.05, + 0.25, + 0.545, + 0.75, + 0.95 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 2, 2, 2, 2, 3, 3 } -inputBoxes = { 1, 1 } -inputWidth = { 640, 290 } -inputPos = { { 0.275, 0.25, -0.91 }, { 0.6295, 0.25, -0.44 } } -require("playercards/customizable/Upgradesheet") +inputBoxes = { 1, 1 } +inputWidth = { 640, 290 } +inputPos = { { 0.275, 0.25, -0.91 }, { 0.6295, 0.25, -0.44 } } + +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/GrizzledUpgradeSheet.ef8f08.ttslua b/objects/AllPlayerCards.15bb07/GrizzledUpgradeSheet.ef8f08.ttslua index 23ed6192..39a5a906 100644 --- a/objects/AllPlayerCards.15bb07/GrizzledUpgradeSheet.ef8f08.ttslua +++ b/objects/AllPlayerCards.15bb07/GrizzledUpgradeSheet.ef8f08.ttslua @@ -1,22 +1,181 @@ -- Customizable Cards: Grizzled +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons and input boxes boxSize = 40 inputFontsize = 50 -x_1 = -0.933 -x_offset = 0.075 + +-- static values +x_1 = -0.933 +x_offset = 0.075 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.71, - -0.458, - -0.205, - 0.362, - 0.82 + -0.71, + -0.458, + -0.205, + 0.362, + 0.82 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 2, 3, 4, 5 } -inputBoxes = { 1, 1, 1 } -inputWidth = { 600, 875, 875 } -inputPos = { { 0.3, 0.25, -0.91 }, { 0.005, 0.25, -0.58 }, { 0.005, 0.25, -0.32 } } -require("playercards/customizable/Upgradesheet") +inputBoxes = { 1, 1, 1 } +inputWidth = { 600, 875, 875 } +inputPos = { { 0.3, 0.25, -0.91 }, { 0.005, 0.25, -0.58 }, { 0.005, 0.25, -0.32 } } + +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/HonedInstinctUpgradeSheet.ba0e34.ttslua b/objects/AllPlayerCards.15bb07/HonedInstinctUpgradeSheet.ba0e34.ttslua index 7cf218de..bde1a713 100644 --- a/objects/AllPlayerCards.15bb07/HonedInstinctUpgradeSheet.ba0e34.ttslua +++ b/objects/AllPlayerCards.15bb07/HonedInstinctUpgradeSheet.ba0e34.ttslua @@ -1,22 +1,181 @@ -- Customizable Cards: Honed Instinct -boxSize = 38 -x_1 = -0.935 -x_offset = 0.069 +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons +boxSize = 38 + +-- static values +x_1 = -0.935 +x_offset = 0.069 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.905, - -0.705, - -0.5, - -0.29, - -0.09, - 0.12, - 0.325, - 0.62 + -0.905, + -0.705, + -0.5, + -0.29, + -0.09, + 0.12, + 0.325, + 0.62 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 } + inputBoxes = {} -require("playercards/customizable/Upgradesheet") +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/HuntersArmorUpgradeSheet.d2d01b.ttslua b/objects/AllPlayerCards.15bb07/HuntersArmorUpgradeSheet.d2d01b.ttslua index 6b64b6f0..b2ed3fda 100644 --- a/objects/AllPlayerCards.15bb07/HuntersArmorUpgradeSheet.d2d01b.ttslua +++ b/objects/AllPlayerCards.15bb07/HuntersArmorUpgradeSheet.d2d01b.ttslua @@ -1,21 +1,180 @@ -- Customizable Cards: Hunter's Armor -boxSize = 40 -x_1 = -0.933 -x_offset = 0.075 +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons +boxSize = 40 + +-- static values +x_1 = -0.933 +x_offset = 0.075 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.892, - -0.560, - -0.220, - -0.092, - 0.047, - 0.376, - 0.820 + -0.892, + -0.560, + -0.220, + -0.092, + 0.047, + 0.376, + 0.820 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 2, 2, 2, 2, 3, 3 } + inputBoxes = {} -require("playercards/customizable/Upgradesheet") +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/HyperphysicalShotcasterUpgradeSheet.a4eec2.ttslua b/objects/AllPlayerCards.15bb07/HyperphysicalShotcasterUpgradeSheet.a4eec2.ttslua index 8ce32945..fb094979 100644 --- a/objects/AllPlayerCards.15bb07/HyperphysicalShotcasterUpgradeSheet.a4eec2.ttslua +++ b/objects/AllPlayerCards.15bb07/HyperphysicalShotcasterUpgradeSheet.a4eec2.ttslua @@ -1,21 +1,180 @@ -- Customizable Cards: Hyperphysical Shotcaster -boxSize = 38 -x_1 = -0.935 -x_offset = 0.069 +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons +boxSize = 38 + +-- static values +x_1 = -0.935 +x_offset = 0.069 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.9, - -0.615, - -0.237, - 0.232, - 0.61, - 0.988, - 1.185 + -0.9, + -0.615, + -0.237, + 0.232, + 0.61, + 0.988, + 1.185 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 2, 2, 2, 2, 2, 4, 4 } + inputBoxes = {} -require("playercards/customizable/Upgradesheet") +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/LivingLinkUpgradeSheet.19a05b.ttslua b/objects/AllPlayerCards.15bb07/LivingLinkUpgradeSheet.19a05b.ttslua new file mode 100644 index 00000000..7599137e --- /dev/null +++ b/objects/AllPlayerCards.15bb07/LivingLinkUpgradeSheet.19a05b.ttslua @@ -0,0 +1,180 @@ +-- Customizable Cards: Living Ink +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons +boxSize = 40 + +-- static values +x_1 = -0.935 +x_offset = 0.075 +y_visible = 0.25 +y_invisible = -0.5 + +-- z-values (lines on the sheet) +posZ = { + -0.69, + -0.355, + 0.0855, + 0.425, + 0.555, + 0.685, + 1.02 +} + +-- box setup (amount of boxes per line and amount of marked boxes in that line) +existingBoxes = { 1, 1, 2, 2, 3, 3, 3 } + +inputBoxes = {} + +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/MakeshiftTrapUpgradeSheet.64dfce.ttslua b/objects/AllPlayerCards.15bb07/MakeshiftTrapUpgradeSheet.64dfce.ttslua index c785f0bf..f43f200c 100644 --- a/objects/AllPlayerCards.15bb07/MakeshiftTrapUpgradeSheet.64dfce.ttslua +++ b/objects/AllPlayerCards.15bb07/MakeshiftTrapUpgradeSheet.64dfce.ttslua @@ -1,21 +1,180 @@ -- Customizable Cards: Makeshift Trap -boxSize = 39 -x_1 = -0.935 -x_offset = 0.0735 +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons +boxSize = 39 + +-- static values +x_1 = -0.935 +x_offset = 0.0735 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.889, - -0.655, - -0.325, - -0.085, - 0.252, - 0.585, - 0.927 + -0.889, + -0.655, + -0.325, + -0.085, + 0.252, + 0.585, + 0.927 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 2, 2, 2, 3, 4 } + inputBoxes = {} -require("playercards/customizable/Upgradesheet") +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/PocketMultiToolUpgradeSheet.d706e7.ttslua b/objects/AllPlayerCards.15bb07/PocketMultiToolUpgradeSheet.d706e7.ttslua index c65728b0..24c8e8ca 100644 --- a/objects/AllPlayerCards.15bb07/PocketMultiToolUpgradeSheet.d706e7.ttslua +++ b/objects/AllPlayerCards.15bb07/PocketMultiToolUpgradeSheet.d706e7.ttslua @@ -1,21 +1,180 @@ -- Customizable Cards: Pocket Multi Tool -boxSize = 40 -x_1 = -0.933 -x_offset = 0.075 +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons +boxSize = 40 + +-- static values +x_1 = -0.933 +x_offset = 0.075 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.892, - -0.560, - -0.326, - -0.092, - 0.142, - 0.376, - 0.610 + -0.892, + -0.560, + -0.326, + -0.092, + 0.142, + 0.376, + 0.610 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 2, 2, 2, 3, 4 } + inputBoxes = {} -require("playercards/customizable/Upgradesheet") +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/PowerWordUpgradeSheet.0d9481.ttslua b/objects/AllPlayerCards.15bb07/PowerWordUpgradeSheet.0d9481.ttslua index d6a3870d..9d19459b 100644 --- a/objects/AllPlayerCards.15bb07/PowerWordUpgradeSheet.0d9481.ttslua +++ b/objects/AllPlayerCards.15bb07/PowerWordUpgradeSheet.0d9481.ttslua @@ -1,22 +1,181 @@ -- Customizable Cards: Power Word -boxSize = 38 -x_1 = -0.933 -x_offset = 0.069 +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons +boxSize = 38 + +-- static values +x_1 = -0.933 +x_offset = 0.069 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.905, - -0.6, - -0.32, - -0.02, - 0.28, - 0.48, - 0.775, - 0.975 + -0.905, + -0.6, + -0.32, + -0.02, + 0.28, + 0.48, + 0.775, + 0.975 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 1, 1, 2, 3, 3, 3 } + inputBoxes = {} -require("playercards/customizable/Upgradesheet") +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/RunicAxeUpgradeSheet.be427d.ttslua b/objects/AllPlayerCards.15bb07/RunicAxeUpgradeSheet.be427d.ttslua index 29bcc4b5..3a365ef0 100644 --- a/objects/AllPlayerCards.15bb07/RunicAxeUpgradeSheet.be427d.ttslua +++ b/objects/AllPlayerCards.15bb07/RunicAxeUpgradeSheet.be427d.ttslua @@ -1,22 +1,181 @@ -- Customizable Cards: Runic Axe -boxSize = 38 -x_1 = -0.935 -x_offset = 0.0705 +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons +boxSize = 38 + +-- static values +x_1 = -0.935 +x_offset = 0.0705 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.92, - -0.715, - -0.415, - -0.018, - 0.265, - 0.66, - 0.86, - 1.065 + -0.92, + -0.715, + -0.415, + -0.018, + 0.265, + 0.66, + 0.86, + 1.065 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 1, 1, 1, 3, 3, 4 } + inputBoxes = {} -require("playercards/customizable/Upgradesheet") +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.ttslua b/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.ttslua index d78b8af6..75ab4600 100644 --- a/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.ttslua +++ b/objects/AllPlayerCards.15bb07/SummonedServitorUpgradeSheet.5397a6.ttslua @@ -1,22 +1,181 @@ -- Customizable Cards: Summoned Servitor -boxSize = 35 -x_1 = -0.935 -x_offset = 0.068 +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons +boxSize = 35 + +-- static values +x_1 = -0.935 +x_offset = 0.068 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.92, - -0.625, - -0.33, - 0.055, - 0.26, - 0.56, - 0.765, - 1.06 + -0.92, + -0.625, + -0.33, + 0.055, + 0.26, + 0.56, + 0.765, + 1.06 } -- box setup (amount of boxes per line and amount of marked boxes in that line) existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 } + inputBoxes = {} -require("playercards/customizable/Upgradesheet") +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/objects/AllPlayerCards.15bb07/TheRavenQuillUpgradeSheet.23b96a.ttslua b/objects/AllPlayerCards.15bb07/TheRavenQuillUpgradeSheet.23b96a.ttslua index aa21945e..e213bf7c 100644 --- a/objects/AllPlayerCards.15bb07/TheRavenQuillUpgradeSheet.23b96a.ttslua +++ b/objects/AllPlayerCards.15bb07/TheRavenQuillUpgradeSheet.23b96a.ttslua @@ -1,24 +1,183 @@ -- Customizable Cards: The Raven Quill +-- by Chr1Z +information = { + version = "1.7", + last_updated = "12.10.2022" +} + +-- Color information for buttons and input boxes boxSize = 37 inputFontsize = 38 -x_1 = -0.935 -x_offset = 0.0705 + +-- static values +x_1 = -0.935 +x_offset = 0.0705 +y_visible = 0.25 +y_invisible = -0.5 -- z-values (lines on the sheet) posZ = { - -0.72, - -0.52, - -0.305, - -0.105, - 0.1, - 0.4, - 0.695 + -0.72, + -0.52, + -0.305, + -0.105, + 0.1, + 0.4, + 0.695 } -- 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/Upgradesheet") +inputBoxes = { 1, 1 } +inputWidth = { 425, 775 } +inputPos = { { 0.5, 0.25, -0.905 }, { 0.125, 0.25, 0 } } + +-- 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 + +-- 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] + else + markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } + inputValues = { "", "", "", "", "" } + end + + makeData() + createButtonsAndBoxes() + + self.addContextMenuItem("Reset Inputs", function() updateState() end) + self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) + self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) + self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) +end + +function updateState(markedBoxesNew) + if markedBoxesNew then markedBoxes = markedBoxesNew end + makeData() + createButtonsAndBoxes() +end + +-- create Data +function makeData() + Data = {} + Data.checkbox = {} + Data.textbox = {} + + -- repeat this for each entry (= line) in existingBoxes + local totalCount = 0 + for i = 1, #existingBoxes do + -- repeat this for each checkbox per line + for j = 1, existingBoxes[i] do + totalCount = totalCount + 1 + 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 (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "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 + + -- repeat this for each entry (= line) in inputBoxes + local totalCount = 0 + for i = 1, #inputBoxes do + -- repeat this for each textbox per line + for j = 1, inputBoxes[i] do + totalCount = totalCount + 1 + Data.textbox[totalCount] = {} + Data.textbox[totalCount].pos = inputPos[totalCount] + Data.textbox[totalCount].width = inputWidth[totalCount] + Data.textbox[totalCount].value = inputValues[totalCount] + end + end +end + +-- checks or unchecks the given box +function click_checkbox(tableIndex) + local row = Data.checkbox[tableIndex].row + + if Data.checkbox[tableIndex].state == true 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 click_textbox(i, value, selected) + if selected == false then + inputValues[i] = value + end +end + +function createButtonsAndBoxes() + self.clearButtons() + self.clearInputs() + + for i, box_data in ipairs(Data.checkbox) do + local funcName = "checkbox" .. i + local func = function() click_checkbox(i) end + self.setVar(funcName, func) + + self.createButton({ + click_function = funcName, + function_owner = self, + position = box_data.pos, + height = boxSize, + width = boxSize, + font_size = box_data.size, + scale = { 1, 1, 1 }, + color = { 0, 0, 0 }, + font_color = { 0, 0, 0 } + }) + end + + for i, box_data in ipairs(Data.textbox) do + local funcName = "textbox" .. i + local func = function(_, _, val, sel) click_textbox(i, val, sel) end + self.setVar(funcName, func) + + self.createInput({ + input_function = funcName, + function_owner = self, + label = "Click to type", + alignment = 2, + position = box_data.pos, + scale = buttonScale, + width = box_data.width, + height = (inputFontsize * 1) + 24, + font_size = inputFontsize, + color = "White", + font_color = buttonFontColor, + value = box_data.value + }) + end +end diff --git a/src/playercards/customizable/UpgradeSheet.ttslua b/src/playercards/customizable/UpgradeSheet.ttslua deleted file mode 100644 index e5809755..00000000 --- a/src/playercards/customizable/UpgradeSheet.ttslua +++ /dev/null @@ -1,125 +0,0 @@ --- override 'marked boxes' for debugging ('all' or 'none') -local markDEBUG = "" - --- save state when going into bags / decks -function onDestroy() self.script_state = onSave() end - -function onSave() return JSON.encode({ markedBoxes, inputValues }) end - -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] - else - markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } - inputValues = { "", "", "", "", "" } - end - - makeData() - createButtonsAndBoxes() - - self.addContextMenuItem("Reset Inputs", function() updateState() end) - self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) - self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) - self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) -end - --- can be called to set the state to 'markedBoxesNew' / 'inputValuesNew' -function updateState(markedBoxesNew, inputValuesNew) - if markedBoxesNew then markedBoxes = markedBoxesNew end - if inputValuesNew then inputValues = inputValuesNew end - makeData() - createButtonsAndBoxes() -end - --- create Data (mainly positions of boxes) -function makeData() - Data = {} - Data.checkbox = {} - Data.inputbox = {} - - -- repeat this for each entry (= line) in existingBoxes - local totalCount = 0 - for i = 1, #existingBoxes do - -- repeat this for each checkbox per line - for j = 1, existingBoxes[i] do - local state = (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") - totalCount = totalCount + 1 - Data.checkbox[totalCount] = {} - Data.checkbox[totalCount].state = state - Data.checkbox[totalCount].pos = { x = x_1 + j * x_offset, y = state and 0.25 or -0.5, z = posZ[i] } - Data.checkbox[totalCount].row = i - end - end - - -- repeat this for each entry (= line) in inputBoxes - local totalCount = 0 - for i = 1, #inputBoxes do - -- repeat this for each inputbox per line - for j = 1, inputBoxes[i] do - totalCount = totalCount + 1 - Data.inputbox[totalCount] = {} - Data.inputbox[totalCount].pos = inputPos[totalCount] - Data.inputbox[totalCount].width = inputWidth[totalCount] - Data.inputbox[totalCount].value = inputValues[totalCount] - end - end -end - --- checks or unchecks the given box -function clickCheckbox(tableIndex) - local row = Data.checkbox[tableIndex].row - local state = Data.checkbox[tableIndex].state - - Data.checkbox[tableIndex].state = not state - Data.checkbox[tableIndex].pos.y = state and -0.5 or 0.25 - markedBoxes[row] = markedBoxes[row] + (state and -1 or 1) - - 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 then return end - inputValues[i] = value -end - -function createButtonsAndBoxes() - self.clearButtons() - self.clearInputs() - - -- create checkboxes - for i, box_data in ipairs(Data.checkbox) do - local funcName = "checkbox" .. i - self.setVar(funcName, function() clickCheckbox(i) end) - self.createButton({ - click_function = funcName, - function_owner = self, - position = box_data.pos, - height = boxSize, - width = boxSize, - font_size = box_data.size, - color = { 0, 0, 0 }, - font_color = { 0, 0, 0 } - }) - end - - -- create inputboxes - for i, box_data in ipairs(Data.inputbox) do - local funcName = "inputbox" .. i - self.setVar(funcName, function(_, _, val, sel) clickTextbox(i, val, sel) end) - self.createInput({ - input_function = funcName, - function_owner = self, - label = "Click to type", - alignment = 2, - position = box_data.pos, - width = box_data.width, - height = (inputFontsize * 1) + 24, - font_size = inputFontsize, - color = "White", - value = box_data.value - }) - end -end From cd83347c729d0cd457fd22a6365e2767e8bdd958 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 6 Dec 2022 11:32:57 +0100 Subject: [PATCH 4/6] resolve merge conflict --- src/arkhamdb/DeckImporterMain.ttslua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index 7be0b5e3..66a6956a 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -392,8 +392,7 @@ function loadCards(slots, investigatorId, customizations, playerColor, commandMa deckPos, Zones.getDefaultCardRotation(playerColor, zone), true, -- Sort deck - spreadCallback) - + Callback) coroutine.yield(0) end From c84e8a2101c8d00718d97a7e41efa198c463dca9 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 6 Dec 2022 11:34:00 +0100 Subject: [PATCH 5/6] resolve merge conflict (again) --- src/arkhamdb/DeckImporterMain.ttslua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index 66a6956a..01003429 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -392,7 +392,8 @@ function loadCards(slots, investigatorId, customizations, playerColor, commandMa deckPos, Zones.getDefaultCardRotation(playerColor, zone), true, -- Sort deck - Callback) + callback) + coroutine.yield(0) end From 5b0cdf942da744127e8eb13e50cf364d31ed6a88 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Tue, 6 Dec 2022 11:34:49 +0100 Subject: [PATCH 6/6] resolve merge conflict (again!!) --- src/arkhamdb/DeckImporterMain.ttslua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/arkhamdb/DeckImporterMain.ttslua b/src/arkhamdb/DeckImporterMain.ttslua index 01003429..258bad2f 100644 --- a/src/arkhamdb/DeckImporterMain.ttslua +++ b/src/arkhamdb/DeckImporterMain.ttslua @@ -388,11 +388,11 @@ function loadCards(slots, investigatorId, customizations, playerColor, commandMa spreadCallback = function(deck) deck.spread(spreadDistance) end end Spawner.spawnCards( - zoneCards, - deckPos, - Zones.getDefaultCardRotation(playerColor, zone), - true, -- Sort deck - callback) + zoneCards, + deckPos, + Zones.getDefaultCardRotation(playerColor, zone), + true, -- Sort deck + callback) coroutine.yield(0) end