Post: Center Menus/String C# Script (Every CoD)
11-19-2013, 12:43 AM #1
seb5594
Proud Former Admin
(adsbygoogle = window.adsbygoogle || []).push({}); Hey NGU,
i saw today a old Thread by Blackstorm and i thought i port it from GSC to C# cause it may be usefull for Menus.
You must login or register to view this content.
It took me 5 mins of my life to do it so enjoy :derp:


What it do?
Originally posted by Blackstorm View Post
Basically what this does, is spaces out each string in each array depending on the biggest string to give it a "centered" effect.


The Script:
    
public String[] centerString(String[] StringArray)
{
Int32 maxSize = 0;
Int32 trimSize = 0;
String tempStr = "";
for (Int32 i = 0; i < StringArray.Length; i++)
{
if (StringArray[i].Length > maxSize)
maxSize = StringArray[i].Length;
}
for(Int32 i = 0; i < StringArray.Length;i++)
{
tempStr = "";
if (StringArray[i].Length < maxSize)
{
trimSize = maxSize - StringArray[i].Length;
for (Int32 x = 0; x < trimSize; x++)
tempStr += " ";
}
tempStr += StringArray[i];
StringArray[i] = tempStr;
}
return StringArray;
}
public String buildString(String[] StringArray)
{
String str = "";
for (Int32 i = 0; i < StringArray.Length; i++)
str += StringArray[i] + "\n";
return str;
}


How to use? i created a test function to show it.
            public void TestCenterString()
{
String[] MyMenutext = new String[]
{
"Hello",//Original Text from Blackstorm lol
"Why Hello There",
"penis",
"lol"
};
String TestString = buildString(centerString(MyMenutext));
MessageBox.Show(TestString);
}


The Result:
You must login or register to view this content.
The Text need to be a Array!

Please give Credits if you use this Function Smile

Credits:
Blackstorm - Original GSC Script
seb5594 - Porting this to C#
Last edited by seb5594 ; 11-19-2013 at 12:46 AM.

The following 17 users say thank you to seb5594 for this useful post:

-Elmas15-, Ansity., BaSs_HaXoR, Blackstorm, ImPiffHD, INSAN3LY_D34TH, Mango_Knife, John, Notorious, RAV-_-MALWA, ROBERT_ROWL_, Script Kiddie, SnaY, Sticky, Whos Your Host, xBeaTzMoDz, Fatality
11-19-2013, 05:05 PM #2
Originally posted by seb5594 View Post
Hey NGU,
i saw today a old Thread by Blackstorm and i thought i port it from GSC to C# cause it may be usefull for Menus.
You must login or register to view this content.
It took me 5 mins of my life to do it so enjoy :derp:


What it do?


The Script:
    
public String[] centerString(String[] StringArray)
{
Int32 maxSize = 0;
Int32 trimSize = 0;
String tempStr = "";
for (Int32 i = 0; i < StringArray.Length; i++)
{
if (StringArray[i].Length > maxSize)
maxSize = StringArray[i].Length;
}
for(Int32 i = 0; i < StringArray.Length;i++)
{
tempStr = "";
if (StringArray[i].Length < maxSize)
{
trimSize = maxSize - StringArray[i].Length;
for (Int32 x = 0; x < trimSize; x++)
tempStr += " ";
}
tempStr += StringArray[i];
StringArray[i] = tempStr;
}
return StringArray;
}
public String buildString(String[] StringArray)
{
String str = "";
for (Int32 i = 0; i < StringArray.Length; i++)
str += StringArray[i] + "\n";
return str;
}


How to use? i created a test function to show it.
            public void TestCenterString()
{
String[] MyMenutext = new String[]
{
"Hello",//Original Text from Blackstorm lol
"Why Hello There",
"penis",
"lol"
};
String TestString = buildString(centerString(MyMenutext));
MessageBox.Show(TestString);
}


The Result:
You must login or register to view this content.
The Text need to be a Array!

Please give Credits if you use this Function Smile

Credits:
Blackstorm - Original GSC Script
seb5594 - Porting this to C#


Great release man ill use this Smile
11-19-2013, 08:31 PM #3
seb5594
Proud Former Admin
Originally posted by DM
Great release man ill use this Smile


No problem Smile
Hope to see some centered Menus in the future

The following user thanked seb5594 for this useful post:

Whos Your Host
11-20-2013, 09:48 AM #4
Thanks for the post Smile
11-23-2013, 05:43 AM #5
Blackstorm
Veni. Vidi. Vici.
Can't even understand my own code anymore. Well done though. Claps

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

INSAN3LY_D34TH, Fatality
11-23-2013, 10:02 PM #6
seb5594
Proud Former Admin
Originally posted by Blackstorm View Post
Can't even understand my own code anymore. Well done though. Claps


lmao thanks never thought you will see this thread Smile
You stopped with coding?
11-24-2013, 07:08 AM #7
Blackstorm
Veni. Vidi. Vici.
Originally posted by seb5594 View Post
lmao thanks never thought you will see this thread Smile
You stopped with coding?


yeah man, it's been like a whole year already!

The following user thanked Blackstorm for this useful post:

12-21-2013, 11:27 AM #8
TeAz
Banned
Not bad Happy
03-31-2014, 12:08 AM #9
Notorious
Caprisuns Is Back
Originally posted by seb5594 View Post
Hey NGU,
i saw today a old Thread by Blackstorm and i thought i port it from GSC to C# cause it may be usefull for Menus.
You must login or register to view this content.
It took me 5 mins of my life to do it so enjoy :derp:


What it do?


The Script:
    
public String[] centerString(String[] StringArray)
{
Int32 maxSize = 0;
Int32 trimSize = 0;
String tempStr = "";
for (Int32 i = 0; i < StringArray.Length; i++)
{
if (StringArray[i].Length > maxSize)
maxSize = StringArray[i].Length;
}
for(Int32 i = 0; i < StringArray.Length;i++)
{
tempStr = "";
if (StringArray[i].Length < maxSize)
{
trimSize = maxSize - StringArray[i].Length;
for (Int32 x = 0; x < trimSize; x++)
tempStr += " ";
}
tempStr += StringArray[i];
StringArray[i] = tempStr;
}
return StringArray;
}
public String buildString(String[] StringArray)
{
String str = "";
for (Int32 i = 0; i < StringArray.Length; i++)
str += StringArray[i] + "\n";
return str;
}


How to use? i created a test function to show it.
            public void TestCenterString()
{
String[] MyMenutext = new String[]
{
"Hello",//Original Text from Blackstorm lol
"Why Hello There",
"penis",
"lol"
};
String TestString = buildString(centerString(MyMenutext));
MessageBox.Show(TestString);
}


The Result:
You must login or register to view this content.
The Text need to be a Array!

Please give Credits if you use this Function Smile

Credits:
Blackstorm - Original GSC Script
seb5594 - Porting this to C#


Im gonna use this for my bo2 menu :yes:

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo