RString MovieDecoder_FFMpeg::OpenCodec()
{
	Init();

	ASSERT( m_pStream != NULL );
	if( m_pStream->codec->codec )
		avcodec::avcodec_close( m_pStream->codec );

	avcodec::AVCodec *pCodec = avcodec::avcodec_find_decoder( m_pStream->codec->codec_id );
	if( pCodec == NULL )
		return ssprintf( "Couldn't find decoder %i", m_pStream->codec->codec_id );

	m_pStream->codec->workaround_bugs   = 1;
	m_pStream->codec->idct_algo         = FF_IDCT_AUTO;
	m_pStream->codec->error_concealment = 3;

	if( pCodec->capabilities & CODEC_CAP_DR1 )
		m_pStream->codec->flags |= CODEC_FLAG_EMU_EDGE;

	LOG->Trace("Opening codec %s", pCodec->name );

	int ret = avcodec::avcodec_open2( m_pStream->codec, pCodec, NULL );
	if( ret < 0 )
		return RString( averr_ssprintf(ret, "Couldn't open codec \"%s\"", pCodec->name) );
	ASSERT( m_pStream->codec->codec != NULL );

	return RString();
}
RString MovieDecoder_FFMpeg::Open( RString sFile )
{
	MovieTexture_FFMpeg::RegisterProtocols();

	int ret = avcodec::av_open_input_file( &m_fctx, "rage://" + sFile, NULL, 0, NULL );
	if( ret < 0 )
		return RString( averr_ssprintf(ret, "AVCodec: Couldn't open \"%s\"", sFile.c_str()) );

	ret = avcodec::av_find_stream_info( m_fctx );
	if( ret < 0 )
		return RString( averr_ssprintf(ret, "AVCodec (%s): Couldn't find codec parameters", sFile.c_str()) );

	avcodec::AVStream *pStream = FindVideoStream( m_fctx );
	if( pStream == NULL )
		return "Couldn't find any video streams";
	m_pStream = pStream;

	if( m_pStream->codec->codec_id == avcodec::CODEC_ID_NONE )
		return ssprintf( "Unsupported codec %08x", m_pStream->codec->codec_tag );

	RString sError = OpenCodec();
	if( !sError.empty() )
		return ssprintf( "AVCodec (%s): %s", sFile.c_str(), sError.c_str() );

	LOG->Trace( "Bitrate: %i", m_pStream->codec->bit_rate );
	LOG->Trace( "Codec pixel format: %s", avcodec::avcodec_get_pix_fmt_name(m_pStream->codec->pix_fmt) );

	return RString();
}
void
RS_XML(entityDeclaration)(void *ctx,
                            const xmlChar *name, int type, const xmlChar *publicId,
			    const xmlChar *systemId, xmlChar *content)
{
    USER_OBJECT_ fun, opArgs, tmp;
    RS_XMLParserData *parserData = (RS_XMLParserData*) ctx;
    DECL_ENCODING_FROM_EVENT_PARSER(parserData)

    /* check if there is a function to call before making the list of 5 elements. */
    fun = RS_XML(findFunction)(HANDLER_FUN_NAME(parserData, "entityDeclaration"), parserData->methods); 
    if(fun == NULL || fun == NULL_USER_OBJECT) 
	return;

    PROTECT(fun);
    PROTECT(opArgs = NEW_LIST(5));
    SET_VECTOR_ELT(opArgs, 0, RString(name));
    PROTECT(tmp = ScalarInteger(type));
    SET_NAMES(tmp, mkString(EntityTypeNames[type-1]));
    SET_VECTOR_ELT(opArgs, 1, tmp);
    UNPROTECT(1);
    SET_VECTOR_ELT(opArgs, 2, RString(content));
    SET_VECTOR_ELT(opArgs, 3, RString(systemId));
    SET_VECTOR_ELT(opArgs, 4, RString(publicId));

    (void) RS_XML(invokeFunction)(fun, opArgs, parserData->stateObject, parserData->ctx);    
    UNPROTECT(2);
}
RString MovieDecoder_FFMpeg::OpenCodec()
{
	Init();

	ASSERT( m_pStream );
	if( m_pStream->codec->codec )
		avcodec::avcodec_close( m_pStream->codec );

	avcodec::AVCodec *pCodec = avcodec::avcodec_find_decoder( m_pStream->codec->codec_id );
	if( pCodec == NULL )
		return ssprintf( "Couldn't find decoder %i", m_pStream->codec->codec_id );

	LOG->Trace("Opening codec %s", pCodec->name );

	if( !m_bHadBframes )
	{
		LOG->Trace("Setting CODEC_FLAG_LOW_DELAY" );
		m_pStream->codec->flags |= CODEC_FLAG_LOW_DELAY;
	}

	int ret = avcodec::avcodec_open( m_pStream->codec, pCodec );
	if( ret < 0 )
		return RString( averr_ssprintf(ret, "Couldn't open codec \"%s\"", pCodec->name) );
	ASSERT( m_pStream->codec->codec );

	/* This is set to true when we find a B-frame, to use on the next loop. */
	m_bHadBframes = false;

	return RString();
}
/* Find an announcer directory with sounds in it.  First search sFolderName,
 * then all aliases above.  Ignore directories that are empty, since we might
 * have "select difficulty intro" with sounds and an empty "ScreenSelectDifficulty
 * intro". */
RString AnnouncerManager::GetPathTo( RString sAnnouncerName, RString sFolderName )
{
    if(sAnnouncerName == "")
        return RString(); /* announcer disabled */

    const RString AnnouncerPath = GetAnnouncerDirFromName(sAnnouncerName);

    if( !DirectoryIsEmpty(AnnouncerPath+sFolderName+"/") )
        return AnnouncerPath+sFolderName+"/";

    /* Search for the announcer folder in the list of aliases. */
    int i;
    for(i = 0; aliases[i][0] != NULL; ++i)
    {
        if(!sFolderName.EqualsNoCase(aliases[i][0]))
            continue; /* no match */

        if( !DirectoryIsEmpty(AnnouncerPath+aliases[i][1]+"/") )
            return AnnouncerPath+aliases[i][1]+"/";
    }

    /* No announcer directory matched.  In debug, create the directory by
     * its preferred name. */
#ifdef DEBUG
    LOG->Trace( "The announcer in '%s' is missing the folder '%s'.",
                AnnouncerPath.c_str(), sFolderName.c_str() );
//	MessageBeep( MB_OK );
    RageFile temp;
    temp.Open( AnnouncerPath+sFolderName + "/announcer files go here.txt", RageFile::WRITE );
#endif

    return RString();
}
Exemple #6
0
void CryptManager::GenerateRSAKey( unsigned int keyLength, RString &sPrivKey, RString &sPubKey )
{
	int iRet;

	rsa_key key;
	iRet = rsa_make_key( &g_pPRNG->m_PRNG, g_pPRNG->m_iPRNG, keyLength / 8, 65537, &key );
	if( iRet != CRYPT_OK )
	{
		LOG->Warn( "GenerateRSAKey(%i) error: %s", keyLength, error_to_string(iRet) );
		return;
	}

	unsigned char buf[1024];
	unsigned long iSize = sizeof(buf);
	iRet = rsa_export( buf, &iSize, PK_PUBLIC, &key );
	if( iRet != CRYPT_OK )
	{
		LOG->Warn( "Export error: %s", error_to_string(iRet) );
		return;
	}

	sPubKey = RString( (const char *) buf, iSize );

	iSize = sizeof(buf);
	iRet = rsa_export( buf, &iSize, PK_PRIVATE, &key );
	if( iRet != CRYPT_OK )
	{
		LOG->Warn( "Export error: %s", error_to_string(iRet) );
		return;
	}

	sPrivKey = RString( (const char *) buf, iSize );
}
LRESULT MainDialog::OnFinishConvert(UINT, WPARAM wp, LPARAM)
{
	EnableDlgItem(IDC_XML, true);
	EnableDlgItem(IDC_XML_BROWSE, true);
	EnableDlgItem(IDC_OUT_IMPORT, true);
	EnableDlgItem(IDC_OUT_MYSQL, true);
	EnableDlgItem(IDC_OUT_PSQL7, true);
	EnableDlgItem(IDC_OUT_PSQL8, true);
	EnableDlgItem(IDC_OPT_NOTEXT, true);
	EnableDlgItem(IDC_OUTDIR, true);
	EnableDlgItem(IDC_OUTDIR_BROWSE, true);
	EnableDlgItem(IDC_START, true);
	OnUpdateOption(0, 0, 0);
	m_converting = false;
	
	SetWindowText(RString(IDS_APP_TITLE));
	if(!m_abort) {
		m_csStderr.Lock();
		if(wp == 0) {
			if(m_errbuff.IsEmpty()) {
				MessageBox(RString(IDS_COMPLETE), MB_ICONINFORMATION);
			} else {
				RString mesg(IDS_COMPLETE_WARNING);
				MessageBox(mesg + m_errbuff, MB_ICONINFORMATION);
			}
		} else {
			MessageBox(m_errbuff, MB_ICONEXCLAMATION);
		}
		m_csStderr.Unlock();
	}
	m_abort = false;
	return 0;
}
Exemple #8
0
static RString GetCurrentString( const CListBox &list )
{
	// TODO: Add your control notification handler code here
	int iSel = list.GetCurSel();
	if( iSel == LB_ERR )
		return RString();
	CString s;
	list.GetText( list.GetCurSel(), s );
	return RString( s );
}
void TitleSubst::Subst( TitleFields &tf )
{
	FOREACH_CONST( TitleTrans*, ttab, iter )
	{
		TitleTrans* tt = *iter;

		TitleFields to;
		if( !tt->Matches(tf,to) )
			continue;

		/* The song matches.  Replace whichever strings aren't empty. */
		if( !tt->Replacement.Title.empty() && tf.Title != tt->Replacement.Title )
		{
			if( tt->translit )
				tf.TitleTranslit = tf.Title;
			tf.Title = (tt->Replacement.Title != ERASE_MARKER)? to.Title : RString();
			FontCharAliases::ReplaceMarkers( tf.Title );
		}
		if( !tt->Replacement.Subtitle.empty() && tf.Subtitle != tt->Replacement.Subtitle )
		{
			if( tt->translit )
				tf.SubtitleTranslit = tf.Subtitle;
			tf.Subtitle = (tt->Replacement.Subtitle != ERASE_MARKER)? to.Subtitle : RString();
			FontCharAliases::ReplaceMarkers( tf.Subtitle );
		}
		if( !tt->Replacement.Artist.empty() && tf.Artist != tt->Replacement.Artist )
		{
			if( tt->translit )
				tf.ArtistTranslit = tf.Artist;
			tf.Artist = (tt->Replacement.Artist != ERASE_MARKER)? to.Artist : RString();
			FontCharAliases::ReplaceMarkers( tf.Artist );
		}

		/* These are used when applying kanji to a field that doesn't have the
		 * correct data.  Should be used sparingly. */
		if( !tt->Replacement.TitleTranslit.empty() )
		{
			tf.TitleTranslit = (tt->Replacement.TitleTranslit != ERASE_MARKER)? tt->Replacement.TitleTranslit : RString();
			FontCharAliases::ReplaceMarkers( tf.TitleTranslit );
		}
		if( !tt->Replacement.SubtitleTranslit.empty() )
		{
			tf.SubtitleTranslit = (tt->Replacement.SubtitleTranslit != ERASE_MARKER)? tt->Replacement.SubtitleTranslit : RString();
			FontCharAliases::ReplaceMarkers( tf.SubtitleTranslit );
		}
		if( !tt->Replacement.ArtistTranslit.empty() )
		{
			tf.ArtistTranslit = (tt->Replacement.ArtistTranslit != ERASE_MARKER)? tt->Replacement.ArtistTranslit : RString();
			FontCharAliases::ReplaceMarkers( tf.ArtistTranslit );
		}

		// Matched once.  Keep processing to allow multiple matching entries.  For example, allow 
		// one entry to translate a title, and another entry to translate the artist.
	}
Exemple #10
0
void Steps::SetNoteData( const NoteData& noteDataNew )
{
    ASSERT( noteDataNew.GetNumTracks() == GAMEMAN->GetStepsTypeInfo(m_StepsType).iNumTracks );

    DeAutogen( false );

    *m_pNoteData = noteDataNew;
    m_bNoteDataIsFilled = true;

    m_sNoteDataCompressed = RString();
    m_iHash = 0;
    m_sFilename = RString(); // We can no longer read from the file because it has changed in memory.
}
void StackAlloc_Test::perfTest()
{
  StackAllocScope stk;
  tick_t start = ::acdk::lang::sys::core_tick::now();
  allocTest(ObjectHeap::allocator());
  tick_t end1 = ::acdk::lang::sys::core_tick::now();
  allocTest(stk);
  tick_t end2 = ::acdk::lang::sys::core_tick::now();
  System::out->println(RString("Allocator 0: ") 
      + int(end1 - start) 
      + RString("; Allocator stackalloc: ") + int(end2 - end1));
  
}
void ChangeGameSettings::OnOK() 
{
	// TODO: Add extra validation here
	IniFile ini;
	ini.ReadFile( SpecialFiles::PREFERENCES_INI_PATH );

	if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_OPENGL) )
		ini.SetValue( "Options", "VideoRenderers", (RString)"opengl" );
	else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_DIRECT3D) )
		ini.SetValue( "Options", "VideoRenderers", (RString)"d3d" );
	else
		ini.SetValue( "Options", "VideoRenderers", RString() );


	if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_DIRECTSOUND_HARDWARE) )
		ini.SetValue( "Options", "SoundDrivers", (RString)"DirectSound" );
	else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_DIRECTSOUND_SOFTWARE) )
		ini.SetValue( "Options", "SoundDrivers", (RString)"DirectSound-sw" );
	else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_WAVEOUT) )
		ini.SetValue( "Options", "SoundDrivers", (RString)"WaveOut" );
	else if( BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_NULL) )
		ini.SetValue( "Options", "SoundDrivers", (RString)"null" );
	else
		ini.SetValue( "Options", "SoundDrivers", RString() );


	if( BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_FORCE_60HZ) )
	{
		ini.SetValue( "Options", "RefreshRate", 60 );
	}
	else
	{
		int iRefresh = 0;
		ini.GetValue( "Options", "RefreshRate", iRefresh );
		if( iRefresh == 60 )
			ini.SetValue( "Options", "RefreshRate", 0 );
	}
	ini.SetValue( "Options", "LogToDisk",		BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_LOG_TO_DISK) );
	ini.SetValue( "Options", "ShowLogOutput",	BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_SHOW_LOG_WINDOW) );


	if( !ini.WriteFile(SpecialFiles::PREFERENCES_INI_PATH) )
	{
		RString sError = ssprintf( ERROR_WRITING_FILE.GetValue(), SpecialFiles::PREFERENCES_INI_PATH.c_str(), ini.GetError().c_str() );
		Dialog::OK( sError );
	}

	CDialog::OnOK();
}
RString MovieDecoder_FFMpeg::Open( RString sFile )
{
	MovieTexture_FFMpeg::RegisterProtocols();
    
	m_fctx = avcodec::avformat_alloc_context();
	if( !m_fctx )
		return "AVCodec: Couldn't allocate context";
    
	RageFile *f = new RageFile;

	if( !f->Open(sFile, RageFile::READ) )
	{
		RString errorMessage = f->GetError();
		RString error = ssprintf("MovieDecoder_FFMpeg: Error opening \"%s\": %s", sFile.c_str(), errorMessage.c_str() );
		delete f;
		return error;
	}

	m_buffer = (unsigned char *)avcodec::av_malloc(STEPMANIA_FFMPEG_BUFFER_SIZE);
	m_avioContext = avcodec::avio_alloc_context(m_buffer, STEPMANIA_FFMPEG_BUFFER_SIZE, 0, f, AVIORageFile_ReadPacket, NULL, AVIORageFile_Seek);
	m_fctx->pb = m_avioContext;
	int ret = avcodec::avformat_open_input( &m_fctx, sFile.c_str(), NULL, NULL );
	if( ret < 0 )
		return RString( averr_ssprintf(ret, "AVCodec: Couldn't open \"%s\"", sFile.c_str()) );

	ret = avcodec::avformat_find_stream_info( m_fctx, NULL );
	if( ret < 0 )
		return RString( averr_ssprintf(ret, "AVCodec (%s): Couldn't find codec parameters", sFile.c_str()) );

	int stream_idx = avcodec::av_find_best_stream( m_fctx, avcodec::AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0 );
	if ( stream_idx < 0 ||
		static_cast<unsigned int>(stream_idx) >= m_fctx->nb_streams ||
		m_fctx->streams[stream_idx] == NULL )
		return "Couldn't find any video streams";
	m_pStream = m_fctx->streams[stream_idx];

	if( m_pStream->codec->codec_id == avcodec::CODEC_ID_NONE )
		return ssprintf( "Unsupported codec %08x", m_pStream->codec->codec_tag );

	RString sError = OpenCodec();
	if( !sError.empty() )
		return ssprintf( "AVCodec (%s): %s", sFile.c_str(), sError.c_str() );

	LOG->Trace( "Bitrate: %i", m_pStream->codec->bit_rate );
	LOG->Trace( "Codec pixel format: %s", avcodec::av_get_pix_fmt_name(m_pStream->codec->pix_fmt) );

	return RString();
}
Exemple #14
0
RString	Sprite::GetTexturePath() const
{
	if( m_pTexture==NULL )
		return RString();

	return m_pTexture->GetID().filename;
}
Exemple #15
0
static void InitEntities()
{
	if( !g_mapEntitiesToChars.empty() )
		return;

	static struct Entity
	{
		char c;
		const char *pEntity;
	}
	const EntityTable[] =
	{
		{ '&',  "amp", },
		{ '\"', "quot", },
		{ '\'', "apos", },
		{ '<',  "lt", },
		{ '>',  "gt", } 
	};

	for( unsigned i = 0; i < ARRAYLEN(EntityTable); ++i )
	{
		const Entity &ent = EntityTable[i];
		g_mapEntitiesToChars[ent.pEntity] = RString(1, ent.c);
		g_mapCharsToEntities[ent.c] = ent.pEntity;
	}
}
RString DSound::Init()
{
	HRESULT hr;
	if( FAILED( hr = DirectSoundCreate(NULL, &m_pDS, NULL) ) )
		return hr_ssprintf( hr, "DirectSoundCreate" );

	static bool bShownInfo = false;
	if( !bShownInfo )
	{
		bShownInfo = true;
		DirectSoundEnumerate( EnumCallback, 0 );

		DSCAPS Caps;
		Caps.dwSize = sizeof(Caps);
		HRESULT hr;
		if( FAILED(hr = m_pDS->GetCaps(&Caps)) )
		{
			LOG->Warn( hr_ssprintf(hr, "m_pDS->GetCaps failed") );
		}
		else
		{
			LOG->Info( "DirectSound sample rates: %i..%i %s", Caps.dwMinSecondarySampleRate, Caps.dwMaxSecondarySampleRate,
				(Caps.dwFlags & DSCAPS_CONTINUOUSRATE)?"(continuous)":"" );
		}
	}

	/* Try to set primary mixing privileges */
	hr = m_pDS->SetCooperativeLevel( GetDesktopWindow(), DSSCL_PRIORITY );

	SetPrimaryBufferMode();

	return RString();
}
Exemple #17
0
RString ArchHooks::GetPreferredLanguage()
{
	CFStringRef app = kCFPreferencesCurrentApplication;
	CFTypeRef t = CFPreferencesCopyAppValue( CFSTR("AppleLanguages"), app );
	RString ret = "en";

	if( t == NULL )
		return ret;
	if( CFGetTypeID(t) != CFArrayGetTypeID() )
	{
		CFRelease( t );
		return ret;
	}

	CFArrayRef languages = CFArrayRef( t );
	CFStringRef lang;

	if( CFArrayGetCount(languages) > 0 &&
		(lang = (CFStringRef)CFArrayGetValueAtIndex(languages, 0)) != NULL )
	{
		// MacRoman agrees with ASCII in the low-order 7 bits.
		const char *str = CFStringGetCStringPtr( lang, kCFStringEncodingMacRoman );
		if( str )
			ret = RString( str, 2 );
		else
			LOG->Warn( "Unable to determine system language. Using English." );
	}

	CFRelease( languages );
	return ret;
}
EXPORT_C RString RStringPool::String(TInt aIndex,const TStringTable& aTable) const
/** Gets a case-sensitive string specified by a string table enumeration value.

aIndex is interpreted as an offset into the handle's pre-loaded string table. 

@param	aIndex The string table enumeration value
@param	aTable The string table from which to read the string
@return	Initialised RString object
@panic	EStringTableNotFound If the table supplied is not found. This panic is raised in debug builds only, in release mode the behaviour is undefined*/
	{	
	__ASSERT_DEBUG(aTable.iCaseSensitive==1,StringPoolPanic::Panic(StringPoolPanic::ECreatingStringWithWrongCase));
	if(aIndex <(TInt)aTable.iCount)
		{//the index is in valid range the index 
		RString r;
		r.iPool = *this;
		TInt16 tableUid = iImplementation->TableUid(aTable);
		__ASSERT_DEBUG(tableUid!=KErrNotFound,StringPoolPanic::Panic(StringPoolPanic::EStringTableNotFound));
		r.iVal = StringUtils::ValFromIndex(aIndex, tableUid);
		TInt originalVal;	
		if (KErrNotFound!=(originalVal=iImplementation->FindFirstValFromDuplicate(r.iVal)))
			{
			r.iVal=originalVal;
			}
		return r;
		}
	else // the index is out of range 
	return RString();
	}
Exemple #19
0
TEST(StringTests, rshort)
{
    LString short_text = "0123456789"_s;
    EXPECT_EQ(&*short_text.begin(), &*RString(short_text).begin());
    EXPECT_EQ(&*short_text.begin(), &*AString(short_text).begin());
    RString r = VString<255>(short_text);
    EXPECT_EQ(r.size(), 10);
    AString a = VString<255>(short_text);
    EXPECT_EQ(r, a);
    AString r2 = r, r3;
    RString a2 = a, a3;
    XString r1 = r2;
    XString a1 = a2;
    r3 = r1;
    a3 = a1;
    EXPECT_EQ(r, r1);
    EXPECT_EQ(a, a1);
    EXPECT_EQ(r, r2);
    EXPECT_EQ(a, a2);
    EXPECT_EQ(r, r3);
    EXPECT_EQ(a, a3);
    EXPECT_EQ(&*r.begin(), &*r1.begin());
    EXPECT_NE(&*a.begin(), &*a1.begin());
    EXPECT_EQ(&*r.begin(), &*r2.begin());
    EXPECT_NE(&*a.begin(), &*a2.begin());
    EXPECT_EQ(&*r.begin(), &*r3.begin());
    EXPECT_NE(&*a.begin(), &*a3.begin());
}
Exemple #20
0
RString CryptManager::GetMD5ForFile( RString fn )
{
	RageFile file;
	if( !file.Open( fn, RageFile::READ ) )
	{
		LOG->Warn( "GetMD5: Failed to open file '%s'", fn.c_str() );
		return RString();
	}
	int iHash = register_hash( &md5_desc );
	ASSERT( iHash >= 0 );

	unsigned char digest[16];
	HashFile( file, digest, iHash );

	return RString( (const char *) digest, sizeof(digest) );
}
RString FindSystemFile( RString sFile )
{
	char szWindowsPath[MAX_PATH];
	GetWindowsDirectory( szWindowsPath, MAX_PATH );

	const char *szPaths[] =
	{
		"/system32/",
		"/system32/drivers/",
		"/system/",
		"/system/drivers/",
		"/",
		NULL
	};

	for( int i = 0; szPaths[i]; ++i )
	{
		RString sPath = ssprintf( "%s%s%s", szWindowsPath, szPaths[i], sFile.c_str() );
		struct stat buf;
		if( !stat(sPath, &buf) )
			return sPath;
	}

	return RString();
}
Exemple #22
0
bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, RString &sVal )
{
	HKEY hKey = OpenRegKey( sKey, READ );
	if( hKey == NULL )
		return false;

	char sBuffer[MAX_PATH];
	DWORD iSize = sizeof(sBuffer);
	DWORD iType;
	LONG iRet = RegQueryValueEx( hKey, sName, NULL, &iType, (LPBYTE)sBuffer, &iSize );
	RegCloseKey( hKey );
	if( iRet != ERROR_SUCCESS )
		return false;

	/* Actually, CStrings are 8-bit clean, so we can accept any type of data.  Remove
	 * this if that becomes useful. */
	if( iType != REG_SZ && iType != REG_MULTI_SZ && iType != REG_EXPAND_SZ && iType != REG_BINARY )
		return false; /* type mismatch */

	if( iSize && (iType == REG_SZ || iType == REG_MULTI_SZ || iType == REG_EXPAND_SZ) )
		--iSize; /* remove nul terminator */

	sVal = RString( sBuffer, iSize );
	return true;
}
void ScreenOptionsEditProfile::BeginScreen()
{
	m_Original = *GAMESTATE->GetEditLocalProfile();

	vector<OptionRowHandler*> vHands;

	Profile *pProfile = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sEditLocalProfileID );
	ASSERT( pProfile != NULL );

	{
		vHands.push_back( OptionRowHandlerUtil::MakeNull() );
		OptionRowDefinition &def = vHands.back()->m_Def;
		def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
		def.m_bOneChoiceForAllPlayers = true;
		def.m_bAllowThemeItems = false;
		def.m_bAllowThemeTitle = false;
		def.m_bAllowExplanation = false;
		def.m_bExportOnChange = true;
		def.m_sName = "Character";
		def.m_vsChoices.clear();
		vector<Character*> vpCharacters;
		CHARMAN->GetCharacters( vpCharacters );
		FOREACH_CONST( Character*, vpCharacters, c )
			def.m_vsChoices.push_back( (*c)->GetDisplayName() );
		if( def.m_vsChoices.empty() )
			def.m_vsChoices.push_back( RString() );
	}

	InitMenu( vHands );

	ScreenOptions::BeginScreen();
}
Exemple #24
0
XNode *HighScoreImpl::CreateNode() const
{
	XNode *pNode = new XNode( "HighScore" );
	const bool bWriteSimpleValues = RadarValues::WRITE_SIMPLE_VALIES;
	const bool bWriteComplexValues = RadarValues::WRITE_COMPLEX_VALIES;

	// TRICKY:  Don't write "name to fill in" markers.
	pNode->AppendChild( "Name",			IsRankingToFillIn(sName) ? RString("") : sName );
	pNode->AppendChild( "Grade",			GradeToString(grade) );
	pNode->AppendChild( "Score",			iScore );
	pNode->AppendChild( "PercentDP",		fPercentDP );
	pNode->AppendChild( "SurviveSeconds",	fSurviveSeconds );
	pNode->AppendChild( "MaxCombo",			iMaxCombo );
	pNode->AppendChild( "StageAward",		StageAwardToString(stageAward) );
	pNode->AppendChild( "PeakComboAward",	PeakComboAwardToString(peakComboAward) );
	pNode->AppendChild( "Modifiers",		sModifiers );
	pNode->AppendChild( "DateTime",			dateTime.GetString() );
	pNode->AppendChild( "PlayerGuid",		sPlayerGuid );
	pNode->AppendChild( "MachineGuid",		sMachineGuid );
	pNode->AppendChild( "ProductID",		iProductID );
	XNode* pTapNoteScores = pNode->AppendChild( "TapNoteScores" );
	FOREACH_ENUM( TapNoteScore, tns )
		if( tns != TNS_None )	// HACK: don't save meaningless "none" count
			pTapNoteScores->AppendChild( TapNoteScoreToString(tns), iTapNoteScores[tns] );
	XNode* pHoldNoteScores = pNode->AppendChild( "HoldNoteScores" );
	FOREACH_ENUM( HoldNoteScore, hns )
		if( hns != HNS_None )	// HACK: don't save meaningless "none" count
			pHoldNoteScores->AppendChild( HoldNoteScoreToString(hns), iHoldNoteScores[hns] );
	pNode->AppendChild( radarValues.CreateNode(bWriteSimpleValues, bWriteComplexValues) );
	pNode->AppendChild( "LifeRemainingSeconds",	fLifeRemainingSeconds );
	pNode->AppendChild( "Disqualified",		bDisqualified);

	return pNode;
}
RString ArchHooks_Win32::GetMachineId() const
{
	RString s;
	if( RegistryAccess::GetRegValue( CURRENT_VERSION_KEY, "ProductID", s ) )
		return s;
	return RString();
}
void ScreenTextEntry::UpdateAnswerText()
{
	RString s;
	if( g_bPassword )
		s = RString( m_sAnswer.size(), '*' );
	else
		s = WStringToRString(m_sAnswer);

	bool bAnswerFull = (int) s.length() >= g_iMaxInputLength;

	if( g_pFormatAnswerForDisplay )
		s = g_pFormatAnswerForDisplay( s );

	// Handle caret drawing
	//m_iCaretLocation = s.length()
	if( m_bShowAnswerCaret 	&&  !bAnswerFull )
		s += ANSWER_CARET; // was '_'
	else
	{
		s += ANSWER_BLANK; // was "  "
	}

	FontCharAliases::ReplaceMarkers( s );
	m_textAnswer.SetText( s );
}
Exemple #27
0
void Steps::Compress() const
{
    /* Always leave lights data uncompressed. */
    if( this->m_StepsType == StepsType_lights_cabinet && m_bNoteDataIsFilled )
    {
        m_sNoteDataCompressed = RString();
        return;
    }

    /* Always leave karaoke data uncompressed. */
    if( this->m_StepsType == StepsType_karaoke_single && m_bNoteDataIsFilled )
    {
        m_sNoteDataCompressed = RString();
        return;
    }

    if( !m_sFilename.empty() && m_LoadedFromProfile == ProfileSlot_Invalid )
    {
        /*
         * We have a file on disk; clear all data in memory.
         *
         * Data on profiles can't be accessed normally (need to mount and time-out the
         * device), and when we start a game and load edits, we want to be sure that
         * it'll be available if the user picks it and pulls the device.  Also,
         * Decompress() doesn't know how to load .edits.
         */
        m_pNoteData->Init();
        m_bNoteDataIsFilled = false;

        /* Be careful; 'x = ""', m_sNoteDataCompressed.clear() and m_sNoteDataCompressed.reserve(0)
         * don't always free the allocated memory. */
        m_sNoteDataCompressed = RString();
        return;
    }

    /* We have no file on disk.  Compress the data, if necessary. */
    if( m_sNoteDataCompressed.empty() )
    {
        if( !m_bNoteDataIsFilled )
            return; /* no data is no data */
        NoteDataUtil::GetSMNoteDataString( *m_pNoteData, m_sNoteDataCompressed );
    }

    m_pNoteData->Init();
    m_bNoteDataIsFilled = false;
}
/* Return a reversible representation of a DeviceInput. This is not affected by
 * InputDrivers, localization or the keyboard language. */
RString DeviceInput::ToString() const
{
	if( device == InputDevice_Invalid )
		return RString();

	RString s = InputDeviceToString(device) + "_" + DeviceButtonToString(button);
	return s;
}
void
String2_Test::join()
{
  RStringArray sa = new StringArray(0);
  sa->append("first");
  sa->append("second");
  sa->append("third");

  testAssert(String::join((RObjectArray)sa)->equals("firstsecondthird") == true);
  testAssert(String::join((RObjectArray)sa, "|")->equals("first|second|third") == true);
  testAssert(String::join(sa->iterator())->equals("firstsecondthird") == true);
  testAssert(String::join(sa->iterator(), "|")->equals("first|second|third") == true);
  testAssert(String::join(sa->iterator(), '|')->equals("first|second|third") == true);
  testAssert(String::join((RObjectArray)Nil, "|") == Nil);

  testAssert(RString("a b  c")->split()->length() == 3);
  testAssert(RString("a|b|c")->split('|')->length() == 3);
}
Exemple #30
0
static void AddPart( vector<RString> &AddTo, float level, RString name )
{
	if( level == 0 )
		return;

	const RString LevelStr = (level == 1)? RString(""): ssprintf( "%ld%% ", lrintf(level*100) );

	AddTo.push_back( LevelStr + name );
}