Horizontal tabs (\t)
#1

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 !
Reply
#2

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.
Reply
#3

Quote:

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

Cool! but who ? and where i can find it ?
Reply
#4

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.
Reply
#5

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.
Reply
#6

Its not so hard.
I will try.

Btw thanks for help.
Reply
#7

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.
Reply
#8

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.
Reply
#9

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.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)