Exemple #1
0
MainWindow::MainWindow(std::unique_ptr<BootParameters> boot_parameters) : QMainWindow(nullptr)
{
  setWindowTitle(QString::fromStdString(Common::scm_rev_str));
  setWindowIcon(Resources::GetAppIcon());
  setUnifiedTitleAndToolBarOnMac(true);
  setAcceptDrops(true);

  InitControllers();

  CreateComponents();

  ConnectGameList();
  ConnectHost();
  ConnectToolBar();
  ConnectRenderWidget();
  ConnectStack();
  ConnectMenuBar();
  ConnectHotkeys();

  InitCoreCallbacks();

  NetPlayInit();

  if (boot_parameters)
    StartGame(std::move(boot_parameters));
}
Exemple #2
0
MainWindow::MainWindow() : QMainWindow(nullptr)
{
  setWindowTitle(QString::fromStdString(scm_rev_str));
  setWindowIcon(QIcon(Resources::GetMisc(Resources::LOGO_SMALL)));
  setUnifiedTitleAndToolBarOnMac(true);
  setAcceptDrops(true);

  CreateComponents();

  ConnectGameList();
  ConnectToolBar();
  ConnectRenderWidget();
  ConnectStack();
  ConnectMenuBar();

  InitControllers();
  InitCoreCallbacks();
}
Exemple #3
0
 void CSimulator::Init() {
    /* General configuration */
    InitFramework(GetNode(m_tConfigurationRoot, "framework"));
    /* Initialize controllers */
    InitControllers(GetNode(m_tConfigurationRoot, "controllers"));
    /* Create loop functions */
    if(NodeExists(m_tConfigurationRoot, "loop_functions")) {
       /* User specified a loop_functions section in the XML */
       InitLoopFunctions(GetNode(m_tConfigurationRoot, "loop_functions"));
    }
    else {
       /* No loop_functions in the XML */
       m_pcLoopFunctions = new CLoopFunctions;
    }
    /* Physics engines */
    InitPhysics(GetNode(m_tConfigurationRoot, "physics_engines"));
    /* Media */
    InitMedia(GetNode(m_tConfigurationRoot, "media"));
    /* Space */
    InitSpace(GetNode(m_tConfigurationRoot, "arena"));
    /* Call user init function */
    if(NodeExists(m_tConfigurationRoot, "loop_functions")) {
       m_pcLoopFunctions->Init(GetNode(m_tConfigurationRoot, "loop_functions"));
    }
    /* Physics engines */
    InitPhysics2();
    /* Media */
    InitMedia2();
    /* Initialise visualization */
    TConfigurationNodeIterator itVisualization;
    if(NodeExists(m_tConfigurationRoot, "visualization") &&
       ((itVisualization = itVisualization.begin(&GetNode(m_tConfigurationRoot, "visualization"))) != itVisualization.end())) {
       InitVisualization(GetNode(m_tConfigurationRoot, "visualization"));
    }
    else {
       LOG << "[INFO] No visualization selected." << std::endl;
       m_pcVisualization = new CDefaultVisualization();
    }
    /* Start profiling, if needed */
    if(IsProfiling()) {
       m_pcProfiler->Start();
    }
 }
Exemple #4
0
// -------------------------------------------------------------------
// Init
// -------------------------------------------------------------------
void BitSwarmClient::Init()
{
	if (dispatcher == NULL) 
	{
		dispatcher = boost::shared_ptr<EventDispatcher>(new EventDispatcher(shared_from_this()));
	}

	// Do it once
	if (!controllersInited)	
	{
		InitControllers();
		controllersInited = true;
	}


	if (socket != NULL) return; // Don't init the socket layer if it's already initialized
		
	socket = boost::shared_ptr<ISocketLayer>(new TCPSocketLayer(shared_from_this()));

	boost::shared_ptr<ConnectionDelegate> delegateConnection (new ConnectionDelegate(&BitSwarmClient::OnSocketConnect, (unsigned long long)this));
	socket->OnConnect(delegateConnection);

	boost::shared_ptr<ConnectionDelegate> delegateDisconnection (new ConnectionDelegate(&BitSwarmClient::OnSocketClose, (unsigned long long)this));
	socket->OnDisconnect(delegateDisconnection);

	boost::shared_ptr<OnDataDelegate> delegateOnData (new OnDataDelegate(&BitSwarmClient::OnSocketData, (unsigned long long)this));
	socket->OnData(delegateOnData);

	boost::shared_ptr<OnErrorDelegate> delegateOnError (new OnErrorDelegate(&BitSwarmClient::OnSocketError, (unsigned long long)this));
	socket->OnError(delegateOnError); 

	bbClient = boost::shared_ptr<BBClient>(new BBClient(shared_from_this()));
	bbClient->Initialize();

	bbClient->AddEventListener(BBEvent::CONNECT, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(&BitSwarmClient::OnBBConnect, (unsigned long long)this)));
	bbClient->AddEventListener(BBEvent::DATA, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(&BitSwarmClient::OnBBData, (unsigned long long)this)));
	bbClient->AddEventListener(BBEvent::DISCONNECT, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(&BitSwarmClient::OnBBDisconnect, (unsigned long long)this)));
	bbClient->AddEventListener(BBEvent::IO_ERROR, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(&BitSwarmClient::OnBBError, (unsigned long long)this)));
	bbClient->AddEventListener(BBEvent::SECURITY_ERROR, boost::shared_ptr<EventListenerDelegate> (new EventListenerDelegate(&BitSwarmClient::OnBBError, (unsigned long long)this)));

	threadManager->Start();
}
Exemple #5
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
  PAINTSTRUCT ps;


  switch(uMsg) 
  {
  case WM_COMMAND:
	  {
		  // load new model here
		  unsigned int id = LOWORD(wParam);
			if( id > 500 && (int)(id - 500) <= g_iNumModels ) 
			{
			  int index = id - 501;
			  strcpy(g_szHandFileName,g_szModelFileNames[index]);

				FreeControllers();
				HRESULT rval = InitControllers();
			  if (FAILED(rval))
			  {
					if( ERR_FILENOTFOUND != rval )	// annunciated by InitControllers()
				    DisplayErrorCode(rval);
					exit(rval);
			  }
			}
	  }
	  break;
    case WM_ACTIVATE:
      break;

    case WM_ACTIVATEAPP:
      g_bActive = wParam;
      break;

    case WM_PAINT:
      BeginPaint(hWnd, &ps);
      EndPaint(hWnd, &ps);
      break;

    case WM_CLOSE:
			PostQuitMessage( 0 );
			return 0;

    case WM_KEYDOWN:
      switch( wParam )
      {
        case VK_ESCAPE:
          PostQuitMessage( 0 );
        break;

      }
      break;


    default:
      break;
  }

	// grab keypresses for the keyboardcontrol
	if (WM_CHAR == uMsg)
  {
    TCHAR chCharCode = (TCHAR) wParam;
    if (!g_pKeyboardControl->HandleKey(chCharCode))
    {
      if (TCHAR(' ') == chCharCode)
      {
				//toggle full screen mode
				uMsg = WM_COMMAND;
				wParam = IDM_TOGGLEFULLSCREEN;
      }
      else if (TCHAR('z') == chCharCode)
      {
				//toggle full screen mode
				uMsg = WM_MOUSEWHEEL;
				wParam = MAKEWPARAM( 0, ZOOM_DELTA );
      }
      else if (TCHAR('x') == chCharCode)
      {
				//toggle full screen mode
				uMsg = WM_MOUSEWHEEL;
				wParam = MAKEWPARAM( 0, -ZOOM_DELTA );
      }
    }
  }


  // then allow the engine its chance to handle messages (like WM_SIZE)
  if (g_pEngine)
  {
    g_pEngine->HandleMessage(hWnd, uMsg, wParam, lParam);
  }
  
  return DefWindowProc(hWnd, uMsg, wParam, lParam); 

}
Exemple #6
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
  MSG    msg;
  HRESULT rval;

  rval = InitInstance(hInstance, lpCmdLine, nCmdShow, SCREEN_WIDTH, SCREEN_HEIGHT);
  if (rval != S_OK)
  {
		if( ERR_FILENOTFOUND != rval )	// annunciated by InitInstance
	    DisplayErrorCode(rval);
    exit(rval);
  }

  // create the core engine
  g_pEngine = new (_NORMAL_BLOCK, __FILE__, __LINE__)C3DEngine;
  rval = g_pEngine->Init(g_hWnd, g_hInstance, g_szAppName);
  if (rval)
  {
    DisplayErrorCode(rval);
    exit(rval);
  }  

	// initialize controllers
	rval = InitControllers();
  if (rval)
  {
    DisplayErrorCode(rval);
    exit(rval);
  }

  // create a room object
  g_pRoomObject = new C3DFrameObject;
  rval = g_pRoomObject->Init(g_pEngine, g_szRoomFileName );
  if (rval)
  {
    DisplayErrorCode(rval);
    exit(rval);
  }

	// scale it
	D3DXMATRIX mScale, mIdentity;
	D3DXMatrixIdentity( &mIdentity );
	D3DXMatrixScaling( &mScale, g_fRoomScale, g_fRoomScale, g_fRoomScale );
	g_pRoomObject->SetMatrices( &mIdentity, &mScale );

  // add it to our world
  rval = g_pEngine->AddChild(g_pRoomObject);
  if (rval)
  {
    DisplayErrorCode(rval);
    exit(rval);
  }

	// message pump
  do
  {
    if (PeekMessage(&msg, g_hWnd, 0, 0,PM_REMOVE))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    else
    {

      // idle tasks here...

			// This is where the glove can change values
		  // Read the current values
		  float x = g_pKeyboardControl->GetRawValue("HandX");
		  float y = g_pKeyboardControl->GetRawValue("HandY");
		  float z = g_pKeyboardControl->GetRawValue("HandZ");
		  float yaw = g_pKeyboardControl->GetRawValue("HandYaw");
		  float pitch = g_pKeyboardControl->GetRawValue("HandPitch");
		  float roll = g_pKeyboardControl->GetRawValue("HandRoll");
		  float thumb = g_pKeyboardControl->GetRawValue("ThumbCurl");
		  float index = g_pKeyboardControl->GetRawValue("IndexCurl1");
		  float middle = g_pKeyboardControl->GetRawValue("MiddleCurl1");
		  float ring = g_pKeyboardControl->GetRawValue("RingCurl1");
		  float pinky = g_pKeyboardControl->GetRawValue("PinkyCurl1");
		 
		  // Allow Glove to change values
		  ReadGloveValues(x,y,z,yaw,pitch,roll,thumb,index,middle,ring,pinky);
		 
		  // Write the changes back to the keyboard control
		  g_pKeyboardControl->SetRawValue("HandX",x);
		  g_pKeyboardControl->SetRawValue("HandY",y);
		  g_pKeyboardControl->SetRawValue("HandZ",z);
		  g_pKeyboardControl->SetRawValue("HandYaw",yaw);
		  g_pKeyboardControl->SetRawValue("HandPitch",pitch);
		  g_pKeyboardControl->SetRawValue("HandRoll",roll);
		  g_pKeyboardControl->SetRawValue("ThumbCurl",thumb);
		  g_pKeyboardControl->SetRawValue("ThumbCurl2",thumb);
		  g_pKeyboardControl->SetRawValue("IndexCurl1",index);
		  g_pKeyboardControl->SetRawValue("IndexCurl2",index);
		  g_pKeyboardControl->SetRawValue("IndexCurl3",index);
		  g_pKeyboardControl->SetRawValue("MiddleCurl1",middle);
		  g_pKeyboardControl->SetRawValue("MiddleCurl2",middle);
		  g_pKeyboardControl->SetRawValue("MiddleCurl3",middle);
		  g_pKeyboardControl->SetRawValue("RingCurl1",ring);
		  g_pKeyboardControl->SetRawValue("RingCurl2",ring);
		  g_pKeyboardControl->SetRawValue("RingCurl3",ring);
		  g_pKeyboardControl->SetRawValue("PinkyCurl1",pinky);
		  g_pKeyboardControl->SetRawValue("PinkyCurl2",pinky);
		  g_pKeyboardControl->SetRawValue("PinkyCurl3",pinky);

			// render the scene
			g_pEngine->Render();

      // show the back surface
      g_pEngine->Flip();
    }

  } while (msg.message != WM_QUIT);

	// clean up
	delete g_pKeyboardControl;
	
  // destroy and delete the engine
  g_pEngine->Destroy();
  delete g_pEngine;
  g_pEngine = NULL;

	for(int n=0; n<g_iNumModels; n++)
	{
		delete g_szMenuModelNames[n];
		delete g_szModelFileNames[n];
	}
  return 0;
}