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


C++ Control::GetType方法代码示例

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


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

示例1: if

/**
*  @brief
*    Called when a control of the input controller has been activated
*/
void Application30::OnControl(Control &cControl)
{
	// Get name of control
	String sControl = cControl.GetName();

	// Display control value
	String sValue;
	if (cControl.GetType() == ControlButton)
		sValue = static_cast<Button&>(cControl).IsPressed() ? "<pressed>" : "<released>";
	else if (cControl.GetType() == ControlAxis)
		sValue = String::Format("%5.2f", static_cast<Axis&>(cControl).GetValue());
	System::GetInstance()->GetConsole().Print("- '" + sControl + "': " + sValue + '\n');

	// LED test
	if ((cControl.GetName() == "Plus" || cControl.GetName() == "Minus") && static_cast<Button&>(cControl).IsPressed()) {
		// Get LED control
		LED *pLED = static_cast<LED*>(cControl.GetController()->GetControl("LED"));
		if (pLED) {
			// Change LED value
			uint32 nLED = pLED->GetLEDs();
			if (cControl.GetName() == "Plus")
				nLED++;
			else
				nLED--;
			if (nLED > 15)
				nLED = 0;
			pLED->SetLEDs(nLED);
		}
	}

	// Rumble test
	if (cControl.GetName() == "Button1" || cControl.GetName() == "Button2") {
		// Get rumble control (try "Rumble3" first for joystick, then "Rumble1" for WiiMote)
		Effect *pRumble = static_cast<Effect*>(cControl.GetController()->GetControl("Rumble3"));
		if (!pRumble)
			pRumble = static_cast<Effect*>(cControl.GetController()->GetControl("Rumble1"));
		if (pRumble) {
			// Enable or disable rumble?
			if (cControl.GetName() == "Button1")
				pRumble->SetValue(1.0f);
			if (cControl.GetName() == "Button2")
				pRumble->SetValue(0.0f);
		}
	}
}
开发者ID:Tank-D,项目名称:potential-octo-dubstep,代码行数:49,代码来源:Application30.cpp

示例2: PerformPicking

/**
*  @brief
*    Performs the picking
*/
void MyPicking::PerformPicking()
{
	// Get the default input controller of the application
	Controller *pController = reinterpret_cast<Controller*>(m_pApplication->GetInputController());
	if (pController && pController->GetActive()) {
		// Get the "MouseLeft" control
		Control *pControl = pController->GetControl("MouseLeft");
		if (pControl && pControl->GetType() == ControlButton) {
			Button *pButton = reinterpret_cast<Button*>(pControl);
			SceneNode *pPickedSceneNode = nullptr;

			// If the left mouse button is currently down, do NOT perform new picking
			if (!pButton->IsPressed()) {
				// Get the current time data
				const uint64 nPastTime = Timing::GetInstance()->GetPastTime();

				// Perform mouse picking - do not make this test each frame because it may cost some performance
				if ((nPastTime-m_nLastPickingTime) > 100) {
					m_nLastPickingTime = nPastTime;

					// Perform picking - "PerformMousePicking()" is using the current mouse position inside the main window
					// and the currently used camera in order to find the scene node under the mouse cursor
					PickingResult cPickingResult;
					if (PerformMousePicking(cPickingResult))
						pPickedSceneNode = cPickingResult.GetSceneNode();
				} else {
					// Use the previous result
					pPickedSceneNode = m_cCurrentPickedSceneNodeHandler.GetElement();
				}

				// Picked changed?
				if (pPickedSceneNode != m_cCurrentPickedSceneNodeHandler.GetElement()) {
					// Backup the currently picked scene node
					m_cCurrentPickedSceneNodeHandler.SetElement(pPickedSceneNode);
				}
			}

			// Is currently anything picked?
			if (pButton->IsHit() && pPickedSceneNode) {
				// Toggle the debug mode of the picked scene node
				if (pPickedSceneNode->GetDebugFlags() & SceneNode::DebugEnabled) {
					// Disable debug mode
					pPickedSceneNode->SetDebugFlags(pPickedSceneNode->GetDebugFlags() & ~SceneNode::DebugEnabled);
				} else {
					// Enable debug mode
					pPickedSceneNode->SetDebugFlags(pPickedSceneNode->GetDebugFlags() |SceneNode::DebugEnabled);
				}
			}
		}
	}
}
开发者ID:Tank-D,项目名称:potential-octo-dubstep,代码行数:55,代码来源:MyPicking.cpp

示例3: MouseScrolls

void Gui::MouseScrolls(SRPWindows *pSRPWindow, Control &cControl)
{
	if (pSRPWindow)
	{
		if (pSRPWindow->GetData()->bIsVisable && pSRPWindow->GetData()->bMouseEnabled)
		{
			if (cControl.GetType() == ControlAxis)
			{
				if (cControl.GetName() == "MouseWheel")
				{
					// if all of the above is true, send mouse scroll
					pSRPWindow->GetAwesomiumWindow()->InjectMouseWheel(int(static_cast<Axis&>(cControl).GetValue()), 0);
				}
			}
		}
	}
}
开发者ID:PixelLightCommunity,项目名称:Plugins,代码行数:17,代码来源:Gui.cpp

示例4: if

/**
*  @brief
*    Called when a control event has occurred
*/
void Application61::OnControl(Control &cControl)
{
	// Is it a button?
	if (cControl.GetType() == ControlButton && static_cast<Button&>(cControl).IsPressed()) {
		// Check whether the escape key was pressed
		if (cControl.GetName() == "KeyboardEscape") {
			// Shut down the application
			Exit(0);
		} else {
			// Get current time difference
			Timing *pTimer = Timing::GetInstance();
			const float fTimeScaleFactor = pTimer->GetTimeScaleFactor();

			// Check button
			if (cControl.GetName() == "Keyboard1") {
				// Decrease timescale
				pTimer->SetTimeScaleFactor(fTimeScaleFactor - 0.1f);
				if (pTimer->GetTimeScaleFactor() < 0.1f)
					pTimer->SetTimeScaleFactor(0.1f);
			} else if (cControl.GetName() == "Keyboard2") {
				// Increase timescale
				pTimer->SetTimeScaleFactor(fTimeScaleFactor +  0.1f);
				if (pTimer->GetTimeScaleFactor() > 4.0f)
					pTimer->SetTimeScaleFactor(4.0f);
			} else if (cControl.GetName() == "Keyboard3") {
				// Reset timescale
				pTimer->SetTimeScaleFactor();
			}

			// Time scale factor changed?
			if (fTimeScaleFactor != pTimer->GetTimeScaleFactor()) {
				// Update the time scale text node
				UpdateTimeScaleTextNode();

				// Update the pitch variable of the sound container using the time scale factor
				SceneContainer *pSceneContainer = GetScene();
				if (pSceneContainer)
					pSceneContainer->SetAttribute("Pitch", pTimer->GetTimeScaleFactor());
			}
		}
	}
}
开发者ID:Tank-D,项目名称:potential-octo-dubstep,代码行数:46,代码来源:Application61.cpp

示例5: OnControl

/**
*  @brief
*    Called when a control event has occurred
*/
void Application::OnControl(Control &cControl)
{
	// Is it a button and was it just hit?
	if (cControl.GetType() == ControlButton) {
		// Shut down the application?
		if (cControl.GetName() == "KeyboardEscape") {
			if (reinterpret_cast<Button&>(cControl).IsHit())
				Exit(0);

		// Make a screenshot from the current render target?
		} else if (cControl.GetName() == "KeyboardF12") {
			if (reinterpret_cast<Button&>(cControl).IsHit())
				GetScreenshotTool().SaveScreenshot();

		// Toggle mouse cursor visibility?
		} else if (cControl.GetName() == "KeyboardM") {
			// Toggle mouse cursor visibility
			if (reinterpret_cast<Button&>(cControl).IsHit())
				GetFrontend().SetMouseVisible(!GetFrontend().IsMouseVisible());
		}
	}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:26,代码来源:Application.cpp

示例6: if

/**
*  @brief
*    Called when a control event has occurred
*/
void Application67::OnControl(Control &cControl)
{
	// Is it a button and was it just hit?
	if (cControl.GetType() == ControlButton && reinterpret_cast<Button&>(cControl).IsHit()) {
		// Check whether the escape key was pressed
		if (cControl.GetName() == "KeyboardEscape") {
			// Shut down the application
			Exit(0);

		// Restart the game
		} else if (cControl.GetName() == "KeyboardR") {
			Restart();

		// Toggle post processing
		} else if (cControl.GetName() == "KeyboardP") {
			// Get the camera
			const SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera());
			if (pCamera) {
				// Loop through all available post process scene node modifiers
				bool			   bRenderToTexture = false;
				uint32			   nIndex			= 0;
				SceneNodeModifier *pModifier		= pCamera->GetModifier("PLCompositing::SNMPostProcess", nIndex);
				while (pModifier) {
					// Toggle the active state of the post process scene node modifier
					pModifier->SetActive(!pModifier->IsActive());
					if (pModifier->IsActive())
						bRenderToTexture = true;

					// Next modifier, please
					pModifier = pCamera->GetModifier("PLCompositing::SNMPostProcess", ++nIndex);
				}

				// Enable/disable render to texture for the post processing feature
				GetSceneRendererTool().SetPassAttribute("Begin", "Flags", bRenderToTexture ? "" : "Inactive");
			}
		}
	}
}
开发者ID:ByeDream,项目名称:pixellight,代码行数:42,代码来源:Application67.cpp

示例7:

/**
*  @brief
*    Called when a control event has occurred
*/
void Application70::OnControl(Control &cControl)
{
	// Check whether the escape key was pressed
	if (cControl.GetType() == ControlButton && cControl.GetName() == "KeyboardEscape")
		Exit(0); // Shut down the application
}
开发者ID:Tank-D,项目名称:potential-octo-dubstep,代码行数:10,代码来源:Application70.cpp

示例8: if

/**
*  @brief
*    Called when a control event has occurred
*/
void Application65::OnControl(Control &cControl)
{
	// Is it a button and was it just hit?
	if (cControl.GetType() == ControlButton && reinterpret_cast<Button&>(cControl).IsHit()) {
		// Check whether the escape key was pressed
		if (cControl.GetName() == "KeyboardEscape") {
			// Shut down the application
			Exit(0);

		// Show/hide the help text
		} else if (cControl.GetName() == "KeyboardF1") {
			// Get the info text scene node
			SceneNode *pSceneNode = GetRootScene() ? GetRootScene()->GetByName("InfoText") : nullptr;
			if (pSceneNode) {
				// Toggle the active state of the scene node
				pSceneNode->SetActive(!pSceneNode->IsActive());
			}

		// Toggle post processing
		} else if (cControl.GetName() == "KeyboardSpace") {
			// Get the currently used camera
			SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera());
			if (pCamera) {
				// Loop through all available post process scene node modifiers
				uint32			   nIndex    = 0;
				SceneNodeModifier *pModifier = pCamera->GetModifier("PLCompositing::SNMPostProcess", nIndex);
				while (pModifier) {
					// Toggle the active state of the post process scene node modifier
					pModifier->SetActive(!pModifier->IsActive());

					// Next modifier, please
					pModifier = pCamera->GetModifier("PLCompositing::SNMPostProcess", ++nIndex);
				}
			}

		// Next post process effect
		} else if (cControl.GetName() == "KeyboardPageUp") {
			// Get the currently used camera
			SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera());
			if (pCamera) {
				// Increase the current selected modifier index
				m_nCurrentSelectedModifier++;
				if (m_nCurrentSelectedModifier >= m_lstModifierClasses.GetNumOfElements())
					m_nCurrentSelectedModifier = 0;

				// Remove all old modifiers add the new one
				pCamera->ClearModifiers();
				pCamera->AddModifier(m_lstModifierClasses[m_nCurrentSelectedModifier]->GetClassName());
			}

		// Previous post process effect
		} else if (cControl.GetName() == "KeyboardPageDown") {
			// Get the currently used camera
			SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera());
			if (pCamera) {
				// Decrease the current selected modifier index
				if (m_nCurrentSelectedModifier)
					m_nCurrentSelectedModifier--;
				else
					m_nCurrentSelectedModifier = m_lstModifierClasses.GetNumOfElements()-1;

				// Remove all old modifiers add the new one
				pCamera->ClearModifiers();
				pCamera->AddModifier(m_lstModifierClasses[m_nCurrentSelectedModifier]->GetClassName());
			}

		// Custom post process effect: "Rainbow"
		} else if (cControl.GetName() == "Keyboard1") {
			// Get the currently used camera
			SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera());
			if (pCamera) {
				// Remove all old modifiers add the new one
				pCamera->ClearModifiers();
				pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessCrazyBars", "ColorScaleY=\"0.002\"");
			}

		// Custom post process effect: "Cartoon"
		} else if (cControl.GetName() == "Keyboard2") {
			// Get the currently used camera
			SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera());
			if (pCamera) {
				// Remove all old modifiers add the new ones
				pCamera->ClearModifiers();
				pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessEdgeDetect", "LuminanceConvert=\"-0.2125 -0.7154 -0.0721\"");
				pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessCombineMultiplicate");
			}

		// Custom post process effect: "Animated cartoon"
		} else if (cControl.GetName() == "Keyboard3") {
			// Get the currently used camera
			SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera());
			if (pCamera) {
				// Remove all old modifiers add the new ones
				pCamera->ClearModifiers();
				pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessEdgeDetect", "LuminanceConvert=\"-0.2125 -0.7154 -0.0721\"");
				pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessOldFilm");
//.........这里部分代码省略.........
开发者ID:Tank-D,项目名称:potential-octo-dubstep,代码行数:101,代码来源:Application65.cpp


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