Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Simple vSpeedHUD for Tribes 1.40 w/GreyHounds ScriptGL
- // modeled after the example scripts included with ScriptGL
- function vhud::SpeedHUD::create()
- {
- // if this hud is already loaded, stop here
- if ( $vSpeedHUD::Loaded )
- return;
- // a stupid global variable that says this hud is loaded
- $vSpeedHUD::Loaded = true;
- // create a scriptGL hud - configs without vhudmover ignore all but the first and last of these vars
- vhud::create( "ScriptGL::vSpeedHUD", "0% 0%", "0% 0%", vhud::vSpeedHUD::onrender );
- // create a native tribes hud so you have something to drag with the stock hudmover
- // HUD::New("hud name here", positionX, positionY, ExtentX, ExtentY, wakefunction, sleepfunction)
- HUD::New("ScriptGL::vSpeedHUD", 365, 0, 88, 20, vSpeed::WakeSleep, vSpeed::WakeSleep);
- }
- // normal huds go to 'sleep' when you tab out - we just have a blank function here to avoid console errors :P
- function vSpeed::WakeSleep() { }
- // the ScriptGL hud
- function vhud::vSpeedHUD::onrender()
- {
- // dont draw anywhere but playGui (ingame)
- if($Scriptgl::CurrentGui != "playGui")
- return;
- // dont draw if set to hidden
- if(!Control::getVisible("ScriptGL::vSpeedHUD"))
- return;
- // local variables to find where our hud is so we know where to draw stuff
- %pos = Control::getposition("ScriptGL::vSpeedHUD");
- %position[x] = getWord(%pos,0);
- %position[y] = getWord(%pos,1);
- %size = Control::getExtent("ScriptGL::vSpeedHUD");
- %size[x] = getWord(%size,0);
- %size[y] = getWord(%size,1);
- // i think this is like the red pill that resets the GL matrix
- glLoadIdentity();
- // setup GL options
- glDisable($GL_TEXTURE_2D);
- glDisable($GL_SCISSOR_TEST);
- glEnable($GL_ALPHA_TEST);
- glBlendFunc($GL_SRC_ALPHA,$GL_ONE_MINUS_SRC_ALPHA);
- glAlphaFunc($GL_GREATER,$GL_ZERO);
- // this is the color and opacity of the background box in RGBA 0-255
- glColor4ub( 0, 0, 0, 150 );
- // this is the background box - should draw as big as the extent settings in our original HUD::New
- glBegin($GL_QUADS);
- glVertex2f(%position[x] , %position[y]);
- glVertex2f(%position[x] + %size[x], %position[y]);
- glVertex2f(%position[x] + %size[x], %position[y] + %size[y]);
- glVertex2f(%position[x] , %position[y] + %size[y]);
- glEnd();
- // font and size
- glSetFont( "calibri", 14, 0, 9 );
- // font draw color in R,G,B,A 0-255
- glColor4ub( 255, 255, 255, 255 );
- // draw the word 'Speed: ' at whatever position in the hud. in this case it's 2 pixels to the right and 2 down
- glDrawString(%position[x] + 2,%position[y] + 2, "Speed: " );
- // draw the value of $speed 55 pixels to the right and 2 down
- glDrawString(%position[x] + 55, %position[y] + 2, $Speed );
- }
- vhud::SpeedHUD::create();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement