Exemplo n.º 1
0
/** Press arrow key, skip empty tiles */
void safe_press_arrow_key(uint8_t n)
{
	// preserve old position
	const uint8_t x1 = pos_x;
	const uint8_t y1 = pos_y;

	if (n == D_LEFT || n == D_RIGHT) {

		// traverse all buttons
		for (uint8_t i = 0; i < CARD_COUNT; i++) {
			button_click(n);

			if (board[Cursor].state != GONE) return;
		}

	} else {

		for (uint8_t i = 0; i < HEIGHT; i++) {

			// Go up/down
			button_click(n);
			if (board[Cursor].state != GONE) return;

			for (int8_t x = 0; x < WIDTH; x++) {

				if ((int8_t) pos_x - x >= 0) {
					if (board[Cursor - x].state != GONE) {
						pos_x -= x;
						return;
					}
				}

				if ((int8_t) pos_x + x < WIDTH) {
					if (board[Cursor + x].state != GONE) {
						pos_x += x;
						return;
					}
				}
			}
		}
	}

	// restore original position
	pos_x = x1;
	pos_y = y1;
}
Exemplo n.º 2
0
void button_hover(int x1,int y1,int x2,int y2)
{
	hidemouseptr();
	setcolor(WHITE);
	line(x1,y2,x1,y1);
	line(x1,y1,x2,y1);
	setcolor(BLACK);
	line(x2,y1,x2,y2);
	line(x2,y2,x1,y2);
	showmouseptr();
	delay(100);
	button_click(x1,y1,x2,y2);
}
void NewsScreenInterface::MousedownNewsButton ( Button *button )
{

	int index;
	sscanf ( button->name, "news_story %d", &index );

	CompanyUplink *cu = (CompanyUplink *) game->GetWorld ()->GetCompany ( "Uplink" );
	UplinkAssert ( cu );

	if ( cu->GetNews ( index + baseoffset ) ) 
		button_click ( button );
	

}
Exemplo n.º 4
0
/** Update game (every 10 ms) */
void update()
{
	// handle buttons (with repeating when held down)
	for (uint8_t i = 0; i < DEBO_CHANNELS; i++) {
		if (debo_get_pin(i)) {
			if (btn_hold_cnt[i] == 0) {
				if (is_arrow_key(i)) {
					safe_press_arrow_key(i);
				} else {
					button_click(i);
				}
			}

			// non-arrows wrap to 1 -> do not generate repeated clicks
			inc_wrap(btn_hold_cnt[i], is_arrow_key(i) ? 0 : 1, BTNHOLD_REPEAT);

		} else {
			btn_hold_cnt[i] = 0;
		}
	}

	// game logic - hide or remove cards when time is up
	if (hide_timeout > 0) {
		if (--hide_timeout == 0) {
			if (hide_timeout_match) {
				// Tiles removed from board
				board[tile1].state = GONE;
				board[tile2].state = GONE;

				if (board[Cursor].state == GONE) {
					// move to some other tile
					// try not to change row if possible
					if ((Cursor % WIDTH) == (WIDTH - 1))
						safe_press_arrow_key(D_LEFT);
					else
						safe_press_arrow_key(D_RIGHT);
				}
			} else {
				// Tiles made secret again
				board[tile1].state = SECRET;
				board[tile2].state = SECRET;
			}

			tiles_revealed = 0; // no revealed
		}
	}

	// Animation for pulsing the active color
	inc_wrapi(animframe, 0, F_ANIM_LEN * 2);
}
void BBSScreenInterface::MousedownBBSButton ( Button *button )
{

	int index;
	sscanf ( button->name, "BBmessage %d", &index );

	CompanyUplink *cu = (CompanyUplink *) game->GetWorld ()->GetCompany ( "Uplink" );
	UplinkAssert ( cu );

	if ( cu->GetMission ( index + baseoffset ) ) 
		button_click ( button );
	

}
Exemplo n.º 6
0
void VoiceAnalyser::PlayMouseDown ( Button *button )
{

	UplinkAssert (button);

	char name [64];
	int pid;
	sscanf ( button->name, "%s %d", name, &pid );

	VoiceAnalyser *thistask = (VoiceAnalyser *) SvbGetTask ( pid );

	if ( thistask->STATUS == VOICEANALYSER_STATUS_READY )
		button_click ( button );

}
Exemplo n.º 7
0
void monitor_tools(int n,int t)
{
	getmousepos(&button,&mousex,&mousey);
	for(;mousey<20;getmousepos(&button,&mousex,&mousey))
	{
	       if((mousex/20>0)&&(mousex/20)<=n&&(mousex/20)!=button_track)
	       {
			button_track=mousex/20;
			top_panel_buttons(n,button_track,2);
			if(t==0)
			{
				hidemouseptr();
				settextstyle(0,0,1);
				if(cur_color==0)
					setcolor(WHITE);
				else
					setcolor(BLACK);
				hover_text(mousex/20);
				showmouseptr();
			}
	       }
	       else if(mousex<20&&button==1&&t!=0)
	       {
			cur_panel=0;
			t=0;
			cur_style=1;
			n=tool_but_num;
			button_hover(2,2,18,18);
			top_panel_default();
			top_panel_buttons(tool_but_num,0,1);
			button_click((2+cur_tool*20),2,(18+cur_tool*20),18);
		   }
		   else if(t==0&&mousex>619&&button==1)
			{
				button_hover(620,2,638,18);
				ask_exit();
			}
	       else if(((mousex/20)==0||(mousex/20>(n+1)))&&button_track!=-1)
			{
			button_track=-1;
			top_panel_buttons(n,0,2);
			if(t==0)
			button_click((2+cur_tool*20),2,(18+cur_tool*20),18);
			else if(t==1)
			button_click((2+cur_style*20),2,(18+cur_style*20),18);
			}
		   if((mousex/20>0)&&(mousex/20)<=n&&button==1)
	       {
			if(t==0)
			{
			if(button_track!=18)
			cur_tool=button_track;
			button_hover((2+button_track*20),2,(18+button_track*20),18);
			if(button_track==18)
			{
			cur_panel=2;
		   draw_color();
			}
			draw_style();
			break;
			}
			else
			{
			cur_style=button_track;
			button_hover((2+cur_style*20),2,(18+cur_style*20),18);
			}
	       }

	}
}
Exemplo n.º 8
0
void canvas()
{	
	int button,mousex,mousey;	//local mouse variables
	if(cur_panel==0&&canvas_flag!=1)
	{
	top_panel_buttons(tool_but_num,0,5);
	hover_text(cur_tool);
	button_click((2+cur_tool*20),2,(18+cur_tool*20),18);
	canvas_flag=1;
	}
	else if(cur_panel==1&&canvas_flag!=2)
	{
	hover_text(cur_tool);
	top_panel_buttons(buttons_data[cur_tool-1],0,5);
	button_click((2+cur_style*20),2,(18+cur_style*20),18);
	canvas_flag=2;
	}
	hover_text(cur_tool);
	getmousepos(&button,&mousex,&mousey);
	for(;mousey>20;getmousepos(&button,&mousex,&mousey))
	{
		if(button==1)
		{
			restrictmouseptr(0,27,xmax,ymax);
			switch(cur_tool)
			{
				case 4: user_text(mousex,mousey);
						break;
				case 5: pencil();
						break;
				case 6: brush(2);
						break;
				case 7: bfill(mousex,mousey);
						break;
				case 8: brush(1);
						break;
				case 9: user_pickcolor();
						break;
				case 10: user_line();
						break;
				case 11: drawRectangle();
						break;
				case 12: drawEllipse();
						break;
				case 13: drawSpray();
						break;
				case 14: drawSpiral();
						break;
				case 15:user_clip();
						break;
				case 16:user_poly();
						break;
				case 17:drawCircle(cur_style);
						break;

			}

		}
		else
		{
			restrictmouseptr(0,0,xmax,ymax);
			
		}
	}
}
Exemplo n.º 9
0
/* ------------ */
main()
{
register int which; 										/* Ausgel�ste Aktion */
register int i; 												/* Schleifenindex */
int msg[8]; 														/* Message-Buffer */
int dummy;															/* f�r unwichtige Werte */

appl_init();
open_vwork();

fnt_path[0] = Dgetdrv() + 'A';					/* Aktuellen Pfad ermitteln*/
fnt_path[1] = ':';
Dgetpath(fnt_path + 2, 0);
strcat(fnt_path, "\\*.FNT");

rsrc_load("VDI_FONT.RSC");							/* RSC laden */

graf_mouse(ARROW, 0L);									/* Mauspfeil */

set_workarea(); 												/* Hintergrund anlegen */
count_defined();
set_marker(); 													/* Marker positionieren */
restore_char(); 												/* Erstes Zeichen holen */
show_ccharacter();

do
	{
	which = evnt_multi(MU_BUTTON|MU_KEYBD|MU_MESAG,
										 2, 1, 1,
										 0, 0, 0, 0, 0,
										 0, 0, 0, 0, 0,
										 msg,
										 0, 0,
										 &mousex, &mousey, &dummy,
										 &dummy, &key, &clicks);


	switch(which)
		{
		case MU_KEYBD:											/* Tastendruck ? */
			if ((char)key >= 'a' && (char)key <= 'z')
				key &= 0xDF;
				
			if (!(char)key) 									/* Kontrolltaste ?*/
				{
				key >>= 8;
				key |= 0x80;
				}

			for (i = 0; i < KEY_NUM; i++)					/* Passenden Men�eintrag suchen */
				if (m_keys[i] == (char)key)
					{
					which = MU_MESAG;
					msg[0] = MN_SELECTED;
					msg[4] = m_entry[i];
					menu_action(msg); 						/* Men�eintrag ausf�hren */
					break;
					}
			break;

		case MU_MESAG:
			if (msg[0] == MN_SELECTED)				/* Men�eintrag ? */
				{
				menu_action(msg);
				menu_tnormal(menu_adr, msg[3], TRUE);
				}
			break;

		case MU_BUTTON:
			button_click(); 									/* Mausklick */
			break;
		}

	}while(which != MU_MESAG || msg[0] != MN_SELECTED || msg[4] != F_OK);

cls_vwork();
appl_exit();
}