Angel 3.2
A 2D Game Prototyping Engine
Public Member Functions | Static Public Member Functions | List of all members
Tuning Class Reference

The class which handles getting and setting tuning variables. More...

#include <TuningVariable.h>

Public Member Functions

StringSet GetVariables ()
 
int GetInt (const String &name)
 
float GetFloat (const String &name)
 
String GetString (const String &name)
 
Vector2 GetVector (const String &name)
 
void SetInt (const String &name, int val)
 
void SetFloat (const String &name, float val)
 
void SetString (const String &name, const String &val)
 
void SetVector (const String &name, const Vector2 &val)
 
void AddToRuntimeTuningList (const String &varName)
 
bool IsRuntimeTuned (const String &varName)
 

Static Public Member Functions

static TuningGetInstance ()
 

Detailed Description

This class is used to handle housekeeping of variables you'll want to manually change at runtime to affect the way your game plays. A good example is the height a character can jump – you might declare this as a tuning variable in the Config/tuning.ini, change it from the console using the tune() function, and then call SaveTuningVariables() from the console to save the new value back into the file.

Some people find it helpful to bind certain tuning functions to keypresses while they're tuning, so you could increase or decrease a certain tuning variable with the arrow keys, for instance.

It's also possible to declare new tuning variables at runtime and do all sorts of crazy things. Go nuts!

Definition at line 54 of file TuningVariable.h.

Member Function Documentation

Tuning & Tuning::GetInstance ( )
static

Used to access the singleton instance of this class. As a shortcut, you can just use "theTuning".

Returns
The singleton

Definition at line 35 of file TuningVariable.cpp.

StringSet Tuning::GetVariables ( )

Get a list of the currently declared tuning variables. This only gives you a set of variable names; you'll have to look up the values if you want them.

Returns
The set of strings representing the variable names.

Definition at line 49 of file TuningVariable.cpp.

int Tuning::GetInt ( const String &  name)

Get an integer representation of a tuning variable. The engine will do its best to convert declared values into reasonable integer representations, and will return 0 if it can't or if the variable has not been declared.

Parameters
nameThe name of the variable
Returns
Its integer representation

Definition at line 61 of file TuningVariable.cpp.

float Tuning::GetFloat ( const String &  name)

Get a floating point representation of a tuning variable. The engine will do its best to convert declared values into reasonable float representations, and will return 0.0f if it can't or if the variable has not been declared.

Parameters
nameThe name of the variable
Returns
Its floating point representation

Definition at line 71 of file TuningVariable.cpp.

String Tuning::GetString ( const String &  name)

Get a string representation of a tuning variable. If the variable was declared as another type, you'll still get a string representation of the value. Returns an empty string if the variable has not been declared.

Parameters
nameThe name of the variable
Returns
Its string representation

Definition at line 81 of file TuningVariable.cpp.

Vector2 Tuning::GetVector ( const String &  name)

Get a Vector2 representation of a tuning variable. This guy is pretty much the odd man out in terms of conversions, since there's no obvious default way to convert between the different types and a 2d vector. Returns a zero-length vector if you haven't actually set a vector to this variable or if the variable has not been declared.

Parameters
nameThe name of the variable
Returns
Its Vector2 representation

Definition at line 91 of file TuningVariable.cpp.

void Tuning::SetInt ( const String &  name,
int  val 
)

Change a tuning variable's value to a new integer. The Set* functions are also how you declare new tuning variables.

Parameters
nameThe name of the variable to change
valThe new integer value

Definition at line 101 of file TuningVariable.cpp.

void Tuning::SetFloat ( const String &  name,
float  val 
)

Change a tuning variable's value to a new float. The Set* functions are also how you declare new tuning variables.

Parameters
nameThe name of the variable to change.
valThe new float value

Definition at line 106 of file TuningVariable.cpp.

void Tuning::SetString ( const String &  name,
const String &  val 
)

Change a tuning variable's value to a new string. The Set* functions are also how you declare new tuning variables.

Parameters
nameThe name of the variable to change.
valThe new string value

Definition at line 111 of file TuningVariable.cpp.

void Tuning::SetVector ( const String &  name,
const Vector2 val 
)

Change a tuning variable's value to a new vector. The Set* functions are also how you declare new tuning variables.

Parameters
nameThe name of the variable to change.
valThe new vector value

Definition at line 116 of file TuningVariable.cpp.

void Tuning::AddToRuntimeTuningList ( const String &  varName)

For internal usage – lets the engine keep track of what variables have been tuned at runtime so they don't get stomped by the auto-reloading of the tuning.ini file.

Parameters
varNameThe name of the variable to add to the list.

Definition at line 121 of file TuningVariable.cpp.

bool Tuning::IsRuntimeTuned ( const String &  varName)

For internal usage – lets the engine keep check if a variable has been tuned at runtime so it doesn't get stomped when tuning.ini gets reloaded.

Parameters
varNameThe name of the variable to check
Returns
Whether or not it's been tuned manually during this session

Definition at line 126 of file TuningVariable.cpp.


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