/*
 * Show snapshot select UI
 */
void Engine::ShowSnapshotSelectUI() {
  service_->Snapshots().ShowSelectUIOperation(
      ALLOW_CREATE_SNAPSHOT_INUI,
      ALLOW_DELETE_SNAPSHOT_INUI,
      MAX_SNAPSHOTS,
      SNAPSHOT_UI_TITLE,
      [this](gpg::SnapshotManager::SnapshotSelectUIResponse const & response) {
    LOGI("Snapshot selected");
    if (IsSuccess(response.status)) {
      if (response.data.Valid()) {
        LOGI("Description: %s", response.data.Description().c_str());
        LOGI("FileName %s", response.data.FileName().c_str());

        //Opening the snapshot data
        current_snapshot_ = response.data;
        LoadFromSnapshot();
      } else {
        LOGI("Creating new snapshot");
        SaveSnapshot();
      }
    } else {
      LOGI("ShowSelectUIOperation returns an error %d", response.status);
      EnableUI(true);
    }
  });
}
예제 #2
0
//-----------------------------------------------------------------------------
// Name: OneTimeSceneInit()
// Desc: Called during initial app startup, this function performs all the
//       permanent initialization.
//-----------------------------------------------------------------------------
HRESULT CMyApplication::OneTimeSceneInit()
{
    HRESULT hr;
    
    // Load the icon
    HICON hIcon = LoadIcon( GetModuleHandle(NULL), MAKEINTRESOURCE( IDI_MAIN ) );
    
    // Set the icon for this dialog.
    SendMessage( m_hWnd, WM_SETICON, ICON_BIG,   (LPARAM) hIcon );  // Set big icon
    SendMessage( m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hIcon );  // Set small icon
    
    // Initialize DirectInput
    if( FAILED( hr = InitInput() ) )
        return DXTRACE_ERR( TEXT("InitInput"), hr );
    
    HWND hNumPlayers = GetDlgItem( m_hWnd, IDC_NUM_PLAYERS_COMBO );
    SendMessage( hNumPlayers, CB_ADDSTRING, 0, (LPARAM) TEXT("1") );
    SendMessage( hNumPlayers, CB_ADDSTRING, 0, (LPARAM) TEXT("2") );
    SendMessage( hNumPlayers, CB_ADDSTRING, 0, (LPARAM) TEXT("3") );
    SendMessage( hNumPlayers, CB_ADDSTRING, 0, (LPARAM) TEXT("4") );
    SendMessage( hNumPlayers, CB_SETCURSEL, m_dwNumPlayers-1, 0 );

    EnableUI();
    
    return S_OK;
}
예제 #3
0
void MagnifyTool::InitApp( CDXUTDialogResourceManager* pResourceManager )
{
    D3DCOLOR DlgColor = 0x88888888;

    m_MagnifyUI.Init( pResourceManager );

    int iY = 0;

    m_MagnifyUI.SetBackgroundColors( DlgColor );
    m_MagnifyUI.EnableCaption( true );
    m_MagnifyUI.SetCaptionText( L"-- Magnify Tool --" );

    m_MagnifyUI.AddCheckBox( IDC_MAGNIFY_CHECKBOX_ENABLE, L"Magnify: RMouse", 5, iY, 140, 24, true );

    m_MagnifyUI.AddStatic( IDC_MAGNIFY_STATIC_PIXEL_REGION, L"Pixel Region : 128", 5, iY += 25, 90, 24 );
    m_MagnifyUI.AddSlider( IDC_MAGNIFY_SLIDER_PIXEL_REGION, 15, iY += 25, 140, 24, 16, 256, 128, false );

    m_MagnifyUI.AddStatic( IDC_MAGNIFY_STATIC_SCALE, L"Scale : 5", 5, iY += 25, 50, 24 );
    m_MagnifyUI.AddSlider( IDC_MAGNIFY_SLIDER_SCALE, 15, iY += 25, 140, 24, 2, 10, 5, false );

    m_MagnifyUI.AddCheckBox( IDC_MAGNIFY_CHECKBOX_DEPTH, L"View Depth", 5, iY += 25, 140, 24, false );

    m_MagnifyUI.AddStatic( IDC_MAGNIFY_STATIC_DEPTH_MIN, L"Depth Min : 0.0f", 5, iY += 25, 90, 24 );
    m_MagnifyUI.AddSlider( IDC_MAGNIFY_SLIDER_DEPTH_MIN, 15, iY += 25, 140, 24, 0, 100, 0, false );

    m_MagnifyUI.AddStatic( IDC_MAGNIFY_STATIC_DEPTH_MAX, L"Depth Max : 1.0f", 5, iY += 25, 90, 24 );
    m_MagnifyUI.AddSlider( IDC_MAGNIFY_SLIDER_DEPTH_MAX, 15, iY += 25, 140, 24, 0, 100, 100, false );

    m_MagnifyUI.AddCheckBox( IDC_MAGNIFY_CHECKBOX_SUB_SAMPLES, L"Subsamples: MWheel", 5, iY += 25, 140, 24, false );

    EnableTool();
    EnableUI();
}
/*
 * Claim quest milestone
 */
void Engine::ClaimMilestone(gpg::QuestMilestone milestone)
{
  EnableUI(false);
  service_->Quests().ClaimMilestone(milestone, [this,milestone](gpg::QuestManager::ClaimMilestoneResponse milestoneResponse){
    if( gpg::IsSuccess(milestoneResponse.status) )
    {
      LOGI("Claiming reward");
      auto begin = milestone.CompletionRewardData().begin();
      auto end = milestone.CompletionRewardData().end();
      std::string reward = "You got " + std::string(begin, end);
      ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([reward]() {
        jui_helper::JUIToast toast(reward.c_str());
        toast.Show();
      });
    }
    EnableUI(true);
  });
}
/*
 * Load snapshot data
 */
void Engine::LoadFromSnapshot() {
  if (!current_snapshot_.Valid()) {
    LOGI("Snapshot is not valid!");
    EnableUI(true);
    return;
  }
  LOGI("Opening file");
  service_->Snapshots()
      .Open(current_snapshot_.FileName(),
            gpg::SnapshotConflictPolicy::MANUAL,
            [this](gpg::SnapshotManager::OpenResponse const & response) {
    LOGI("Opened file");
    if (IsSuccess(response.status)) {
      //Do need conflict resolution?
      if (response.data.Valid() == false) {
        if (response.conflict_id != "") {
          LOGI("Need conflict resolution");
          bool b = ResolveConflicts(response, 0);
          if (!b) {
            LOGI("Failed resolving conflicts");
            EnableUI(true);
            return;
          }
        } else {
          EnableUI(true);
          return;
        }
      }

      LOGI("Reading file");
      gpg::SnapshotManager::ReadResponse responseRead =
          service_->Snapshots().ReadBlocking(response.data);
      if (IsSuccess(responseRead.status)) {
        LOGI("Parsing data");
        ParseSnapshotData(responseRead.data);
        ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this]() {
          UpdateGameUI();
        });
      }
    }

    EnableUI(true);
  });
}
/*
 * Show quest UI
 */
void Engine::ShowQuestUI() {
  EnableUI(false);
  service_->Quests().ShowAllUI([this](
      gpg::QuestManager::QuestUIResponse const & response) {
    if (IsSuccess(response.status)) {
      if (response.accepted_quest.Valid())
      {
        LOGI("Accepted a quest");
        EnableUI(true);
      }
      if (response.milestone_to_claim.Valid())
      {
        LOGI("Claimed a milestone");
        ClaimMilestone(response.milestone_to_claim);
      }
    } else {
      LOGI("Invalid response status");
      EnableUI(true);
    }
  });
}
예제 #7
0
BOOL CDlgMotorMontior::OnInitDialog() 
{
	CDialog::OnInitDialog();

	m.Info.bSubDlgOpen = true;
	f.UpdateButtonState();

	// init button 
	m_btnOK.SetIcon(IDI_OK);;
	m_btnOK.SetAlign(CButtonST::ST_ALIGN_VERT);;
	m_btnOK.SetFlat(FALSE);
	
	m_btnCancel.SetIcon(IDI_CANCEL);
	m_btnCancel.SetAlign(CButtonST::ST_ALIGN_VERT);
	m_btnCancel.SetFlat(FALSE);

	m_btnModify.SetIcon(IDI_SAVE);
	m_btnModify.SetAlign(CButtonST::ST_ALIGN_VERT);
	m_btnModify.SetFlat(FALSE);

	m_btnTorque.SetIcon(IDI_MANUAL_TORQUE);
	m_btnTorque.SetAlign(CButtonST::ST_ALIGN_VERT);
	m_btnTorque.SetFlat(FALSE);

	m_bStop = false; 

	// Init Led 
	InitLed();

	// Init UI
	EnableUI();

	// Pre Select Motor
	OnSelect();

	// Set Timer for get Motor Status
	SetTimer(ID_TIME_GET_STATUS, _Status_Timer, NULL);

	// Pre set default value for each wnd
	UpdateData(FALSE);

	//
	f.SetTitleExtend(this, theApp.enTtileMachineFile );

	//
	f.ChangeLanguage(GetSafeHwnd());
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
/*
 * Callback: Authentication started
 */
void Engine::OnAuthActionStarted(gpg::AuthOperation op) {
  ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this, op]() {
    EnableUI(false);
    authorizing_ = true;
    if (status_text_) {
      if (op == gpg::AuthOperation::SIGN_IN) {
        LOGI("Signing in to GPG");
        status_text_->SetAttribute("Text", "Signing In...");
      } else {
        LOGI("Signing out from GPG");
        status_text_->SetAttribute("Text", "Signing Out...");
      }
    }
  });
}
/*
 * Callback: Authentication finishes
 */
void Engine::OnAuthActionFinished(gpg::AuthOperation op,
                                  gpg::AuthStatus status) {
  ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this, status]() {
    EnableUI(true);
    authorizing_ = false;
    if (button_sign_in_) {
      button_sign_in_->SetAttribute(
          "Text", gpg::IsSuccess(status) ? "Sign Out" : "Sign In");
    }

    if (status_text_) {
      status_text_->SetAttribute(
          "Text",
          gpg::IsSuccess(status) ? "Signed In" : "Signed Out");
    }
  });
}
예제 #10
0
//-----------------------------------------------------------------------------
// Name: ConfigInput()
// Desc: 
//-----------------------------------------------------------------------------
VOID CMyApplication::ConfigInput()
{
    HRESULT hr;
    
    EnableWindow( m_hWnd, FALSE );

    CleanupDeviceStateStructs();
    
    // Update UI
    EnableUI();    
    SendMessage( GetDlgItem(m_hWnd,IDC_DEVICE_ASSIGNED_P1), LB_RESETCONTENT, 0, 0 );
    SendMessage( GetDlgItem(m_hWnd,IDC_DEVICE_ASSIGNED_P2), LB_RESETCONTENT, 0, 0 );
    SendMessage( GetDlgItem(m_hWnd,IDC_DEVICE_ASSIGNED_P3), LB_RESETCONTENT, 0, 0 );
    SendMessage( GetDlgItem(m_hWnd,IDC_DEVICE_ASSIGNED_P4), LB_RESETCONTENT, 0, 0 );
    
    // Configure the devices (with edit capability)
    hr = m_pInputDeviceManager->ConfigureDevices( m_hWnd, NULL, NULL, DICD_EDIT, NULL );    
    if( FAILED(hr) )
    {
        if( hr == E_DIUTILERR_PLAYERWITHOUTDEVICE )
        {
            // There's a player that hasn't been assigned a device.  Some games may
            // want to handle this by reducing the number of players, or auto-assigning
            // a device, or warning the user, etc.
            MessageBox( m_hWnd, TEXT("There is at least one player that wasn't assigned ") \
                                TEXT("a device\n") \
                                TEXT("Press OK to auto-assign a device to these users"), 
                                TEXT("Player Without Device"), MB_OK | MB_ICONEXCLAMATION );
        }

        // Auto-reassign every player a device.
        ChangeNumPlayers( m_dwNumPlayers, FALSE, FALSE );
    }

    EnableWindow( m_hWnd, TRUE );
    SetForegroundWindow( m_hWnd );
}
/*
 * Initialize main sample UI,
 * invoking jui_helper functions to create java UIs
 */
void Engine::InitUI() {
  const int32_t buttonWidth = 600;
    // Show toast with app label
  ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([]() {
    jui_helper::JUIToast toast(
        ndk_helper::JNIHelper::GetInstance()->GetAppLabel());
    toast.Show();
  });

  // The window initialization
  jui_helper::JUIWindow::Init(app_->activity, JUIHELPER_CLASS_NAME);

  //
  // Setup Buttons
  //
  status_text_ = new jui_helper::JUITextView(
      service_->IsAuthorized() ? "Signed In." : "Signed Out.");

  status_text_->AddRule(jui_helper::LAYOUT_PARAMETER_ALIGN_PARENT_BOTTOM,
                        jui_helper::LAYOUT_PARAMETER_TRUE);
  status_text_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                        jui_helper::LAYOUT_PARAMETER_TRUE);

  // Sign in button.
  button_sign_in_ = new jui_helper::JUIButton(
      service_->IsAuthorized() ? "Sign Out" : "Sign In");
  button_sign_in_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                           jui_helper::LAYOUT_PARAMETER_TRUE);
  button_sign_in_->AddRule(jui_helper::LAYOUT_PARAMETER_ABOVE, status_text_);
  button_sign_in_->SetCallback(
      [this](jui_helper::JUIView * view, const int32_t message) {
    if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
      if (service_->IsAuthorized()) {
        service_->SignOut();
      } else {
        service_->StartAuthorizationUI();
      }
    }
  });
  button_sign_in_->SetAttribute("MinimumWidth", buttonWidth);
  button_sign_in_->SetMargins(0, 50, 0, 0);

  button_quests_ = new jui_helper::JUIButton("Show quests");
  button_quests_->AddRule(jui_helper::LAYOUT_PARAMETER_ABOVE, button_sign_in_);
  button_quests_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                           jui_helper::LAYOUT_PARAMETER_TRUE);
  button_quests_->SetAttribute("MinimumWidth", buttonWidth);
  button_quests_->SetCallback(
      [this](jui_helper::JUIView * view, const int32_t message) {
    if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
      ShowQuestUI();
    }
  });

  button_events_ = new jui_helper::JUIButton("Show event status");
  button_events_->AddRule(jui_helper::LAYOUT_PARAMETER_ABOVE,
                          button_quests_);
  button_events_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                          jui_helper::LAYOUT_PARAMETER_TRUE);
  button_events_->SetAttribute("MinimumWidth", buttonWidth);
  button_events_->SetCallback(
      [this](jui_helper::JUIView * view, const int32_t message) {
    if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
      ShowEventStatus();
    }
  });
  button_events_->SetMargins(0, 50, 0, 0);

  button_green_ = new jui_helper::JUIButton("Green event");
  button_green_->AddRule(jui_helper::LAYOUT_PARAMETER_ABOVE,
                         button_events_);
  button_green_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                               jui_helper::LAYOUT_PARAMETER_TRUE);
  button_green_->SetAttribute("MinimumWidth", buttonWidth);
  button_green_->SetCallback(
      [this](jui_helper::JUIView * view, const int32_t message) {
    if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
      std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("event_green");
      if( id == "" || id == "ReplaceMe")
      {
        LOGI("Invalid Event ID!, please check res/values/ids.xml");
        return;
      }
      service_->Events().Increment(id.c_str());
      ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([]() {
        jui_helper::JUIToast toast("Got Green event");
        toast.Show();
      });
    }
  });

  button_yellow_ = new jui_helper::JUIButton("Yellow event");
  button_yellow_->AddRule(jui_helper::LAYOUT_PARAMETER_ABOVE,
                          button_green_);
  button_yellow_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                               jui_helper::LAYOUT_PARAMETER_TRUE);
  button_yellow_->SetAttribute("MinimumWidth", buttonWidth);
  button_yellow_->SetCallback(
      [this](jui_helper::JUIView * view, const int32_t message) {
    if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
      std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("event_yellow");
      if( id == "" || id == "ReplaceMe")
      {
        LOGI("Invalid Event ID!, please check res/values/ids.xml");
        return;
      }
      service_->Events().Increment(id.c_str());
      ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([]() {
        jui_helper::JUIToast toast("Got Yellow event");
        toast.Show();
      });
    }
  });

  button_blue_ = new jui_helper::JUIButton("Blue event");
  button_blue_->AddRule(jui_helper::LAYOUT_PARAMETER_ABOVE,
                        button_yellow_);
  button_blue_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                               jui_helper::LAYOUT_PARAMETER_TRUE);
  button_blue_->SetAttribute("MinimumWidth", buttonWidth);
  button_blue_->SetCallback(
      [this](jui_helper::JUIView * view, const int32_t message) {
    if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
      std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("event_blue");
      if( id == "" || id == "ReplaceMe")
      {
        LOGI("Invalid Event ID!, please check res/values/ids.xml");
        return;
      }
      service_->Events().Increment(id.c_str());
      ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([]() {
        jui_helper::JUIToast toast("Got Blue event");
        toast.Show();
      });
    }
  });

  button_red_ = new jui_helper::JUIButton("Red event");
  button_red_->AddRule(jui_helper::LAYOUT_PARAMETER_ABOVE,
                       button_blue_);
  button_red_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                               jui_helper::LAYOUT_PARAMETER_TRUE);
  button_red_->SetAttribute("MinimumWidth", buttonWidth);
  button_red_->SetCallback(
      [this](jui_helper::JUIView * view, const int32_t message) {
    if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
      std::string id = ndk_helper::JNIHelper::GetInstance()->GetStringResource("event_red");
      if( id == "" || id == "ReplaceMe")
      {
        LOGI("Invalid Event ID!, please check res/values/ids.xml");
        return;
      }
      service_->Events().Increment(id.c_str());
      ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([]() {
        jui_helper::JUIToast toast("Got Red event");
        toast.Show();
      });
    }
  });

  //Add to screen
  jui_helper::JUIWindow::GetInstance()->AddView(button_red_);
  jui_helper::JUIWindow::GetInstance()->AddView(button_blue_);
  jui_helper::JUIWindow::GetInstance()->AddView(button_yellow_);
  jui_helper::JUIWindow::GetInstance()->AddView(button_green_);

  jui_helper::JUIWindow::GetInstance()->AddView(button_events_);
  jui_helper::JUIWindow::GetInstance()->AddView(button_quests_);
  jui_helper::JUIWindow::GetInstance()->AddView(button_sign_in_);
  jui_helper::JUIWindow::GetInstance()->AddView(status_text_);

  textViewFPS_ = new jui_helper::JUITextView("0.0FPS");
  textViewFPS_->SetAttribute("Gravity", jui_helper::ATTRIBUTE_GRAVITY_LEFT);
  textViewFPS_->SetAttribute("TextColor", 0xffffffff);
  textViewFPS_->SetAttribute("TextSize", jui_helper::ATTRIBUTE_UNIT_SP, 18.f);
  textViewFPS_->SetAttribute("Padding", 10, 10, 10, 10);
  jui_helper::JUIWindow::GetInstance()->AddView(textViewFPS_);

  if (authorizing_)
    EnableUI(false);
  return;
}
/*
 * Show current event status
 */
void Engine::ShowEventStatus()
{
  EnableUI(false);
  service_->Events().FetchAll([this](gpg::EventManager::FetchAllResponse const &response)
                              {
    if (IsSuccess(response.status))
    {
      ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([this,response]() {
        LOGI("Showing event status");
        if (dialog_)
          delete dialog_;

        dialog_ = new jui_helper::JUIDialog(app_->activity);

        std::ostringstream str;
        auto begin = response.data.begin();
        auto end = response.data.end();
        while( begin != end)
        {
          str <<begin->second.Name() << ": " << begin->second.Count() << "\n";
          begin++;
        }

        // Setting up message
        jui_helper::JUITextView* text = new jui_helper::JUITextView(
            str.str().c_str());

        text->AddRule(jui_helper::LAYOUT_PARAMETER_ALIGN_PARENT_TOP,
                              jui_helper::LAYOUT_PARAMETER_TRUE);
        text->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                              jui_helper::LAYOUT_PARAMETER_TRUE);
        text->SetAttribute("TextSize", jui_helper::ATTRIBUTE_UNIT_SP, 18.f);

        // OK Button
        jui_helper::JUIButton *button = new jui_helper::JUIButton("OK");
        button->SetCallback(
            [this](jui_helper::JUIView * view, const int32_t message) {
          switch (message) {
          case jui_helper::JUICALLBACK_BUTTON_UP: {
            dialog_->Close();
          }
          }
        });
        button->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                        jui_helper::LAYOUT_PARAMETER_TRUE);
        button->AddRule(jui_helper::LAYOUT_PARAMETER_BELOW, text);

        dialog_->SetCallback(
            jui_helper::JUICALLBACK_DIALOG_CANCELLED,
            [this](jui_helper::JUIDialog * dialog, const int32_t message) {
          LOGI("Dialog cancelled");
          dialog_->Close();
          EnableUI(true);
        });
        dialog_->SetCallback(
            jui_helper::JUICALLBACK_DIALOG_DISMISSED,
            [this](jui_helper::JUIDialog * dialog, const int32_t message) {
          LOGI("Dialog dismissed");
          dialog_->Close();
          EnableUI(true);
        });

        dialog_->SetAttribute("Title", "Event status");
        dialog_->AddView(text);
        dialog_->AddView(button);
        dialog_->Show();
        LOGI("Showing dialog");
      });

    }
    else
      EnableUI(true);
  });
}
예제 #13
0
void CDlgMotorMontior::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	EnableUI(); // re-set UI
	CDialog::OnShowWindow(bShow, nStatus);	
}
예제 #14
0
//-----------------------------------------------------------------------------
// Name: ChangeNumPlayers()
// Desc: Signals a change in the number of players. It is also called to reset
//       ownership and mapping data.
//-----------------------------------------------------------------------------
HRESULT CMyApplication::ChangeNumPlayers( DWORD dwNumPlayers, BOOL bResetOwnership, 
                                          BOOL bResetMappings )
{
    HRESULT hr;
    
    m_dwNumPlayers = dwNumPlayers;

    // Just pass in stock names.  Real games may want to ask the user for a name, etc.
    TCHAR* strUserNames[4] = { TEXT("Player 1"), TEXT("Player 2"), 
                               TEXT("Player 3"), TEXT("Player 4") };

    BOOL bSuccess = FALSE;
    while( !bSuccess )
    {
        // Update UI
        EnableUI();    
        SendMessage( GetDlgItem(m_hWnd,IDC_DEVICE_ASSIGNED_P1), LB_RESETCONTENT, 0, 0 );
        SendMessage( GetDlgItem(m_hWnd,IDC_DEVICE_ASSIGNED_P2), LB_RESETCONTENT, 0, 0 );
        SendMessage( GetDlgItem(m_hWnd,IDC_DEVICE_ASSIGNED_P3), LB_RESETCONTENT, 0, 0 );
        SendMessage( GetDlgItem(m_hWnd,IDC_DEVICE_ASSIGNED_P4), LB_RESETCONTENT, 0, 0 );
        
        hr = m_pInputDeviceManager->Create( m_hWnd, strUserNames, m_dwNumPlayers, &m_diafGame, 
                                            StaticInputAddDeviceCB, this, 
                                            bResetOwnership, bResetMappings );

        if( FAILED(hr) )
        {
            switch( hr )
            {
                case E_DIUTILERR_DEVICESTAKEN:
                {
                    // It's possible that a single user could "own" too many devices for the other
                    // players to get into the game. If so, we reinit the manager class to provide 
                    // each user with a device that has a default configuration.
                    bResetOwnership = TRUE;
                    
                    MessageBox( m_hWnd, TEXT("You have entered more users than there are suitable ")       \
                                        TEXT("devices, or some users are claiming too many devices.\n") \
                                        TEXT("Press OK to give each user a default device"), 
                                        TEXT("Devices Are Taken"), MB_OK | MB_ICONEXCLAMATION );
                    break;
                }
                    
                case E_DIUTILERR_TOOMANYUSERS:
                {
                    // Another common error is if more users are attempting to play than there are devices
                    // attached to the machine. In this case, the number of players is automatically 
                    // lowered to make playing the game possible. 
                    DWORD dwNumDevices = m_pInputDeviceManager->GetNumDevices();
                    m_dwNumPlayers = dwNumDevices;                    
                    SendMessage( GetDlgItem( m_hWnd, IDC_NUM_PLAYERS_COMBO ), 
                                 CB_SETCURSEL, m_dwNumPlayers-1, 0 );
                                
                    TCHAR sz[256];
                    wsprintf( sz, TEXT("There are not enough devices attached to the ")          \
                                  TEXT("system for the number of users you entered.\nThe ")      \
                                  TEXT("number of users has been automatically changed to ")     \
                                  TEXT("%i (the number of devices available on the system)."),
                                  m_dwNumPlayers );
                    MessageBox( m_hWnd, sz, _T("Too Many Users"), MB_OK | MB_ICONEXCLAMATION );                    
                    break;
                }

                default:
                    return DXTRACE_ERR( TEXT("m_pInputDeviceManager->Create"), hr );
                    break;
            }
            
            m_pInputDeviceManager->Cleanup();                                
        }
        else
        {
            bSuccess = TRUE;
        }
    }
    
    return S_OK;
}
/*
 * Initialize main sample UI,
 * invoking jui_helper functions to create java UIs
 */
void Engine::InitUI() {
  const int32_t buttonWidth = 600;
    // Show toast with app label
  ndk_helper::JNIHelper::GetInstance()->RunOnUiThread([]() {
    jui_helper::JUIToast toast(
        ndk_helper::JNIHelper::GetInstance()->GetAppLabel());
    toast.Show();
  });

  // The window initialization
  jui_helper::JUIWindow::Init(app_->activity, JUIHELPER_CLASS_NAME);

  //
  // Buttons
  //
  // Setting up game UI
  int32_t index = 0;
  jui_helper::JUILinearLayout *masterLayout = new jui_helper::JUILinearLayout();
  masterLayout->SetAttribute("Orientation",
                             jui_helper::LAYOUT_ORIENTATION_VERTICAL);
  masterLayout->SetAttribute("Gravity",
                             jui_helper::ATTRIBUTE_GRAVITY_CENTER_VERTICAL);
  masterLayout->SetLayoutParams(jui_helper::ATTRIBUTE_SIZE_MATCH_PARENT,
                                jui_helper::ATTRIBUTE_SIZE_WRAP_CONTENT);

  //Select stage
  jui_helper::JUILinearLayout *layout = new jui_helper::JUILinearLayout();
  layout->SetLayoutParams(jui_helper::ATTRIBUTE_SIZE_MATCH_PARENT,
                          jui_helper::ATTRIBUTE_SIZE_WRAP_CONTENT);
  layout->SetMargins(0, 50, 0, 50);
  layout->SetAttribute("Orientation",
                       jui_helper::LAYOUT_ORIENTATION_HORIZONTAL);
  layout->SetAttribute("Gravity", jui_helper::ATTRIBUTE_GRAVITY_CENTER);
  buttonLeft_ = new jui_helper::JUIButton("<<");
  buttonRight_ = new jui_helper::JUIButton(">>");
  labelWorld_ = new jui_helper::JUITextView("Stage 1");
  buttonLeft_->SetCallback(
      [this](jui_helper::JUIView * view, const int32_t message) {
    if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
      //Change game world
      if (current_world_ > 0) {
        current_world_--;
        UpdateGameUI();
      }
    }
  });
  buttonRight_->SetCallback(
      [this](jui_helper::JUIView * view, const int32_t message) {
    if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
      //Change game world
      if (current_world_ < NUM_GAME_WORLD - 1) {
        current_world_++;
        UpdateGameUI();
      }
    }
  });

  layout->AddView(buttonLeft_);
  layout->AddView(labelWorld_);
  layout->AddView(buttonRight_);
  masterLayout->AddView(layout);

  for (int32_t i = 0; i < 4; ++i) {
    button_games_[index + 0] = CreateButton(index + 0);
    button_games_[index + 1] = CreateButton(index + 1);
    button_games_[index + 2] = CreateButton(index + 2);

    //Center element
    button_games_[index + 1]
        ->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                  jui_helper::LAYOUT_PARAMETER_TRUE);
    button_games_[index + 1]->SetMargins(50, 50, 50, 50);

    jui_helper::JUILinearLayout *layout = new jui_helper::JUILinearLayout();
    layout->SetLayoutParams(jui_helper::ATTRIBUTE_SIZE_MATCH_PARENT,
                            jui_helper::ATTRIBUTE_SIZE_WRAP_CONTENT);
    layout->SetMargins(0, 50, 0, 50);
    layout->SetAttribute("Orientation",
                         jui_helper::LAYOUT_ORIENTATION_HORIZONTAL);
    layout->SetAttribute("Gravity", jui_helper::ATTRIBUTE_GRAVITY_CENTER);
    layout->AddView(button_games_[index + 0]);
    layout->AddView(button_games_[index + 1]);
    layout->AddView(button_games_[index + 2]);
    masterLayout->AddView(layout);

    index += 3;
  }
  jui_helper::JUIWindow::GetInstance()->AddView(masterLayout);

  status_text_ = new jui_helper::JUITextView(
      service_->IsAuthorized() ? "Signed In." : "Signed Out.");

  status_text_->AddRule(jui_helper::LAYOUT_PARAMETER_ALIGN_PARENT_BOTTOM,
                        jui_helper::LAYOUT_PARAMETER_TRUE);
  status_text_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                        jui_helper::LAYOUT_PARAMETER_TRUE);
  jui_helper::JUIWindow::GetInstance()->AddView(status_text_);

  // Sign in button.
  button_sign_in_ = new jui_helper::JUIButton(
      service_->IsAuthorized() ? "Sign Out" : "Sign In");
  button_sign_in_->AddRule(jui_helper::LAYOUT_PARAMETER_ABOVE, status_text_);
  button_sign_in_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                           jui_helper::LAYOUT_PARAMETER_TRUE);
  button_sign_in_->SetCallback(
      [this](jui_helper::JUIView * view, const int32_t message) {
    LOGI("button_sign_in_ click: %d", message);
    if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
      if (service_->IsAuthorized()) {
        service_->SignOut();
      } else {
        service_->StartAuthorizationUI();
      }
    }
  });
  button_sign_in_->SetAttribute("MinimumWidth", buttonWidth);
  button_sign_in_->SetMargins(0, 50, 0, 0);

  // Select button.
  button_select_ = new jui_helper::JUIButton("Select");
  button_select_->AddRule(jui_helper::LAYOUT_PARAMETER_ABOVE, button_sign_in_);
  button_select_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                          jui_helper::LAYOUT_PARAMETER_TRUE);
  button_select_->SetCallback(
      [this](jui_helper::JUIView * view, const int32_t message) {
    LOGI("button_select_ click: %d", message);
    if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
      EnableUI(false);
      ShowSnapshotSelectUI();
    }
  });
  button_select_->SetAttribute("MinimumWidth", buttonWidth);

  // Save button.
  button_save_ = new jui_helper::JUIButton("Save");
  button_save_->AddRule(jui_helper::LAYOUT_PARAMETER_ABOVE, button_select_);
  button_save_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                        jui_helper::LAYOUT_PARAMETER_TRUE);
  button_save_->SetCallback(
      [this](jui_helper::JUIView * view, const int32_t message) {
    LOGI("button_save_ click: %d", message);
    if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
      //Save snapshot
      SaveSnapshot();
    }
  });
  button_save_->SetAttribute("MinimumWidth", buttonWidth);

  // Load button.
  button_load_ = new jui_helper::JUIButton("Load");
  button_load_->AddRule(jui_helper::LAYOUT_PARAMETER_ABOVE, button_save_);
  button_load_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                        jui_helper::LAYOUT_PARAMETER_TRUE);
  button_load_->SetCallback(
      [this](jui_helper::JUIView * view, const int32_t message) {
    LOGI("button_load_ click: %d", message);
    if (message == jui_helper::JUICALLBACK_BUTTON_UP) {
      EnableUI(false);
      LoadFromSnapshot();
    }
  });
  button_load_->SetAttribute("MinimumWidth", buttonWidth);

  jui_helper::JUIWindow::GetInstance()->AddView(button_sign_in_);
  jui_helper::JUIWindow::GetInstance()->AddView(button_select_);
  jui_helper::JUIWindow::GetInstance()->AddView(button_save_);
  jui_helper::JUIWindow::GetInstance()->AddView(button_load_);

  textViewFPS_ = new jui_helper::JUITextView("0.0FPS");
  textViewFPS_->SetAttribute("Gravity", jui_helper::ATTRIBUTE_GRAVITY_LEFT);
  textViewFPS_->SetAttribute("TextColor", 0xffffffff);
  textViewFPS_->SetAttribute("TextSize", jui_helper::ATTRIBUTE_UNIT_SP, 18.f);
  textViewFPS_->SetAttribute("Padding", 10, 10, 10, 10);
  jui_helper::JUIWindow::GetInstance()->AddView(textViewFPS_);

  // Progress bar
  progressBar_ = new jui_helper::JUIProgressBar();
  progressBar_->AddRule(jui_helper::LAYOUT_PARAMETER_CENTER_IN_PARENT,
                        jui_helper::LAYOUT_PARAMETER_TRUE);
  jui_helper::JUIWindow::GetInstance()->AddView(progressBar_);
  progressBar_->SetAttribute("Hidden", true);

  //Update game ui
  UpdateGameUI();

  if (authorizing_)
    EnableUI(false);
  return;
}
예제 #16
0
extern "C" void __stdcall EnableUIVB(void)
{
	EnableUI();
}
예제 #17
0
void MagnifyTool::OnGUIEvent( UINT nEvent, int nControlID, CDXUTControl* pControl, void* pUserContext )
{
    WCHAR szTemp[256];
    int nTemp;
    bool bChecked;
    float fTemp;

    switch( nControlID )
    {
        case IDC_MAGNIFY_CHECKBOX_ENABLE:
            bChecked = ((CDXUTCheckBox*)pControl)->GetChecked();
            if( bChecked )
            {
                EnableUI();

                if( NULL == m_pSourceRTResource )
                {
                    ForceDepthUI();
                }

                if( NULL == m_pSourceDepthResource )
                {
                    DisableDepthUI();
                }

                ID3D10Device1* pd3dDevice1 = DXUTGetD3D10Device1();
                if( ( NULL == pd3dDevice1 ) && ( m_nSamples > 1 ) )
                {
                    DisableDepthUI();
                }

                if( m_nSamples == 1 )
                {
                    DisableSubSampleUI();
                }
            }
            else
            {
                DisableUI();
            }
            break;

        case IDC_MAGNIFY_SLIDER_PIXEL_REGION:
            nTemp = m_MagnifyUI.GetSlider( IDC_MAGNIFY_SLIDER_PIXEL_REGION )->GetValue();
            if( nTemp % 2 )
            {
                nTemp++;
            }
            swprintf_s( szTemp, L"Pixel Region : %d", nTemp );
            m_MagnifyUI.GetStatic( IDC_MAGNIFY_STATIC_PIXEL_REGION )->SetText( szTemp );
            m_Magnify.SetPixelRegion( nTemp );
            break;

        case IDC_MAGNIFY_SLIDER_SCALE:
            nTemp = m_MagnifyUI.GetSlider( IDC_MAGNIFY_SLIDER_SCALE )->GetValue();
            swprintf_s( szTemp, L"Scale : %d", nTemp );
            m_MagnifyUI.GetStatic( IDC_MAGNIFY_STATIC_SCALE )->SetText( szTemp );
            m_Magnify.SetScale( nTemp );
            break;

        case IDC_MAGNIFY_CHECKBOX_DEPTH:
            bChecked = ((CDXUTCheckBox*)pControl)->GetChecked();
            if( bChecked )
            {
                m_Magnify.SetSourceResource( m_pSourceDepthResource, m_DepthFormat, m_nWidth, m_nHeight, m_nSamples );
            }
            else
            {
                m_Magnify.SetSourceResource( m_pSourceRTResource, m_RTFormat, m_nWidth, m_nHeight, m_nSamples );
            }
            break;

        case IDC_MAGNIFY_SLIDER_DEPTH_MIN:
            fTemp = (float)m_MagnifyUI.GetSlider( IDC_MAGNIFY_SLIDER_DEPTH_MIN )->GetValue();
            fTemp /= 100.0f;
            swprintf_s( szTemp, L"Depth Min : %.2f", fTemp );
            m_MagnifyUI.GetStatic( IDC_MAGNIFY_STATIC_DEPTH_MIN )->SetText( szTemp );
            m_Magnify.SetDepthRangeMin( fTemp );
            break;

        case IDC_MAGNIFY_SLIDER_DEPTH_MAX:
            fTemp = (float)m_MagnifyUI.GetSlider( IDC_MAGNIFY_SLIDER_DEPTH_MAX )->GetValue();
            fTemp /= 100.0f;
            swprintf_s( szTemp, L"Depth Max : %.2f", fTemp );
            m_MagnifyUI.GetStatic( IDC_MAGNIFY_STATIC_DEPTH_MAX )->SetText( szTemp );
            m_Magnify.SetDepthRangeMax( fTemp );
            break;
	}
}