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::Talk Class Reference

#include <base.h>

Inheritance diagram for BaseInterface::Room::Talk:
BaseInterface::Room::Link

Public Member Functions

virtual void Click (::BaseInterface *base, float x, float y, int button, int state)
 
 Talk (const std::string &ind, const std::string &pythonfile)
 
virtual ~Talk ()
 

Public Attributes

std::vector< std::string > say
 
std::vector< std::string > soundfiles
 
int index
 
int curroom
 

Additional Inherited Members

Detailed Description

Definition at line 117 of file base.h.

Constructor & Destructor Documentation

BaseInterface::Room::Talk::Talk ( const std::string &  ind,
const std::string &  pythonfile 
)
explicit

Definition at line 1007 of file base_interface.cpp.

References first(), i, MessageCenter::last(), gameMessage::message, mission, Mission::msgcenter, say, and soundfiles.

1007  :
1009 {
1010 #ifndef BASE_MAKER
1011  gameMessage last;
1012  int i = 0;
1013  vector< std::string >who;
1014  string newmsg;
1015  string newsound;
1016  who.push_back( "bar" );
1017  while ( ( mission->msgcenter->last( i++, last, who ) ) ) {
1018  newmsg = last.message;
1019  newsound = "";
1020  string::size_type first = newmsg.find_first_of( "[" );
1021  {
1022  string::size_type last = newmsg.find_first_of( "]" );
1023  if ( first != string::npos && (first+1) < newmsg.size() ) {
1024  newsound = newmsg.substr( first+1, last-first-1 );
1025  newmsg = newmsg.substr( 0, first );
1026  }
1027  }
1028  this->say.push_back( newmsg );
1029  this->soundfiles.push_back( newsound );
1030  }
1031 #endif
1032 }
virtual BaseInterface::Room::Talk::~Talk ( )
inlinevirtual

Definition at line 127 of file base.h.

127 {}

Member Function Documentation

void BaseInterface::Room::Talk::Click ( ::BaseInterface base,
float  x,
float  y,
int  button,
int  state 
)
virtual

Reimplemented from BaseInterface::Room::Link.

Definition at line 1300 of file base_interface.cpp.

References AUDCreateSoundWAV(), AUDDeleteSound(), AUDStartPlaying(), BaseInterface::Room::Link::Click(), BaseInterface::curroom, index, BaseInterface::othtext, BaseInterface::rooms, TextPlane::SetText(), size, VSFileSystem::vs_fprintf(), and WS_MOUSE_UP.

1301 {
1302  if (state == WS_MOUSE_UP) {
1303  Link::Click( base, x, y, button, state );
1304  if (index >= 0) {
1305  delete base->rooms[curroom]->objs[index];
1306  base->rooms[curroom]->objs[index] = NULL;
1307  index = -1;
1308  base->othtext.SetText( "" );
1309  } else if ( say.size() ) {
1310  curroom = base->curroom;
1311  int sayindex = rand()%say.size();
1312  base->rooms[curroom]->objs.push_back( new Room::BaseTalk( say[sayindex], "currentmsg", true ) );
1313  if (soundfiles[sayindex].size() > 0) {
1314  int sound = AUDCreateSoundWAV( soundfiles[sayindex], false );
1315  if (sound == -1) {
1316  VSFileSystem::vs_fprintf( stderr, "\nCan't find the sound file %s\n", soundfiles[sayindex].c_str() );
1317  } else {
1318  AUDStartPlaying( sound );
1319  AUDDeleteSound( sound ); //won't actually toast it until it stops
1320  }
1321  }
1322  } else {
1323  VSFileSystem::vs_fprintf( stderr, "\nThere are no things to say...\n" );
1324  assert( 0 );
1325  }
1326  }
1327 }

Member Data Documentation

int BaseInterface::Room::Talk::curroom

Definition at line 124 of file base.h.

int BaseInterface::Room::Talk::index

Definition at line 123 of file base.h.

std::vector< std::string > BaseInterface::Room::Talk::say

Definition at line 121 of file base.h.

Referenced by Talk().

std::vector< std::string > BaseInterface::Room::Talk::soundfiles

Definition at line 122 of file base.h.

Referenced by Talk().


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