当前位置: 首页>>代码示例>>C++>>正文


C++ Preference类代码示例

本文整理汇总了C++中Preference的典型用法代码示例。如果您正苦于以下问题:C++ Preference类的具体用法?C++ Preference怎么用?C++ Preference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Preference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ChangeVisualDelay

void ChangeVisualDelay( float fDelta )
{
	Preference<float> *pRet = Preference<float>::GetPreferenceByName("VisualDelaySeconds");
	float fSecs = pRet->Get();
	fSecs += fDelta;
	fSecs = Rage::clamp( fSecs, -1.0f, 1.0f );
	pRet->Set( fSecs );
}
开发者ID:hanubeki,项目名称:stepmania,代码行数:8,代码来源:ScreenDebugOverlay.cpp

示例2: ChangeVolume

void ChangeVolume( float fDelta )
{
	Preference<float> *pRet = Preference<float>::GetPreferenceByName("SoundVolume");
	float fVol = pRet->Get();
	fVol += fDelta;
	fVol = Rage::clamp( fVol, 0.0f, 1.0f );
	pRet->Set( fVol );
	SOUNDMAN->SetMixVolume();
}
开发者ID:hanubeki,项目名称:stepmania,代码行数:9,代码来源:ScreenDebugOverlay.cpp

示例3: MoveMap

static void MoveMap( int &sel, Preference<T> &opt, bool ToSel, const T *mapping, unsigned cnt )
{
	if( ToSel )
	{
		sel = FindClosestEntry( opt.Get(), mapping, cnt );
	} else {
		/* sel -> opt */
		opt.Set( mapping[sel] );
	}
}
开发者ID:BitMax,项目名称:openitg,代码行数:10,代码来源:ScreenOptionsMasterPrefs.cpp

示例4: MoveData

static void MoveData( int &sel, Preference<bool> &opt, bool ToSel )
{
	if( ToSel )	sel = opt;
	else		opt.Set( !!sel );
}
开发者ID:BitMax,项目名称:openitg,代码行数:5,代码来源:ScreenOptionsMasterPrefs.cpp

示例5: Preference

void MainWindow::showPreference()
{
    Preference *pref = new Preference(this);
    connect(pref, &Preference::accepted, this, &MainWindow::setColor);
    pref->exec();
}
开发者ID:Geremia,项目名称:FancyClock,代码行数:6,代码来源:mainwindow.cpp

示例6: FrameLimitBeforeVsync

void RageDisplay::FrameLimitBeforeVsync( int iFPS )
{
	ASSERT( iFPS != 0 );

	int iDelayMicroseconds = 0;
	if( g_fFrameLimitPercent.Get() > 0.0f && !g_LastFrameEndedAt.IsZero() )
	{
		float fFrameTime = g_LastFrameEndedAt.GetDeltaTime();
		float fExpectedTime = 1.0f / iFPS;

		/* This is typically used to turn some of the delay that would normally
		 * be waiting for vsync and turn it into a usleep, to make sure we give
		 * up the CPU.  If we overshoot the sleep, then we'll miss the vsync,
		 * so allow tweaking the amount of time we expect a frame to take.
		 * Frame limiting is disabled by setting this to 0. */
		fExpectedTime *= g_fFrameLimitPercent.Get();
		float fExtraTime = fExpectedTime - fFrameTime;

		iDelayMicroseconds = int(fExtraTime * 1000000);
	}

	if( !HOOKS->AppHasFocus() )
		iDelayMicroseconds = max( iDelayMicroseconds, 10000 ); // give some time to other processes and threads

#if defined(_WINDOWS)
	/* In Windows, always explicitly give up a minimum amount of CPU for other threads. */
	iDelayMicroseconds = max( iDelayMicroseconds, 1000 );
#endif

	if( iDelayMicroseconds > 0 )
		usleep( iDelayMicroseconds );
}
开发者ID:Highlogic,项目名称:stepmania-event,代码行数:32,代码来源:RageDisplay.cpp

示例7: FrameLimitAfterVsync

void RageDisplay::FrameLimitAfterVsync()
{
	if( g_fFrameLimitPercent.Get() == 0.0f )
		return;

	g_LastFrameEndedAt.Touch();
}
开发者ID:Highlogic,项目名称:stepmania-event,代码行数:7,代码来源:RageDisplay.cpp

示例8: ChangeAppPri

static bool ChangeAppPri()
{
	if( g_bNeverBoostAppPriority.Get() )
		return false;

	// if using NTPAD don't boost or else input is laggy
#if defined(_WINDOWS)
	{
		vector<InputDeviceInfo> vDevices;

		// This can get called before INPUTMAN is constructed.
		if( INPUTMAN )
		{
			INPUTMAN->GetDevicesAndDescriptions(vDevices);
			FOREACH_CONST( InputDeviceInfo, vDevices, d )
			{
				if( d->sDesc.find("NTPAD") != string::npos )
				{
					LOG->Trace( "Using NTPAD.  Don't boost priority." );
					return false;
				}
			}
		}
	}
#endif

	/* If this is a debug build, don't.  It makes the VC debugger sluggish. */
#if defined(WIN32) && defined(DEBUG)
	return false;
#else
	return true;
#endif
}
开发者ID:goofwear,项目名称:stepmania,代码行数:33,代码来源:GameLoop.cpp

示例9: UpdateSongPosition

void SongPosition::UpdateSongPosition( float fPositionSeconds, const TimingData &timing, const RageTimer &timestamp )
{

	if( !timestamp.IsZero() )
		m_LastBeatUpdate = timestamp;
	else
		m_LastBeatUpdate.Touch();

	TimingData::GetBeatArgs beat_info;
	beat_info.elapsed_time= fPositionSeconds;
	timing.GetBeatAndBPSFromElapsedTime(beat_info);
	m_fSongBeat= beat_info.beat;
	m_fCurBPS= beat_info.bps_out;
	m_bFreeze= beat_info.freeze_out;
	m_bDelay= beat_info.delay_out;
	m_iWarpBeginRow= beat_info.warp_begin_out;
	m_fWarpDestination= beat_info.warp_dest_out;
	
	// "Crash reason : -243478.890625 -48695.773438"
	// The question is why is -2000 used as the limit? -aj
	ASSERT_M( m_fSongBeat > -2000, ssprintf("Song beat %f at %f seconds is less than -2000!", m_fSongBeat, fPositionSeconds) );

	m_fMusicSeconds = fPositionSeconds;

	m_fLightSongBeat = timing.GetBeatFromElapsedTime( fPositionSeconds + g_fLightsAheadSeconds );

	m_fSongBeatNoOffset = timing.GetBeatFromElapsedTimeNoOffset( fPositionSeconds );
	
	m_fMusicSecondsVisible = fPositionSeconds - g_fVisualDelaySeconds.Get();
	beat_info.elapsed_time= m_fMusicSecondsVisible;
	timing.GetBeatAndBPSFromElapsedTime(beat_info);
	m_fSongBeatVisible= beat_info.beat;
}
开发者ID:Highlogic,项目名称:stepmania-event,代码行数:33,代码来源:SongPosition.cpp

示例10: HandleScreenMessage

void ScreenNetworkOptions::HandleScreenMessage( const ScreenMessage SM )
{
	if( SM == SM_DoneConnecting )
	{
		if( !ScreenTextEntry::s_bCancelledLast )
		{
			CString sNewName = ScreenTextEntry::s_sLastAnswer;
			NSMAN->PostStartUp(sNewName);
			NSMAN->DisplayStartupStatus();
			UpdateConnectStatus( );
			g_sLastServer.Set( ScreenTextEntry::s_sLastAnswer );
		}
	}
	else if( SM == SM_ServerNameEnter )
	{
		if( !ScreenTextEntry::s_bCancelledLast )
		{
			if ( NSMAN->LANserver == NULL)
				NSMAN->LANserver = new StepManiaLanServer;
			NSMAN->LANserver->servername = ScreenTextEntry::s_sLastAnswer;
			if (NSMAN->LANserver->ServerStart())
			{
				NSMAN->isLanServer = true;
				SCREENMAN->SystemMessage( "Server Started." );
			}
			else
				SCREENMAN->SystemMessage( "Server failed: " + NSMAN->LANserver->lastError + ssprintf(" Code:%d",NSMAN->LANserver->lastErrorCode) );
		}
	}

	ScreenOptions::HandleScreenMessage( SM );
}
开发者ID:Prcuvu,项目名称:StepMania-3.95,代码行数:32,代码来源:ScreenNetworkOptions.cpp

示例11: Open

bool RageSoundReader_Preload::Open( RageSoundReader *pSource )
{
	ASSERT( pSource );
	m_iSampleRate = pSource->GetSampleRate();
	m_iChannels = pSource->GetNumChannels();
	m_fRate = pSource->GetStreamToSourceRatio();

	int iMaxSamples = g_iSoundPreloadMaxSamples.Get();
	
	/* Check the length, and see if we think it'll fit in the buffer. */
	int iLen = pSource->GetLength_Fast();
	if( iLen != -1 )
	{
		float fSecs = iLen / 1000.f;

		int iFrames = lrintf( fSecs * m_iSampleRate ); /* seconds -> frames */
		int iSamples = unsigned( iFrames * m_iChannels ); /* frames -> samples */
		if( iSamples > iMaxSamples )
			return false; /* Don't bother trying to preload it. */

		int iBytes = unsigned( iSamples * samplesize ); /* samples -> bytes */
		m_Buffer.Get()->reserve( iBytes );
	}

	while(1)
	{
		/* If the rate changes, we won't preload it. */
		if( pSource->GetStreamToSourceRatio() != m_fRate )
			return false; /* Don't bother trying to preload it. */

		float buffer[1024];
		int iCnt = pSource->Read( buffer, ARRAYLEN(buffer) / m_iChannels );

		if( iCnt == END_OF_FILE )
			break;
		if( iCnt < 0 )
			return false;

		/* Add the buffer. */
		if( m_bBufferIs16Bit )
		{
			int16_t buffer16[1024];
			RageSoundUtil::ConvertFloatToNativeInt16( buffer, buffer16, iCnt*m_iChannels );
			m_Buffer.Get()->append( (char *) buffer16, (char *) (buffer16+iCnt*m_iChannels) );
		}
		else
		{
			m_Buffer.Get()->append( (char *) buffer, (char *) (buffer+iCnt*m_iChannels) );
		}

		if( m_Buffer.Get()->size() > iMaxSamples * samplesize )
			return false; /* too big */
	}

	m_iPosition = 0;
	delete pSource;
	return true;
}
开发者ID:goofwear,项目名称:stepmania,代码行数:58,代码来源:RageSoundReader_Preload.cpp

示例12: XCreateColormap

bool X11Helper::MakeWindow( Window &win, int screenNum, int depth, Visual *visual, int width, int height, bool overrideRedirect )
{
	if( !Dpy )
		return false;

	XSetWindowAttributes winAttribs;
	winAttribs.border_pixel = 0;
	winAttribs.event_mask = 0L;

	if( win )
	{
		// Preserve the event mask.
		XWindowAttributes attribs;
		XGetWindowAttributes( Dpy, win, &attribs );
		winAttribs.event_mask = attribs.your_event_mask;
		XDestroyWindow( Dpy, win );
	}
	// XXX: Error catching/handling?
	winAttribs.colormap = XCreateColormap( Dpy, RootWindow(Dpy, screenNum), visual, AllocNone );
	unsigned long mask = CWBorderPixel | CWColormap | CWEventMask;

	if( overrideRedirect )
	{
		winAttribs.override_redirect = True;
		mask |= CWOverrideRedirect;
	}
	win = XCreateWindow( Dpy, RootWindow(Dpy, screenNum), 0, 0, width, height, 0,
			     depth, InputOutput, visual, mask, &winAttribs );
	if( win == None )
		return false;

	XClassHint *hint = XAllocClassHint();
	if ( hint == nullptr ) {
		LOG->Warn("Could not set class hint for X11 Window");
	} else {
		hint->res_name   = (char*)g_XWMName.Get().c_str();
		hint->res_class  = (char*)PRODUCT_FAMILY;
		XSetClassHint(Dpy, win, hint);
		XFree(hint);
	}

	// Hide the mouse cursor in certain situations.
    if( !PREFSMAN->m_bShowMouseCursor )
	{
		const char pBlank[] = { 0,0,0,0,0,0,0,0 };
		Pixmap BlankBitmap = XCreateBitmapFromData( Dpy, win, pBlank, 8, 8 );

		XColor black = { 0, 0, 0, 0, 0, 0 };
		Cursor pBlankPointer = XCreatePixmapCursor( Dpy, BlankBitmap, BlankBitmap, &black, &black, 0, 0 );
		XFreePixmap( Dpy, BlankBitmap );

		XDefineCursor( Dpy, win, pBlankPointer );
		XFreeCursor( Dpy, pBlankPointer );
	}

	return true;
}
开发者ID:dguzek,项目名称:stepmania,代码行数:57,代码来源:X11Helper.cpp

示例13:

LightsDriver_EXTIO::LightsDriver_EXTIO()
{
	if (s_bInitialized) return;
	s_bInitialized = true; //only one instance should do this
	m_bShutdown = false;


	LOG->Info("EXTIO: Initializing EXTIO Light drivers...");
	LOG->Info("EXTIO: Configured EXTIO serial port: %s", m_EXTIO_COMPORT.Get().c_str());
	//check if we have a valid com port name for EXTIO
	if (m_EXTIO_COMPORT.Get().length()>1)
	{
		//this is nice because EXTIO code will now only run after this SINGLE check
		EXTIOThread.SetName("EXTIO thread");
		EXTIOThread.Create(EXTIOThread_Start, this);
	}


}
开发者ID:mooinglemur,项目名称:openitg,代码行数:19,代码来源:LightsDriver_EXTIO.cpp

示例14: HandleScreenMessage

void ScreenNetworkOptions::HandleScreenMessage( const ScreenMessage SM )
{
	if( SM == SM_DoneConnecting )
	{
		if( !ScreenTextEntry::s_bCancelledLast )
		{
			RString sNewName = ScreenTextEntry::s_sLastAnswer;
			NSMAN->PostStartUp(sNewName);
			NSMAN->DisplayStartupStatus();
			UpdateConnectStatus( );
			g_sLastServer.Set( ScreenTextEntry::s_sLastAnswer );
		}
	}

	ScreenOptions::HandleScreenMessage( SM );
}
开发者ID:goofwear,项目名称:stepmania,代码行数:16,代码来源:ScreenNetworkOptions.cpp

示例15: EXTIOThreadMain

void LightsDriver_EXTIO::EXTIOThreadMain()
{
	extio.setPort(m_EXTIO_COMPORT.Get().c_str()); //on a ddr pcb, extio must reside on COM1
	extio.setBaudrate(38400);
	extio.setTimeout(serial_timeout);
	extio.open();
	LOG->Info("EXTIO: Opened EXTIO");
	//all P2/P3IO have the extio as pad lights so lets make sure that is good

	while (!m_bShutdown)
	{
		//LOG->Info("EXTIO: EXTIO PING");
		UpdateLightsEXTIO();
		usleep(16666); //60 times per sec

	}

	//turn off pad lights
	memset(extio_message, 0, 4 * sizeof(uint8_t));// zero out the message
	WriteExtioPacket();

}
开发者ID:mooinglemur,项目名称:openitg,代码行数:22,代码来源:LightsDriver_EXTIO.cpp


注:本文中的Preference类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。