void HandleScreenShot() { #ifdef AVP_DEBUG_VERSION if (DebouncedKeyboardInput[KEY_F8]) ScreenShot(); if (KeyboardInput[KEY_F7]) { if(!SaveCameraPosKeyPressed) { if(KeyboardInput[KEY_LEFTSHIFT]||KeyboardInput[KEY_RIGHTSHIFT]) { ModuleLinkAssist=TRUE; DeleteFile("avp_rifs\\module.aaa"); } else { LogCameraPosForModuleLinking(); SaveCameraPosKeyPressed=1; } } } else SaveCameraPosKeyPressed=0; if(AvP.MainLoopRunning && ModuleLinkAssist)LoadModuleData(); #endif }
void displayCallback() { if (showMap == 1) { DrawParabolicMapWithCube(); } else if (showMap == 2) { DrawParabolicMapWithSphere(); } else { glEnable(GL_SCISSOR_TEST); for (int view = 0; view < 4; view++) { SelectViewport(view, true); if (view == ROTATE) DrawSurface(); else DrawFrame(); DrawGrid(); if (view != ROTATE) DrawControlPoints(); } glDisable(GL_SCISSOR_TEST); if (saveScreens) ScreenShot(); } glutSwapBuffers(); }
void CMainFrame::OnViewScreenshotClipboard() { if (Model_Loaded()) { CWaitCursor wait; // slightly iffy here, I'm going to assume that the rendering context is still valid from last time. // I can't do much else because I need to supply DC shit that I don't have in order to issue an OnDraw // command to do it legally, so f**k it... // gbTextInhibit = AppVars.bCleanScreenShots; //true; { ModelList_Render( g_iScreenWidth, g_iScreenHeight ); // render to back buffer ScreenShot(NULL,va("(C) Raven Software %s",GetYearAsString())); } gbTextInhibit = false; void *pvDIB; int iBytes; if (BMP_GetMemDIB(pvDIB, iBytes)) { ClipBoard_SendDIB(pvDIB, iBytes); } BMP_Free(); } m_splitter.Invalidate(false); }
bool Save_ScreenShot(char *fn, int size) { int i; struct stat st; for (i=1; i<100; i++) { snprintf(fn, size, "%s/screenshot%d.png", USBLOADER_PATH, i); if (stat(fn, &st)) break; } return ScreenShot(fn); }
//============================================================================= // スクリーンショット //============================================================================= void CDeviceHolder::ScreenShot(void) { s8 filename[256] = {NULL}; // スクリーンショット名を時間で決める sprintf(filename,"screenshot/%d.bmp",timeGetTime()); // スクリーンショット ScreenShot(filename); }
void CMainFrame::OnViewScreenshotFile() { if (Model_Loaded()) { CWaitCursor wait; // slightly iffy here, I'm going to assume that the rendering context is still valid from last time. // I can't do much else because I need to supply DC shit that I don't have in order to issue an OnDraw // command to do it legally, so f**k it... // gbTextInhibit = AppVars.bCleanScreenShots; //true; { ModelList_Render( g_iScreenWidth, g_iScreenHeight ); // render to back buffer // generate a filename... // char sBaseName[MAX_PATH]; sprintf(sBaseName, Filename_WithoutPath(Filename_PathOnly(Model_GetFullPrimaryFilename()))); // // look for a numbered slot to snapshot to... // #define NUM_SAVE_SLOTS 1000 for (int iName=0; iName<NUM_SAVE_SLOTS; iName++) { char sFilename[MAX_PATH]; if (iName==NUM_SAVE_SLOTS) { ErrorBox(va("Couldn't find a free save slot! (tried %d slots)",NUM_SAVE_SLOTS)); } sprintf(sFilename, "c:\\%s_%03d.bmp",sBaseName,iName); if (!FileExists(sFilename)) { ScreenShot(sFilename,va("(C) Raven Software %s",GetYearAsString())); BMP_Free(); break; } } } gbTextInhibit = false; } else { ErrorBox("No model loaded to work out path from!\n\n( So duhhhh... why try to take a snapshot? )"); } m_splitter.Invalidate(false); }
void MriWatcherGUI::ScreenShot() { QString m_filename = QFileDialog::getSaveFileName( this, tr("Save As"), QDir::currentPath(), tr("*.bmp") ); if( m_filename.isEmpty() ) { g_screenshot->setDown(false); return; } ScreenShot(m_filename); }
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { Graphics::TBitmap *B; B = new Graphics::TBitmap(); try { ScreenShot(B, true); // Default value does not exist in C5 this->Image1->Picture->Bitmap->Assign(B); } __finally { delete B; } }
BOOL HandleKeyPress(DWORD vKey) { switch(vKey) { case VK_F4: { if(bShowNameTags) { bShowNameTags = FALSE; break; } else { bShowNameTags = TRUE; break; } } case VK_F7: pChatWindow->ToggleEnabled(); break; case VK_F8: { CScreenshot ScreenShot(pD3DDevice); std::string sFileName; GetScreenshotFileName(sFileName); if(ScreenShot.TakeScreenShot((PCHAR)sFileName.c_str())) { pChatWindow->AddInfoMessage("Screenshot Taken - %s",sFileName.c_str()); } else { pChatWindow->AddInfoMessage("Unable to take a screenshot"); } } break; case VK_RETURN: pCmdWindow->ProcessInput(); break; } return FALSE; }
ProcessControls() { int xmax, ymax; xmax = (layer[0].sizex * 16) - sx; ymax = (layer[0].sizey * 16) - sy; if (key[SCAN_F5]) { key[SCAN_F5]=0; ShellMAP(); } if (key[SCAN_F6]) { key[SCAN_F6]=0; CompileAll(); } if (key[SCAN_F8]) { key[SCAN_F8]=0; ShellVERGE(); } if (key[SCAN_ALT] && key[SCAN_D]) { key[SCAN_D]=0; ShellToDOS(); } if (key[SCAN_ALT] && key[SCAN_L]) LoadMAPDialog(); if (key[SCAN_ALT] && key[SCAN_V]) ShellEditMAP(); if (key[SCAN_ALT] && key[SCAN_S]) ShellEditSystem(); if (key[SCAN_ALT] && key[SCAN_N]) NewMAP(); if (key[SCAN_ALT] && key[SCAN_P]) MPDialog(); if (!key[SCAN_ALT] && key[SCAN_P]) { pasting^=1; key[SCAN_P]=0; } // aen if (key[SCAN_A] && el<6) { lt++; if (lt==numtiles) lt=0; key[SCAN_A]=0; } if (key[SCAN_Z] && el<6) { if (lt) lt--; else lt=numtiles-1; key[SCAN_Z]=0; } if (key[SCAN_A] && el==7) { curzone++; key[SCAN_A]=0; } if (key[SCAN_Z] && el==7) { curzone--; key[SCAN_Z]=0; } if (key[SCAN_S]) { rt++; if (rt==numtiles) rt=0; key[SCAN_S]=0; } if (key[SCAN_X]) { if (rt) rt--; else rt=numtiles-1; key[SCAN_X]=0; } if (key[SCAN_F10]) { key[SCAN_F10]=0; if (random(0,255)<15) HAL(); SaveMAP(mapname); SaveVSP(vspname); CompileMAP(); Message("MAP/VSP saved.",100); modified=0; } if (key[SCAN_C]) { key[SCAN_C]=0; sprintf(strbuf,"Left: %d Right: %d", lt, rt); Message(strbuf, 300); } if (key[SCAN_M]) { key[SCAN_M]=0; GenerateMiniVSP(); MiniMAP(); } if (key[SCAN_H]) { key[SCAN_H]=0; mh=mh^1; if (mh) Message("MAP Tile Highlight enabled.",100); else Message("MAP Tile Highlight disabled.",100); } // *** // movement code moved to PollMovement() // *** if (key[SCAN_PGUP]) { key[SCAN_PGUP]=0; ywin -= sy; if (ywin < 0) ywin = 0; } if (key[SCAN_HOME]) { key[SCAN_HOME]=0; xwin -= sx; if (xwin < 0) xwin = 0; } if (key[SCAN_END]) { key[SCAN_END]=0; xwin += sx; if (xwin > xmax) xwin = xmax; } if (key[SCAN_PGDN]) { key[SCAN_PGDN]=0; ywin += sy; if (ywin > ymax) ywin = ymax; } if (key[SCAN_CTRL] && el<6) { key[SCAN_CTRL]=0; TileSelector(); } if (key[SCAN_CTRL] && el==7) { key[SCAN_CTRL]=0; ZoneEdDialog(); } if (key[SCAN_TAB]) { key[SCAN_TAB]=0; if (scrollmode) { scrollmode=0; xwin=xwin/16; xwin=xwin*16; ywin=ywin/16; ywin=ywin*16; Message("Tile scroll.",150); } else { scrollmode=1; Message("Pixel scroll.",150); } } if (key[SCAN_1]) { if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) { layertoggle[0]=0; return; } layertoggle[0]=1; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; el=0; key[SCAN_1]=0; } if (key[SCAN_2]) { if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) { layertoggle[1]=0; return; } key[SCAN_2]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; if (numlayers>1) { layertoggle[1]=1; el=1; } } if (key[SCAN_3]) { if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) { layertoggle[2]=0; return; } key[SCAN_3]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; if (numlayers>2) { layertoggle[2]=1; el=2; } } if (key[SCAN_4]) { if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) { layertoggle[3]=0; return; } key[SCAN_4]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; if (numlayers>3) { layertoggle[3]=1; el=3; } } if (key[SCAN_5]) { if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) { layertoggle[4]=0; return; } key[SCAN_5]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; if (numlayers>4) { layertoggle[4]=1; el=4; } } if (key[SCAN_6]) { if (key[SCAN_LSHIFT] || key[SCAN_RSHIFT]) { layertoggle[5]=0; return; } key[SCAN_6]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; if (numlayers>5) { layertoggle[5]=1; el=5; } } if (key[SCAN_O]) { key[SCAN_O]=0; layertoggle[6]=1; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=0; el=6; } if (key[SCAN_N]) { key[SCAN_N]=0; layertoggle[6]=0; layertoggle[7]=1; layertoggle[8]=0; layertoggle[9]=0; el=7; } if (key[SCAN_E]) { key[SCAN_E]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=1; layertoggle[9]=0; el=8; } if (key[SCAN_T]) { key[SCAN_T]=0; layertoggle[6]=0; layertoggle[7]=0; layertoggle[8]=0; layertoggle[9]=1; el=9; } if (key[SCAN_F9]) { // aen key[SCAN_F9]=0; mouse_scroll^=1; sprintf(strbuf,"Mouse scroll %sabled.", mouse_scroll ? "en" : "dis"); Message(strbuf, 100); } if (key[SCAN_F11]) { key[SCAN_F11]=0; ScreenShot(); Message("Screen capture saved.",300); } if (key[SCAN_F12]) { key[SCAN_F12]=0; OutputVSPpcx(); Message("PCX file exported.",300); } if (key[SCAN_LANGLE]) { key[SCAN_LANGLE]=0; ShutdownVideo(); vm=0; InitVideo(0); set_intensity(63); InitMouse(); // aen -- gotta recalc this if you're in a lower res at the bottom of // the map and jump to a higher res. xmax = (layer[0].sizex * 16) - sx; ymax = (layer[0].sizey * 16) - sy; if (xwin > xmax) xwin=xmax; if (ywin > ymax) ywin=ymax; } if (key[SCAN_RANGLE]) { key[SCAN_RANGLE]=0; ShutdownVideo(); vm=1; InitVideo(1); set_intensity(63); InitMouse(); // aen -- gotta recalc this if you're in a lower res at the bottom of // the map and jump to a higher res. xmax = (layer[0].sizex * 16) - sx; ymax = (layer[0].sizey * 16) - sy; if (xwin > xmax) xwin=xmax; if (ywin > ymax) ywin=ymax; } if (CheckMouseTabs()) return; if (mb>=3) MainMenu(mx-4,my-5); if (key[SCAN_ESC]) DoMainMenu(); if (mb==1 && key[SCAN_SLASH] && el<6) { lt=layers[el][((((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16) * layer[el].sizex)+(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16)]; return; } if (mb==2 && key[SCAN_SLASH] && el<6) { rt=layers[el][((((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16) * layer[el].sizex)+(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16)]; return; } // aen; these must come before the tile plotting code just below // to work correctly. if (mb && el<6 && key[SCAN_LSHIFT] && !shifted) { selx1=(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16); sely1=(((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16); selx2=selx1; sely2=sely1; shifted=mb; return; } if (mb && el<6 && shifted) { selx2=(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16); sely2=(((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16); return; } if (!mb && el<6 && shifted) { int i,j; int x1,y1,x2,y2; x1=selx1; y1=sely1; x2=selx2; y2=sely2; if (x2<x1) x2^=x1,x1^=x2,x2^=x1; if (y2<y1) y2^=y1,y1^=y2,y2^=y1; copybuf_wide=x2-x1+1; copybuf_deep=y2-y1+1; if (shifted==2) { // block fill modified=1; for (j=0; j<copybuf_deep; j++) { for (i=0; i<copybuf_wide; i++) layers[el][((y1+j)*layer[el].sizex)+(x1+i)]=lt; } } if (shifted==1) { modified=1; if (copybuf) vfree(copybuf); copybuf=(word *)valloc(copybuf_wide*copybuf_deep*2, "copybuf", 0); // copy for (j=0; j<copybuf_deep; j++) { for (i=0; i<copybuf_wide; i++) copybuf[(j*copybuf_wide)+i]=layers[el][((y1+j)*layer[el].sizex)+(x1+i)]; } pasting=1; } selx1=sely1=0; selx2=sely2=0; shifted=0; } if (mb==1 && el<6 && !shifted && pasting) { int a,b,i,j; a=(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16)/16); b=(((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16); // paste for (j=0; j<copybuf_deep; j++) { for (i=0; i<copybuf_wide; i++) { if (b+j<layer[el].sizey && a+i<layer[el].sizex) layers[el][((b+j)*layer[el].sizex)+(a+i)]=copybuf[(j*copybuf_wide)+i]; } } } if (mb==1 && el<6 && !shifted && !pasting) { if (mx>335) mx=334; modified=1; layers[el][((((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16) * layer[el].sizex)+(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16) /16)]=lt; } if (mb==2 && el<6 && !shifted) { if (mx>335) mx=334; modified=1; layers[el][((((ywin*layer[el].pmulty/layer[el].pdivy)+my-16)/16) * layer[el].sizex)+(((xwin*layer[el].pmultx/layer[el].pdivx)+mx-16) /16)]=rt; } if (mb==1 && el==6) { modified=1; obstruct[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) /16)]=1; } if (mb==2 && el==6) { modified=1; obstruct[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) /16)]=0; } if (mb==1 && el==7 && (key[SCAN_LSHIFT] || key[SCAN_RSHIFT])) { curzone=zone[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) /16)]; WaitRelease(); ZoneEdDialog(); return; } if (mb==1 && el==7) { modified=1; zone[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) /16)]=curzone; } if (mb==2 && el==7) { modified=1; zone[((((ywin*layer[0].pmulty/layer[0].pdivy)+my-16)/16) * layer[0].sizex)+(((xwin*layer[0].pmultx/layer[0].pdivx)+mx-16) /16)]=0; } if (mb==1 && el==8) { WaitRelease(); ProcessEntity((xwin+(mx-16))/16,(ywin+(my-16))/16); modified=1; } if (el==8 && EntityThere((mx-16+xwin)/16,(my+ywin-16)/16) && key[SCAN_DEL]) { WaitRelease(); DeleteEntity((mx-16+xwin)/16,(my-16+ywin)/16); modified=1; } }
void CDlgCapCam::OnBnClickedButtonScreenshot() { // TODO: 在此添加控件通知处理程序代码 ScreenShot(1,0); }
void CDlgCapCam::UpdateImage(void) { int i; CPen cur_pen, *old_pen=NULL; CBrush cur_brush,*old_brush = NULL; CPoint point; CSize size; CRect rect_image; CImage * pimage; CString str_dis; CRect client_rect1; CSize paint_size1; __time32_t l_time; if (!m_img_show.IsNull()) { pimage = &m_img_show; _time32(&l_time); CWnd * pDis1 = GetDlgItem(IDC_STATIC_IMGSHOW); CDC* pDC1 = pDis1->GetDC(); CDC MemDC1; CBitmap MemBitmap1; CPen pen_target; rect_image = CRect(0,0,pimage->GetWidth()-1, pimage->GetHeight()-1); pDis1->GetClientRect(&client_rect1); MemDC1.CreateCompatibleDC(pDC1); MemBitmap1.CreateCompatibleBitmap(pDC1,rect_image.Width(),rect_image.Height()); MemDC1.SelectObject(&MemBitmap1); MemDC1.SetStretchBltMode(COLORONCOLOR); pDC1->SetStretchBltMode(COLORONCOLOR); pimage->BitBlt(MemDC1.GetSafeHdc(),rect_image, CPoint(0,0),SRCCOPY); //draw other osd targets pen_target.CreatePen(PS_SOLID, 2, RGB(255, 0, 0)); MemDC1.SelectStockObject(NULL_BRUSH); MemDC1.SelectObject(&pen_target); for (i=0; i<m_proc_result_buf.target_set.num; i++) { MemDC1.Rectangle(m_proc_result_buf.target_set.targets[i].rect.left, m_proc_result_buf.target_set.targets[i].rect.bottom, m_proc_result_buf.target_set.targets[i].rect.right, m_proc_result_buf.target_set.targets[i].rect.top); } //修改事件抓拍为每10秒钟1次 #define SNATCH_TIME_INTER 10 #define SNATCH_TIME_LATE 120 time_t cur_time; struct tm * now_time; time(&cur_time); now_time = localtime(&cur_time); if (m_proc_result_buf.target_set.num > 0) { if (cur_time - m_trigger_snatch_time >= SNATCH_TIME_INTER) { //超过10s间隔 ScreenShot(1, SNATCH_TIME_INTER); m_trigger_snatch_time = cur_time; } } //延续120秒 else if(m_trigger_snatch_time > 0 && cur_time - m_trigger_snatch_time <=SNATCH_TIME_LATE) { ScreenShot(SNATCH_TIME_LATE/SNATCH_TIME_INTER, SNATCH_TIME_INTER); m_trigger_snatch_time = 0; } if (!m_proc_result_buf.flg_used) { if (m_proc_result_buf.target_set.num) { ((CSTEvaluationDlg*)pWndParent)->AddTarget(&m_proc_result_buf.target_set); } //do event for (i=0; i<m_proc_result_buf.event_set.num; i++) { //摄像头采集的,帧数置零 ((CSTEvaluationDlg*)pWndParent)->AddEvent(0,l_time,m_proc_result_buf.event_set.events[i].type); //同时触发抓拍 //ScreenShot(12, 10); } //防止由于刷新,事件被触发两次 m_proc_result_buf.flg_used = TRUE; } //---------------------抓拍的操作------------------- //if (WaitForSingleObject(m_proc_flgscreenshot, 0) == WAIT_OBJECT_0) if (m_snatch_count>0 && l_time - m_snatch_pretime>=m_snatch_intertime) { CImage img; CString str_name; time_t cur_time; struct tm * now_time; str_name = ((CSTEvaluationDlg*)pWndParent)->file_path; str_name += +_T("\\screenshot\\"); time(&cur_time); now_time = localtime(&cur_time); str_name.AppendFormat(_T("_%012d_alarm.jpg"), cur_time); img.Attach(MemBitmap1); img.Save(str_name); img.Detach(); m_snatch_count--; m_snatch_pretime = l_time; } pDC1->StretchBlt(0,0,STE_IMAGE_WIDTH*2-1,STE_IMAGE_HEIGH*2-1,&MemDC1,0,0,rect_image.Width()-1, rect_image.Height()-1, SRCCOPY); pDis1->ReleaseDC(pDC1); } else { pimage = &m_img_def; CWnd * pDis1 = GetDlgItem(IDC_STATIC_IMGSHOW); CDC* pDC1 = pDis1->GetDC(); rect_image = CRect(0,0,pimage->GetWidth()-1, pimage->GetHeight()-1); pDis1->GetClientRect(&client_rect1); pimage->StretchBlt(pDC1->GetSafeHdc(),client_rect1, rect_image, SRCCOPY); pDis1->ReleaseDC(pDC1); } #ifdef _DEBUG if (!m_img1.IsNull()) { pimage = &m_img1; //CWnd * pDis1 = GetDlgItem(IDC_STATIC_IMGSHOW); CDC* pDC1 = GetDC(); rect_image = CRect(0,0,pimage->GetWidth()-1, pimage->GetHeight()-1); GetClientRect(&client_rect1); pimage->StretchBlt(pDC1->GetSafeHdc(),CRect(380,20, 380+175, 20+143), rect_image); //pimage->BitBlt(pDC1->GetSafeHdc(), 500,0,352,288, 0,0,SRCCOPY); ReleaseDC(pDC1); } if (!m_img2.IsNull()) { pimage = &m_img2; //CWnd * pDis1 = GetDlgItem(IDC_STATIC_IMGSHOW); CDC* pDC1 = GetDC(); rect_image = CRect(0,0,pimage->GetWidth()-1, pimage->GetHeight()-1); GetClientRect(&client_rect1); pimage->StretchBlt(pDC1->GetSafeHdc(),CRect(380,170, 380+175, 170+143), rect_image); //pimage->BitBlt(pDC1->GetSafeHdc(), 500,0,352,288, 0,0,SRCCOPY); ReleaseDC(pDC1); } if (!m_img3.IsNull()) { pimage = &m_img3; //CWnd * pDis1 = GetDlgItem(IDC_STATIC_IMGSHOW); CDC* pDC1 = GetDC(); rect_image = CRect(0,0,pimage->GetWidth()-1, pimage->GetHeight()-1); GetClientRect(&client_rect1); pimage->StretchBlt(pDC1->GetSafeHdc(),CRect(560,20, 560+175, 20+143), rect_image); //pimage->BitBlt(pDC1->GetSafeHdc(), 500,0,352,288, 0,0,SRCCOPY); ReleaseDC(pDC1); } if (!m_img4.IsNull()) { pimage = &m_img4; //CWnd * pDis1 = GetDlgItem(IDC_STATIC_IMGSHOW); CDC* pDC1 = GetDC(); rect_image = CRect(0,0,pimage->GetWidth()-1, pimage->GetHeight()-1); GetClientRect(&client_rect1); pimage->StretchBlt(pDC1->GetSafeHdc(),CRect(560,170, 560+175, 170+143), rect_image); //pimage->BitBlt(pDC1->GetSafeHdc(), 500,0,352,288, 0,0,SRCCOPY); ReleaseDC(pDC1); } #endif //因为帧数等信息和图像相关,所以也放在此处更新 __time32_t n_time = 0; if (m_flg_process) { _time32(&n_time); } //str_dis.Format(_T("Frame:%06d; Time(s):%06d"), m_proc_result_buf.frame_index, n_time-m_start_time); str_dis.Format(_T("Frame:%02d; Time: %02dm:%02ds"), m_proc_result_buf.frame_index, (n_time-m_start_time)/60, (n_time-m_start_time)%60); GetDlgItem(IDC_STATIC_STATUS)->SetWindowText(str_dis); }
bool Display(float timeDelta) { if( Device ) { // // Update: Update the camera. // if( ::GetAsyncKeyState('W') & 0x8000f ) TheCamera.walk(0.004f * timeDelta); if( ::GetAsyncKeyState('S') & 0x8000f ) TheCamera.walk(-0.004f * timeDelta); if( ::GetAsyncKeyState('A') & 0x8000f ) TheCamera.strafe(-0.004f * timeDelta); if( ::GetAsyncKeyState('D') & 0x8000f ) TheCamera.strafe(0.004f * timeDelta); if( ::GetAsyncKeyState('R') & 0x8000f ) TheCamera.fly(0.004f * timeDelta); if( ::GetAsyncKeyState('F') & 0x8000f ) TheCamera.fly(-0.004f * timeDelta); if( ::GetAsyncKeyState(VK_UP) & 0x8000f ) TheCamera.pitch(0.0004f * timeDelta); if( ::GetAsyncKeyState(VK_DOWN) & 0x8000f ) TheCamera.pitch(-0.0004f * timeDelta); if( ::GetAsyncKeyState(VK_LEFT) & 0x8000f ) TheCamera.yaw(-0.0004f * timeDelta); if( ::GetAsyncKeyState(VK_RIGHT) & 0x8000f ) TheCamera.yaw(0.0004f * timeDelta); if( ::GetAsyncKeyState('N') & 0x8000f ) TheCamera.roll(0.0004f * timeDelta); if( ::GetAsyncKeyState('M') & 0x8000f ) TheCamera.roll(-0.0004f * timeDelta); /*Update the view matrix representing the cameras new position/orientation.*/ D3DXMATRIX V; TheCamera.getViewMatrix(&V); Device->SetTransform(D3DTS_VIEW, &V); // // Render // /* D3DXVECTOR3 position(127.0f, 129.0f, -31.0f); D3DXVECTOR3 target(127.0f, 129.0f, 0.0f); D3DXVECTOR3 up(0.0f, 1.0f, 0.0f); D3DXMATRIX V; D3DXMatrixLookAtLH(&V, &position, &target, &up); Device->SetTransform(D3DTS_VIEW, &V);*/ Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00000000, 1.0f, 0); Device->BeginScene(); DrawBasicScene(Device); axis->draw(Device); for(S32 i=0; i<obj.size(); i++) { obj[i].draw(Device, &WHITE_MTRL, Tex); } Device->EndScene(); ScreenShot("1.bmp"); Device->Present(0, 0, 0, 0); } return true; }
int main(int argc, char *argv[ ]){ ClearPrints(); chdir(CombineStrings("/home/", GetUser())); DelFile(output_log); DebugLog("--- Begin Android Dev Tools ARGS"); for(tick = 1; tick < argc; tick++) DebugLog(CombineStrings("ARG: ", argv[tick])); DebugLog(""); DebugLog("--- Begin Android Dev Tools"); CmdOut("aDev_adb devices > tmp.txt"); if(IsFileEmpty("tmp.txt")){ ClearPrints(); PrintText("--- Proprietary Files Not Found! ---"); PrintText("Run: \'aDev config\'"); LineSkip(); exit(-1); } DelFile("tmp.txt"); if(argc <= 1){ PrintText("--- Invalid parameters! ---"); PrintText("Run: \'aDev --help\'"); LineSkip(); exit(-1); } for(tick = 1; tick < argc; tick++){ if(IsStringEmpty(argv[tick])) continue; if(CompareStrings(argv[tick], "--help") || CompareStrings(argv[tick], "-h")){ PrintHelp(); exit(0); } if(CompareStrings(argv[tick], "--version") || CompareStrings(argv[tick], "-v")){ PrintVersion(); exit(0); } else if(CompareStrings(argv[tick], "test")){ PrintText("aDev was properly installed, enjoy!"); LineSkip(); exit(0); } else if(CompareStrings(argv[tick], "logcat")){ DevLog(1); exit(0); } else if(CompareStrings(argv[tick], "dmesg")){ DevLog(2); exit(0); } else if(CompareStrings(argv[tick], "kmsg")){ DevLog(3); exit(0); } else if(CompareStrings(argv[tick], "screenshot")){ ScreenShot(); exit(0); } else if(CompareStrings(argv[tick], "info")){ Info(); exit(0); } else if(CompareStrings(argv[tick], "adb")){ text = "aDev_adb "; for(tick2 = 1; tick2 < argc; tick2++) if(!CompareStrings(argv[tick2], "adb")) text = CombineStrings(text, CombineStrings(argv[tick2], " ")); CmdOut(text); exit(0); } else if(CompareStrings(argv[tick], "fastboot")){ text = "aDev_fastboot "; for(tick2 = 1; tick2 < argc; tick2++) if(!CompareStrings(argv[tick2], "fastboot")) text = CombineStrings(text, CombineStrings(argv[tick2], " ")); CmdOut(text); exit(0); } else{ for(tick2 = (argc - 1); tick2 < 0; tick2--){ if(!IsValidArg(argv[tick2])) break; if(tick2 == 1) quit(); } if(IsValidArg(argv[tick2])) tick2--; if(IsValidArg(argv[tick2])) quit(); PrintText(CombineStrings("Unknown Parameter: ", argv[tick2])); quit(); } } return 0; }
void CModViewView::OnTimer(UINT nIDEvent) { if (nIDEvent != th_100FPS) { CView::OnTimer(nIDEvent); return; } // otherwise, it's one of our timer events, so... { // new bit, poll the remote control stuff 10 times per second (it's also done in OnIdle(), but that's not always fast enough when animating) static float fTime = 0.0f; float fTimeNow = GetFloatTime(); #define UPDATE_FRAMES_PER_SECOND 10.0f if (fTimeNow - fTime > 1.0f/UPDATE_FRAMES_PER_SECOND) { fTime = fTimeNow; // OutputDebugString(va("Time = %f seconds\n",GetFloatTime())); if (WinTalk_HandleMessages()) { // app exit requested AppVars.bAnimate = qfalse; // groan... stop the animation so the app doesn't spend all it's time // in the render loop. This allows the App::OnIdle() version // of the Wintalk_HandleMessages() handler to get a look in, // and therefore spot that an exit is being requested. } } } // if (!DraggingMouse()) { if (ModelList_Animation()) { // one or more models have updated frames (or lerping)... // Invalidate(false); } } if (Gallery_Active()) { extern bool gbInRenderer; if (!gbInRenderer) { static bool bAlreadyHere = false; if (!bAlreadyHere) // jic. { bAlreadyHere = true; extern int giRenderCount; static CString strCaption; static CString strScript; static bool bSnapshotTakingPlace = false; if (!bSnapshotTakingPlace) { int iRemainingPlusOne = GalleryRead_ExtractEntry(strCaption, strScript); if (iRemainingPlusOne) // because 0 would be fail/empty { giGalleryItemsRemaining = iRemainingPlusOne-1; StatusMessage( va("( Gallery: %d remaining )", giGalleryItemsRemaining) ); OutputDebugString(va("\"%s\" (script len %d)\n",(LPCSTR)strCaption,strScript.GetLength())); strScript += "\n"; string strOutputFileName( va("%s\\%s",scGetTempPath(),"temp.mvs") ); int iReturn = SaveFile(strOutputFileName.c_str(),(LPCSTR)strScript, strScript.GetLength()); if (iReturn != -1) { extern bool Document_ModelLoadPrimary(LPCSTR psFilename); if (Document_ModelLoadPrimary(strOutputFileName.c_str())) { if (Model_Loaded()) { ModelHandle_t hModel = AppVars.Container.hModel; Model_Sequence_Lock( hModel, Gallery_GetSeqToLock(), true, false); } giRenderCount = 0; bSnapshotTakingPlace = true; } } } else { // all done... // gbTextInhibit = false; Gallery_Done(); StatusMessage( NULL ); // // report... // CString strReport; if (!strGalleryErrors.IsEmpty()) { strReport += "====================== Errors: ===================\n\n"; strReport += strGalleryErrors; strReport += "\n\n"; } if (!strGalleryWarnings.IsEmpty()) { strReport += "====================== Warnings: ===================\n\n"; strReport += strGalleryWarnings; strReport += "\n\n"; } if (!strGalleryInfo.IsEmpty()) { strReport += "====================== Info: ===================\n\n"; strReport += strGalleryInfo; strReport += "\n\n"; } if (!strReport.IsEmpty()) { strReport.Insert(0,"The following messages appeared during gallery-snapshots....\n\n"); } else { strReport = va("All gallery-snapshots done\n\nOutput dir was: \"%s\\n",Gallery_GetOutputDir()); } SendStringToNotepad(strReport,"gallery_report.txt"); } } else { if (giRenderCount == 2) // ... so it's rendered to back buffer for snapshot, and front for user { // // generate a filename... // char sOutputFileName[MAX_PATH]; CString strBaseName(strCaption); while (strBaseName.Replace("\t"," ")); while (strBaseName.Replace(" "," ")); sprintf(sOutputFileName, "%s\\%s.bmp",Gallery_GetOutputDir(),strBaseName); ScreenShot(sOutputFileName,/*strCaption*/strBaseName); BMP_Free(); bSnapshotTakingPlace = false; // trigger next snapshot } else { Invalidate(false); // cause another screen update until render count satisfied } } bAlreadyHere = false; } } } }
//--------------------------------------------------------------------------- void __fastcall TMainForm::IdTCPServerExecute(TIdPeerThread *AThread) { AnsiString s; AnsiString sCommand; AnsiString sAction; TFileStream* tmpfStream; Graphics::TBitmap *tbm; try { s = UpperCase(AThread->Connection->ReadLn("",5000)); sCommand = s.SubString (1,3); sAction = s.SubString(5,s.Length()-4); if (sCommand == "LST") { AThread->Connection->WriteLn(GetList()); AThread->Connection->Disconnect(); } else if (sCommand == "PIC") { if (FileExists(ExtractFileDir(ParamStr(0)) + "\\images\\" + sAction)) { lstRequests->Items->Add("Serving up: " + sAction); // open file stream to image requested tmpfStream = new TFileStream(ExtractFileDir(ParamStr(0)) + "\\images\\" + sAction,fmOpenRead |fmShareDenyNone); // copy file stream to write stream AThread->Connection->OpenWriteBuffer(-1); AThread->Connection->WriteStream(tmpfStream,true,false); AThread->Connection->CloseWriteBuffer(); // free the file stream delete tmpfStream; tmpfStream=NULL; lstRequests->Items->Add("File transfer completed"); AThread->Connection->Disconnect(); } else {AThread->Connection->WriteLn("ERR - Requested file does not exist"); AThread->Connection->Disconnect(); } } else if (sCommand == "SRN") { // in production version you would use a unique file name such as one generated // from a tickcount plus clint IP / id etc. // take snapshot lstRequests->Items->Add("Taking screen snap shot"); tbm = new Graphics::TBitmap(); ScreenShot(0,0,Screen->Width,Screen->Height,tbm); if (FileExists (ExtractFileDir(ParamStr(0)) + "\\images\\ScreenShot.BMP")) DeleteFile(ExtractFileDir(ParamStr(0)) + "\\images\\ScreenShot.BMP"); tbm->SaveToFile(ExtractFileDir(ParamStr(0)) + "\\images\\ScreenShot.BMP"); tbm->FreeImage(); delete tbm; tbm=NULL; lstRequests->Items->Add("Serving up: SCREENSHOT.BMP"); // open file stream to image requested tmpfStream = new TFileStream(ExtractFileDir(ParamStr(0)) + "\\images\\ScreenShot.BMP",fmOpenRead | fmShareDenyNone); // copy file stream to write stream AThread->Connection->OpenWriteBuffer(-1); AThread->Connection->WriteStream(tmpfStream,true,false); AThread->Connection->CloseWriteBuffer(); // free the file stream delete tmpfStream; tmpfStream=NULL; lstRequests->Items->Add("File transfer completed"); AThread->Connection->Disconnect(); } else if ((sCommand != "LST") && (sCommand != "PIC") && (sCommand != "SRN")) { AThread->Connection->WriteLn("ERR : Unknown command / action"); AThread->Connection->Disconnect(); } } catch (Exception& E) { ShowMessage(E.Message); } }
void SpecialKeyDown(int key, int x, int y) { Keyboard *keyboard = CurrentGame()->getKeyboard(); keyboard->special_key_state[key] = true; keyboard->m_special_key_event_board.onEvent(key, EnumEventType::ON_DOWN); // HACK static bool fullscreen = 0; switch (key){ //toggle Creative Mode case GLUT_KEY_F2: bCreative ^= 1; bGravity ^= 1; break; /* //toggle the shader case GLUT_KEY_F1: bCustomGLSL ^= 1; break; */ //toggle view_mode case GLUT_KEY_F5: view_mode = (view_mode + 1) % VIEW_MODE_TOTAL_NUMBER; break; //toggle showing the observer case GLUT_KEY_F6: { Entity *entity = CurrentGame()->getPlayerEntity(); if (entity != nullptr) entity->render_config.is_visible ^= 1; break; } //toggle moving sun light case GLUT_KEY_F7: bMovingLight ^= 1; break; //toggle showing the box lines case GLUT_KEY_F9: bBoxLine ^= 1; break; //toggle showing the shadow depth map at the top right corner case GLUT_KEY_F10: bDebugDepthMap ^= 1; break; //toggle fullscreen case GLUT_KEY_F11: if (fullscreen){ glutReshapeWindow(1000, 700); glutPositionWindow(0, 0); fullscreen = 0; } else { glutFullScreen(); fullscreen = 1; } break; //screen_shot case GLUT_KEY_F12: { std::string filename = "screenshot_" + std::to_string(screenshot_count) + ".bmp"; ScreenShot(filename); screenshot_count++; break; } } }
MriWatcherGUI::MriWatcherGUI(QWidget *parent) { setupUi(this); installEventFilter(this); setAcceptDrops(true); connect(g_loadimg, SIGNAL( clicked() ), this, SLOT( LoadImg() ) ); connect(g_loadoverlay, SIGNAL( clicked() ), this, SLOT( LoadOverlay() ) ); connect(g_loadimg2, SIGNAL( clicked() ), this, SLOT( LoadImg2() ) ); connect(g_reset_view, SIGNAL( clicked() ), this, SLOT( ResetView() ) ); connect(g_screenshot, SIGNAL( clicked() ), this, SLOT( ScreenShot() ) ); connect(g_combine, SIGNAL( clicked() ), this, SLOT( Combine() ) ); connect(g_help, SIGNAL( clicked() ), this, SLOT( Help() ) ); connect(g_xview, SIGNAL( toggled(bool) ), this, SLOT( ChangeView() ) ); connect(g_yview, SIGNAL( toggled(bool) ), this, SLOT( ChangeView() ) ); connect(g_zview, SIGNAL( toggled(bool) ), this, SLOT( ChangeView() ) ); connect(g_slice_slider, SIGNAL( sliderMoved(int) ), this, SLOT( ChangeSlice(int) ) ); // connect(g_slice_slider, SIGNAL( valueChanged(int) ), this, SLOT( ChangeSlice(int) )); connect(g_overlay_alpha_slider, SIGNAL( valueChanged(int) ), this, SLOT( ChangeOverlayAlpha(int) ) ); connect(g_draw_name, SIGNAL( stateChanged(int) ), this, SLOT( DrawImageName(int) ) ); connect(g_draw_info, SIGNAL( stateChanged(int) ), this, SLOT( DrawImageInfo(int) ) ); connect(g_draw_position, SIGNAL( stateChanged(int) ), this, SLOT( DrawImagePosition(int) ) ); connect(g_draw_intensity, SIGNAL( stateChanged(int) ), this, SLOT( DrawImageIntensity(int) ) ); connect(g_overlayzero, SIGNAL( stateChanged(int) ), this, SLOT( ChangeOverlayZero() ) ); connect(g_intensity_min_slider, SIGNAL( valueChanged(int) ), this, SLOT( ChangeIntensityMin(int) ) ); connect(g_intensity_max_slider, SIGNAL( valueChanged(int) ), this, SLOT( ChangeIntensityMax(int) ) ); connect(g_blending_mode, SIGNAL( stateChanged(int) ), this, SLOT( SetBlendingMode() ) ); connect(g_alpha, SIGNAL( valueChanged(int) ), this, SLOT( ChangeImageAlpha(int) ) ); connect(g_viewall, SIGNAL( toggled(bool) ), this, SLOT( ViewOptions() ) ); connect(g_viewcolumn, SIGNAL( toggled(bool) ), this, SLOT( ViewOptions() ) ); // connect(g_nbcolumn, SIGNAL( returnPressed() ), this, SLOT( ViewOptions() ) ); connect(g_nbcolumn, SIGNAL( valueChanged(int) ), this, SLOT( ChangeColumn() )); connect(g_overlaymin, SIGNAL( returnPressed() ), this, SLOT( ChangeOverlayMinMax() ) ); connect(g_overlaymax, SIGNAL( returnPressed() ), this, SLOT( ChangeOverlayMinMax() ) ); m_direction = 0; m_numberofimages = 0; m_maxsize[0] = 0; m_maxsize[1] = 0; m_maxsize[2] = 0; m_imagemin = 999999; m_imagemax = 0; m_keyalt = false; m_keyctrl = false; // multiselection m_overlaymin = 0; m_overlaymax = 0; m_imagemanager.ChangeAlpha(100); g_slice_slider->setEnabled(false); g_overlay_alpha_slider->setEnabled(false); g_intensity_min_slider->setMinimum(0); g_intensity_max_slider->setMinimum(0); g_intensity_min_slider->setMaximum(static_cast<int>(MAX_PERCENTAGE) ); g_intensity_max_slider->setMaximum(static_cast<int>(MAX_PERCENTAGE) ); g_intensity_min_slider->setValue(0); g_intensity_max_slider->setValue(static_cast<int>(MAX_PERCENTAGE) ); m_frame = new MriWatcherFrame(g_scrollArea); connect(m_frame, SIGNAL( UnSelectAll() ), this, SLOT( UnSelectAll() ) ); connect(m_frame, SIGNAL( GetFiles(const QString &) ), this, SLOT( LoadFile(const QString &) ) ); // m_imageframelayout = new ImageFrameLayout(); // QBoxLayout* gm = new QVBoxLayout(m_frame); m_imageframelayout = new ImageFrameLayout(); // g_scrollArea->setLayout(m_imageframelayout); g_scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); g_scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // g_scrollArea->verticalScrollBar()->setRange(); g_scrollArea->setWidget(m_frame); m_frame->setLayout(m_imageframelayout); g_name_version->setText(QString("MriWatcher") + " " + MriWatcher_VERSION); g_tips->setText( "\nQuick Tips:\n- Left mouse drag: Move image\n- Right mouse drag: Zoom in/out\n- Middle mouse: Pick one voxel\n- Control + mouse: Pick images\n- Shift + mouse: Global operatation\n- Left or right key: Switch order\n- Delete key: Remove image"); /* imageLabel = new QLabel; imageLabel->setBackgroundRole(QPalette::Base); imageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); imageLabel->setScaledContents(true); g_scrollArea->setBackgroundRole(QPalette::Dark); g_scrollArea->setWidget(imageLabel); */ }
void CommonEvent(CommonState * state, SDL_Event * event, int *done) { int i; if (state->verbose & VERBOSE_EVENT) { PrintEvent(event); } switch (event->type) { case SDL_WINDOWEVENT: switch (event->window.event) { case SDL_WINDOWEVENT_CLOSE: { SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); if (window) { SDL_DestroyWindow(window); } } break; } break; case SDL_KEYDOWN: switch (event->key.keysym.sym) { /* Add hotkeys here */ case SDLK_PRINTSCREEN: { SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { for (i = 0; i < state->num_windows; ++i) { if (window == state->windows[i]) { ScreenShot(state->renderers[i]); } } } } break; case SDLK_c: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-C copy awesome text! */ SDL_SetClipboardText("SDL rocks!\nYou know it!"); printf("Copied text to clipboard\n"); } break; case SDLK_v: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-V paste awesome text! */ char *text = SDL_GetClipboardText(); if (*text) { printf("Clipboard: %s\n", text); } else { printf("Clipboard is empty\n"); } SDL_free(text); } break; case SDLK_g: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-G toggle grab */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { SDL_SetWindowGrab(window, !SDL_GetWindowGrab(window)); } } break; case SDLK_m: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-M maximize */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { Uint32 flags = SDL_GetWindowFlags(window); if (flags & SDL_WINDOW_MAXIMIZED) { SDL_RestoreWindow(window); } else { SDL_MaximizeWindow(window); } } } break; case SDLK_r: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-R toggle mouse relative mode */ SDL_SetRelativeMouseMode(!SDL_GetRelativeMouseMode()); } break; case SDLK_z: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-Z minimize */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { SDL_MinimizeWindow(window); } } break; case SDLK_RETURN: if (event->key.keysym.mod & KMOD_CTRL) { /* Ctrl-Enter toggle fullscreen */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { Uint32 flags = SDL_GetWindowFlags(window); if (flags & SDL_WINDOW_FULLSCREEN) { SDL_SetWindowFullscreen(window, SDL_FALSE); } else { SDL_SetWindowFullscreen(window, SDL_TRUE); } } } break; case SDLK_ESCAPE: *done = 1; break; default: break; } break; case SDL_QUIT: *done = 1; break; } }
/******************************************************************************** * TitleBrowser- opens a browser with a list of installed Titles * relies on code from any title deleter. *********************************************************************************/ int TitleBrowser(u32 type) { u32 num_titles; u32 titles[100] ATTRIBUTE_ALIGN(32); u32 num_sys_titles; u32 sys_titles[10] ATTRIBUTE_ALIGN(32); s32 ret = -1; int numtitle;//to get rid of a stupid compile wrning //open the database file FILE *f; char path[100]; ISFS_Initialize(); sprintf(path,"%s/config/database.txt",bootDevice); f = fopen(path, "r"); // Get count of titles of our requested type ret = getTitles_TypeCount(type, &num_titles); if (ret < 0) { //printf("\tError! Can't get count of titles! (ret = %d)\n", ret); //exit(1); } // Get titles of our requested type ret = getTitles_Type(type, titles, num_titles); if (ret < 0) { //printf("\tError! Can't get list of titles! (ret = %d)\n", ret); //exit(1); } // Get count of system titles ret = getTitles_TypeCount(0x00010002, &num_sys_titles); if (ret < 0) { //printf("\tError! Can't get count of titles! (ret = %d)\n", ret); //exit(1); } // Get system titles ret = getTitles_Type(0x00010002, sys_titles, num_sys_titles); if (ret < 0) { //printf("\tError! Can't get list of titles! (ret = %d)\n", ret); //exit(1); } //this array will hold all the names for the titles so we only have to get them one time char name[num_titles+num_sys_titles][50]; customOptionList options3(num_titles+num_sys_titles+1); //write the titles on the option browser u32 i = 0; //first add the good stuff while (i < num_titles) { //start from the beginning of the file each loop if (f)rewind(f); //char name[50]; char text[15]; strcpy(name[i],"");//make sure name is empty u8 found=0; //set the title's name, number, ID to text sprintf(text, "%s", titleText(type, titles[i])); //get name from database cause i dont like the ADT function char line[200]; char tmp[50]; snprintf(tmp,50," "); //check if the content.bin is on the SD card for that game //if there is content.bin,then the game is on the SDmenu and not the wii sprintf(line,"SD:/private/wii/title/%s/content.bin",text); if (!checkfile(line)) { if (f) { while (fgets(line, sizeof(line), f)) { if (line[0]== text[0]&& line[1]== text[1]&& line[2]== text[2]) { int j=0; found=1; for (j=0;(line[j+4]!='\0' || j<51);j++) tmp[j]=line[j+4]; snprintf(name[i],sizeof(name[i]),"%s",tmp); //break; } } } if (!found) { if (getName00(name[i], TITLE_ID(type, titles[i]),CONF_GetLanguage()*2)>=0) found=2; if (!found) { if (getNameBN(name[i], TITLE_ID(type, titles[i]))>=0) found=3; if (!found) snprintf(name[i],sizeof(name[i]),"Unknown Title (%08x)",titles[i]); } } //set the text to the option browser options3.SetName(i, "%s",text); options3.SetValue(i, "%s",name[i]); //options3.SetValue(i, " (%08x) %s",titles[i],name[i]);//use this line to show the number to call to launch the channel //move on to the next title } i++; } // now add the crappy system titles while (i < num_titles+num_sys_titles) { //start from the beginning of the file each loop if (f)rewind(f); //char name[50]; char text[15]; strcpy(name[i],"");//make sure name is empty u8 found=0; //set the title's name, number, ID to text sprintf(text, "%s", titleText(0x00010002, sys_titles[i-num_titles])); //get name from database cause i dont like the ADT function char line[200]; char tmp[50]; snprintf(tmp,50," "); //snprintf(name[i],sizeof(name[i]),"Unknown Title"); if (f) { while (fgets(line, sizeof(line), f)) { if (line[0]== text[0]&& line[1]== text[1]&& line[2]== text[2]) { int j=0; found=1; for (j=0;(line[j+4]!='\0' || j<51);j++) tmp[j]=line[j+4]; snprintf(name[i],sizeof(name[i]),"%s",tmp); break; } } } if (!found) { if (getName00(name[i], TITLE_ID(0x00010002, sys_titles[i-num_titles]))>=0) found=2; if (!found) { if (getNameBN(name[i], TITLE_ID(0x00010002, sys_titles[i-num_titles]))>=0) found=3; if (!found) snprintf(name[i],sizeof(name[i]),"Unknown Title (%08x)",sys_titles[i-num_titles]); } } //set the text to the option browser options3.SetName(i, "%s",text); options3.SetValue(i, "%s",name[i]); //options3.SetValue(i, " (%08x) %s",titles[i],name[i]);//use this line to show the number to call to launch the channel //move on to the next title i++; } if (i == num_titles+num_sys_titles) { options3.SetName(i, " "); options3.SetValue(i, "%s",tr("Wii Settings")); } //we have all the titles we need so close the database and stop poking around in the wii fclose(f); //get rid of our footprints in there Uninstall_FromTitle(TITLE_ID(1, 0)); ISFS_Deinitialize(); bool exit = false; if (IsNetworkInit()) ResumeNetworkWait(); GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, Settings.sfxvolume); // because destroy GuiSound must wait while sound playing is finished, we use a global sound if(!btnClick2) btnClick2=new GuiSound(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); // GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, Settings.sfxvolume); char imgPath[100]; snprintf(imgPath, sizeof(imgPath), "%sbutton_dialogue_box.png", CFG.theme_path); GuiImageData btnOutline(imgPath, button_dialogue_box_png); snprintf(imgPath, sizeof(imgPath), "%sgamesettings_background.png", CFG.theme_path); GuiImageData settingsbg(imgPath, settings_background_png); GuiTrigger trigA; trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); GuiTrigger trigHome; trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); GuiTrigger trigB; trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); GuiText titleTxt(tr("Title Launcher"), 28, (GXColor) {0, 0, 0, 255}); titleTxt.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); titleTxt.SetPosition(12,40); titleTxt.SetMaxWidth(356, GuiText::SCROLL); GuiImage settingsbackground(&settingsbg); GuiButton settingsbackgroundbtn(settingsbackground.GetWidth(), settingsbackground.GetHeight()); settingsbackgroundbtn.SetAlignment(ALIGN_LEFT, ALIGN_TOP); settingsbackgroundbtn.SetPosition(0, 0); settingsbackgroundbtn.SetImage(&settingsbackground); GuiText cancelBtnTxt(tr("Back"), 22, THEME.prompttext); cancelBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); GuiImage cancelBtnImg(&btnOutline); if (Settings.wsprompt == yes) { cancelBtnTxt.SetWidescreen(CFG.widescreen); cancelBtnImg.SetWidescreen(CFG.widescreen); } GuiButton cancelBtn(&cancelBtnImg,&cancelBtnImg, 2, 3, 180, 400, &trigA, &btnSoundOver, btnClick2,1); cancelBtn.SetScale(0.9); cancelBtn.SetLabel(&cancelBtnTxt); cancelBtn.SetTrigger(&trigB); u8 scrollbaron = 0; if (num_titles > 9) scrollbaron = 1; GuiCustomOptionBrowser optionBrowser3(396, 280, &options3, CFG.theme_path, "bg_options_gamesettings.png", bg_options_settings_png, num_titles+num_sys_titles>9?1:0, 200); optionBrowser3.SetPosition(0, 90); optionBrowser3.SetAlignment(ALIGN_CENTRE, ALIGN_TOP); snprintf(imgPath, sizeof(imgPath), "%sWifi_btn.png", CFG.theme_path); GuiImageData wifiImgData(imgPath, Wifi_btn_png); GuiImage wifiImg(&wifiImgData); if (Settings.wsprompt == yes) { wifiImg.SetWidescreen(CFG.widescreen); } GuiButton wifiBtn(wifiImg.GetWidth(), wifiImg.GetHeight()); wifiBtn.SetImage(&wifiImg); wifiBtn.SetPosition(100, 400); wifiBtn.SetEffectGrow(); wifiBtn.SetAlpha(80); wifiBtn.SetTrigger(&trigA); GuiTrigger trigZ; trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z); GuiButton screenShotBtn(0,0); screenShotBtn.SetPosition(0,0); screenShotBtn.SetTrigger(&trigZ); HaltGui(); GuiWindow w(screenwidth, screenheight); w.Append(&screenShotBtn); w.Append(&settingsbackgroundbtn); w.Append(&titleTxt); w.Append(&cancelBtn); w.Append(&wifiBtn); w.Append(&optionBrowser3); mainWindow->Append(&w); int tmp=num_titles+num_sys_titles; ResumeGui(); numtitle=num_titles; while (!exit) { VIDEO_WaitVSync(); if (shutdown == 1) Sys_Shutdown(); if (reset == 1) Sys_Reboot(); else if (wifiBtn.GetState() == STATE_CLICKED) { ResumeNetworkWait(); wifiBtn.ResetState(); } if (IsNetworkInit()) { wifiBtn.SetAlpha(255); } ret = optionBrowser3.GetClickedOption(); if (ret > -1) {//if a click happened //char name[50]; char text[15]; if (f)rewind(f); //strcpy(name,"");//make sure name is empty if (ret<numtitle) { //set the title's name, number, ID to text sprintf(text, "%s", titleText(type, titles[ret])); char temp[100]; //prompt to boot selected title snprintf(temp, sizeof(temp), "%s : %s",text,name[ret]); int choice = WindowPrompt(tr("Boot?"), temp, tr("OK"), tr("Cancel")); if (choice) {//if they say yes //stop all this stuff before starting the channel CloseXMLDatabase(); ExitGUIThreads(); ShutdownAudio(); StopGX(); WII_Initialize(); WII_LaunchTitle(TITLE_ID(type,titles[ret])); //this really shouldn't be needed because the title will be booted exit = true; break; } else { //if they said no to booting the title ret = -1; optionBrowser3.ResetState(); } } else { //if they clicked a system title if (ret == tmp) { CloseXMLDatabase(); ExitGUIThreads(); ShutdownAudio(); StopGX(); WII_Initialize(); WII_ReturnToSettings(); } else { //set the title's name, number, ID to text sprintf(text, "%s", titleText(0x00010002, sys_titles[ret-num_titles])); char temp[112]; //prompt to boot selected title snprintf(temp, sizeof(temp), tr("%s : %s May not boot correctly if your System Menu is not up to date."),text,name[ret]); int choice = WindowPrompt(tr("Boot?"), temp, tr("OK"), tr("Cancel")); if (choice) {//if they say yes //stop all this stuff before starting the channel CloseXMLDatabase(); ExitGUIThreads(); ShutdownAudio(); StopGX(); WII_Initialize(); WII_LaunchTitle(TITLE_ID(0x00010002,sys_titles[ret-num_titles])); //this really shouldn't be needed because the title will be booted exit = true; break; } else { //if they said no to booting the title ret = -1; optionBrowser3.ResetState(); } } } } if(infilesize > 0) { char filesizetxt[50]; char temp[50]; char filepath[100]; // u32 read = 0; //make sure there is a folder for this to be saved in struct stat st; snprintf(filepath, sizeof(filepath), "%s/wad/", bootDevice); if (stat(filepath, &st) != 0) { if (subfoldercreate(filepath) != 1) { WindowPrompt(tr("Error !"),tr("Can't create directory"),tr("OK")); } } snprintf(filepath, sizeof(filepath), "%s/wad/tmp.tmp", bootDevice); if (infilesize < MB_SIZE) snprintf(filesizetxt, sizeof(filesizetxt), tr("Incoming file %0.2fKB"), infilesize/KB_SIZE); else snprintf(filesizetxt, sizeof(filesizetxt), tr("Incoming file %0.2fMB"), infilesize/MB_SIZE); snprintf(temp, sizeof(temp), tr("Load file from: %s ?"), GetIncommingIP()); int choice = WindowPrompt(filesizetxt, temp, tr("OK"), tr("Cancel")); gprintf("\nchoice:%d",choice); if (choice == 1) { u32 read = 0; u8 *temp = NULL; int len = NETWORKBLOCKSIZE; temp = (u8 *) malloc(infilesize); bool error = false; u8 *ptr = temp; gprintf("\nrecieving shit"); while (read < infilesize) { ShowProgress(tr("Receiving file from:"), GetIncommingIP(), NULL, read, infilesize, true); if (infilesize - read < (u32) len) len = infilesize-read; else len = NETWORKBLOCKSIZE; int result = network_read(ptr, len); if (result < 0) { WindowPrompt(tr("Error while transfering data."), 0, tr("OK")); error = true; break; } if (!result) { gprintf("\n!RESULT"); break; } ptr += result; read += result; } ProgressStop(); char filename[101]; char tmptxt[200]; //bool installWad=0; if (!error) { gprintf("\nno error yet"); network_read((u8*) &filename, 100); gprintf("\nfilename: %s",filename); // Do we need to unzip this thing? if (wiiloadVersion[0] > 0 || wiiloadVersion[1] > 4) { gprintf("\nusing newer wiiload version"); if (uncfilesize != 0) { // if uncfilesize == 0, it's not compressed gprintf("\ntrying to uncompress"); // It's compressed, uncompress u8 *unc = (u8 *) malloc(uncfilesize); uLongf f = uncfilesize; error = uncompress(unc, &f, temp, infilesize) != Z_OK; uncfilesize = f; free(temp); temp = unc; } } if (!error) { sprintf(tmptxt,"%s",filename); //if we got a wad if (strcasestr(tmptxt,".wad")) { FILE *file = fopen(filepath, "wb"); fwrite(temp, 1, (uncfilesize>0?uncfilesize:infilesize), file); fclose(file); sprintf(tmptxt,"%s/wad/%s",bootDevice,filename); if (checkfile(tmptxt))remove(tmptxt); rename(filepath, tmptxt); //check and make sure the wad we just saved is the correct size u32 lSize; file = fopen(tmptxt, "rb"); // obtain file size: fseek (file , 0 , SEEK_END); lSize = ftell (file); rewind (file); if (lSize==(uncfilesize>0?uncfilesize:infilesize)) { gprintf("\nsize is ok"); int pick = WindowPrompt(tr(" Wad Saved as:"), tmptxt, tr("Install"),tr("Uninstall"),tr("Cancel")); //install or uninstall it if (pick==1) { HaltGui(); w.Remove(&titleTxt); w.Remove(&cancelBtn); w.Remove(&wifiBtn); w.Remove(&optionBrowser3); ResumeGui(); Wad_Install(file); HaltGui(); w.Append(&titleTxt); w.Append(&cancelBtn); w.Append(&wifiBtn); w.Append(&optionBrowser3); ResumeGui(); } if (pick==2)Wad_Uninstall(file); } else gprintf("\nBad size"); //close that beast, we're done with it fclose (file); //do we want to keep the file in the wad folder if (WindowPrompt(tr("Delete ?"), tmptxt, tr("Delete"),tr("Keep"))!=0) remove(tmptxt); } else { WindowPrompt(tr("ERROR:"), tr("Not a WAD file."), tr("OK")); } } } if (error || read != infilesize) { WindowPrompt(tr("Error:"), tr("No data could be read."), tr("OK")); } if(temp)free(temp); } CloseConnection(); ResumeNetworkWait(); } if (cancelBtn.GetState() == STATE_CLICKED) { //break the loop and end the function exit = true; ret = -10; } else if (screenShotBtn.GetState() == STATE_CLICKED) { gprintf("\n\tscreenShotBtn clicked"); screenShotBtn.ResetState(); ScreenShot(); gprintf("...It's easy, mmmmmmKay"); } } CloseConnection(); if (IsNetworkInit()) HaltNetworkThread(); fclose(f); HaltGui(); mainWindow->Remove(&w); ResumeGui(); return ret; }