Beispiel #1
0
 inline virtual void consumeEvent(const ui::Event& ev)
 {
     switch (ev.type)
     {
     case ui::MOUSE_PRESSED_EVENT:
         std::cerr << "Mouse pressed at " <<
                   ev.mouseButtonPos().toString() << std::endl;
         break;
     case ui::MOUSE_RELEASED_EVENT:
         std::cerr << "Mouse relesed at " <<
                   ev.mouseButtonPos().toString() << std::endl;
         break;
     case ui::MOUSE_MOTION_EVENT:
         std::cerr << "Mouse moved from " <<
                   ev.mouseMotionFromPos().toString() <<
                   " to " <<
                   ev.mouseMotionToPos().toString() << std::endl;
         break;
     case ui::KEY_PRESSED_EVENT:
         std::cerr << "Key pressed: " << ev.key.unicode << std::endl;
     case ui::KEY_RELEASED_EVENT:
         std::cerr << "Key released: " << ev.key.unicode << std::endl;
         if (ev.key.unicode == ui::KeyEvent::SCAPE_KEY)
             engine->stopLoop();
     default:
         break;
     }
 }
Beispiel #2
0
UI::EventReturn SaveSlotView::OnSaveState(UI::EventParams &e) {
	g_Config.iCurrentStateSlot = slot_;
	SaveState::SaveSlot(gamePath_, slot_, &AfterSaveStateAction);
	UI::EventParams e2{};
	e2.v = this;
	OnStateSaved.Trigger(e2);
	return UI::EVENT_DONE;
}
Beispiel #3
0
UI::EventReturn SaveSlotView::OnSaveState(UI::EventParams &e) {
	g_Config.iCurrentStateSlot = slot_;
	SaveState::SaveSlot(slot_, SaveState::Callback(), 0);
	UI::EventParams e2;
	e2.v = this;
	OnStateSaved.Trigger(e2);
	return UI::EVENT_DONE;
}
Beispiel #4
0
UI::EventReturn ProductView::OnLaunchClick(UI::EventParams &e) {
	std::string pspGame = GetSysDirectory(DIRECTORY_GAME);
	std::string path = pspGame + entry_.file;
#ifdef _WIN32
	path = ReplaceAll(path, "\\", "/");
#endif

	UI::EventParams e2;
	e2.s = path;
	// Insta-update - here we know we are already on the right thread.
	OnClickLaunch.Trigger(e2);
	return UI::EVENT_DONE;
}
Beispiel #5
0
UI::EventReturn ProductView::OnLaunchClick(UI::EventParams &e) {
	if (g_GameManager.GetState() != GameManagerState::IDLE) {
		// Button should have been disabled. Just a safety check.
		return UI::EVENT_DONE;
	}

	std::string pspGame = GetSysDirectory(DIRECTORY_GAME);
	std::string path = pspGame + entry_.file;
#ifdef _WIN32
	path = ReplaceAll(path, "\\", "/");
#endif
	UI::EventParams e2{};
	e2.v = e.v;
	e2.s = path;
	// Insta-update - here we know we are already on the right thread.
	OnClickLaunch.Trigger(e2);
	return UI::EVENT_DONE;
}
Beispiel #6
0
UI::EventReturn SaveSlotView::OnScreenshotClick(UI::EventParams &e) {
	UI::EventParams e2{};
	e2.v = this;
	OnScreenshotClicked.Trigger(e2);
	return UI::EVENT_DONE;
}
Beispiel #7
0
bool CManipRot::UIEventHandler( const ui::Event& EV )
{	
	int ex = EV.miX;
	int ey = EV.miY;
	
	CVector2 posubp = EV.GetUnitCoordBP();

	CCamera *pcam = mManager.GetActiveCamera();
	
	bool brval = false;
			
	bool isshift = false; //CSystem::IsKeyDepressed(VK_SHIFT );
	bool isctrl = false; //CSystem::IsKeyDepressed(VK_CONTROL );
	
	switch( EV.miEventCode )
	{
		case ui::UIEV_PUSH:
		{	
			mManager.mManipHandler.Init(posubp, pcam->mCameraData.GetIVPMatrix(), pcam->QuatC );
			mBaseTransform = mManager.mCurTransform;

			SelectBestPlane(posubp);

			brval = true;
		}
		break;

		case ui::UIEV_RELEASE:
		{
			mManager.DisableManip();

			brval = true;
		}
		break;

		case ui::UIEV_DRAG:
		{
			IntersectWithPlanes( posubp );

			if ( CheckIntersect() )
			{	
				///////////////////////////////////////////
				// calc normalvectors from base:origin to point on activeintersection plane (in world space)
				const CVector3 & Origin = mBaseTransform.GetTransform().GetPosition();
				CVector3 D1 = (Origin-mActiveIntersection->mIntersectionPoint).Normal();
				CVector3 D0 = (Origin-mActiveIntersection->mBaseIntersectionPoint).Normal();
				///////////////////////////////////////////
				// calc matrix to put worldspace vector into plane local space
				CMatrix4 MatWldToObj = mBaseTransform.GetTransform().GetMatrix(); //GetRotation();
				MatWldToObj.Inverse();
				CVector4 bAxisAngle = mLocalRotationAxis; 
				CQuaternion brq;
				brq.FromAxisAngle(bAxisAngle);
				CMatrix4 MatObjToPln = brq.ToMatrix();
				MatObjToPln.Inverse();
				CMatrix4 MatWldToPln = MatObjToPln*MatWldToObj;
				//CMatrix4 MatInvRot = InvQuat.ToMatrix();
				///////////////////////////////////////////
				// calc plane local rotation
				CVector4 AxisAngle = mLocalRotationAxis; 
				CVector4 D0I = CVector4(D0,CReal(0.0f)).Transform(MatWldToPln);
				CVector4 D1I = CVector4(D1,CReal(0.0f)).Transform(MatWldToPln);
				//orkprintf( "D0 <%f %f %f>\n", float(D0.GetX()), float(D0.GetY()), float(D0.GetZ()) );
				//orkprintf( "D1 <%f %f %f>\n", float(D1.GetX()), float(D1.GetY()), float(D1.GetZ()) );
				//orkprintf( "D0I <%f %f %f>\n", float(D0I.GetX()), float(D0I.GetY()), float(D0I.GetZ()) );
				//orkprintf( "D1I <%f %f %f>\n", float(D1I.GetX()), float(D1I.GetY()), float(D1I.GetZ()) );
				AxisAngle.SetW( CalcAngle(D0I,D1I) );
				CQuaternion RotQ;
				RotQ.FromAxisAngle( AxisAngle );
				///////////////////
				// Rot Snap
				if( isshift )
				{	CReal SnapAngleVal( PI2/16.0f );
					CVector4 NewAxisAngle = RotQ.ToAxisAngle();
					CReal Angle = NewAxisAngle.GetW();
					Angle = SnapReal( Angle, SnapAngleVal );
					NewAxisAngle.SetW( Angle );
					RotQ.FromAxisAngle( NewAxisAngle );
				}
				///////////////////
				// accum rotation
				CQuaternion oq = mBaseTransform.GetTransform().GetRotation();
				CQuaternion NewQ = RotQ.Multiply(oq);
				///////////////////
				// Rot Reset To Identity
				if( isctrl && isshift )
				{
					NewQ.FromAxisAngle( CVector4( CReal(0.0f), CReal(1.0f), CReal(0.0f), CReal(0.0f) ) );
				}
				///////////////////
				TransformNode mset = mManager.mCurTransform;
				mset.GetTransform().SetRotation( NewQ );
				mManager.ApplyTransform( mset );
				///////////////////
			}

			brval = true;
		}
		break;

		default:
			break;
	}

	return brval;
}