Posted 26 December 2016 - 06:49 AM
So I'm having trouble with the UI of my cc program. Basically my monitor touch events all take place about half a cell higher than they should and off to the right. Its not completely consistent as some events take place almost full cells higher but the red boxes in this image show where I actually have to press to use the buttons.
http://i.imgur.com/B21FSs9.png
At first I thought it may be a textScale issue but setting it to 1 doesn't fix the alignment issues. I see no reason why my code shouldn't work even if it is a bit messy. I have stripped out everything unrelated to the buttons.
Full code:
http://pastebin.com/1GYzD5iN
Button table:
Button control code:
http://i.imgur.com/B21FSs9.png
At first I thought it may be a textScale issue but setting it to 1 doesn't fix the alignment issues. I see no reason why my code shouldn't work even if it is a bit messy. I have stripped out everything unrelated to the buttons.
Full code:
http://pastebin.com/1GYzD5iN
Button table:
local b = { --table for roulette game buttons {text, x, y, active, bg colour, fg colour, inactive bg colour, inactive fg colour}
{text = "ODD", x = 3, y = 10, active = false, bg = 32768, fg = 1, inactivebg = 256, inactivefg = 1},
{text = " 0 ", x = 7, y = 10, active = false, bg = 8192, fg = 1, inactivebg = 256, inactivefg = 1},
{text = "EVN", x = 11, y = 10, active = false, bg = 16384, fg = 1, inactivebg = 256, inactivefg = 1},
{text = "SPIN!", x = 6, y = 12, active = false, bg = 32, fg = 1, inactivebg = 256, inactivefg = 1},
{text = "0", x = 8, y = 18, active = true, bg = 128, fg = 1},
{text = " +", x = 9, y = 18, active = true, bg = 8192, fg = 1},
{text = " >", x = 11, y = 18, active = true, bg = 32, fg = 1},
{text = ' '..string.char(194,59), x = 13, y = 18, active = true, bg = 8192, fg = 1},
{text = "- ", x = 6, y = 18, active = true, bg = 16384, fg = 1},
{text = "< ", x = 4, y = 18, active = true, bg = 64, fg = 1},
{text = string.char(194,43)..' ', x = 2, y = 18, active = true, bg = 16384, fg = 1}
--,{text = "Quit", x = 8, y = 12, active = true, bg = 16384, fg = 1}
}
Button control code:
local function buttonControl(x, y)
for i=1, #b do
if y == b[i].y and x >= b[i].x and x < b[i].x + #b[i].text then
if i == 1 then btnBetType(1); return
elseif i == 2 then btnBetType(2); return
elseif i == 3 then btnBetType(3); return
elseif i == 4 and b[4].active and currentGame.bet > 0 then btnBetType(0); return
elseif i == 5 then btnBet(0); return
elseif i == 6 then btnBet(currentGame.base); return
elseif i == 7 then btnBet(currentGame.base * 16); return
elseif i == 8 then btnBet(currentGame.base * 64); return
elseif i == 9 then btnBet(0-currentGame.base); return
elseif i == 10 then btnBet(0-currentGame.base * 16); return
elseif i == 11 then btnBet(0-currentGame.base * 64); return
elseif i == 12 then return true
end
end
end
end