Exemple #1
0
SGraphicStackItem::SGraphicStackItem( const QString & text , QWidget *parent )
    : QToolButton( parent )
{
    setText( text );
    setAutoRaise( true );
    setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
    setCheckable( true );
    setFixedHeight( 28 );
    //setFixedWidth( 73 );
    connect( this , SIGNAL(clicked()) , SLOT(click_on()) );
}
Exemple #2
0
int main(int argc, char *argv[]) {
	/*set line buffering of stdout*/
	setvbuf(stdout, NULL, _IOLBF, 0);

	int maxloops;	
	if(argc == 1)
		maxloops = 100;
	else
		maxloops = atoi(argv[1]);
	printf("EVaura activated for %i mining loops\n", maxloops);

	/*Initialize random number generator*/
	point rsult;
	points rsults = {0, NULL};
	gsl_rng_default_seed = time(NULL);
   	r = gsl_rng_alloc (gsl_rng_default);


	current_time = time(NULL);
	int shieldson = 0;
	int randompulse, pulsetimer;
	char number_of_belts = 0;
	char current_belt = 0;
	char is_belt_toast[20] = {0};
	char unable_to_lock = 0;

    display = XOpenDisplay(NULL); // Open first (-best) display
    screen = DefaultScreenOfDisplay(display);
	assert(display);
	
	xdodisplay = xdo_new_with_opened_display (display,":0",1);
	xdo_window_select_with_click(xdodisplay, &EVEwindow);	

	update_screenshot(); //obtain display properties
	initialize_images(); 
	initialize_ore_tables();

	ship *s = &mackinaw;

	for(int i = 0; i < maxloops; i++){

		undock();

		//Warp to belt
		click_on(&menu_belts_inactive, 1, "");
		mysleep(500);

		update_screenshot();
		number_of_belts = find_multiple(&aba_menu, NULL);
		if(number_of_belts < 1){
			printf("No belts found!!!\n Docking!");
			//dock();
			//break;
		}
		else 
			printf("We found %i belts\n", number_of_belts);

		//choose random belt which isn't already depleted
		while((current_belt = random_int(1, number_of_belts)) && 
				is_belt_toast[(int)current_belt] == 1) {
			printf("We chosed %i. belt, but is is empty\n", current_belt);
		}

		if (findmatch(&menu_name, &rsult) == 0){
			click(rsult.X + random_int(0,30), rsult.Y + 19*current_belt, 1, "s");
			printf("Warping to %i. belt\n", current_belt);
		}

		if(random_int(0,3) > 1) {
			start_shields(s);
			shieldson = 1;
		}
		else
			shieldson = 0;
	
		wait_for_warp(s);
		//arrived to belt

		launch_drones(s);

		click_on(&menu_mining_inactive, 1, "");
		mysleep(1500);

		lock_nearest_roid();
		start_mining(&pulsetimer, &randompulse);

		if(shieldson == 0)
			start_shields(s);

		while(1){
			sleep(1);
			update_screenshot();

			if (findmatch(&full_cargo2, NULL) == 0)
				break;

			if (findmatch(&invalid_target, NULL) == 0)
				click_on(&OK, 1, "");

			switch (check_roid_lock()) {
				case 0 :
					unable_to_lock++;
					if(unable_to_lock > 6){
						printf("We were repeatedly unable to lock anything, this belt is probably toast\n");
						//FIXME: this could probably also happen with pirates or roids too far to lock
						is_belt_toast[(int)current_belt] = 1;
						i--;//decrease counter, sice this loop wasnt finished
						goto dock;
					}
					printf("we didnt found any locked roids, attempting to lock one\n");
					if (lock_best_roid() == 0) {	
						start_mining(&pulsetimer, &randompulse);
						unable_to_lock = 0;
					}
					continue;
				case 1 :
					if(find_multiple(&i_mining_laser_active, &rsults) == 0){
						start_mining(&pulsetimer, &randompulse);
					}
					lock_best_roid();
					unable_to_lock = 0;
					continue;
			}

			switch (find_multiple(&i_mining_laser_active, &rsults)) {
				case 0 :
					printf("we have a locked roid however lasers were not active\n");
					start_mining(&pulsetimer, &randompulse);
					continue;
				case 1 :
					xdo_keysequence(xdodisplay, CURRENTWINDOW, "F1", 5);
					//pulse random laser, if we are lucky we turn on the right one
					//if not, we will turn on both next time
					break;
			}

			sleep(2);

			if ( (time(NULL) - pulsetimer) > randompulse ) {
				printf("cycling lasers\n");
				xdo_keysequence(xdodisplay, CURRENTWINDOW, "F1", 5);
				xdo_keysequence(xdodisplay, CURRENTWINDOW, "F2", 5);
				mysleep(1000);
				update_screenshot();
				if (check_roid_lock() == 1) {
					mysleep(50);
					xdo_keysequence(xdodisplay, CURRENTWINDOW, "F1", 5);
					xdo_keysequence(xdodisplay, CURRENTWINDOW, "F2", 5);
					mysleep(random_int(100,300));
				}
				else if(check_roid_lock() > 1 ){
					mouse_move(locked_roids.rsult[0].X, locked_roids.rsult[0].Y);
					xdo_click(xdodisplay, CURRENTWINDOW, 1);
					xdo_keysequence(xdodisplay, CURRENTWINDOW, "F1", 5);
					mysleep(550);
					mouse_move(locked_roids.rsult[1].X, locked_roids.rsult[1].Y);
					xdo_click(xdodisplay, CURRENTWINDOW, 1);
					xdo_keysequence(xdodisplay, CURRENTWINDOW, "F2", 5);
				}

				pulsetimer = time(NULL);
				randompulse = random_int(50,150);
			}
		}

dock:
		dock_drones(s);//we can dock while preparing to warp
		if (click_on(&menu_default_inactive, 1, "") == 0) {
			printf("defalut menu inactive, clicking on it\n");
			mysleep(random_int(800,1200));
		}
		else
			printf("default menu probably active, no need to click\n");

		update_screenshot();
		if(click_on(&aba_peace_station, 1, "d") == 0) {
			printf("found Aba station, attempting a warp\n");
		}
		else 
			printf ("Cant find Aba station, something bad is going on.\n");
	
		wait_for_warp(s);
		mysleep(10000);//FIXME: new function wait for dock???

		
		for (int i = 0; unload_ore(s) == 1; i++){
			mysleep(5000);
			if(i > 4){		
				printf("Unable to unload ore\n");
				goto exit;
			}
		}


	}

exit:

	if(displayImage)
		cvReleaseImage(&displayImage);

	XCloseDisplay(display);

	return 0;
}