From 5688f26edddf194e27593777d2f599fc813d6deb Mon Sep 17 00:00:00 2001 From: Jorge Parra Date: Thu, 23 Mar 2023 10:42:46 -0400 Subject: [PATCH] Moved position of percentages on Token Arranger --- src/accessories/TokenArranger.ttslua | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/accessories/TokenArranger.ttslua b/src/accessories/TokenArranger.ttslua index 02c60b93..12fe52c0 100644 --- a/src/accessories/TokenArranger.ttslua +++ b/src/accessories/TokenArranger.ttslua @@ -235,13 +235,19 @@ end -- creates percentage representation buttons function createPercentageButton(token_count, value_count, data, cumulative_percentage) - local cumulative_percentage = cumulative_percentage or false - local offset = 2.2 + local offset = -2.675 local label_string = string.format("%s", string.format("%05.2f", math.floor((token_count / #data) * 10000) / 100) .. "%") - + local buttonScale = {2, 2, 2} + if percentage == "cumulative" then + buttonScale = {1.5, 1.5, 1.5} + offset = -2.9 + end if cumulative_percentage then - offset = 3.8 + offset = -2.5 label_string = string.format("%s", "(" .. string.format("%05.2f", cumulative_percentage) .. "%)") + if cumulative_percentage == 100 then + label_string = string.format("%s", "(" .. string.format("%05.1f", cumulative_percentage) .. "%)") + end end self.createButton({ @@ -249,9 +255,9 @@ function createPercentageButton(token_count, value_count, data, cumulative_perce click_function = "print", width = 0, height = 0, - scale = {2, 2, 2}, + scale = buttonScale, font_color = {r=1,g=1,b=1}, - position = (Vector(offset, -0.05, -2.675) + Vector((0.875 * token_count) + 0.1, 0, 0.875 * value_count)) + position = (Vector(2.2, -0.05, offset) + Vector(0.1, 0, 0.875 * value_count)) }) end @@ -304,6 +310,9 @@ function layout(_, _, isRightClick) -- laying out the tokens local pos = self.getPosition() + Vector(3.55, -0.05, -3.95) + if percentage then + pos.z = self.getPosition().z - 7 + end local location = { x = pos.x, y = pos.y, z = pos.z } local current_value = data[1].value local token_count = 0