193 using namespace CockpitXML;
197 string::size_type where = inp.rfind(
"." );
199 if (x < 700) x = 640;
210 if (where == string::npos)
211 return inp+
"_"+rez+
".spr";
213 return inp.substr( 0, where )+
"_"+rez+
".spr";
216 void GameCockpit::beginElement(
const string &name,
const AttributeList &attributes )
218 static bool cockpit_smooth =
220 static bool panel_smooth =
222 static bool crosshair_smooth =
224 AttributeList::const_iterator iter;
229 std::string gaugename(
"shieldstat.spr" );
230 std::string myfont(
"9x12.font" );
233 unsigned int mymodes = 0;
234 float xsize = -1, ysize = -1, xcent = FLT_MAX, ycent = FLT_MAX;
243 bool replaced[4] = {
false,
false,
false,
false};
248 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
253 myfont = (*iter).value;
275 std::string tmp =
getRes( (*iter).value );
278 if ( !Pit[0]->LoadSuccess() ) {
288 SetSoundFile( (*iter).value );
298 std::string tmp =
getRes( (*iter).value );
299 oldpit = Pit[attr-
FRONT];
301 if ( !Pit[attr-
FRONT]->LoadSuccess() ) {
302 delete Pit[attr-
FRONT];
305 replaced[attr-
FRONT] =
true;
315 for (counter = 0; counter < 4; ++counter)
316 if (!replaced[counter]) {
318 Pit[counter] =
false;
375 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
379 gaugename = (*iter).value;
427 gauges[elem] =
new Gauge( gaugename.c_str(), tmpdir );
429 gauges[elem]->
SetSize( xsize, ysize );
430 if (xcent != FLT_MAX)
431 gauges[elem]->SetPosition( xcent, ycent );
432 if (leftx != -10 && rightx != -10 && topy != -10 && boty != -10) {
433 gauges[elem]->SetPosition( .5*(leftx+rightx), .5*(topy+boty) );
434 gauges[elem]->SetSize( fabs( leftx-rightx ), fabs( topy-boty ) );
440 if (Panel.size() == 0)
441 Panel.push_back( NULL );
442 if ( Panel.front() ) {
443 delete Panel.front();
444 Panel.front() = NULL;
446 newsprite = &Panel.front();
448 if (Panel.size() == 0)
449 Panel.push_back( NULL );
450 Panel.push_back( NULL );
451 newsprite = &Panel.back();
455 newsprite = &radarSprites[0];
458 newsprite = &radarSprites[1];
461 vdu.push_back( NULL );
462 newvdu = &vdu.back();
465 #ifdef NETCOMM_WEBCAM
472 vdu.push_back( NULL );
473 newvdu = &vdu.back();
478 vdu.push_back( NULL );
479 newvdu = &vdu.back();
481 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
487 std::string firstmode = (*iter).value.substr( 0, (*iter).value.find(
" " ) );
497 for (iter = attributes.begin(); iter != attributes.end(); iter++) {
507 std::string tmp =
getRes( (*iter).value );
508 bool bil = elem ==
PANEL ? panel_smooth : crosshair_smooth;
510 if ( !(*newsprite)->LoadSuccess() ) {
514 adjsprite = *newsprite;
516 VDU *tmp =
new VDU( (*iter).value.c_str(), text, mymodes, rows, cols, &StartArmor[0], &maxhull );
519 if (tmp->
getMode() != default_mode) {
520 for (
int i = 0;
i < 32; ++
i) {
522 if (tmp->
getMode() == default_mode)
563 adjsprite->
SetSize( xsize, ysize );
564 if (xcent != FLT_MAX)
566 if (leftx != -10 && rightx != -10 && topy != -10 && boty != -10) {
567 adjsprite->
SetPosition( .5*(leftx+rightx), .5*(topy+boty) );
568 adjsprite->
SetSize( fabs( leftx-rightx ), fabs( topy-boty ) );
570 }
else if ( newsprite == &Panel.back() ) {
571 Panel.erase( Panel.end()-1 );
579 void GameCockpit::endElement(
const string &name )
583 using namespace VSFileSystem;
585 void GameCockpit::LoadXML(
const char *filename )
587 const int chunk_size = 16384;
591 if (filename[0] !=
'\0')
601 Panel.push_back(
new VSSprite(
"crosshairs.spr" ) );
604 XML_Parser parser = XML_ParserCreate( NULL );
605 XML_SetUserData( parser,
this );
608 XML_Parse( parser, ( f.
ReadFull() ).c_str(), f.
Size(), 1 );
628 XML_ParserFree( parser );