Jump to content
Tova

Predict number of lines for cutText

Recommended Posts

Hello,

I have a long string I want to print on the screen using cutText. The command behaviour is use to use linebreaks if the string is too long to fit as a single line on the screen.

 

I would like to predict on how many lines my text is going to be printed.

 

To achieve this I tried using getTextWidth combined with safeZoneW, my understanding being that :

  • getTextWidth : Retrieves the size of my string when printed on screen (with an arbitrary unit?)
  • safeZoneW  : Something equivalent to the maximum length of a string to fit as a single line (with an arbitrary unit?)

 

My issue however is that the units of the results seems to be different, on my PC I find :

 

  • getTextWidth : 33 for the longest string that fits on a single line (found empirically)
  • safeZoneW  : 1.56


I believe I should have found a result where roughly getTextWidth == safeZoneW, what did I miss ?
 

Share this post


Link to post
Share on other sites
7 hours ago, Tova said:

with an arbitrary unit?

if you've never heard of it it might seem like that, but they are screen coordinates: https://community.bistudio.com/wiki/Arma_3:_GUI_Coordinates

 

8 hours ago, Tova said:

safeZoneW  : Something equivalent to the maximum length of a string to fit as a single line

Not quite. safeZoneW is just the width of your screen in Arma's UI coordinates. So the maximum width a CONTROL can have before going offscreen.

 

8 hours ago, Tova said:

I believe I should have found a result where roughly getTextWidth == safeZoneW, what did I miss ?

So, safeZoneW is the width of the screen in screen coordinates, getTextWidth returns the needed width of a control in screen coordinates to display the whole text. that control can also be wider than the screen. the cutText command also automatically breaks lines (it most likely uses a CT_STRUCTURED_TEXT control) so to predict how many lines there are going to be, you'd need to know the width of that control but as it is handled by the engine I am not sure how to find that out.

  • Like 1

Share this post


Link to post
Share on other sites
On 8/23/2021 at 3:26 AM, 7erra said:

if you've never heard of it it might seem like that, but they are screen coordinates: https://community.bistudio.com/wiki/Arma_3:_GUI_Coordinates

 

Not quite. safeZoneW is just the width of your screen in Arma's UI coordinates. So the maximum width a CONTROL can have before going offscreen.

 

So, safeZoneW is the width of the screen in screen coordinates, getTextWidth returns the needed width of a control in screen coordinates to display the whole text. that control can also be wider than the screen. the cutText command also automatically breaks lines (it most likely uses a CT_STRUCTURED_TEXT control) so to predict how many lines there are going to be, you'd need to know the width of that control but as it is handled by the engine I am not sure how to find that out.

Hi 7erra, about your VASS, Im wondering if there is a way to let players access the store via script without actually spawn a unit as the store owner?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×