GamepadPage::GamepadPage(wxWindow* parent, InputPlugin& plugin, const unsigned int pad_num, InputConfigDialog* const config_dialog) : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize) ,controller(plugin.controllers[pad_num]) , m_config_dialog(config_dialog) , m_plugin(plugin) { wxBoxSizer* control_group_sizer = new ControlGroupsSizer(m_plugin.controllers[pad_num], this, this, &control_groups); wxStaticBoxSizer* profile_sbox = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Profile")); // device chooser wxStaticBoxSizer* const device_sbox = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Device")); device_cbox = new wxComboBox(this, -1, wxT(""), wxDefaultPosition, wxSize(64,-1)); device_cbox->ToggleWindowStyle(wxTE_PROCESS_ENTER); wxButton* refresh_button = new wxButton(this, -1, _("Refresh"), wxDefaultPosition, wxSize(60,-1)); device_cbox->Bind(wxEVT_COMMAND_COMBOBOX_SELECTED, &GamepadPage::SetDevice, this); device_cbox->Bind(wxEVT_COMMAND_TEXT_ENTER, &GamepadPage::SetDevice, this); refresh_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GamepadPage::RefreshDevices, this); device_sbox->Add(device_cbox, 1, wxLEFT|wxRIGHT, 3); device_sbox->Add(refresh_button, 0, wxRIGHT|wxBOTTOM, 3); wxButton* const default_button = new wxButton(this, -1, _("Default"), wxDefaultPosition, wxSize(48,-1)); wxButton* const clearall_button = new wxButton(this, -1, _("Clear"), wxDefaultPosition, wxSize(58,-1)); wxStaticBoxSizer* const clear_sbox = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Reset")); clear_sbox->Add(default_button, 1, wxLEFT, 3); clear_sbox->Add(clearall_button, 1, wxRIGHT, 3); clearall_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GamepadPage::ClearAll, this); default_button->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GamepadPage::LoadDefaults, this); profile_cbox = new wxComboBox(this, -1, wxT(""), wxDefaultPosition, wxSize(64,-1)); wxButton* const pload_btn = new wxButton(this, -1, _("Load"), wxDefaultPosition, wxSize(48,-1)); wxButton* const psave_btn = new wxButton(this, -1, _("Save"), wxDefaultPosition, wxSize(48,-1)); wxButton* const pdelete_btn = new wxButton(this, -1, _("Delete"), wxDefaultPosition, wxSize(60,-1)); pload_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GamepadPage::LoadProfile, this); psave_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GamepadPage::SaveProfile, this); pdelete_btn->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &GamepadPage::DeleteProfile, this); profile_sbox->Add(profile_cbox, 1, wxLEFT, 3); profile_sbox->Add(pload_btn, 0, wxLEFT, 3); profile_sbox->Add(psave_btn, 0, 0, 3); profile_sbox->Add(pdelete_btn, 0, wxRIGHT|wxBOTTOM, 3); wxBoxSizer* const dio = new wxBoxSizer(wxHORIZONTAL); dio->Add(device_sbox, 1, wxEXPAND|wxRIGHT, 5); dio->Add(clear_sbox, 0, wxEXPAND|wxRIGHT, 5); dio->Add(profile_sbox, 1, wxEXPAND|wxRIGHT, 5); wxBoxSizer* const mapping = new wxBoxSizer(wxVERTICAL); mapping->Add(dio, 1, wxEXPAND|wxLEFT|wxTOP|wxBOTTOM, 5); mapping->Add(control_group_sizer, 0, wxLEFT|wxEXPAND, 5); UpdateGUI(); SetSizerAndFit(mapping); // needed Layout(); };
BOOL CEditImage::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here ((CButton *) GetDlgItem(IDC_COLOR))->EnableWindow(1); ((CButton *) GetDlgItem(IDC_COLOR3))->EnableWindow(1); ((CStatic *) GetDlgItem(IDC_COLORSTATIC))->EnableWindow(1); ((CStatic *) GetDlgItem(IDC_STATICCHOOSE))->EnableWindow(1); ((CComboBox *) GetDlgItem(IDC_PREDEFINEDSHAPE))->EnableWindow(1); ((CButton *) GetDlgItem(IDC_CHECK1))->EnableWindow(1); ((CStatic *) GetDlgItem(IDC_STATIC1))->EnableWindow(1); ((CStatic *) GetDlgItem(IDC_COLORSTATIC2))->EnableWindow(1); ((CButton *) GetDlgItem(IDC_COLOR2))->EnableWindow(1); ((CEdit *) GetDlgItem(IDC_BORDERSIZE))->EnableWindow(1); ((CSpinButtonCtrl *) GetDlgItem(IDC_SPIN1))->EnableWindow(1); ((CStatic *) GetDlgItem(IDC_BORDERSTATIC))->EnableWindow(1); ((CSpinButtonCtrl *) GetDlgItem(IDC_SPIN1))->SetBuddy(GetDlgItem(IDC_BORDERSIZE)); if (m_transWnd) { /* //CDC *tempDC = ((CStatic *) GetDlgItem(IDC_COLORSTATIC))->GetDC(); CDC *tempDC = GetWindowDC(); CRect winRect(100,100,400,300); //((CStatic *) GetDlgItem(IDC_COLORSTATIC))->GetWindowRect(&winRect); //tempDC->FillSolidRect(&winRect,m_transWnd->m_transparentColor); tempDC->Rectangle(&winRect); ReleaseDC(tempDC); */ if (m_transWnd->m_hbitmap) ((CButton *) GetDlgItem(IDBKCOLOR))->EnableWindow(0); else ((CButton *) GetDlgItem(IDBKCOLOR))->EnableWindow(1); ((CSpinButtonCtrl *) GetDlgItem(IDC_SPIN1))->SetRange(1,15); ((CSpinButtonCtrl *) GetDlgItem(IDC_SPIN1))->SetPos(m_transWnd->m_borderSize); //((CEdit *) GetDlgItem(IDC_COLORSTATIC))->SetTextColor(m_transWnd->m_transparentColor); if ((m_transWnd->m_regionPredefinedShape>=0) && (m_transWnd->m_regionPredefinedShape<=2)) ((CComboBox *) GetDlgItem(IDC_PREDEFINEDSHAPE))->SetCurSel(m_transWnd->m_regionPredefinedShape); if (m_transWnd->m_borderYes) ((CButton *) GetDlgItem(IDC_CHECK1))->SetCheck(1); else ((CButton *) GetDlgItem(IDC_CHECK1))->SetCheck(0); //CString txt; //txt.Format("%d",m_transWnd->m_borderSize); //((CEdit *) GetDlgItem(IDC_BORDERSIZE))->SetWindowText(txt); } UpdateGUI(); m_dialogInitialized = 1; if (m_transWnd) { if (m_transWnd->baseType == 1) { ((CButton *) GetDlgItem(IDBKCOLOR))->EnableWindow(0); ((CButton *) GetDlgItem(IDLOAD))->EnableWindow(0); } } return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const char* const label) : PadSetting(new wxCheckBox(parent, -1, wxGetTranslation(StrToWxStr(label)), wxDefaultPosition)) , value(_value) { UpdateGUI(); }
// Stop the emulation void CFrame::DoStop() { if (!Core::IsRunningAndStarted()) return; if (m_confirmStop) return; // don't let this function run again until it finishes, or is aborted. m_confirmStop = true; m_bGameLoading = false; if (Core::GetState() != Core::CORE_UNINITIALIZED || m_RenderParent != nullptr) { #if defined __WXGTK__ wxMutexGuiLeave(); std::lock_guard<std::recursive_mutex> lk(keystate_lock); wxMutexGuiEnter(); #endif // Ask for confirmation in case the user accidentally clicked Stop / Escape if (SConfig::GetInstance().bConfirmStop) { // Exit fullscreen to ensure it does not cover the stop dialog. DoFullscreen(false); // Pause the state during confirmation and restore it afterwards Core::EState state = Core::GetState(); // Do not pause if netplay is running as CPU thread might be blocked // waiting on inputs bool should_pause = !NetPlayDialog::GetNetPlayClient(); // If exclusive fullscreen is not enabled then we can pause the emulation // before we've exited fullscreen. If not then we need to exit fullscreen first. should_pause = should_pause && (!RendererIsFullscreen() || !g_Config.ExclusiveFullscreenEnabled() || SConfig::GetInstance().bRenderToMain); if (should_pause) { Core::SetState(Core::CORE_PAUSE); } wxMessageDialog m_StopDlg( this, !m_tried_graceful_shutdown ? _("Do you want to stop the current emulation?") : _("A shutdown is already in progress. Unsaved data " "may be lost if you stop the current emulation " "before it completes. Force stop?"), _("Please confirm..."), wxYES_NO | wxSTAY_ON_TOP | wxICON_EXCLAMATION, wxDefaultPosition); HotkeyManagerEmu::Enable(false); int Ret = m_StopDlg.ShowModal(); HotkeyManagerEmu::Enable(true); if (Ret != wxID_YES) { if (should_pause) Core::SetState(state); m_confirmStop = false; return; } } const auto& stm = WII_IPC_HLE_Interface::GetDeviceByName("/dev/stm/eventhook"); if (!m_tried_graceful_shutdown && stm && std::static_pointer_cast<CWII_IPC_HLE_Device_stm_eventhook>(stm)->HasHookInstalled()) { Core::DisplayMessage("Shutting down", 30000); // Unpause because gracefully shutting down needs the game to actually request a shutdown if (Core::GetState() == Core::CORE_PAUSE) DoPause(); ProcessorInterface::PowerButton_Tap(); m_confirmStop = false; m_tried_graceful_shutdown = true; return; } if (UseDebugger && g_pCodeWindow) { if (g_pCodeWindow->HasPanel<CWatchWindow>()) g_pCodeWindow->GetPanel<CWatchWindow>()->SaveAll(); PowerPC::watches.Clear(); if (g_pCodeWindow->HasPanel<CBreakPointWindow>()) g_pCodeWindow->GetPanel<CBreakPointWindow>()->SaveAll(); PowerPC::breakpoints.Clear(); PowerPC::memchecks.Clear(); if (g_pCodeWindow->HasPanel<CBreakPointWindow>()) g_pCodeWindow->GetPanel<CBreakPointWindow>()->NotifyUpdate(); g_symbolDB.Clear(); Host_NotifyMapLoaded(); } // TODO: Show the author/description dialog here if (Movie::IsRecordingInput()) DoRecordingSave(); if (Movie::IsMovieActive()) Movie::EndPlayInput(false); if (NetPlayDialog::GetNetPlayClient()) NetPlayDialog::GetNetPlayClient()->Stop(); Core::Stop(); UpdateGUI(); } }
void CFrame::OnStopped() { m_confirmStop = false; m_tried_graceful_shutdown = false; #if defined(HAVE_X11) && HAVE_X11 if (SConfig::GetInstance().bDisableScreenSaver) X11Utils::InhibitScreensaver(X11Utils::XDisplayFromHandle(GetHandle()), X11Utils::XWindowFromHandle(GetHandle()), false); #endif #ifdef _WIN32 // Allow windows to resume normal idling behavior SetThreadExecutionState(ES_CONTINUOUS); #endif m_RenderFrame->SetTitle(StrToWxStr(scm_rev_str)); // Destroy the renderer frame when not rendering to main m_RenderParent->Unbind(wxEVT_SIZE, &CFrame::OnRenderParentResize, this); // Mouse wxTheApp->Unbind(wxEVT_RIGHT_DOWN, &CFrame::OnMouse, this); wxTheApp->Unbind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this); wxTheApp->Unbind(wxEVT_MIDDLE_DOWN, &CFrame::OnMouse, this); wxTheApp->Unbind(wxEVT_MIDDLE_UP, &CFrame::OnMouse, this); wxTheApp->Unbind(wxEVT_MOTION, &CFrame::OnMouse, this); if (SConfig::GetInstance().bHideCursor) m_RenderParent->SetCursor(wxNullCursor); DoFullscreen(false); if (!SConfig::GetInstance().bRenderToMain) { m_RenderFrame->Destroy(); } else { #if defined(__APPLE__) // Disable the full screen button when not in a game. m_RenderFrame->EnableFullScreenView(false); #endif // Make sure the window is not longer set to stay on top m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() & ~wxSTAY_ON_TOP); } m_RenderParent = nullptr; m_bRendererHasFocus = false; m_RenderFrame = nullptr; // Clean framerate indications from the status bar. GetStatusBar()->SetStatusText(" ", 0); // Clear Wii Remote connection status from the status bar. GetStatusBar()->SetStatusText(" ", 1); // If batch mode was specified on the command-line or we were already closing, exit now. if (m_bBatchMode || m_bClosing) Close(true); // If using auto size with render to main, reset the application size. if (SConfig::GetInstance().bRenderToMain && SConfig::GetInstance().bRenderWindowAutoSize) SetSize(SConfig::GetInstance().iWidth, SConfig::GetInstance().iHeight); m_GameListCtrl->Enable(); m_GameListCtrl->Show(); m_GameListCtrl->SetFocus(); UpdateGUI(); }
void CDownloadMenu::HandleCommands( const idStr &cmd, idUserInterface *gui ) { if( cmd == "mainmenu_heartbeat" ) { // Update download progress if( _selectedMods.Num() > 0 ) { UpdateDownloadProgress( gui ); } // Do we have a pending mission list request? if( gameLocal.m_MissionManager->IsDownloadableModsRequestInProgress() ) { CMissionManager::RequestStatus status = gameLocal.m_MissionManager->ProcessReloadDownloadableModsRequest(); switch( status ) { case CMissionManager::FAILED: { gui->HandleNamedEvent( "onAvailableMissionsRefreshed" ); // hide progress dialog // Issue a failure message gameLocal.Printf( "Connection Error.\n" ); GuiMessage msg; msg.title = common->Translate( "#str_02140" ); // Unable to contact Mission Archive msg.message = common->Translate( "#str_02007" ); // Cannot connect to server. msg.type = GuiMessage::MSG_OK; msg.okCmd = "close_msg_box"; gameLocal.AddMainMenuMessage( msg ); } break; case CMissionManager::SUCCESSFUL: { gui->HandleNamedEvent( "onAvailableMissionsRefreshed" ); // hide progress dialog UpdateGUI( gui ); UpdateDownloadProgress( gui ); } break; default: break; }; } // Process pending details download request if( gameLocal.m_MissionManager->IsModDetailsRequestInProgress() ) { CMissionManager::RequestStatus status = gameLocal.m_MissionManager->ProcessReloadModDetailsRequest(); switch( status ) { case CMissionManager::FAILED: { gui->HandleNamedEvent( "onDownloadableMissionDetailsDownloadFailed" ); // hide progress dialog // Issue a failure message gameLocal.Printf( "Connection Error.\n" ); GuiMessage msg; msg.title = common->Translate( "#str_02008" ); // Mission Details Download Failed msg.message = common->Translate( "#str_02009" ); // Failed to download the details XML file. msg.type = GuiMessage::MSG_OK; msg.okCmd = "close_msg_box"; gameLocal.AddMainMenuMessage( msg ); } break; case CMissionManager::SUCCESSFUL: { gui->HandleNamedEvent( "onDownloadableMissionDetailsLoaded" ); // hide progress dialog UpdateModDetails( gui ); UpdateScreenshotItemVisibility( gui ); } break; default: break; }; } // Process pending screenshot download request if( gameLocal.m_MissionManager->IsMissionScreenshotRequestInProgress() ) { CMissionManager::RequestStatus status = gameLocal.m_MissionManager->ProcessMissionScreenshotRequest(); switch( status ) { case CMissionManager::FAILED: { gui->HandleNamedEvent( "onFailedToDownloadScreenshot" ); // Issue a failure message gameLocal.Printf( "Connection Error.\n" ); GuiMessage msg; msg.title = common->Translate( "#str_02002" ); // "Connection Error" msg.message = common->Translate( "#str_02139" ); // "Failed to download the screenshot file." msg.type = GuiMessage::MSG_OK; msg.okCmd = "close_msg_box"; gameLocal.AddMainMenuMessage( msg ); } break; case CMissionManager::SUCCESSFUL: { // Load data into GUI // Get store "next" number from the GUI int nextScreenNum = gui->GetStateInt( "av_mission_next_screenshot_num" ); UpdateNextScreenshotData( gui, nextScreenNum ); // Ready to fade gui->HandleNamedEvent( "onStartFadeToNextScreenshot" ); } break; default: break; }; } } else if( cmd == "refreshavailablemissionlist" ) { if( !cv_tdm_allow_http_access.GetBool() || gameLocal.m_HttpConnection == NULL ) { gui->HandleNamedEvent( "onAvailableMissionsRefreshed" ); // hide progress dialog // HTTP Access disallowed, display message gameLocal.Printf( "HTTP requests disabled, cannot check for available missions.\n" ); GuiMessage msg; msg.type = GuiMessage::MSG_OK; msg.okCmd = "close_msg_box"; msg.title = common->Translate( "#str_02140" ); // "Unable to contact Mission Archive" msg.message = common->Translate( "#str_02141" ); // "HTTP Requests have been disabled,\n cannot check for available missions." gameLocal.AddMainMenuMessage( msg ); return; } // Clear data before updating the list _selectedListTop = 0; _selectedMods.Clear(); UpdateGUI( gui ); UpdateDownloadProgress( gui ); // Start refreshing the list, will be handled in mainmenu_heartbeat if( gameLocal.m_MissionManager->StartReloadDownloadableMods() == -1 ) { gameLocal.Error( "No URLs specified to download the mission list XML." ); } } else if( cmd == "ondownloadablemissionselected" ) { int selectedMission = gui->GetStateInt( "av_mission_selected" ); int missionIndex = selectedMission + _availListTop; // Update mission details const DownloadableModList &mods = gameLocal.m_MissionManager->GetDownloadableMods(); if( missionIndex > mods.Num() ) { return; } gui->SetStateString( "av_mission_title", mods[missionIndex]->title ); gui->SetStateString( "av_mission_author", mods[missionIndex]->author ); gui->SetStateString( "av_mission_release_date", mods[missionIndex]->releaseDate ); gui->SetStateString( "av_mission_type", mods[missionIndex]->type == DownloadableMod::Multi ? common->Translate( "#str_04353" ) : // Campaign common->Translate( "#str_04352" ) ); // Single Mission gui->SetStateString( "av_mission_version", va( "%d", mods[missionIndex]->version ) ); gui->SetStateString( "av_mission_size", va( "%0.1f %s", mods[missionIndex]->sizeMB, common->Translate( "#str_02055" ) ) ); // MB gui->SetStateBool( "av_mission_details_visible", true ); gui->HandleNamedEvent( "UpdateAvailableMissionColours" ); } else if( cmd == "onselectmissionfordownload" ) { int selectedMission = gui->GetStateInt( "av_mission_selected" ); int missionIndex = selectedMission + _availListTop; _selectedMods.AddUnique( missionIndex ); gui->SetStateInt( "av_mission_selected", -1 ); gui->SetStateBool( "av_mission_details_visible", false ); UpdateGUI( gui ); } else if( cmd == "ondeselectmissionfordownload" ) { int selectedItem = gui->GetStateInt( "dl_mission_selected" ); int index = selectedItem + _selectedListTop; if( index >= _selectedMods.Num() ) { return; } _selectedMods.Remove( _selectedMods[index] ); UpdateGUI( gui ); UpdateDownloadProgress( gui ); } else if( cmd == "ondownloadablemissionscrollup" ) { int numMissionsPerPage = gui->GetStateInt( "packagesPerPage", "5" ); _availListTop -= numMissionsPerPage; if( _availListTop < 0 ) { _availListTop = 0; } UpdateGUI( gui ); } else if( cmd == "ondownloadablemissionscrolldown" ) { int numMissionsPerPage = gui->GetStateInt( "packagesPerPage", "5" ); _availListTop += numMissionsPerPage; UpdateGUI( gui ); } else if( cmd == "onselectedmissionscrollup" ) { int itemsPerPage = gui->GetStateInt( "selectedPackagesPerPage", "5" ); _selectedListTop -= itemsPerPage; if( _selectedListTop < 0 ) { _selectedListTop = 0; } UpdateGUI( gui ); } else if( cmd == "onselectedmissionscrolldown" ) { int itemsPerPage = gui->GetStateInt( "selectedPackagesPerPage", "5" ); _selectedListTop += itemsPerPage; UpdateGUI( gui ); } else if( cmd == "ondownloadablemissionshowdetails" ) { int selectedMission = gui->GetStateInt( "av_mission_selected" ); int missionIndex = selectedMission + _availListTop; // Issue a new download request gameLocal.m_MissionManager->StartDownloadingModDetails( missionIndex ); gui->HandleNamedEvent( "onDownloadableMissionDetailsLoaded" ); } else if( cmd == "onstartdownload" ) { StartDownload( gui ); UpdateDownloadProgress( gui ); // do this first UpdateGUI( gui ); } else if( cmd == "ondownloadcompleteconfirm" ) { // Let the GUI request another refresh of downloadable missions (with delay) gui->HandleNamedEvent( "QueueDownloadableMissionListRefresh" ); } else if( cmd == "ongetnextscreenshotforavailablemission" ) { PerformScreenshotStep( gui, +1 ); UpdateScreenshotItemVisibility( gui ); } else if( cmd == "ongetprevscreenshotforavailablemission" ) { PerformScreenshotStep( gui, -1 ); UpdateScreenshotItemVisibility( gui ); } }
// Prepare the GUI to start the game. void CFrame::StartGame(const std::string& filename) { if (m_bGameLoading) return; m_bGameLoading = true; GetToolBar()->EnableTool(IDM_PLAY, false); GetMenuBar()->FindItem(IDM_PLAY)->Enable(false); if (SConfig::GetInstance().bRenderToMain) { // Game has been started, hide the game list m_GameListCtrl->Disable(); m_GameListCtrl->Hide(); m_RenderParent = m_Panel; m_RenderFrame = this; if (SConfig::GetInstance().bKeepWindowOnTop) m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() | wxSTAY_ON_TOP); else m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() & ~wxSTAY_ON_TOP); // No, I really don't want TAB_TRAVERSAL being set behind my back, // thanks. (Note that calling DisableSelfFocus would prevent this flag // from being set for new children, but wouldn't reset the existing // flag.) m_RenderParent->SetWindowStyle(m_RenderParent->GetWindowStyle() & ~wxTAB_TRAVERSAL); } else { wxRect window_geometry( SConfig::GetInstance().iRenderWindowXPos, SConfig::GetInstance().iRenderWindowYPos, SConfig::GetInstance().iRenderWindowWidth, SConfig::GetInstance().iRenderWindowHeight); // Set window size in framebuffer pixels since the 3D rendering will be operating at // that level. wxSize default_size{wxSize(640, 480) * (1.0 / GetContentScaleFactor())}; m_RenderFrame = new CRenderFrame(this, wxID_ANY, _("Dolphin"), wxDefaultPosition, default_size); // Convert ClientSize coordinates to frame sizes. wxSize decoration_fudge = m_RenderFrame->GetSize() - m_RenderFrame->GetClientSize(); default_size += decoration_fudge; if (!window_geometry.IsEmpty()) window_geometry.SetSize(window_geometry.GetSize() + decoration_fudge); WxUtils::SetWindowSizeAndFitToScreen(m_RenderFrame, window_geometry.GetPosition(), window_geometry.GetSize(), default_size); if (SConfig::GetInstance().bKeepWindowOnTop) m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() | wxSTAY_ON_TOP); else m_RenderFrame->SetWindowStyle(m_RenderFrame->GetWindowStyle() & ~wxSTAY_ON_TOP); m_RenderFrame->SetBackgroundColour(*wxBLACK); m_RenderFrame->Bind(wxEVT_CLOSE_WINDOW, &CFrame::OnRenderParentClose, this); m_RenderFrame->Bind(wxEVT_ACTIVATE, &CFrame::OnActive, this); m_RenderFrame->Bind(wxEVT_MOVE, &CFrame::OnRenderParentMove, this); #ifdef _WIN32 // The renderer should use a top-level window for exclusive fullscreen support. m_RenderParent = m_RenderFrame; #else // To capture key events on Linux and Mac OS X the frame needs at least one child. m_RenderParent = new wxPanel(m_RenderFrame, IDM_MPANEL, wxDefaultPosition, wxDefaultSize, 0); #endif m_RenderFrame->Show(); } #if defined(__APPLE__) m_RenderFrame->EnableFullScreenView(true); #endif wxBusyCursor hourglass; DoFullscreen(SConfig::GetInstance().bFullscreen); if (!BootManager::BootCore(filename)) { DoFullscreen(false); // Destroy the renderer frame when not rendering to main if (!SConfig::GetInstance().bRenderToMain) m_RenderFrame->Destroy(); m_RenderFrame = nullptr; m_RenderParent = nullptr; m_bGameLoading = false; UpdateGUI(); } else { #if defined(HAVE_X11) && HAVE_X11 if (SConfig::GetInstance().bDisableScreenSaver) X11Utils::InhibitScreensaver(X11Utils::XDisplayFromHandle(GetHandle()), X11Utils::XWindowFromHandle(GetHandle()), true); #endif #ifdef _WIN32 // Prevents Windows from sleeping, turning off the display, or idling EXECUTION_STATE shouldScreenSave = SConfig::GetInstance().bDisableScreenSaver ? ES_DISPLAY_REQUIRED : 0; SetThreadExecutionState(ES_CONTINUOUS | shouldScreenSave | ES_SYSTEM_REQUIRED); #endif m_RenderParent->SetFocus(); wxTheApp->Bind(wxEVT_KEY_DOWN, &CFrame::OnKeyDown, this); wxTheApp->Bind(wxEVT_RIGHT_DOWN, &CFrame::OnMouse, this); wxTheApp->Bind(wxEVT_RIGHT_UP, &CFrame::OnMouse, this); wxTheApp->Bind(wxEVT_MIDDLE_DOWN, &CFrame::OnMouse, this); wxTheApp->Bind(wxEVT_MIDDLE_UP, &CFrame::OnMouse, this); wxTheApp->Bind(wxEVT_MOTION, &CFrame::OnMouse, this); m_RenderParent->Bind(wxEVT_SIZE, &CFrame::OnRenderParentResize, this); } }
// Updating void VoxGame::Update() { // FPS #ifdef _WIN32 QueryPerformanceCounter(&m_fpsCurrentTicks); m_deltaTime = ((float)(m_fpsCurrentTicks.QuadPart - m_fpsPreviousTicks.QuadPart) / (float)m_fpsTicksPerSecond.QuadPart); #else struct timeval tm; gettimeofday(&tm, NULL); m_fpsCurrentTicks = (double)tm.tv_sec + (double)tm.tv_usec / 1000000.0; m_deltaTime = (m_fpsCurrentTicks - m_fpsPreviousTicks); #endif //_WIN32 m_fps = 1.0f / m_deltaTime; m_fpsPreviousTicks = m_fpsCurrentTicks; // Update interpolator singleton Interpolator::GetInstance()->Update(m_deltaTime); // Pause the interpolator if animations are paused. Interpolator::GetInstance()->SetPaused(m_animationUpdate == false); // Update the time manager (countdowntimers); TimeManager::GetInstance()->Update(m_deltaTime); // Animation update if (m_animationUpdate) { // Update the lighting manager m_pLightingManager->Update(m_deltaTime); // Block particle manager m_pBlockParticleManager->Update(m_deltaTime); // Player m_pPlayer->Update(m_deltaTime); if (m_cameraMode == CameraMode_MouseRotate || m_cameraMode == CameraMode_AutoCamera) { vec3 playerMovementChanged = m_pPlayer->GetPositionMovementAmount(); m_pGameCamera->SetFakePosition(m_pGameCamera->GetFakePosition() + playerMovementChanged); } } // Update the chunk manager m_pChunkManager->Update(m_deltaTime); // Update controls UpdateControls(m_deltaTime); // Update the camera based on movements if (m_gameMode == GameMode_Game) { UpdateCamera(m_deltaTime); } // Update the dynamic camera zoom UpdateCameraZoom(m_deltaTime); // Update the camera clipping m_targetCameraPositionBeforeClipping = m_pGameCamera->GetFakePosition(); UpdateCameraClipping(m_deltaTime); // Update the player's alpha and transparency based on camera distance to player if (m_gameMode == GameMode_Game && m_cameraMode != CameraMode_Debug) { UpdatePlayerAlpha(m_deltaTime); } // Update the GUI int x = m_pVoxWindow->GetCursorX(); int y = m_pVoxWindow->GetCursorY(); m_pGUI->Update(m_deltaTime); if (m_pVoxWindow->IsCursorOn()) { m_pGUI->ImportMouseMotion(x, m_windowHeight - y); } UpdateGUI(m_deltaTime); // Update lights UpdateLights(m_deltaTime); // Update the application and window m_pVoxApplication->Update(m_deltaTime); m_pVoxWindow->Update(m_deltaTime); }
int main(int argc, char *argv[]) { #ifdef WINDOWS_SYS // The current directory of the application is changed when using the native dialog on Windows // This is a quick fix until libretroshare is using a absolute path in the portable Version #if QT_VERSION >= QT_VERSION_CHECK (5, 3, 0) // Do we need a solution in v0.6? #endif #if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) && QT_VERSION < QT_VERSION_CHECK (5, 3, 0) typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options); typedef QString (*_qt_filedialog_open_filename_hook) (QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options); typedef QString (*_qt_filedialog_save_filename_hook) (QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options); typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options); extern Q_GUI_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook; extern Q_GUI_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook; extern Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook; extern Q_GUI_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook; qt_filedialog_open_filename_hook = filedialog_open_filename_hook; qt_filedialog_open_filenames_hook = filedialog_open_filenames_hook; qt_filedialog_save_filename_hook = filedialog_save_filename_hook; qt_filedialog_existing_directory_hook = filedialog_existing_directory_hook; #endif #if QT_VERSION < QT_VERSION_CHECK (5, 0, 0) extern bool Q_GUI_EXPORT qt_use_native_dialogs; qt_use_native_dialogs = false; #endif { /* Set the current directory to the application dir, because the start dir with autostart from the registry run key is not the exe dir */ QApplication app(argc, argv); QDir::setCurrent(QCoreApplication::applicationDirPath()); } #endif QStringList args = char_array_to_stringlist(argv+1, argc-1); Q_INIT_RESOURCE(images); Q_INIT_RESOURCE(icons); // This is needed to allocate rsNotify, so that it can be used to ask for PGP passphrase // RsControl::earlyInitNotificationSystem() ; NotifyQt *notify = NotifyQt::Create(); rsNotify->registerNotifyClient(notify); /* RetroShare Core Objects */ RsInit::InitRsConfig(); int initResult = RsInit::InitRetroShare(argc, argv); if(initResult == RS_INIT_NO_KEYRING) // happens when we already have accounts, but no pgp key. This is when switching to the openpgp-sdk version. { QApplication dummyApp (argc, argv); // needed for QMessageBox /* Translate into the desired language */ LanguageSupport::translate(LanguageSupport::defaultLanguageCode()); QMessageBox msgBox; msgBox.setText(QObject::tr("This version of RetroShare is using OpenPGP-SDK. As a side effect, it's not using the system shared PGP keyring, but has it's own keyring shared by all RetroShare instances. <br><br>You do not appear to have such a keyring, although PGP keys are mentioned by existing RetroShare accounts, probably because you just changed to this new version of the software.")); msgBox.setInformativeText(QObject::tr("Choose between:<br><ul><li><b>Ok</b> to copy the existing keyring from gnupg (safest bet), or </li><li><b>Close without saving</b> to start fresh with an empty keyring (you will be asked to create a new PGP key to work with RetroShare, or import a previously saved pgp keypair). </li><li><b>Cancel</b> to quit and forge a keyring by yourself (needs some PGP skills)</li></ul>")); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Discard | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Ok); msgBox.setWindowIcon(QIcon(":/icons/logo_128.png")); int ret = msgBox.exec(); if(ret == QMessageBox::Cancel) return 0 ; if(ret == QMessageBox::Ok) { if(!RsAccounts::CopyGnuPGKeyrings()) return 0 ; initResult = RsInit::InitRetroShare(argc, argv); displayWarningAboutDSAKeys() ; } else initResult = RS_INIT_OK ; } if (initResult < 0) { /* Error occured */ QApplication dummyApp (argc, argv); // needed for QMessageBox /* Translate into the desired language */ LanguageSupport::translate(LanguageSupport::defaultLanguageCode()); displayWarningAboutDSAKeys(); QMessageBox mb(QMessageBox::Critical, QObject::tr("RetroShare"), "", QMessageBox::Ok); mb.setWindowIcon(QIcon(":/icons/logo_128.png")); switch (initResult) { case RS_INIT_AUTH_FAILED: std::cerr << "RsInit::InitRetroShare AuthGPG::InitAuth failed" << std::endl; mb.setText(QObject::tr("Initialization failed. Wrong or missing installation of PGP.")); break; default: /* Unexpected return code */ std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl; mb.setText(QObject::tr("An unexpected error occurred. Please report 'RsInit::InitRetroShare unexpected return code %1'.").arg(initResult)); break; } mb.exec(); return 1; } /* create global settings object path maybe wrong, when no profile exist in this case it can be use only for default values */ RshareSettings::Create (); /* Setup The GUI Stuff */ Rshare rshare(args, argc, argv, QString::fromUtf8(RsAccounts::ConfigDirectory().c_str())); std::string url = RsInit::getRetroShareLink(); if (!url.empty()) { /* start with RetroShare link */ EventReceiver eventReceiver; if (eventReceiver.sendRetroShareLink(QString::fromStdString(url))) { return 0; } /* Start RetroShare */ } QSplashScreen splashScreen(QPixmap(":/images/logo/logo_splash.png")/* , Qt::WindowStaysOnTopHint*/); switch (initResult) { case RS_INIT_OK: { /* Login Dialog */ /* check for existing Certificate */ bool genCert = false; std::list<RsPeerId> accountIds; if (RsAccounts::GetAccountIds(accountIds) && (accountIds.size() > 0)) { StartDialog sd; if (sd.exec() == QDialog::Rejected) { return 1; } /* if we're logged in */ genCert = sd.requestedNewCert(); } else { genCert = true; } if (genCert) { GenCertDialog gd(false); if (gd.exec () == QDialog::Rejected) { return 1; } } splashScreen.show(); } break; case RS_INIT_HAVE_ACCOUNT: { splashScreen.show(); splashScreen.showMessage(rshare.translate("SplashScreen", "Load profile"), Qt::AlignHCenter | Qt::AlignBottom); RsPeerId preferredId; RsAccounts::GetPreferredAccountId(preferredId); // true: note auto-login is active Rshare::loadCertificate(preferredId, true); } break; default: /* Unexpected return code */ std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl; QMessageBox::warning(0, QObject::tr("RetroShare"), QObject::tr("An unexpected error occured. Please report 'RsInit::InitRetroShare unexpected return code %1'.").arg(initResult)); return 1; } /* recreate global settings object, now with correct path */ RshareSettings::Create(true); Rshare::resetLanguageAndStyle(); SoundManager::create(); splashScreen.showMessage(rshare.translate("SplashScreen", "Load configuration"), Qt::AlignHCenter | Qt::AlignBottom); /* stop Retroshare if startup fails */ if (!RsControl::instance()->StartupRetroShare()) { std::cerr << "libretroshare failed to startup!" << std::endl; return 1; } Rshare::initPlugins(); splashScreen.showMessage(rshare.translate("SplashScreen", "Create interface"), Qt::AlignHCenter | Qt::AlignBottom); RsharePeerSettings::Create(); Emoticons::load(); if (Settings->value(QString::fromUtf8("FirstRun"), true).toBool()) { splashScreen.hide(); Settings->setValue(QString::fromUtf8("FirstRun"), false); SoundManager::initDefault(); #ifdef __APPLE__ /* For OSX, we set the default to "cleanlooks", as the AQUA style hides some input boxes * only on the first run - as the user might want to change it ;) */ QString osx_style("cleanlooks"); Rshare::setStyle(osx_style); Settings->setInterfaceStyle(osx_style); #endif // This is now disabled - as it doesn't add very much. // Need to make sure that defaults are sensible! #ifdef ENABLE_QUICKSTART_WIZARD QuickStartWizard qstartWizard; qstartWizard.exec(); #endif } MainWindow *w = MainWindow::Create (); splashScreen.finish(w); EventReceiver *eventReceiver = NULL; if (Settings->getRetroShareProtocol()) { /* Create event receiver */ eventReceiver = new EventReceiver; if (eventReceiver->start()) { QObject::connect(eventReceiver, SIGNAL(linkReceived(const QUrl&)), w, SLOT(retroshareLinkActivated(const QUrl&))); } } if (!url.empty()) { /* Now use link from the command line, because no RetroShare was running */ RetroShareLink link(QString::fromStdString(url)); if (link.valid()) { w->retroshareLinkActivated(link.toUrl()); } } // I'm using a signal to transfer the hashing info to the mainwindow, because Qt schedules signals properly to // avoid clashes between infos from threads. // qRegisterMetaType<FileDetail>("FileDetail") ; qRegisterMetaType<RsPeerId>("RsPeerId") ; std::cerr << "connecting signals and slots" << std::endl ; QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->transfersDialog->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ; QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->friendsDialog->networkDialog ,SLOT(securedUpdateDisplay())) ; QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus())); QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->friendsDialog->networkDialog,SLOT(setLogInfo(QString))) ; QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->friendsDialog->networkView,SLOT(update()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ; w->installGroupChatNotifier(); /* only show window, if not startMinimized */ if (RsInit::getStartMinimised() || Settings->getStartMinimized()) { splashScreen.close(); } else { w->show(); } /* Startup a Timer to keep the gui's updated */ QTimer *timer = new QTimer(w); timer -> connect(timer, SIGNAL(timeout()), notify, SLOT(UpdateGUI())); timer->start(1000); notify->enable() ; // enable notification system after GUI creation, to avoid data races in Qt. WebuiPage::checkStartWebui(); /* dive into the endless loop */ int ti = rshare.exec(); delete w ; WebuiPage::checkShutdownWebui(); if (eventReceiver) { /* Destroy event receiver */ delete eventReceiver; eventReceiver = NULL; } /* cleanup */ ChatDialog::cleanupChat(); #ifdef RS_ENABLE_GXS RsGxsUpdateBroadcast::cleanup(); #endif RsControl::instance()->rsGlobalShutDown(); delete(soundManager); soundManager = NULL; Settings->sync(); delete(Settings); return ti ; }
void CConfigMain::CreateGUIControls() { InitializeGUILists(); // Create the notebook and pages Notebook = new wxNotebook(this, ID_NOTEBOOK); wxPanel* const GeneralPage = new wxPanel(Notebook, ID_GENERALPAGE); wxPanel* const DisplayPage = new wxPanel(Notebook, ID_DISPLAYPAGE); wxPanel* const AudioPage = new wxPanel(Notebook, ID_AUDIOPAGE); wxPanel* const GamecubePage = new wxPanel(Notebook, ID_GAMECUBEPAGE); wxPanel* const WiiPage = new wxPanel(Notebook, ID_WIIPAGE); PathsPage = new wxPanel(Notebook, ID_PATHSPAGE); Notebook->AddPage(GeneralPage, _("General")); Notebook->AddPage(DisplayPage, _("Interface")); Notebook->AddPage(AudioPage, _("Audio")); Notebook->AddPage(GamecubePage, _("GameCube")); Notebook->AddPage(WiiPage, _("Wii")); Notebook->AddPage(PathsPage, _("Paths")); // General page // Core Settings - Basic CPUThread = new wxCheckBox(GeneralPage, ID_CPUTHREAD, _("Enable Dual Core (speedup)")); SkipIdle = new wxCheckBox(GeneralPage, ID_IDLESKIP, _("Enable Idle Skipping (speedup)")); EnableCheats = new wxCheckBox(GeneralPage, ID_ENABLECHEATS, _("Enable Cheats")); // Framelimit Framelimit = new wxChoice(GeneralPage, ID_FRAMELIMIT, wxDefaultPosition, wxDefaultSize, arrayStringFor_Framelimit); // Core Settings - Advanced CPUEngine = new wxRadioBox(GeneralPage, ID_CPUENGINE, _("CPU Emulator Engine"), wxDefaultPosition, wxDefaultSize, arrayStringFor_CPUEngine, 0, wxRA_SPECIFY_ROWS); _NTSCJ = new wxCheckBox(GeneralPage, ID_NTSCJ, _("Force Console as NTSC-J")); // Populate the General settings wxBoxSizer* sFramelimit = new wxBoxSizer(wxHORIZONTAL); sFramelimit->Add(TEXT_BOX(GeneralPage, _("Framelimit:")), 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM, 5); sFramelimit->Add(Framelimit, 0, wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 5); wxStaticBoxSizer* const sbBasic = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, _("Basic Settings")); sbBasic->Add(CPUThread, 0, wxALL, 5); sbBasic->Add(SkipIdle, 0, wxALL, 5); sbBasic->Add(EnableCheats, 0, wxALL, 5); sbBasic->Add(sFramelimit); wxStaticBoxSizer* const sbAdvanced = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, _("Advanced Settings")); sbAdvanced->Add(CPUEngine, 0, wxALL, 5); sbAdvanced->Add(_NTSCJ, 0, wxALL, 5); wxBoxSizer* const sGeneralPage = new wxBoxSizer(wxVERTICAL); sGeneralPage->Add(sbBasic, 0, wxEXPAND | wxALL, 5); sGeneralPage->Add(sbAdvanced, 0, wxEXPAND | wxALL, 5); GeneralPage->SetSizer(sGeneralPage); // Interface Language InterfaceLang = new wxChoice(DisplayPage, ID_INTERFACE_LANG, wxDefaultPosition, wxDefaultSize, arrayStringFor_InterfaceLang); // Hotkey configuration HotkeyConfig = new wxButton(DisplayPage, ID_HOTKEY_CONFIG, _("Hotkeys"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); // Interface settings ConfirmStop = new wxCheckBox(DisplayPage, ID_INTERFACE_CONFIRMSTOP, _("Confirm on Stop")); UsePanicHandlers = new wxCheckBox(DisplayPage, ID_INTERFACE_USEPANICHANDLERS, _("Use Panic Handlers")); OnScreenDisplayMessages = new wxCheckBox(DisplayPage, ID_INTERFACE_ONSCREENDISPLAYMESSAGES, _("On-Screen Display Messages")); wxBoxSizer* sInterface = new wxBoxSizer(wxHORIZONTAL); sInterface->Add(TEXT_BOX(DisplayPage, _("Language:")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); sInterface->Add(InterfaceLang, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); sInterface->AddStretchSpacer(); sInterface->Add(HotkeyConfig, 0, wxALIGN_RIGHT | wxALL, 5); // theme selection auto const theme_selection = new wxChoice(DisplayPage, wxID_ANY); CFileSearch::XStringVector theme_dirs; theme_dirs.push_back(File::GetUserPath(D_THEMES_IDX)); theme_dirs.push_back(File::GetSysDirectory() + THEMES_DIR); CFileSearch cfs(CFileSearch::XStringVector(1, "*"), theme_dirs); auto const& sv = cfs.GetFileNames(); std::for_each(sv.begin(), sv.end(), [theme_selection](const std::string& filename) { std::string name, ext; SplitPath(filename, nullptr, &name, &ext); name += ext; auto const wxname = StrToWxStr(name); if (-1 == theme_selection->FindString(wxname)) theme_selection->Append(wxname); }); theme_selection->SetStringSelection(StrToWxStr(SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name)); // std::function = avoid error on msvc theme_selection->Bind(wxEVT_CHOICE, std::function<void(wxEvent&)>([theme_selection](wxEvent&) { SConfig::GetInstance().m_LocalCoreStartupParameter.theme_name = WxStrToStr(theme_selection->GetStringSelection()); main_frame->InitBitmaps(); main_frame->UpdateGameList(); })); auto const scInterface = new wxBoxSizer(wxHORIZONTAL); scInterface->Add(TEXT_BOX(DisplayPage, _("Theme:")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); scInterface->Add(theme_selection, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); scInterface->AddStretchSpacer(); sbInterface = new wxStaticBoxSizer(wxVERTICAL, DisplayPage, _("Interface Settings")); sbInterface->Add(ConfirmStop, 0, wxALL, 5); sbInterface->Add(UsePanicHandlers, 0, wxALL, 5); sbInterface->Add(OnScreenDisplayMessages, 0, wxALL, 5); sbInterface->Add(scInterface, 0, wxEXPAND | wxALL, 5); sbInterface->Add(sInterface, 0, wxEXPAND | wxALL, 5); sDisplayPage = new wxBoxSizer(wxVERTICAL); sDisplayPage->Add(sbInterface, 0, wxEXPAND | wxALL, 5); DisplayPage->SetSizer(sDisplayPage); // Audio page DSPEngine = new wxRadioBox(AudioPage, ID_DSPENGINE, _("DSP Emulator Engine"), wxDefaultPosition, wxDefaultSize, arrayStringFor_DSPEngine, 0, wxRA_SPECIFY_ROWS); DSPThread = new wxCheckBox(AudioPage, ID_DSPTHREAD, _("DSPLLE on Separate Thread")); DumpAudio = new wxCheckBox(AudioPage, ID_DUMP_AUDIO, _("Dump Audio")); DPL2Decoder = new wxCheckBox(AudioPage, ID_DPL2DECODER, _("Dolby Pro Logic II decoder")); VolumeSlider = new wxSlider(AudioPage, ID_VOLUME, 0, 1, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL|wxSL_INVERSE); VolumeText = new wxStaticText(AudioPage, wxID_ANY, ""); BackendSelection = new wxChoice(AudioPage, ID_BACKEND, wxDefaultPosition, wxDefaultSize, wxArrayBackends, 0, wxDefaultValidator, wxEmptyString); Latency = new wxSpinCtrl(AudioPage, ID_LATENCY, "", wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 30); Latency->Bind(wxEVT_SPINCTRL, &CConfigMain::AudioSettingsChanged, this); if (Core::GetState() != Core::CORE_UNINITIALIZED) { Latency->Disable(); BackendSelection->Disable(); DPL2Decoder->Disable(); } // Create sizer and add items to dialog wxStaticBoxSizer *sbAudioSettings = new wxStaticBoxSizer(wxVERTICAL, AudioPage, _("Sound Settings")); sbAudioSettings->Add(DSPEngine, 0, wxALL | wxEXPAND, 5); sbAudioSettings->Add(DSPThread, 0, wxALL, 5); sbAudioSettings->Add(DumpAudio, 0, wxALL, 5); sbAudioSettings->Add(DPL2Decoder, 0, wxALL, 5); wxStaticBoxSizer *sbVolume = new wxStaticBoxSizer(wxVERTICAL, AudioPage, _("Volume")); sbVolume->Add(VolumeSlider, 1, wxLEFT|wxRIGHT, 13); sbVolume->Add(VolumeText, 0, wxALIGN_CENTER|wxALL, 5); wxGridBagSizer *sBackend = new wxGridBagSizer(); sBackend->Add(TEXT_BOX(AudioPage, _("Audio Backend:")), wxGBPosition(0, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL|wxALL, 5); sBackend->Add(BackendSelection, wxGBPosition(0, 1), wxDefaultSpan, wxALL, 5); sBackend->Add(TEXT_BOX(AudioPage, _("Latency:")), wxGBPosition(1, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL|wxALL, 5); sBackend->Add(Latency, wxGBPosition(1, 1), wxDefaultSpan, wxALL, 5); wxStaticBoxSizer *sbBackend = new wxStaticBoxSizer(wxHORIZONTAL, AudioPage, _("Backend Settings")); sbBackend->Add(sBackend, 0, wxEXPAND); wxBoxSizer *sAudio = new wxBoxSizer(wxHORIZONTAL); sAudio->Add(sbAudioSettings, 1, wxEXPAND|wxALL, 5); sAudio->Add(sbVolume, 0, wxEXPAND|wxALL, 5); sAudioPage = new wxBoxSizer(wxVERTICAL); sAudioPage->Add(sAudio, 0, wxALL|wxEXPAND); sAudioPage->Add(sbBackend, 0, wxALL|wxEXPAND, 5); AudioPage->SetSizerAndFit(sAudioPage); // GameCube page // IPL settings GCSystemLang = new wxChoice(GamecubePage, ID_GC_SRAM_LNG, wxDefaultPosition, wxDefaultSize, arrayStringFor_GCSystemLang); GCAlwaysHLE_BS2 = new wxCheckBox(GamecubePage, ID_GC_ALWAYS_HLE_BS2, _("Skip BIOS")); // Device settings // EXI Devices wxStaticText* GCEXIDeviceText[3]; GCEXIDeviceText[0] = TEXT_BOX(GamecubePage, _("Slot A")); GCEXIDeviceText[1] = TEXT_BOX(GamecubePage, _("Slot B")); GCEXIDeviceText[2] = TEXT_BOX(GamecubePage, "SP1"); GCEXIDevice[0] = new wxChoice(GamecubePage, ID_GC_EXIDEVICE_SLOTA); GCEXIDevice[1] = new wxChoice(GamecubePage, ID_GC_EXIDEVICE_SLOTB); GCEXIDevice[2] = new wxChoice(GamecubePage, ID_GC_EXIDEVICE_SP1); GCMemcardPath[0] = new wxButton(GamecubePage, ID_GC_EXIDEVICE_SLOTA_PATH, "...", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); GCMemcardPath[1] = new wxButton(GamecubePage, ID_GC_EXIDEVICE_SLOTB_PATH, "...", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); //SI Devices wxStaticText* GCSIDeviceText[4]; GCSIDeviceText[0] = TEXT_BOX(GamecubePage, _("Port 1")); GCSIDeviceText[1] = TEXT_BOX(GamecubePage, _("Port 2")); GCSIDeviceText[2] = TEXT_BOX(GamecubePage, _("Port 3")); GCSIDeviceText[3] = TEXT_BOX(GamecubePage, _("Port 4")); GCSIDevice[0] = new wxChoice(GamecubePage, ID_GC_SIDEVICE0); GCSIDevice[1] = new wxChoice(GamecubePage, ID_GC_SIDEVICE1); GCSIDevice[2] = new wxChoice(GamecubePage, ID_GC_SIDEVICE2); GCSIDevice[3] = new wxChoice(GamecubePage, ID_GC_SIDEVICE3); // Populate the GameCube page sGamecubeIPLSettings = new wxGridBagSizer(); sGamecubeIPLSettings->Add(GCAlwaysHLE_BS2, wxGBPosition(0, 0), wxGBSpan(1, 2), wxALL, 5); sGamecubeIPLSettings->Add(TEXT_BOX(GamecubePage, _("System Language:")), wxGBPosition(1, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5); sGamecubeIPLSettings->Add(GCSystemLang, wxGBPosition(1, 1), wxDefaultSpan, wxLEFT|wxRIGHT|wxBOTTOM, 5); sbGamecubeIPLSettings = new wxStaticBoxSizer(wxVERTICAL, GamecubePage, _("IPL Settings")); sbGamecubeIPLSettings->Add(sGamecubeIPLSettings); wxStaticBoxSizer *sbGamecubeDeviceSettings = new wxStaticBoxSizer(wxVERTICAL, GamecubePage, _("Device Settings")); wxGridBagSizer* sbGamecubeEXIDevSettings = new wxGridBagSizer(10, 10); for (int i = 0; i < 3; ++i) { sbGamecubeEXIDevSettings->Add(GCEXIDeviceText[i], wxGBPosition(i, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); sbGamecubeEXIDevSettings->Add(GCEXIDevice[i], wxGBPosition(i, 1), wxGBSpan(1, (i < 2)?1:2), wxALIGN_CENTER_VERTICAL); if (i < 2) sbGamecubeEXIDevSettings->Add(GCMemcardPath[i], wxGBPosition(i, 2), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); if (NetPlay::IsNetPlayRunning()) GCEXIDevice[i]->Disable(); } sbGamecubeDeviceSettings->Add(sbGamecubeEXIDevSettings, 0, wxALL, 5); wxFlexGridSizer* sbGamecubeDevSettings = new wxFlexGridSizer(2, 10, 10); for (int i = 0; i < 4; ++i) { sbGamecubeDevSettings->Add(GCSIDeviceText[i], 1, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 0); sbGamecubeDevSettings->Add(GCSIDevice[i], 1, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 0); if (NetPlay::IsNetPlayRunning() || Movie::IsRecordingInput() || Movie::IsPlayingInput()) { GCSIDevice[i]->Disable(); } } sbGamecubeDeviceSettings->Add(sbGamecubeDevSettings, 0, wxALL, 5); sGamecubePage = new wxBoxSizer(wxVERTICAL); sGamecubePage->Add(sbGamecubeIPLSettings, 0, wxEXPAND|wxALL, 5); sGamecubePage->Add(sbGamecubeDeviceSettings, 0, wxEXPAND|wxALL, 5); GamecubePage->SetSizer(sGamecubePage); // Wii page // Misc Settings WiiScreenSaver = new wxCheckBox(WiiPage, ID_WII_IPL_SSV, _("Enable Screen Saver")); WiiEuRGB60 = new wxCheckBox(WiiPage, ID_WII_IPL_E60, _("Use EuRGB60 Mode (PAL60)")); WiiAspectRatio = new wxChoice(WiiPage, ID_WII_IPL_AR, wxDefaultPosition, wxDefaultSize, arrayStringFor_WiiAspectRatio); WiiSystemLang = new wxChoice(WiiPage, ID_WII_IPL_LNG, wxDefaultPosition, wxDefaultSize, arrayStringFor_WiiSystemLang); // Device Settings WiiSDCard = new wxCheckBox(WiiPage, ID_WII_SD_CARD, _("Insert SD Card")); WiiKeyboard = new wxCheckBox(WiiPage, ID_WII_KEYBOARD, _("Connect USB Keyboard")); // Populate the Wii Page sWiiIPLSettings = new wxGridBagSizer(); sWiiIPLSettings->Add(WiiScreenSaver, wxGBPosition(0, 0), wxGBSpan(1, 2), wxALL, 5); sWiiIPLSettings->Add(WiiEuRGB60, wxGBPosition(1, 0), wxGBSpan(1, 2), wxALL, 5); sWiiIPLSettings->Add(TEXT_BOX(WiiPage, _("Aspect Ratio:")), wxGBPosition(2, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL|wxALL, 5); sWiiIPLSettings->Add(WiiAspectRatio, wxGBPosition(2, 1), wxDefaultSpan, wxALL, 5); sWiiIPLSettings->Add(TEXT_BOX(WiiPage, _("System Language:")), wxGBPosition(3, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL|wxALL, 5); sWiiIPLSettings->Add(WiiSystemLang, wxGBPosition(3, 1), wxDefaultSpan, wxALL, 5); sbWiiIPLSettings = new wxStaticBoxSizer(wxVERTICAL, WiiPage, _("Misc Settings")); sbWiiIPLSettings->Add(sWiiIPLSettings); sbWiiDeviceSettings = new wxStaticBoxSizer(wxVERTICAL, WiiPage, _("Device Settings")); sbWiiDeviceSettings->Add(WiiSDCard, 0, wxALL, 5); sbWiiDeviceSettings->Add(WiiKeyboard, 0, wxALL, 5); sWiiPage = new wxBoxSizer(wxVERTICAL); sWiiPage->Add(sbWiiIPLSettings, 0, wxEXPAND|wxALL, 5); sWiiPage->Add(sbWiiDeviceSettings, 0, wxEXPAND|wxALL, 5); WiiPage->SetSizer(sWiiPage); // Paths page ISOPaths = new wxListBox(PathsPage, ID_ISOPATHS, wxDefaultPosition, wxDefaultSize, arrayStringFor_ISOPaths, wxLB_SINGLE); RecursiveISOPath = new wxCheckBox(PathsPage, ID_RECURSIVEISOPATH, _("Search Subfolders")); AddISOPath = new wxButton(PathsPage, ID_ADDISOPATH, _("Add...")); RemoveISOPath = new wxButton(PathsPage, ID_REMOVEISOPATH, _("Remove")); RemoveISOPath->Enable(false); DefaultISO = new wxFilePickerCtrl(PathsPage, ID_DEFAULTISO, wxEmptyString, _("Choose a default ISO:"), _("All GC/Wii images (gcm, iso, wbfs, ciso, gcz)") + wxString::Format("|*.gcm;*.iso;*.wbfs;*.ciso;*.gcz|%s", wxGetTranslation(wxALL_FILES)), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN); DVDRoot = new wxDirPickerCtrl(PathsPage, ID_DVDROOT, wxEmptyString, _("Choose a DVD root directory:"), wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL); ApploaderPath = new wxFilePickerCtrl(PathsPage, ID_APPLOADERPATH, wxEmptyString, _("Choose file to use as apploader: (applies to discs constructed from directories only)"), _("apploader (.img)") + wxString::Format("|*.img|%s", wxGetTranslation(wxALL_FILES)), wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN); NANDRoot = new wxDirPickerCtrl(PathsPage, ID_NANDROOT, wxEmptyString, _("Choose a NAND root directory:"), wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL); // Populate the settings wxBoxSizer* sISOButtons = new wxBoxSizer(wxHORIZONTAL); sISOButtons->Add(RecursiveISOPath, 0, wxALL|wxALIGN_CENTER, 0); sISOButtons->AddStretchSpacer(); sISOButtons->Add(AddISOPath, 0, wxALL, 0); sISOButtons->Add(RemoveISOPath, 0, wxALL, 0); sbISOPaths = new wxStaticBoxSizer(wxVERTICAL, PathsPage, _("ISO Directories")); sbISOPaths->Add(ISOPaths, 1, wxEXPAND|wxALL, 0); sbISOPaths->Add(sISOButtons, 0, wxEXPAND|wxALL, 5); sOtherPaths = new wxGridBagSizer(); sOtherPaths->Add(TEXT_BOX(PathsPage, _("Default ISO:")), wxGBPosition(0, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL|wxALL, 5); sOtherPaths->Add(DefaultISO, wxGBPosition(0, 1), wxDefaultSpan, wxEXPAND|wxALL, 5); sOtherPaths->Add(TEXT_BOX(PathsPage, _("DVD Root:")), wxGBPosition(1, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL|wxALL, 5); sOtherPaths->Add(DVDRoot, wxGBPosition(1, 1), wxDefaultSpan, wxEXPAND|wxALL, 5); sOtherPaths->Add(TEXT_BOX(PathsPage, _("Apploader:")), wxGBPosition(2, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL|wxALL, 5); sOtherPaths->Add(ApploaderPath, wxGBPosition(2, 1), wxDefaultSpan, wxEXPAND|wxALL, 5); sOtherPaths->Add(TEXT_BOX(PathsPage, _("Wii NAND Root:")), wxGBPosition(3, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL|wxALL, 5); sOtherPaths->Add(NANDRoot, wxGBPosition(3, 1), wxDefaultSpan, wxEXPAND|wxALL, 5); sOtherPaths->AddGrowableCol(1); // Populate the Paths page sPathsPage = new wxBoxSizer(wxVERTICAL); sPathsPage->Add(sbISOPaths, 1, wxEXPAND|wxALL, 5); sPathsPage->Add(sOtherPaths, 0, wxEXPAND|wxALL, 5); PathsPage->SetSizer(sPathsPage); wxBoxSizer* sMain = new wxBoxSizer(wxVERTICAL); sMain->Add(Notebook, 1, wxEXPAND|wxALL, 5); sMain->Add(CreateButtonSizer(wxOK), 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); InitializeGUIValues(); InitializeGUITooltips(); UpdateGUI(); SetSizerAndFit(sMain); Center(); SetFocus(); }
void CShop::HandleCommands(const char *menuCommand, idUserInterface *gui) { if (idStr::Icmp(menuCommand, "shopLoad") == 0) { // Clear out the shop Init(); // get list of all items that can be sold LoadShopItemDefinitions(); // init and update the shop GUI DisplayShop(gui); // refresh the display so items are greyed out gui->HandleNamedEvent("UpdateItemColours"); } else if (idStr::Icmp(menuCommand, "shopBuy") == 0) { // Buy an item int boughtItem = gui->GetStateInt("boughtItem", "0"); BuyItem(boughtItem); UpdateGUI(gui); } else if (idStr::Icmp(menuCommand, "shopSold") == 0) { // Return an item to the shelf int soldItem = gui->GetStateInt("soldItem", "0"); SellItem(soldItem); UpdateGUI(gui); } else if (idStr::Icmp(menuCommand, "shopDropUndrop") == 0) { // Drop one of the starting items int dropItem = gui->GetStateInt("dropItem", "0"); // Decide depending on the item if we should drop or undrop DropUndropItem(dropItem); UpdateGUI(gui); } else if (idStr::Icmp(menuCommand, "shopMore") == 0) { const char * listName = gui->GetStateString("moreList", ""); if (idStr::Icmp(listName, "forSale") == 0) { _forSaleTop = ScrollList(_forSaleTop, LIST_SIZE_FOR_SALE, _itemsForSale); } else if (idStr::Icmp(listName, "starting") == 0) { _startingTop = ScrollList(_startingTop, LIST_SIZE_STARTING, _startingItems); } else if (idStr::Icmp(listName, "purchased") == 0) { _purchasedTop = ScrollList(_purchasedTop, LIST_SIZE_PURCHASED, _itemsPurchased); } UpdateGUI(gui); } else if (idStr::Icmp(menuCommand, "shopDone") == 0) { // The player is done shopping, now set up the starting equipment CopyPurchasedIntoStartingEquipment(); } }
void PreferenceDlg::OnListViewSelected( wxListEvent& event ) { UpdateGUI(); event.Skip(); }
PadSettingCheckBox::PadSettingCheckBox(wxWindow* const parent, ControlState& _value, const char* const label) : PadSetting(new wxCheckBox(parent, -1, WXTSTR_FROM_CSTR(label), wxDefaultPosition)) , value(_value) { UpdateGUI(); }
int main(int argc, char *argv[]) { #ifdef WINDOWS_SYS { /* Set the current directory to the application dir, because the start dir with autostart from the registry run key is not the exe dir */ QApplication app(argc, argv); QDir::setCurrent(QCoreApplication::applicationDirPath()); } #endif QStringList args = char_array_to_stringlist(argv+1, argc-1); Q_INIT_RESOURCE(images); rsiface = NULL; NotifyQt *notify = NotifyQt::Create(); createRsIface(*notify); createRsControl(*rsiface, *notify); /* RetroShare Core Objects */ RsInit::InitRsConfig(); int initResult = RsInit::InitRetroShare(argc, argv); if(initResult == RS_INIT_NO_KEYRING) // happens when we already have accounts, but no pgp key. This is when switching to the openpgp-sdk version. { QApplication dummyApp (argc, argv); // needed for QMessageBox QMessageBox msgBox; msgBox.setText(QObject::tr("This version of RetroShare is using OpenPGP-SDK. As a side effect, it's not using the system shared PGP keyring, but has it's own keyring shared by all RetroShare instances. <br><br>You do not appear to have such a keyring, although GPG keys are mentionned by existing RetroShare accounts, probably because you just changed to this new version of the software.")); msgBox.setInformativeText(QObject::tr("Choose between:<br><ul><li><b>Ok</b> to copy the existing keyring from gnupg (safest bet), or </li><li><b>Close without saving</b> to start fresh with an empty keyring (you will be asked to create a new PGP key to work with RetroShare, or import a previously saved pgp keypair). </li><li><b>Cancel</b> to quit and forge a keyring by yourself (needs some PGP skills)</li></ul>")); msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Discard | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Ok); msgBox.setWindowIcon(QIcon(":/images/rstray3.png")); int ret = msgBox.exec(); if(ret == QMessageBox::Cancel) return 0 ; if(ret == QMessageBox::Ok) { if(!RsInit::copyGnuPGKeyrings()) return 0 ; initResult = RsInit::InitRetroShare(argc, argv); } else initResult = RS_INIT_OK ; } if (initResult < 0) { /* Error occured */ QApplication dummyApp (argc, argv); // needed for QMessageBox QMessageBox mb(QMessageBox::Critical, QObject::tr("RetroShare"), "", QMessageBox::Ok); mb.setWindowIcon(QIcon(":/images/rstray3.png")); switch (initResult) { case RS_INIT_AUTH_FAILED: std::cerr << "RsInit::InitRetroShare AuthGPG::InitAuth failed" << std::endl; mb.setText(QObject::tr("Inititialize failed. Wrong or missing installation of gpg.")); break; default: /* Unexpected return code */ std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl; mb.setText(QObject::tr("An unexpected error occured. Please report 'RsInit::InitRetroShare unexpected return code %1'.").arg(initResult)); break; } mb.exec(); return 1; } /* create global settings object path maybe wrong, when no profile exist in this case it can be use only for default values */ RshareSettings::Create (); /* Setup The GUI Stuff */ Rshare rshare(args, argc, argv, QString::fromUtf8(RsInit::RsConfigDirectory().c_str())); std::string url = RsInit::getRetroShareLink(); if (!url.empty()) { /* start with RetroShare link */ EventReceiver eventReceiver; if (eventReceiver.sendRetroShareLink(QString::fromStdString(url))) { return 0; } /* Start RetroShare */ } QSplashScreen splashScreen(QPixmap(":/images/splash.png")/* , Qt::WindowStaysOnTopHint*/); switch (initResult) { case RS_INIT_OK: { /* Login Dialog */ /* check for existing Certificate */ StartDialog *sd = NULL; bool genCert = false; std::list<std::string> accountIds; if (RsInit::getAccountIds(accountIds) && (accountIds.size() > 0)) { sd = new StartDialog(); sd->show(); while(sd -> isVisible()) { rshare.processEvents(); #ifdef WIN32 Sleep(10); #else // __LINUX__ usleep(10000); #endif } /* if we're logged in */ genCert = sd->requestedNewCert(); delete (sd); } else { genCert = true; } if (genCert) { GenCertDialog gd; gd.exec (); } splashScreen.show(); } break; case RS_INIT_HAVE_ACCOUNT: { splashScreen.show(); splashScreen.showMessage(rshare.translate("SplashScreen", "Load profile"), Qt::AlignHCenter | Qt::AlignBottom); std::string preferredId, gpgId, gpgName, gpgEmail, sslName; RsInit::getPreferedAccountId(preferredId); if (RsInit::getAccountDetails(preferredId, gpgId, gpgName, gpgEmail, sslName)) { RsInit::SelectGPGAccount(gpgId); } // true: note auto-login is active std::string lockFile; int retVal = RsInit::LockAndLoadCertificates(true, lockFile); switch(retVal) { case 0: break; case 1: QMessageBox::warning( 0, QObject::tr("Multiple instances"), QObject::tr("Another RetroShare using the same profile is " "already running on your system. Please close " "that instance first\n Lock file:\n") + QString::fromStdString(lockFile)); return 1; case 2: QMessageBox::critical( 0, QObject::tr("Multiple instances"), QObject::tr("An unexpected error occurred when Retroshare" "tried to acquire the single instance lock\n Lock file:\n") + QString::fromStdString(lockFile)); return 1; case 3: QMessageBox::critical( 0, QObject::tr("Login Failure"), QObject::tr("Maybe password is wrong") ); return 1; default: std::cerr << "StartDialog::loadCertificates() unexpected switch value " << retVal << std::endl; } } break; default: /* Unexpected return code */ std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl; QMessageBox::warning(0, QObject::tr("RetroShare"), QObject::tr("An unexpected error occured. Please report 'RsInit::InitRetroShare unexpected return code %1'.").arg(initResult)); return 1; } /* recreate global settings object, now with correct path */ RshareSettings::Create(true); Rshare::resetLanguageAndStyle(); SoundManager::create(); splashScreen.showMessage(rshare.translate("SplashScreen", "Load configuration"), Qt::AlignHCenter | Qt::AlignBottom); /* stop Retroshare if startup fails */ if (!rsicontrol->StartupRetroShare()) { std::cerr << "libretroshare failed to startup!" << std::endl; return 1; } Rshare::initPlugins(); splashScreen.showMessage(rshare.translate("SplashScreen", "Create interface"), Qt::AlignHCenter | Qt::AlignBottom); RsharePeerSettings::Create(); #ifdef MINIMAL_RSGUI MessengerWindow::showYourself(); rshare.setQuitOnLastWindowClosed(true); splashScreen.hide(); #else Emoticons::load(); if (Settings->value(QString::fromUtf8("FirstRun"), true).toBool()) { splashScreen.hide(); Settings->setValue(QString::fromUtf8("FirstRun"), false); #ifdef __APPLE__ /* For OSX, we set the default to "cleanlooks", as the AQUA style hides some input boxes * only on the first run - as the user might want to change it ;) */ QString osx_style("cleanlooks"); Rshare::setStyle(osx_style); Settings->setInterfaceStyle(osx_style); #endif // This is now disabled - as it doesn't add very much. // Need to make sure that defaults are sensible! #ifdef ENABLE_QUICKSTART_WIZARD QuickStartWizard qstartWizard; qstartWizard.exec(); #endif } MainWindow *w = MainWindow::Create (); splashScreen.finish(w); EventReceiver *eventReceiver = NULL; if (Settings->getRetroShareProtocol()) { /* Create event receiver */ eventReceiver = new EventReceiver; if (eventReceiver->start()) { QObject::connect(eventReceiver, SIGNAL(linkReceived(const QUrl&)), w, SLOT(linkActivated(const QUrl&))); } } if (!url.empty()) { /* Now use link from the command line, because no RetroShare was running */ RetroShareLink link(QString::fromStdString(url)); if (link.valid()) { w->linkActivated(link.toUrl()); } } // I'm using a signal to transfer the hashing info to the mainwindow, because Qt schedules signals properly to // avoid clashes between infos from threads. // qRegisterMetaType<FileDetail>("FileDetail") ; std::cerr << "connecting signals and slots" << std::endl ; QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ; QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->sharedfilesDialog ,SLOT(preModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w->sharedfilesDialog ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); QObject::connect(notify,SIGNAL(privateChatChanged(int, int)) ,w ,SLOT(privateChatChanged(int, int) )); QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ; QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ; QObject::connect(notify,SIGNAL(messagesTagsChanged()) ,w->messagesDialog ,SLOT(messagesTagsChanged() )) ; QObject::connect(notify,SIGNAL(messagesChanged()) ,w ,SLOT(updateMessages() )) ; QObject::connect(notify,SIGNAL(forumsChanged()) ,w ,SLOT(updateForums() ), Qt::QueuedConnection); QObject::connect(notify,SIGNAL(channelsChanged(int)) ,w ,SLOT(updateChannels(int) ), Qt::QueuedConnection); QObject::connect(notify,SIGNAL(downloadCompleteCountChanged(int)) ,w ,SLOT(updateTransfers(int) )); QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus())); QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->networkDialog,SLOT(setLogInfo(QString))) ; QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->networkDialog,SLOT(updateNewDiscoveryInfo()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ; w->installGroupChatNotifier(); /* only show window, if not startMinimized */ if (RsInit::getStartMinimised() || Settings->getStartMinimized()) { splashScreen.close(); } else { w->show(); } /* Startup a Timer to keep the gui's updated */ QTimer *timer = new QTimer(w); timer -> connect(timer, SIGNAL(timeout()), notify, SLOT(UpdateGUI())); timer->start(1000); #endif // MINIMAL_RSGUI /* dive into the endless loop */ int ti = rshare.exec(); #ifndef MINIMAL_RSGUI delete w ; if (eventReceiver) { /* Destroy event receiver */ delete eventReceiver; eventReceiver = NULL; } /* cleanup */ ChatDialog::cleanupChat(); #endif // MINIMAL_RSGUI rsicontrol->rsGlobalShutDown(); delete(soundManager); soundManager = NULL; Settings->sync(); delete(Settings); return ti ; }
HRESULT CompressFiles( const UString &arcPathPrefix, const UString &arcName, const UString &arcType, const UStringVector &names, bool email, bool showDialog, bool /* waitFinish */) { //::MessageBoxW(NULL, (LPCWSTR)L"CompressCall2::CompressFiles", (LPCWSTR)L"mooo", MB_OK); HRESULT result; MY_TRY_BEGIN CREATE_CODECS CUpdateCallbackGUI callback; callback.Init(); CUpdateOptions uo; uo.EMailMode = email; uo.SetAddActionCommand(); CIntVector formatIndices; if (!codecs->FindFormatForArchiveType(arcType, formatIndices)) { ErrorLangMessage(IDS_UNSUPPORTED_ARCHIVE_TYPE, 0x0200060D); return E_FAIL; } if (!uo.Init(codecs, formatIndices, arcPathPrefix + arcName)) { ErrorLangMessage(IDS_UPDATE_NOT_SUPPORTED, 0x02000601); return E_FAIL; } NWildcard::CCensor censor; for (int i = 0; i < names.Size(); i++) censor.AddItem(true, names[i], false); //::MessageBoxW(NULL, (LPCWSTR)L"CompressCall2::CompressFiles2", (LPCWSTR)L"mooo", MB_OK); bool messageWasDisplayed = false; result = UpdateGUI(codecs, censor, uo, showDialog, messageWasDisplayed, &callback, g_HWND); //::MessageBoxW(NULL, (LPCWSTR)L"CompressCall2::CompressFiles3", (LPCWSTR)L"mooo", MB_OK); if (result != S_OK) { if (result != E_ABORT && messageWasDisplayed) return E_FAIL; throw CSystemException(result); } if (callback.FailedFiles.Size() > 0) { if (!messageWasDisplayed) throw CSystemException(E_FAIL); return E_FAIL; } MY_TRY_FINISH return S_OK; }
int CPartFileConvert::performConvertToeMule(CString folder) { BOOL bWorking; CString filepartindex,newfilename; CString buffer; UINT fileindex; CFileFind finder; CString partfile=folder; folder.Delete(folder.ReverseFind('\\'),folder.GetLength()); partfile=partfile.Mid(partfile.ReverseFind('\\')+1,partfile.GetLength()); UpdateGUI(0,GetResString(IDS_IMP_STEPREADPF),true); filepartindex=partfile.Left(partfile.Find('.')); //int pos=filepartindex.ReverseFind('\\'); //if (pos>-1) filepartindex=filepartindex.Mid(pos+1,filepartindex.GetLength()-pos); UpdateGUI(4,GetResString(IDS_IMP_STEPBASICINF)); CPartFile* file=new CPartFile(); pfconverting->partmettype=file->LoadPartFile(folder,partfile,true); switch (pfconverting->partmettype) { case PMT_UNKNOWN: case PMT_BADFORMAT: delete file; return CONV_BADFORMAT; break; } CString oldfile=folder+_T("\\")+partfile.Left(partfile.GetLength()- ((pfconverting->partmettype==PMT_SHAREAZA)?3:4) ); pfconverting->size=file->GetFileSize(); pfconverting->filename=file->GetFileName(); pfconverting->filehash= EncodeBase16( file->GetFileHash() ,16); UpdateGUI(pfconverting); if (theApp.downloadqueue->GetFileByID(file->GetFileHash())!=0) { delete file; return CONV_ALREADYEXISTS; } if (pfconverting->partmettype==PMT_SPLITTED ) { try { CByteArray ba; ba.SetSize(PARTSIZE); CFile inputfile; int pos1,pos2; CString filename; // just count UINT maxindex=0; UINT partfilecount=0; bWorking = finder.FindFile(folder+_T("\\")+filepartindex+_T(".*.part")); while (bWorking) { bWorking = finder.FindNextFile(); ++partfilecount; buffer=finder.GetFileName(); pos1=buffer.Find('.'); pos2=buffer.Find('.',pos1+1); fileindex=_tstoi(buffer.Mid(pos1+1,pos2-pos1) ); if (fileindex==0) continue; if (fileindex>maxindex) maxindex=fileindex; } float stepperpart; if (partfilecount>0) { stepperpart=(80.0f / partfilecount ); if (maxindex*PARTSIZE<=pfconverting->size) pfconverting->spaceneeded=maxindex*PARTSIZE; else pfconverting->spaceneeded=((pfconverting->size / PARTSIZE) * PARTSIZE)+(pfconverting->size % PARTSIZE); } else { stepperpart=80.0f; pfconverting->spaceneeded=0; } UpdateGUI(pfconverting); if (GetFreeDiskSpaceX(thePrefs.GetTempDir()) < (maxindex*PARTSIZE) ) { delete file; return CONV_OUTOFDISKSPACE; } // create new partmetfile, and remember the new name file->CreatePartFile(); newfilename=file->GetFullName(); UpdateGUI(8,GetResString(IDS_IMP_STEPCRDESTFILE)); file->m_hpartfile.SetLength( pfconverting->spaceneeded ); uint16 curindex=0; bWorking = finder.FindFile(folder+_T("\\")+filepartindex+_T(".*.part")); while (bWorking) { bWorking = finder.FindNextFile(); //stats ++curindex; buffer.Format(GetResString(IDS_IMP_LOADDATA),curindex,partfilecount); UpdateGUI( 10+(curindex*stepperpart) ,buffer); filename=finder.GetFileName(); pos1=filename.Find('.'); pos2=filename.Find('.',pos1+1); fileindex=_tstoi(filename.Mid(pos1+1,pos2-pos1) ); if (fileindex==0) continue; uint32 chunkstart=(fileindex-1) * PARTSIZE ; // open, read data of the part-part-file into buffer, close file inputfile.Open(finder.GetFilePath(),CFile::modeRead|CFile::shareDenyWrite); uint32 readed=inputfile.Read( ba.GetData() ,PARTSIZE); inputfile.Close(); buffer.Format(GetResString(IDS_IMP_SAVEDATA),curindex,partfilecount); UpdateGUI( 10+(curindex*stepperpart) ,buffer); // write the buffered data file->m_hpartfile.Seek(chunkstart, CFile::begin ); file->m_hpartfile.Write(ba.GetData(),readed); } } catch(CFileException* error) { CString strError(GetResString(IDS_IMP_IOERROR)); TCHAR szError[MAX_CFEXP_ERRORMSG]; if (error->GetErrorMessage(szError, ARRSIZE(szError))){ strError += _T(" - "); strError += szError; } LogError(false, _T("%s"), strError); error->Delete(); delete file; return CONV_IOERROR; } file->m_hpartfile.Close(); } // import an external common format partdownload else //if (pfconverting->partmettype==PMT_DEFAULTOLD || pfconverting->partmettype==PMT_NEWOLD || Shareaza ) { if (!pfconverting->removeSource) pfconverting->spaceneeded=GetDiskFileSize(oldfile); UpdateGUI(pfconverting); if (!pfconverting->removeSource && (GetFreeDiskSpaceX(thePrefs.GetTempDir()) < pfconverting->spaceneeded) ) { delete file; return CONV_OUTOFDISKSPACE; } file->CreatePartFile(); newfilename=file->GetFullName(); file->m_hpartfile.Close(); bool ret=false; UpdateGUI( 92 ,GetResString(IDS_COPY)); DeleteFile(newfilename.Left(newfilename.GetLength()-4)); if (!PathFileExists(oldfile)) { // data file does not exist. well, then create a 0 byte big one HANDLE hFile = CreateFile( newfilename.Left(newfilename.GetLength()-4) , // file to open GENERIC_WRITE, // open for reading FILE_SHARE_READ, // share for reading NULL, // default security CREATE_NEW, // existing file only FILE_ATTRIBUTE_NORMAL, // normal file NULL); // no attr. template ret= !(hFile == INVALID_HANDLE_VALUE) ; CloseHandle(hFile); } else if (pfconverting->removeSource) ret=MoveFile( oldfile, newfilename.Left(newfilename.GetLength()-4) ); else ret=CopyFile( oldfile, newfilename.Left(newfilename.GetLength()-4) ,false); if (!ret) { file->DeleteFile(); //delete file; return CONV_FAILED; } } UpdateGUI( 94 ,GetResString(IDS_IMP_GETPFINFO)); DeleteFile(newfilename); if (pfconverting->removeSource) MoveFile(folder+_T("\\")+partfile,newfilename); else CopyFile(folder+_T("\\")+partfile,newfilename,false); for (int i = 0; i < file->hashlist.GetSize(); i++) delete[] file->hashlist[i]; file->hashlist.RemoveAll(); while (file->gaplist.GetCount()>0 ) { delete file->gaplist.GetAt(file->gaplist.GetHeadPosition()); file->gaplist.RemoveAt(file->gaplist.GetHeadPosition()); } if (!file->LoadPartFile(thePrefs.GetTempDir(),file->GetPartMetFileName(),false)) { //delete file; file->DeleteFile(); return CONV_BADFORMAT; } if (pfconverting->partmettype==PMT_NEWOLD || pfconverting->partmettype==PMT_SPLITTED ) { file->completedsize=file->transfered; file->m_iGainDueToCompression = 0; file->m_iLostDueToCorruption = 0; } UpdateGUI( 100 ,GetResString(IDS_IMP_ADDDWL)); theApp.downloadqueue->AddDownload(file,thePrefs.AddNewFilesPaused()); file->SavePartFile(); if (file->GetStatus(true) == PS_READY) theApp.sharedfiles->SafeAddKFile(file); // part files are always shared files if (pfconverting->removeSource) { bWorking = finder.FindFile(folder+_T("\\")+filepartindex+_T(".*")); while (bWorking) { bWorking = finder.FindNextFile(); _tunlink(finder.GetFilePath()); } if (pfconverting->partmettype==PMT_SPLITTED) RemoveDirectory(folder+_T("\\")); } return CONV_OK; }
// Updating void VoxGame::Update() { // FPS #ifdef _WIN32 QueryPerformanceCounter(&m_fpsCurrentTicks); m_deltaTime = ((float)(m_fpsCurrentTicks.QuadPart - m_fpsPreviousTicks.QuadPart) / (float)m_fpsTicksPerSecond.QuadPart); #else struct timeval tm; gettimeofday(&tm, NULL); m_fpsCurrentTicks = (double)tm.tv_sec + (double)tm.tv_usec / 1000000.0; m_deltaTime = (m_fpsCurrentTicks - m_fpsPreviousTicks); #endif //_WIN32 m_fps = 1.0f / m_deltaTime; m_fpsPreviousTicks = m_fpsCurrentTicks; float maxDeltaTime = 0.25f; if (m_deltaTime > maxDeltaTime) { cout << "Warning: DeltaTime exceeded sensible value, switching dt from " << m_deltaTime << " to " << maxDeltaTime << ".\n"; m_deltaTime = maxDeltaTime; } // Update interpolator singleton Interpolator::GetInstance()->Update(m_deltaTime); // Pause the interpolator we are are paused. Interpolator::GetInstance()->SetPaused(m_bPaused); // Update the time manager (countdowntimers); TimeManager::GetInstance()->Update(m_deltaTime); // Update the audio manager AudioManager::GetInstance()->Update(m_pGameCamera->GetPosition(), m_pGameCamera->GetFacing(), m_pGameCamera->GetUp()); // Update the initial wait timer and variables, so we dont do gameplay updates straight away if (m_initialStartWait == true) { if (m_initialWaitTimer > m_initialWaitTime) { m_initialStartWait = false; } else { m_initialWaitTimer += m_deltaTime; m_initialStartWait = true; } } // Update the current biome Biome currentBiome = m_pBiomeManager->GetBiome(m_pPlayer->GetCenter()); if (currentBiome != m_currentBiome) { m_pSkybox->SetCurrentBiome(currentBiome); m_currentBiome = currentBiome; } // Update game music if (m_gameMode == GameMode_Game) { UpdateGameMusic(m_deltaTime); } // Main components update if (m_bPaused == false && m_initialStartWait == false) { // Update the lighting manager m_pLightingManager->Update(m_deltaTime); // Block particle manager m_pBlockParticleManager->Update(m_deltaTime); // Instance manager m_pInstanceManager->Update(m_deltaTime); // Scenery manager m_pSceneryManager->Update(m_deltaTime); // Inventory manager m_pInventoryManager->Update(m_deltaTime); // Item manager m_pItemManager->Update(m_deltaTime); m_pItemManager->UpdateItemLights(m_deltaTime); m_pItemManager->UpdateItemParticleEffects(m_deltaTime); m_interactItemMutex.lock(); m_pInteractItem = m_pItemManager->CheckItemPlayerInteraction(); m_interactItemMutex.unlock(); // Projectile manager m_pProjectileManager->Update(m_deltaTime); m_pProjectileManager->UpdateProjectileLights(m_deltaTime); m_pProjectileManager->UpdateProjectileParticleEffects(m_deltaTime); // Text effects manager m_pTextEffectsManager->Update(m_deltaTime); // Update the NPC manager m_pNPCManager->Update(m_deltaTime); // Update the enemy manager m_pEnemyManager->Update(m_deltaTime); // Update the biome manager m_pBiomeManager->Update(m_deltaTime); // Player if (m_animationUpdate) { m_pPlayer->Update(m_deltaTime); } // Camera faked position if (m_cameraMode == CameraMode_MouseRotate || m_cameraMode == CameraMode_AutoCamera || m_cameraMode == CameraMode_NPCDialog) { vec3 playerMovementChanged = m_pPlayer->GetPositionMovementAmount(); m_pGameCamera->SetFakePosition(m_pGameCamera->GetFakePosition() + playerMovementChanged); } // Water m_elapsedWaterTime += m_deltaTime; } // Update the chunk manager m_pChunkManager->Update(m_deltaTime); // Update name picking if (m_pGUI->IsMouseInteractingWithGUIComponent(false) == false) { UpdateNamePicking(); } // Update the NPC hover selection based on the mouse name picking if (m_gameMode == GameMode_FrontEnd) { if (m_bNamePickingSelected) { m_pNPCManager->UpdateHoverNamePickingSelection(m_pickedObject); } else { m_pNPCManager->UpdateHoverNamePickingSelection(-1); } } // Update controls UpdateControls(m_deltaTime); // Update the camera based on movements if (m_gameMode == GameMode_Game) { UpdateCamera(m_deltaTime); m_pPlayer->SetCameraPosition(m_pGameCamera->GetPosition()); m_pPlayer->SetCameraForward(normalize(m_pGameCamera->GetFacing())); m_pPlayer->SetCameraUp(normalize(m_pGameCamera->GetUp())); m_pPlayer->SetCameraRight(normalize(m_pGameCamera->GetRight())); } // Update the dynamic camera zoom UpdateCameraZoom(m_deltaTime); // Update the camera clipping m_targetCameraPositionBeforeClipping = m_pGameCamera->GetFakePosition(); UpdateCameraClipping(m_deltaTime); // Update the player's alpha and transparency based on camera distance to player if (m_gameMode == GameMode_Game && m_cameraMode != CameraMode_Debug) { UpdatePlayerAlpha(m_deltaTime); } // Update the frontend m_pFrontendManager->Update(m_deltaTime); // Update the GUI int x = m_pVoxWindow->GetCursorX(); int y = m_pVoxWindow->GetCursorY(); m_pGUI->Update(m_deltaTime); if (IsCursorOn()) { m_pGUI->ImportMouseMotion(x, m_windowHeight - y); } UpdateGUI(m_deltaTime); if (m_bPaused == false && m_initialStartWait == false) { // Update game GUI UpdateGameGUI(m_deltaTime); // Update lights UpdateLights(m_deltaTime); } // Update the application and window m_pVoxWindow->Update(m_deltaTime); }
int main(int argc, char *argv[]) { #ifdef WINDOWS_SYS { /* Set the current directory to the application dir, because the start dir with autostart from the registry run key is not the exe dir */ QApplication app(argc, argv); QDir::setCurrent(QCoreApplication::applicationDirPath()); } #endif QStringList args = char_array_to_stringlist(argv+1, argc-1); Q_INIT_RESOURCE(images); rsiface = NULL; NotifyQt *notify = NotifyQt::Create(); createRsIface(*notify); createRsControl(*rsiface, *notify); /* RetroShare Core Objects */ RsInit::InitRsConfig(); int initResult = RsInit::InitRetroShare(argc, argv); if (initResult < 0) { /* Error occured */ QApplication dummyApp (argc, argv); // needed for QMessageBox QMessageBox mb(QMessageBox::Critical, QObject::tr("RetroShare"), "", QMessageBox::Ok); mb.setWindowIcon(QIcon(":/images/rstray3.png")); switch (initResult) { case RS_INIT_AUTH_FAILED: std::cerr << "RsInit::InitRetroShare AuthGPG::InitAuth failed" << std::endl; mb.setText(QObject::tr("Inititialize failed. Wrong or missing installation of gpg.")); break; default: /* Unexpected return code */ std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl; mb.setText(QObject::tr("An unexpected error occured. Please report 'RsInit::InitRetroShare unexpected return code %1'.").arg(initResult)); break; } mb.exec(); return 1; } /* create global settings object path maybe wrong, when no profile exist in this case it can be use only for default values */ RshareSettings::Create (); /* Setup The GUI Stuff */ Rshare rshare(args, argc, argv, QString::fromStdString(RsInit::RsConfigDirectory())); std::string url = RsInit::getRetroShareLink(); if (!url.empty()) { /* start with RetroShare link */ EventReceiver eventReceiver; if (eventReceiver.sendRetroShareLink(QString::fromStdString(url))) { return 0; } /* Start RetroShare */ } QSplashScreen splashScreen(QPixmap(":/images/splash.png")/* , Qt::WindowStaysOnTopHint*/); switch (initResult) { case RS_INIT_OK: { /* Login Dialog */ /* check for existing Certificate */ std::string userName; StartDialog *sd = NULL; bool genCert = false; std::list<std::string> accountIds; if (RsInit::getAccountIds(accountIds) && (accountIds.size() > 0)) { sd = new StartDialog(); sd->show(); while(sd -> isVisible()) { rshare.processEvents(); #ifdef WIN32 Sleep(10); #else // __LINUX__ usleep(10000); #endif } /* if we're logged in */ genCert = sd->requestedNewCert(); delete (sd); } else { genCert = true; } if (genCert) { GenCertDialog gd; gd.exec (); } splashScreen.show(); } break; case RS_INIT_HAVE_ACCOUNT: { splashScreen.show(); splashScreen.showMessage(rshare.translate("SplashScreen", "Load profile"), Qt::AlignHCenter | Qt::AlignBottom); std::string preferredId, gpgId, gpgName, gpgEmail, sslName; RsInit::getPreferedAccountId(preferredId); if (RsInit::getAccountDetails(preferredId, gpgId, gpgName, gpgEmail, sslName)) { RsInit::SelectGPGAccount(gpgId); } // true: note auto-login is active std::string lockFile; int retVal = RsInit::LockAndLoadCertificates(true, lockFile); switch(retVal) { case 0: break; case 1: QMessageBox::warning( 0, QObject::tr("Multiple instances"), QObject::tr("Another RetroShare using the same profile is " "already running on your system. Please close " "that instance first\n Lock file:\n") + QString::fromStdString(lockFile)); return 1; case 2: QMessageBox::critical( 0, QObject::tr("Multiple instances"), QObject::tr("An unexpected error occurred when Retroshare" "tried to acquire the single instance lock\n Lock file:\n") + QString::fromStdString(lockFile)); return 1; case 3: QMessageBox::critical( 0, QObject::tr("Login Failure"), QObject::tr("Maybe password is wrong") ); return 1; default: std::cerr << "StartDialog::loadCertificates() unexpected switch value " << retVal << std::endl; } } break; default: /* Unexpected return code */ std::cerr << "RsInit::InitRetroShare unexpected return code " << initResult << std::endl; QMessageBox::warning(0, QObject::tr("RetroShare"), QObject::tr("An unexpected error occured. Please report 'RsInit::InitRetroShare unexpected return code %1'.").arg(initResult)); return 1; } splashScreen.showMessage(rshare.translate("SplashScreen", "Load configuration"), Qt::AlignHCenter | Qt::AlignBottom); rsicontrol->StartupRetroShare(); splashScreen.showMessage(rshare.translate("SplashScreen", "Create interface"), Qt::AlignHCenter | Qt::AlignBottom); /* recreate global settings object, now with correct path */ RshareSettings::Create (); RsharePeerSettings::Create(); #ifdef MINIMAL_RSGUI MessengerWindow::showYourself(); rshare.setQuitOnLastWindowClosed(true); splashScreen.hide(); #else Emoticons::load(); if (Settings->value(QString::fromUtf8("FirstRun"), true).toBool()) { splashScreen.hide(); Settings->setValue(QString::fromUtf8("FirstRun"), false); QuickStartWizard qstartWizard; qstartWizard.exec(); } MainWindow *w = MainWindow::Create (); splashScreen.finish(w); EventReceiver *eventReceiver = NULL; if (Settings->getRetroShareProtocol()) { /* Create event receiver */ eventReceiver = new EventReceiver; if (eventReceiver->start()) { QObject::connect(eventReceiver, SIGNAL(linkReceived(const QUrl&)), w, SLOT(linkActivated(const QUrl&))); } } if (!url.empty()) { /* Now use link from the command line, because no RetroShare was running */ RetroShareLink link(QString::fromStdString(url)); if (link.valid()) { w->linkActivated(link.toUrl()); } } // I'm using a signal to transfer the hashing info to the mainwindow, because Qt schedules signals properly to // avoid clashes between infos from threads. // qRegisterMetaType<FileDetail>("FileDetail") ; std::cerr << "connecting signals and slots" << std::endl ; QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ; QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ; QObject::connect(notify,SIGNAL(filesPreModChanged(bool)) ,w->sharedfilesDialog ,SLOT(preModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w->sharedfilesDialog ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(filesPostModChanged(bool)) ,w ,SLOT(postModDirectories(bool) )) ; QObject::connect(notify,SIGNAL(transfersChanged()) ,w->transfersDialog ,SLOT(insertTransfers() )) ; QObject::connect(notify,SIGNAL(friendsChanged()) ,w->friendsDialog ,SLOT(insertPeers() )) ; QObject::connect(notify,SIGNAL(publicChatChanged(int)) ,w->friendsDialog ,SLOT(publicChatChanged(int) )); QObject::connect(notify,SIGNAL(groupsChanged(int)) ,w->friendsDialog ,SLOT(groupsChanged(int) )); QObject::connect(notify,SIGNAL(privateChatChanged(int, int)) ,w ,SLOT(privateChatChanged(int, int) )); QObject::connect(notify,SIGNAL(neighboursChanged()) ,w->networkDialog ,SLOT(insertConnect() )) ; QObject::connect(notify,SIGNAL(messagesChanged()) ,w->messagesDialog ,SLOT(insertMessages() )) ; QObject::connect(notify,SIGNAL(messagesTagsChanged()) ,w->messagesDialog ,SLOT(messagesTagsChanged() )) ; QObject::connect(notify,SIGNAL(messagesChanged()) ,w ,SLOT(updateMessages() )) ; QObject::connect(notify,SIGNAL(forumsChanged()) ,w ,SLOT(updateForums() ), Qt::QueuedConnection); QObject::connect(notify,SIGNAL(channelsChanged(int)) ,w ,SLOT(updateChannels(int) ), Qt::QueuedConnection); QObject::connect(notify,SIGNAL(downloadCompleteCountChanged(int)) ,w ,SLOT(updateTransfers(int) )); QObject::connect(notify,SIGNAL(chatStatusChanged(const QString&,const QString&,bool)),w->friendsDialog,SLOT(updatePeerStatusString(const QString&,const QString&,bool))); QObject::connect(notify,SIGNAL(ownStatusMessageChanged()),w->friendsDialog,SLOT(loadmypersonalstatus())); QObject::connect(notify,SIGNAL(logInfoChanged(const QString&)) ,w->networkDialog,SLOT(setLogInfo(QString))) ; QObject::connect(notify,SIGNAL(discInfoChanged()) ,w->networkDialog,SLOT(updateNewDiscoveryInfo()),Qt::QueuedConnection) ; QObject::connect(notify,SIGNAL(errorOccurred(int,int,const QString&)),w,SLOT(displayErrorMessage(int,int,const QString&))) ; QObject::connect(w->friendsDialog,SIGNAL(friendsUpdated()),w->networkDialog,SLOT(insertConnect())) ; w->installGroupChatNotifier(); /* only show window, if not startMinimized */ if (RsInit::getStartMinimised() || Settings->getStartMinimized()) { splashScreen.close(); } else { w->show(); } /* Startup a Timer to keep the gui's updated */ QTimer *timer = new QTimer(w); timer -> connect(timer, SIGNAL(timeout()), notify, SLOT(UpdateGUI())); timer->start(1000); #endif // MINIMAL_RSGUI /* dive into the endless loop */ int ti = rshare.exec(); #ifndef MINIMAL_RSGUI delete w ; if (eventReceiver) { /* Destroy event receiver */ delete eventReceiver; eventReceiver = NULL; } /* cleanup */ PopupChatDialog::cleanupChat(); #endif // MINIMAL_RSGUI rsicontrol->rsGlobalShutDown(); Settings->sync(); delete Settings; return ti ; }