Dragonfly 4.19
A text-based game engine
Public Member Functions | Private Attributes | List of all members
df::ViewObject Class Reference
Inheritance diagram for df::ViewObject:
Inheritance graph

Public Member Functions

 ViewObject ()
 
virtual int draw () override
 
virtual int eventHandler (const Event *p_e) override
 
void setLocation (ViewObjectLocation new_location)
 
ViewObjectLocation getLocation () const
 
void setDrawValue (bool new_draw_value=true)
 
bool getDrawValue () const
 
void setValue (int new_value)
 
int getValue () const
 
void setBorder (bool new_border)
 
bool getBorder () const
 
void setColor (Color new_color)
 
Color getColor () const
 
void setViewString (std::string new_view_string)
 
std::string getViewString () const
 
virtual int setPosition (Vector new_pos) override
 
virtual std::string serialize (std::string attr="") override
 
virtual int deserialize (std::string s) override
 
virtual bool isModified (enum ViewObjectAttribute attribute) const
 
virtual bool isModified () const override
 
- Public Member Functions inherited from df::Object
 Object ()
 
virtual ~Object ()
 
void setId (int new_id)
 
int getId () const
 
void setType (std::string new_type)
 
std::string getType () const
 
virtual int setPosition (Vector new_position)
 
Vector getPosition () const
 
virtual int eventHandler (const Event *p_event)
 
bool isSolid () const
 
int setSolidness (Solidness new_solid)
 
Solidness getSolidness () const
 
void setNoSoft (bool new_no_soft=true)
 
bool getNoSoft () const
 
void setAvoidCollisions (bool new_avoid_collisions=true)
 
bool getAvoidCollisions () const
 
int setAltitude (int new_altitude)
 
int getAltitude () const
 
void setSpeed (float speed)
 
float getSpeed () const
 
void setDirection (Vector new_direction)
 
Vector getDirection () const
 
void setVelocity (Vector velocity)
 
Vector getVelocity () const
 
void setAcceleration (Vector new_acceleration)
 
Vector getAcceleration () const
 
void accelerate ()
 
Vector predictPosition ()
 
void pathTo (Vector position)
 
void pathTo (Object *p_o_target)
 
void moveTo (Vector new_position)
 
void doPathFollowing ()
 
int setVisible (bool new_visible=true)
 
bool isVisible () const
 
int setActive (bool new_active=true)
 
bool isActive () const
 
void setBox (Box new_box)
 
Box getBox () const
 
int registerInterest (std::string event_type)
 
int unregisterInterest (std::string event_type)
 
int setSprite (std::string sprite_label)
 
void setAnimation (Animation new_animation, bool set_box=true)
 
Animation getAnimation () const
 
virtual int draw ()
 
virtual std::string serialize (std::string attr="")
 
virtual int deserialize (std::string s)
 
virtual bool isModified (enum ObjectAttribute attribute) const
 
virtual bool isModified () const
 
void setShape (Shape new_shape)
 
Shape getShape () const
 
void setFollowPath (bool new_follow_path=true)
 
bool getFollowPath () const
 
void setPath (Path new_path)
 
Path getPath () const
 
PathFindgetPathFind ()
 
std::string toString () const
 

Private Attributes

std::string m_view_string
 
int m_value
 
bool m_draw_value
 
bool m_border
 
Color m_color
 
ViewObjectLocation m_location
 
bool m_vmodified [VATTR_COUNT]
 

Additional Inherited Members

- Static Public Attributes inherited from df::Object
static int max_id
 

Constructor & Destructor Documentation

◆ ViewObject()

df::ViewObject::ViewObject ( )

Construct ViewObject.

Object settings: SPECTRAL, max altitude. ViewObject defaults: border, top_center, default color, draw_value.

Member Function Documentation

◆ deserialize()

virtual int df::ViewObject::deserialize ( std::string  s)
overridevirtual

Deserialize string to become attributes.

Return 0 if no errors, else -1.

Reimplemented from df::Object.

Reimplemented in df::Button, and df::TextEntry.

◆ draw()

virtual int df::ViewObject::draw ( )
overridevirtual

Draw view string (and value).

Return 0 if ok, negative if not.

Reimplemented from df::Object.

Reimplemented in df::TextEntry.

◆ eventHandler()

virtual int df::ViewObject::eventHandler ( const Event p_e)
overridevirtual

Handle "view" event if tag matches view_string (others ignored).

Return 0 if ignored, else 1.

Reimplemented from df::Object.

Reimplemented in df::Button, df::Fraps, and df::TextEntry.

◆ getBorder()

bool df::ViewObject::getBorder ( ) const

Get view border (true = display border).

◆ getColor()

Color df::ViewObject::getColor ( ) const

Get view color.

◆ getDrawValue()

bool df::ViewObject::getDrawValue ( ) const

Get draw value (true if draw value with display string).

◆ getLocation()

ViewObjectLocation df::ViewObject::getLocation ( ) const

Get general location of ViewObject on screen.

◆ getValue()

int df::ViewObject::getValue ( ) const

Get view value.

◆ getViewString()

std::string df::ViewObject::getViewString ( ) const

Get view display string.

◆ isModified() [1/2]

virtual bool df::ViewObject::isModified ( ) const
overridevirtual

Return true if any attribute modified since last serialize.

Reimplemented from df::Object.

Reimplemented in df::Button, and df::TextEntry.

◆ isModified() [2/2]

virtual bool df::ViewObject::isModified ( enum ViewObjectAttribute  attribute) const
virtual

Return true if attribute modified since last serialize.

◆ serialize()

virtual std::string df::ViewObject::serialize ( std::string  attr = "")
overridevirtual

Serialize ViewObject attributes to single string.

Can specify attribute to serialize (default "" means all modified). separated by commas. If attr is "ALL", serialize all attributes (modified or not). Clear m_vmodified[] array for attributes serialized.

Reimplemented from df::Object.

Reimplemented in df::Button, and df::TextEntry.

◆ setBorder()

void df::ViewObject::setBorder ( bool  new_border)

Set view border (true = display border).

◆ setColor()

void df::ViewObject::setColor ( Color  new_color)

Set view color.

◆ setDrawValue()

void df::ViewObject::setDrawValue ( bool  new_draw_value = true)

Set true to draw value with display string.

◆ setLocation()

void df::ViewObject::setLocation ( ViewObjectLocation  new_location)

Set general location of ViewObject on screen.

◆ setPosition()

virtual int df::ViewObject::setPosition ( Vector  new_pos)
overridevirtual

Set position of ViewObject, with setting "location" to UNDEFINED.

Reimplemented from df::Object.

◆ setValue()

void df::ViewObject::setValue ( int  new_value)

Set view value.

◆ setViewString()

void df::ViewObject::setViewString ( std::string  new_view_string)

Set view display string.

Member Data Documentation

◆ m_border

bool df::ViewObject::m_border
private

True if border around display.

◆ m_color

Color df::ViewObject::m_color
private

Color for text (and border).

◆ m_draw_value

bool df::ViewObject::m_draw_value
private

True if should draw value.

◆ m_location

ViewObjectLocation df::ViewObject::m_location
private

Location of ViewObject.

◆ m_value

int df::ViewObject::m_value
private

Value displayed (e.g., points).

◆ m_view_string

std::string df::ViewObject::m_view_string
private

Label for value (e.g., "Points").

◆ m_vmodified

bool df::ViewObject::m_vmodified[VATTR_COUNT]
private

Mod. attrib. since serialize().