Post: [RELEASE] Center Menus!
12-25-2011, 06:42 PM #1
Blackstorm
Veni. Vidi. Vici.
(adsbygoogle = window.adsbygoogle || []).push({}); Okay, so I told DaftVader I would make a script to center a string for his credits =D Well here it is:

    
centerString( array )
{
maxSize = 0;
trimSize = 0;
tempStr = "";
for ( i = 0; i < array.size; i++ )
if( array[i].size > maxSize )
maxSize = array[i].size;
for ( i = 0; i < array.size; i++ )
{
tempStr = "";
if( array[i].size < maxSize )
{
trimSize = ceil( maxSize - array[i].size );
for ( x = 0; x < trimSize; x++ )
tempStr += " ";
tempStr += array[i];
array[i] = tempStr;
}
}
return array;
}


Basically what this does, is spaces out each string in each array depending on the biggest string to give it a "centered" effect.

how to use:

    

function()
{
array[0] = "Hello";
array[1] = "Why Hello There";
array[2] = "penis";
array[3] = "lol";

menuString = buildString( centerString( array ) );

menu setText( menuString );
}
centerString( array )
{
maxSize = 0;
trimSize = 0;
tempStr = "";
for ( i = 0; i < array.size; i++ )
if( array[i].size > maxSize )
maxSize = array[i].size;
for ( i = 0; i < array.size; i++ )
{
tempStr = "";
if( array[i].size < maxSize )
{
trimSize = ceil( maxSize - array[i].size );
for ( x = 0; x < trimSize; x++ )
tempStr += " ";
tempStr += array[i];
array[i] = tempStr;
}
}
return array;
}


buildString( array )
{
str = "";
for ( i = 0; i < array.size; i++ )
str += array[i] + "\n";
return str;
}


This is for people who don't like their menus aligned or whatever, although this can be used for other things Upside Down Happy

The following 11 users say thank you to Blackstorm for this useful post:

aerosoul94, Correy, IELIITEMODZX, ItsLollo1000, Jacob-And-Britt, Karoolus, KCxFTW, Mango_Knife, John, Rebuged, x_DaftVader_x
12-25-2011, 08:01 PM #2
this is a good script save's me time making one thanks <3

The following user thanked IELIITEMODZX for this useful post:

Blackstorm
12-25-2011, 11:13 PM #3
Originally posted by Blackstorm View Post
Okay, so I told DaftVader I would make a script to center a string for his credits =D Well here it is:

    
centerString( array )
{
maxSize = 0;
trimSize = 0;
tempStr = "";
for ( i = 0; i < array.size; i++ )
if( array[i].size > maxSize )
maxSize = array[i].size;
for ( i = 0; i < array.size; i++ )
{
tempStr = "";
if( array[i].size < maxSize )
{
trimSize = ceil( maxSize - array[i].size );
for ( x = 0; x < trimSize; x++ )
tempStr += " ";
tempStr += array[i];
array[i] = tempStr;
}
}
return array;
}


Basically what this does, is spaces out each string in each array depending on the biggest string to give it a "centered" effect.

how to use:

    

function()
{
array[0] = "Hello";
array[1] = "Why Hello There";
array[2] = "penis";
array[3] = "lol";

menuString = buildString( centerString( array ) );

menu setText( menuString );
}
centerString( array )
{
maxSize = 0;
trimSize = 0;
tempStr = "";
for ( i = 0; i < array.size; i++ )
if( array[i].size > maxSize )
maxSize = array[i].size;
for ( i = 0; i < array.size; i++ )
{
tempStr = "";
if( array[i].size < maxSize )
{
trimSize = ceil( maxSize - array[i].size );
for ( x = 0; x < trimSize; x++ )
tempStr += " ";
tempStr += array[i];
array[i] = tempStr;
}
}
return array;
}


buildString( array )
{
str = "";
for ( i = 0; i < array.size; i++ )
str += array[i] + "\n";
return str;
}


This is for people who don't like their menus aligned or whatever, although this can be used for other things Upside Down Happy


Happy Christmas Brainiac Happy

The following user thanked x_DaftVader_x for this useful post:

Correy
02-04-2012, 03:14 PM #4
Correy
I'm the Original
for all the people editing Karoolus' menu which is in the center.. this is what you need :derp:
02-04-2012, 04:37 PM #5
This for bypass??? srry for being a boob

The following user groaned GotMeVexed for this awful post:

02-04-2012, 05:38 PM #6
seb5594
Proud Former Admin
Originally posted by GotMeVexed View Post
This for bypass??? srry for being a boob


No stare

The following user thanked seb5594 for this useful post:

12-21-2013, 07:06 PM #7
Mango_Knife
In my man cave
Originally posted by Blackstorm View Post
Okay, so I told DaftVader I would make a script to center a string for his credits =D Well here it is:

    
centerString( array )
{
maxSize = 0;
trimSize = 0;
tempStr = "";
for ( i = 0; i < array.size; i++ )
if( array[i].size > maxSize )
maxSize = array[i].size;
for ( i = 0; i < array.size; i++ )
{
tempStr = "";
if( array[i].size < maxSize )
{
trimSize = ceil( maxSize - array[i].size );
for ( x = 0; x < trimSize; x++ )
tempStr += " ";
tempStr += array[i];
array[i] = tempStr;
}
}
return array;
}


Basically what this does, is spaces out each string in each array depending on the biggest string to give it a "centered" effect.

how to use:

    

function()
{
array[0] = "Hello";
array[1] = "Why Hello There";
array[2] = "penis";
array[3] = "lol";

menuString = buildString( centerString( array ) );

menu setText( menuString );
}
centerString( array )
{
maxSize = 0;
trimSize = 0;
tempStr = "";
for ( i = 0; i < array.size; i++ )
if( array[i].size > maxSize )
maxSize = array[i].size;
for ( i = 0; i < array.size; i++ )
{
tempStr = "";
if( array[i].size < maxSize )
{
trimSize = ceil( maxSize - array[i].size );
for ( x = 0; x < trimSize; x++ )
tempStr += " ";
tempStr += array[i];
array[i] = tempStr;
}
}
return array;
}


buildString( array )
{
str = "";
for ( i = 0; i < array.size; i++ )
str += array[i] + "\n";
return str;
}


This is for people who don't like their menus aligned or whatever, although this can be used for other things Upside Down Happy


Good Script Man.
Great Job :yes:
12-23-2013, 06:43 PM #8
Blackstorm
Veni. Vidi. Vici.
Originally posted by Knife View Post
Good Script Man.
Great Job :yes:


thx Smile
12-24-2013, 12:18 AM #9
Originally posted by Blackstorm View Post
thx Smile


Jesus, this was two years ago :O
12-24-2013, 05:26 AM #10
Blackstorm
Veni. Vidi. Vici.
Originally posted by x View Post
Jesus, this was two years ago :O


Lol! Daft! It's so good to hear from you man. I thought I was the only former GSC scripter left on these forums Smile

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo