void SMLoader::LoadFromTokens( RString sStepsType, RString sDescription, RString sDifficulty, RString sMeter, RString sRadarValues, RString sNoteData, Steps &out ) { // we're loading from disk, so this is by definition already saved: out.SetSavedToDisk( true ); Trim( sStepsType ); Trim( sDescription ); Trim( sDifficulty ); Trim( sNoteData ); // LOG->Trace( "Steps::LoadFromTokens()" ); // backwards compatibility hacks: // HACK: We eliminated "ez2-single-hard", but we should still handle it. if( sStepsType == "ez2-single-hard" ) sStepsType = "ez2-single"; // HACK: "para-single" used to be called just "para" if( sStepsType == "para" ) sStepsType = "para-single"; out.m_StepsType = GAMEMAN->StringToStepsType( sStepsType ); out.SetDescription( sDescription ); out.SetCredit( sDescription ); // this is often used for both. out.SetChartName(sDescription); // yeah, one more for good measure. out.SetDifficulty( OldStyleStringToDifficulty(sDifficulty) ); // Handle hacks that originated back when StepMania didn't have // Difficulty_Challenge. (At least v1.64, possibly v3.0 final...) if( out.GetDifficulty() == Difficulty_Hard ) { // HACK: SMANIAC used to be Difficulty_Hard with a special description. if( sDescription.CompareNoCase("smaniac") == 0 ) out.SetDifficulty( Difficulty_Challenge ); // HACK: CHALLENGE used to be Difficulty_Hard with a special description. if( sDescription.CompareNoCase("challenge") == 0 ) out.SetDifficulty( Difficulty_Challenge ); } if( sMeter.empty() ) { // some simfiles (e.g. X-SPECIALs from Zenius-I-Vanisher) don't // have a meter on certain steps. Make the meter 1 in these instances. sMeter = "1"; } out.SetMeter( StringToInt(sMeter) ); out.SetSMNoteData( sNoteData ); out.TidyUpData(); }
/* Given "HKEY_LOCAL_MACHINE\hardware\foo", return "hardware\foo", and place * the HKEY_LOCAL_MACHINE constant in key. */ static bool GetRegKeyType( const RString &sIn, RString &sOut, HKEY &key ) { size_t iBackslash = sIn.find( '\\' ); if( iBackslash == sIn.npos ) { LOG->Warn( "Invalid registry key: \"%s\" ", sIn.c_str() ); return false; } RString sType = sIn.substr( 0, iBackslash ); if( !sType.CompareNoCase( "HKEY_CLASSES_ROOT" ) ) key = HKEY_CLASSES_ROOT; else if( !sType.CompareNoCase( "HKEY_CURRENT_CONFIG" ) ) key = HKEY_CURRENT_CONFIG; else if( !sType.CompareNoCase( "HKEY_CURRENT_USER" ) ) key = HKEY_CURRENT_USER; else if( !sType.CompareNoCase( "HKEY_LOCAL_MACHINE" ) ) key = HKEY_LOCAL_MACHINE; else if( !sType.CompareNoCase( "HKEY_USERS" ) ) key = HKEY_USERS; else { LOG->Warn( "Invalid registry key: \"%s\" ", sIn.c_str() ); return false; } sOut = sIn.substr( iBackslash+1 ); return true; }
bool ThemeManager::DoesLanguageExist( const RString &sLanguage ) { vector<RString> asLanguages; GetLanguages( asLanguages ); for( unsigned i=0; i<asLanguages.size(); i++ ) if( sLanguage.CompareNoCase(asLanguages[i])==0 ) return true; return false; }
bool ThemeManager::DoesThemeExist( const RString &sThemeName ) { vector<RString> asThemeNames; GetThemeNames( asThemeNames ); for( unsigned i=0; i<asThemeNames.size(); i++ ) { if( !sThemeName.CompareNoCase(asThemeNames[i]) ) return true; } return false; }
BOOL ChangeGameSettings::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here DialogUtil::LocalizeDialogAndContents( *this ); // // Fill the radio buttons // IniFile ini; ini.ReadFile( SpecialFiles::PREFERENCES_INI_PATH ); RString sValue; // video renderers sValue = ""; ini.GetValue( "Options", "VideoRenderers", sValue ); if( sValue.CompareNoCase("opengl")==0 ) CheckDlgButton( IDC_RADIO_OPENGL, BST_CHECKED ); else if( sValue.CompareNoCase("d3d")==0 ) CheckDlgButton( IDC_RADIO_DIRECT3D, BST_CHECKED ); else CheckDlgButton( IDC_RADIO_DEFAULT, BST_CHECKED ); // sound drivers sValue = ""; ini.GetValue( "Options", "SoundDrivers", sValue ); if( sValue.CompareNoCase("DirectSound")==0 ) CheckDlgButton( IDC_RADIO_SOUND_DIRECTSOUND_HARDWARE, BST_CHECKED ); else if( sValue.CompareNoCase("DirectSound-sw")==0 ) CheckDlgButton( IDC_RADIO_SOUND_DIRECTSOUND_SOFTWARE, BST_CHECKED ); else if( sValue.CompareNoCase("WaveOut")==0 ) CheckDlgButton( IDC_RADIO_SOUND_WAVEOUT, BST_CHECKED ); else if( sValue.CompareNoCase("null")==0 ) CheckDlgButton( IDC_RADIO_SOUND_NULL, BST_CHECKED ); else CheckDlgButton( IDC_RADIO_SOUND_DEFAULT, BST_CHECKED ); { int iValue = 0; ini.GetValue( "Options", "RefreshRate", iValue ); CheckDlgButton( IDC_CHECK_FORCE_60HZ, iValue == 60 ? BST_CHECKED : BST_UNCHECKED ); } { bool bValue = false; ini.GetValue( "Options", "LogToDisk", bValue ); CheckDlgButton( IDC_CHECK_LOG_TO_DISK, bValue ? BST_CHECKED : BST_UNCHECKED ); } { bool bValue = false; ini.GetValue( "Options", "ShowLogOutput", bValue ); CheckDlgButton( IDC_CHECK_SHOW_LOG_WINDOW, bValue ? BST_CHECKED : BST_UNCHECKED ); } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
/** ColorBitmapText ***********************************************************/ void ColorBitmapText::SetText( const RString& _sText, const RString& _sAlternateText, int iWrapWidthPixels ) { ASSERT( m_pFont ); RString sNewText = StringWillUseAlternate(_sText,_sAlternateText) ? _sAlternateText : _sText; if( iWrapWidthPixels == -1 ) // wrap not specified iWrapWidthPixels = m_iWrapWidthPixels; if( m_sText == sNewText && iWrapWidthPixels==m_iWrapWidthPixels ) return; m_sText = sNewText; m_iWrapWidthPixels = iWrapWidthPixels; // Set up the first color. m_vColors.clear(); ColorChange change; change.c = RageColor (1, 1, 1, 1); change.l = 0; m_vColors.push_back( change ); m_wTextLines.clear(); RString sCurrentLine = ""; int iLineWidth = 0; RString sCurrentWord = ""; int iWordWidth = 0; int iGlyphsSoFar = 0; for( unsigned i = 0; i < m_sText.length(); i++ ) { int iCharsLeft = m_sText.length() - i - 1; // First: Check for the special (color) case. if( m_sText.length() > 8 && i < m_sText.length() - 9 ) { RString FirstThree = m_sText.substr( i, 3 ); if( FirstThree.CompareNoCase("|c0") == 0 && iCharsLeft > 8 ) { ColorChange cChange; unsigned int r, g, b; sscanf( m_sText.substr( i, 9 ).c_str(), "|%*c0%2x%2x%2x", &r, &g, &b ); cChange.c = RageColor( r/255.f, g/255.f, b/255.f, 1.f ); cChange.l = iGlyphsSoFar; if( iGlyphsSoFar == 0 ) m_vColors[0] = cChange; else m_vColors.push_back( cChange ); i+=8; continue; } } char curChar = m_sText[i]; int iCharLen = m_pFont->GetLineWidthInSourcePixels( wstring(1, curChar) ); switch( curChar ) { case ' ': if( /* iLineWidth == 0 &&*/ iWordWidth == 0 ) break; sCurrentLine += sCurrentWord + " "; iLineWidth += iWordWidth + iCharLen; sCurrentWord = ""; iWordWidth = 0; iGlyphsSoFar++; break; case '\n': if( iLineWidth + iWordWidth > iWrapWidthPixels ) { SimpleAddLine( sCurrentLine, iLineWidth ); if( iWordWidth > 0 ) iLineWidth = iWordWidth + //Add the width of a space m_pFont->GetLineWidthInSourcePixels( L" " ); sCurrentLine = sCurrentWord + " "; iWordWidth = 0; sCurrentWord = ""; iGlyphsSoFar++; } else { SimpleAddLine( sCurrentLine + sCurrentWord, iLineWidth + iWordWidth ); sCurrentLine = ""; iLineWidth = 0; sCurrentWord = ""; iWordWidth = 0; } break; default: if( iWordWidth + iCharLen > iWrapWidthPixels && iLineWidth == 0 ) { SimpleAddLine( sCurrentWord, iWordWidth ); sCurrentWord = curChar; iWordWidth = iCharLen; } else if( iWordWidth + iLineWidth + iCharLen > iWrapWidthPixels ) { SimpleAddLine( sCurrentLine, iLineWidth ); sCurrentLine = ""; iLineWidth = 0; sCurrentWord += curChar; iWordWidth += iCharLen; } else { sCurrentWord += curChar; iWordWidth += iCharLen; } iGlyphsSoFar++; break; } } if( iWordWidth > 0 ) { sCurrentLine += sCurrentWord; iLineWidth += iWordWidth; } if( iLineWidth > 0 ) SimpleAddLine( sCurrentLine, iLineWidth ); BuildChars(); UpdateBaseZoom(); }
static bool CompareStringNoCase( const RString &s1, const RString &s2 ) { return s1.CompareNoCase( s2 ) < 0; }