Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BaseInterface::Room::BaseTalk Class Reference

#include <base.h>

Inheritance diagram for BaseInterface::Room::BaseTalk:
BaseInterface::Room::BaseObj

Public Member Functions

virtual void Draw (::BaseInterface *base)
 
virtual ~BaseTalk ()
 
 BaseTalk (const std::string &msg, const std::string &ind, bool only_one_talk)
 
- Public Member Functions inherited from BaseInterface::Room::BaseObj
virtual ~BaseObj ()
 
 BaseObj (const std::string &ind)
 

Public Attributes

unsigned int curchar
 
float curtime
 
std::string message
 
- Public Attributes inherited from BaseInterface::Room::BaseObj
const std::string index
 

Static Public Attributes

static bool hastalked = false
 

Detailed Description

Definition at line 292 of file base.h.

Constructor & Destructor Documentation

virtual BaseInterface::Room::BaseTalk::~BaseTalk ( )
inlinevirtual

Definition at line 300 of file base.h.

300 {}
BaseInterface::Room::BaseTalk::BaseTalk ( const std::string &  msg,
const std::string &  ind,
bool  only_one_talk 
)

Definition at line 498 of file base_interface.cpp.

References active_talks.

498  : BaseObj( ind )
499  , curchar( 0 )
500  , curtime( 0 )
501  , message( msg )
502 {
503  if (only_one)
504  active_talks.clear();
505  active_talks.push_back( this );
506 }

Member Function Documentation

void BaseInterface::Room::BaseTalk::Draw ( ::BaseInterface base)
virtual

Reimplemented from BaseInterface::Room::BaseObj.

Definition at line 578 of file base_interface.cpp.

References active_talks, BaseInterface::curroom, GetElapsedTime(), getTimeCompression(), VegaConfig::getVariable(), BaseInterface::othtext, XMLSupport::parse_float(), BaseInterface::rooms, TextPlane::SetText(), and vs_config.

579 {
580  //FIXME: should be called from draw()
581  if (hastalked) return;
583  static float delay = XMLSupport::parse_float( vs_config->getVariable( "graphics", "text_delay", ".05" ) );
584  if ( ( std::find( active_talks.begin(), active_talks.end(),
585  this ) == active_talks.end() )
586  || ( curchar >= message.size() && curtime > ( ( delay*message.size() )+2 ) ) ) {
587  curtime = 0;
588  std::vector< BaseObj* >::iterator ind = std::find( base->rooms[base->curroom]->objs.begin(),
589  base->rooms[base->curroom]->objs.end(),
590  this );
591  if ( ind != base->rooms[base->curroom]->objs.end() )
592  *ind = NULL;
593  std::vector< BaseTalk* >::iterator ind2 = std::find( active_talks.begin(), active_talks.end(), this );
594  if ( ind2 != active_talks.end() )
595  *ind2 = NULL;
596  base->othtext.SetText( "" );
597  delete this;
598  return; //do not do ANYTHING with 'this' after the previous statement...
599  }
600  if ( curchar < message.size() ) {
601  static float inbetween = XMLSupport::parse_float( vs_config->getVariable( "graphics", "text_speed", ".025" ) );
602  if (curtime > inbetween) {
603  base->othtext.SetText( message.substr( 0, ++curchar ) );
604  curtime = 0;
605  }
606  }
607  hastalked = true;
608 }

Member Data Documentation

unsigned int BaseInterface::Room::BaseTalk::curchar

Definition at line 298 of file base.h.

float BaseInterface::Room::BaseTalk::curtime

Definition at line 299 of file base.h.

bool BaseInterface::Room::BaseTalk::hastalked = false
static

Definition at line 295 of file base.h.

Referenced by BaseInterface::Draw().

std::string BaseInterface::Room::BaseTalk::message

Definition at line 301 of file base.h.


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