|
LPCGame
A Simple 2d Game Engine
|
A clickable ui Button, can run a static/non-member function when clicked. More...
#include <button.h>
Inherits Entity.
Inherited by ObjectButton< T >.
Public Member Functions | |
| Button (std::string script) | |
| void | Draw (std::weak_ptr< Camera > camera) |
| virtual void | OnClick () |
| void | RegisterCallBack (void(*f)(std::string), std::string param) |
| virtual Json::Value | Save () |
| virtual void | Load (Json::Value val) |
Public Member Functions inherited from Entity | |
| Entity (std::string file) | |
| virtual void | Init (std::shared_ptr< Entity > self=nullptr) |
| virtual void | Free () |
| virtual void | Update () |
| Update the game object. | |
| virtual void | Move (float deltaT) |
| virtual void | OnMouseDown () |
| On mouse down events. | |
| virtual void | OnMouseUp () |
| On mouse up event. | |
| virtual void | OnMouseEnter () |
| On mouse enter. | |
| virtual void | OnMouseExit () |
| On mouse exit. | |
| virtual void | CheckMouseOver (const Vector2f &pos) |
| bool | GetMouseOver () const |
| Return T/F is the mouse is over the object. | |
| Physics * | GetPhysics () |
| std::weak_ptr< Physics > | GetPhysicsWeakPtr () |
| void | SetCollisionMap (CollisionMap map) |
| Rectf | Box () const |
| Get the object's box. | |
| void | SetTag (std::string tag) |
| Set the entity's tag. | |
| std::string | Tag () const |
| Get the entity's tag. | |
| void | SetName (std::string name) |
| std::string | Name () const |
| void | Render (bool b) |
| Set the Entity render flag. | |
| bool | Render () const |
| Check if the Entity should be drawn. | |
| void | IsUiElement (bool b) |
| Set the Entity "is ui element" flag. | |
| bool | IsUiElement () const |
| Check if the Entity is a ui element. | |
| LuaScript * | Script () |
| Get a pointer to the Entity's LuaScript. | |
| virtual Json::Value | Save () const |
| virtual void | Save (const std::string &file) const |
| virtual void | Load (const std::string &file, Json::Value overrides=Json::Value()) |
Protected Attributes | |
| Text | mText |
| void(* | mFunc )(std::string) |
| The callback function pointer & its value. | |
| std::string | mParam |
Protected Attributes inherited from Entity | |
| Image | mImage |
| std::shared_ptr< Physics > | mPhysics |
| Handle's the objects physics. | |
| std::string | mTag |
| A general tag for the entity. | |
| std::string | mName |
| The entity's name. | |
| std::string | mConfigFile |
| bool | mMouseOver |
| For tracking mouse over and clicks. | |
| bool | mClicked |
| bool | mRender |
| For tracking if the entity should be rendered, and if it's a ui element. | |
| bool | mUiElement |
| LuaScript | mScript |
| The entity's lua script. | |
A clickable ui Button, can run a static/non-member function when clicked.
A simple button class, for handling mouse input will run the registered function when pressed, the button inherites its mouse event reading functionality from GameObject TODO: This class will be replaced by scripted entities
| Button::Button | ( | std::string | script | ) |
Construct the Button and load its script
| script | The object's script |
|
virtual |
Draw the object, apply an adjustment for the camera if one is desired
| cam | The camera to adjust for |
Reimplemented from Entity.
|
virtual |
Load the object from a Json::Value
| val | The Json::Value to load from |
Reimplemented from Entity.
Reimplemented in ObjectButton< T >.
|
virtual |
On click, run the callback function if one was registered This should call a Lua script function, OnClick as well
Reimplemented from Entity.
Reimplemented in ObjectButton< T >.
| void Button::RegisterCallBack | ( | void(*)(std::string) | f, |
| std::string | param | ||
| ) |
Register a non-member function as the callback function to run when the button is pressed
| f | The function to call, must be a function returning void and taking a string |
| param | The param to pass to the function |
|
virtual |
Save the object data to a json value and return it