Character Sheet Pixel Positions

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
strangely
Posts: 25
Joined: Mon Oct 29, 2012 2:28 am
Location: Tucson, AZ

Character Sheet Pixel Positions

Post by strangely »

I wrote some code to figure out the skill positions in pixels for any screen resolution and I thought it might be useful to any UI modders.
The following will draw a bar under each skill on the character sheet:

Code: Select all

function onDrawSkills(self, context, champion)

	local width = context.width
	local height = context.height
	
	local heightRatio = height / 1080

	local barX = width - (536 * heightRatio)
	local barY = 339 * heightRatio
	local initialY = barY
	local barWidth = 224 * heightRatio
	local barHeight = 4 * heightRatio
	local barSpacingY = (31 * heightRatio)
	
	if barHeight < 1 then
		barHeight = 1
	end

	context.color(255, 255, 0, 128)

	for i=0, 7 do
		context.drawRect(barX, barY, barWidth, barHeight)

		barY = barY + barSpacingY
	end

	barY = initialY;
	barX = barX + (252 * heightRatio)
	for i=0, 7 do
		context.drawRect(barX, barY, barWidth, barHeight)

		barY = barY + barSpacingY
	end
end
I've tested it in many resolutions but if you find one that doesn't work, please let me know.
Post Reply