VSLib
Simple, powerful VScript Library for L4D2
 All Classes Namespaces Files Functions Pages
VSLib.HUD.Item Class Reference

Binds external data in an intuitive way. More...

Inheritance diagram for VSLib.HUD.Item:
VSLib.HUD.Bar VSLib.HUD.Countdown VSLib.HUD.Menu

Private Member Functions

void SetFormatString (string formatStr)
 
void SetValue (string key, object value)
 
string GetValue (string key)
 
string GetString ()
 
void AttachTo (int hudtype)
 
void Detach ()
 
bool IsBound ()
 
int GetFlags ()
 
void SetFlags (int newFlags)
 
void SetTextPosition (int alignFlag)
 
void StopBlinking ()
 
void StartBlinking ()
 
bool IsBlinking ()
 
void Hide ()
 
void Show ()
 
bool IsHidden ()
 
void AddFlag (int flag)
 
void RemoveFlag (int flag)
 
void IsFlagSet (int flag)
 
int GetSlot ()
 
void Resize (float width, float height)
 
void SetWidth (float width)
 
void SetHeight (float height)
 
void SetPosition (float x, float y)
 
void SetPositionX (float x)
 
void SetPositionY (float y)
 
void ChangeHUD (float x, float y, float width, float height)
 
void CenterHorizontal ()
 
void CenterVertical ()
 
void CenterScreen ()
 
void BlinkTime (double seconds)
 
void ShowTime (double seconds, bool detachAfter=false)
 
object[] GetPosition ()
 
object[] GetSize ()
 
object[] GetCenterPoint ()
 
void SetPositionNative (int x, int y, int resx, int resy)
 
void ResizeNative (int width, int height, int resx, int resy)
 
void ChangeHUDNative (int x, int y, int width, int height, int resx, int resy)
 
string ParseString (string str)
 

Detailed Description

Binds external data in an intuitive way.

Suppose you want to display "[some_player] killed [another_player]". E.g. "Luke killed Tiger!" To do that, you can pass in the following specifier:

HUD.Item someVariable ( "{1} killed {2}!", "Luke", "Tiger" );

The {n} specifies the argument number. "Luke" is the first argument, and "Tiger" is the second argument. If you wanted to change the format string to say "Tiger was killed by Luke!", you simply have to change the order like so:

HUD.Item someVariable ( "{2} was killed by {1}!", "Luke", "Tiger" );

You can also get fancy by using SetValue() directly without passing in any default arguments. Here's an example:

HUD.Item someVariable ( "{Victim} was killed by {Attacker}!" ); someVariable.SetValue ( "Attacker", "Luke" ); someVariable.SetValue ( "Victim", "Tiger" );

See the API documentation for in-depth examples and how-to.

Member Function Documentation

void VSLib.HUD.Item.AddFlag ( int  flag)
private

Adds a flag.

void VSLib.HUD.Item.AttachTo ( int  hudtype)
private

Sets the HUD slot for this object. A value between 0 through 14 (inclusive) or Valve's enums.

void VSLib.HUD.Item.BlinkTime ( double  seconds)
private

Blinks the text for the specified time in seconds

void VSLib.HUD.Item.CenterHorizontal ( )
private

Centers the HUD object in the middle of the screen without changing its Y coordinate

void VSLib.HUD.Item.CenterScreen ( )
private

Centers the HUD object in the middle of the screen.

void VSLib.HUD.Item.CenterVertical ( )
private

Centers the HUD object in the middle of the screen without changing its X coordinate

void VSLib.HUD.Item.ChangeHUD ( float  x,
float  y,
float  width,
float  height 
)
private

Repositions and resizes the HUD object natively.

void VSLib.HUD.Item.ChangeHUDNative ( int  x,
int  y,
int  width,
int  height,
int  resx,
int  resy 
)
private
See also
SetPositionNative
ResizeNative

Basically combines SetPositionNative() and ResizeNative()

Parameters
xThe X position to move to
yThe Y position to move to
widthThe new width
heightThe new height
resxYour horizontal screen resolution (for example, 1024)
resyYour vertical screen resolution (for example, 768)
void VSLib.HUD.Item.Detach ( )
private

Removes the HUD panel for this object

object [] VSLib.HUD.Item.GetCenterPoint ( )
private

Returns the center point of the HUD object. The returned table consists of an x value and a y value. For example:

local test = item.GetCenterPoint(); if (test.x == 0.5 && test.y == 0.2) ... // etc

int VSLib.HUD.Item.GetFlags ( )
private

Gets the object's flags

object [] VSLib.HUD.Item.GetPosition ( )
private

Returns the current position of the object

Returns
A table with keys: x and y
object [] VSLib.HUD.Item.GetSize ( )
private

Returns the current dimensions of the object

Returns
A table with keys: width and height
int VSLib.HUD.Item.GetSlot ( )
private

Returns the slot of this object

string VSLib.HUD.Item.GetString ( )
private

Gets the modified token string

string VSLib.HUD.Item.GetValue ( string  key)
private

Get a token's value.

void VSLib.HUD.Item.Hide ( )
private

Hides this object.

bool VSLib.HUD.Item.IsBlinking ( )
private

Returns true if blinking.

bool VSLib.HUD.Item.IsBound ( )
private

Returns true if this item is currently bound to a slot.

void VSLib.HUD.Item.IsFlagSet ( int  flag)
private

Returns true if a flag is set.

bool VSLib.HUD.Item.IsHidden ( )
private

Returns true if this object is hidden.

string VSLib.HUD.Item.ParseString ( string  str)
private

Parses the input string.

void VSLib.HUD.Item.RemoveFlag ( int  flag)
private

Removes a flag.

void VSLib.HUD.Item.Resize ( float  width,
float  height 
)
private

Resizes the HUD object

void VSLib.HUD.Item.ResizeNative ( int  width,
int  height,
int  resx,
int  resy 
)
private
See also
SetPositionNative

Does practically the same thing, but this time scales for width and height proportional to a screen resolution.

Parameters
widthThe new width
heightThe new height
resxYour horizontal screen resolution (for example, 1024)
resyYour vertical screen resolution (for example, 768)
void VSLib.HUD.Item.SetFlags ( int  newFlags)
private

Sets the object's flags

void VSLib.HUD.Item.SetFormatString ( string  formatStr)
private

Sets a new format string

void VSLib.HUD.Item.SetHeight ( float  height)
private

Resizes the HUD object's height

void VSLib.HUD.Item.SetPosition ( float  x,
float  y 
)
private

Repositions the HUD object

void VSLib.HUD.Item.SetPositionNative ( int  x,
int  y,
int  resx,
int  resy 
)
private

It can be difficult to think in terms of a fraction (0.0 - 1.0), so this function attempts to scale native screen resolution positions to VGUI positions. For example, if you have a 1600 x 900 res screen, and you want to move the object to x = 400 and y = 300, this function will convert these coordinates to fractions between 0.0 - 1.0. The resulting movement should be the same in all screen resolutions because the calculations are proportional.

Parameters
xThe X position to move to
yThe Y position to move to
resxYour horizontal screen resolution (for example, 1024)
resyYour vertical screen resolution (for example, 768)
void VSLib.HUD.Item.SetPositionX ( float  x)
private

Repositions the HUD object's X position

void VSLib.HUD.Item.SetPositionY ( float  y)
private

Repositions the HUD object's Y position

void VSLib.HUD.Item.SetTextPosition ( int  alignFlag)
private

Changes the alignment of the text, e.g. TextAlign.Left or TextAlign.Center or TextAlign.Right

void VSLib.HUD.Item.SetValue ( string  key,
object  value 
)
private

Sets a token's value.

void VSLib.HUD.Item.SetWidth ( float  width)
private

Resizes the HUD object's width

void VSLib.HUD.Item.Show ( )
private

Shows this object.

void VSLib.HUD.Item.ShowTime ( double  seconds,
bool  detachAfter = false 
)
private

Shows the GUI panel for the specified time before hiding it again

void VSLib.HUD.Item.StartBlinking ( )
private

Starts blinking this object.

void VSLib.HUD.Item.StopBlinking ( )
private

Stops blinking this object.


The documentation for this class was generated from the following file: