void CFloatingInfoWnd::AddDownloadToList(vmsDownloadSmartPtr dld, bool bUploadInfo) { char szFile [MY_MAX_PATH]; CDownloads_Tasks::GetFileName (dld, szFile); m_mxList.Lock (); int iItem = m_wndList.GetItemCount (); m_wndList.AddItem (szFile, GetSysColor (COLOR_WINDOW), GetSysColor (COLOR_WINDOWTEXT), bUploadInfo ? 1 : 0); m_wndList.SetItemData (iItem, (ULONG)(fsDownload*)dld); m_mxList.Unlock (); UpdateDownloadProgress (iItem); UpdateDownloadSpeed (iItem); }
void CFloatingInfoWnd::OnTimer(UINT nIDEvent) { if (nIDEvent == 2) { KillTimer (2); RebuildList (); return; } try { // TDOO: crash here when exit for (int i = 0; i < m_wndList.GetItemCount (); i++) { UpdateDownloadProgress (i); UpdateDownloadSpeed (i); } } catch (...) {} BOOL bFS = fsIsSystemInFullScreenMode (); if (!m_bWasFS != !bFS) { m_bWasFS = bFS; if (bFS && IsWindowVisible () && _App.FloatingWndsHideInFSMode ()) ShowWindow (SW_HIDE); else if (bFS == FALSE && m_bNeedToShow && IsWindowVisible () == FALSE && m_bHideAlways == FALSE) ShowWindow (SW_SHOW); } CFrameWnd::OnTimer(nIDEvent); }
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 ); } }