本文整理汇总了C++中CStringArray::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ CStringArray::empty方法的具体用法?C++ CStringArray::empty怎么用?C++ CStringArray::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStringArray
的用法示例。
在下文中一共展示了CStringArray::empty方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetStageIconPath
CString Character::GetStageIconPath() const
{
CStringArray as;
// first try and find an icon specific to the select music screen
// so you can have different icons for music select / char select
GetDirListing( m_sCharDir+"stageicon.png", as, false, true );
GetDirListing( m_sCharDir+"stageicon.jpg", as, false, true );
GetDirListing( m_sCharDir+"stageicon.gif", as, false, true );
GetDirListing( m_sCharDir+"stageicon.bmp", as, false, true );
if( as.empty() )
{
// if that failed, try using the regular icon
GetDirListing( m_sCharDir+"card.png", as, false, true );
GetDirListing( m_sCharDir+"card.jpg", as, false, true );
GetDirListing( m_sCharDir+"card.gif", as, false, true );
GetDirListing( m_sCharDir+"card.bmp", as, false, true );
if( as.empty() )
return "";
else
return as[0];
}
else
return as[0];
}
示例2: LoadFromDir
bool KSFLoader::LoadFromDir( CString sDir, Song &out )
{
LOG->Trace( "Song::LoadFromKSFDir(%s)", sDir.c_str() );
CStringArray arrayKSFFileNames;
GetDirListing( sDir + CString("*.ksf"), arrayKSFFileNames );
/* We shouldn't have been called to begin with if there were no KSFs. */
if( arrayKSFFileNames.empty() )
RageException::Throw( "Couldn't find any KSF files in '%s'", sDir.c_str() );
if(!LoadGlobalData(out.GetSongDir() + arrayKSFFileNames[0], out))
return false;
// load the Steps from the rest of the KSF files
for( unsigned i=0; i<arrayKSFFileNames.size(); i++ )
{
Steps* pNewNotes = new Steps;
if(!LoadFromKSFFile( out.GetSongDir() + arrayKSFFileNames[i], *pNewNotes, out ))
{
delete pNewNotes;
continue;
}
out.AddSteps( pNewNotes );
}
return true;
}
示例3: GetRandomFileInDir
CString GetRandomFileInDir( CString sDir )
{
CStringArray asFiles;
GetDirListing( sDir, asFiles, false, true );
if( asFiles.empty() )
return "";
else
return asFiles[rand()%asFiles.size()];
}
示例4: GetTakingABreakPath
CString Character::GetTakingABreakPath() const
{
CStringArray as;
GetDirListing( m_sCharDir+"break.png", as, false, true );
GetDirListing( m_sCharDir+"break.jpg", as, false, true );
GetDirListing( m_sCharDir+"break.gif", as, false, true );
GetDirListing( m_sCharDir+"break.bmp", as, false, true );
if( as.empty() )
return "";
else
return as[0];
}
示例5: GetIconPath
CString Character::GetIconPath() const
{
CStringArray as;
GetDirListing( m_sCharDir+"icon.png", as, false, true );
GetDirListing( m_sCharDir+"icon.jpg", as, false, true );
GetDirListing( m_sCharDir+"icon.gif", as, false, true );
GetDirListing( m_sCharDir+"icon.bmp", as, false, true );
if( as.empty() )
return "";
else
return as[0];
}
示例6: join
CString join( const CString &Deliminator, const CStringArray& Source)
{
if( Source.empty() )
return "";
CString csTmp;
// Loop through the Array and Append the Deliminator
for( unsigned iNum = 0; iNum < Source.size()-1; iNum++ ) {
csTmp += Source[iNum];
csTmp += Deliminator;
}
csTmp += Source.back();
return csTmp;
}
示例7: DoPlayOnceFromDir
static void DoPlayOnceFromDir( CString sPath )
{
if( sPath == "" )
return;
// make sure there's a slash at the end of this path
if( sPath.Right(1) != "/" )
sPath += "/";
CStringArray arraySoundFiles;
GetDirListing( sPath + "*.mp3", arraySoundFiles );
GetDirListing( sPath + "*.wav", arraySoundFiles );
GetDirListing( sPath + "*.ogg", arraySoundFiles );
if( arraySoundFiles.empty() )
return;
int index = rand() % arraySoundFiles.size();
SOUNDMAN->PlayOnce( sPath + arraySoundFiles[index] );
}
示例8: Init
void ScreenOptionsMaster::Init()
{
ScreenOptions::Init();
// make sure volume is set to full in options, and menu lights are on
ScreenAttract::SetAttractVolume( false );
LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU );
CStringArray asLineNames;
split( LINE_NAMES, ",", asLineNames );
if( asLineNames.empty() )
RageException::Throw( "%s::LineNames is empty.", m_sName.c_str() );
CStringArray Flags;
split( OPTION_MENU_FLAGS, ";", Flags, true );
InputMode im = INPUTMODE_INDIVIDUAL;
for( unsigned i = 0; i < Flags.size(); ++i )
{
CString sFlag = Flags[i];
sFlag.MakeLower();
if( sFlag == "together" )
im = INPUTMODE_SHARE_CURSOR;
else if( sFlag == "explanations" )
;
else if( sFlag == "forceallplayers" )
{
FOREACH_PlayerNumber( pn )
GAMESTATE->m_bSideIsJoined[pn] = true;
GAMESTATE->m_MasterPlayerNumber = PlayerNumber(0);
}
else if( sFlag == "smnavigation" )
SetNavigation( NAV_THREE_KEY_MENU );
else if( sFlag == "toggle" || sFlag == "firstchoicegoesdown" )
SetNavigation( PREFSMAN->m_bArcadeOptionsNavigation? NAV_TOGGLE_THREE_KEY:NAV_TOGGLE_FIVE_KEY );
else
RageException::Throw( "Unknown flag \"%s\"", sFlag.c_str() );
}
vector<OptionRowDefinition> OptionRowDefs;
OptionRowDefs.resize( asLineNames.size() );
OptionRowHandlers.resize( asLineNames.size() );
for( unsigned i = 0; i < asLineNames.size(); ++i )
{
CString sLineName = asLineNames[i];
OptionRowDefinition &def = OptionRowDefs[i];
CString sRowCommands = LINE(sLineName);
OptionRowHandler* &pHand = OptionRowHandlers[i];
pHand = NULL;
Commands vCommands;
ParseCommands( sRowCommands, vCommands );
if( vCommands.v.size() != 1 )
RageException::Throw( "Parse error in %s::Line%s", m_sName.c_str(), sLineName.c_str() );
Command& command = vCommands.v[0];
pHand = OptionRowHandlerUtil::Make( command, def );
if( pHand == NULL )
RageException::Throw( "Invalid OptionRowHandler '%s' in %s::%s", command.GetOriginalCommandString().c_str(), m_sName.c_str(), sLineName.c_str() );
}
ASSERT( OptionRowHandlers.size() == asLineNames.size() );
InitMenu( im, OptionRowDefs, OptionRowHandlers );
}
示例9: params
RageDisplay *CreateDisplay()
{
/* We never want to bother users with having to decide which API to use.
*
* Some cards simply are too troublesome with OpenGL to ever use it, eg. Voodoos.
* If D3D8 isn't installed on those, complain and refuse to run (by default).
* For others, always use OpenGL. Allow forcing to D3D as an advanced option.
*
* If we're missing acceleration when we load D3D8 due to a card being in the
* D3D list, it means we need drivers and that they do exist.
*
* If we try to load OpenGL and we're missing acceleration, it may mean:
* 1. We're missing drivers, and they just need upgrading.
* 2. The card doesn't have drivers, and it should be using D3D8. In other words,
* it needs an entry in this table.
* 3. The card doesn't have drivers for either. (Sorry, no S3 868s.) Can't play.
*
* In this case, fail to load; don't silently fall back on D3D. We don't want
* people unknowingly using D3D8 with old drivers (and reporting obscure bugs
* due to driver problems). We'll probably get bug reports for all three types.
* #2 is the only case that's actually a bug.
*
* Actually, right now we're falling back. I'm not sure which behavior is better.
*/
CheckVideoDefaultSettings();
RageDisplay::VideoModeParams params(GetCurVideoModeParams());
CString error = "There was an error while initializing your video card.\n\n"
" PLEASE DO NOT FILE THIS ERROR AS A BUG!\n\n"
"Video Driver: "+GetVideoDriverName()+"\n\n";
CStringArray asRenderers;
split( PREFSMAN->m_sVideoRenderers, ",", asRenderers, true );
if( asRenderers.empty() )
RageException::Throw("No video renderers attempted.");
for( unsigned i=0; i<asRenderers.size(); i++ )
{
CString sRenderer = asRenderers[i];
if( sRenderer.CompareNoCase("opengl")==0 )
{
#if defined(SUPPORT_OPENGL)
error += "Initializing OpenGL...\n";
try {
return new RageDisplay_OGL( params, PREFSMAN->m_bAllowUnacceleratedRenderer );
} catch(RageException e) {
error += CString(e.what()) + "\n";
continue;
};
#endif
}
else if( sRenderer.CompareNoCase("d3d")==0 )
{
#if defined(SUPPORT_D3D)
error += "Initializing Direct3D...\n";
try {
return new RageDisplay_D3D( params );
} catch( const exception &e ) {
error += CString(e.what()) + "\n";
};
#endif
}
else if( sRenderer.CompareNoCase("null")==0 )
return new RageDisplay_Null( params );
else
RageException::Throw("Unknown video renderer value: %s", sRenderer.c_str() );
}
RageException::Throw( error );
}
示例10: LoadGlobalData
bool KSFLoader::LoadGlobalData( const CString &sPath, Song &out )
{
MsdFile msd;
if( !msd.ReadFile( sPath ) )
RageException::Throw( "Error opening file \"%s\": %s", sPath.c_str(), msd.GetError().c_str() );
float BPMPos2 = -1, BPM2 = -1, BPMPos3 = -1, BPM3 = -1;;
for( unsigned i=0; i < msd.GetNumValues(); i++ )
{
const MsdFile::value_t &sParams = msd.GetValue(i);
CString sValueName = sParams[0];
// handle the data
if( 0==stricmp(sValueName,"TITLE") )
LoadTags(sParams[1], out);
else if( 0==stricmp(sValueName,"BPM") )
out.AddBPMSegment( BPMSegment(0, strtof(sParams[1], NULL)) );
else if( 0==stricmp(sValueName,"BPM2") )
BPM2 = strtof( sParams[1], NULL );
else if( 0==stricmp(sValueName,"BPM3") )
BPM3 = strtof( sParams[1], NULL );
else if( 0==stricmp(sValueName,"BUNKI") )
BPMPos2 = strtof( sParams[1], NULL ) / 100.0f;
else if( 0==stricmp(sValueName,"BUNKI2") )
BPMPos3 = strtof( sParams[1], NULL ) / 100.0f;
else if( 0==stricmp(sValueName,"STARTTIME") )
out.m_Timing.m_fBeat0OffsetInSeconds = -strtof( sParams[1], NULL )/100;
else if( 0==stricmp(sValueName,"TICKCOUNT") ||
0==stricmp(sValueName,"STEP") ||
0==stricmp(sValueName,"DIFFICULTY"))
; /* Handled in LoadFromKSFFile; don't warn. */
else
LOG->Trace( "Unexpected value named '%s'", sValueName.c_str() );
}
/* This doesn't work yet: we also need to move the data around, I think, and
* we should handle more than one BPM change. */
if( BPM2 > 0 && BPMPos2 > 0 )
{
const float BeatsPerSecond = out.GetBPMAtBeat(0) / 60.0f;
const float beat = BPMPos2 * BeatsPerSecond;
LOG->Trace("BPM %f, BPS %f, BPMPos2 %f, beat %f",
out.GetBPMAtBeat(0), BeatsPerSecond, BPMPos2, beat);
out.AddBPMSegment( BPMSegment(beat, BPM2) );
}
if( BPM3 > 0 && BPMPos3 > 0 )
{
const float BeatsPerSecond = out.GetBPMAtBeat(0) / 60.0f;
const float beat = BPMPos3 * BeatsPerSecond;
LOG->Trace("BPM %f, BPS %f, BPMPos3 %f, beat %f",
out.GetBPMAtBeat(0), BeatsPerSecond, BPMPos3, beat);
out.AddBPMSegment( BPMSegment(beat, BPM3) );
}
/* Try to fill in missing bits of information from the pathname. */
{
CStringArray asBits;
split( sPath, "/", asBits, true);
ASSERT(asBits.size() > 1);
LoadTags(asBits[asBits.size()-2], out);
}
// search for music with song in the file name
CStringArray arrayPossibleMusic;
GetDirListing( out.GetSongDir() + CString("song.mp3"), arrayPossibleMusic );
GetDirListing( out.GetSongDir() + CString("song.ogg"), arrayPossibleMusic );
GetDirListing( out.GetSongDir() + CString("song.wav"), arrayPossibleMusic );
if( !arrayPossibleMusic.empty() ) // we found a match
out.m_sMusicFile = arrayPossibleMusic[0];
return true;
}
示例11: Loadable
bool NotesLoader::Loadable( CString sPath )
{
CStringArray list;
GetApplicableFiles( sPath, list );
return !list.empty();
}
示例12: if
ScreenOptionsMaster::ScreenOptionsMaster( const CString &sClassName ):
ScreenOptions( sClassName )
{
LOG->Trace("ScreenOptionsMaster::ScreenOptionsMaster(%s)", m_sName.c_str() );
/* If this file doesn't exist, leave the music alone (eg. ScreenPlayerOptions music sample
* left over from ScreenSelectMusic). If you really want to play no music, add a redir
* to _silent. */
CString MusicPath = THEME->GetPathToS( ssprintf("%s music", m_sName.c_str()), true );
if( MusicPath != "" )
SOUND->PlayMusic( MusicPath );
CStringArray asLineNames;
split( LINE_NAMES, ",", asLineNames );
if( asLineNames.empty() )
RageException::Throw( "%s::LineNames is empty.", m_sName.c_str() );
CStringArray Flags;
split( OPTION_MENU_FLAGS, ";", Flags, true );
InputMode im = INPUTMODE_INDIVIDUAL;
bool Explanations = false;
unsigned i;
for( i = 0; i < Flags.size(); ++i )
{
CString &flag = Flags[i];
flag.MakeLower();
if( flag == "together" )
im = INPUTMODE_SHARE_CURSOR;
else if( flag == "explanations" )
Explanations = true;
else if( flag == "forceallplayers" )
{
FOREACH_PlayerNumber( pn )
GAMESTATE->m_bSideIsJoined[pn] = true;
GAMESTATE->m_MasterPlayerNumber = PlayerNumber(0);
}
else if( flag == "smnavigation" )
SetNavigation( NAV_THREE_KEY_MENU );
else if( flag == "toggle" || flag == "firstchoicegoesdown" )
SetNavigation( PREFSMAN->m_bArcadeOptionsNavigation? NAV_TOGGLE_THREE_KEY:NAV_TOGGLE_FIVE_KEY );
}
m_OptionRowAlloc = new OptionRowData[asLineNames.size()];
for( i = 0; i < asLineNames.size(); ++i )
{
OptionRowData &row = m_OptionRowAlloc[i];
vector<ParsedCommand> vCommands;
ParseCommands( LINE(asLineNames[i]), vCommands );
if( vCommands.size() < 1 )
RageException::Throw( "Parse error in %s::Line%i", m_sName.c_str(), i+1 );
OptionRowHandler hand;
for( unsigned part = 0; part < vCommands.size(); ++part)
{
ParsedCommand& command = vCommands[part];
HandleParams;
const CString name = sParam(0);
if( !name.CompareNoCase("list") )
{
SetList( row, hand, sParam(1), row.name );
}
else if( !name.CompareNoCase("steps") )
{
SetStep( row, hand );
row.name = "Steps";
}
else if( !name.CompareNoCase("conf") )
{
SetConf( row, hand, sParam(1), row.name );
}
else if( !name.CompareNoCase("characters") )
{
SetCharacter( row, hand );
row.name = "Characters";
}
else
RageException::Throw( "Unexpected type '%s' in %s::Line%i", name.c_str(), m_sName.c_str(), i );
CheckHandledParams;
}
// TRICKY: Insert a down arrow as the first choice in the row.
if( m_OptionsNavigation == NAV_TOGGLE_THREE_KEY )
{
row.choices.insert( row.choices.begin(), ENTRY_NAME("NextRow") );
hand.ListEntries.insert( hand.ListEntries.begin(), ModeChoice() );
}
OptionRowHandlers.push_back( hand );
}
ASSERT( OptionRowHandlers.size() == asLineNames.size() );
//.........这里部分代码省略.........
示例13: Load
void ConditionalBGA::Load(const CString &szScreenName)
{
RageFile file;
CString szConditionalBGAFile = THEME->GetCurThemeDir() + szScreenName + " ConditionalBGA.ini";
// char filepath[512];
// strcpy(filepath,""); // empty the path first
// strcpy(filepath,szConditionalBGAFile.c_str());
LOG->Trace("ConditionalBGA Load:%s",szConditionalBGAFile.c_str());
bool loaded = file.Open(szConditionalBGAFile,RageFile::READ);
// FILE* fp = NULL;
// fp = fopen(filepath,"r");
if(!loaded)
{
LOG->Trace("ConditionalBGA File Not Found");
return;
}
else
{
CString currentline;
int bgano=0;
while(!file.AtEOF())
{
file.GetLine(currentline); // get the current line
// kill any possible comments
CStringArray asKillComments;
asKillComments.clear(); // get rid of anything in there
split(currentline, "#",asKillComments); // A comment starting with #
if(!asKillComments.empty())
{
currentline = asKillComments[0]; // there was some commentstuff here, take the first bit to be the actual data
}
asKillComments.clear(); // get rid of anything in there
split(currentline, "/",asKillComments); // A comment starting with // or /*
if(!asKillComments.empty())
{
currentline = asKillComments[0]; // there was some commentstuff here, take the first bit to be the actual data
}
TrimRight(currentline); // nuke trailing whitespace
// start parsing the data
if(currentline.c_str()[0] == '[') // we found a new bganimation
{
if(!m_bgainfo.empty()) // last one wasnt empty
{
CheckBgaRequirements(m_bgainfo[bgano]);
bgano++;
}
BgaCondInfo temp;
m_bgainfo.push_back(temp);
ClearINFO(bgano); // wipe out the old info structure.
CStringArray asSplitLine;
split(currentline,"[",asSplitLine);
split(asSplitLine[0],"]",asSplitLine);
if(!asSplitLine.empty() && asSplitLine.size() >= 1)
m_bgainfo[bgano].bganame = asSplitLine[asSplitLine.size() - 1];
}
else
{
CStringArray asSplitLine;
split(currentline,":",asSplitLine);
if(asSplitLine.empty()) continue;
if(!asSplitLine[0].CompareNoCase("clear") && asSplitLine.size() > 1)
{
if(!asSplitLine[1].CompareNoCase("true") || !asSplitLine[1].CompareNoCase("cleared") || !asSplitLine[1].CompareNoCase("clear")) // true / clear (any clear condition)
m_bgainfo[bgano].cleared = CBGA_CSCLEARED;
else if(!asSplitLine[1].CompareNoCase("false") || !asSplitLine[1].CompareNoCase("failed")) // false / failed
m_bgainfo[bgano].cleared = CBGA_CSFAILED;
else if(!asSplitLine[1].CompareNoCase("maxcombo") || !asSplitLine[1].CompareNoCase("fullcombo")) // passed with maxcombo
m_bgainfo[bgano].cleared = CBGA_CSMAXCOMBO;
else if(!asSplitLine[1].CompareNoCase("brokencombo")) // passed with a broken combo
m_bgainfo[bgano].cleared = CBGA_CSBROKECOMBO;
// LOG->Trace("Clear Conditon: %d",info.cleared);
}
if(!asSplitLine[0].CompareNoCase("songtitle") && asSplitLine.size() > 1)
{
m_bgainfo[bgano].songtitle = asSplitLine[1];
// LOG->Trace("SongTitle: %s",info.songtitle.c_str());
}
if(!asSplitLine[0].CompareNoCase("songartist") && asSplitLine.size() > 1)
{
m_bgainfo[bgano].songartist = asSplitLine[1];
// LOG->Trace("SongArtist: %s",info.songartist.c_str());
}
if(!asSplitLine[0].CompareNoCase("songday") && asSplitLine.size() > 1)
{
CStringArray asDays;
split( asSplitLine[1], ",", asDays );
for( unsigned d=0; d<asDays.size(); d++ )
{
int dn = atoi(asDays[d].c_str());
//.........这里部分代码省略.........