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

Public Member Functions

void clearText ()
 
void setText (std::string new_text)
 
std::string getText () const
 
int eventHandler (const Event *p_e) override
 
virtual void callback ()=0
 
void setLimit (int new_limit)
 
int getLimit () const
 
void setCursor (int new_cursor)
 
int getCursor () const
 
void setBlinkRate (int new_blink_rate)
 
int getBlinkRate () const
 
bool numbersOnly () const
 
void setNumbersOnly (bool new_numbers_only=true)
 
void setCursorChar (char new_cursor_char)
 
char getCursorChar () const
 
virtual int draw () override
 
virtual int serialize (std::stringstream *p_ss, unsigned int attr=0) override
 
virtual int deserialize (std::stringstream *p_ss, unsigned int *p_a=NULL) override
 
- Public Member Functions inherited from df::ViewObject
 ViewObject ()
 
virtual int draw () override
 
virtual int eventHandler (const Event *p_e) override
 
virtual void setLocation (ViewObjectLocation new_location)
 
ViewObjectLocation getLocation () const
 
virtual void setDrawValue (bool new_draw_value=true)
 
bool getDrawValue () const
 
virtual void setValue (int new_value)
 
int getValue () const
 
virtual void setBorder (bool new_border)
 
bool getBorder () const
 
virtual void setColor (Color new_color)
 
Color getColor () const
 
virtual void setViewString (std::string new_view_string)
 
std::string getViewString () const
 
virtual int setPosition (Vector new_pos) override
 
virtual int serialize (std::stringstream *p_ss, unsigned int attr=0) override
 
virtual int deserialize (std::stringstream *p_ss, unsigned int *p_a=NULL) override
 
std::string toString () const
 
bool operator== (const ViewObject &vo)
 
bool operator!= (const ViewObject &vo)
 
- Public Member Functions inherited from df::Object
 Object ()
 
virtual ~Object ()
 
void setId (int new_id)
 
int getId () const
 
virtual 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
 
virtual int setSolidness (Solidness new_solid)
 
Solidness getSolidness () const
 
void setNoSoft (bool new_no_soft=true)
 
bool getNoSoft () const
 
virtual void setAvoidCollisions (bool new_avoid_collisions=true)
 
bool getAvoidCollisions () const
 
virtual int setAltitude (int new_altitude)
 
int getAltitude () const
 
void setSpeed (float speed)
 
float getSpeed () const
 
virtual void setDirection (Vector new_direction)
 
Vector getDirection () const
 
virtual void setVelocity (Vector velocity)
 
Vector getVelocity () const
 
virtual 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)
 
virtual bool isVisible () const
 
virtual int setActive (bool new_active=true)
 
bool isActive () const
 
virtual void setBox (Box new_box)
 
Box getBox () const
 
int registerInterest (std::string event_type)
 
int unregisterInterest (std::string event_type)
 
int getEventCount () const
 
virtual int setSprite (std::string sprite_label)
 
virtual void setAnimation (Animation new_animation, bool set_box=true)
 
Animation getAnimation () const
 
virtual int draw ()
 
virtual int serialize (std::stringstream *p_ss, unsigned int attr=0)
 
virtual int deserialize (std::stringstream *p_ss, unsigned int *p_a=NULL)
 
bool isModified (enum ObjectAttribute attribute) const
 
bool isModified () const
 
virtual void setModified (unsigned int new_modified)
 
virtual unsigned int getModified () const
 
virtual void setShape (Shape new_shape)
 
Shape getShape () const
 
virtual void setFollowPath (bool new_follow_path=true)
 
bool getFollowPath () const
 
void setPath (Path new_path)
 
Path getPath () const
 
PathFindgetPathFind ()
 
std::string toString () const
 
bool operator== (const Object &o)
 
bool operator!= (const Object &o)
 

Private Attributes

std::string m_text
 
int m_limit
 
int m_cursor
 
char m_cursor_char
 
int m_blink_rate
 
bool m_numbers_only
 
bool m_shift_down
 

Additional Inherited Members

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

Member Function Documentation

◆ callback()

virtual void df::TextEntry::callback ( )
pure virtual

Called when TextEntry enter hit.

Must be defined by derived class.

◆ clearText()

void df::TextEntry::clearText ( )

Clear text entry.

◆ deserialize()

virtual int df::TextEntry::deserialize ( std::stringstream *  p_ss,
unsigned int *  p_a = NULL 
)
overridevirtual

Deserialize stream to attributes and apply.

p_ss - incoming stream to deserialize. p_a - outgoing bitmask of attributes modified (NULL means no outgoing). Return 0 if ok, else -1.

Reimplemented from df::ViewObject.

◆ draw()

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

Draw viewstring + text entered.

Reimplemented from df::ViewObject.

◆ eventHandler()

int df::TextEntry::eventHandler ( const Event p_e)
overridevirtual

Handle "keyboard" events.

Return 0 if ignored, else 1.

Reimplemented from df::ViewObject.

◆ getBlinkRate()

int df::TextEntry::getBlinkRate ( ) const

Get blink rate for cursor (in ticks).

◆ getCursor()

int df::TextEntry::getCursor ( ) const

Get cursor location.

◆ getCursorChar()

char df::TextEntry::getCursorChar ( ) const

Get cursor character.

◆ getLimit()

int df::TextEntry::getLimit ( ) const

Get limit of number of characters allowed.

◆ getText()

std::string df::TextEntry::getText ( ) const

Get text entered.

◆ numbersOnly()

bool df::TextEntry::numbersOnly ( ) const

Return true if only numbers can be entered.

◆ serialize()

virtual int df::TextEntry::serialize ( std::stringstream *  p_ss,
unsigned int  attr = 0 
)
overridevirtual

Serialize attributes to stream.

Can specify individual attribute(s) to force (modified or not). Default is only modified attributes. Clears modified bits for attributes serialized. Return 0 if ok, else -1.

Reimplemented from df::ViewObject.

◆ setBlinkRate()

void df::TextEntry::setBlinkRate ( int  new_blink_rate)

Set blink rate for cursor (in ticks).

◆ setCursor()

void df::TextEntry::setCursor ( int  new_cursor)

Set cursor to location.

◆ setCursorChar()

void df::TextEntry::setCursorChar ( char  new_cursor_char)

Set cursor character.

◆ setLimit()

void df::TextEntry::setLimit ( int  new_limit)

Set limit of number of characters allowed.

◆ setNumbersOnly()

void df::TextEntry::setNumbersOnly ( bool  new_numbers_only = true)

Set to allow only numbers to be entered.

◆ setText()

void df::TextEntry::setText ( std::string  new_text)

Set text, increasing limit if needed.

Member Data Documentation

◆ m_blink_rate

int df::TextEntry::m_blink_rate
private

Cursor blink rate.

◆ m_cursor

int df::TextEntry::m_cursor
private

Cursor location.

◆ m_cursor_char

char df::TextEntry::m_cursor_char
private

Cursor character.

◆ m_limit

int df::TextEntry::m_limit
private

Character limit in text.

◆ m_numbers_only

bool df::TextEntry::m_numbers_only
private

True if only numbers.

◆ m_shift_down

bool df::TextEntry::m_shift_down
private

True if shift key pressed.

◆ m_text

std::string df::TextEntry::m_text
private

Text entered.