VSLib
Simple, powerful VScript Library for L4D2
|
Binds external data in an intuitive way. More...
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) |
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.
|
private |
Adds a flag.
|
private |
Sets the HUD slot for this object. A value between 0 through 14 (inclusive) or Valve's enums.
|
private |
Blinks the text for the specified time in seconds
|
private |
Centers the HUD object in the middle of the screen without changing its Y coordinate
|
private |
Centers the HUD object in the middle of the screen.
|
private |
Centers the HUD object in the middle of the screen without changing its X coordinate
|
private |
Repositions and resizes the HUD object natively.
|
private |
Basically combines SetPositionNative() and ResizeNative()
x | The X position to move to |
y | The Y position to move to |
width | The new width |
height | The new height |
resx | Your horizontal screen resolution (for example, 1024) |
resy | Your vertical screen resolution (for example, 768) |
|
private |
Removes the HUD panel for this object
|
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
|
private |
Gets the object's flags
|
private |
Returns the current position of the object
|
private |
Returns the current dimensions of the object
|
private |
Returns the slot of this object
|
private |
Gets the modified token string
|
private |
Get a token's value.
|
private |
Hides this object.
|
private |
Returns true if blinking.
|
private |
Returns true if this item is currently bound to a slot.
|
private |
Returns true if a flag is set.
|
private |
Returns true if this object is hidden.
|
private |
Parses the input string.
|
private |
Removes a flag.
|
private |
Resizes the HUD object
|
private |
Does practically the same thing, but this time scales for width and height proportional to a screen resolution.
width | The new width |
height | The new height |
resx | Your horizontal screen resolution (for example, 1024) |
resy | Your vertical screen resolution (for example, 768) |
|
private |
Sets the object's flags
|
private |
Sets a new format string
|
private |
Resizes the HUD object's height
|
private |
Repositions the HUD object
|
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.
x | The X position to move to |
y | The Y position to move to |
resx | Your horizontal screen resolution (for example, 1024) |
resy | Your vertical screen resolution (for example, 768) |
|
private |
Repositions the HUD object's X position
|
private |
Repositions the HUD object's Y position
|
private |
Changes the alignment of the text, e.g. TextAlign.Left or TextAlign.Center or TextAlign.Right
|
private |
Sets a token's value.
|
private |
Resizes the HUD object's width
|
private |
Shows this object.
|
private |
Shows the GUI panel for the specified time before hiding it again
|
private |
Starts blinking this object.
|
private |
Stops blinking this object.