示例#1
0
void SrvrMergeOverlappingWalls( uint32_t client_id, INDEX iWorld, PORTHOAREA rect )
{
	// for all walls - find a wall without a mate in the rect area...
	// then for all remaining walls - find another wall that is the 
	// same line as this one....
	GETWORLD(iWorld);

	int nwalls, n;
	PWALL *wallarray;
	wallarray = GetLinearWallArray( world->walls, &nwalls );
	for( n = 0; n < nwalls; n++ )
	{
		_POINT start, end;
		PWALL wall = wallarray[n];
		if( wall->iWallInto == INVALID_INDEX )
		{
			PFLATLAND_MYLINESEG line = GetLine( wall->iLine );
			addscaled( start, line->r.o, line->r.n, line->dFrom );
			addscaled( end, line->r.o, line->r.n, line->dTo );
			if( PointInRect( start, rect ) &&
			    PointInRect( end, rect ) )
			{
				int m;
				for( m = n+1; m < nwalls; m++ )
				{
					PWALL wall2 = wallarray[m];
					if( wall2->iWallInto == INVALID_INDEX )
					{
						_POINT start2, end2;
						PFLATLAND_MYLINESEG line = GetLine( wall2->iLine );
						addscaled( start2, line->r.o, line->r.n, line->dFrom );
						addscaled( end2, line->r.o, line->r.n, line->dTo );
						/*
						if( PointInRect( start2, rect ) && 
							 PointInRect( end2, rect ) )
						{
							Log4( "starts: (%12.12g,%12.12g) vs (%12.12g,%12.12g)" 
										,start[0], start[1]
										,start2[0], start2[1] );
							Log4( "ends  : (%12.12g,%12.12g) vs (%12.12g,%12.12g)" 
										,end[0], end[1]
										,end2[0], end2[1] );
						}
						*/
						if( ( Near( start2, start ) &&
						      Near( end2, end ) ) 
						  ||( Near( start2, end ) &&
						      Near( end2, start ) ) )
						{
							SrvrMergeWalls( client_id, iWorld, GetWallIndex( wall ), GetWallIndex( wall2 ) );
							break;
						}

					}
				}
			}
		}	
	}
	Release( wallarray );
}
BOOL CTyStationAssistPng::PointInObj(float x, float y,float errRange)
{
	try
	{
		ASSERT(errRange >= 0);

		if (m_bDelete) 
			return FALSE; 

		BOOL ret = FALSE;

		RectStruct rt,rt2;
		GetRect(&rt.x0,&rt.y0,&rt.x1,&rt.y1);

		rt2 = rt;
		rt2.InflateRect(errRange,errRange);

		ret = PointInRect(x,y,rt2);

		return ret;
	}
	catch(...)
	{

	}
	return FALSE;
}
示例#3
0
void CBaseState::ProcessButtons(void)
{
	if (m_fInputDelayTimer > 0.0f)
		return;

	SDL_Rect buttonRect;
	SDL_Point selectorPos = m_pInputManager->GetSelectorPos();
	Uint8 btnIter = 0;
	for (; btnIter < m_ucNumButtons; ++btnIter)
	{
		buttonRect = m_ppButtons[btnIter]->GetPixelDstRect();

		if (PointInRect(&selectorPos, &buttonRect) == SDL_TRUE)
		{
			if (m_cOverKey != btnIter)
			{
				m_pInputManager->SetCursor(SDL_SYSTEM_CURSOR_HAND);
				m_cOverKey = btnIter;
			}
			break;
		}
	}

	if (m_cOverKey != INVALID_BUTTON)
	{
		if (btnIter == m_ucNumButtons)
		{
			m_pInputManager->SetCursor(SDL_SYSTEM_CURSOR_ARROW);
			m_cOverKey = INVALID_BUTTON;
		}
	}
}
示例#4
0
文件: WinBase.c 项目: RFBGH/ugui
PWindow LocatWinByXY(PPoint pPoint)
{
    PWindow pWinCurr = NULL;
    PWindow pWinRet = NULL;

	pWinCurr = pWinRoot->m_pFirstSon;

	while(TRUE)
	{
		if(PointInRect(pPoint, &pWinCurr->m_showRect))
		{
			pWinRet = pWinCurr;
			pWinCurr = pWinCurr->m_pFirstSon;
		}else
		{
			pWinCurr = pWinCurr->m_pNext;
		}

		if(pWinCurr == NULL)
		{
			break;
		}
	}

	return pWinRet;
}
示例#5
0
int CPROC CheckWallInRect( uint32_t client_id, PWALL wall, PGROUPWALLSELECTINFO psi )
{
	GETWORLD(psi->iWorld);
	_POINT p1, p2;
	PORTHOAREA rect = psi->rect; // shorter pointer
	if( wall->iLine == INVALID_INDEX )
	{
		PSECTOR sector = GetSector( wall->iSector );
   		Log( "Line didn't exist..." );
   		if( sector )
		{
			PNAME name = GetName( sector->iName );
   			Log( "Sector exists..." );
   			if( name &&
				name[0].name )
		   		Log1( "Wall in Sector %s does not have a line", name[0].name );
			else
				Log( "Sector referenced does not have a name" );
		}
		else
			Log( "Wall should not be active... WHY is it?!" );
   }
   else
   {
		PFLATLAND_MYLINESEG line = GetLine( wall->iLine );
		addscaled( p1, line->r.o, line->r.n, line->dFrom );
		addscaled( p2, line->r.o, line->r.n, line->dTo );
		if( !PointInRect( p1, rect) ||
	   	 !PointInRect( p2, rect) )
		{
			return 0;
		}
   		else
		{
			if( psi->ppwalls )
			{
				psi->ppwalls[psi->nwalls++] = GetWallIndex( wall );
				SrvrBalanceALine( client_id, psi->iWorld, wall->iLine );
			}
			else
				psi->nwalls++;
		}
	}
	return 0; // abort immediate...
}
示例#6
0
文件: Plot.cpp 项目: Daice/bmd101
	void CPlot::DrawLine(CDC* pDC,const CRect& rectZone,const CPoint* pPtr,int nCount)
	{
		if(nCount<1 || pPtr==NULL){	// 无需绘制
			return;
		}
		BOOL lastPointInRect = FALSE;	// 上一点是否在矩形内
		CPoint tpPoint;	//临时点
		//逐点绘制
		for(int i=0;i<nCount;i++){
			if(i==0){//第一个点
				lastPointInRect = PointInRect(rectZone,pPtr[i]);
				pDC->MoveTo(pPtr[i].x,pPtr[i].y);
				continue;;
			}
			if(lastPointInRect==FALSE
				&& PointInRect(rectZone,pPtr[i])==FALSE)
			{// 上一个点与该点均不在矩形内
					continue;
			}
			if (lastPointInRect==TRUE
				&& PointInRect(rectZone,pPtr[i]))
			{// 上一个点与该点均在矩形内
				pDC->LineTo(pPtr[i].x,pPtr[i].y);
				continue;
			}
			if(lastPointInRect){// 上一个点在,该点不在
				tpPoint = IntersectionRectLine(rectZone,pPtr[i-1],pPtr[i]);
				pDC->MoveTo(pPtr[i-1].x,pPtr[i-1].y);
				pDC->LineTo(tpPoint.x,tpPoint.y);
				lastPointInRect = FALSE;
			}else{
				tpPoint = IntersectionRectLine(rectZone,pPtr[i],pPtr[i-1]);
				pDC->MoveTo(tpPoint.x,tpPoint.y);
				pDC->LineTo(pPtr[i].x,pPtr[i].y);
				lastPointInRect = TRUE;
			}
			
		}

		//pDC->MoveTo(pPtr[0].x,pPtr[0].y);
		//for (int i=1;i<nCount;i++)
		//{
		//	pDC->LineTo(pPtr[i].x,pPtr[i].y);
		//}
	}
示例#7
0
//=================================================================================================
void ListBox::Update(float dt)
{
	if(extended)
	{
		if(menu->visible)
		{
			// powinno byæ aktualizowane tu ale niestety wed³ug kolejnoœci musi byæ na samym pocz¹tku
			//menu->Update(dt);
			if(!menu->focus)
				menu->visible = false;
		}
		else if(mouse_focus && Key.Focus() && PointInRect(GUI.cursor_pos, global_pos, size) && Key.PressedRelease(VK_LBUTTON))
		{
			menu->global_pos = global_pos + INT2(0,size.y);
			if(menu->global_pos.y+menu->size.y >= GUI.wnd_size.y)
				menu->global_pos.y = GUI.wnd_size.y-menu->size.y;
			menu->visible = true;
			menu->focus = true;
		}
	}
	else
	{
		if(mouse_focus && Key.Focus() && PointInRect(GUI.cursor_pos, global_pos, real_size) && Key.PressedRelease(VK_LBUTTON))
		{
			int n = (GUI.cursor_pos.y-global_pos.y+int(scrollbar.offset))/20;
			if(n >= 0 && n < (int)items.size() && n != selected)
			{
				selected = n;
				if(e_change_index)
					e_change_index(n);
			}
		}

		if(IsInside(GUI.cursor_pos))
			scrollbar.ApplyMouseWheel();
		scrollbar.Update(dt);
	}
}
bool DropDownListButton::OnInputEvent(const GUIMessage * message)
{
	double trueX, trueY;
	trueX = x;
	trueY = y;
	if (isPositionRelative) {
		trueX += father->GetPositionX();
		trueY += father->GetPositionY();
	}
	bool used = false;
	switch (message->GetType())
	{
	case GUIMessage::MOUSE_BUTTON_CLICK:
	{
		const ClickMessage * mouseMovement = static_cast<const ClickMessage *>(message);
		if (PointInRect(mouseMovement->GetX(), mouseMovement->GetY(), trueX, trueY, width, height)) {
			static_cast<DropList *>(father)->setSelection(this);
			disabled = true;
			used = true;
		}
		
	}
		break;
	case GUIMessage::MOUSE_MOVE:
	{
		const MouseMovementMessage * mouseMovement = static_cast<const MouseMovementMessage *>(message);
		if (PointInRect(mouseMovement->GetX(), mouseMovement->GetY(), trueX, trueY, width, height)) {
			currentImage = hooverImage;
			used = true;
		}
		else {
			currentImage = activeImage;
		}
	}
		break;
	}
	return used;
}
bool CollisionManager::CircleToRect(double cx, double cy, double cr, double rx, double ry, double rw, double rh) const {
	if (PointInRect(cx, cy, rx, ry, rw, rh))
		return true;
	else {
		double nearestX;
		double nearestY;
		ClosestPointToRect(cx, cy, rx, ry, rw, rh, &nearestX, &nearestY);

		if (Distance(cx, cy, nearestX, nearestY) <= cr)
			return true;
		else
			return false;
	}
}
示例#10
0
文件: WinBase.c 项目: RFBGH/ugui
INT WindowLocatFlow(PWindow pWin)
{

    if(pWinLocat)
    {
        return 2;
    }
    
    if(PointInRect(pPointLocat, &pWin->m_rect))
    {
        pWinLocat = pWin;
        return 1;
    }
    return 0;
}
示例#11
0
BOOL CTyHMProxy::PointInObj(float x, float y, float errRange)
{
	ASSERT(errRange>=0);
	if (m_bDelete) return FALSE; 

	BOOL ret=FALSE;
	RectStruct rt,rt2;
	GetRect(&rt.x0,&rt.y0,&rt.x1,&rt.y1);

	rt2=rt;
	rt2.InflateRect(errRange,errRange);
	ret=PointInRect(x,y,rt2);

	return ret;
}
示例#12
0
void CXTFlatComboBox::OnNoFlickerPaint(CDC* pDC)   
{   
    ASSERT(pDC != NULL);   
       
    // Get the client area to paint.    
    CRect rcClient;   
    GetClientRect(&rcClient);   
   
    CDC memDC; // memory device context.    
   
    // Create the memory DC, set Map Mode    
    memDC.CreateCompatibleDC(pDC);   
    memDC.SetMapMode(pDC->GetMapMode());   
   
    // Create a bitmap big enough to hold the window's image    
    CBitmap bitmap;   
    bitmap.CreateCompatibleBitmap(pDC, rcClient.Width(), rcClient.Height());   
   
    // Select the bitmap into the memory DC    
    CBitmap* pOldBitmap = memDC.SelectObject(&bitmap);   
   
    // Repaint the background, this takes the place of WM_ERASEBKGND.    
    memDC.FillSolidRect(rcClient, m_clr3DFace);   
   
    // Let the window do its default painting...    
    CWnd::DefWindowProc( WM_PAINT, (WPARAM)memDC.m_hDC, 0 );   
   
    if (m_bFlatLook)   
    {   
        if (PointInRect() || m_bHasFocus) {   
            DrawCombo(&memDC, RAISED, m_clr3DShadow, m_clr3DHilight);   
        }   
        else {   
            DrawCombo(&memDC, NORMAL, m_clr3DFace, m_clr3DFace);   
        }   
    }   
   
    // Blt it    
    pDC->BitBlt(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height(),   
        &memDC, rcClient.left, rcClient.top, SRCCOPY);               
   
    // Select the original bitmap back in    
    memDC.SelectObject(pOldBitmap);   
   
    // Clean up    
    bitmap.DeleteObject();   
    memDC.DeleteDC();   
}   
示例#13
0
void CXTFlatComboBox::OnTimer(UINT nIDEvent)    
{   
    UNREFERENCED_PARAMETER(nIDEvent);   
       
    if (m_bFlatLook)   
    {   
        CClientDC dc(this);   
   
        // OnLButtonDown, show PRESSED.    
        if (m_bLBtnDown==TRUE)   
        {   
            KillTimer (1);   
   
            if (m_bPainted == TRUE)   
            {   
                DrawCombo(&dc, PRESSED, m_clr3DShadow, m_clr3DHilight);   
                m_bPainted = FALSE;   
            }   
        }   
           
        // If mouse leaves, show flat.    
        else if (!PointInRect() && !m_bHasFocus)   
        {   
            KillTimer (1);   
   
            if (m_bPainted == TRUE)   
            {   
                DrawCombo(&dc, NORMAL, m_clr3DFace, m_clr3DFace);   
                m_bPainted = FALSE;   
            }   
   
        }   
   
        // On mouse over, show RAISED.    
        else   
        {   
            if (m_bPainted == TRUE)   
            {   
                return;   
            }   
            else   
            {   
                m_bPainted = TRUE;   
                DrawCombo(&dc, RAISED, m_clr3DShadow, m_clr3DHilight);   
            }   
        }   
    }   
}   
示例#14
0
bool SGE_Button::IsPressed(void) const
{
    const CTexture* pTexture = mpSprite->GetTexture();

    SRect boundary;
    mpSprite->GetPosition(boundary.min.x, boundary.min.y);
    boundary.max.x = boundary.min.x + pTexture->GetWidth();
    boundary.max.y = boundary.min.y + pTexture->GetHeight();

    bool bPressed = false;
    SVector2 mouse((float)CDXInput::Get()->GetMouseScreenX(), (float)CDXInput::Get()->GetMouseScreenY());
    if (PointInRect(mouse, boundary) && CDXInput::Get()->IsMousePressed(Mouse::LBUTTON))
    {
        bPressed = true;
    }
    return bPressed;
}
示例#15
0
//=================================================================================================
void CreateCharacterPanel::Update(float dt)
{
	RenderUnit();
	UpdateUnit(dt);

	// obracanie
	if(PointInRect(GUI.cursor_pos, INT2(pos.x+228,pos.y+94), INT2(128,256)) && Key.Focus() && focus)
	{
		if(Key.Down(VK_LBUTTON))
			unit->rot = clip(unit->rot - float(GUI.cursor_pos.x - pos.x - 228 - 64)/16*dt);
		//dist = clamp(dist + GUI.mouse_wheel, -3.f, -1.f);
	}

	if(mode == PickClass)
	{
		for(int i=0; i<5; ++i)
		{
			bts[i].mouse_focus = focus;
			bts[i].Update(dt);
		}
	}
	else
	{
		for(int i=0; i<2; ++i)
		{
			bts2[i].mouse_focus = focus;
			bts2[i].Update(dt);
		}

		if(!game->IsOnline())
		{
			checkbox.mouse_focus = focus;
			checkbox.Update(dt);
		}

		for(int i=0; i<5; ++i)
		{
			slider[i].mouse_focus = focus;
			slider[i].Update(dt);
		}
	}

	if(focus && Key.Focus() && Key.PressedRelease(VK_ESCAPE))
		Event((GuiEvent)IdCancel);
}
示例#16
0
BOOL CObject::IsTouch(int x, int y)
{
	switch(m_type)
	{
	case OBJ_TYPE_INPUT:
	case OBJ_TYPE_PLAT_BUTTON:
	case OBJ_TYPE_BUTTON:
	case OBJ_TYPE_CHECK:
	case OBJ_TYPE_GROUP:
		if(!(GetStatus()&OBJ_STAT_DISABLE))
		{
			return PointInRect(&m_rect, x, y);
		}
		break;
	}

	return FALSE;
}
示例#17
0
//=================================================================================================
void GamePanel::UpdateButton(float dt)
{
	bt_updated = true;

	if(GUI.HaveDialog())
		return;

	if(PointInRect(GUI.cursor_pos, INT2(GUI.wnd_size.x-32, GUI.wnd_size.y-32), INT2(32,32)) && Key.Focus() && Key.PressedRelease(VK_LBUTTON))
	{
		menu.visible = true;
		menu.focus = true;
		GUI.focused_ctrl = &menu;
		UpdateMenuText();
	}
	
	if(menu.visible)
		menu.Update(dt);
}
示例#18
0
void SGE_Button::Update(float fSeconds)
{
    const CTexture* pTexture = mpSprite->GetTexture();

    SRect boundary;
    mpSprite->GetPosition(boundary.min.x, boundary.min.y);
    boundary.max.x = boundary.min.x + pTexture->GetWidth();
    boundary.max.y = boundary.min.y + pTexture->GetHeight();

    SVector2 mouse((float)CDXInput::Get()->GetMouseScreenX(), (float)CDXInput::Get()->GetMouseScreenY());
    if (PointInRect(mouse, boundary))
    {
        mpSprite->SetCurrentFrame(ON);
    }
    else
    {
        mpSprite->SetCurrentFrame(OFF);
    }
}
示例#19
0
void ConfigHandleMotion( Config *conf, int x, int y )
{
	int i;
	SDL_Rect rect;
	
	for(i = 0; i < conf->init_entries; i++)
	{
		rect.x = conf->entry[i].x;
		rect.y = conf->entry[i].y;
		rect.h = conf->entry[i].h;
		rect.w = conf->entry[i].w;
		
		// is the menu active
		if( PointInRect(x, y, &rect) )
		{
			// was the entry already active
			if( !conf->entry[i].active )
			{
				// entry becomes active
				if( conf->entry[i].type != CONF_SIMPLE_TEXT )
				{
					conf->entry[i].active = 1;
				}
			}
			
			if( conf->entry[i].type == CONF_KEY )
			{
				strcpy( conf->entry[i].key->keyname, SDL_GetKeyName(*conf->entry[i].key->key_id));
				sprintf( conf->entry[i].text,
				         "%s: %s",
					 conf->entry[i].key->name,
					 conf->entry[i].key->keyname);
			}
		}
		else
		{
			// entry is not active
			conf->entry[i].active = 0;
		}
	}
	
	return;
}
示例#20
0
文件: WinBase.c 项目: RFBGH/ugui
PWindow LocatWinByXY(PPoint pPoint)
{
    PWindow pWinCurr = NULL;
    PWindow pWinParent = NULL;
    CList   list;
    int     iStackTop;

    InitList(&list);
    pWinCurr = pWinRoot;
    while(TRUE)
    {
        if(pWinCurr)
        {

            PushList(&list, pWinCurr);
            pWinCurr = pWinCurr->m_pLastSon;          
        }
        else{
            iStackTop = list.m_iListSize;
            if(iStackTop == -1)
            {
                break;
            }
            
            pWinCurr = GetListData(&list, iStackTop-1);
            RemoveListByData(&list, pWinCurr);

            if(PointInRect(pPoint, &pWinCurr->m_showRect))
            {
                break;
            }
            pWinCurr = pWinCurr->m_pLast;
        }
    }

    DeletList(&list);
    return pWinCurr;
}
示例#21
0
文件: CheckBox.cpp 项目: lcs2/carpg
//=================================================================================================
void CheckBox::Update(float dt)
{
	if(state == DISABLED)
		return;

	if(Key.Focus() && mouse_focus && PointInRect(GUI.cursor_pos, global_pos, bt_size))
	{
		GUI.cursor_mode = CURSOR_HAND;
		if(state == PRESSED)
		{
			if(Key.Up(VK_LBUTTON))
			{
				state = FLASH;
				if(radiobox)
				{
					if(!checked)
					{
						checked = true;
						parent->Event((GuiEvent)id);
					}
				}
				else
				{
					checked = !checked;
					parent->Event((GuiEvent)id);
				}
			}
		}
		else if(Key.Pressed(VK_LBUTTON))
			state = PRESSED;
		else
			state = FLASH;
	}
	else
		state = NONE;
}
示例#22
0
void Sampler::seMouseUp(int button) {
  if (showLoad || showSampleSel || showEnvSel) {
    return;
  }
  if (sloadS!=1) {
    sloadS=PointInRect(mouse.x,mouse.y,690,10,690+40,10+20);
    if (sloadS) {
      printf("load?\n");
      readDir(wd.c_str());
      showLoad=true;
      loadHIndex=-1;
    }
  }
  if (sselectS!=1) {
    sselectS=PointInRect(mouse.x,mouse.y,10,10,10+60,10+20);
    if (sselectS) {
      printf("select?\n");
      prepareSampleSel();
      showSampleSel=true;
      loadHIndex=-1;
    }
  }
  if (seupS!=1) {
    seupS=PointInRect(mouse.x,mouse.y,630,40,630+40,40+20);
    doUp=false;
  }
  if (sedownS!=1) {
    sedownS=PointInRect(mouse.x,mouse.y,580,40,580+40,40+20);
    doDown=false;
  }
  
  if (sevolS!=1) {
    sevolS=PointInRect(mouse.x,mouse.y,10,70,10+70,70+20);
    if (sevolS) {
      prepareEnvSel(true);
      showEnvSel=true;
      envSTarget=1;
      loadHIndex=s[curSample].envVol+1;
    }
  }
  if (sepanS!=1) {
    sepanS=PointInRect(mouse.x,mouse.y,375,70,375+70,70+20);
    if (sepanS) {
      prepareEnvSel(true);
      showEnvSel=true;
      envSTarget=2;
      loadHIndex=s[curSample].envPan+1;
    }
  }
  if (sepitchS!=1) {
    sepitchS=PointInRect(mouse.x,mouse.y,10,200,10+70,200+20);
    if (sepitchS) {
      prepareEnvSel(true);
      showEnvSel=true;
      envSTarget=3;
      loadHIndex=s[curSample].envPitch+1;
    }
  }
  if (secutS!=1) {
    secutS=PointInRect(mouse.x,mouse.y,375,200,375+70,200+20);
    if (secutS) {
      prepareEnvSel(true);
      showEnvSel=true;
      envSTarget=4;
      loadHIndex=s[curSample].envCut+1;
    }
  }
  if (seresS!=1) {
    seresS=PointInRect(mouse.x,mouse.y,10,330,10+70,330+20);
    if (seresS) {
      prepareEnvSel(true);
      showEnvSel=true;
      envSTarget=5;
      loadHIndex=s[curSample].envRes+1;
    }
  }
  
  if (sfiltlS!=1) {
    sfiltlS=PointInRect(mouse.x,mouse.y,446,372,446+64,372+40);
    if (sfiltlS) {
      s[curSample].filter^=1;
    }
  }
  if (sfilthS!=1) {
    sfilthS=PointInRect(mouse.x,mouse.y,520,372,520+64,372+40);
    if (sfilthS) {
      s[curSample].filter^=2;
    }
  }
  if (sfiltbS!=1) {
    sfiltbS=PointInRect(mouse.x,mouse.y,594,372,594+64,372+40);
    if (sfiltbS) {
      s[curSample].filter^=4;
    }
  }
  
  kVolAmp->mouseUp(mouse.x,mouse.y,button);
  kVolCap->mouseUp(mouse.x,mouse.y,button);
  kPanAmp->mouseUp(mouse.x,mouse.y,button);
  kPanCap->mouseUp(mouse.x,mouse.y,button);
  kPitchAmp->mouseUp(mouse.x,mouse.y,button);
  kPitchCap->mouseUp(mouse.x,mouse.y,button);
  kCutAmp->mouseUp(mouse.x,mouse.y,button);
  kCutCap->mouseUp(mouse.x,mouse.y,button);
  kResAmp->mouseUp(mouse.x,mouse.y,button);
  kResCap->mouseUp(mouse.x,mouse.y,button);
  
  tSName->mouseUp(mouse.x,mouse.y,button);
}
示例#23
0
文件: map.c 项目: Gilles86/afni
/*****
* Name: 		_XmHTMLGetImagemapAnchor
* Return Type: 	XmHTMLAnchor*
* Description:  checks whether the given coordinates lie somewhere within
*				the given imagemap.
* In: 
*	html:		XmHTMLWidget
*	x,y:		point coordinates, relative to upper-left corner of the
*				html widget
*	image:		current image data, required to make x and y coordinates
*				relative to upper-left corner of the image.
*	map:		imagemap to check
* Returns:
*	anchor data if successfull, NULL otherwise
*****/
XmHTMLAnchor*
_XmHTMLGetAnchorFromMap(XmHTMLWidget html, int x, int y,
	XmHTMLImage *image, XmHTMLImageMap *map)
{
	int xs, ys;
	mapArea *area, *def_area;
	XmHTMLAnchor *anchor = NULL;
	Boolean found = False;

	/* map coordinates to upperleft corner of image */
	xs = x + html->html.scroll_x - image->owner->x;
	ys = y + html->html.scroll_y - image->owner->y;

	_XmHTMLFullDebug(10, ("map.c: _XmHTMLGetAnchorFromMap, x = %i, y = %i, "
		"relative x = %i, relative y = %i\n", x, y, xs, ys));

	area = map->areas;
	def_area = NULL;

	/*
	* We test against found instead of anchor becoming non-NULL:
	* areas with the NOHREF attribute set don't have an anchor but
	* should be taken into account as well.
	*/
	while(area && !found)
	{
		switch(area->shape)
		{
			case MAP_RECT:
				if(PointInRect(xs, ys, area->coords))
				{
					anchor = area->anchor;
					found = True;
				}
				break;
			case MAP_CIRCLE:
				if(PointInCircle(xs, ys, area->coords[0], area->coords[1],
					area->coords[2]))
				{
					anchor = area->anchor;
					found = True;
				}
				break;
			case MAP_POLY:
				if(PointInPoly(xs, ys, area->region))
				{
					anchor = area->anchor;
					found = True;
				}
				break;
			/*
			* just save default area info; it's only needed if nothing
			* else matches.
			*/
			case MAP_DEFAULT:
				def_area = area;
				break;
		}
		area = area->next;
	}
	if(!found && def_area)
		anchor = def_area->anchor;

	_XmHTMLFullDebug(10, ("map.c: _XmHTMLGetAnchorFromMap, %s anchor found\n",
		(anchor ? "an" : "no")));

	return(anchor);
}
示例#24
0
//=================================================================================================
void FlowContainer::Update(float dt)
{
	bool ok = false;
	group = -1;
	id = -1;

	if(mouse_focus)
	{
		if(IsInside(GUI.cursor_pos))
		{
			ok = true;

			if(Key.Focus())
				scroll.ApplyMouseWheel();

			Int2 off(0, (int)scroll.offset);

			for(FlowItem* fi : items)
			{
				Int2 p = fi->pos - off + global_pos;
				if(fi->type == FlowItem::Item)
				{
					if(fi->group != -1 && PointInRect(GUI.cursor_pos, p, fi->size))
					{
						group = fi->group;
						id = fi->id;
						if(allow_select && fi->state != Button::DISABLED)
						{
							GUI.cursor_mode = CURSOR_HAND;
							if(on_select && Key.Pressed(VK_LBUTTON))
							{
								selected = fi;
								on_select();
								return;
							}
						}
					}
				}
				else if(fi->type == FlowItem::Button && fi->state != Button::DISABLED)
				{
					if(PointInRect(GUI.cursor_pos, p, fi->size))
					{
						GUI.cursor_mode = CURSOR_HAND;
						if(fi->state == Button::DOWN)
						{
							if(Key.Up(VK_LBUTTON))
							{
								fi->state = Button::HOVER;
								on_button(fi->group, fi->id);
								return;
							}
						}
						else if(Key.Pressed(VK_LBUTTON))
							fi->state = Button::DOWN;
						else
							fi->state = Button::HOVER;
					}
					else
						fi->state = Button::NONE;
				}
			}
		}

		scroll.mouse_focus = mouse_focus;
		scroll.Update(dt);
	}

	if(!ok)
	{
		for(FlowItem* fi : items)
		{
			if(fi->type == FlowItem::Button && fi->state != Button::DISABLED)
				fi->state = Button::NONE;
		}
	}
}
示例#25
0
void Sampler::seMouseDown(int button) {
  if (showLoad || showSampleSel || showEnvSel) {
    return;
  }
  if (PointInRect(mouse.x,mouse.y,690,10,690+40,10+20)) {
    sloadS=2;
  }
  if (PointInRect(mouse.x,mouse.y,10,10,10+60,10+20)) {
    sselectS=2;
  }
  // rate
  if (PointInRect(mouse.x,mouse.y,630,40,630+40,40+20)) {
    seupS=2;
    if (button!=1) {
      doUp=true;
      doXTarget=0;
    } else {
      s[curSample].rate*=2;
    }
  }
  if (PointInRect(mouse.x,mouse.y,580,40,580+40,40+20)) {
    sedownS=2;
    if (button!=1) {
      doDown=true;
      doXTarget=0;
    } else {
      s[curSample].rate/=2;
    }
  }
  
  if (PointInRect(mouse.x,mouse.y,10,70,10+70,70+20)) {
    sevolS=2;
  }
  if (PointInRect(mouse.x,mouse.y,375,70,375+70,70+20)) {
    sepanS=2;
  }
  if (PointInRect(mouse.x,mouse.y,10,200,10+70,200+20)) {
    sepitchS=2;
  }
  if (PointInRect(mouse.x,mouse.y,375,200,375+70,200+20)) {
    secutS=2;
  }
  if (PointInRect(mouse.x,mouse.y,10,330,10+70,330+20)) {
    seresS=2;
  }
  
  if (PointInRect(mouse.x,mouse.y,446,372,446+64,372+40)) {
    sfiltlS=2;
  }
  if (PointInRect(mouse.x,mouse.y,520,372,520+64,372+40)) {
    sfilthS=2;
  }
  if (PointInRect(mouse.x,mouse.y,594,372,594+64,372+40)) {
    sfiltbS=2;
  }
  
  kVolAmp->mouseDown(mouse.x,mouse.y,button);
  kVolCap->mouseDown(mouse.x,mouse.y,button);
  kPanAmp->mouseDown(mouse.x,mouse.y,button);
  kPanCap->mouseDown(mouse.x,mouse.y,button);
  kPitchAmp->mouseDown(mouse.x,mouse.y,button);
  kPitchCap->mouseDown(mouse.x,mouse.y,button);
  kCutAmp->mouseDown(mouse.x,mouse.y,button);
  kCutCap->mouseDown(mouse.x,mouse.y,button);
  kResAmp->mouseDown(mouse.x,mouse.y,button);
  kResCap->mouseDown(mouse.x,mouse.y,button);
  
  tSName->mouseDown(mouse.x,mouse.y,button);
}
示例#26
0
int main(int argc, char *argv[])
{
	int i, j;
	SDL_Texture *texture = NULL;
	TTF_Font *font;
	texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB555, SDL_TEXTUREACCESS_TARGET,	SCREEN_WIDTH, SCREEN_HEIGHT);
	Button button[20];
	for(i = 0; i < 20; i++){
		button[i].button_rect.x = button_x[i/5] + 4;
		button[i].button_rect.y = button_y[i%5] + 3;
		button[i].button_rect.w = BUTTON_WIDTH - 8;
		button[i].button_rect.h = BUTTON_HEIGHT - 6;
		button[i].button_char = button_ch[i];
		button[i].button_status = 0;
	}
	
	if(!init()) {
		printf("Failed to initialize!");
	}else{
		
		int quit = 0;
		SDL_Event e;
		while(!quit){

			SDL_SetRenderTarget(renderer, texture);
			SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);			
			SDL_RenderClear(renderer);

			SDL_SetRenderTarget(renderer, texture);
			SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);			
			for(i = 0; i < 4; i++){
				SDL_RenderDrawLine(renderer, button_x[i], button_y[0], button_x[i], SCREEN_HEIGHT);
			}
			for(i = 0; i < 5; i++){
				SDL_RenderDrawLine(renderer, button_x[0], button_y[i], SCREEN_WIDTH, button_y[i]);
			}
			for(i = 0; i < 20; i++){
				StatusButton(button[i]);
			
				font = TTF_OpenFont("Choko.ttf", 35);
				SDL_Color ttf_color = {0, 0, 0};

				SDL_Texture *ttexture;
				SDL_Surface *surface;
				SDL_Rect rect;
				ttexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGB555, SDL_TEXTUREACCESS_TARGET, SCREEN_WIDTH, SCREEN_HEIGHT);
				surface = TTF_RenderText_Solid(font, button[i].button_char, ttf_color);
				ttexture = SDL_CreateTextureFromSurface(renderer, surface);

				TTF_SizeText(font, button[i].button_char, &rect.w, &rect.h);
				rect.x = button[i].button_rect.x + (BUTTON_WIDTH - rect.w)/2;
				rect.y = button[i].button_rect.y + (BUTTON_HEIGHT - rect.h)/2;
				
				SDL_SetRenderTarget(renderer, ttexture);
				SDL_RenderCopyEx(renderer, ttexture, NULL, &rect, 0.0, NULL, SDL_FLIP_NONE); 

				SDL_FreeSurface(surface);
				SDL_DestroyTexture(ttexture);
				TTF_CloseFont(font);
			}

			
			while(SDL_PollEvent(&e) != 0){
				if(e.type == SDL_QUIT){
					quit = 1;
				}else if(e.type == SDL_MOUSEBUTTONDOWN){
					if(e.button.button == SDL_BUTTON_LEFT){
						SDL_Point point;
						SDL_GetMouseState(&point.x, &point.y);
						for(i = 0; i < 20; i++){
							if(PointInRect(point, button[i].button_rect))
								button[i].button_status = 1;
						}
					}
				}else{
					for(i = 0; i < 20; i++){
						button[i].button_status = 0;
					}
				}
			}
			SDL_SetRenderTarget(renderer, NULL);
			SDL_RenderCopy(renderer, texture, NULL, NULL);   
			SDL_RenderPresent(renderer);
		}
	}
	
	TTF_Quit();
	SDL_DestroyRenderer(renderer);
	renderer = NULL;
	SDL_DestroyWindow(window);
	window = NULL;
	SDL_Quit();
	return 0;
}
示例#27
0
///////////////////
// Mouse over event
int	CListview::DoMouseMove(int x, int y, int dx, int dy, bool down, MouseButton button, const ModifiersState& modstate)
{
	if(cScrollbar->getVisible() && (cScrollbar->getGrabbed() || cScrollbar->InBox(x, y)))  {
		cScrollbar->DoMouseMove(x - cScrollbar->getX(), y - cScrollbar->getY(), dx, dy, down, button, modstate);

		CContainerWidget::DoMouseMove(x, y, dx, dy, down, button, modstate);
		return WID_PROCESSED;
	}

	// Check that the mouse is inside the listview
	if (!RelInBox(x, y))  {
		if (tMouseOverItem)  {
			tMouseOverItem->setActive(false);
			tMouseOverItem->setDown(false);
			tMouseOverItem = NULL;
		}

		CContainerWidget::DoMouseMove(x, y, dx, dy, down, button, modstate);
		return WID_PROCESSED;
	}

	// Reset the cursor
	SetGameCursor(CURSOR_ARROW);

	// Go through the columns and check, if the mouse is in the space between two columns
	if (bShowColumnHeaders && tColumns.size() > 1)  {
		std::vector<CListviewColumn *>::iterator it = tColumns.begin() + 1;
		std::vector<CListviewColumn *>::iterator prev = tColumns.begin();

		if(y > cBorder.getTopW() && y < tItemArea.y)  {
			int cur_x = cBorder.getLeftW() + tColumns[0]->getWidth();

			// Go through the columns
			for (; it != tColumns.end(); it++, prev++)  {
				if (x >= cur_x && x <= cur_x + 4)  { // Between the columns
					SetGameCursor(CURSOR_RESIZE);
					break;
				} else if (x >= cur_x && x < cur_x + (*it)->getWidth() - 2)  { // In the column
					if (!(*it)->isMouseDown())  {
						(*it)->setMouseDown(down);
						Repaint();
					}
					break;
				}

				cur_x += (*it)->getWidth() - 2;
			}
		} else {
			// Reset the click state of all headers
			for (; it != tColumns.end(); it++)  {
				if ((*it)->isMouseDown())  {
					(*it)->setMouseDown(false);
					Repaint();
				}
			}
		}

		// Is any of the columns grabbed? Move it
		if (iGrabbed > 0 && down)  {

			// Resize the two columns
			int w1, w2;
			w1 = w2 = 0;
			if (iGrabbed > 1)
				w1 = tColumns[iGrabbed - 1]->getWidth() + dx;
			w2 = tColumns[iGrabbed]->getWidth() - dx;

			// Resize only if they both will have at least minimal width
			if (w1 > MIN_COL_WIDTH && w2 > MIN_COL_WIDTH)  {
				tColumns[iGrabbed - 1]->setWidth(w1);
				tColumns[iGrabbed]->setWidth(w2);
				Repaint();
			}

			SetGameCursor(CURSOR_RESIZE);

			CContainerWidget::DoMouseMove(x, y, dx, dy, down, button, modstate);
			return WID_PROCESSED;
		}
	}

	// Go through items and subitems, processing the widgets
	tMouseOverSubWidget = NULL;
	if (tMouseOverItem)  {
		tMouseOverItem->setActive(false);
		tMouseOverItem->setDown(false);
		tMouseOverItem = NULL;
		Repaint();
	}

	int cur_y = tItemArea.y;
	int count = 0;
	for(std::list<CListviewItem *>::iterator item = tItems.begin(); // Go through the items
		item != tItems.end(); item++) {

			// Don't process invisible items
			if (!(*item)->isVisible())
				continue;

			if (count++ < cScrollbar->getValue())
				continue;

			// Reset the style
			(*item)->setActive(false);
			(*item)->setDown(false);

			// Check if the item is under the mouse
			if (y < cur_y || y >= cur_y + (*item)->getHeight())  {
				cur_y += (*item)->getHeight();
				if (cur_y >= tItemArea.y + tItemArea.h)
					break;
				continue;
			}

			// Change the style
			(*item)->setActive(true);
			(*item)->setDown(down);
			tMouseOverItem = (*item);

			std::list<CListviewSubitem *>::iterator subitem = (*item)->getSubitems().begin();
			std::vector<CListviewColumn *>::iterator col = tColumns.begin();
			int cur_x = tItemArea.x;

			for (; col != tColumns.end() &&
				subitem != (*item)->getSubitems().end(); subitem++, col++)  { // Go through the subitems

					// Don't process invisible subitems
					if (!(*subitem)->isVisible())
						continue;

					// Process the widget
					if ((*subitem)->getType() == sub_Widget)  {
						CWidgetSubitem *wsub = (CWidgetSubitem *)(*subitem);
						CWidget *w = wsub->getWidget();
						SDL_Rect r = wsub->getWidgetRect((*item)->getHeight());
						r.x += cur_x;
						r.y += cur_y;

						if(PointInRect(x, y, r))  {
							tMouseOverSubWidget = w;

							// If in the previous frame the widget wasn't under the mouse and now it is, fire the "enter" event
							if (!w->InBox(x - dy, y - dy))
								w->DoMouseEnter(x, y, dx, dy, modstate);

							// Mouse move event
							if (w->DoMouseMove(x, y, dx, dy, down, button, modstate) == WID_PROCESSED)  {
								CContainerWidget::DoMouseMove(x, y, dx, dy, down, button, modstate);
								return WID_PROCESSED;
							}
						} else {
							// If in the previous frame the widget was under the mouse and now it is not, fire the "leave" event
							if (PointInRect(x - dy, y - dy, r))
								w->DoMouseLeave(x, y, dx, dy, modstate);
						}
					}

					cur_x += (*col)->getWidth();
			}

			Repaint();

			cur_y += (*item)->getHeight();
			if (cur_y >= tItemArea.y + tItemArea.h)
				break;
	}

	CContainerWidget::DoMouseMove(x, y, dx, dy, down, button, modstate);
	return WID_PROCESSED;
}
示例#28
0
SRect Map::GetBoundingBoxFromSegment(SLineSegment line, Character& character) {
	// Validate that the line segment is within the maps range
	if (line.from.x < 0.0f || line.from.x > mMapData.GetWidth()
			|| line.from.y < 0.0f || line.from.y > mMapData.GetHeight()
			|| line.to.x < 0.0f || line.to.x > mMapData.GetWidth()
			|| line.to.y < 0.0f || line.to.y > mMapData.GetHeight()) {
		return SRect();
	}

	// Convert position to indices
	const int fromX = static_cast<int>(line.from.x) / 32;
	const int fromY = static_cast<int>(line.from.y) / 32;
	const int toX = static_cast<int>(line.to.x) / 32;
	const int toY = static_cast<int>(line.to.y) / 32;

	// Calculate Tile Count
	const int countX = toX - fromX + 1;
	const int countY = toY - fromY + 1;

	// Get Region
	SRect region;

#if _DEBUG

	for(int a = 0; a < mNumberOfNPCS; ++a)
	{
		SRect region2 = mNPCS[a]->GetBoundingBox();
		Graphics_DebugRect(region2 + sOffset, 0XFF00FF);

		Graphics_DebugRect(character.GetBoundingBox() + sOffset, 0X00FFFF);
	}

	for(int a = 0; a < mMapData.GetTileAmount(); ++a)
	{
		if(!mMapData.mLayer1[a].IsWalkable())
		{
			SRect region2 = mMapData.mLayer1[a].GetBoundingBox();
			Graphics_DebugRect(region2 + sOffset, 0XFF00FF);
		}
	}

#endif

	int width = GetWidth();
	for (int y = 0; y < countY; ++y) {
		for (int x = 0; x < countX; ++x) {
			const int index = (fromX + x) + ((fromY + y) * (width));

			character.SetTileIndex(index);

			// Block Tile
			if (!mMapData.mLayer1[index].IsWalkable()) {
				region += mMapData.mLayer1[index].GetBoundingBox();
				Graphics_DebugRect(region + sOffset, 0XFF0000);
			}

			for (int a = 0; a < mNumberOfNPCS; ++a) {
				bool npcIntersect = PointInRect(line.to,
						mNPCS[a]->GetBoundingBox());

				if (npcIntersect) {
					return region += mNPCS[a]->GetBoundingBox();
				}
			}

			// Item Tile
			if (mMapData.mLayer1[index].GetItemImageNumber()) {
				SRect debug = region + mMapData.mLayer1[index].GetBoundingBox();
				character.SetOnItem(mMapData.mLayer1[index].GetItemID());
				character.SetOnItemIndex(index);
				Graphics_DebugRect(debug + sOffset, 0XFFFF00);
			} else {
				character.SetOnItem(0);
			}
		}
	}

	return region;
}
示例#29
0
///////////////////
// Mouse down event
int	CListview::DoMouseDown(int x, int y, int dx, int dy, MouseButton button, const ModifiersState& modstate)
{
	// Scrollbar
	if(cScrollbar->InBox(x, y)) {
		cScrollbar->DoMouseDown(x - cScrollbar->getX(), y - cScrollbar->getY(), dx, dy, button, modstate);

		CContainerWidget::DoMouseDown(x, y, dx, dy, button, modstate);
		return WID_PROCESSED;
	}

	//
	// Column headers
	//
	iGrabbed = -1; // No column grabbed yet
	if (bShowColumnHeaders)  {

		// Not grabbed
		if( y >= cBorder.getTopW() && y < tItemArea.y)  {
			int cur_x = cBorder.getLeftW();
			std::vector<CListviewColumn *>::iterator col = tColumns.begin();
			int i = 0;

			for (col++; col != tColumns.end(); col++, i++)  {
				// Reset
				(*col)->setMouseDown(false);
				(*col)->setMouseOver(false);

				// If in the area between two columns, grab
				if (x >= cur_x-2 && x <= cur_x + 2)  {
					iGrabbed = i;
					break;
				}

				// Click
				else if (x >= cur_x + 2 && x <= cur_x + (*col)->getWidth() - 2 && iGrabbed <= 0)  {
					SetGameCursor(CURSOR_ARROW);
					(*col)->setMouseDown(true);
					(*col)->setMouseOver(true);
				}

				cur_x += (*col)->getWidth();
			}

			CContainerWidget::DoMouseDown(x, y, dx, dy, button, modstate);
			return WID_PROCESSED;
		}
	}

	setSelectedSub(NULL, -1);
	bool clicked_widget = false;

	// Go through items and subitems, processing the widgets
	tMouseOverSubWidget = NULL;
	int i = 0;

	int cur_y = tItemArea.y;
	int count = 0;
	for(std::list<CListviewItem *>::iterator item = tItems.begin(); // Go through the items
		item != tItems.end(); item++, i++) {
			// Ignore invisible items
			if (!(*item)->isVisible())
				continue;

			// Check if the item is in the display area
			if (count++ < cScrollbar->getValue())
				continue;

			// Select the item after a click
			if (y >= cur_y && y < cur_y + (*item)->getHeight())
				setSelected(item, i);

			std::list<CListviewSubitem *>::iterator subitem = (*item)->getSubitems().begin();
			std::vector<CListviewColumn *>::iterator col = tColumns.begin();
			int j = 0;
			int cur_x = tItemArea.x;

			for (; col != tColumns.end() &&
				subitem != (*item)->getSubitems().end(); subitem++, col++, j++)  { // Go through the subitems

					// Don't process hidden subitems
					if (!(*subitem)->isVisible())
						continue;

					// Process the widget
					if ((*subitem)->getType() == sub_Widget)  {
						CWidgetSubitem *wsub = (CWidgetSubitem *)(*subitem);
						CWidget *w = wsub->getWidget();
						SDL_Rect r = wsub->getWidgetRect((*item)->getHeight());
						r.x += cur_x;
						r.y += cur_y;

						if(PointInRect(x, y, r))  {
							clicked_widget = true;
							tMouseOverSubWidget = w;

							// Focus the widget
							if (w != tFocusedSubWidget)  {
								tFocusedSubWidget->setFocused(false);
								tFocusedSubWidget = w;
								w->setFocused(true);
							}
						}

					}

					// Clicked in the subitem?
					if (PointInRect(x, y, MakeRect(cur_x, cur_y, (*col)->getWidth(), (*item)->getHeight())))  {
						setSelectedSub(*subitem, j);
					}

					cur_x += (*col)->getWidth();
			}

			cur_y += (*item)->getHeight();
	}

	// Remove the focus from any focused widget if no widget was clicked
	if (!clicked_widget)
		if (tFocusedSubWidget)  {
			tFocusedSubWidget->setFocused(false);
			tFocusedSubWidget = NULL;
			Repaint();
		}

	CWidget::DoMouseDown(x, y, dx, dy, button, modstate);
	return WID_PROCESSED;
}
示例#30
0
/*------------------------------------------------------------
 * 啖  允月[
 * 娄醒
 *  index       int     平乓仿及奶件犯永弁旦
 *  dir         int       轾
 * 忒曰袄
 *  CHAR_WALKRET
 ------------------------------------------------------------*/
static CHAR_WALKRET CHAR_walk_move( int charaindex, int dir )
{
    int     i;
    int     fx,fy,ff;
    int     ox,oy,of;
    int     objbuf[128];
    int     objbufindex=0;
    int     notover=FALSE;
    int     retvalue=CHAR_WALKSUCCESSED;

    if( !CHAR_CHECKINDEX( charaindex )) return CHAR_WALKSYSTEMERROR;
    ox = CHAR_getInt(charaindex,CHAR_X);
    oy = CHAR_getInt(charaindex,CHAR_Y);
    of = CHAR_getInt(charaindex,CHAR_FLOOR);
    CHAR_getCoordinationDir( dir,ox,oy,1,&fx,&fy);
    ff = of;

    if( CHAR_getInt( charaindex,CHAR_WHICHTYPE ) == CHAR_TYPEENEMY ){
        RECT    walkr;
        POINT   nextp;
        int npccreateindex;
        npccreateindex = CHAR_getInt( charaindex,CHAR_NPCCREATEINDEX );
        if( CHAR_isInvincibleArea( ff,fx,fy)) {
            CHAR_setInt(charaindex,CHAR_DIR,dir);
            retvalue = CHAR_WALKEXTEND;
            goto CHAR_AFTERWALK;
        }
        if( NPC_isBoundarySet( npccreateindex ) &&
            NPC_createGetRECT( npccreateindex,&walkr ) == TRUE )
        {
            nextp.x = fx;
            nextp.y = fy;
            if( PointInRect( &walkr,&nextp ) == FALSE ){
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALKEXTEND;
                goto CHAR_AFTERWALK;
            }
        }else{
            ;
        }
    }


    if( CHAR_getFlg( charaindex, CHAR_ISBIG ) == 1 ){
        static POINT offset[5]={
            { 0,-1},
            {-1, 0},
            { 0, 0},
            { 1, 0},
            { 0, 1},
        };
        int     k;
        for( k=0 ; k<5; k++ ){
            if( !MAP_walkAble( charaindex, ff, fx+offset[k].x,
                               fy+offset[k].y )){
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALK1357;
                goto CHAR_AFTERWALK;
            }
        }

    }else{
        if( CHAR_getDX(dir)*CHAR_getDY(dir) == 0 ){
            if( !MAP_walkAble( charaindex,ff, fx, fy ) ){
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALK1357;
                goto CHAR_AFTERWALK;
            }
        }else{
            int     xflg,yflg;
            if( !MAP_walkAble( charaindex,ff, fx, fy ) ){
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALK1357;
                goto CHAR_AFTERWALK;
            }

            xflg = MAP_walkAble( charaindex,of, ox+CHAR_getDX(dir), oy );
            yflg = MAP_walkAble( charaindex,of, ox, oy+CHAR_getDY(dir) );

            if( !xflg || !yflg ) {
                CHAR_setInt(charaindex,CHAR_DIR,dir);
                retvalue = CHAR_WALK1357;
                goto CHAR_AFTERWALK;
            }
        }
    }
    objbufindex = CHAR_getSameCoordinateObjects( objbuf, arraysizeof( objbuf ), ff,fx,fy );
    for( i = 0 ; i < objbufindex ; i ++ ){
        int     objindex= objbuf[i];
        switch( OBJECT_getType(objindex) ){
        case OBJTYPE_CHARA:
            if( !CHAR_getFlg( OBJECT_getIndex(objindex),CHAR_ISOVERED) ){
            	if(!CHAR_CHECKINDEX(OBJECT_getIndex(objindex))){
	            	printf("自动删除一个问题对象!");
	        			endObjectOne(objindex);
	        			break;
	        		}
              notover= TRUE;
            }
            break;
        case OBJTYPE_ITEM:
            if( !ITEM_getInt( OBJECT_getIndex(objindex), ITEM_ISOVERED ) )
                notover= TRUE;
            break;
        case OBJTYPE_GOLD:
            break;
        default:
            break;
        }
    }
    if( notover == TRUE ){
        CHAR_setInt(charaindex,CHAR_DIR,dir);
        retvalue = CHAR_WALKHITOBJECT;
    }else{
        for( i = 0 ; i < objbufindex ; i ++ ){
            typedef void (*PREOFUNC)(int,int);
            PREOFUNC   pfunc=NULL;
            int     objindex=objbuf[i];
            switch( OBJECT_getType(objindex) ){
            case OBJTYPE_CHARA:
                pfunc = (PREOFUNC)CHAR_getFunctionPointer(
                    OBJECT_getIndex(objindex),
                    CHAR_PREOVERFUNC);
                break;
            case OBJTYPE_ITEM:
                pfunc = (PREOFUNC)ITEM_getFunctionPointer(
                    OBJECT_getIndex(objindex),
                    ITEM_PREOVERFUNC);
                break;
            case OBJTYPE_GOLD:
                break;
            default:
                break;
            }
            if( pfunc )pfunc( OBJECT_getIndex(objindex),charaindex );
        }

        CHAR_setInt(charaindex,CHAR_X,fx);
        CHAR_setInt(charaindex,CHAR_Y,fy);
        CHAR_setInt(charaindex,CHAR_FLOOR,ff);
        CHAR_setInt(charaindex,CHAR_DIR,dir);

        {
            int objindex;
            int ox,oy,of;
            objindex = CHAR_getWorkInt( charaindex,CHAR_WORKOBJINDEX );
            of = OBJECT_setFloor(objindex,
                                 CHAR_getInt(charaindex,CHAR_FLOOR));
            ox = OBJECT_setX(objindex,CHAR_getInt(charaindex,CHAR_X));
            oy = OBJECT_setY(objindex,CHAR_getInt(charaindex,CHAR_Y));
            if( !MAP_objmove( objindex, of,ox,oy,ff,fx,fy ) ){
                /*  仇氏卅氏升丹仄方丹手卅中    */
                fprint( "ERROR MAP_OBJMOVE objindex=%d(%s)\n",objindex,
                	CHAR_getUseName( charaindex ) );
            }
        }

        CHAR_setInt(charaindex,CHAR_WALKCOUNT,
                    CHAR_getInt(charaindex,CHAR_WALKCOUNT) + 1 );


        for( i = 0 ; i < objbufindex ; i ++ ){
            typedef void (*POSTOFUNC)(int,int);
            POSTOFUNC   pfunc=NULL;
            int     objindex=objbuf[i];

            switch( OBJECT_getType(objindex) ){
            case OBJTYPE_CHARA:
                pfunc = (POSTOFUNC)CHAR_getFunctionPointer(
                    OBJECT_getIndex(objindex),
                    CHAR_POSTOVERFUNC);
                break;
            case OBJTYPE_ITEM:
                pfunc = (POSTOFUNC)ITEM_getFunctionPointer( OBJECT_getIndex(objindex), ITEM_POSTOVERFUNC);
                break;
            case OBJTYPE_GOLD:
                break;
            default:
                break;
            }
            if( pfunc )pfunc( OBJECT_getIndex(objindex),charaindex );
        }
        objbufindex = CHAR_getSameCoordinateObjects(objbuf, arraysizeof(objbuf), of, ox, oy );
        for( i=0 ;i<objbufindex;i++){
            typedef void (*OFFFUNC)(int,int);
            OFFFUNC   ofunc=NULL;
            int     objindex = objbuf[i];

            switch( OBJECT_getType( objindex ) ){
            case OBJTYPE_CHARA:
                ofunc = (OFFFUNC)CHAR_getFunctionPointer( OBJECT_getIndex(objindex), CHAR_OFFFUNC);
                break;
            case OBJTYPE_ITEM:
                /*    卞窒手仄卅中  */
                break;
            case OBJTYPE_GOLD:
                /*    卞窒手仄卅中  */
                break;
            default:
                break;
            }
            if( ofunc )ofunc( OBJECT_getIndex(objindex), charaindex );

        }
    }
CHAR_AFTERWALK:
    if( retvalue == CHAR_WALK1357 || retvalue == CHAR_WALKHITOBJECT ){
	    {
	        int     opt[2] = { ox, oy};
	        CHAR_sendWatchEvent( CHAR_getWorkInt(charaindex,
	                                             CHAR_WORKOBJINDEX),
	                             CHAR_ACTWALK,opt,2,TRUE );
	    }
        CHAR_setWorkChar( charaindex, CHAR_WORKWALKARRAY, "");
		if( CHAR_getInt( charaindex, CHAR_WHICHTYPE) == CHAR_TYPEPLAYER) {
		    CHAR_sendWatchEvent( CHAR_getWorkInt(charaindex, CHAR_WORKOBJINDEX),
    		                     CHAR_ACTWARP,NULL,0,TRUE);
		}
    }else if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPLAYER ){

		BOOL	flg = FALSE;
		int		par;
		int		count;
		CHAR_setWorkInt( charaindex, CHAR_WORKACTION, -1 );
		if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE ) == BATTLE_CHARMODE_NONE ){
			CHAR_sendCharaAtWalk( charaindex, of,ox,oy,CHAR_getDX(dir), CHAR_getDY(dir));
		}

	    {
	        int     opt[2] = { ox, oy};
	        CHAR_sendWatchEvent( CHAR_getWorkInt(charaindex,
	                                             CHAR_WORKOBJINDEX),
	                             CHAR_ACTWALK,opt,2,TRUE );
	    }
		if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE) == CHAR_PARTY_CLIENT ) {
			CHAR_sendMapAtWalk( charaindex, of,
								ox,oy,
								CHAR_getInt( charaindex, CHAR_X),
								CHAR_getInt( charaindex, CHAR_Y));
		}
		count = CHAR_getWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT);
		if( count > 0 ) {
			CHAR_setWorkInt( charaindex, CHAR_WORK_TOHELOS_COUNT, count -1);
			if( count -1 == 0 ) {
				CHAR_talkToCli( charaindex, -1, "道具的效力已到。", CHAR_COLORWHITE);
			}
		}
		par = ENCOUNT_getEncountPercentMin( charaindex, of,ox,oy);
		if( par != -1 ) {
			if( CHAR_getWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN) != par ){
				flg = TRUE;
				CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN, par);
			}
		}

		par = ENCOUNT_getEncountPercentMax( charaindex, of,ox,oy);
		if( par != -1 ) {
			if( CHAR_getWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX) != par ){
				flg = TRUE;
				CHAR_setWorkInt( charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX, par);
			}
		}
		// Arminius 7.12 login announce
		/*
		{
		  int enfd = getfdFromCharaIndex( charaindex );
		  if (CONNECT_get_announced(enfd)==0) {
		    // Robin 0720
		    //AnnounceToPlayer(charaindex);
		    AnnounceToPlayerWN( enfd );
		    CONNECT_set_announced(enfd,1);
		  }
		}
		*/
		// Arminius 6.22 check Encounter
		// Nuke 0622: Provide No Enemy function
		{
		  int enfd = getfdFromCharaIndex( charaindex );
		  int eqen = getEqNoenemy( enfd );	// Arminius 7.2: Ra's amulet
		  int noen = getNoenemy(enfd);

          // Arminius 7.31 cursed stone
      if (getStayEncount(enfd)>0) {
			  clearStayEncount(enfd);
		  }
		  //print("\n enfd=%d,eqen=%d,noen=%d", enfd, eqen, noen);

		  // Arminius 7.2 Ra's amulet
		  if (eqen>=200) {
		    noen=1;
		  } else if (eqen>=120) {
		    if ((ff==100)||(ff==200)||(ff==300)||(ff==400)||(ff==500)) noen=1;
		  } else if (eqen>=80) {
		    if ((ff==100)||(ff==200)||(ff==300)||(ff==400)) noen=1;
		  } else if (eqen>=40) {
		    if ((ff==100)||(ff==200)) noen=1;
		  }


		  //print("\n noen=%d", noen);
		  if (noen==0) {
				int maxep = CHAR_getWorkInt(charaindex, CHAR_WORKENCOUNTPROBABILITY_MAX);
		    int minep = CHAR_getWorkInt(charaindex, CHAR_WORKENCOUNTPROBABILITY_MIN);
		    int cep = CONNECT_get_CEP(enfd);

		    if (cep<minep) cep=minep;
		    if (cep>maxep) cep=maxep;
		    if (CHAR_getWorkInt(charaindex,CHAR_WORKBATTLEMODE)==BATTLE_CHARMODE_NONE) {
				int entflag=1;
				{
					int objindex,index;
					OBJECT obj;
					for ( obj = MAP_getTopObj( ff, fx, fy); obj; obj = NEXT_OBJECT( obj)) {
						objindex = GET_OBJINDEX( obj);
						if (OBJECT_getType( objindex) == OBJTYPE_CHARA) {
							int etype;
							index = OBJECT_getIndex( objindex);
							if (!CHAR_CHECKINDEX( index)) continue;
							if( CHAR_getInt( index, CHAR_WHICHTYPE) == CHAR_TYPENPCENEMY &&
								CHAR_getWorkInt( index, CHAR_WORKEVENTTYPE) == CHAR_EVENT_ENEMY )	{
								CHAR_setInt( charaindex, CHAR_X, ox);
								CHAR_setInt( charaindex, CHAR_Y, oy);
								lssproto_XYD_send( getfdFromCharaIndex(charaindex),
								CHAR_getInt( charaindex, CHAR_X ),
								CHAR_getInt( charaindex, CHAR_Y ),
								CHAR_getInt( charaindex, CHAR_DIR ) );
								break;
							}
							etype = CHAR_getWorkInt( index, CHAR_WORKEVENTTYPE);
							if (etype!=CHAR_EVENT_NONE) {
								if (etype==CHAR_EVENT_WARP) entflag=0;
							}
						}
					}
				}
#ifdef _ENEMY_ACTION
				if( rand()%(120*getEnemyAction()) < cep ){
#else
		      if (rand()%120<cep){	// Arminius 6.28 lower encounter prob.
#endif
					if (entflag) {
#ifdef _Item_MoonAct
						if( getEqRandenemy( enfd) > 0 )	{
							int Rnum=0;
							int RandEnemy = getEqRandenemy( enfd);
							Rnum = RAND(0,100);
							if( Rnum > RandEnemy )	{
#endif
								//encounter!!
								cep = minep;
								lssproto_EN_recv(enfd,
								CHAR_getInt(charaindex,CHAR_X),
								CHAR_getInt(charaindex,CHAR_Y));
#ifdef _Item_MoonAct
							}
						}else{
								cep = minep;
								lssproto_EN_recv(enfd,
								CHAR_getInt(charaindex,CHAR_X),
								CHAR_getInt(charaindex,CHAR_Y));
						}
#endif
					}
		      } else {
		        if (cep<maxep) cep++;
		      }
		    }
		    CONNECT_set_CEP(enfd, cep);
		  }
		}
		if( CHAR_getWorkInt( charaindex, CHAR_WORKPARTYMODE )!= CHAR_PARTY_CLIENT ){
			CHAR_setFlg( charaindex, CHAR_ISWARP, 0);
		}
    }
    else if( CHAR_getInt( charaindex, CHAR_WHICHTYPE ) == CHAR_TYPEPET ||