Exemple #1
0
void
do_perft(position_t *pos, scored_move_t *ms, int ply, int depth)
{
	scored_move_t *msbase = ms;
	uint8 stm = Stm(ply);
	scored_move_t *mv;

	if (Checked(stm^1))
		return;

	if (Checked(stm)) {
		ms = generate_evasions(pos, ms, ply);
		for (mv = msbase; mv < ms; mv++)
			if (PieceType(Capture(mv->move)) == KING)
				return;
	} else {
		ms = generate_captures(pos, ms, ply);
		for (mv = msbase; mv < ms; mv++)
			if (PieceType(Capture(mv->move)) == KING)
				return;
		ms = generate_noncaptures(pos, ms, ply);
	}

	for (mv = msbase; mv < ms; mv++) {
		make_move(pos, mv->move, ply);
		if (depth - 1)
			do_perft(pos, ms, ply + 1, depth - 1);
		else if (!Checked(stm))
			total_moves++;
		unmake_move(pos, mv->move, ply);
	}
}
Exemple #2
0
void cGUIButton::OnUpdate()
{
	if(einput->isMouseDown(0))
	{
		if(m_mousein)
			Capture(true);
	}
	else
	if(!einput->mouseValue(0))
	{
		if(IsCaptured()) 
		{ 
			Capture(false);
			if(m_mousein)
				Action(1);
		}
	}

	if(!IsCaptured() && m_mousein && einput->isMouseDown(1))
		Action(2);

	if( g_gui->m_capture == this ) 
		style |= GUISTYLE_PRESSED;
	else
		style &= ~GUISTYLE_PRESSED;
}
Exemple #3
0
void GSplitter::OnMouseClick(GMouse &m)
{
	if (m.Down())
	{
		if (OverSplit(m.x, m.y))
		{
			Capture(true);

			if (d->Vertical)
			{
				d->Bar.x1 = d->PosA.x2;
				d->Bar.y1 = d->PosA.y1;
				d->Bar.x2 = d->PosB.x1;
				d->Bar.y2 = d->PosA.y2;
				d->Offset = m.x - d->Bar.x1;
			}
			else
			{
				d->Bar.x1 = d->PosA.x1;
				d->Bar.y1 = d->PosA.y2;
				d->Bar.x2 = d->PosA.x2;
				d->Bar.y2 = d->PosB.y1;
				d->Offset = m.y - d->Bar.y1;
			}
		}
	}
	else if (IsCapturing())
	{
		Capture(false);
	}
}
void* camera_action(void* parameters)
{
	struct arguments* p = (struct arguments*) parameters;

	Set_Up_Camera();
	Capture(&My_Buffer);
	thresholded=threshold(My_Buffer,Width,Height,refR_YELLOW,refG_YELLOW,refB_YELLOW,disD_YELLOW,refR_RED,refG_RED,refB_RED,disD_RED);	
	make_bmp(My_Buffer,"Img1",Width,Height);
	make_bmp(thresholded,"Img2",Width,Height);			
	find_XY(My_Buffer,Width,Height,refR_YELLOW,refG_YELLOW,refB_YELLOW,disD_YELLOW,&x_YELLOW,&y_YELLOW,refR_RED,refG_RED,refB_RED,disD_RED,&x_RED,&y_RED);

	p->curr_x=x_YELLOW;
	p->curr_y=y_YELLOW;
	p->prev_x=x_YELLOW;
	p->prev_y=y_YELLOW;

	while(1)
	{
		lock1=1;
		p->prev_x=p->curr_x;
		p->prev_y=p->curr_y;
		Capture(&My_Buffer);
		find_XY(My_Buffer,Width,Height,refR_YELLOW,refG_YELLOW,refB_YELLOW,disD_YELLOW,&x_YELLOW,&y_YELLOW,refR_RED,refG_RED,refB_RED,disD_RED,&x_RED,&y_RED);
		p->curr_x=x_YELLOW;
		p->curr_y=y_YELLOW;
		lock1=0;
		//printf("(%d,%d,%d,%d)\n",x_YELLOW,y_YELLOW,x_RED,y_RED);
		//handle_clicks();

	if(abs(x_YELLOW-x_RED)<70&&abs(y_YELLOW-y_RED)<70&&left_pressed==0&&y_YELLOW>y_RED)
	{
		report_left_mouse_press();
		printf("Mouse Pressed\n");
		left_pressed=1;	
	}
	if((!(abs(x_YELLOW-x_RED)<70&&abs(y_YELLOW-y_RED)<70)&&y_YELLOW>y_RED)&&left_pressed==1)
	{
		report_left_mouse_released();
		printf("Mouse Released\n");
		left_pressed=0;
	}



		usleep(200000);
	}
	return NULL;
}
void __fastcall TForm1::btnTriggerClick(TObject *Sender)
{
      if(tvConnectDev->Selected == NULL) return;
      PDevInfo pDev = NULL;
      TTreeNodes *nodes = tvConnectDev->Items;
      if(nodes != NULL)
      {
          for(int i = 0; i < nodes->Count; i++)
          {
              if(TreeView_GetCheckState(tvConnectDev->Handle,nodes->Item[i]->ItemId))
              {
                String strViewIP = nodes->Item[i]->Text;

                  for(int j = 0; j < pDevList->Count; j++)
                  {
                      pDev = PDevInfo(pDevList->Items[j]);
                      if(pDev != NULL)
                      {
                          String strDevListIP;
                          strDevListIP.sprintf("%s", pDev->ucIP);
                          if(strDevListIP == strViewIP)
                          {   if(pDev->pHandle != NULL)
                              {
                                  int nRes = Capture(pDev->pHandle);
                                  if(nRes != 0) ShowMessage("模拟触发失败,返回值 = " + IntToStr(nRes));
                                  return;
                              }
                          }
                      }
                  }
              }
          }
      }
}
Exemple #6
0
void Camera::run() {

	while (1) {
		if (processData) {

			processData = false; // Wait till the next frame (interrup) fires processing
			DetectSatellite(); // Perform detection algorithm

			if (sendPic) { // If picture was requested, send
				tm.turnOff();
				char tmpVal[4];
				tmUart.write("CAMERA", 6);
				for (int i = 0; i < IMAGESIZE; i += 2) {
					sprintf(tmpVal, "%03u", DCMI_Buffer[i]);
					tmUart.write(tmpVal, 4);
					while (!tmUart.isWriteFinished()) {
					}
				}
				tmUart.write("CAMEND", 6);
				sendPic = false;
			}

			if (active) { // Continue captureing/processing if cam is still active
				Capture();
			}

			suspendCallerUntil(NOW()+200*MILLISECONDS); // Could run even faster but 200ms is suficient for mission mode
		}
	}

}
Exemple #7
0
void CGLView::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: 여기에 그리기 코드를 추가합니다.
	BeginGL();

	Setup_Viewport();

	ClearBuffer();

	Setup_Projection();

	Setup_Camera();

	glLightfv(GL_LIGHT0, GL_POSITION, m_vp.LightPosition0);

	DrawGL();


	glFinish();

	Capture();

	SwapBuffers(m_dp.hdc);

	EndGL();

}
void Simulation::Update()
{
    Move();
    Generate();
    Defeat();
    Capture();
    Rescue();
}
Exemple #9
0
 void Entity::CaptureAll()
 {
     Capture();
     for (auto it = _children.begin(); it != _children.end(); ++it)
     {
         (*it)->Capture();
     }
 }
Exemple #10
0
void GSlider::OnMouseClick(GMouse &m)
{
	Capture(m.Down());
	if (Thumb.Overlap(m.x, m.y))
	{
		Tx = m.x - Thumb.x1;
		Ty = m.y - Thumb.y1;
	}
}
Exemple #11
0
int main()
{
	New();
	
	LifeState* snakePair = NewState("2ob2o$o3bo$bobo$2ob2o!", -15, -7);
	LifeTarget* target = NewTarget(snakePair);
	
	//For lower part
	LifeState* synth = NewState("obo$b2o$bo13$4bo$4b2o$3bobo$11b3o$11bo$12bo$18bo$17b2o$17bobo!", -20, -20);
	LifeState* gld = NewState("bo$2o$obo!", -6, 13, 1, 0, 0, 1);
	LifeIterator* iter = NewIterator(gld, -30, -30, 60, 60, 4);
	LifeTarget* targetEmpty = NewTarget(Captures[1], NewState("5o2bo2b5o$5ob3ob5o$6obob6o$5o2bo2b5o$15o$15o$15o$15o$15o$15o$15o$15o$15o$15o$15o$15o!", -20, -7));

	//For upper part
	//LifeState* synth = NewState("obo$b2o$bo13$4bo$4b2o$3bobo$11b3o$11bo$12bo$18bo$17b2o$17bobo5$11bo$10b2o$10bobo!", -20, -20);
	//LifeTarget* targetEmpty = NewTarget(Captures[1], NewState("15o$15o$15o$15o$15o$15o$15o$15o$15o$15o$15o$5o2bo2b5o$5ob3ob5o$6obob6o$5o2bo2b5o!", -20, -18));
	//LifeState* gld = NewState("2bo$2o$b2o!", -2, -23, 1, 0, 0, -1);
	//LifeIterator* iter = NewIterator(gld, -30, -10, 60, 60, 4);
	
	do
	{
		New();
		
		PutState(synth);
		PutState(iter);
		
		
		Run(210);
		Capture(0);
		Run(2);
		
		//if(ContainsTarget(targetEmpty) == NO && ContainsTarget(target) == YES && GetPop() != 12 + 5)
		if(ContainsTarget(targetEmpty) == NO && ContainsTarget(target) == YES)// && !AreEqual(0))
		{
			Print();
			
			New();
			
			PutState(synth);
			PutState(iter);
			
			PrintRLE();
			//Print();
			
			printf("\nSUCCESS\n");
			getchar();
			printf("\nSearching\n");
			
		}
	}
	while(Next(iter) == SUCCESS);
	
	printf("\nFinish\n");
	
	getchar();
}
void ScreenshotCommand::CaptureDock(wxWindow *win, wxString fileName)
{
   int x = 0, y = 0;
   int width, height;

   win->ClientToScreen(&x, &y);
   win->GetParent()->ScreenToClient(&x, &y);
   win->GetClientSize(&width, &height);

   Capture(fileName, win, x, y, width, height);
}
bool AutoCaptureMechanism::Capture(wxBitmap* bitmap, Control& ctrl)
{
    // no manual specification for the control name
    // or name adjustment is disabled globally
    if (ctrl.name == wxT("") || m_flag & AJ_DisableNameAdjust)
    {
        // Get its name from wxRTTI
        ctrl.name = ctrl.ctrl->GetClassInfo()->GetClassName();
    }

    int choice = wxNO;

    wxRect rect = GetRect(ctrl.ctrl, ctrl.flag);

    if (ctrl.flag & AJ_Dropdown && !(m_flag & AJ_DisableDropdown))
    {
        // for drop-down controls we need the help of the user
        wxString caption = _("Drop-down screenshot...");
        wxString msg =
            wxString::Format(_("Do you wish to capture the drop-down list of '%s' ?\n\n If YES, please drop down the list of '%s' in 5 seconds after closing this message box.\n If NO, the screenshot for this control won't contain its drop-down list."),
                             ctrl.name, ctrl.name);

        choice = wxMessageBox(msg, caption, wxYES_NO, m_notebook);

        if (choice == wxYES)
        {
            //A little hint
            ctrl.ctrl->SetCursor(wxCursor(wxCURSOR_HAND));

            // Do some rect adjust so it can include the dropdown list
            // This adjust isn't pretty, but it works fine on all three paltforms.
            // Looking forward to a better solution
            int h = rect.GetHeight();
            rect.SetHeight(h * 4);
        }
    }

    // cut off "wx" and change the name into lowercase.
    // e.g. wxButton will have a name of "button" at the end
    ctrl.name.StartsWith(wxT("wx"), &(ctrl.name));
    ctrl.name.MakeLower();

    // take the screenshot
    Capture(bitmap, rect, (choice == wxYES)?5:0);

    if (choice == wxYES) ctrl.ctrl->SetCursor(wxNullCursor);

    if (ctrl.flag & AJ_RegionAdjust)
        PutBack(ctrl.ctrl);

    return true;
}
Exemple #14
0
CameraFeed::CameraFeed() {
//  is_capturing_ = false;
  timer_.setInterval(100);
  connect(&timer_, SIGNAL(timeout()),
          this, SLOT(Capture()));

  QSettings settings("Astronomican.ini", QSettings::IniFormat);
  settings.beginGroup("Main Camera");
  size_ = (settings.value("frame_size", QSize(1280, 720))).toSize();

  settings.endGroup();

}
HRESULT WIACamera::CaptureAllSequ(IplImage ***pIplImages)
{
	HRESULT hr = S_OK;

	if ( (*pIplImages)==NULL ) {
		Allocate(pIplImages);
	}

	for ( unsigned int id=0; id < m_iCount; id++ ) {
		Capture(id,&(*pIplImages)[id]);
	}

	return hr;
}
Exemple #16
0
    bool Particle::Update()
    {
        TLFXLOG(PARTICLES, ("particle #%p update", this));

        Capture();

        if (_emitter->IsDying() || _emitter->IsOneShot() || _dead)
            _releaseSingleParticle = true;

        if (_emitter->IsSingleParticle() && !_releaseSingleParticle)
        {
            _age = _particleManager->GetCurrentTime() - _dob;
            if (_age > _lifeTime)
            {
                _age = 0;
                _dob = _particleManager->GetCurrentTime();
            }
        }
        else
        {
            _age = _particleManager->GetCurrentTime() - _dob;
        }

        base::Update();

        if (_age > _lifeTime || _dead == 2)                 // if dead=2 then that means its reached the end of the line (in kill mode) for line traversal effects
        {
            _dead = 1;
            if (_children.empty())
            {
                _particleManager->ReleaseParticle(this);
                if (_emitter->IsGroupParticles())
                    _emitter->GetParentEffect()->RemoveInUse(_layer, this);

                Reset();
                return false;               // RemoveChild
            }
            else
            {
                _emitter->ControlParticle(this);
                KillChildren();
            }

            return true;
        }

        _emitter->ControlParticle(this);
        return true;
    }
Exemple #17
0
BOOL CDlgStackTrace::OnInitDialog() 
{_STT();
	CDialog::OnInitDialog();

	if ( m_images.GetSafeHandle() == NULL )
	{	m_images.Create( 16, 16, ILC_MASK | ILC_COLOR24, 0, 32 );
		m_images.Add( AfxGetApp()->LoadIcon( IDI_GOLDDOT ) );		
	} // end if

	ListCtrl_SetExtendedListViewStyle( m_list.GetSafeHwnd(), LVS_EX_FULLROWSELECT );

	m_list.SetImageList( &m_images, LVSIL_NORMAL );
	m_list.SetImageList( &m_images, LVSIL_SMALL );

	m_tabSource.InsertItem(	0, "Call Stack" );
#ifdef ENABLE_STACK_HISTORY
	m_tabSource.InsertItem(	1, "Stack History" );
#endif
#ifdef ENABLE_STACK_PROFILE
	m_tabSource.InsertItem(	2, "Stack Profile" );
#endif

	m_tabSource.SetCurSel( 0 );

/*
	m_comboSource.SetItemData( m_comboSource.AddString( "Call Stack" ), 0 );

#ifdef ENABLE_STACK_HISTORY
	m_comboSource.SetItemData( m_comboSource.AddString( "Stack History" ), 1 );
#endif

#ifdef ENABLE_STACK_PROFILE
	m_comboSource.SetItemData( m_comboSource.AddString( "Stack Profile" ), 2 );
#endif

	m_comboSource.SetCurSel( 0 );
*/
	Size();

	Capture();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
int main(int argc, char ** argv) {
	FloatRect startRegion(-50, -50, 100, 100);
	if (argc == 1) {
		std::cout << "\nusage:\t./tracker video.mp4\n\n";
		std::cout << "\t./tracker video.mp4 x y w h\n\n";
		return 0;
	} else if (argc > 5) {
		startRegion = FloatRect(atof(argv[2]), atof(argv[3]), atof(argv[4]), atof(argv[5]));
	}
	vidhance_load();
    Display display("normal");
    Display displayStabilized("tracker");
    VidhanceTracker tracker(startRegion);
    Capture(argv[1]).foreach([&](const Image& image){
		display.show(image);
		displayStabilized.show(tracker.process(image));
	});
	return 0;
}
void DoCaptureDown( void)
{
	
	bool stat = IsEngaged();
	if (stat == 0)
	{
		Engage();
	}
	FrameDown();
	stat = LithoIsScanning();
	if (stat == 0)
	{
		LithoScan(1);
	}  
	
	Capture(0,CaptureFlags(0));
	
	WaitForCapture();
	LithoScan(0);
}
float UAbilitySystemBlueprintLibrary::EvaluateAttributeValueWithTags(UAbilitySystemComponent* AbilitySystem, FGameplayAttribute Attribute, const FGameplayTagContainer& SourceTags, const FGameplayTagContainer& TargetTags, bool& bSuccess)
{
	float RetVal = 0.f;
	if (!AbilitySystem || !AbilitySystem->HasAttributeSetForAttribute(Attribute))
	{
		bSuccess = false;
		return RetVal;
	}

	FGameplayEffectAttributeCaptureDefinition Capture(Attribute, EGameplayEffectAttributeCaptureSource::Source, true);

	FGameplayEffectAttributeCaptureSpec CaptureSpec(Capture);
	AbilitySystem->CaptureAttributeForGameplayEffect(CaptureSpec);

	FAggregatorEvaluateParameters EvalParams;

	EvalParams.SourceTags = &SourceTags;
	EvalParams.TargetTags = &TargetTags;

	bSuccess = CaptureSpec.AttemptCalculateAttributeMagnitude(EvalParams, RetVal);

	return RetVal;
}
void CFlagZoneBase::Touch( CBaseEntity *pOther )
{
	if ( m_bDisabled )
		return;

	if ( !pOther )
	{
		return;
	}
	else if ( !pOther->IsPlayer() )
	{
		return;
	}

	CModPlayer *pPlayer = ToModPlayer( pOther );
	if ( GetTeamNumber() == pPlayer->GetTeamNumber() ||
		GetTeamNumber() == TEAM_SPECTATOR )
	{
		if ( pPlayer->HasFlag () )
		{
			Capture( pPlayer );
		}
	}
}
void WIACamera::CaptureThread()
{
	int id;
	{
		HANDLE hMutex = CreateMutex( NULL, FALSE, NULL );

		WaitForSingleObject( hMutex, INFINITE );
		id = m_iCameraCounterForThread;
		m_iCameraCounterForThread++;
		ReleaseMutex( hMutex );
	}

	HRESULT hr = Capture(id, &(*m_pImagesForThread)[id] );

	{
		HANDLE hMutex = CreateMutex( NULL, FALSE, NULL );
		WaitForSingleObject( hMutex, INFINITE );
		m_iImageCounterForThread++;
		if ( hr != S_OK ) {
			m_hrForThread = hr;
		}
		ReleaseMutex( hMutex );
	}
}
void ScreenshotCommand::CaptureToolbar(ToolManager *man, int type, wxString name)
{
   bool visible = man->IsVisible(type);
   if (!visible) {
      man->ShowHide(type);
      Yield();
   }

   wxWindow *w = man->GetToolBar(type);
   int x = 0, y = 0;
   int width, height;

   w->ClientToScreen(&x, &y);
   w->GetParent()->ScreenToClient(&x, &y);
   w->GetClientSize(&width, &height);

   Capture(name, w, x, y, width, height);

   if (!visible) {
      man->ShowHide(type);
      if (mIgnore)
         mIgnore->Raise();
   }
}
Exemple #24
0
bool FtpDataAnalyzer::TryRecognize() {
	if (m_ci->GetWasSYN()) {
		TRC(2, m_ci->DstEndPoint);

		FtpAnalyzerClass::CDataEndpoints::iterator it = FtpAnalyzerClass::I->DataEndpoints.find(m_ci->DstEndPoint);
		if (it != FtpAnalyzerClass::I->DataEndpoints.end()) {
			FileMessage = it->second.first;
			FtpAnalyzerClass::I->DataEndpoints.erase(it);
			Capture();

#if UCFG_SNIF_PACKET_CAPTURE
			if (CTcpMan::s_bEnableLog && FileMessage && g_opt_SaveFiles) {
				String dir = Path::Combine(g_ftpMessageAnalyzerClass.Dir, "files");
				String fullpath = AddDirSeparator(dir)+ FileMessage->Filename;
				Directory::CreateDirectory(Path::GetDirectoryName(fullpath));
				FileMessage->m_stm.Open(fullpath, FileMode::Create, FileAccess::Write);
			}
#endif
			return true;
		}
	}
	Delete();
	return false;
}
Exemple #25
0
// 생성자(Capture)
CDIB::CDIB(HWND hwnd)
:	DIB(NULL), Alpha(NULL), Rgn(NULL)
{
	Construct();
	Capture(hwnd);
}
Exemple #26
0
int Move(int Cboard[10][12], int x1, int y1, int x2, int y2){

int it_moved = 1;	/*it_moved = 0 - it can't move; = 1 - it moved; = 2 - it captured*/
/*printf("Inside Move it_moved is %d\n", it_moved);*/
int whichpiece = Cboard[x1][y1];
/*printf("which piece is %d\n", whichpiece);*/


switch(whichpiece)
{

	case 20: case -20: case 21: case -21:
		if(ValidPawnMove(Cboard, x1, y1, x2, y2) == 1){
			
			/*checks if first move, and pawn will double move, updates board with the info*/
			if(Cboard[x1][y1] >0 && y1 == 9 && y2 == y1-2)
				Cboard[x1][y1] += 1;
			else if(Cboard[x1][y1] <0 && y1 == 2 && y2 == y1+2)
				Cboard[x1][y1] += -1;
			
			/*check if capture, move the piece*/
			if(Cboard[x2][y2] != 0){

			Capture(Cboard, x1, y1, x2, y2);
			it_moved = 2;
			}
			
			else{
				Cboard[x2][y2] = Cboard[x1][y1];
				Cboard[x1][y1] = 0;
			}
			
			if((y2 = 2) || (y2 = 9)){
				PawnPromotion(Cboard, x2, y2);
			}
		
		}
		
		else{
		printf("Not a valid move\n");
		it_moved = 0;
		}
		break;
	
	case 3: case -3:
		if(ValidRookMove(Cboard, x1, y1, x2, y2) == 1){
		
			/*check if capture, move the piece*/
			if(Cboard[x2][y2] != 0){

			Capture(Cboard, x1, y1, x2, y2);
			it_moved = 2;
			}
			
			else{
				Cboard[x2][y2] = Cboard[x1][y1];
				Cboard[x1][y1] = 0;
			}
			
			/*top left rook*/
			if((x1 = 1) && (y1 = 2)){
				HasRook1Moved = 1;
			}
			
			/*top right rook*/
			else if((x1 = 8) && (y1 = 2)){
				HasRook2Moved = 1;
			}
			
			/*bottom left rook*/
			else if((x1 = 1) && (y1 = 9)){
				HasRook3Moved = 1;
			}
			
			/*bottom right rook*/
			else if((x1 = 8) && (y1 = 9)){
				HasRook4Moved = 1;
			}
		
		}
		
		else{
		printf("Not a valid move\n");
		it_moved = 0;
		}
		break;
	
	case 5: case -5:
		if(ValidKnightMove(Cboard, x1, y1, x2, y2) == 1){
		
			/*check if capture, move the piece*/
			if(Cboard[x2][y2] != 0){

			Capture(Cboard, x1, y1, x2, y2);
			it_moved = 2;
			}
			
			else{
				Cboard[x2][y2] = Cboard[x1][y1];
				Cboard[x1][y1] = 0;
			}
		
		}
		
		else{
		printf("Not a valid move\n");
		it_moved = 0;
		}
		break;
		
	case 7: case -7:
		if(ValidBishopMove(Cboard, x1, y1, x2, y2) == 1){
		
			/*check if capture, move the piece*/
			if(Cboard[x2][y2] != 0){

			Capture(Cboard, x1, y1, x2, y2);
			it_moved = 2;
			}
			
			else{
				Cboard[x2][y2] = Cboard[x1][y1];
				Cboard[x1][y1] = 0;
			}
		
		}
		
		else{
		printf("Not a valid move\n");
		it_moved = 0;
		}
		break;
		
	case 9: case -9:
		if(ValidQueenMove(Cboard, x1, y1, x2, y2) == 1){
		
			/*check if capture, move the piece*/
			if(Cboard[x2][y2] != 0){

			Capture(Cboard, x1, y1, x2, y2);
			it_moved = 2;
			}
			
			else{
				Cboard[x2][y2] = Cboard[x1][y1];
				Cboard[x1][y1] = 0;
			}
		
		}
		
		else{
		printf("Not a valid move\n");
		it_moved = 0;
		}
		break;
		
	case 10: case -10:
		if(ValidKingMove(Cboard, x1, y1, x2, y2) == 1){
		
			/*check if capture, move the piece*/
			if(Cboard[x2][y2] != 0){

			Capture(Cboard, x1, y1, x2, y2);
			it_moved = 2;
			}
			
			else{
				Cboard[x2][y2] = Cboard[x1][y1];
				Cboard[x1][y1] = 0;
			}
		
		}
		
		else{
		printf("Not a valid move\n");
		it_moved = 0;
		}
		
		/* check castling !!!STILL NEEDED!!!*/
		break;
		
	default :
		printf("No piece selected\n");
		it_moved = 0;

} /*end switch*/
	/* printf("it_moved end of Move = %d\n", it_moved);*/
	return it_moved;

/*if checkmate, print out You Win or You Lose, Start New Game or Quit */
}/*end move*/
bool ScreenshotCommand::Apply(CommandExecutionContext context)
{
   // Read the parameters that were passed in
   wxString filePath    = GetString(wxT("FilePath"));
   wxString captureMode = GetString(wxT("CaptureMode"));
   wxString background  = GetString(wxT("Background"));

   // Build a suitable filename
   wxString fileName = MakeFileName(filePath, captureMode);

   if (background.IsSameAs(wxT("Blue")))
   {
      mBackground = true;
      mBackColor = wxColour(51, 102, 153);
   }
   else if (background.IsSameAs(wxT("White")))
   {
      mBackground = true;
      mBackColor = wxColour(255, 255, 255);
   }
   else
   {
      mBackground = false;
   }

   // Reset the toolbars to a known state
   context.proj->mToolManager->Reset();

   wxTopLevelWindow *w = GetFrontWindow(context.proj);
   if (!w)
   {
      return false;
   }

   if (captureMode.IsSameAs(wxT("window")))
   {
      int x = 0, y = 0;
      int width, height;

      w->ClientToScreen(&x, &y);
      w->GetClientSize(&width, &height);

      if (w != context.proj && w->GetTitle() != wxT("")) {
         fileName = MakeFileName(filePath,
               captureMode + (wxT("-") + w->GetTitle() + wxT("-")));
      }

      Capture(fileName, w, x, y, width, height);
   }
   else if (captureMode.IsSameAs(wxT("fullwindow"))
         || captureMode.IsSameAs(wxT("windowplus")))
   {

      wxRect r = w->GetRect();
      r.SetPosition(w->GetScreenPosition());
      r = w->GetScreenRect();

      if (w != context.proj && w->GetTitle() != wxT("")) {
         fileName = MakeFileName(filePath,
               captureMode + (wxT("-") + w->GetTitle() + wxT("-")));
      }

#if defined(__WXGTK__)
      // In wxGTK, we need to include decoration sizes
      r.width += (wxSystemSettings::GetMetric(wxSYS_BORDER_X, w) * 2);
      r.height += wxSystemSettings::GetMetric(wxSYS_CAPTION_Y, w) +
         wxSystemSettings::GetMetric(wxSYS_BORDER_Y, w);
#endif
      if (!mBackground && captureMode.IsSameAs(wxT("windowplus")))
      {
         // background colour not selected but we want a background
         wxRect b = GetBackgroundRect();
         r.x = (r.x - b.x) >= 0 ? (r.x - b.x): 0;
         r.y = (r.y - b.y) >= 0 ? (r.y - b.y): 0;
         r.width += b.width;
         r.height += b.height;
      }

      Capture(fileName, w, r.x, r.y, r.width, r.height, true);
   }
   else if (captureMode.IsSameAs(wxT("fullscreen")))
   {
      int width, height;
      wxDisplaySize(&width, &height);

      Capture(fileName, w, 0, 0, width, height);
   }
   else if (captureMode.IsSameAs(wxT("toolbars")))
   {
      CaptureDock(context.proj->mToolManager->GetTopDock(), fileName);
   }
   else if (captureMode.IsSameAs(wxT("selectionbar")))
   {
      CaptureDock(context.proj->mToolManager->GetBotDock(), fileName);
   }
   else if (captureMode.IsSameAs(wxT("tools")))
   {
      CaptureToolbar(context.proj->mToolManager, ToolsBarID, fileName);
   }
   else if (captureMode.IsSameAs(wxT("control")))
   {
      CaptureToolbar(context.proj->mToolManager, ControlBarID, fileName);
   }
   else if (captureMode.IsSameAs(wxT("mixer")))
   {
      CaptureToolbar(context.proj->mToolManager, MixerBarID, fileName);
   }
   else if (captureMode.IsSameAs(wxT("meter")))
   {
      CaptureToolbar(context.proj->mToolManager, MeterBarID, fileName);
   }
   else if (captureMode.IsSameAs(wxT("edit")))
   {
      CaptureToolbar(context.proj->mToolManager, EditBarID, fileName);
   }
   else if (captureMode.IsSameAs(wxT("device")))
   {
      CaptureToolbar(context.proj->mToolManager, DeviceBarID, fileName);
   }
   else if (captureMode.IsSameAs(wxT("transcription")))
   {
      CaptureToolbar(context.proj->mToolManager, TranscriptionBarID, fileName);
   }
   else if (captureMode.IsSameAs(wxT("trackpanel")))
   {
      TrackPanel *panel = context.proj->mTrackPanel;
      AdornedRulerPanel *ruler = panel->mRuler;

      int h = ruler->GetRulerHeight();
      int x = 0, y = -h;
      int width, height;

      panel->ClientToScreen(&x, &y);
      panel->GetParent()->ScreenToClient(&x, &y);
      panel->GetClientSize(&width, &height);

      Capture(fileName, panel, x, y, width, height + h);
   }
   else if (captureMode.IsSameAs(wxT("ruler")))
   {
      TrackPanel *panel = context.proj->mTrackPanel;
      AdornedRulerPanel *ruler = panel->mRuler;

      int x = 0, y = 0;
      int width, height;

      ruler->ClientToScreen(&x, &y);
      ruler->GetParent()->ScreenToClient(&x, &y);
      ruler->GetClientSize(&width, &height);
      height = ruler->GetRulerHeight();

      Capture(fileName, ruler, x, y, width, height);
   }
   else if (captureMode.IsSameAs(wxT("tracks")))
   {
      TrackPanel *panel = context.proj->mTrackPanel;

      int x = 0, y = 0;
      int width, height;

      panel->ClientToScreen(&x, &y);
      panel->GetParent()->ScreenToClient(&x, &y);
      panel->GetClientSize(&width, &height);

      Capture(fileName, panel, x, y, width, height);
   }
   else if (captureMode.IsSameAs(wxT("firsttrack")))
   {
      TrackPanel *panel = context.proj->mTrackPanel;
      TrackListIterator iter(context.proj->GetTracks());
      Track * t = iter.First();
      if (!t) {
         return false;
      }
      wxRect r = panel->FindTrackRect(t, true);

      int x = 0, y = r.y - 3;
      int width, height;

      panel->ClientToScreen(&x, &y);
      panel->GetParent()->ScreenToClient(&x, &y);
      panel->GetClientSize(&width, &height);

      Capture(fileName, panel, x, y, width, r.height + 6);

   }
   else if (captureMode.IsSameAs(wxT("secondtrack")))
   {
      TrackPanel *panel = context.proj->mTrackPanel;
      TrackListIterator iter(context.proj->GetTracks());
      Track * t = iter.First();
      if (!t) {
         return false;
      }
      if (t->GetLinked()) {
         t = iter.Next();
      }
      t = iter.Next();
      if (!t) {
         return false;
      }
      wxRect r = panel->FindTrackRect(t, true);

      int x = 0, y = r.y - 3;
      int width, height;

      panel->ClientToScreen(&x, &y);
      panel->GetParent()->ScreenToClient(&x, &y);
      panel->GetClientSize(&width, &height);

      Capture(fileName, panel, x, y, width, r.height + 6);
   }
   else
   {
      // Invalid capture mode!
      return false;
   }

   return true;
}
Exemple #28
0
Snapshot::Snapshot(const HWND& hWnd) : m_hBitmap(NULL)
{
	Capture(hWnd);
}
Exemple #29
0
void Notation::image(const Board & b, const Move & m, OutputFormat format, ostream &image) {
   if (format == UCI) {
      return UCIMoveImage(m,image);
   }
   else if (format == WB_OUT) {
      if (TypeOfMove(m) == KCastle) {
          image << "O-O";
      }
      else if (TypeOfMove(m) == QCastle) {
          image << "O-O-O";
      }
      else {
         image << FileImage(StartSquare(m));
         image << RankImage(StartSquare(m));
         image << FileImage(DestSquare(m));
         image << RankImage(DestSquare(m));
         if (TypeOfMove(m) == Promotion) {
            // N.b. ICS requires lower case.
            image << (char)tolower((int)PieceImage(PromoteTo(m)));
         }
      }
      return;
   }
   // format is SAN
   if (IsNull(m)) {
       image << "(null)";
      return;
   }

   PieceType p = PieceMoved(m);
   ASSERT(p != Empty);
   if (TypeOfMove(m) == KCastle) {
       image << "O-O";
   }
   else if (TypeOfMove(m) == QCastle) {
       image << "O-O-O";
   }
   else {
      if (p == Pawn) {
         if (Capture(m) == Empty) {
            image << FileImage(DestSquare(m));
            image << RankImage(DestSquare(m));
         }
         else {
            image << FileImage(StartSquare(m));
            image << 'x';
            image << FileImage(DestSquare(m));
            image << RankImage(DestSquare(m));
         }
         if (TypeOfMove(m) == Promotion) {
            image << '=';
            image << PieceImage(PromoteTo(m));
         }
      }
      else {
         image << PieceImage(p);
         Bitboard attacks =
            b.calcAttacks(DestSquare(m), b.sideToMove());
         unsigned n = attacks.bitCount();
         int dups = 0;
         int filedups = 0;
         int rankdups = 0;
         int files[9];
         int ranks[9];

         if (n > 1) {
            Square sq;
            while (attacks.iterate(sq)) {
               if (TypeOfPiece(b[sq]) == p) {
                  files[dups] = File(sq);
                  if (files[dups] == File(StartSquare(m)))
                     filedups++;
                  ranks[dups] = Rank(sq,White);
                  if (ranks[dups] == Rank(StartSquare(m),White))
                     rankdups++;
                  ++dups;
               }
            }
         }
         if (dups > 1) {
            // need to disambiguate move.
            if (filedups == 1) {
               image << FileImage(StartSquare(m));
            }
            else if (rankdups == 1) {
               image << RankImage(StartSquare(m));
            }
            else {
               // need both rank and file to disambiguate
               image << FileImage(StartSquare(m));
               image << RankImage(StartSquare(m));
            }
         }
         if (Capture(m) != Empty) {
            image << 'x';
         }
         image << FileImage(DestSquare(m));
         image << RankImage(DestSquare(m));
      }
   }
   Board board_copy(b);
   board_copy.doMove(m);
   if (board_copy.checkStatus() == InCheck) {
      Move moves[Constants::MaxMoves];
      MoveGenerator mg(board_copy);
      if (mg.generateEvasions(moves))
         image << '+';
      else
         image << '#';                        // mate
   }
}
Exemple #30
0
void CDataParser::CaptureImage( quint8 nChannel )
{
    emit Capture( nChannel );
}