Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Plugins & Mods

Quests::Plugins & Mods Completed plugins for public use as well as modifications.

Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2010, 03:41 PM
Akkadius's Avatar
Akkadius
Administrator
 
Join Date: Feb 2009
Location: MN
Posts: 2,071
Default Popup Window Auto Center

Alright, I wanted to make a post for this considering I am going to be making a big cheat sheet list of plugins and I want to be able to refer to this example for this exact function since it does more than one thing, it does quite a bit for just one function.

This is the plugin usage:

Code:
###plugin::PWAutoCenter("Text to be centered in popup window", ([Send Character length to window? = 1] [Use AutoCenter based on given character length = 2]));
###If the second arguement is 2, the first arguement has to declare how many characters there are in the line you are presenting. And then it will push the 
###Appropriate amount of spaces. IE plugin::PWAutoCenter(56, 2); for example
Let's say you wanted to simply center one phrase on a line into a popup window WITHOUT colors or anything fancy. Then you would do it just like it is mentioned in the other thread like this (Highlighted in Yellow)

Code:
sub EVENT_SAY{
	if($text=~/hail/i){
	my $TextToCenter = plugin::PWAutoCenter("This is the text I want to be centered");
	my $TextToCenter2 = plugin::PWAutoCenter("2nd line to be centered");
	my $TextToCenter3 = plugin::PWAutoCenter("3rd line");
	my $TextToCenter4 = plugin::PWAutoCenter("4th line to be centered");
	my $TextToCenter5 = plugin::PWAutoCenter("5th line to be centered, blah, blah, blah, blah, blah");
	my $Indent = plugin::PWIndent();
	my $Link = plugin::PWHyperLink("http://www.google.com", "Google Search it!");
	my $Yel = plugin::PWColor("Yellow");
	my $Blu = plugin::PWColor("Light Blue");
	my $Red = plugin::PWColor("Red");
	my $grn = plugin::PWColor("Forest Green");
	quest::popup("Test", "$TextToCenter <br>
	$Yel $TextToCenter2 </c> <br>
	$Blu $TextToCenter3 </c> <br>
	<br><br>
	$Red $TextToCenter4 </c> <br>
	$grn $TextToCenter5 </c> <br><br><br>
	$Indent $Link
	");
	}
}
That would give you this as a result:


Now the method above works fine, if you have pure raw text to just throw into the plugin. BUT if you want to have two different phrases or words centered together and be DIFFERENT colors, then we start to have a problem because color codes interfere with how the spaces are counted.

SO, I made an optional arguement for this function that will autogenerate spaces for you. Let me start by giving an example. Now before I begin, I must say that this may look like a pain, but really, it is SOOOO much easier than trying to format windows manually with a ton of spaces crapping up your perl script. Let me demonstrate.

I am going to start with a very basic line.

Code:
sub EVENT_SAY{
	if($text=~/hail/i){
	quest::popup("Test", "I am going to start with a very basic line");
	}
}


Let's say I wanted to color different parts of this line. But if I were to put color codes inside of the center plugin it would throw off the centering script.

So I would do it like this, let me tell you this will be put back into the popup window, this is simply to use the character measuring part of the script.

Code:
sub EVENT_SAY{
	if($text=~/hail/i){
	my $TextToCenter = plugin::PWAutoCenter("I am going to start with a very basic line", 1);
	quest::popup("Test", "$TextToCenter");
	}
}
Notice the yellow 1 in this arguement, this tells the plugin that you want to count the amount of characters in the plugin, it will show up in your window like this:



Since it has given you the amount of characters, you can use that number for arguement two for the plugin. Like this:

Code:
sub EVENT_SAY{
	if($text=~/hail/i){
	my $Space1 = plugin::PWAutoCenter(19.4, 2);
	quest::popup("Test", "$Space1 I am going to start with a very basic line");
	}
}
I excluded an image of the preview above because I am limited to 4 images per post. It looks like the image below without the colors.

And now that $Space1 knows how many spaces to give the amount of characters in your line, you can now start adding your colors so it does not throw off the centering process.

Code:
sub EVENT_SAY{
	if($text=~/hail/i){
	my $Space1 = plugin::PWAutoCenter(19.4, 2);
	my $Col1 = plugin::PWColor("Light Blue");
	my $Col2 = plugin::PWColor("Gold2");
	my $Col3 = plugin::PWColor("Firebrick3");
	quest::popup("Test", "$Space1 $Col1 I am going to </c> $Col2 start with a </c> $Col3 very basic line </c>");
	}
}


You can also skip the whole step 1 of the plugin and just start putting in a number and adding to it or subtracting to it to see immediate output in your window. It simply auto creates spaces for you which in itself can be very useful.


For more information on colors, you can find more detail of the plugin function in this post:

http://www.eqemulator.org/forums/showthread.php?t=32624

I hope this makes peoples lives much easier trying to use these cause it does and has for me.


These are available in the repository, see the sticky thread here

http://www.eqemulator.org/forums/showthread.php?t=32608
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 08:34 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3