SA-MP Forums Archive
Horizontal tabs (\t) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Horizontal tabs (\t) (/showthread.php?tid=244154)



Horizontal tabs (\t) - Holnista - 26.03.2011

Hey guys.

I need to know how to make equal text in GUI using horizontal tab character (\t).
Text is dynamic and string can change but tab must be still on one line.

I was trying do function to calculate stlen of string but it not working correct
becouse (for example) string 'lij' is shorter (in pixels) than 'LLL' but have the same stlen.

Can someon help ?
Respects.

PS: Yeah.. bad english ;/ Sorry !


Re: Horizontal tabs (\t) - Rachael - 26.03.2011

you will need to create a really complicated function to calculate the visual length of a particular string

hint: create textdraws to serve as a scale close to the user chatbox, and measure the length of, say 10 identical letters. Do this for all the characters, numbers, and symbols. Use the data in your function.

someone has already done this, and they are probably awesome.


Re: Horizontal tabs (\t) - Holnista - 26.03.2011

Quote:

someone has already done this, and they are probably awesome.

Cool! but who ? and where i can find it ?


Re: Horizontal tabs (\t) - Rachael - 26.03.2011

I don't think it has been released, they just showed me a screenshot of it in use.

You might have to write this yourself.

If you really want the function you will spend the time to make it a reality.


Re: Horizontal tabs (\t) - Calgon - 26.03.2011

Someone did this manually a while ago, but they never created a function to do it.

Good luck to whoever makes it, if anyone ever makes it.


Re: Horizontal tabs (\t) - Holnista - 26.03.2011

Its not so hard.
I will try.

Btw thanks for help.


Re: Horizontal tabs (\t) - WackoX - 26.03.2011

Ask SA:MP team if they range the tabs on string length, and not pixel length.
Otherwise it would be really difficult to make such a function, i have the same problem.


Re: Horizontal tabs (\t) - Holnista - 26.03.2011

I make something like this:
Quote:

stock Pause(str[])
{
new result[32];
new len = 0;
len = strlen(str);
if(strfind(str, "i", true) != -1 || strfind(str, "j", false) != -1 || strfind(str, "l", false) != -1) len += 1;
if(len <= 9) result = "\t\t";
else result = "\t";
return result;
}

Working in 90% cases.


Re: Horizontal tabs (\t) - Macluawn - 26.03.2011

Possible, but it will look ugly with some texts. example:
T h i s i s the first line
This is the second line



But in general it's easy to make - Get the longest line, and then in a while loop adding a spaces in lines until it's the same length.

Код:
for(1...line amount)
  if(strlen(line(i)) > strlen(longestline)) 
    longestline = line;

for(1..line amount)
  while(strlen(line(i) >= strlen(longestline))
    add spaces using variable
too lazy to make a proper code.


Re: Horizontal tabs (\t) - Holnista - 26.03.2011

Quote:

Possible, but it will look ugly with some texts. example:
T h i s i s the first line
This is the second line

Yeah but who use texts like this ?

Quote:

But in general it's easy to make - Get the longest line, and then in a while loop adding a spaces in lines until it's the same length.

Right but sometime spaces arent equal..
Write some lines using your method and you will see.