Jump to content

Positioning in lua scripts


llunak

Recommended Posts

Are there some docs, or could somebody please explain to me in brief how positioning of elements in the LUA scripts works?

I'm trying to modify the GC panel to show little soldier role icons in all the minibars, so that one does not have to hover each of them for a tooltip, and I've kind of managed to get coordinates that place things correctly for me, but I'm totally confused on how it actually works. For example, it seems to me that I actually had to move the soldier role icon to the left of the soldier number (i.e. negative infobar_roleimage_left) in order to have it placed just to the right of it. Do x/y actually specify center of the item, or what am I missing?

diff --git a/assets/scripts/combatguiexport_large.lua b/assets/scripts/combatguiexport_large.luaindex 334e1da..d7253ca 100644--- a/assets/scripts/combatguiexport_large.lua+++ b/assets/scripts/combatguiexport_large.lua@@ -276,10 +276,14 @@ local infobar_top = gui_background_top - infobar_height;local infobar_spacing = -4;local soldier_infobars_image = "uitextures/progressbar_fill"; -local miniprogressbar_width = infobar_width-35;+local infobar_roleimage_size = infobar_height - 14;+-- I don't quite get how this positioning works, but this value seems about right.+local infobar_roleimage_left = -6;++local miniprogressbar_width = infobar_width-33-infobar_roleimage_size;local miniprogressbar_height = 5;local miniprogressbar_top = infobar_top + 6;-local miniprogressbar_left = 7;+local miniprogressbar_left = 7 + infobar_roleimage_size/2+2;local miniprogressbar_vspacing = 4;local infobar_vehicle_left = infobar_init_x + (infobar_width+infobar_spacing)*13;@@ -1638,6 +1642,16 @@ MakeDialog			  barimage = soldier_infobars_image,			  percent  = false,			},+			NonUniformScaledImage+			{+			  name = "soldier1_roleimage",+			  x = infobar_init_x + infobar_roleimage_left,+			  y = miniprogressbar_top,+			  w = infobar_roleimage_size,+			  h = infobar_roleimage_size,+			  --image = "uitextures/roles/unused",+			  aspectfix = 1.0;+			},			Window			{				name = "soldier1_miniPortraitPopup",@@ -1761,6 +1775,16 @@ MakeDialog			  barimage = soldier_infobars_image,			  percent  = false,			},+			NonUniformScaledImage+			{+			  name = "soldier2_roleimage",+			  x = (infobar_init_x + infobar_roleimage_left) + (infobar_width+infobar_spacing)*1,+			  y = miniprogressbar_top,+			  w = infobar_roleimage_size,+			  h = infobar_roleimage_size,+			  --image = "uitextures/roles/unused",+			  aspectfix = 1.0;+			},			Window			{				name = "soldier2_miniPortraitPopup",

soldierroles.jpg

soldierroles.jpg

soldierroles.jpg.ba6e171c22091b3d3877db5

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...