[ScriptGL] Bottom Print

User avatar
DaJ4ck3L
Crow{OZ}
Posts: 3375
Joined: Thu Jul 22, 2010 11:51 pm
Contact:

[ScriptGL] Bottom Print

Post by DaJ4ck3L »

Is there a neat script for bottom print in SGL?

I ask because I have this awesome config, but bottom print is ruined with the hud where it is.

http://www.thelandofoz.net/shoutcast/

I was thinking of making a new bottom print function to raise it up a little above the hud, and maybe have it transparent + matching font. I could do this with the stock hud functions, but I'm not to versed in SGL.
Image
Groove
Posts: 218
Joined: Thu Apr 17, 2014 10:36 pm

Re: [ScriptGL] Bottom Print

Post by Groove »

Code: Select all

// Groovey remote for 1.4 + scriptGL
// hijacks center top and bottom prints and reformats them for scriptGl

// here be options
// font colors are set in hex RRGGBBAA
$GREMOTE::color0 = "<9fff27ff>" ; // currently set to limey greenish
$GREMOTE::color1 = "<18efd5ff>" ; // currently set to light bluey
$GREMOTE::color2 = "<ffff00ff>" ; // currently set to yellow
$GREMOTE::color3 = "<ff3131ff>" ; // currently set to reddish
$GREMOTE::font = "verdana" ; // this is a very complicated one i know
$GREMOTE::sizefont = 11 ; // this one too
$GREMOTE::BG::R = "0"; // bg color is set differently just to confuse you
$GREMOTE::BG::G = "0";
$GREMOTE::BG::B = "0";
$GREMOTE::BG::A = "205";
$GREMOTE::outline = 1 ; // do you want an outline box for lines with JC tag? 0 no 1 yes

// you probably shouldn't edit below this line
// other than maybe the outline box color that i didn't make a global var
//****************************************************************************************************************

function vhud::remoteCPHUD::create() {
	if ( $remoteCPHUD::Loaded )
		return;
		
	$remoteCPHUD::Loaded = true;

	// name, size %, position %, onrender
	vhud::create( "remoteCPHUD", "0% 0%", "0% 0%", Groove::GREMOTE::onRender );
	}

function Groove::GREMOTE (%manager, %msg, %timeout, %type) before RemoteCP 
// grab the remotecp bp tp messages and process them for scriptGL
{
	$centerPrintId++;
	$GREMOTE::visible = "true" ;
	$GREMOTE::JCTAG = 0;

	// some things use a blank message to clear the print 
	 if ( %msg == "" ) { Schedule::Add("Groove::GREMOTE::clear(" @ $centerPrintId @ ");", 0); }

	// set timeout
	if (%timeout) { Schedule::Add("Groove::GREMOTE::clear(" @ $centerPrintId @ " );", %timeout); }

	$GREMOTE::lineshigh = 1; // any time we get a msg it'll be at least one line high
	// switch to set where on the screen to draw
	switch(%type){
		case "0":
			$GREMOTE::align = "CENTER"; 
			break;
		case "1":
			$GREMOTE::align = "BOTTOM";
			break;
		case "2":
			$GREMOTE::align = "TOP";
			break;
		default:
			$GREMOTE::align = "CENTER"; 
			break;		
	}

// omg for i stuff
		%len = String::len(%msg); // get the length of the string so we know where to stop
		for (%i = 0; %i <= %len; %i++) {
		%onechar = String::GetSubStr(%msg,%i,1);

// if we find a backslash n its a carriage return, so ill use this to determine how high things should be since i always get 0 for height with glgetstringdimensions
			if (%onechar == "\n") { $GREMOTE::lineshigh++;}

// change formatting tags into scriptGL color tags and stufs			
			else if (%onechar == "<") {
				%fourchars = String::ToLower(String::GetSubStr(%msg,%i,4));
					switch(%fourchars){
						case "<f0>":
							%msg = String::Replace(%msg, "<f0>", $GREMOTE::color0); 
							break;
						case "<f1>":
							%msg = String::Replace(%msg, "<f1>", $GREMOTE::color1); 
							break;
						case "<f2>":
							%msg = String::Replace(%msg, "<f2>", $GREMOTE::color2); 
							break;
						case "<jc>":
							%msg = String::Replace(%msg, "<jc>", "" ); // center justify tag, im ignoring you because my shiz is all centered
							$GREMOTE::JCTAG = 1;
							break;
						case "<jl>":
							// right justify tag im lazy and ignoring it for now
							break;
						case "<jr>":
							break;	
						case "<l5>":
							%msg = String::Replace(%msg, "<L5>", $GREMOTE::color3); // im not sure what L5 is so im making it a color tag
							break;								
						default:
							// echoc(3, "remotecp found "~%fourchars~", probably a color tag" ); // echo other tags found jic i didn't set one but probably a colortag
							break;
					}	
			}
		}
	// lazy way to process tabs
	%msg = String::Replace(%msg, "\t", "   ");
	// make the message into a global var i can look at from other funcs
	$GREMOTE::themsg = %msg;
	// im setting this to 0 just in case for later
	$GREMOTE::sglmsgwidth = 0 ;
	// put halt here and it shouldn't call the real remoteCP
	halt;
}

function Groove::GREMOTE::clear(%id)
{ 
	if(%id == $centerPrintId) 
	$GREMOTE::visible = "false" ;
}

function Groove::GREMOTE::onrender()
{
	// if(!Control::getVisible("remoteCPHUD"))
		// return;

	if($GREMOTE::visible != "true")
		return;
		
	if($Scriptgl::CurrentGui != "playGui")
		return;

	// finds your screen resolution 
	%PGx = getWord(Control::getExtent("PlayGui"), 0);
	%PGy = getWord(Control::getExtent("PlayGui"), 1);
	%lineheight = $GREMOTE::sizefont + 6 ;
	%y = %PGy / 2 - $GREMOTE::lineshigh * %lineheight / 2 ;

	// stringdim kills FPS so i'm trying to only run it once if string changes
	if ($GREMOTE::sglmsgwidth == 0 && String::len($GREMOTE::themsg) > 0 ) {
		 glSetFont( $GREMOTE::font, $GREMOTE::sizefont, 0, 9 );
		 $GREMOTE::sglmsgwidth = ScriptGL::StringDim( ScriptGL::StripColorTags($GREMOTE::themsg) );
		 }
	
	%x = %PGx / 2 - $GREMOTE::sglmsgwidth / 2 ; 
	
	switch( $GREMOTE::align ){
		case "CENTER":
			 %y = %PGy / 2 - $GREMOTE::lineshigh * %lineheight / 2 ;
			break;
		case "BOTTOM":
			%y = %PGy * 0.9 - $GREMOTE::lineshigh * %lineheight ;
			break;
		case "TOP":
			%y = %PGy * 0.2 ;
			break;
		default:
			%y = %PGy / 2 - $GREMOTE::lineshigh * %lineheight / 2 ;
			break;		
	}

// reset the matrix
	glLoadIdentity();

// GL texture environment stuf
	glDisable($GL_TEXTURE_2D);
	glDisable($GL_SCISSOR_TEST);
	glDisable($GL_ALPHA_TEST);

// uses a blue outlined box for messages with the JC tag.
	if ($GREMOTE::JCTAG && $GREMOTE::outline) {
	glColor4ub( 0, 0, 255, 210 ); // this is the color of the outline box, feel free to change it
	glRectangle( %x -2 , %y -2 , $GREMOTE::sglmsgwidth*1.05 + 4 , $GREMOTE::lineshigh* %lineheight + 4 );
	}

// background box	
	glColor4ub( $GREMOTE::BG::R,$GREMOTE::BG::G,$GREMOTE::BG::B,$GREMOTE::BG::A ); 
	glRectangle( %x, %y, $GREMOTE::sglmsgwidth*1.05 , $GREMOTE::lineshigh* %lineheight );

// set font and draw text
	glColor4ub(255,255,255,255);
	glSetFont( $GREMOTE::font, $GREMOTE::sizefont, 0, 9 );
	glDrawString(%x, %y + 2, $GREMOTE::themsg );
}

vhud::remoteCPHUD::create();
User avatar
DaJ4ck3L
Crow{OZ}
Posts: 3375
Joined: Thu Jul 22, 2010 11:51 pm
Contact:

Re: [ScriptGL] Bottom Print

Post by DaJ4ck3L »

sweeeeeet, u the man!!!!
Image
Groove
Posts: 218
Joined: Thu Apr 17, 2014 10:36 pm

Re: [ScriptGL] Bottom Print

Post by Groove »

it could probably use a bit of tweaking but it works

i didn't really notice problems with it but i think when i joined the anni server one of the join message lines got cut off
D4M45T3R
Posts: 69
Joined: Sun May 11, 2014 7:15 am

Re: [ScriptGL] Bottom Print

Post by D4M45T3R »

considering storks hud fonts are thick you should try setting antialiasing to the max in your graphic card menu. imho it really improves the game & in this case hud will look ok because of the bold font.
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: [ScriptGL] Bottom Print

Post by perrinoia »

The join message is always on top of the loading image, for me... So I've never been able to read it, anyway.
Image
User avatar
DaJ4ck3L
Crow{OZ}
Posts: 3375
Joined: Thu Jul 22, 2010 11:51 pm
Contact:

Re: [ScriptGL] Bottom Print

Post by DaJ4ck3L »

missing a function.

ScriptGL::StripColorTags: Unknown command.

Code: Select all

// Groovey remote for 1.4 + scriptGL
// hijacks center top and bottom prints and reformats them for scriptGl

// here be options
// font colors are set in hex RRGGBBAA
$GREMOTE::color0 = "<d68a00ff>" ; // currently set to dark tan
$GREMOTE::color1 = "<ffd07bff>" ; // currently set to light tan
$GREMOTE::color2 = "<ffffffff>" ; // currently set to white
$GREMOTE::color3 = "<ff0000ff>" ; // currently set to reddish
$GREMOTE::font = "Jet Set" ; // this is a very complicated one i know
$GREMOTE::sizefont = 14 ; // this one too
$GREMOTE::BG::R = "0"; // bg color is set differently just to confuse you
$GREMOTE::BG::G = "0";
$GREMOTE::BG::B = "0";
$GREMOTE::BG::A = "205";

// you probably shouldn't edit below this line
// other than maybe the outline box color that i didn't make a global var
//****************************************************************************************************************

function vhud::remoteCPHUD::create() {
   if ( $remoteCPHUD::Loaded )
      return;
      
   $remoteCPHUD::Loaded = true;

   // name, size %, position %, onrender
   vhud::create( "remoteCPHUD", "0% 0%", "0% 0%", Groove::GREMOTE::onRender );
   }

function Groove::GREMOTE (%manager, %msg, %timeout, %type) before RemoteCP
// grab the remotecp bp tp messages and process them for scriptGL
{
	if(%type != 1) //just have it check bottom print for this config -DaJ4ck3L
	{
		$GREMOTE::visible = "false" ;
		return;
	}
		
		
   $bottomPrintId++;
   $GREMOTE::visible = "true" ;
   $GREMOTE::JCTAG = 0;
   $GREMOTE::JCWidth = 0;

   // some things use a blank message to clear the print
    if ( %msg == "" ) { Schedule::Add("Groove::GREMOTE::clear(" @ $bottomPrintId @ ");", 0); }

   // set timeout
   if (%timeout) { Schedule::Add("Groove::GREMOTE::clear(" @ $bottomPrintId @ " );", %timeout); }

   $GREMOTE::lineshigh = 1; // any time we get a msg it'll be at least one line high
   // switch to set where on the screen to draw
   switch(%type){
      case "0":
         $GREMOTE::align = "CENTER";
         break;
      case "1":
         $GREMOTE::align = "BOTTOM";
         break;
      case "2":
         $GREMOTE::align = "TOP";
         break;
      default:
         $GREMOTE::align = "CENTER";
         break;      
   }

// omg for i stuff
      %len = String::len(%msg); // get the length of the string so we know where to stop
      for (%i = 0; %i <= %len; %i++) {
      %onechar = String::GetSubStr(%msg,%i,1);

// if we find a backslash n its a carriage return, so ill use this to determine how high things should be since i always get 0 for height with glgetstringdimensions
         if (%onechar == "\n") { $GREMOTE::lineshigh++;}

// change formatting tags into scriptGL color tags and stufs         
         else if (%onechar == "<") {
            %fourchars = String::ToLower(String::GetSubStr(%msg,%i,4));
               switch(%fourchars){
                  case "<f0>":
                     %msg = String::Replace(%msg, "<f0>", $GREMOTE::color0);
                     break;
                  case "<f1>":
                     %msg = String::Replace(%msg, "<f1>", $GREMOTE::color1);
                     break;
                  case "<f2>":
                     %msg = String::Replace(%msg, "<f2>", $GREMOTE::color2);
                     break;
                  case "<jc>":
                     %msg = String::Replace(%msg, "<jc>", "" ); // center justify tag, im ignoring you because my shiz is all centered
                     $GREMOTE::JCTAG = 1;
                     break;
                  case "<jl>":
                     // right justify tag im lazy and ignoring it for now
                     break;
                  case "<jr>":
                     break;   
                  case "<l5>":
                     %msg = String::Replace(%msg, "<L5>", $GREMOTE::color3); // im not sure what L5 is so im making it a color tag
                     break;                        
                  default:
                     // echoc(3, "remotecp found "~%fourchars~", probably a color tag" ); // echo other tags found jic i didn't set one but probably a colortag
                     break;
               }   
         }
      }
   // lazy way to process tabs
   %msg = String::Replace(%msg, "\t", "   ");
   // make the message into a global var i can look at from other funcs
   $GREMOTE::themsg = %msg;
   // get a number so we can slide text over, crows ghetto rig..
   %len = String::len(%msg); 
    for (%i = 0; %i <= %len; %i++) {
		%onechar = String::GetSubStr(%msg,%i,1);
		if (%onechar == "\n") { break;}
		$GREMOTE::JCWidth++;
	  }   
   // im setting this to 0 just in case for later
   $GREMOTE::sglmsgwidth = 0 ;
   // put halt here and it shouldn't call the real remoteCP
   halt;
}

function Groove::GREMOTE::clear(%id)
{
   if(%id == $bottomPrintId)
   $GREMOTE::visible = "false" ;
}

function Groove::GREMOTE::onrender()
{
   // if(!Control::getVisible("remoteCPHUD"))
      // return;

   if($GREMOTE::visible != "true")
      return;
      
   if($Scriptgl::CurrentGui != "playGui")
      return;

   // finds your screen resolution
   %PGx = getWord(Control::getExtent("PlayGui"), 0);
   %PGy = getWord(Control::getExtent("PlayGui"), 1);
   %lineheight = $GREMOTE::sizefont + 6 ;
   %y = %PGy / 2 - $GREMOTE::lineshigh * %lineheight / 2 ;

   // stringdim kills FPS so i'm trying to only run it once if string changes
   if ($GREMOTE::sglmsgwidth == 0 && String::len($GREMOTE::themsg) > 0 ) {
       glSetFont( $GREMOTE::font, $GREMOTE::sizefont, 0, 9 );
       $GREMOTE::sglmsgwidth = ScriptGL::StringDim( ScriptGL::StripColorTags($GREMOTE::themsg) ); //missing function ScriptGL::StripColorTags
       }
   
   %x = %PGx / 2 - $GREMOTE::sglmsgwidth / 2 ;
   
   switch( $GREMOTE::align ){
      case "CENTER":
          %y = %PGy / 2 - $GREMOTE::lineshigh * %lineheight / 2 ;
         break;
      case "BOTTOM":
         %y = %PGy * 0.9 - $GREMOTE::lineshigh * %lineheight ;
         break;
      case "TOP":
         %y = %PGy * 0.2 ;
         break;
      default:
         %y = %PGy / 2 - $GREMOTE::lineshigh * %lineheight / 2 ;
         break;      
   }

// reset the matrix
   glLoadIdentity();

// GL texture environment stuf
   glDisable($GL_TEXTURE_2D);
   glDisable($GL_SCISSOR_TEST);
   glDisable($GL_ALPHA_TEST);

// changed this for better center print -DaJ4ck3L
// set font and draw text
	Client::centerPrint("", 0); //clear old
	glColor4ub(255,255,255,255);
	glSetFont( $GREMOTE::font, $GREMOTE::sizefont, 0, 9 );
	glDrawString(%x - $GREMOTE::JCWidth*3.14, %y + 2, $GREMOTE::themsg );
}

vhud::remoteCPHUD::create();
here's what i got so far. this method for centering the text is not the best lol.
Attachments
bpct.jpg
Image
Groove
Posts: 218
Joined: Thu Apr 17, 2014 10:36 pm

Re: [ScriptGL] Bottom Print

Post by Groove »

yeah lemme look for that func, it's probably part of vhudmover

either that or u dont have all the scriptGL support stuff but it's probably the first thing

once i got vhudmover working i kinda abandoned those older, fixed-sized scriptGL huds but that gremote script was one of the few i didn't convert because its annoyingly complex for something that should be really simple
Groove
Posts: 218
Joined: Thu Apr 17, 2014 10:36 pm

Re: [ScriptGL] Bottom Print

Post by Groove »

ya its part of vhudmover

download here
http://www.tribalwar.com/forums/showthread.php?t=660707

(that particular func is in H.ScriptGLSupport.acs)

those true vhuds are really the sweetest way to do scriptGL stuff since it's so easy to resize and it auto-adjusts to any resolution

and even if u dont use true vhuds it does have some useful addon scriptGL funcs (including stuff for centered text altho i dont think ive tried it)
User avatar
DaJ4ck3L
Crow{OZ}
Posts: 3375
Joined: Thu Jul 22, 2010 11:51 pm
Contact:

Re: [ScriptGL] Bottom Print

Post by DaJ4ck3L »

yea ill need to check out the centered text. as you cane see above this script centers the text, but starts it at the center point as well lol. i did a ghetto rig to move it over based on how long the first line is, but the number of letters in a line don't equal pixel size, so it's not perfect.
Image
Post Reply