void RageTexture::GetFrameDimensionsFromFileName( CString sPath, int* piFramesWide, int* piFramesHigh ) { *piFramesWide = *piFramesHigh = 1; // set default values in case we don't find the dimension in the file name sPath.MakeLower(); const CString sFName = SetExtension( sPath, "" ); CStringArray arrayBits; split( sFName, " ", arrayBits, false ); /* XXX: allow dims to be in parens */ for( unsigned i=0; i<arrayBits.size(); i++ ) { CString &sBit = arrayBits[ i ]; // Test to see if it looks like "%ux%u" (e.g. 16x8) CStringArray arrayDimensionsBits; split( sBit, "x", arrayDimensionsBits, false ); if( arrayDimensionsBits.size() != 2 ) continue; else if( !IsAnInt(arrayDimensionsBits[0]) || !IsAnInt(arrayDimensionsBits[1]) ) continue; *piFramesWide = atoi(arrayDimensionsBits[0]); *piFramesHigh = atoi(arrayDimensionsBits[1]); return; } }
void Dialog::Init() { if( g_pImpl != NULL ) return; CString drivers = "win32,cocoa,null"; CStringArray DriversToTry; split(drivers, ",", DriversToTry, true); ASSERT( DriversToTry.size() != 0 ); CString Driver; for( unsigned i = 0; g_pImpl == NULL && i < DriversToTry.size(); ++i ) { try { Driver = DriversToTry[i]; #if defined(HAVE_DIALOG_WIN32) if( !DriversToTry[i].CompareNoCase("Win32") ) g_pImpl = new DialogDriver_Win32; #endif if( !DriversToTry[i].CompareNoCase("Null") ) g_pImpl = new DialogDriver_Null; } catch( const RageException &e ) { if( LOG ) LOG->Info("Couldn't load driver %s: %s", DriversToTry[i].c_str(), e.what()); } } /* DialogDriver_Null should have worked, at least. */ ASSERT( g_pImpl != NULL ); }
void RageFileManager::GetDirListing( CString sPath, CStringArray &AddTo, bool bOnlyDirs, bool bReturnPathToo ) { LockMut( *g_Mutex ); NormalizePath( sPath ); for( unsigned i = 0; i < g_Drivers.size(); ++i ) { LoadedDriver &ld = g_Drivers[i]; const CString p = ld.GetPath( sPath ); if( p.size() == 0 ) continue; const unsigned OldStart = AddTo.size(); g_Drivers[i].driver->GetDirListing( p, AddTo, bOnlyDirs, bReturnPathToo ); /* If returning the path, prepend the mountpoint name to the files this driver returned. */ if( bReturnPathToo ) for( unsigned j = OldStart; j < AddTo.size(); ++j ) AddTo[j] = ld.MountPoint + AddTo[j]; } /* More than one driver might return the same file. Remove duplicates (case- * insensitively). */ sort( AddTo.begin(), AddTo.end(), ilt ); CStringArray::iterator it = unique( AddTo.begin(), AddTo.end(), ieq ); AddTo.erase(it, AddTo.end()); }
bool RandomSample::LoadSoundDir( CString sDir, int iMaxToLoad ) { if( sDir == "" ) return true; #if 0 /* (don't want to do this just yet) */ /* If this is actually a directory, add a backslash to the filename, * so we'll look for eg. themes\Default\sounds\sDir\*.mp3. Otherwise, * don't, so we'll look for all of the files starting with sDir, * eg. themes\Default\sounds\sDir*.mp3. */ if(IsADirectory(sDir) && sDir[sDir.GetLength()-1] != "/" ) sDir += "/"; #else // make sure there's a slash at the end of this path if( sDir.Right(1) != "/" ) sDir += "/"; #endif CStringArray arraySoundFiles; GetDirListing( sDir + "*.mp3", arraySoundFiles ); GetDirListing( sDir + "*.ogg", arraySoundFiles ); GetDirListing( sDir + "*.wav", arraySoundFiles ); random_shuffle( arraySoundFiles.begin(), arraySoundFiles.end() ); arraySoundFiles.resize( min( arraySoundFiles.size(), (unsigned)iMaxToLoad ) ); for( unsigned i=0; i<arraySoundFiles.size(); i++ ) LoadSound( sDir + arraySoundFiles[i] ); return true; }
void EditMetricsDlg::RefreshTree() { m_tree.DeleteAllItems(); iniBase.Reset(); iniBase.SetPath( "Themes\\default\\metrics.ini" ); iniBase.ReadFile(); iniTheme.Reset(); iniTheme.SetPath( "Themes\\"+m_sTheme+"\\metrics.ini" ); iniTheme.ReadFile(); IniFile iniCombined; iniCombined.SetPath( "Themes\\default\\metrics.ini" ); iniCombined.ReadFile(); iniCombined.SetPath( "Themes\\"+m_sTheme+"\\metrics.ini" ); iniCombined.ReadFile(); CStringArray asKeys; IniFile::const_iterator it; for( it = iniCombined.begin(); it != iniCombined.end(); ++it ) asKeys.push_back( it->first ); SortCStringArray( asKeys ); for( unsigned i=0; i<asKeys.size(); i++ ) { CString sKey = asKeys[i]; bool bInBase = iniBase.GetKey(sKey) != NULL; bool bInTheme = iniTheme.GetKey(sKey) != NULL; HTREEITEM item1 = m_tree.InsertItem( sKey ); SET_ITEM_STYLE( item1, bInBase, bInTheme ); const IniFile::key* pKey = iniCombined.GetKey( sKey ); CStringArray asNames; for( IniFile::key::const_iterator val = pKey->begin(); val != pKey->end(); ++val ) { CString sName = val->first, sValue = val->second; asNames.push_back( sName ); } SortCStringArray( asNames ); for( unsigned j=0; j<asNames.size(); j++ ) { CString sName = asNames[j]; CString sValue; iniCombined.GetValue( sKey, sName, sValue ); CString sThrowAway; bool bInBase = !!iniBase.GetValue( sKey, sName, sThrowAway ); bool bInTheme = !!iniTheme.GetValue( sKey, sName, sThrowAway ); HTREEITEM item2 = m_tree.InsertItem( sName, item1 ); SET_ITEM_STYLE( item2, bInBase, bInTheme ); } } }
void RageFileManager::MountInitialFilesystems() { /* Add file search paths, higher priority first. */ #if defined(XBOX) RageFileManager::Mount( "dir", "D:\\", "" ); #elif defined(LINUX) /* Absolute paths. This is rarely used, eg. by Alsa9Buf::GetSoundCardDebugInfo(). * All paths that start with a slash (eg. "/proc") should use this, so put it * first. */ RageFileManager::Mount( "dir", "/", "/" ); /* We can almost do this, to have machine profiles be system-global to eg. share * scores. It would need to handle permissions properly. */ /* RageFileManager::Mount( "dir", "/var/lib/games/stepmania", "Data/Profiles" ); */ // CString Home = getenv( "HOME" ) + "/" + PRODUCT_NAME; /* * Next: path to write general mutable user data. If the above path fails (eg. * wrong permissions, doesn't exist), machine memcard data will also go in here. * XXX: It seems silly to have two ~ directories. If we're going to create a * directory on our own, it seems like it should be a dot directory, but it * seems wrong to put lots of data (eg. music) in one. Hmm. */ /* XXX: create */ /* RageFileManager::Mount( "dir", Home + "." PRODUCT_NAME, "Data" ); */ /* Next, search ~/StepMania. This is where users can put music, themes, etc. */ /* RageFileManager::Mount( "dir", Home + PRODUCT_NAME, "" ); */ /* Search for a directory with "Songs" in it. Be careful: the CWD is likely to * be ~, and it's possible that some users will have a ~/Songs/ directory that * has nothing to do with us, so check the initial directory last. */ CString Root = ""; struct stat st; if( Root == "" && !stat( DirOfExecutable + "/Songs", &st ) && st.st_mode&S_IFDIR ) Root = DirOfExecutable; if( Root == "" && !stat( InitialWorkingDirectory + "/Songs", &st ) && st.st_mode&S_IFDIR ) Root = InitialWorkingDirectory; if( Root == "" ) RageException::Throw( "Couldn't find \"Songs\"" ); RageFileManager::Mount( "dir", Root, "" ); #elif defined(_WINDOWS) /* All Windows data goes in the directory one level above the executable. */ CHECKPOINT_M( ssprintf( "DOE \"%s\"", DirOfExecutable.c_str()) ); CStringArray parts; split( DirOfExecutable, "/", parts ); CHECKPOINT_M( ssprintf( "... %i parts", parts.size()) ); ASSERT_M( parts.size() > 1, ssprintf("Strange DirOfExecutable: %s", DirOfExecutable.c_str()) ); CString Dir = join( "/", parts.begin(), parts.end()-1 ); RageFileManager::Mount( "dir", Dir, "" ); #else /* Paths relative to the CWD: */ RageFileManager::Mount( "dir", ".", "" ); #endif }
//---------------------------------------- bool CUnit::HasDateRef(CDate* dateRef /*= NULL*/, CStringArray* array /*= NULL*/) const { if (!IsDate()) { return false; } CStringArray ar; ar.ExtractStrings(GetText().c_str(), ' '); size_t len = ar.size(); if (len <= 2) { return false; } int32_t index = ar.FindIndex("since"); if (index < 0) { return false; } CDate dateTmp; int32_t result = BRATHL_ERROR; std::string strDate; for (uint32_t i = index + 1 ; i < ar.size() ; i++) { strDate.append(ar.at(i)); strDate.append(" "); } strDate = CTools::StringTrim(strDate); result = dateTmp.SetDate(strDate.c_str()); if (result == BRATHL_SUCCESS) { if (dateRef != NULL) { *dateRef = dateTmp; } } if (array != NULL) { array->Insert(ar); } return (result == BRATHL_SUCCESS); }
/* Add the list named "ListName" to the given row/handler. */ void ScreenOptionsMaster::SetList( OptionRowData &row, OptionRowHandler &hand, const CString &ListName, CString &TitleOut ) { hand.type = ROW_LIST; TitleOut = ListName; if( !ListName.CompareNoCase("noteskins") ) { hand.Default.Init(); /* none */ row.bOneChoiceForAllPlayers = false; CStringArray arraySkinNames; NOTESKIN->GetNoteSkinNames( arraySkinNames ); ModeChoice mc; for( unsigned skin=0; skin<arraySkinNames.size(); skin++ ) { arraySkinNames[skin].MakeUpper(); mc.m_sModifiers = arraySkinNames[skin]; hand.ListEntries.push_back( mc ); row.choices.push_back( arraySkinNames[skin] ); } return; } hand.Default.Load( -1, ENTRY_DEFAULT(ListName) ); /* Parse the basic configuration metric. */ CStringArray asParts; split( ENTRY(ListName), ",", asParts ); if( asParts.size() < 1 ) RageException::Throw( "Parse error in ScreenOptionsMasterEntries::ListName%s", ListName.c_str() ); row.bOneChoiceForAllPlayers = false; const int NumCols = atoi( asParts[0] ); for( unsigned i=0; i<asParts.size(); i++ ) { if( asParts[i].CompareNoCase("together") == 0 ) row.bOneChoiceForAllPlayers = true; else if( asParts[i].CompareNoCase("multiselect") == 0 ) row.bMultiSelect = true; } for( int col = 0; col < NumCols; ++col ) { ModeChoice mc; mc.Load( 0, ENTRY_MODE(ListName, col) ); if( mc.m_sName == "" ) RageException::Throw( "List \"%s\", col %i has no name", ListName.c_str(), col ); if( !mc.IsPlayable() ) continue; hand.ListEntries.push_back( mc ); CString sChoice = ENTRY_NAME(mc.m_sName); row.choices.push_back( sChoice ); } }
void ParsedCommand::Set( const CString &sCommand ) { CStringArray vsTokens; split( sCommand, ",", vsTokens, false ); // don't ignore empty vTokens.resize( vsTokens.size() ); for( unsigned j=0; j<vsTokens.size(); j++ ) vTokens[j].Set( vsTokens[j] ); }
void ParseCommands( const CString &sCommands, vector<ParsedCommand> &vCommandsOut ) { vCommandsOut.clear(); CStringArray vsCommands; split( sCommands, ";", vsCommands, true ); // do ignore empty vCommandsOut.resize( vsCommands.size() ); for( unsigned i=0; i<vsCommands.size(); i++ ) vCommandsOut[i].Set( vsCommands[i] ); }
void RageMatrixCommand( CString sCommandString, RageMatrix &mat ) { CStringArray asCommands; split( sCommandString, ";", asCommands, true ); for( unsigned c=0; c<asCommands.size(); c++ ) { CStringArray asTokens; split( asCommands[c], ",", asTokens, true ); int iMaxIndexAccessed = 0; #define sParam(i) (GetParam(asTokens,i,iMaxIndexAccessed)) #define fParam(i) (strtof(sParam(i),NULL)) #define iParam(i) (atoi(sParam(i))) #define bParam(i) (iParam(i)!=0) CString& sName = asTokens[0]; sName.MakeLower(); RageMatrix b; // Act on command if( sName=="x" ) RageMatrixTranslation( &b, fParam(1),0,0 ); else if( sName=="y" ) RageMatrixTranslation( &b, 0,fParam(1),0 ); else if( sName=="z" ) RageMatrixTranslation( &b, 0,0,fParam(1) ); else if( sName=="zoomx" ) RageMatrixScaling(&b, fParam(1),1,1 ); else if( sName=="zoomy" ) RageMatrixScaling(&b, 1,fParam(1),1 ); else if( sName=="zoomz" ) RageMatrixScaling(&b, 1,1,fParam(1) ); else if( sName=="rotationx" ) RageMatrixRotationX( &b, fParam(1) ); else if( sName=="rotationy" ) RageMatrixRotationY( &b, fParam(1) ); else if( sName=="rotationz" ) RageMatrixRotationZ( &b, fParam(1) ); else { CString sError = ssprintf( "MatrixCommand: Unrecognized matrix command name '%s' in command string '%s'.", sName.c_str(), sCommandString.c_str() ); LOG->Warn( sError ); Dialog::OK( sError ); continue; } if( iMaxIndexAccessed != (int)asTokens.size()-1 ) { CString sError = ssprintf( "MatrixCommand: Wrong number of parameters in command '%s'. Expected %d but there are %d.", join(",",asTokens).c_str(), iMaxIndexAccessed+1, (int)asTokens.size() ); LOG->Warn( sError ); Dialog::OK( sError ); continue; } RageMatrix a(mat); RageMatrixMultiply(&mat, &a, &b); } }
void ParseCommands( const CString &sCommands, Commands &vCommandsOut ) { CStringArray vsCommands; split( sCommands, ";", vsCommands, true ); // do ignore empty vCommandsOut.v.resize( vsCommands.size() ); for( unsigned i=0; i<vsCommands.size(); i++ ) { Command &cmd = vCommandsOut.v[i]; cmd.Load( vsCommands[i] ); } }
void AnnouncerManager::GetAnnouncerNames( CStringArray& AddTo ) { GetDirListing( ANNOUNCERS_DIR+"*", AddTo, true ); // strip out the folder called "CVS" and EMPTY_ANNOUNCER_NAME for( int i=AddTo.size()-1; i>=0; i-- ) if( !stricmp( AddTo[i], "cvs" ) ) AddTo.erase(AddTo.begin()+i, AddTo.begin()+i+1 ); for( int i=AddTo.size()-1; i>=0; i-- ) if( !stricmp( AddTo[i], EMPTY_ANNOUNCER_NAME ) ) AddTo.erase(AddTo.begin()+i, AddTo.begin()+i+1 ); }
bool SMLoader::LoadFromDir( CString sPath, Song &out ) { CStringArray aFileNames; GetApplicableFiles( sPath, aFileNames ); if( aFileNames.size() > 1 ) RageException::Throw( "There is more than one SM file in '%s'. There should be only one!", sPath.c_str() ); /* We should have exactly one; if we had none, we shouldn't have been * called to begin with. */ ASSERT( aFileNames.size() == 1 ); return LoadFromSMFile( sPath + aFileNames[0], out ); }
bool UserPackManager::IsPackMountable( const CString &sPack, CString &sError ) { RageFileDriverZip *pZip = new RageFileDriverZip; if ( !pZip->Load(sPack) ) { sError = "not a valid zip file"; SAFE_DELETE( pZip ); return false; } for( unsigned i = 0; i < NUM_BLACKLISTED_FOLDERS && BLACKLISTED_FOLDERS[i] != NULL; i++ ) { CString sDir = CString("/") + BLACKLISTED_FOLDERS[i]; CStringArray sDirListing; pZip->GetDirListing( sDir, sDirListing, false, true ); int iListSize = sDirListing.size(); // if any blacklisted folders exist, reject the pack if ( iListSize > 0 ) { sError = ssprintf( "blacklisted folder: %s", BLACKLISTED_FOLDERS[i] ); SAFE_DELETE( pZip ); return false; } } // do not add if it's just folders of individual songs without a group folder CStringArray asRootFolders; pZip->GetDirListing( "/*", asRootFolders, true, false ); for( unsigned i = 0; i < asRootFolders.size(); i++ ) { CStringArray asFiles; pZip->GetDirListing( "/" + asRootFolders[i] + "/*.sm", asFiles, false, false ); pZip->GetDirListing( "/" + asRootFolders[i] + "/*.dwi", asFiles, false, false ); if ( asFiles.size() > 0 ) { sError = "Package is not a group folder package.\nPlease add songs to a single group folder.\n(i.e. {Group Name}/{Song Folder}/Song.sm)"; SAFE_DELETE( pZip ); return false; } } SAFE_DELETE( pZip ); return true; }
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; }
int DiagnosticsUtil::GetNumMachineEdits() { CStringArray aEdits; CString sDir = PROFILEMAN->GetProfileDir(PROFILE_SLOT_MACHINE) + EDIT_SUBDIR; GetDirListing( sDir , aEdits ); return aEdits.size(); }
void ActiveAttackList::Refresh() { CString s; const AttackArray& attacks = GAMESTATE->m_ActiveAttacks[m_PlayerNumber]; // NUM_INVENTORY_SLOTS // clear all lines, then add all active attacks for( unsigned i=0; i<attacks.size(); i++ ) { if( !attacks[i].bOn ) continue; /* hasn't started yet */ CStringArray asMods; split( attacks[i].sModifier, ",", asMods ); for( unsigned j=0; j<asMods.size(); j++ ) { CString& sMod = asMods[j]; TrimLeft( sMod ); TrimRight( sMod ); sMod = PlayerOptions::ThemeMod( sMod ); if( s.empty() ) s = sMod; else s = sMod + "\n" + s; } } this->SetText( s ); // BitmapText will not rebuild vertices if these strings are the same. }
/* seemingly good start of an automagical way to mount a user pack based on the folder structure */ CString UserPackManager::GetPackMountPoint( const CString &sPack ) { enum UserPackMountType { UPACK_MOUNT_ROOT, UPACK_MOUNT_SONGS }; RageFileDriverZip *pZip = new RageFileDriverZip; CHECKPOINT_M( sPack ); // it should already be a valid zip by now... ASSERT( pZip->Load( sPack ) ); UserPackMountType upmt = UPACK_MOUNT_SONGS; CStringArray asRootEntries; pZip->GetDirListing( "/", asRootEntries, true, false ); SAFE_DELETE( pZip ); // if we find a StepMania root folder, mount it as one for( unsigned i = 0; i < asRootEntries.size(); ++i ) { for( unsigned j = 0; j < ARRAYLEN(asRootDirs); j++ ) { if ( asRootEntries[i].CompareNoCase( asRootDirs[j] ) == 0 ) return "/"; } } /* for now, assume a Songs-only pack if the root dirs aren't there */ return "/Songs"; }
//---------------------------------------- std::string CUnit::GetDateUnitWithoutDateOrigin() const { std::string str = GetText(); if (!IsDate()) { return str; } if (!HasDateRef()) { return str; } CStringArray ar; ar.ExtractStrings(GetText().c_str(), " since "); size_t len = ar.size(); if (len <= 1) { return str; } str = ar[0]; return str; }
bool UserPackManager::IsPackTransferable( const CString &sPack, const CString &sPath, CString &sError ) { /* Check for duplicate names. */ { CStringArray asSavedPacks; GetUserPacks( asSavedPacks ); for( unsigned i = 0; i < asSavedPacks.size(); ++i ) { if ( asSavedPacks[i].CompareNoCase(sPack) == 0 ) { sError = ssprintf("%s is already on the machine", asSavedPacks[i].c_str()); return false; } } } /* Do we have enough disk space? */ { uint64_t iFree = HOOKS->GetDiskSpaceFree( USER_PACK_TRANSFER_PATH ); uint64_t iFileSize = (uint64_t) FILEMAN->GetFileSizeInBytes( sPath ); if( iFree < iFileSize ) { sError = "Insufficient disk space"; return false; } } return true; }
/* This is similar in style to Actor::Command. However, Actors don't store * matrix stacks; they only store offsets and scales, and compound them into * a single transformations at once. This makes some things easy, but it's not * convenient for generic 3d transforms. For that, we have this, which has the * small subset of the actor commands that applies to raw matrices, and we apply * commands in the order given. "scale,2;x,1;" is very different from * "x,1;scale,2;". */ static CString GetParam( const CStringArray& sParams, int iIndex, int& iMaxIndexAccessed ) { iMaxIndexAccessed = max( iIndex, iMaxIndexAccessed ); if( iIndex < int(sParams.size()) ) return sParams[iIndex]; else return ""; }
ScreenSelect::ScreenSelect( CString sClassName ) : ScreenWithMenuElements(sClassName) { LOG->Trace( "ScreenSelect::ScreenSelect()" ); m_sName = sClassName; // // Load choices // { // Instead of using NUM_CHOICES, use a comma-separated list of choices. Each // element in the list is a choice name. This level of indirection // makes it easier to add or remove items without having to change a bunch // of indices. CStringArray asChoiceNames; split( CHOICE_NAMES, ",", asChoiceNames, true ); for( unsigned c=0; c<asChoiceNames.size(); c++ ) { CString sChoiceName = asChoiceNames[c]; CString sChoice = CHOICE(sChoiceName); ModeChoice mc; mc.m_sName = sChoiceName; mc.Load( c, sChoice ); m_aModeChoices.push_back( mc ); CString sBGAnimationDir = THEME->GetPath(BGAnimations, m_sName, mc.m_sName, true); // true="optional" if( sBGAnimationDir == "" ) sBGAnimationDir = THEME->GetPathToB(m_sName+" background"); BGAnimation *pBGA = new BGAnimation; m_vpBGAnimations.push_back( pBGA ); } } // // Load codes // for( int c=0; c<NUM_CODES; c++ ) { CodeItem code; if( !code.Load( CODE(c) ) ) continue; m_aCodes.push_back( code ); m_aCodeActions.push_back( CODE_ACTION(c) ); ModeChoice mc; mc.Load( c, CODE_ACTION(c) ); m_aCodeChoices.push_back( mc ); } if( !m_aModeChoices.size() ) RageException::Throw( "Screen \"%s\" does not set any choices", m_sName.c_str() ); // derived classes can override if they want LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU ); }
CString GetRandomFileInDir( CString sDir ) { CStringArray asFiles; GetDirListing( sDir, asFiles, false, true ); if( asFiles.empty() ) return ""; else return asFiles[rand()%asFiles.size()]; }
void LinkedOptionsMenu::SetChoices( const CStringArray &asChoices ) { ClearChoices(); for( unsigned i = 0; i < asChoices.size(); i++ ) { CString ch = asChoices[i]; BitmapText *bt = new BitmapText; m_Rows.push_back( bt ); bt->LoadFromFont( THEME->GetPathF( m_sName, "menutext" ) ); bt->SetName( "Row" ); bt->SetXY( ROW_OFFSET_X, ROW_OFFSET_Y + (ROW_SPACING_Y * (float)(i % ROWS_PER_PAGE)) ); bt->SetText( ch ); m_Frame.AddChild( bt ); ON_COMMAND( *bt ); } // show first page of choices for( unsigned i = 0; i < asChoices.size() && i < (unsigned)ROWS_PER_PAGE; i++ ) { m_Rows[i]->PlayCommand("TweenOn"); } m_iCurPage = 0; if ( asChoices.size() > (unsigned)ROWS_PER_PAGE ) { m_sprIndicatorDown.PlayCommand("TweenOn"); m_bIndTweenedOn[1] = true; } if ( m_Rows.size() > 0 ) { if ( m_bFocus ) m_Cursor.PlayCommand( "TweenOn" ); m_Cursor.SetXY( CURSOR_OFFSET_X + m_Rows[0]->GetX(), m_Rows[0]->GetY() ); m_Cursor.SetBarWidth( floor(m_Rows[0]->GetZoomedWidth()) ); m_iCurrentSelection = 0; } else { m_iCurrentSelection = -1; m_Cursor.PlayCommand( "TweenOff" ); if ( m_bFocus ) SCREENMAN->PostMessageToTopScreen( m_smChangeMenu, 0.0f ); } }
bool AnnouncerManager::DoesAnnouncerExist( CString sAnnouncerName ) { if( sAnnouncerName == "" ) return true; CStringArray asAnnouncerNames; GetAnnouncerNames( asAnnouncerNames ); for( unsigned i=0; i<asAnnouncerNames.size(); i++ ) if( 0==stricmp(sAnnouncerName, asAnnouncerNames[i]) ) return true; return false; }
static void EmptyDir( CString dir ) { ASSERT(dir[dir.size()-1] == '/'); CStringArray asCacheFileNames; GetDirListing( dir, asCacheFileNames ); for( unsigned i=0; i<asCacheFileNames.size(); i++ ) { if( !IsADirectory(dir + asCacheFileNames[i]) ) FILEMAN->Remove( dir + asCacheFileNames[i] ); } }
void KSFLoader::LoadTags( const CString &str, Song &out ) { /* str is either a #TITLE or a directory component. Fill in missing information. * str is either "title", "artist - title", or "artist - title - difficulty". */ CStringArray asBits; split( str, " - ", asBits, false ); /* Ignore the difficulty, since we get that elsewhere. */ if( asBits.size() == 3 && (!stricmp(asBits[2], "double") || !stricmp(asBits[2], "easy") || !stricmp(asBits[2], "normal") || !stricmp(asBits[2], "hard") || !stricmp(asBits[2], "crazy")) ) { asBits.erase(asBits.begin()+2, asBits.begin()+3); } CString title, artist; if( asBits.size() == 2 ) { artist = asBits[0]; title = asBits[1]; } else { title = asBits[0]; } /* Convert, if possible. Most KSFs are in Korean encodings (CP942/EUC-KR). */ if( !ConvertString( title, "korean" ) ) title = ""; if( !ConvertString( artist, "korean" ) ) artist = ""; if( out.m_sMainTitle == "" ) out.m_sMainTitle = title; if( out.m_sArtist == "" ) out.m_sArtist = artist; }
void SMLoader::LoadFromSMTokens( CString sStepsType, CString sDescription, CString sDifficulty, CString sMeter, CString sRadarValues, CString sNoteData, CString sAttackData, Steps &out ) { TrimLeft(sStepsType); TrimRight(sStepsType); TrimLeft(sDescription); TrimRight(sDescription); TrimLeft(sDifficulty); TrimRight(sDifficulty); // LOG->Trace( "Steps::LoadFromSMTokens()" ); out.m_StepsType = GameManager::StringToStepsType(sStepsType); out.SetDescription(sDescription); out.SetDifficulty(StringToDifficulty( sDifficulty )); // HACK: We used to store SMANIAC as DIFFICULTY_HARD with special description. // Now, it has its own DIFFICULTY_CHALLENGE if( sDescription.CompareNoCase("smaniac") == 0 ) out.SetDifficulty( DIFFICULTY_CHALLENGE ); // HACK: We used to store CHALLENGE as DIFFICULTY_HARD with special description. // Now, it has its own DIFFICULTY_CHALLENGE if( sDescription.CompareNoCase("challenge") == 0 ) out.SetDifficulty( DIFFICULTY_CHALLENGE ); out.SetMeter(atoi(sMeter)); CStringArray saValues; split( sRadarValues, ",", saValues, true ); if( saValues.size() == NUM_RADAR_CATEGORIES ) { RadarValues v; FOREACH_RadarCategory(rc) v[rc] = strtof( saValues[rc], NULL ); out.SetRadarValues( v ); } out.SetSMNoteData(sNoteData, sAttackData); out.TidyUpData(); }
void RadarValues::FromString( CString sRadarValues ) { CStringArray saValues; split( sRadarValues, ",", saValues, true ); if( saValues.size() != NUM_RADAR_CATEGORIES ) { MakeUnknown(); return; } FOREACH_RadarCategory(rc) m_Values.f[rc] = strtof( saValues[rc], NULL ); }