static void LoadMapObject(MapObject *m, json_t *node) { memset(m, 0, sizeof *m); m->Idx = -1; LoadInt(&m->Idx, node, "Index"); m->Name = GetString(node, "Name"); LoadPic(&m->Normal.Pic, node, "Pic", "OldPic"); LoadPic(&m->Wreck.Pic, node, "WreckPic", "OldWreckPic"); if (m->Normal.Pic) { // Default offset: centered X, align bottom of tile and sprite m->Normal.Offset = Vec2iNew( -m->Normal.Pic->size.x / 2, TILE_HEIGHT / 2 - m->Normal.Pic->size.y); LoadVec2i(&m->Normal.Offset, node, "Offset"); } if (m->Wreck.Pic) { m->Wreck.Offset = Vec2iScaleDiv(m->Wreck.Pic->size, -2); LoadVec2i(&m->Wreck.Offset, node, "WreckOffset"); } // Default tile size m->Size = Vec2iNew(TILE_WIDTH, TILE_HEIGHT); LoadVec2i(&m->Size, node, "Size"); LoadInt(&m->Health, node, "Health"); LoadBulletGuns(&m->DestroyGuns, node, "DestroyGuns"); json_t *flagsNode = json_find_first_label(node, "Flags"); if (flagsNode != NULL && flagsNode->child != NULL) { for (json_t *flagNode = flagsNode->child->child; flagNode; flagNode = flagNode->next) { m->Flags |= 1 << StrPlacementFlag(flagNode->text); } } // Special types JSON_UTILS_LOAD_ENUM(m->Type, node, "Type", StrMapObjectType); switch (m->Type) { case MAP_OBJECT_TYPE_NORMAL: // Do nothing break; case MAP_OBJECT_TYPE_PICKUP_SPAWNER: { char *tmp = GetString(node, "Pickup"); m->u.PickupClass = StrPickupClass(tmp); CFREE(tmp); } break; default: CASSERT(false, "unknown error"); break; } }
void ImageWndPicWnd::OnDropFiles(HDROP hDropInfo) { char buf[1000]; CString T,T2; GetWindowText(T2); DragQueryFile(hDropInfo,0xFFFFFFFF,buf,1000); DragQueryFile(hDropInfo,0,buf,1000); T=CString(buf); MyTimer Timer1; sec time; CString logT; LogMessage *log=new LogMessage(); log->CreateEntry("Log","Speed tests results",LogMessage::low_pr); Timer1.Start(); LoadPic(T); Timer1.Stop(); time=Timer1.GetValue(); logT.Format("%s org (%.2f Mpix) load time=%s",T2,org.w*org.h/1.e6,ConvTimeToStr(time)); log->Msgs.Add(logT); CKSVU3App* Parent=(CKSVU3App*)AfxGetApp(); Parent->myThread.PostParentMessage(UM_GENERIC_MESSAGE,log); CWnd::OnDropFiles(hDropInfo); }
//--------------------------------------------------------------------- void __fastcall TLogPicDlg::Execute(LPCSTR pNote) { char bf[256]; strcpy(bf, pNote); LPSTR t; LPSTR p = bf; m_Cur = 0; m_Cnt = 0; while(*p){ p = StrDlm(t, p); if( IsDateFormat(t) ){ m_List[m_Cnt] = t; m_Cnt++; if( m_Cnt >= 5 ) break; } } LoadPic(); ShowModal(); }
static LRESULT CALLBACK GEPProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { HGLOBAL hglob; logo_data * gep_gun; if (msg == WM_NCCREATE) { HMODULE hInst = core_api::get_my_instance(); hglob = GlobalAlloc(GMEM_MOVEABLE,sizeof(logo_data)); gep_gun = (logo_data *) GlobalLock(hglob); gep_gun->frame = 0; gep_gun->logos[0] = LoadPic(MAKEINTRESOURCE(IDB_LOGO1), _T("JPG"), hInst); gep_gun->logos[1] = LoadPic(MAKEINTRESOURCE(IDB_LOGO2), _T("JPG"), hInst); IPicture_getHandle(gep_gun->logos[0], (OLE_HANDLE *)&gep_gun->frames[0]); IPicture_getHandle(gep_gun->logos[1], (OLE_HANDLE *)&gep_gun->frames[1]); BITMAP bm; GetObject( gep_gun->frames[0], sizeof(bm), &bm ); gep_gun->ptSize.x = bm.bmWidth; gep_gun->ptSize.y = bm.bmHeight; BITMAPINFOHEADER bmih; bmih.biSize = sizeof(bmih); bmih.biWidth = bm.bmWidth; bmih.biHeight = bm.bmHeight; bmih.biPlanes = bm.bmPlanes; bmih.biBitCount = bm.bmBitsPixel; bmih.biCompression = BI_RGB; bmih.biSizeImage = 0; bmih.biXPelsPerMeter = 0; bmih.biYPelsPerMeter = 0; bmih.biClrUsed = 0; bmih.biClrImportant = 0; BYTE * gfx; gep_gun->backbuffer = CreateDIBSection(0, (const BITMAPINFO *) &bmih, DIB_RGB_COLORS, (VOID **) &gfx, 0, 0); SetWindowLong( wnd, GWL_USERDATA, (LONG) hglob ); SetWindowPos( wnd, 0, 0, 0, gep_gun->ptSize.x, gep_gun->ptSize.y, SWP_NOMOVE | SWP_NOREDRAW | SWP_NOZORDER); SetTimer( wnd, 666, 10, 0 ); } else { hglob = (HGLOBAL) GetWindowLong( wnd, GWL_USERDATA ); if (hglob == NULL) return DefWindowProc(wnd, msg, wp, lp); gep_gun = (logo_data *) GlobalLock(hglob); } switch (msg) { case WM_TIMER: if (wp == 666) { gep_gun->frame++; if (gep_gun->frame >= 1000) gep_gun->frame = 0; if (!gep_gun->frame || (gep_gun->frame >= 400 && gep_gun->frame <= 500) || (gep_gun->frame >= 900)) { RECT rc; GetClientRect( wnd, &rc ); InvalidateRect( wnd, &rc, FALSE ); } } break; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint( wnd, &ps ); HDC hdcMem, hdcBB; HBITMAP hbmOld, hbmOldBB; BLENDFUNCTION func = { AC_SRC_OVER, 0, 0, 0 }; ps.rcPaint.right -= ps.rcPaint.left; ps.rcPaint.bottom -= ps.rcPaint.top; if (gep_gun->frame < 400) { hdcMem = CreateCompatibleDC( hdc ); hbmOld = (HBITMAP) SelectObject( hdcMem, gep_gun->frames[0] ); BitBlt( hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom, hdcMem, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); SelectObject( hdcMem, hbmOld ); DeleteDC( hdcMem ); } else if (gep_gun->frame < 500) { hdcBB = CreateCompatibleDC( hdc ); hbmOldBB = (HBITMAP) SelectObject( hdcBB, gep_gun->backbuffer ); hdcMem = CreateCompatibleDC( hdc ); hbmOld = (HBITMAP) SelectObject( hdcMem, gep_gun->frames[0] ); BitBlt( hdcBB, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom, hdcMem, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); SelectObject( hdcMem, gep_gun->frames[1] ); func.SourceConstantAlpha = (gep_gun->frame - 400) * 255 / 100; AlphaBlend( hdcBB, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom, hdcMem, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom, func); SelectObject( hdcMem, hbmOld ); DeleteDC( hdcMem ); BitBlt( hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom, hdcBB, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); SelectObject( hdcBB, hbmOldBB ); DeleteDC( hdcBB ); } else if (gep_gun->frame < 900) { hdcMem = CreateCompatibleDC( hdc ); hbmOld = (HBITMAP) SelectObject( hdcMem, gep_gun->frames[1] ); BitBlt( hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom, hdcMem, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); SelectObject( hdcMem, hbmOld ); DeleteDC( hdcMem ); } else if (gep_gun->frame < 1000) { hdcBB = CreateCompatibleDC( hdc ); hbmOldBB = (HBITMAP) SelectObject( hdcBB, gep_gun->backbuffer ); hdcMem = CreateCompatibleDC( hdc ); hbmOld = (HBITMAP) SelectObject( hdcMem, gep_gun->frames[1] ); BitBlt( hdcBB, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom, hdcMem, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); SelectObject( hdcMem, gep_gun->frames[0] ); func.SourceConstantAlpha = (gep_gun->frame - 900) * 255 / 100; AlphaBlend( hdcBB, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom, hdcMem, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom, func); SelectObject( hdcMem, hbmOld ); DeleteDC( hdcMem ); BitBlt( hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom, hdcBB, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); SelectObject( hdcBB, hbmOldBB ); DeleteDC( hdcBB ); } EndPaint( wnd, &ps ); } break; /*case WM_LBUTTONDOWN: PlaySound(LPCSTR(IDR_COUGH), core_api::get_my_instance(), SND_RESOURCE | SND_ASYNC); break;*/ case WM_DESTROY: KillTimer( wnd, 666 ); SetWindowLong( wnd, GWL_USERDATA, 0 ); IPicture_Release(gep_gun->logos[0]); IPicture_Release(gep_gun->logos[1]); DeleteObject(gep_gun->backbuffer); GlobalUnlock(hglob); GlobalFree(hglob); return 0; } GlobalUnlock(hglob); return uDefWindowProc(wnd, msg, wp, lp); }
BOOL CALLBACK infoDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { char Buffer[1024]; char *LFpsftag; //char LFpsftag[50001]; DWORD c,d; IPicture * pPicture; HANDLE surpriseImage; int randNum; switch (uMsg) { case WM_CLOSE: if(decode_pos_ms >= TrackLength-FadeLength) TrackLength=decode_pos_ms+FadeLength; EndDialog(hDlg,TRUE); return 0; case WM_INITDIALOG: pimpbot = FALSE; randNum = rand(); SetWindowLong(hDlg, DWL_USER, (LONG)0); if (PepperisaGoodBoy) { pPicture = NULL; if (randNum < RAND_MAX*0.025) // 1/10th a chance of occurring { pPicture = LoadPic(MAKEINTRESOURCE(IDB_BIGKITTY), "JPG", mod.hDllInstance); } else if (randNum >= RAND_MAX*0.025 && randNum < RAND_MAX*0.05) { pPicture = LoadPic(MAKEINTRESOURCE(IDB_PIMPBOT), "JPG", mod.hDllInstance); pimpbot = TRUE; } else if (randNum >= RAND_MAX*0.05 && randNum < RAND_MAX*0.1) { pPicture = LoadPic(MAKEINTRESOURCE(IDB_PEPPER), "JPG", mod.hDllInstance); } if (pPicture) { if (IPicture_getHandle(pPicture, (OLE_HANDLE *)&surpriseImage) == S_OK) { SendMessage( GetDlgItem(hDlg, IDC_LOGO), STM_SETIMAGE, IMAGE_BITMAP, (long)surpriseImage); //change the logo graphic SetWindowLong(hDlg, DWL_USER, (LONG)pPicture); } else { IPicture_Release(pPicture); } } } if(infoDlgDisableTimer) { CheckDlgButton(hDlg,IDC_DTIMER,BST_CHECKED); playforever=1; } SetinfoDlgText(hDlg); break; case WM_LBUTTONDOWN: if (pimpbot) { if (rand() > RAND_MAX/2) PlaySound((LPCSTR)IDR_PIMPBOT1, mod.hDllInstance, SND_RESOURCE|SND_ASYNC); else PlaySound((LPCSTR)IDR_PIMPBOT2, mod.hDllInstance, SND_RESOURCE|SND_ASYNC); } break; case WM_COMMAND: switch (GET_WM_COMMAND_ID(wParam, lParam)) { case IDOK: GetDlgItemText(hDlg,IDC_TITLE,Buffer,1024); psftag_raw_setvar(infoDlgpsftag,50000-1,"title",Buffer); GetDlgItemText(hDlg,IDC_ARTIST,Buffer,1024); psftag_raw_setvar(infoDlgpsftag,50000-1,"artist",Buffer); GetDlgItemText(hDlg,IDC_GAME,Buffer,1024); psftag_raw_setvar(infoDlgpsftag,50000-1,"game",Buffer); GetDlgItemText(hDlg,IDC_YEAR,Buffer,1024); psftag_raw_setvar(infoDlgpsftag,50000-1,"year",Buffer); GetDlgItemText(hDlg,IDC_COPYRIGHT,Buffer,1024); psftag_raw_setvar(infoDlgpsftag,50000-1,"copyright",Buffer); GetDlgItemText(hDlg,IDC_GSFBY,Buffer,1024); psftag_raw_setvar(infoDlgpsftag,50000-1,"gsfby",Buffer); GetDlgItemText(hDlg,IDC_TAGBY,Buffer,1024); psftag_raw_setvar(infoDlgpsftag,50000-1,"tagger",Buffer); GetDlgItemText(hDlg,IDC_VOLUME,Buffer,1024); psftag_raw_setvar(infoDlgpsftag,50000-1,"volume",Buffer); if(IsCurrentFile&&!SongChanged) { relvolume=VolumeFromString(Buffer); if(relvolume==0) relvolume=defvolume; } GetDlgItemText(hDlg,IDC_LENGTH,Buffer,1024); psftag_raw_setvar(infoDlgpsftag,50000-1,"length",Buffer); if(IsCurrentFile&&!SongChanged) TrackLength=LengthFromString(Buffer); GetDlgItemText(hDlg,IDC_FADE,Buffer,1024); psftag_raw_setvar(infoDlgpsftag,50000-1,"fade",Buffer); if(IsCurrentFile&&!SongChanged) { FadeLength=LengthFromString(Buffer); TrackLength+=FadeLength; if(TrackLength == 0) { TrackLength = (deflen + deffade)*1000; FadeLength = deffade*1000; } track_length=TrackLength; } //mod.GetLength; GetDlgItemText(hDlg,IDC_COMMENT,Buffer,1024); // remove 0x0d (in PSF a newline is 0x0a) for (c=0,d=0; c < strlen(Buffer); c++) { if (Buffer[c] != 0x0d) { Buffer[d]=Buffer[c]; d++; } } Buffer[d]='\0'; psftag_raw_setvar(infoDlgpsftag,50000,"comment",Buffer); infoDlgWriteNewTags=1; case IDCANCEL: if(decode_pos_ms >= TrackLength-FadeLength) TrackLength=decode_pos_ms+FadeLength; EndDialog(hDlg, TRUE); break; case IDC_NOWBUT: if(decode_pos_ms != 0) { sprintf(Buffer,"%i:%02i.%i",getoutputtime()/60000,(getoutputtime()%60000)/1000,getoutputtime()%1000); SetDlgItemText(hDlg,IDC_LENGTH,Buffer); } break; case IDC_DTIMER: infoDlgDisableTimer=(IsDlgButtonChecked(hDlg, IDC_DTIMER) == BST_CHECKED) ? TRUE : FALSE; playforever=infoDlgDisableTimer; if(decode_pos_ms >= TrackLength-FadeLength) TrackLength=decode_pos_ms+FadeLength; break; //case IDC_SECRETBUTTON: // PlaySound((LPCSTR)IDR_WAVE1, mod.hDllInstance, SND_RESOURCE|SND_ASYNC); // surpriseImage = LoadImage(mod.hDllInstance, MAKEINTRESOURCE(IDB_BIGKITTY), IMAGE_BITMAP, 0, 0, 0); //change the logo graphic //SendMessage( GetDlgItem(hDlg, IDC_SECRETBUTTON), STM_SETIMAGE, IMAGE_BITMAP, (long)surpriseImage); //'' // SendMessage(GetDlgItem(hDlg,IDC_SECRETBUTTON),BM_SETIMAGE,IMAGE_BITMAP, (long)surpriseImage); // break; case IDC_LAUNCHCONFIG: DialogBox(mod.hDllInstance, (const char *)IDD_CONFIG, hDlg, configDlgProc); break; case IDC_VIEWRAW: DialogBox(mod.hDllInstance, (const char *)IDD_RAWTAG, hDlg, rawDlgProc); SetinfoDlgText(hDlg); } break; case WM_DESTROY: pPicture = (IPicture *) GetWindowLong(hDlg, DWL_USER); if (pPicture) IPicture_Release(pPicture); break; default: return 0; } return 1; }