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
BaseUtil Namespace Reference

Classes

class  VideoAudioStreamListener
 

Typedefs

typedef std::map< std::string,
std::string > 
Dictionary
 

Functions

BaseInterface::RoomCheckRoom (int room)
 
int Room (std::string text)
 
void Texture (int room, std::string index, std::string file, float x, float y)
 
SharedPtr< SourceCreateVideoSoundStream (const std::string &afile, const std::string &scene)
 
void DestroyVideoSoundStream (SharedPtr< Source > source, const std::string &scene)
 
bool Video (int room, std::string index, std::string vfile, std::string afile, float x, float y)
 
bool VideoStream (int room, std::string index, std::string streamfile, float x, float y, float w, float h)
 
void SetVideoCallback (int room, std::string index, std::string callback)
 
void SetTexture (int room, std::string index, std::string file)
 
void SetTextureSize (int room, std::string index, float w, float h)
 
void SetTexturePos (int room, std::string index, float x, float y)
 
void PlayVideo (int room, std::string index)
 
void StopVideo (int room, std::string index)
 
void SetDJEnabled (bool enabled)
 
void Ship (int room, std::string index, QVector pos, Vector Q, Vector R)
 
void RunScript (int room, std::string ind, std::string pythonfile, float time)
 
void TextBox (int room, std::string ind, std::string text, float x, float y, Vector widheimult, Vector backcol, float backalp, Vector forecol)
 
void SetTextBoxText (int room, std::string index, std::string text)
 
void SetLinkArea (int room, std::string index, float x, float y, float wid, float hei)
 
void SetLinkText (int room, std::string index, std::string text)
 
void SetLinkPython (int room, std::string index, std::string python)
 
void SetLinkRoom (int room, std::string index, int to)
 
void SetLinkEventMask (int room, std::string index, std::string maskdef)
 
static void BaseLink (BaseInterface::Room *room, float x, float y, float wid, float hei, std::string text, bool reverse=false)
 
void Link (int room, std::string index, float x, float y, float wid, float hei, std::string text, int to)
 
void LinkPython (int room, std::string index, std::string pythonfile, float x, float y, float wid, float hei, std::string text, int to)
 
void Launch (int room, std::string index, float x, float y, float wid, float hei, std::string text)
 
void LaunchPython (int room, std::string index, std::string pythonfile, float x, float y, float wid, float hei, std::string text)
 
void EjectPython (int room, std::string index, std::string pythonfile, float x, float y, float wid, float hei, std::string text)
 
void Comp (int room, std::string index, float x, float y, float wid, float hei, std::string text, std::string modes)
 
void CompPython (int room, std::string index, std::string pythonfile, float x, float y, float wid, float hei, std::string text, std::string modes)
 
void Python (int room, std::string index, float x, float y, float wid, float hei, std::string text, std::string pythonfile, bool front)
 
void GlobalKeyPython (std::string pythonfile)
 
void MessageToRoom (int room, std::string text)
 
void EnqueueMessageToRoom (int room, std::string text)
 
void Message (std::string text)
 
void EnqueueMessage (std::string text)
 
void EraseLink (int room, std::string index)
 
void EraseObj (int room, std::string index)
 
int GetCurRoom ()
 
void SetCurRoom (int room)
 
int GetNumRoom ()
 
bool BuyShip (std::string name, bool my_fleet, bool force_base_inventory)
 
bool SellShip (std::string name)
 
Dictionary_GetEventData ()
 
void SetEventData (BoostPythonDictionary data)
 
void SetMouseEventData (std::string type, float x, float y, int buttonMask)
 
void SetKeyStatusEventData (unsigned int modmask)
 
void SetKeyEventData (std::string type, unsigned int keycode, unsigned int modmask)
 
const DictionaryGetEventData ()
 
float GetTextHeight (std::string text, Vector widheimult)
 
float GetTextWidth (std::string text, Vector widheimult)
 
void LoadBaseInterface (string name)
 
void LoadBaseInterfaceAtDock (string name, Unit *dockat, Unit *dockee)
 
void refreshBaseComputerUI (const Cargo *carg)
 
void ExitGame ()
 
bool HasObject (int room, std::string index)
 
void SetEventData (Dictionary data)
 
void LoadBaseInterface (std::string name)
 
void LoadBaseInterfaceAtDock (std::string name, Unit *dockat, Unit *dockee)
 
void refreshBaseComputerUI (const class Cargo *dirtyCarg)
 
bool Video (int room, std::string index, std::string file, float x, float y)
 
void Python (int room, std::string index, float x, float y, float wid, float hei, std::string text, std::string pythonfile)
 

Typedef Documentation

typedef std::map< std::string, std::string > BaseUtil::Dictionary

Definition at line 42 of file base_util.h.

Function Documentation

Dictionary & BaseUtil::_GetEventData ( )

Definition at line 656 of file base_util.cpp.

Referenced by GetEventData(), SetEventData(), SetKeyEventData(), SetKeyStatusEventData(), and SetMouseEventData().

657 {
658  static BoostPythonDictionary data;
659  return data;
660 }
static void BaseUtil::BaseLink ( BaseInterface::Room room,
float  x,
float  y,
float  wid,
float  hei,
std::string  text,
bool  reverse = false 
)
static

Definition at line 442 of file base_util.cpp.

References BaseInterface::Room::Link::hei, BaseInterface::Room::links, BaseInterface::Room::Link::text, BaseInterface::Room::Link::wid, BaseInterface::Room::Link::x, x, BaseInterface::Room::Link::y, and y.

Referenced by CompPython(), EjectPython(), LaunchPython(), LinkPython(), and Python().

443 {
445  if (reverse)
446  lnk = room->links.front();
447  else
448  lnk = room->links.back();
449  lnk->x = x;
450  lnk->y = y;
451  lnk->wid = wid;
452  lnk->hei = hei;
453  lnk->text = text;
454 }
bool BaseUtil::BuyShip ( std::string  name,
bool  my_fleet,
bool  force_base_inventory 
)

Definition at line 643 of file base_util.cpp.

References BaseInterface::baseun, buyShip(), BaseInterface::caller, BaseInterface::CurrentBase, and UnitContainer::GetUnit().

644 {
647  return ::buyShip( base, un, name, my_fleet, force_base_inventory, NULL );
648 }
void BaseUtil::Comp ( int  room,
std::string  index,
float  x,
float  y,
float  wid,
float  hei,
std::string  text,
std::string  modes 
)

Definition at line 500 of file base_util.cpp.

References CompPython().

Referenced by BaseInterface::BaseInterface(), BaseInterface::Room::Click(), CompPython(), and Unit::GetSortedCargoCat().

501 {
502  CompPython( room, index, "", x, y, wid, hei, text, modes );
503 }
void BaseUtil::CompPython ( int  room,
std::string  index,
std::string  pythonfile,
float  x,
float  y,
float  wid,
float  hei,
std::string  text,
std::string  modes 
)

Definition at line 504 of file base_util.cpp.

References BaseLink(), BaseComputer::CARGO, CheckRoom(), Comp(), BaseComputer::DISPLAY_MODE_COUNT, i, BaseComputer::INFO, j, BaseInterface::Room::links, BaseComputer::LOADSAVE, XMLSupport::EnumMap::lookup(), BaseComputer::MISSIONS, BaseInterface::Room::Comp::modes, BaseComputer::NETWORK, BaseComputer::NEWS, BaseComputer::SHIP_DEALER, BaseComputer::UPGRADE, and VSFileSystem::vs_fprintf().

Referenced by Comp().

513 {
514  BaseInterface::Room *newroom = CheckRoom( room );
515  if (!newroom) return;
516  BaseInterface::Room::Comp *newcomp = new BaseInterface::Room::Comp( index, pythonfile );
517  newroom->links.push_back( newcomp );
518  BaseLink( newroom, x, y, wid, hei, text );
519  static const EnumMap::Pair modelist[] = {
521  EnumMap::Pair( "Upgrade", BaseComputer::UPGRADE ),
522  EnumMap::Pair( "ShipDealer", BaseComputer::SHIP_DEALER ),
523  EnumMap::Pair( "Missions", BaseComputer::MISSIONS ),
526  EnumMap::Pair( "LoadSave", BaseComputer::LOADSAVE ),
527  EnumMap::Pair( "Network", BaseComputer::NETWORK ),
529  };
530  static const EnumMap modemap( modelist, sizeof (modelist)/sizeof (*modelist) );
531  const char *newmode = modes.c_str();
532  int newlen = modes.size();
533  char *curmode = new char[newlen+1];
534  for (int i = 0; i < newlen;) {
535  int j;
536  for (j = 0; newmode[i] != ' ' && newmode[i] != '\0'; i++, j++)
537  curmode[j] = newmode[i];
538  while (newmode[i] == ' ')
539  i++;
540  if (j == 0)
541  continue;
542  //in otherwords, if j is 0 then the 0th index will become null
543  //EnumMap crashes if the string is empty.
544  curmode[j] = '\0';
545  int modearg = modemap.lookup( curmode );
546  if (modearg < BaseComputer::DISPLAY_MODE_COUNT)
547  newcomp->modes.push_back( (BaseComputer::DisplayMode) (modearg) );
548  else
549  VSFileSystem::vs_fprintf( stderr, "WARNING: Unknown computer mode %s found in python script...\n", curmode );
550  }
551  delete[] curmode;
552 }
SharedPtr< Audio::Source > BaseUtil::CreateVideoSoundStream ( const std::string &  afile,
const std::string &  scene 
)

Definition at line 139 of file base_util.cpp.

References VSFileSystem::VideoFile.

Referenced by BaseInterface::Room::BaseVSMovie::BaseVSMovie(), BaseInterface::Room::BaseVSMovie::SetMovie(), and Video().

140 {
141  SharedPtr<Sound> sound = SceneManager::getSingleton()->getRenderer()->getSound(
142  afile,
144  true);
145 
146  SharedPtr<Source> source = SceneManager::getSingleton()->createSource(
147  sound,
148  false);
149 
150  source->setAttenuated(false);
151  source->setRelative(true);
152  source->setPosition(LVector3(0,0,1));
153  source->setDirection(Vector3(0,0,-1));
154  source->setVelocity(Vector3(0,0,0));
155  source->setRadius(1.0);
156  source->setGain(1.0);
157 
158  SceneManager::getSingleton()->getScene(scene)->add(source);
159 
160  return source;
161 }
void BaseUtil::DestroyVideoSoundStream ( SharedPtr< Source source,
const std::string &  scene 
)

Definition at line 163 of file base_util.cpp.

Referenced by BaseInterface::Room::BaseVSMovie::SetMovie(), and BaseInterface::Room::BaseVSSprite::~BaseVSSprite().

164 {
165  if (source->isPlaying())
166  source->stopPlaying();
167  SceneManager::getSingleton()->getScene(scene)->remove(source);
168 }
void BaseUtil::EjectPython ( int  room,
std::string  index,
std::string  pythonfile,
float  x,
float  y,
float  wid,
float  hei,
std::string  text 
)

Definition at line 493 of file base_util.cpp.

References BaseLink(), CheckRoom(), and BaseInterface::Room::links.

494 {
495  BaseInterface::Room *newroom = CheckRoom( room );
496  if (!newroom) return;
497  newroom->links.push_back( new BaseInterface::Room::Eject( index, pythonfile ) );
498  BaseLink( newroom, x, y, wid, hei, text );
499 }
void BaseUtil::EnqueueMessage ( std::string  text)

Definition at line 595 of file base_util.cpp.

References BaseInterface::CurrentBase, and EnqueueMessageToRoom().

596 {
597  if (!BaseInterface::CurrentBase) return;
599 }
void BaseUtil::EnqueueMessageToRoom ( int  room,
std::string  text 
)

Definition at line 585 of file base_util.cpp.

References BaseInterface::CurrentBase, and BaseInterface::rooms.

Referenced by EnqueueMessage().

586 {
587  if (!BaseInterface::CurrentBase) return;
588  BaseInterface::CurrentBase->rooms[room]->objs.push_back( new BaseInterface::Room::BaseTalk( text, "currentmsg", false ) );
589 }
void BaseUtil::EraseLink ( int  room,
std::string  index 
)

Definition at line 600 of file base_util.cpp.

References CheckRoom(), i, int, and BaseInterface::Room::links.

601 {
602  BaseInterface::Room *newroom = CheckRoom( room );
603  if (!newroom) return;
604  for (int i = 0; i < (int) newroom->links.size(); i++)
605  if (newroom->links[i]) {
606  if (newroom->links[i]->index == index) {
607  newroom->links.erase( newroom->links.begin()+i );
608  i--;
609 //break;
610  }
611  }
612 }
void BaseUtil::EraseObj ( int  room,
std::string  index 
)

Definition at line 613 of file base_util.cpp.

References CheckRoom(), i, int, and BaseInterface::Room::objs.

614 {
615  BaseInterface::Room *newroom = CheckRoom( room );
616  if (!newroom) return;
617  for (int i = 0; i < (int) newroom->objs.size(); i++)
618  if (newroom->objs[i]) {
619  if (newroom->objs[i]->index == index) {
620  newroom->objs.erase( newroom->objs.begin()+i );
621  i--;
622 //break;
623  }
624  }
625 }
void BaseUtil::ExitGame ( )

Definition at line 753 of file base_util.cpp.

References CockpitKeys::QuitNow().

754 {
756 }
int BaseUtil::GetCurRoom ( )

Definition at line 626 of file base_util.cpp.

References BaseInterface::CurrentBase, and BaseInterface::curroom.

Referenced by BaseUtil::VideoAudioStreamListener::onEndOfStream().

627 {
628  if (!BaseInterface::CurrentBase) return -1;
630 }
const Dictionary & BaseUtil::GetEventData ( )

Definition at line 711 of file base_util.cpp.

References _GetEventData().

Referenced by GetEventDataPython().

712 {
713  return _GetEventData();
714 }
int BaseUtil::GetNumRoom ( )

Definition at line 638 of file base_util.cpp.

References BaseInterface::CurrentBase, and BaseInterface::rooms.

639 {
640  if (!BaseInterface::CurrentBase) return -1;
641  return BaseInterface::CurrentBase->rooms.size();
642 }
float BaseUtil::GetTextHeight ( std::string  text,
Vector  widheimult 
)

Definition at line 716 of file base_util.cpp.

References g_game, getFontHeight(), VegaConfig::getVariable(), XMLSupport::parse_bool(), XMLSupport::parse_float(), vs_config, and game_data_t::y_resolution.

717 {
718  static bool force_highquality = true;
719  static bool use_bit = force_highquality
720  || XMLSupport::parse_bool( vs_config->getVariable( "graphics", "high_quality_font", "false" ) );
721  static float font_point = XMLSupport::parse_float( vs_config->getVariable( "graphics", "font_point", "16" ) );
722  return use_bit ? getFontHeight() : (font_point*2/g_game.y_resolution);
723 }
float BaseUtil::GetTextWidth ( std::string  text,
Vector  widheimult 
)

Definition at line 725 of file base_util.cpp.

726 {
727  //Unsupported for now
728  return 0;
729 }
void BaseUtil::GlobalKeyPython ( std::string  pythonfile)

Definition at line 574 of file base_util.cpp.

References BaseInterface::CurrentBase, and BaseInterface::python_kbhandler.

575 {
578 }
bool BaseUtil::HasObject ( int  room,
std::string  index 
)

Definition at line 71 of file base_util_server.cpp.

72 {
73  return false;
74 }
void BaseUtil::Launch ( int  room,
std::string  index,
float  x,
float  y,
float  wid,
float  hei,
std::string  text 
)

Definition at line 475 of file base_util.cpp.

References LaunchPython().

Referenced by BaseInterface::BaseInterface(), and BaseInterface::Room::Click().

476 {
477  LaunchPython( room, index, "", x, y, wid, hei, text );
478 }
void BaseUtil::LaunchPython ( int  room,
std::string  index,
std::string  pythonfile,
float  x,
float  y,
float  wid,
float  hei,
std::string  text 
)

Definition at line 479 of file base_util.cpp.

References BaseLink(), CheckRoom(), and BaseInterface::Room::links.

Referenced by Launch().

487 {
488  BaseInterface::Room *newroom = CheckRoom( room );
489  if (!newroom) return;
490  newroom->links.push_back( new BaseInterface::Room::Launch( index, pythonfile ) );
491  BaseLink( newroom, x, y, wid, hei, text );
492 }
void BaseUtil::Link ( int  room,
std::string  index,
float  x,
float  y,
float  wid,
float  hei,
std::string  text,
int  to 
)

Definition at line 455 of file base_util.cpp.

References LinkPython().

456 {
457  LinkPython( room, index, "", x, y, wid, hei, text, to );
458 }
void BaseUtil::LinkPython ( int  room,
std::string  index,
std::string  pythonfile,
float  x,
float  y,
float  wid,
float  hei,
std::string  text,
int  to 
)

Definition at line 459 of file base_util.cpp.

References BaseLink(), CheckRoom(), and BaseInterface::Room::links.

Referenced by Link().

468 {
469  BaseInterface::Room *newroom = CheckRoom( room );
470  if (!newroom) return;
471  newroom->links.push_back( new BaseInterface::Room::Goto( index, pythonfile ) );
472  BaseLink( newroom, x, y, wid, hei, text );
473  ( (BaseInterface::Room::Goto*) newroom->links.back() )->index = to;
474 }
void BaseUtil::LoadBaseInterface ( std::string  name)
void BaseUtil::LoadBaseInterface ( string  name)

Definition at line 731 of file base_util.cpp.

References UniverseUtil::getPlayer(), and LoadBaseInterfaceAtDock().

Referenced by GameCockpit::Draw().

void BaseUtil::LoadBaseInterfaceAtDock ( std::string  name,
Unit dockat,
Unit dockee 
)
void BaseUtil::LoadBaseInterfaceAtDock ( string  name,
Unit dockat,
Unit dockee 
)

Definition at line 736 of file base_util.cpp.

References BaseInterface::CurrentBase, BaseInterface::InitCallbacks(), and BaseInterface::Terminate().

Referenced by LoadBaseInterface(), and GameUnit< UnitType >::UpgradeInterface().

737 {
740  BaseInterface *base = new BaseInterface( name.c_str(), dockat, dockee );
741  base->InitCallbacks();
742 }
void BaseUtil::Message ( std::string  text)

Definition at line 590 of file base_util.cpp.

References BaseInterface::CurrentBase, and MessageToRoom().

591 {
592  if (!BaseInterface::CurrentBase) return;
593  MessageToRoom( BaseInterface::CurrentBase->curroom, text );
594 }
void BaseUtil::MessageToRoom ( int  room,
std::string  text 
)

Definition at line 580 of file base_util.cpp.

References BaseInterface::CurrentBase, and BaseInterface::rooms.

Referenced by Message().

581 {
582  if (!BaseInterface::CurrentBase) return;
583  BaseInterface::CurrentBase->rooms[room]->objs.push_back( new BaseInterface::Room::BaseTalk( text, "currentmsg", true ) );
584 }
void BaseUtil::PlayVideo ( int  room,
std::string  index 
)

Definition at line 278 of file base_util.cpp.

References CheckRoom(), i, and BaseInterface::Room::objs.

279 {
280  BaseInterface::Room *newroom = CheckRoom( room );
281  if (!newroom) return;
282  for (size_t i = 0; i < newroom->objs.size(); i++)
283  if (newroom->objs[i]) {
284  if (newroom->objs[i]->index == index) {
285  //FIXME: Will crash if not a Sprite object.
286  SharedPtr<Source> source = dynamic_cast< BaseInterface::Room::BaseVSSprite* > (newroom->objs[i])->soundsource;
287  if (source.get() != NULL) {
288  if (!source->isPlaying())
289  source->startPlaying();
290  }
291  }
292  }
293 }
void BaseUtil::Python ( int  room,
std::string  index,
float  x,
float  y,
float  wid,
float  hei,
std::string  text,
std::string  pythonfile 
)

Definition at line 58 of file base_util_server.cpp.

58 {}
void BaseUtil::Python ( int  room,
std::string  index,
float  x,
float  y,
float  wid,
float  hei,
std::string  text,
std::string  pythonfile,
bool  front 
)

Definition at line 553 of file base_util.cpp.

References BaseLink(), CheckRoom(), and BaseInterface::Room::links.

562 {
563  //instead of "Talk"/"Say" tags
564  BaseInterface::Room *newroom = CheckRoom( room );
565  if (!newroom) return;
567  if (front)
568  newroom->links.insert( newroom->links.begin(), tmp );
569  else
570  newroom->links.push_back( tmp );
571  BaseLink( newroom, x, y, wid, hei, text, front );
572 }
void BaseUtil::refreshBaseComputerUI ( const class Cargo dirtyCarg)

Definition at line 75 of file base_util_server.cpp.

75 {}
void BaseUtil::refreshBaseComputerUI ( const Cargo carg)

Definition at line 744 of file base_util.cpp.

References BaseComputer::dirty.

745 {
746  if (carg)
747  //BaseComputer::draw() used dirty to determine what to recalculate.
748  BaseComputer::dirty = 1; //everything.
749  else
750  BaseComputer::dirty = 2; //only title.
751 }
int BaseUtil::Room ( std::string  text)

Definition at line 117 of file base_util.cpp.

References BaseInterface::CurrentBase, and BaseInterface::rooms.

118 {
119  if (!BaseInterface::CurrentBase) return -1;
121  BaseInterface::CurrentBase->rooms.back()->deftext = text;
122  return BaseInterface::CurrentBase->rooms.size()-1;
123 }
void BaseUtil::RunScript ( int  room,
std::string  ind,
std::string  pythonfile,
float  time 
)

Definition at line 324 of file base_util.cpp.

References CheckRoom(), and BaseInterface::Room::objs.

325 {
326  BaseInterface::Room *newroom = CheckRoom( room );
327  if (!newroom) return;
328  newroom->objs.push_back( new BaseInterface::Room::BasePython( ind, pythonfile, time ) );
329 }
bool BaseUtil::SellShip ( std::string  name)
void BaseUtil::SetCurRoom ( int  room)

Definition at line 631 of file base_util.cpp.

References CheckRoom(), BaseInterface::CurrentBase, and BaseInterface::GotoLink().

632 {
633  BaseInterface::Room *newroom = CheckRoom( room );
634  if (!newroom) return;
635  if (!BaseInterface::CurrentBase) return;
637 }
void BaseUtil::SetDJEnabled ( bool  enabled)

Definition at line 310 of file base_util.cpp.

References BaseInterface::CurrentBase, BaseInterface::setDJEnabled(), and Music::Stop().

311 {
313  if (!enabled)
314  Music::Stop();
315 }
void BaseUtil::SetEventData ( Dictionary  data)
void BaseUtil::SetEventData ( BoostPythonDictionary  data)

Definition at line 662 of file base_util.cpp.

References _GetEventData().

663 {
664  _GetEventData() = data;
665 }
void BaseUtil::SetKeyEventData ( std::string  type,
unsigned int  keycode,
unsigned int  modmask 
)

Definition at line 694 of file base_util.cpp.

References _GetEventData(), and SetKeyStatusEventData().

Referenced by BaseInterface::Key().

695 {
697 
698  //Event type
699  data["type"] = type;
700 
701  //Keycode
702  data["key"] = keycode;
703  if ( (keycode > 0x20) && (keycode < 0xff) )
704  data["char"] = string( 1, keycode );
705 
706  else
707  data["char"] = string();
708  SetKeyStatusEventData( modmask );
709 }
void BaseUtil::SetKeyStatusEventData ( unsigned int  modmask)

Definition at line 682 of file base_util.cpp.

References _GetEventData(), KB_MOD_ALT, KB_MOD_CTRL, KB_MOD_SHIFT, and pullActiveModifiers().

Referenced by SetKeyEventData(), and SetMouseEventData().

683 {
685  //Keyboard modifiers (for kb+mouse)
686  if (modmask == UINT_MAX )
687  modmask = pullActiveModifiers();
688  data["modifiers"] = modmask;
689  data["alt"] = ( (modmask&KB_MOD_ALT) != 0 );
690  data["shift"] = ( (modmask&KB_MOD_SHIFT) != 0 );
691  data["ctrl"] = ( (modmask&KB_MOD_CTRL) != 0 );
692 }
void BaseUtil::SetLinkArea ( int  room,
std::string  index,
float  x,
float  y,
float  wid,
float  hei 
)

Definition at line 356 of file base_util.cpp.

References CheckRoom(), i, BaseInterface::Room::links, x, and y.

357 {
358  BaseInterface::Room *newroom = CheckRoom( room );
359  if (!newroom) return;
360  for (size_t i = 0; i < newroom->links.size(); i++)
361  if (newroom->links[i]) {
362  if (newroom->links[i]->index == index) {
363  newroom->links[i]->x = x;
364  newroom->links[i]->y = y;
365  newroom->links[i]->wid = wid;
366  newroom->links[i]->hei = hei;
367  }
368  }
369 }
void BaseUtil::SetLinkEventMask ( int  room,
std::string  index,
std::string  maskdef 
)

Definition at line 399 of file base_util.cpp.

References CheckRoom(), BaseInterface::Room::Link::ClickEvent, BaseInterface::Room::Link::DownEvent, BaseInterface::Room::Link::EnterEvent, fprintf, i, BaseInterface::Room::Link::LeaveEvent, BaseInterface::Room::links, and BaseInterface::Room::Link::UpEvent.

400 {
401  size_t i;
402  //c=click, u=up, d=down, e=enter, l=leave, m=move
403  unsigned int mask = 0;
404  for (i = 0; i < maskdef.length(); ++i) {
405  switch (maskdef[i])
406  {
407  case 'c':
408  case 'C':
410  break;
411  case 'u':
412  case 'U':
414  break;
415  case 'd':
416  case 'D':
418  break;
419  case 'e':
420  case 'E':
422  break;
423  case 'l':
424  case 'L':
426  break;
427  case 'm':
428  case 'M':
429  fprintf( stderr, "%s: WARNING: Ignoring request for movement event mask.\n", __FILE__ );
430  break;
431  }
432  }
433  BaseInterface::Room *newroom = CheckRoom( room );
434  if (!newroom) return;
435  for (i = 0; i < newroom->links.size(); i++)
436  if (newroom->links[i]) {
437  if (newroom->links[i]->index == index)
438  //FIXME: Will crash if not a Goto object.
439  newroom->links[i]->setEventMask( mask );
440  }
441 }
void BaseUtil::SetLinkPython ( int  room,
std::string  index,
std::string  python 
)

Definition at line 379 of file base_util.cpp.

References CheckRoom(), i, and BaseInterface::Room::links.

380 {
381  BaseInterface::Room *newroom = CheckRoom( room );
382  if (!newroom) return;
383  for (size_t i = 0; i < newroom->links.size(); i++)
384  if (newroom->links[i])
385  if (newroom->links[i]->index == index)
386  newroom->links[i]->Relink( python );
387 }
void BaseUtil::SetLinkRoom ( int  room,
std::string  index,
int  to 
)

Definition at line 388 of file base_util.cpp.

References CheckRoom(), i, and BaseInterface::Room::links.

389 {
390  BaseInterface::Room *newroom = CheckRoom( room );
391  if (!newroom) return;
392  for (size_t i = 0; i < newroom->links.size(); i++)
393  if (newroom->links[i]) {
394  if (newroom->links[i]->index == index)
395  //FIXME: Will crash if not a Goto object.
396  dynamic_cast< BaseInterface::Room::Goto* > (newroom->links[i])->index = to;
397  }
398 }
void BaseUtil::SetLinkText ( int  room,
std::string  index,
std::string  text 
)

Definition at line 370 of file base_util.cpp.

References CheckRoom(), i, and BaseInterface::Room::links.

371 {
372  BaseInterface::Room *newroom = CheckRoom( room );
373  if (!newroom) return;
374  for (size_t i = 0; i < newroom->links.size(); i++)
375  if (newroom->links[i])
376  if (newroom->links[i]->index == index)
377  newroom->links[i]->text = text;
378 }
void BaseUtil::SetMouseEventData ( std::string  type,
float  x,
float  y,
int  buttonMask 
)

Definition at line 667 of file base_util.cpp.

References _GetEventData(), SetKeyStatusEventData(), x, and y.

Referenced by BaseInterface::Room::Link::Click(), BaseInterface::Room::Link::MouseEnter(), BaseInterface::Room::Link::MouseLeave(), and BaseInterface::Room::Link::MouseMove().

668 {
670 
671  //Event type
672  data["type"] = type;
673 
674  //Mouse data
675  data["mousex"] = x;
676  data["mousey"] = y;
677  data["mousebuttons"] = buttonMask;
678 
680 }
void BaseUtil::SetTextBoxText ( int  room,
std::string  index,
std::string  text 
)

Definition at line 345 of file base_util.cpp.

References CheckRoom(), i, and BaseInterface::Room::objs.

346 {
347  BaseInterface::Room *newroom = CheckRoom( room );
348  if (!newroom) return;
349  for (size_t i = 0; i < newroom->objs.size(); i++)
350  if (newroom->objs[i]) {
351  if (newroom->objs[i]->index == index)
352  //FIXME: Will crash if not a Text object.
353  dynamic_cast< BaseInterface::Room::BaseText* > (newroom->objs[i])->SetText( text );
354  }
355 }
void BaseUtil::SetTexture ( int  room,
std::string  index,
std::string  file 
)

Definition at line 245 of file base_util.cpp.

References CheckRoom(), i, and BaseInterface::Room::objs.

246 {
247  BaseInterface::Room *newroom = CheckRoom( room );
248  if (!newroom) return;
249  for (size_t i = 0; i < newroom->objs.size(); i++)
250  if (newroom->objs[i]) {
251  if (newroom->objs[i]->index == index)
252  //FIXME: Will crash if not a Sprite object.
253  dynamic_cast< BaseInterface::Room::BaseVSSprite* > (newroom->objs[i])->SetSprite( file );
254  }
255 }
void BaseUtil::SetTexturePos ( int  room,
std::string  index,
float  x,
float  y 
)

Definition at line 267 of file base_util.cpp.

References CheckRoom(), i, and BaseInterface::Room::objs.

268 {
269  BaseInterface::Room *newroom = CheckRoom( room );
270  if (!newroom) return;
271  for (size_t i = 0; i < newroom->objs.size(); i++)
272  if (newroom->objs[i]) {
273  if (newroom->objs[i]->index == index)
274  //FIXME: Will crash if not a Sprite object.
275  dynamic_cast< BaseInterface::Room::BaseVSSprite* > (newroom->objs[i])->SetPos( x, y );
276  }
277 }
void BaseUtil::SetTextureSize ( int  room,
std::string  index,
float  w,
float  h 
)

Definition at line 256 of file base_util.cpp.

References CheckRoom(), i, and BaseInterface::Room::objs.

257 {
258  BaseInterface::Room *newroom = CheckRoom( room );
259  if (!newroom) return;
260  for (size_t i = 0; i < newroom->objs.size(); i++)
261  if (newroom->objs[i]) {
262  if (newroom->objs[i]->index == index)
263  //FIXME: Will crash if not a Sprite object.
264  dynamic_cast< BaseInterface::Room::BaseVSSprite* > (newroom->objs[i])->SetSize( w, h );
265  }
266 }
void BaseUtil::SetVideoCallback ( int  room,
std::string  index,
std::string  callback 
)

Definition at line 223 of file base_util.cpp.

References CheckRoom(), i, BaseInterface::Room::objs, BaseInterface::Room::BaseVSMovie::setCallback(), and BaseInterface::Room::BaseVSSprite::soundsource.

224 {
225  BaseInterface::Room *newroom = CheckRoom( room );
226  if (!newroom) return;
227  for (size_t i = 0; i < newroom->objs.size(); i++) {
228  if (newroom->objs[i]) {
229  if (newroom->objs[i]->index == index) {
230  //FIXME: Will crash if not a Sprite object.
232  dynamic_cast< BaseInterface::Room::BaseVSMovie* > (newroom->objs[i]);
233  movie->setCallback(callback);
234 
235  if (movie->soundsource.get() != NULL) {
236  SharedPtr<SourceListener> transitionListener(
237  new VideoAudioStreamListener(room, index) );
238 
239  movie->soundsource->setSourceListener(transitionListener);
240  }
241  }
242  }
243  }
244 }
void BaseUtil::Ship ( int  room,
std::string  index,
QVector  pos,
Vector  Q,
Vector  R 
)

Definition at line 316 of file base_util.cpp.

References CheckRoom(), BaseInterface::Room::objs, and Vector.

Referenced by Briefing::AddStarship().

317 {
318  BaseInterface::Room *newroom = CheckRoom( room );
319  if (!newroom) return;
320  Vector P = R.Cross( Q );
321  P.Normalize();
322  newroom->objs.push_back( new BaseInterface::Room::BaseShip( P.i, P.j, P.k, Q.i, Q.j, Q.k, R.i, R.j, R.k, pos, index ) );
323 }
void BaseUtil::StopVideo ( int  room,
std::string  index 
)

Definition at line 294 of file base_util.cpp.

References CheckRoom(), i, and BaseInterface::Room::objs.

295 {
296  BaseInterface::Room *newroom = CheckRoom( room );
297  if (!newroom) return;
298  for (size_t i = 0; i < newroom->objs.size(); i++)
299  if (newroom->objs[i]) {
300  if (newroom->objs[i]->index == index) {
301  //FIXME: Will crash if not a Sprite object.
302  SharedPtr<Source> source = dynamic_cast< BaseInterface::Room::BaseVSSprite* > (newroom->objs[i])->soundsource;
303  if (source.get() != NULL) {
304  if (source->isPlaying())
305  source->stopPlaying();
306  }
307  }
308  }
309 }
void BaseUtil::TextBox ( int  room,
std::string  ind,
std::string  text,
float  x,
float  y,
Vector  widheimult,
Vector  backcol,
float  backalp,
Vector  forecol 
)

Definition at line 330 of file base_util.cpp.

References CheckRoom(), and BaseInterface::Room::objs.

339 {
340  BaseInterface::Room *newroom = CheckRoom( room );
341  if (!newroom) return;
342  newroom->objs.push_back( new BaseInterface::Room::BaseText( text, x, y, widheimult.i, widheimult.j, widheimult.k,
343  GFXColor( backcol, backalp ), GFXColor( forecol ), ind ) );
344 }
void BaseUtil::Texture ( int  room,
std::string  index,
std::string  file,
float  x,
float  y 
)

Definition at line 124 of file base_util.cpp.

References CheckRoom(), VegaConfig::getVariable(), index, BaseInterface::Room::objs, XMLSupport::parse_bool(), and vs_config.

Referenced by ActivateWhite(), DecalQueue::AddTexture(), Background::Background(), Texture::Clone(), Technique::Pass::compile(), GameStarSystem::createBackground(), createTexture(), FactionUtil::createTexture(), ParticleTrail::DrawAndUpdate(), Texture::modold(), Flightgroup::newFlightgroup(), GuiTexture::read(), VSSprite::ReadTexture(), SpriteStarVlist::SpriteStarVlist(), Video(), and VSSprite::VSSprite().

125 {
126  BaseInterface::Room *newroom = CheckRoom( room );
127  if (!newroom) return;
128  newroom->objs.push_back( new BaseInterface::Room::BaseVSSprite( file.c_str(), index ) );
129 #ifdef BASE_MAKER
130  ( (BaseInterface::Room::BaseVSSprite*) newroom->objs.back() )->texfile = file;
131 #endif
132  float tx = 0, ty = 0;
133  static bool addspritepos = XMLSupport::parse_bool( vs_config->getVariable( "graphics", "offset_sprites_by_pos", "true" ) );
134  if (addspritepos)
135  ( (BaseInterface::Room::BaseVSSprite*) newroom->objs.back() )->spr.GetPosition( tx, ty );
136  dynamic_cast< BaseInterface::Room::BaseVSSprite* > ( newroom->objs.back() )->spr.SetPosition( x+tx, y+ty );
137 }
bool BaseUtil::Video ( int  room,
std::string  index,
std::string  file,
float  x,
float  y 
)

Definition at line 12 of file base_util_server.cpp.

12 { return false; }
bool BaseUtil::Video ( int  room,
std::string  index,
std::string  vfile,
std::string  afile,
float  x,
float  y 
)

Definition at line 170 of file base_util.cpp.

References CheckRoom(), CreateVideoSoundStream(), e, g_game, BaseInterface::Room::objs, VSSprite::Reset(), VSSprite::SetTimeSource(), game_data_t::sound_enabled, BaseInterface::Room::BaseVSSprite::soundscene, BaseInterface::Room::BaseVSSprite::soundsource, BaseInterface::Room::BaseVSSprite::spr, and Texture().

171 {
172  BaseInterface::Room *newroom = CheckRoom( room );
173  if (!newroom) return false;
174  BaseUtil::Texture( room, index, vfile, x, y );
175 
176  BaseInterface::Room::BaseVSSprite *baseSprite = dynamic_cast< BaseInterface::Room::BaseVSSprite* > ( newroom->objs.back() );
177 
178  if (!afile.empty()) {
179  if (g_game.sound_enabled) {
180  try {
181  baseSprite->soundscene = "video";
182  baseSprite->soundsource = CreateVideoSoundStream( afile, baseSprite->soundscene );
183  baseSprite->spr.SetTimeSource( baseSprite->soundsource );
184  } catch(Audio::FileOpenException e) {
185  baseSprite->spr.Reset();
186  } catch(VidFile::FileOpenException e) {
187  baseSprite->spr.Reset();
188  }
189  } else {
190  baseSprite->spr.Reset();
191  }
192  }
193 
194  return true;
195 }
bool BaseUtil::VideoStream ( int  room,
std::string  index,
std::string  streamfile,
float  x,
float  y,
float  w,
float  h 
)

Definition at line 196 of file base_util.cpp.

References CheckRoom(), accountXML::file, fprintf, VSSprite::LoadSuccess(), BaseInterface::Room::objs, BaseInterface::Room::BaseVSSprite::SetPos(), BaseInterface::Room::BaseVSSprite::SetSize(), and BaseInterface::Room::BaseVSSprite::spr.

197 {
198  BaseInterface::Room *newroom = CheckRoom( room );
199  if (!newroom) {
200  fprintf(stderr, "ERROR: Room not found!!\n");
201  return false;
202  }
203 
205  newobj->SetPos( x, y );
206  newobj->SetSize( w, h );
207 
208 #ifdef BASE_MAKER
209  newobj->texfile = file;
210 #endif
211 
212  if (newobj->spr.LoadSuccess()) {
213  fprintf(stdout, "INFO: Added video stream %s\n", streamfile.c_str());
214  newroom->objs.push_back( newobj );
215  } else {
216  fprintf(stdout, "INFO: Missing video stream %s\n", streamfile.c_str());
217  delete newobj;
218  return false;
219  }
220 
221  return true;
222 }