Ejemplo n.º 1
0
void CMiniMap::MouseRelease(int x, int y, int button)
{
	if(mouseMove || mouseResize || mouseLook){
		mouseMove=false;
		mouseResize=false;
		mouseLook=false;
		return;
	}
	if(button==SDL_BUTTON_LEFT){
		if(x>xpos+width-10 && y<gu->screeny-ypos-height+10){
			if(maximized){
				maximized=false;
				xpos=oldxpos;
				ypos=oldypos;
				height=oldheight;
				width=oldwidth;
			} else {
				maximized=true;
				oldxpos=xpos;
				oldypos=ypos;
				oldheight=height;
				oldwidth=width;
				height=gu->screeny;
				width=height;
				xpos=(gu->screenx-gu->screeny)/2;
				ypos=0;
			}
			return;
		}
		if(x<xpos+10 && y>gu->screeny-ypos-10){
			minimized=true;
			return;
		}
		float3 pos(float(x-xpos)/width*gs->mapx*SQUARE_SIZE,500,float(y-(gu->screeny-ypos-height))/height*gs->mapx*SQUARE_SIZE);
//		info->AddLine("x %f y %f",pos.x,pos.z);
		if(guihandler->inCommand!=-1){
			FakeMousePress(pos,0);
			return;
		}
		float size=0.2f/sqrt((float)width+height)*gs->mapx*SQUARE_SIZE;
//		info->AddLine("r %f",size);
		CUnit* unit=helper->GetClosestFriendlyUnit(pos,size,gu->myAllyTeam);
		if(unit){
		if(!keys[SDLK_LSHIFT])
		        selectedUnits.ClearSelected();
			selectedUnits.AddUnit(unit);
			return;
		}
		FakeMousePress(pos,1);
		return;
	}
}
Ejemplo n.º 2
0
static int LookAtEvent(struct Control* control, int event)
{
  struct CommandButton* button = (struct CommandButton*)control->ControlData;
  
  switch (event)
  {
    case MSLEFT:
    case MSRIGHT:
    case MSMIDDLE:
    if (PressedInRange(control->posx, control->posy, 
             control->posx + button->len-1, control->posy))
    {
       if (control->SecondPass)
       {
          return (FakeMousePress(control)) ? LEAVE_WINDOW: 
                    CONTROL_ACTIVATE;
       }
       else
          return REQUEST_AGAIN;
    }
    return NOT_ANSWERED;
    
    case ENTERKEY:
    if (!control->active && !control->DefaultControl) 
       return NOT_ANSWERED;
    
    FakeKeyboardPress(control);   
    return LEAVE_WINDOW;

    default:
    return NOT_ANSWERED;
  }
}