void UndoEngine::Redo() { if(!m_redo_events.size()) return; DoEvents(m_redo_events.back(),&m_oldtree); DoEvents(m_redo_events.back(),&m_tree); m_undo_events.push_back(m_redo_events.back()); m_redo_events.pop_back(); PrintTrees(); }
void PublishPPTToPDFWithPresentation(PowerPoint::_PresentationPtr spPresentation, const CStdString& sOutputFile, int from, int to) { LOG_WS_FUNCTION_SCOPE(); DoEvents(); CStdString restrictionLevel = c_sNoRestriction; CStdString classification = c_sNoClassification; try { restrictionLevel = GetRestrictionLevel(spPresentation); classification = GetClassification(spPresentation); if(g_spGITPresentation.GetCookie() != 0) { LOG_WS_INFO(_T("g_spGITPresentation.GetCookie() != 0 - previous printing job is still executing.")); return; } PPTThreadParameters param(from, to, sOutputFile); PresentationGITGuard guard; g_spGITPresentation = (PowerPoint::_Presentation*)spPresentation; HANDLE hThread = ::CreateThread(0, 0, PowerPointPrintOut, (LPVOID)¶m, 0, 0); while(0 != hThread) { DWORD state = ::WaitForSingleObject(hThread, 0); if(WAIT_OBJECT_0 == state) { ::CloseHandle(hThread); break; } DoEvents(); } if(c_sNoRestriction != restrictionLevel) SetPdfRestrictionLevel(sOutputFile, restrictionLevel); if (c_sNoClassification != classification) SetPdfClassification(sOutputFile, classification); } catch(const Workshare::Exception&) { throw; } catch(...) { unexpected(); } }
void CTalkMasterConsoleDlg::doGetSettingsUpdate() { CPleaseWaitDlg dlg; if( !bTalking && !bListening && !m_sessionSocket && !m_playFileSocket && !sendTextDlg.m_bDialogInUse ) { KillTimer(TIMER_UPDATE_READY); dlg.Create(IDD_DIALOG_PLEASE_WAIT); dlg.ShowWindow(SW_SHOWNORMAL); m_bConsoleReady = FALSE; // We are going to re-request all of the settings and then wait releaseCurrentSettings(); m_DAResendSettings( m_hDA ); while( bLoggedOn && !bShuttingDown && !m_bConsoleReady ) { DoEvents(); Sleep(1); } dlg.DestroyWindow(); } }
void CTalkMasterConsoleDlg::showMinimized(BOOL min) { if( !theApp.UserOptions.hideWindow ) return; if( min ) { ShowWindow(SW_HIDE); m_min = TRUE; } else if (m_min) { m_min = FALSE; #if 0 if( this->IsIconic() ) ShowWindow(SW_RESTORE); else ShowWindow(SW_SHOW); DoEvents(); Sleep(10); forceForegroundWindow(); #endif } }
// Stop the download thread void ViDownloadThreadStop(VI_INSTALL_DLG *d) { // Validate arguments if (d == NULL) { return; } if (d->DownloadStarted == false) { return; } d->DownloadStarted = false; d->Halt = true; while (true) { if (WaitThread(d->DownloadThread, 50)) { break; } DoEvents(NULL); } ReleaseThread(d->DownloadThread); }
void CoreWindow::MainLoop(void) { while( 1 ) { g_win->Idle(); DoEvents(); } }
STDMETHODIMP CMktStructureBaseDlg::OnError(PP::ErrorNumberEnum ErrorNumber, BSTR Description, PP::RequestsTypeEnum ReqType, VARIANT Request) { HRESULT hr = S_OK; DoEvents(); if(m_bCanceled) return S_OK; CString strError; _bstr_t bstrSymbol; USES_CONVERSION; switch (ErrorNumber) { case PP::enSymbolNotSupported: case PP::enNoDataAvailableForSymbol: case PP::enNoAccessForData: { if ( (Request.vt & VT_RECORD) == VT_RECORD ) { if (ReqType == PP::enRequestStock ) { PP::StockParams * pParams = (PP::StockParams *) Request.pvRecord; bstrSymbol = pParams->Stock; } else { PP::OptionParams * pParams = (PP::OptionParams *) Request.pvRecord; bstrSymbol = pParams->UnderlyingSymbol; } stocks_map::iterator it = m_stocks.find ( bstrSymbol); if (it != m_stocks.end()) { CContractRequestData & data = it->second; if (! data.m_bError) { it->second.m_bGotData = true; it->second.m_bGotYield = true; it->second.m_bError = true; strError.Format (IDS_MKTSTRUCTURE_ERR_GETDATA, (LPCTSTR)bstrSymbol, (LPCTSTR) CString (Description) ); StatusMessage (strError); UpdateProgress(it); } } } } return hr; default: strError.Format (IDS_MKTSTRUCTURE_ERROR, OLE2T(Description) ); StatusMessage (strError); Stop(); } return hr; }
// 不阻塞消息的延迟 void Delay(DWORD time) { DWORD startTime = GetTickCount(); while (GetTickCount() - startTime < time) { DoEvents(); Sleep(1); // 防止占用CPU } }
// Update the window void Refresh(HWND hWnd) { HWND parent; // Validate arguments if (hWnd == NULL) { return; } DoEvents(hWnd); UpdateWindow(hWnd); DoEvents(hWnd); parent = GetParent(hWnd); if (parent != NULL) { Refresh(parent); } }
STDMETHODIMP CMktStructureBaseDlg::OnOption(PP::OptionParams *Params, PP::OptionInfo *Results, VARIANT_BOOL bLast) { USES_CONVERSION; HRESULT hr = S_OK; DoEvents(); if(m_bCanceled) return hr; /* if(bLast==VARIANT_FALSE && m_opts.m_enProviderType == enMyTrackPriceProvider) { if( fEQZero(Results->Last) && fEQZero(Results->Bid) && fEQZero(Results->Ask) ) return S_OK; } */ if(bLast==VARIANT_FALSE && Results->ExpirationDate < int(vt_date::GetCurrentDate())) return S_OK; stocks_map::iterator it = m_stocks.find (Params->UnderlyingSymbol); if (it != m_stocks.end()) try { USES_CONVERSION; if (bLast) { it->second.m_bGotOptions = true; UpdateProgress(it); return hr; } CDBLayout db; db.Connect(); db.UpdateOptionData (it->second.m_nID, Params, Results); db.Disconnect(); CString strMsg; strMsg.Format(IDS_MKTSTRUCTURE_GOTOPTION, OLE2T(Params->UnderlyingSymbol), OLE2T(Results->Series) ); it->second.m_lGotOptions++; StatusMessage (strMsg, false); UpdateProgress(it); } catch (_com_error & e) { ErrorMessage(e); Stop(); } return hr; }
void UndoEngine::CreateUndoPoint() { std::vector<UndoEvent> events = GetModifications(); if(events.size() == 0) return; m_undo_events.push_back(events); m_redo_events.clear(); DoEvents(events,&m_oldtree); PrintTrees(); }
void UpdateStatus() { int nticks=GetTickCount(); if((nticks-lticks)>250) { int nshown=ListView_GetItemCount(GetDlgItem(hWndFinder,IDC_RESULTS)); sprintf(mtext,"%d matches found (%d shown).",results.size(),nshown); SetWindowText(GetDlgItem(hWndFinder,IDC_MATCHES),mtext); lticks=nticks; DoEvents(); } }
void GameBase::Loop(){ SetZoom(); Init(); InitWorldPhysics(); while(wnd->isOpen()){ wnd->clear(clearColor); DoEvents(); CheckCollitions(); UpdateWorldPhysics(); DrawWorld(); wnd->display(); } }
static void do_gui_main_action (LPSTR cmdline) { NARGV *args = nargv_parse(cmdline); if (args->argc > 0) { if (DirectoryExists(args->argv[0])) { SetWindowText(GetDlgItem(hMainWindow, IDC_MANPATH), args->argv[0]); DoEvents (NULL); populate_dir (); } } nargv_free (args); }
void PublishWordToPDFWithDocumentInternal(PDFConverterController& pdfConverter, Word::_DocumentPtr spDocument, const CStdString& sOutputFile, const TCHAR* range, long pageType) { pdfConverter.InitialisePDFConverterUseFileName(sOutputFile, (Workshare::OptionApi::GetBool(L"PdfPublishingSimulatePostScript") ? VARIANT_TRUE : VARIANT_FALSE)); pdfConverter.SetPaperSize(spDocument); _variant_t vtPrintToFile(VARIANT_FALSE); _bstr_t version = spDocument->Application->Version; bool bDisableSetOutputFile = Workshare::OptionApi::GetBool(L"DisableSetOutputFile"); bool bIsOffice15OrGreater = ( atof(version) >= 15.0f ); _variant_t vtOutputFile(((bDisableSetOutputFile && !bIsOffice15OrGreater)? vtMissing : sOutputFile.c_str())); // vtOutputFile(vtMissing) does not work on windows 8. Workaround for fogbugz #20662 if(bDisableSetOutputFile && bIsOffice15OrGreater) { LOG_WS_ERROR(_T("Option not compatable with windows version...")); } _variant_t vtBackground(VARIANT_FALSE); _variant_t vtRange(vtMissing); _variant_t vtRanges(vtMissing); _variant_t vtFalse(VARIANT_FALSE); _variant_t vtPageType(Word::wdPrintAllPages); _bstr_t bRangeString(range); if (0 < bRangeString.length()) { vtRange = Word::wdPrintRangeOfPages; vtRange.vt = VT_I4; vtRanges = bRangeString; } switch(pageType) { case 1: vtPageType = Word::wdPrintOddPagesOnly; break; case 2: vtPageType = Word::wdPrintEvenPagesOnly; break; default: break; } vtPageType.vt = VT_I4; { WordPrintStateAdjuster adjustWordState(spDocument); //60.18: This msg loop is to prevent the 'known' issue with Workshare events from crashing. DoEvents(); PrintOutWordDocument(spDocument, &vtBackground, &vtFalse, &vtRange, &vtOutputFile, &vtMissing, &vtMissing, &vtMissing, &vtMissing, &vtRanges, &vtPageType, &vtPrintToFile); } }
// Handle the event void DoEvents(HWND hWnd) { MSG msg; if (PeekMessage(&msg, hWnd, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } UpdateWindow(hWnd); if (hWnd) { DoEvents(NULL); } }
DWORD WaitWithMessageLoop(HANDLE* hEvent, DWORD nCount, DWORD dwMilliseconds) { DWORD dwRet = WAIT_FAILED; DWORD dwMaxTick = (dwMilliseconds == INFINITE) ? 0 : GetTickCount() + dwMilliseconds; while (1) { DWORD dwTimeOut = 0; if (dwMilliseconds == INFINITE) { dwTimeOut = INFINITE; } else{ dwTimeOut = (dwMaxTick < GetTickCount()) ? 0 : dwMaxTick - GetTickCount(); //记算还要等待多秒微秒 } // wait for event or message, if it's a message, process it and return to waiting state //dwRet = MsgWaitForMultipleObjectsEx(nCount, hEvent, dwTimeOut, QS_ALLINPUT, MWMO_ALERTABLE); dwRet = MsgWaitForMultipleObjectsEx(nCount, hEvent, dwTimeOut, QS_PAINT | QS_TIMER|QS_SENDMESSAGE , MWMO_ALERTABLE); if (dwRet < WAIT_OBJECT_0 + nCount) { //OutputDebugStringA("WaitWithMessageLoop() event triggered.\n"); return dwRet; } else if (dwRet == WAIT_OBJECT_0 + nCount) { // process window messages //OutputDebugStringA("DoEvents.\n"); DoEvents(); } else if (dwRet == WAIT_TIMEOUT) { // timed out ! //OutputDebugStringA("timed out!\n"); return dwRet; } else if (dwRet == WAIT_FAILED) { //OutputDebugStringA("wait failed!\n"); return dwRet; } else{ return dwRet; } } }
STDMETHODIMP CMktStructureBaseDlg::OnStock(PP::StockParams *Params, PP::StockInfo *Results) { USES_CONVERSION; HRESULT hr = S_OK; DoEvents(); if(m_bCanceled ) return hr; stocks_map::iterator it = m_stocks.find (Params->Stock); if (it != m_stocks.end()) try { it->second.m_bGotData = true; if (! HandleStock(Params, Results) ) { CDBLayout db; db.Connect(); db.UpdateContractData (it->second.m_nID, Params->Stock, Results); db.Disconnect(); } CString strMsg; strMsg.Format(IDS_MKTSTRUCTURE_GOTDATA, OLE2T(Params->Stock)); StatusMessage (strMsg, false); UpdateProgress(it); } catch (_com_error & e) { ErrorMessage(e); Stop(); } return hr; }
int main(int argc, char *argv[]) { int i; GetArg(argc, argv); glibtop_init(); CreateDock(argc, argv); gettimeofday(&timev, NULL); pList = GetProcList(); posProc = pList; ZoneCreate(4, 50, 8, 8, UP); ZoneCreate(54, 50, 8, 8, DOWN); for (i = NB_LINE; i; i--) ZoneCreate(X_PROC + 1, Y_PROC + (i - 1) * 10 + 2, 48, 7, i); DoEvents(); return 0; }
// Release void VwOnFree(HWND hWnd) { if (inited == false) { return; } task.Halt = true; if (task.Thread != NULL) { while (true) { if (WaitForSingleObject(task.Thread, 30) != WAIT_TIMEOUT) { break; } DoEvents(hWnd); } CloseHandle(task.Thread); task.Thread = NULL; } }
// Start the installation process void ViInstallProcessStart(HWND hWnd, VI_INSTALL_DLG *d) { wchar_t *exew; bool ok; char instdir[MAX_PATH]; char hamcore[MAX_PATH]; // Validate arguments if (hWnd == NULL || d == NULL) { return; } ViGenerateVpnSMgrTempDirName(instdir, sizeof(instdir), ViGetSuitableArchForCpu()->Build); ConbinePath(hamcore, sizeof(hamcore), instdir, "hamcore.se2"); exew = setting.DownloadedInstallerPathW; d->NoClose = true; Hide(hWnd, IDCANCEL); SetPos(hWnd, P_PROGRESS, 100); Hide(hWnd, P_PROGRESS); Hide(hWnd, S_SIZEINFO); SetText(hWnd, S_STATUS, _U(IDS_INSTALLSTART+skip)); ok = true; if (setting.DownloadNotRequired == false) { if (setting.WebMode && ViCheckExeSign(hWnd, exew) == false) { // The digital signature is not reliable ok = false; } else { // Installation HANDLE hProcess; SHELLEXECUTEINFOW info; // Run Zero(&info, sizeof(info)); info.cbSize = sizeof(info); info.lpVerb = L"open"; info.lpFile = exew; info.fMask = SEE_MASK_NOCLOSEPROCESS; info.lpParameters = L"/HIDESTARTCOMMAND:1 /DISABLEAUTOIMPORT:1 /ISWEBINSTALLER:1"; info.nShow = SW_SHOWNORMAL; if (ShellExecuteExW(&info) == false) { MsgBox(hWnd, MB_ICONSTOP, _U(IDS_INSTALLSTART_ERROR+skip)); ok = false; } else { hProcess = info.hProcess; // Wait for the install process to complete while (true) { if (WaitForSingleObject(hProcess, 50) != WAIT_TIMEOUT) { break; } DoEvents(hWnd); } CloseHandle(hProcess); } } } if (ok && d->WindowsShutdowning == false) { VI_SETTING_ARCH *a = ViGetSuitableArchForCpu(); wchar_t arg[MAX_PATH]; wchar_t exe[MAX_PATH]; char *arg1 = "/easy"; // Hide the screen Hide(hWnd, 0); if (setting.NormalMode) { arg1 = "/normal"; } // (Just in case) start the VPN Client service if (MsIsServiceRunning("vpnclient") == false) { MsStartService("vpnclient"); } // Wait for that the service becomes available SwWaitForVpnClientPortReady(0); if (UniIsEmptyStr(setting.DownloadedSettingPathW) == false) { // Start a connection by importing the configuration file into the VPN Client UniFormat(arg, sizeof(arg), L"%S \"%s\"", arg1, setting.DownloadedSettingPathW); } else { // Just start the Connection Manager UniFormat(arg, sizeof(arg), L"%S", arg1); } // Get the installation state ViLoadCurrentInstalledStatusForArch(a); if (a->CurrentInstalled) { HANDLE h; wchar_t filename[MAX_PATH]; StrToUni(filename, sizeof(filename), a->VpnCMgrExeFileName); ConbinePathW(exe, sizeof(exe), a->CurrentInstalledPathW, filename); // Start the Connection Manager h = MsRunAsUserExW(exe, arg, false); if (h != NULL) { if (UniIsEmptyStr(setting.DownloadedSettingPathW) == false) { sleep_before_exit = true; } CloseHandle(h); } } } d->NoClose = false; Close(hWnd); }
bool CreateKMZ(long minx, long maxx, long miny, long maxy, LPCSTR mapname, long tileWidth, long tileHeight, long trackSize, int nDatabase, int nDrawOrder) // int nProduct, int nCountry, int nLayer) { unsigned char * bitmap_memory = NULL; long bitmap_width, dest_bitmap_width; long bitmap_height, dest_bitmap_height; long bitmap_memory_size; unsigned char bitmap_palette[1024]; long bitmap_palette_length; int nMetres = MyMap.GetMetresPerTile(); int nPixels = MyMap.GetPixelsPerTile(); double dTileScale = (double) nMetres / nPixels; //dTileScale = 1.0; CProgressWindow wndProgress; wndProgress.Initialize(); CString str_fname; str_fname.Format("%s.txf", mapname); read_txf(str_fname, &nPoints, &points); str_fname.Format("%s.png", mapname); if (minx > maxx) { long t = minx; minx = maxx; maxx = t; } if (miny > maxy) { long t = miny; miny = maxy; maxy = t; } // ToDo: Need to make collar work for OSM and OSPro etc. // long collar = CalculateCollar(minx/**1000*/, maxx/**1000*/, miny/**1000*/, maxy/**1000*/); /* long collar = 1; minx -= (collar/nMetres)*nMetres; maxx += (collar/nMetres)*nMetres; miny -= (collar/nMetres)*nMetres; maxy += (collar/nMetres)*nMetres; */ wndProgress.ResetProgressBar("Tile:", ((maxy-miny)*(maxx-minx)/nMetres*nMetres)); bool successful = false; if (nDatabase == DBASE_LOCAL) { if (MyMap.GetCountry() == COUNTRY_FR && MyMap.GetProduct() == PRODUCT_02) { successful = IGN_ReadTiles(minx, maxx, miny, maxy, wndProgress, bitmap_palette, bitmap_palette_length, bitmap_memory , bitmap_memory_size, bitmap_width, dest_bitmap_width, bitmap_height, dest_bitmap_height); } else { successful = OSPro_ReadTiles(minx, maxx, miny, maxy, wndProgress, bitmap_palette, bitmap_palette_length, bitmap_memory , bitmap_memory_size, bitmap_width, dest_bitmap_width, bitmap_height, dest_bitmap_height); } } else { bool b_use_TL3 = nDatabase == DBASE_TRACKLOGS_3; successful = ReadTracklogsTile(minx, maxx, miny, maxy, wndProgress, bitmap_palette, bitmap_palette_length, bitmap_memory , bitmap_memory_size, bitmap_width, dest_bitmap_width, bitmap_height, dest_bitmap_height, b_use_TL3); } if (!successful) { if (bitmap_memory) free(bitmap_memory); return false; } if (bitmap_memory == NULL) { printf("No images to process\n"); return false; } Gdiplus::GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); CLSID encoderClsid; // Get the CLSID of the JPEG encoder. GetEncoderClsid(L"image/jpeg", &encoderClsid); Gdiplus::EncoderParameters encoderParameters; encoderParameters.Count = 1; ULONG quality = 80; encoderParameters.Parameter[0].Guid = Gdiplus::EncoderQuality; encoderParameters.Parameter[0].Type = Gdiplus::EncoderParameterValueTypeLong; encoderParameters.Parameter[0].NumberOfValues = 1; encoderParameters.Parameter[0].Value = &quality; // xy // 00 10 20 30 40 // 01 11 21 31 41 // 02 12 22 32 42 // 03 13 23 33 43 if ((MyMap.GetProjection() == 3857) || (MyMap.GetProjection() == 900913)) { nMetres = 1; } else { nMetres = 1000; } // Note: 1000 is the rotatey collar! /* minx *= 1000; maxx *= 1000; miny *= 1000; maxy *= 1000; */ double lat,lon; OZIGEN_NorthingEasting_to_LatLon(maxy-nMetres, minx+nMetres, &lat, &lon); double minlat = lat; double maxlat = lat; double minlon = lon; double maxlon = lon; OZIGEN_NorthingEasting_to_LatLon(maxy-nMetres, maxx-nMetres, &lat, &lon); if (lat < minlat) minlat = lat; if (lat > maxlat) maxlat = lat; if (lon < minlon) minlon = lon; if (lon > maxlon) maxlon = lon; OZIGEN_NorthingEasting_to_LatLon(miny+nMetres, minx+nMetres, &lat, &lon); if (lat < minlat) minlat = lat; if (lat > maxlat) maxlat = lat; if (lon < minlon) minlon = lon; if (lon > maxlon) maxlon = lon; OZIGEN_NorthingEasting_to_LatLon(miny+nMetres, maxx-nMetres, &lat, &lon); if (lat < minlat) minlat = lat; if (lat > maxlat) maxlat = lat; if (lon < minlon) minlon = lon; if (lon > maxlon) maxlon = lon; /* SNL 24/10/2013 are these only used for display purposes? // printf("%d %d %d %d\n\n", minx+1000, miny+1000, maxx-1000, maxy-1000); OZIGEN_LatLon_to_NorthingEasting(minlat, minlon, &lat, &lon); // printf("%f %f %f %f\n", minlat, minlon, lat, lon); OZIGEN_LatLon_to_NorthingEasting(minlat, maxlon, &lat, &lon); // printf("%f %f %f %f\n", minlat, maxlon, lat, lon); OZIGEN_LatLon_to_NorthingEasting(maxlat, maxlon, &lat, &lon); // printf("%f %f %f %f\n", maxlat, maxlon, lat, lon); OZIGEN_LatLon_to_NorthingEasting(maxlat, minlon, &lat, &lon); // printf("%f %f %f %f\n\n", maxlat, minlon, lat, lon); */ char kmzName[512]; GetCurrentDirectory(sizeof(kmzName), kmzName); CString Currdir = kmzName; // Save current directory // change directory to %TEMP% and make folder 'files' GetTempPath(sizeof(kmzName), kmzName); SetCurrentDirectory(kmzName); CreateDirectory("files", NULL); sprintf(kmzName, "%s\\%s.kmz", Currdir, mapname); FILE * fp = fopen("doc.kml", "w+"); if (fp == NULL) { printf("Couldn't open doc.kml\n"); return false; } fprintf(fp, "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n" "<kml xmlns=\"http://earth.google.com/kml/2.1\">\n" "<Document>\n" "<name>Custom Map</name>\n" "<Region>\n" "<LatLonAltBox>\n" "<north>%.9f</north>\n" "<south>%.9f</south>\n" "<east>%.9f</east>\n" "<west>%.9f</west>\n" "</LatLonAltBox>\n" "</Region>\n", maxlat, minlat, maxlon, minlon); long nTilesAcross=(dest_bitmap_width+(tileWidth-1))/tileWidth; long nTilesDown=(dest_bitmap_height+(tileHeight-1))/tileHeight; JPEG_tile_list tiles; long across, down; for (across=0; across<nTilesAcross; across++) { for (down=0; down<nTilesDown; down++) { if (nPoints) { if (!TileNearTrack( minlat+(maxlat-minlat)*(nTilesDown-down)/nTilesDown, minlat+(maxlat-minlat)*(nTilesDown-down-1)/nTilesDown, minlon+(maxlon-minlon)*across/nTilesAcross, minlon+(maxlon-minlon)*(across+1)/nTilesAcross, nPoints, points, trackSize) ) continue; /* if (!PointNearTrack(minlat+(maxlat-minlat)*(nTilesDown-down)/nTilesDown, // ne minlon+(maxlon-minlon)*(across+1)/nTilesAcross, nPoints, points) && !PointNearTrack(minlat+(maxlat-minlat)*(nTilesDown-down-1)/nTilesDown, // se minlon+(maxlon-minlon)*(across+1)/nTilesAcross, nPoints, points) && !PointNearTrack(minlat+(maxlat-minlat)*(nTilesDown-down)/nTilesDown, // nw minlon+(maxlon-minlon)*across/nTilesAcross, nPoints, points) && !PointNearTrack(minlat+(maxlat-minlat)*(nTilesDown-down-1)/nTilesDown, // sw minlon+(maxlon-minlon)*across/nTilesAcross, nPoints, points) && !PointNearTrack(minlat+(maxlat-minlat)*(2*nTilesDown-2*down-1)/2/nTilesDown, // middle minlon+(maxlon-minlon)*(2*across+1)/2/nTilesAcross, nPoints, points)) continue; */ } JPEG_tile * pTile = new JPEG_tile; pTile->fname.Format("files/c%02d%02d.jpg", down, across); pTile->lat_north = minlat+(maxlat-minlat)*(nTilesDown-down)/nTilesDown; pTile->lon_east = minlon+(maxlon-minlon)*(across+1)/nTilesAcross; pTile->lat_south = minlat+(maxlat-minlat)*(nTilesDown-down-1)/nTilesDown; pTile->lon_west = minlon+(maxlon-minlon)*across/nTilesAcross; pTile->offset_x0 = dest_bitmap_width*across/nTilesAcross; pTile->offset_x1 = dest_bitmap_width*(across+1)/nTilesAcross; pTile->offset_y0 = dest_bitmap_height*down/nTilesDown; pTile->offset_y1 = dest_bitmap_height*(down+1)/nTilesDown; tiles.AddTail(pTile); } } Global_AddToResultsWindow("Number of tiles = %d",tiles.GetCount()); if (tiles.GetCount() > 100) { if (AfxMessageBox("Warning Tile Count > 100!", MB_OKCANCEL) == IDCANCEL) return false; } wndProgress.m_progress_bar.SetRange(1, tiles.GetCount()); long index = 1; POSITION pos; for (pos=tiles.GetHeadPosition(); pos != NULL; tiles.GetNext(pos)) { JPEG_tile * pTile = (JPEG_tile *)tiles.GetAt(pos); // printf("JPEG %d of %d\r", index++, tiles.GetCount()); wndProgress.m_progress_bar.SetPos(index); wndProgress.m_edit_message.Format("JPEG: %d of %d", index++, tiles.GetCount()); wndProgress.UpdateData(FALSE); DoEvents(); if (wndProgress.m_Cancelled) return false; fprintf(fp, "<GroundOverlay>\n" "<drawOrder>%d</drawOrder>\n" "<Icon>\n" "<href>%s</href>\n" "</Icon>\n" "<LatLonBox>\n" "<north>%.9f</north>\n" "<east>%.9f</east>\n" "<south>%.9f</south>\n" "<west>%.9f</west>\n" "</LatLonBox>\n" "<Region>\n" "<LatLonAltBox>\n" "<north>%.9f</north>\n" "<east>%.9f</east>\n" "<south>%.9f</south>\n" "<west>%.9f</west>\n" "</LatLonAltBox>\n" "<Lod>\n" "<minLodPixels>64</minLodPixels>\n" "</Lod>\n" "</Region>\n" "<color>A1FFFFFF</color>\n" "</GroundOverlay>\n", nDrawOrder, pTile->fname, pTile->lat_north, pTile->lon_east, pTile->lat_south, pTile->lon_west, pTile->lat_north, pTile->lon_east, pTile->lat_south, pTile->lon_west); Gdiplus::Rect r(0, 0, pTile->offset_x1-pTile->offset_x0, pTile->offset_y1-pTile->offset_y0); Gdiplus::Bitmap bmp(r.GetRight(), r.GetBottom(), PixelFormat24bppRGB ); Gdiplus::BitmapData bmpData; bmp.LockBits(&r, Gdiplus::ImageLockModeRead | Gdiplus::ImageLockModeWrite, PixelFormat24bppRGB, &bmpData); long x,y; for (y=pTile->offset_y0; y<pTile->offset_y1; y++) { lat = maxlat-(maxlat-minlat)/dest_bitmap_height*y; unsigned char * dest_bitmap_offset = ((unsigned char *)bmpData.Scan0) + bmpData.Stride*(y-pTile->offset_y0); for (x=pTile->offset_x0; x<pTile->offset_x1; x++) { lon = minlon+(maxlon-minlon)/dest_bitmap_width*x; double northing, easting; OZIGEN_LatLon_to_NorthingEasting(lat, lon, &northing, &easting); if ((MyMap.GetProjection() == 3857) || (MyMap.GetProjection() == 900913)) { } else { northing += 0.5; easting += 0.5; } if (northing < miny || easting < minx || northing > maxy || easting > maxx) { // No bitmap data present -- white *dest_bitmap_offset++ = 255; *dest_bitmap_offset++ = 255; *dest_bitmap_offset++ = 255; } else { // Look up colour of bitmap pixel - SNL 24/10/2013 unsigned char * pal; if ((MyMap.GetProjection() == 3857) || (MyMap.GetProjection() == 900913)) { // pal = bitmap_palette + 4*bitmap_memory[(long)((y)*bitmap_width + (long) (x))]; // pal = bitmap_palette + 4*bitmap_memory[(long)((northing-miny))*bitmap_width + (long)((easting-minx))]; pal = bitmap_palette + 4*bitmap_memory[(long)((northing-miny)/dTileScale)*bitmap_width + (long)((easting-minx)/dTileScale)]; } else { pal = bitmap_palette + 4*bitmap_memory[(long)((maxy-northing)/dTileScale)*bitmap_width + (long)((easting-minx)/dTileScale)]; } *dest_bitmap_offset++ = pal[0]; *dest_bitmap_offset++ = pal[1]; *dest_bitmap_offset++ = pal[2]; } } } bmp.UnlockBits(&bmpData); wchar_t wbuffer[64]; int i; for (i=0; i<pTile->fname.GetLength(); i++) wbuffer[i] = pTile->fname.GetAt(i); wbuffer[i] = 0; bmp.Save(wbuffer, &encoderClsid, &encoderParameters); } fprintf(fp, "</Document>\n" "</kml>\n"); fclose(fp); // Add jpegs / kml to kmz file DeleteFile(kmzName); ZipFileAdd(kmzName, "doc.kml"); DeleteFile("doc.kml"); long indexZip = 1; wndProgress.m_progress_bar.SetRange(1, tiles.GetCount()); for (pos=tiles.GetHeadPosition(); pos != NULL; tiles.GetNext(pos)) { JPEG_tile * pTile = (JPEG_tile *)tiles.GetAt(pos); wndProgress.m_progress_bar.SetPos(indexZip); wndProgress.m_edit_message.Format("Zip: %d of %d", indexZip++, tiles.GetCount()); wndProgress.UpdateData(FALSE); DoEvents(); ZipFileAdd(kmzName, pTile->fname); DeleteFile(pTile->fname); } RemoveDirectory("files"); SetCurrentDirectory(Currdir); tiles.RemoveAll(); if (nPoints) { free(points); nPoints = 0; points = NULL; } Gdiplus::GdiplusShutdown(gdiplusToken); free(bitmap_memory); return true; }
static int GetKeyPress(void) { int keycode; if (UI_alt_function >= 0) return 0x1b; /* escape - go to Main Menu */ PLATFORM_DisplayScreen(); for (;;) { static int rep = KB_DELAY; if (PLATFORM_Keyboard() == AKEY_NONE) { rep = KB_DELAY; break; } if (rep == 0) { rep = KB_AUTOREPEAT; break; } rep--; Atari800_Sync(); } do { #ifdef DIRECTX DoEvents(); #endif Atari800_Sync(); keycode = PLATFORM_Keyboard(); switch (keycode) { case AKEY_WARMSTART: UI_alt_function = UI_MENU_RESETW; return 0x1b; /* escape */ case AKEY_COLDSTART: UI_alt_function = UI_MENU_RESETC; return 0x1b; /* escape */ case AKEY_EXIT: UI_alt_function = UI_MENU_EXIT; return 0x1b; /* escape */ case AKEY_UI: #ifdef DIRECTX UI_Run(); #else if (UI_alt_function >= 0) /* Alt+letter, not F1 */ #endif return 0x1b; /* escape */ break; case AKEY_SCREENSHOT: UI_alt_function = UI_MENU_PCX; return 0x1b; /* escape */ case AKEY_SCREENSHOT_INTERLACE: UI_alt_function = UI_MENU_PCXI; return 0x1b; /* escape */ default: UI_alt_function = -1; /* forget previous Main Menu shortcut */ break; } } while (keycode < 0); return UI_BASIC_key_to_ascii[keycode]; }
void PublishExcelToPDFWithWorkBook(Excel::_WorkbookPtr spWorkbook, const CStdString& sOutputFile, int from, int to) { LOG_WS_FUNCTION_SCOPE(); CStdString restrictionLevel = c_sNoRestriction; CStdString classification = c_sNoClassification; try { _variant_t vSaved = spWorkbook->Saved; restrictionLevel = GetRestrictionLevel(spWorkbook); classification = GetClassification(spWorkbook); // TODO: Switch off Excel's attempt to match the printer's paper size // by temporarily setting spWorkbook->Application->MapPaperSize = VARIANT_FALSE. // But that option isn't available in the Excel 2000 API that we're using. bool bIsNotExcel97 = (atof(spWorkbook->Application->Version) > 8.0); if( !PDFConverterController::UseExcelPrintArea() ) { for (int iIndex = 1; iIndex <= spWorkbook->Worksheets->Count; iIndex++) { Excel::_WorksheetPtr spWorksheet = spWorkbook->Worksheets->Item[ iIndex ]; spWorksheet->PageSetup->PrintArea = _T(""); } } PDFConverterController pdfConverter; pdfConverter.InitialisePDFConverterUseFileName(sOutputFile, VARIANT_TRUE); _variant_t vtPrintToFile(false); _variant_t vtActivePrinter(c_sPDFDriverName); _variant_t vtOutputFile(sOutputFile); _variant_t vtFrom(vtMissing); _variant_t vtTo(vtMissing); if (from != 0 || to != 0) { vtFrom = from; vtTo = to; } if(bIsNotExcel97) { //60.18: This msg loop is to prevent the 'known' issue with Workshare events from crashing. DoEvents(); spWorkbook->PrintOut(&vtFrom, &vtTo, &vtMissing, &vtMissing, &vtActivePrinter, &vtPrintToFile, &vtMissing, &vtOutputFile); } else { if (::PathFileExists(sOutputFile) && !::DeleteFile(sOutputFile)) { CStdString sMsg; sMsg.Format(_T("Failed to overwrite file %s"), sOutputFile.c_str()); throw Workshare::System::IO::IOException(sMsg); } DismissPrintDialog(sOutputFile); _variant_t vtResult; IDispatchPtr spDispDocument = spWorkbook; HRESULT hr = CCOMDispatchHelper::AutoWrap(DISPATCH_METHOD, &vtResult, spDispDocument, L"PrintOut", 7, vtMissing, vtPrintToFile, vtActivePrinter, vtMissing, vtMissing, vtMissing, vtMissing); if (FAILED(hr)) throw Workshare::Com::ComException(_T("Failed to invoke PrintOut method"), hr, spDispDocument); } pdfConverter.UnInitialisePDFConverter(); // Setting the following property fixes an issue in the Office - iManage integration, // in which iManage appears to query the Saved flag on Close and pops up a dialog, // even though we have specified to Close with no Save: LCID lCid = LocaleHelper::GetLocaleIDForInstalledExcel(spWorkbook); spWorkbook->put_Saved(lCid, vSaved); if(c_sNoRestriction != restrictionLevel) SetPdfRestrictionLevel(sOutputFile, restrictionLevel); if (c_sNoClassification != classification) SetPdfClassification(sOutputFile, classification); } catch(const Workshare::Exception&) { throw; } catch(...) { unexpected(); } }
HRESULT CTryData4Dlg::OnClickUrl(IHTMLElement* pElement) { CString sel = this->GetAttribute(pElement,m_elemTypes[0]); UINT newPage=0xffff; while(m_cmdStep != CMD_IDLEHTML) DoEvents(); if(sel.Find("#page_") > 0) { if(m_State == RUNNING) return S_OK; if(m_bAddData) InternalRoutines('9'); //update the 测量结果 if(sel.Find("#page_reg") > 0) newPage = INDEX; if(sel.Find("#page_data") > 0) newPage = DATA; if(sel.Find("#page_config")>0) newPage = CONFIG; if(sel.Find("#page_jh")>0) newPage = JIAOHE; if(sel.Find("#page_report")>0) newPage = REPORT; if(sel.Find("#page_quit") > 0 ) { if(IDYES != MessageBox("是否确定退出?","电阻校验",MB_YESNO)) return S_OK; m_currPage = 0; PostMessage(WM_CLOSE,1,0); return S_OK; } if((newPage != 0xffff)&&(newPage != m_currPage)) { m_cmdStep = CMD_LOADHTML; m_currPage = newPage; } } if(sel.Find("prg_") > 0) { if(sel.Find("#prg_start") > 0) { if(m_State == RUNNING) { CString str("暂停测量"); SetElementText("pause",str.AllocSysString()); if(IDNO == MessageBox("是否继续测量?","电阻校验",MB_YESNO)) { m_State = BEERROR; Abort(); } return S_OK; } if(m_bAddData) InternalRoutines('9'); //update the 测量结果 if(!m_Program.InstallScheme(PathQuery2(CLSGROUP,IDTYPE))) { MessageBox("程序装载失败","电阻校验",MB_OK); return S_OK; } if(m_Program.SetFunctionPointer("MAIN")) { CString str("暂停测量"); m_pChartDlg->DeleteAll(); g_TesterConf.m_iRetestID = -1; m_State = RUNNING; SetElementText("pause",str.AllocSysString()); m_bAddData = true; }; } } if(sel.Find("data_") > 0) { if(sel.Find("data_chart") > 0) { m_pChartDlg->ShowWindow(SW_NORMAL); } if(sel.Find("data_modnbz") > 0) { if(m_State == RUNNING) return S_OK; InternalRoutines('a'); AfxMessageBox("内标准设置修改成功"); } } return S_OK; }
bool CMktStructureBaseDlg::StartDownload(bool bDoSubscribe ) { m_edLog.SetWindowText (_T("")); m_bCanceled = false; m_nCounter = 0; m_pgContract.SetPos (0); g_DataProcessor.CancelData(); Sleep(1000); m_bFeedStopped = true; try { StatusMessage (IDS_MKTSTRUCTURE_INITDATA); if (m_stocks.size() == 0 ) { CDBLayout db; db.Connect(); CClientRecordset rs; db.GetSymbols(rs); for (; ! rs.IsEOF() ;++rs) { DoEvents(); if (m_bCanceled) false; CContractRequestData crd = (int) rs["iContractID"]; crd.m_bGotYield = (int) rs[L"iContractTypeID"] != 1; m_stocks[ rs[L"vcSymbolName"] ] = crd; } db.Disconnect(); } else if (m_stocks.size() == 1) { CContractRequestData & crd = m_stocks.begin()->second; _bstr_t bsFirast = m_stocks.begin()->first; if ( crd.m_nID != 0) { CDBLayout db; db.Connect(); CClientRecordset rs; db.GetSymbolParams( crd.m_nID, rs); if (! rs.IsEOF()) crd.m_bGotYield = (int) rs[L"iContractTypeID"] != 1; db.Disconnect(); } } m_pgContract.SetRange32 (0, m_stocks.size()*m_nPosPerContract); m_pgContract.SetStep (1); if (m_stocks.size() > 0 ) { if (! m_bConnected ) { StatusMessage (IDS_MKTSTRUCTURE_CONNECTING); m_spStructureInfo->Connect(); m_bConnected = true; StatusMessage (IDS_MKTSTRUCTURE_REQUESTING); } m_itCur = m_stocks.begin(); if (bDoSubscribe) SubscribeNextStock (); } else { StatusMessage (IDS_MKTSTRUCTURE_ERR_NOSTOCKS); Stop(); return false; } return true; } catch (_com_error & e) { ErrorMessage(e); Stop(); } return false; }
void do_events (void) { DoEvents (hMainWindow); }
STDMETHODIMP CFACE::Download( BSTR URL, BSTR DownloadFile ){ USES_CONVERSION; HANDLE hFile; TCHAR DownloadTo[ MAX_PATH ] , TXT[ 256 ] ; HWND hDialog; LogBegin( "File Download Method" ); LogPut( CONTINUE , IDS_LOG_DOWNLOAD , URL ); // ユーザーフォルダ名を取得 // ダイアログの作成 hDialog = CreateDialog( hInst ,MAKEINTRESOURCE( IDD_DownLoading ) , hWnd , (DLGPROC)DownLoadProc ); wsprintf( TXT , _T( "%s \nDown To : %s " ) , OLE2T( URL ) , OLE2T( DownloadFile ) ); SetWindowText( GetDlgItem( hDialog , IDC_Down ) ,TXT ); // そこに、ファイル名を追加することで、ダウンロード先の完成 wsprintf( DownloadTo , _T( "%s\\%s" ) , FACEDir , OLE2T( DownloadFile ) ); // ダウンロードを行う関数をロード DWORD dwBytesWrite , dwBytesRead , dwBytesAvailable , dwTotalRead = 0; BYTE *Buffer; // DLL関数初期化 HANDLE hInternet = InternetOpen( _T( "FACE Download Method" ) , INTERNET_OPEN_TYPE_PRECONFIG , NULL , NULL , 0 ) , hInternetFile = InternetOpenUrl( hInternet , OLE2T( URL ) , NULL , 0 ,0 , 0 ); LogPut( CONTINUE , IDS_LOG_DOWNLOAD , OLE2T( URL ) ); if ( hInternet == NULL || hInternetFile == NULL ) LogPut( FATAL , IDS_ERR_CANTDOWNLOAD ); // 最適サイズ取得 InternetQueryDataAvailable( hInternetFile , &dwBytesAvailable, 0, 0 ); Buffer = (BYTE*)malloc( dwBytesAvailable + 1 ); // タイムアウト設定 DWORD TimeOut; TimeOut = 30 * 1000; // ここでは30秒に指定しています。 InternetSetOption( hInternetFile, INTERNET_OPTION_RECEIVE_TIMEOUT, &TimeOut, sizeof(TimeOut) ); // インターネットファイルの更新日時をクエリー SYSTEMTIME LastModified; dwBytesRead = sizeof(LastModified); HttpQueryInfo( hInternetFile , HTTP_QUERY_LAST_MODIFIED | HTTP_QUERY_FLAG_SYSTEMTIME , &LastModified , &dwBytesRead , 0 ); // ファイルがすでにある場合は更新日時をチェック if ( ( hFile = CreateFile( DownloadTo , GENERIC_WRITE , 0 , NULL , OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL ) ) != INVALID_HANDLE_VALUE ){ // 更新日時の比較 FILETIME ft2,ft1; SystemTimeToFileTime( &LastModified , &ft2 ); FileTimeToLocalFileTime( &ft2 , &ft1 ); GetFileTime( hFile , NULL , NULL , &ft2 ); CloseHandle( hFile ); } hFile = CreateFile( DownloadTo , GENERIC_WRITE , 0 , NULL , CREATE_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL ); LONG x = -40 , ax = 1; // Progressing do{ ZeroMemory( Buffer , sizeof(Buffer) ); // ダウンロード InternetReadFile( hInternetFile , Buffer , dwBytesAvailable , &dwBytesRead ); sprintf( TXT , _T( " 最適レート / 実ダウン : %d / %d Bytes" ) , dwBytesAvailable , dwBytesRead ); SetWindowText( GetDlgItem( hDialog , IDC_Down3 ) , TXT ); /* -- ダウンロード総容量の表示 -- */ dwTotalRead += dwBytesRead; if ( dwTotalRead < 1000000 ) sprintf( TXT , _T( " ダウンロード済みサイズ : %.3g KBytes" ) , (double)dwTotalRead / 1024 ); else sprintf( TXT , _T( " ダウンロード済みサイズ : %.3g MBytes " ) , (double)dwTotalRead / 1024 / 1024 ); SetWindowText( GetDlgItem( hDialog , IDC_Down2 ) , TXT ); // ダウンロード進行を示す プログレス x += ax; HDC hDC = GetDC( GetDlgItem( hDialog , IDC_PROGRESS1 ) ); RECT RT ; GetClientRect( GetDlgItem( hDialog , IDC_PROGRESS1 ) , &RT ); if ( x < RT.left- 40 || x > RT.right + 30 ) ax *= -1; FillRect( hDC , &RT , (HBRUSH)( COLOR_BTNFACE + 1 ) ); SetRect( &RT, x , 0 , x + 30 , 10 ); FillRect( hDC , &RT , (HBRUSH)( COLOR_ACTIVECAPTION + 1 ) ); ReleaseDC( GetDlgItem( hDialog , IDC_PROGRESS1 ) , hDC ); Buffer [ dwBytesRead ] = 0; WriteFile( hFile , Buffer , dwBytesRead , &dwBytesWrite , NULL ); BOOL END; DoEvents( &END );if (END)break; }while ( dwBytesRead > 0 ); InternetCloseHandle( hInternetFile ); InternetCloseHandle( hInternet ); CloseHandle( hFile ); DestroyWindow( hDialog ); LogQuit( ); return S_OK; }
BOOL CMD_DUMPCART (void) { int dtype = 2; int rbyte = 0, rcount = 0; PPlugin plugin; char *path, *ext; char filename[MAX_PATH]; char fnamebuf[MAX_PATH]; int cmode, battery, bytes, numk; int mapper,submapper=0; int nes2=0, wram=0, vram=0; BYTE ctype; WORD nblks; char Status[256]; FILE *CRC, *DATA; // select board name plugin = PromptPlugin(PLUG_STD); if (plugin == NULL) return FALSE; mapper = plugin->num; PromptTitle = "Choose a ROM filename (omit extension)"; if (!Prompt(topHWnd)) return FALSE; strcpy(filename,PromptResult); OpenStatus(topHWnd); StatusText("Resetting USB CopyNES..."); ResetNES(RESET_COPYMODE); StatusText("Unloading any existing plugin..."); if (!LoadPlugin("clear.bin")) { CloseStatus(); return FALSE; } RunCode(); Sleep(SLEEP_SHORT); StatusText("Resetting USB CopyNES..."); ResetNES(RESET_COPYMODE); StatusText("Loading plugin..."); if (!LoadPlugin(plugin->file)) { CloseStatus(); return FALSE; } StatusText("Running plugin..."); RunCode(); Sleep(SLEEP_LONG); if (SaveCRC) CRC = fopen(strjoin3(fnamebuf,Path_CRC,filename,".txt"),"wb"); cmode = 0; if (!ReadByte((BYTE *)&cmode)) // mirroring { CloseStatus(); return FALSE; } battery = 0; while (1) { // for the first 'header' byte, wait longer than usual // since the plugin might be busy doing size detection, which can take a while int s; if (!ReadByteEx((BYTE *)&nblks,10,TRUE) || !ReadByte((BYTE *)&nblks+1)) { CloseStatus(); return FALSE; } bytes = nblks << 8; numk = bytes / 1024; if (!ReadByte(&ctype)) { CloseStatus(); return FALSE; } if (ctype == 0) break; switch (ctype) { case 1: ext = ".prg"; if(numk >= 4096) nes2 = 1; path = Path_PRG; sprintf(Status,"Dumping %iK PRG ROM...",numk); break; case 2: ext = ".chr"; if(numk >= 2048) nes2 = 1; path = Path_CHR; sprintf(Status,"Dumping %iK CHR ROM...",numk); break; case 3: ext = ".sav"; path = Path_WRAM; sprintf(Status,"Dumping %iK WRAM/VRAM...",numk); battery = 1; break; case 4: rbyte = nblks / 4; continue; case 5: nes2 = 1; wram = nblks & 0xFF; vram = nblks >> 8; if(wram & 0xF0) battery = 1; if(vram & 0xF0) battery = 1; sprintf(Status,"Non battery WRAM size: %i Bytes...", ((wram & 0x0f)?64 << (wram & 0x0F):0)); StatusText(Status); sprintf(Status,"battery WRAM size: %i Bytes...", ((wram >> 4)?64 << (wram & 0x0F):0)); StatusText(Status); sprintf(Status,"Non battery VRAM size: %i Bytes...", ((vram & 0x0f)?64 << (vram & 0x0F):0)); StatusText(Status); sprintf(Status,"battery VRAM size: %i Bytes...", ((vram >> 4)?64 << (vram & 0x0F):0)); StatusText(Status); continue; case 6: //Mapper number override by plugin. mapper = nblks & 0xFFF; submapper = (nblks & 0xF000) >> 12; sprintf(Status,"Mapper number: %i, submapper: %i...",mapper,submapper); StatusText(Status); if((mapper > 255) || (submapper > 0)) nes2 = 1; continue; case 255: sprintf(Status,"."); continue; //Prevent timeout. default:StatusText("Unknown block type %i! Aborting...",ctype); StatusOK(); return FALSE; break; } StatusText(Status); DATA = fopen(strjoin3(fnamebuf,path,filename,ext),"w+b"); if (DATA == NULL) { StatusText("Unable to open output file!"); StatusOK(); return FALSE; } for (s = 0; s < numk; s++) { int a; BYTE n; for (a = 0; a < 1024; a++) { if (!ReadByte(&n)) { CloseStatus(); return FALSE; } fwrite(&n,1,1,DATA); } if (rbyte) { rcount++; if (rbyte <= rcount) { rcount = 0; StatusText("Resetting USB CopyNES as requested by plugin..."); ResetNES(RESET_COPYMODE); StatusText("Reloading plugin..."); LoadPlugin(plugin->file); StatusText("Rerunning plugin..."); RunCode(); rbyte = 0; if (!ReadByte((BYTE *)&rbyte) || !ReadByte((BYTE *)&rbyte+1)) { CloseStatus(); return FALSE; } rbyte /= 4; } } StatusPercent((s*100)/numk); DoEvents(); } StatusPercent(100); StatusText("...done!"); if (SaveCRC) fprintf(CRC,"%s%s %08X\n",filename,ext,GetCRC(DATA)); fclose(DATA); } if (SaveCRC) fclose(CRC); StatusText("Dump complete!"); StatusOK(); ResetNES(RESET_COPYMODE); { int scrn4 = (cmode & 0x2) >> 1; int mirror = (~cmode & 0x1); int mcon = (cmode & 0x4) >> 2; if (plugin->num == 9999) return TRUE; WriteNES(filename,mapper,battery,mirror,scrn4,nes2,wram,vram,submapper,0); if (MakeUnif == 1) WriteUNIF(filename,plugin->name,battery,mirror,scrn4,mcon); if (SaveFiles == 0) { unlink(strjoin3(fnamebuf,Path_CHR,filename,".chr")); unlink(strjoin3(fnamebuf,Path_PRG,filename,".prg")); } } return TRUE; }
/* Build the list of games in the open file f. * Returns 0 for success or error number. */ int GameListBuild (FILE *f) { ChessMove cm, lastStart; int gameNumber; ListGame *currentListGame = NULL; int error, scratch=100, plyNr=0, fromX, fromY, toX, toY; int offset; char lastComment[MSG_SIZ], buf[MSG_SIZ]; TimeMark t, t2; GetTimeMark(&t); GameListFree(&gameList); yynewfile(f); gameNumber = 0; movePtr = 0; lastStart = (ChessMove) 0; yyskipmoves = FALSE; do { yyboardindex = scratch; offset = yyoffset(); quickFlag = plyNr + 1; cm = (ChessMove) Myylex(); switch (cm) { case GNUChessGame: if ((error = GameListNewGame(¤tListGame))) { rewind(f); yyskipmoves = FALSE; return(error); } currentListGame->number = ++gameNumber; currentListGame->offset = offset; if(1) { CopyBoard(boards[scratch], initialPosition); plyNr = 0; currentListGame->moves = PackGame(boards[scratch]); } if (currentListGame->gameInfo.event != NULL) { free(currentListGame->gameInfo.event); } currentListGame->gameInfo.event = StrSave(yy_text); lastStart = cm; break; case XBoardGame: lastStart = cm; break; case MoveNumberOne: switch (lastStart) { case GNUChessGame: break; /* ignore */ case PGNTag: lastStart = cm; break; /* Already started */ case (ChessMove) 0: case MoveNumberOne: case XBoardGame: if ((error = GameListNewGame(¤tListGame))) { rewind(f); yyskipmoves = FALSE; return(error); } currentListGame->number = ++gameNumber; currentListGame->offset = offset; if(1) { CopyBoard(boards[scratch], initialPosition); plyNr = 0; currentListGame->moves = PackGame(boards[scratch]); } lastStart = cm; break; default: break; /* impossible */ } break; case PGNTag: lastStart = cm; if ((error = GameListNewGame(¤tListGame))) { rewind(f); yyskipmoves = FALSE; return(error); } currentListGame->number = ++gameNumber; currentListGame->offset = offset; ParsePGNTag(yy_text, ¤tListGame->gameInfo); do { yyboardindex = 1; offset = yyoffset(); cm = (ChessMove) Myylex(); if (cm == PGNTag) { ParsePGNTag(yy_text, ¤tListGame->gameInfo); } } while (cm == PGNTag || cm == Comment); if(1) { int btm=0; if(currentListGame->gameInfo.fen) ParseFEN(boards[scratch], &btm, currentListGame->gameInfo.fen, FALSE); else CopyBoard(boards[scratch], initialPosition); plyNr = (btm != 0); currentListGame->moves = PackGame(boards[scratch]); } if(cm != NormalMove) break; case IllegalMove: if(appData.testLegality) break; case NormalMove: /* Allow the first game to start with an unnumbered move */ yyskipmoves = FALSE; if (lastStart == (ChessMove) 0) { if ((error = GameListNewGame(¤tListGame))) { rewind(f); yyskipmoves = FALSE; return(error); } currentListGame->number = ++gameNumber; currentListGame->offset = offset; if(1) { CopyBoard(boards[scratch], initialPosition); plyNr = 0; currentListGame->moves = PackGame(boards[scratch]); } lastStart = MoveNumberOne; } case WhiteCapturesEnPassant: case BlackCapturesEnPassant: case WhitePromotion: case BlackPromotion: case WhiteNonPromotion: case BlackNonPromotion: case WhiteKingSideCastle: case WhiteQueenSideCastle: case BlackKingSideCastle: case BlackQueenSideCastle: case WhiteKingSideCastleWild: case WhiteQueenSideCastleWild: case BlackKingSideCastleWild: case BlackQueenSideCastleWild: case WhiteHSideCastleFR: case WhiteASideCastleFR: case BlackHSideCastleFR: case BlackASideCastleFR: fromX = currentMoveString[0] - AAA; fromY = currentMoveString[1] - ONE; toX = currentMoveString[2] - AAA; toY = currentMoveString[3] - ONE; plyNr++; ApplyMove(fromX, fromY, toX, toY, currentMoveString[4], boards[scratch]); if(currentListGame && currentListGame->moves) PackMove(fromX, fromY, toX, toY, boards[scratch][toY][toX]); break; case WhiteWins: // [HGM] rescom: save last comment as result details case BlackWins: case GameIsDrawn: case GameUnfinished: if(!currentListGame) break; if(currentListGame->gameInfo.result == GameUnfinished) currentListGame->gameInfo.result = cm; // correct result tag with actual result if (currentListGame->gameInfo.resultDetails != NULL) { free(currentListGame->gameInfo.resultDetails); } if(yy_text[0] == '{') { char *p; safeStrCpy(lastComment, yy_text+1, sizeof(lastComment)/sizeof(lastComment[0])); if((p = strchr(lastComment, '}'))) *p = 0; currentListGame->gameInfo.resultDetails = StrSave(lastComment); } break; default: break; } if(gameNumber % 1000 == 0) { snprintf(buf, MSG_SIZ, _("Reading game file (%d)"), gameNumber); DisplayTitle(buf); DoEvents(); } } while (cm != (ChessMove) 0); if(currentListGame) { if(!currentListGame->moves) DisplayError("Game cache overflowed\nPosition-searching might not work properly", 0); if (appData.debugMode) { for (currentListGame = (ListGame *) gameList.head; currentListGame->node.succ; currentListGame = (ListGame *) currentListGame->node.succ) { fprintf(debugFP, "Parsed game number %d, offset %ld:\n", currentListGame->number, currentListGame->offset); PrintPGNTags(debugFP, ¤tListGame->gameInfo); } } } if(appData.debugMode) { GetTimeMark(&t2);printf("GameListBuild %ld msec\n", SubtractTimeMarks(&t2,&t)); } quickFlag = 0; PackGame(boards[scratch]); // for appending end-of-game marker. DisplayTitle("WinBoard"); rewind(f); yyskipmoves = FALSE; return 0; }