The Game Engine  1
Menu Class Reference

A menu. More...

#include <Menu.h>

+ Inheritance diagram for Menu:
+ Collaboration diagram for Menu:

Public Member Functions

 Menu (std::string name, std::string themeName=NULL, bool fullscreen=true)
 Initialize the menu by attempting to read from the actor and text files by the same name and generate our menu text/pictures etc. More...
 
void draw ()
 Draws Sprite. More...
 
void drawCollisions ()
 Draws CollisionObject data for the Object (from outside) More...
 
void update ()
 Update to run each loop. More...
 
void addMenu (std::string name, int index)
 Adds a page to the menu. More...
 
Point2D getBasePos ()
 Obtain Base Pos for drawing. More...
 
Point2D getCenterPos ()
 Obtain Center Pos for Collisions. More...
 
virtual WorldObjectType getType ()
 This provides a simple interface to determine types of objects. More...
 
- Public Member Functions inherited from WorldObject
 WorldObject (std::string name, Point2D pos=Point2D(), int z=0)
 
void drawCollisions (vector< CollisionObject * > &vec, const Point2D &pos)
 Draws CollisionObject data for the Object. More...
 
virtual void runBehavior ()
 Behavior that WorldObject follows. More...
 
void setPosition (double x, double y)
 Sets the WorldObject's x an y coordinate. More...
 
void setPosition (Point2D pos)
 Sets the WorldObject's x an y coordinate. More...
 
void setBasePosition (double x, double y)
 Sets the WorldObject's x an y coordinate relative to base pos. More...
 
void setBasePosition (Point2D pos)
 Sets the WorldObject's x an y coordinate relative to base pos. More...
 
void setCenterPosition (double x, double y)
 Sets the WorldObject's x an y coordinate relative to base pos. More...
 
void setCenterPosition (Point2D pos)
 Sets the WorldObject's x an y coordinate relative to base pos. More...
 
void move (double dx=0.0, double dy=0.0)
 Move by given amount NOTE: This is an instantaneous movement by a given amount and does not correspond to physics which is set to do the updated amount per second. More...
 
virtual void move (Point2D direction)
 Moves the WorldObject relative to the current pos. More...
 
virtual void moveTowards (Point2D direction)
 Move towards a given coordinate (path finding) More...
 
Point2D getPosition ()
 Gets the WorldObject's position. More...
 
void setTransparency (float f)
 Sets the WorldObject's transparency. More...
 
float getTransparency ()
 Gets the WorldObject's transparency. More...
 
void setAngle (float a)
 Sets the WorldObject's angle in degrees. More...
 
float getAngle ()
 Gets the WorldObject's angle. More...
 
void setVelocity (Point2D vel)
 Sets the WorldObject's velocity as a vector (will set MaxVelocity if needed) More...
 
void setVelocity (double xVel, double yVel)
 Sets the WorldObject's velocity from coordinates (will set MaxVelocity if needed) More...
 
Point2D getVelocity ()
 Gets the WorldObject's Velocity. More...
 
void setMaxVelocity (Point2D vel)
 Sets the WorldObject's MaxVelocity (magnitude) from (x,y) and transforms into a magnitude. More...
 
void setMaxVelocity (double vel, Point2D dir)
 Sets the WorldObject's MaxVelocity (magnitude) value in the direction specified. More...
 
void setMaxSpeed (double vel)
 Sets the WorldObject's MaxVelocity (magnitude) value in the direction specified. More...
 
Point2D getMaxVelocity ()
 Gets the WorldObject's Max Velocity. More...
 
double getMaxSpeed ()
 Gets the WorldObject's Max Speed. More...
 
double getMaxSpeedSquared ()
 Gets the WorldObject's Max Speed Squared (cheaper operation). More...
 
void setAcceleration (Point2D accel)
 Sets the WorldObject's Acceleration in (x,y) coords. More...
 
Point2D getAcceleration ()
 Gets the WorldObject's Acceleration. More...
 
void setZOrder (int i)
 
int getZOrder ()
 
std::string getName ()
 returns the WorldObject's name More...
 
bool operator< (WorldObject &rhs)
 Sort worldObjects. More...
 

Protected Attributes

map< std::string, int > mMenus
 map from name to index More...
 
- Protected Attributes inherited from WorldObject
std::string mName
 WorldObject's name. More...
 
Point2D mPos
 The current (x,y) position. More...
 
Point2D mVelocity
 The current velocity vector. More...
 
Point2D mMaxVelocity
 The max velocity is the max possible velocity where lengthis the speed. More...
 
double mMaxSpeed
 The max Speed if MaxVelocity is 0 to store val. More...
 
Point2D mAcceleration
 The current acceleration vector. More...
 
bool mVisible
 Determine if Object should be visible. More...
 
float mTransparency
 Transparency! More...
 
float mAngle
 Angle of rotation. More...
 
float mScale
 Scale for the sprit. More...
 
int ZOrder
 Stacking order. Determines what draws on top. (subsorted by position) More...
 
long mLastUpdate
 Number that indicates when the Object has last updated. Overflows in about 24 days so no worries. More...
 
long mLastDraw
 Number that indicates when the Object has last updated. Overflows in about 24 days so no worries. More...
 
bool mUnused
 Determines whether or not this object's update function should run. More...
 
Behavior mBehavior
 Behavior to act each loop if !mUnused. More...
 

Additional Inherited Members

- Public Types inherited from WorldObject
enum  WorldObjectType {
  SPRITE, BACKGROUND, MENU, TEXT,
  PARTICLESYSTEM
}
 This is to be used for Type checking so as to make no need for dynamic_cast and it's inefficiency. More...
 

Detailed Description

A menu.

This class is tasked with the following:

  • Menu-like interactions for a user
    • Drawing itself (all pieces/sub menus)
    • Loading structure from a file

Definition at line 17 of file Menu.h.

Constructor & Destructor Documentation

Menu::Menu ( std::string  name,
std::string  themeName = NULL,
bool  fullscreen = true 
)

Initialize the menu by attempting to read from the actor and text files by the same name and generate our menu text/pictures etc.

Parameters
nameName for the menu (corresponds to name of menu file in ArtAssets/Text
themeNameThe actor to load of the given name
fullscreenWhether or not the menu should cover all the screen.
Todo:

make MenuButtonList

make MenuPanel (for displaying content etc will consists of Buttonlists and displayAreas (inherit from to make info for monsters etc)

make Button class that has at minimum text, optional location for an image, ability to highlight selection

make changing from one menu to another

Definition at line 4 of file Menu.cpp.

Member Function Documentation

void Menu::addMenu ( std::string  name,
int  index 
)

Adds a page to the menu.

Parameters
nameName of the menu
indexThe index within actor for the menu page
void Menu::draw ( )
virtual

Draws Sprite.

Implements WorldObject.

Definition at line 9 of file Menu.cpp.

void Menu::drawCollisions ( )
virtual

Draws CollisionObject data for the Object (from outside)

Reimplemented from WorldObject.

Definition at line 21 of file Menu.cpp.

Point2D Menu::getBasePos ( )
inlinevirtual

Obtain Base Pos for drawing.

Implements WorldObject.

Definition at line 57 of file Menu.h.

Point2D Menu::getCenterPos ( )
inlinevirtual

Obtain Center Pos for Collisions.

Implements WorldObject.

Definition at line 62 of file Menu.h.

virtual WorldObjectType Menu::getType ( )
inlinevirtual

This provides a simple interface to determine types of objects.

Returns the name of the Class and Descendants i.e. Something inheriting from Sprite would look like Sprite:Thing

Implements WorldObject.

Definition at line 67 of file Menu.h.

void Menu::update ( )
virtual

Update to run each loop.

Reimplemented from WorldObject.

Definition at line 14 of file Menu.cpp.

+ Here is the call graph for this function:

Member Data Documentation

map<std::string,int> Menu::mMenus
protected

map from name to index

Definition at line 71 of file Menu.h.


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