void CAudioManager::Initialize( std::string audio_xml ) { m_pXA = CSGD_XAudio2::GetInstance(); TiXmlDocument x_doc; x_doc.LoadFile( audio_xml.c_str() ); //assert(x_doc.LoadFile( audio_xml.c_str()) != false && " Font XML file could not be loaded"); TiXmlElement* x_pRoot = x_doc.RootElement(); //assert( x_pRoot != nullptr && "XML root is NULL"); TiXmlElement* x_pBGM = x_pRoot->FirstChildElement("BGM"); TiXmlElement* x_pXWM = x_pBGM->FirstChildElement("XWM"); XWM* song; std::string file; TOSTRINGSTREAM wss; while(x_pXWM != nullptr ) { song = new XWM; song->file = x_pXWM->Attribute("file"); wss.str(L""); wss << song->file.c_str(); song->id = m_pXA->MusicLoadSong( wss.str().c_str() ); m_vBGM.push_back(song); x_pXWM = x_pXWM->NextSiblingElement("XWM"); } TiXmlElement* x_pSFX = x_pBGM->NextSiblingElement("SFX"); TiXmlElement* x_pWAV = x_pSFX->FirstChildElement("WAV"); WAV* sound; while( x_pWAV != nullptr ) { sound = new WAV; sound->file = x_pWAV->Attribute("file"); wss.str(L""); wss << sound->file.c_str(); sound->id = m_pXA->SFXLoadSound( wss.str().c_str() ); m_vSFX.push_back(sound); x_pWAV = x_pWAV->NextSiblingElement("WAV"); } }
TSTRING cCharEncoderUtil::char_to_hex( TCHAR ch ) { TOSTRINGSTREAM ss; ss.imbue( std::locale::classic() ); ss.fill ( _T('0') ); ss.width( TCHAR_AS_HEX__IN_TCHARS ); ss.setf( std::ios_base::hex, std::ios_base::basefield ); ss << tss::util::char_to_size( ch ); if( ss.bad() || ss.fail() || ss.str().length() != TCHAR_AS_HEX__IN_TCHARS ) ThrowAndAssert( eBadHexConversion( TSTRING( 1, ch ) ) ); return ss.str(); }
// Render // - render the game entities void CGame::Render( void ) { // Clear the backbuffer m_pD3D->Clear( D3DCOLOR_XRGB( 255, 0, 0 ) ); // Begin rendering m_pD3D->DeviceBegin(); m_pD3D->SpriteBegin(); m_pGameState->RenderAll(); if (m_bShowFPS == true) { // Use an output string stream to format numbers TOSTRINGSTREAM output; output << _T("FPS: ") << m_nFPS; m_pD3D->DrawText(output.str().c_str(), 0, 0, D3DCOLOR_ARGB(255, 0, 0, 0) ); } m_pD3D->SpriteEnd(); m_pD3D->DeviceEnd(); // Present the back buffer to the screen m_pD3D->Present(); }
// NOTE: this version ALWAYS IGNORES the va_list!! Even though it says "...", // it doesn't look at any args following pszErr // Only call this with fully formatted message // Parser will ALWAYS call the narrow-char version, so special case Unicode compile void tw_yy_scan::yyerror( const char* pszErr, ... ) //throw( eParserHelper ) { TOSTRINGSTREAM ssError; // final error string ssError << pszErr; throw eParseFailed( ssError.str() ); }
TSTRING cFCOPropUint64::AsString() const { //TODO:mdb -- implement this through twlocale! // TOSTRINGSTREAM ostr; ostr.imbue( std::locale::classic() ); ostr << (int32)mValue ; return TSTRING(ostr.str()); }
void cPipedMailMessage::SendString(const TSTRING& s) { if (_ftprintf(mpFile, "%s", s.c_str()) < 0) { TOSTRINGSTREAM estr; estr << TSS_GetString(cTripwire, tripwire::STR_ERR2_MAIL_MESSAGE_COMMAND) << mstrSendMailExePath; throw eMailPipedOpen(estr.str()); } }
/////////////////////////////////////////////////////////////////////////////// // PrintPropVector -- function that prints the contents of a cFCOPropVector // TODO: We might want to add this functionality to the property vector some // day... /////////////////////////////////////////////////////////////////////////////// static void PrintPropVector(const cFCOPropVector& v, cDebug& d) { TOSTRINGSTREAM stream; for(int i=0; i<v.GetSize(); i++) { if(v.ContainsItem(i)) stream << i << "," << " "; } stream << std::ends; d.TraceDebug("%s\n", stream.str().c_str()); }
TSTRING cCRC32Signature::AsStringHex() const { TOSTRINGSTREAM ss; ss.imbue( std::locale::classic() ); ss.setf( ios::hex, ios::basefield ); ss << (size_t)mCRCInfo.crc; return ss.str(); }
void CGame::Create_Save_Load_Directory() { char path[MAX_PATH]; LPWSTR wszPath = NULL; size_t pathlen; HRESULT hr = SHGetKnownFolderPath( FOLDERID_LocalAppData, 0, 0, &wszPath); wcstombs_s(&pathlen , path, wszPath, MAX_PATH); m_szFilepath = path; TOSTRINGSTREAM wss; wss.str(L""); m_szFilepath += "\\Trials Of Mastery"; wss << m_szFilepath.c_str(); CreateDirectory(wss.str().c_str(),0); m_szFilepath += "\\save_slots.xml"; }
TSTRING cChecksumSignature::AsStringHex() const { TOSTRINGSTREAM ss; ss.imbue( std::locale::classic() ); ss.setf( ios::hex, ios::basefield ); ASSERT( false ); ss << (size_t)(uint32) mChecksum; // TODO:BAM -- this is truncating a 64-bit value to 32 bits! return ss.str(); }
void tw_yy_scan::output( int c ) { TOSTRINGSTREAM sstr; TCHAR sz[2]; sstr << TSS_GetString( cTWParser, twparser::STR_PARSER_INVALID_CHAR ); sz[0] = (unsigned char)c; // don't want to sign extend this sz[1] = 0; sstr << sz; throw eParseFailed( sstr.str() ); }
/////////////////////////////////////////////////////////////////////////////// // TraceContents /////////////////////////////////////////////////////////////////////////////// void cFSPropSet::TraceContents(int dl) const { if(dl < 0) dl = cDebug::D_DEBUG; cDebug d("cFSPropSet::TraceContents"); TOSTRINGSTREAM ostr; ostr << _T("File Sysytem Prop Set: "); for(int i=0; i<GetNumProps(); i++) { if(mValidProps.ContainsItem(i)) { ostr << _T("[") << i << _T("]") << GetPropName(i) << _T(" = ") << GetPropAt(i)->AsString().c_str() << _T(", "); } } d.Trace(dl, _T("%s\n"), ostr.str().c_str()); }
/////////////////////////////////////////////////////////////////////////////// // SendFinit /////////////////////////////////////////////////////////////////////////////// void cPipedMailMessage::SendFinit() //throw ( eMailMessageError ) { if (mpFile) { #if !USES_MPOPEN int result = fclose(mpFile); #else int result = mpclose(mpFile); #endif if (result != 0) { TOSTRINGSTREAM estr; estr << TSS_GetString(cTripwire, tripwire::STR_ERR2_MAIL_MESSAGE_COMMAND) << mstrSendMailExePath; // uh oh! something bad has happened! throw eMailPipedCmdFailed(estr.str()); } } mpFile = 0; }
/////////////////////////////////////////////////////////////////////////////// // SendInit /////////////////////////////////////////////////////////////////////////////// void cPipedMailMessage::SendInit() // throw( eMailMessageError ) { ASSERT(mpFile == 0); TSTRING strHeader; strHeader += cStringUtil::StrToTstr(cMailMessage::Create822Header()); #if !USES_MPOPEN mpFile = popen(mstrSendMailExePath.c_str(), _T("w")); #else // call mpopen, our safe version popen mpFile = mpopen((char*)mstrSendMailExePath.c_str(), _T("w")); #endif if (!mpFile) { TOSTRINGSTREAM estr; estr << TSS_GetString(cTripwire, tripwire::STR_ERR2_MAIL_MESSAGE_COMMAND) << mstrSendMailExePath; throw eMailPipedOpen(estr.str()); } SendString(strHeader); }
void GameInfo::Display( int x, int y ) { CSGD_Direct3D* pD3D = CSGD_Direct3D::GetInstance(); FontManager* pFont = CGame::GetInstance()->GetFont(); CSGD_TextureManager* pTM = CSGD_TextureManager::GetInstance(); pTM->Draw( m_nMenuArtid, x, y); TOSTRINGSTREAM wss; wss.str(L""); wss << "Stage 0" << m_nLevel; pFont->Draw( CHINESE_TAKEAWAY , wss.str().c_str(), x + 43, y+36, 0.5f,0.5f); wss.str(L""); wss << "EXP: " << m_nExpPts; pFont->Draw( CHINESE_TAKEAWAY , wss.str().c_str(), x + 201, y+36, 0.5f,0.5f); wss.str(L""); wss << m_nFireSpl; pFont->Draw( CHINESE_TAKEAWAY , wss.str().c_str(), x + 83, y + 78, 0.5f,0.5f); wss.str(L""); wss << m_nWindSpl; pFont->Draw( CHINESE_TAKEAWAY , wss.str().c_str(), x + 160, y + 78, 0.5f,0.5f); wss.str(L""); wss << m_nIceSpl; pFont->Draw( CHINESE_TAKEAWAY , wss.str().c_str(), x + 237, y + 78, 0.5f,0.5f); wss.str(L""); wss << m_nEarthSpl; pFont->Draw( CHINESE_TAKEAWAY , wss.str().c_str(), x + 304, y + 78,0.5f,0.5f); }