void CCell::DrawTracker(CDC *pDC) { LOGPEN tLogPen; tLogPen.lopnColor=RGB(0,0,0); tLogPen.lopnStyle=PS_DOT; tLogPen.lopnWidth.x=1; CPen tPen; tPen.CreatePenIndirect(&tLogPen); CPen *pOldPen=(CPen *)pDC->SelectObject(&tPen); CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(NULL_BRUSH); pDC->SetROP2(R2_NOTXORPEN); long x1,y1,x2,y2; switch(m_lHitTarget){ case TK_CT: break; case TK_MOV: UPtoLP(Left(),Top(),&x1,&y1); UPtoLP(Right(),Bottom(),&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); MoveInCell(m_potTracker); UPtoLP(Left(),Top(),&x1,&y1); UPtoLP(Right(),Bottom(),&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); break; } pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
bool Intersects (Room &other, int *adjust_x = NULL, int *adjust_y = NULL) { if (Left() < other.Right() && Right() > other.Left() && Top() < other.Bottom() && Bottom() > other.Top()) { // Intersects, find the intersection distance if required. if (adjust_x != NULL) { // Work out if moving left or right is shorter. if (std::abs(Right() - other.Left()) > std::abs(other.Right() - Left())) { *adjust_x = other.Left() - Right(); } else { *adjust_x = other.Right() - Left(); } } if (adjust_y != NULL) { // Work out if moving up or down is shorter. if (std::abs(Bottom() - other.Top()) > std::abs(other.Bottom() - Top())) { *adjust_y = other.Top() - Bottom(); } else { *adjust_y = other.Bottom() - Top(); } } return true; } return false; }
App::PointInt Viewer::calculateWindowTopLeft(ResizePositionMethod method, const SizeInt &newSize ) { wxDisplay display(DisplayFromPointFallback(PositionScreen())); auto rtDesktop = wxToRect(display.GetClientArea()); switch (method) { case ResizePositionMethod::PositionToScreen: return rtDesktop.TopLeft() + RoundCast((rtDesktop.Dimensions() - newSize) * 0.5f); case ResizePositionMethod::PositionToCurrent: { auto pt = AnchorCenter() + RoundCast(newSize * -0.5f); if ((pt.X + newSize.Width) > rtDesktop.Right()) { pt.X = rtDesktop.Right() - newSize.Width; } else if (pt.X < rtDesktop.Left()) { pt.X = rtDesktop.Left(); } if (pt.Y + newSize.Height > rtDesktop.Bottom()) { pt.Y = rtDesktop.Bottom() - newSize.Height; } else if (pt.Y < rtDesktop.Top()) { pt.Y = rtDesktop.Top(); } AnchorTL(pt); return pt; } case ResizePositionMethod::PositionNothing: { // Cap to screen PointInt pt = AnchorTL(); if ((pt.X + newSize.Width) > rtDesktop.Right()) pt.X=rtDesktop.Right()-newSize.Width; else if (pt.X < rtDesktop.Left()) pt.X = rtDesktop.Left(); if ((pt.Y + newSize.Height) > rtDesktop.Bottom()) pt.Y=rtDesktop.Bottom()-newSize.Height; else if (pt.Y < rtDesktop.Top()) pt.Y=rtDesktop.Top(); AnchorCenter(pt + RoundCast(newSize * 0.5f)); return pt; } default: DO_THROW(Err::InvalidParam, "Invalid reposition method: " + ToAString(method)); } }
void RemoveRange(uint32_t SymbolLow, uint32_t SymbolHigh, uint32_t /* TotalRange */) { Low += SymbolLow*Range; Range *= SymbolHigh-SymbolLow; while ( (Low ^ (Low+Range))<Top() || (Range<Bottom() && ((Range= -Low & (Bottom()-1)),1)) ) { Code= (Code<<8) | Input.get(), Range<<=8, Low<<=8; } }
bool Rectangle::Intersect(const Rectangle& other) const { return (Left() < other.Right()) && (Right() > other.Left()) && (Top() < other.Bottom()) && (Bottom() > other.Top()); }
inline bool IsCollidedRect(const cRectf& rect) { return (!((Right()<rect.Left()) ||(Left()>rect.Right()) ||(Top()>rect.Bottom()) ||(Bottom()<rect.Top()))); }
void CText::DrawHotPoints(CDC *pDC) { LOGPEN tLogPen; tLogPen.lopnColor=RGB(0,0,0); tLogPen.lopnStyle=PS_DOT; tLogPen.lopnWidth.x=1; CPen tPen; tPen.CreatePenIndirect(&tLogPen); CPen *pOldPen=(CPen *)pDC->SelectObject(&tPen); CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(NULL_BRUSH); pDC->SetROP2(R2_NOTXORPEN); long x1,y1,x2,y2; UPtoLP(Left()-DELTA,Top()-DELTA,&x1,&y1); UPtoLP(Right()+DELTA,Bottom()+DELTA,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); /* pDC->SelectStockObject(GRAY_BRUSH); pDC->SelectStockObject(NULL_PEN); pDC->SetROP2(R2_NOT); long x5,y5,x6,y6; UPtoLP((m_lx1+m_lx2)/2,m_ly1-DELTA,&x5,&y5); UPtoLP((m_lx1+m_lx2)/2,m_ly2+DELTA,&x6,&y6); DrawHotPoint(pDC,x5,y5); DrawHotPoint(pDC,x6,y6); */ pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
// Collision bool Sprite::CollisionBoundingBox(System::Graphics::Sprite* Other, int offset){ if (Bottom() - Other->Top() <= offset) return false; if (Other->Bottom() - Top() <= offset) return false; if (Right() - Other->Left() <= offset) return false; if (Other->Right() - Left() <= offset) return false; return true; }
void TextObject::Update(float delta) { if (Game::GetInstance()->GetIsLevelEditMode()) { m_alpha = 1.0f; return; } // get the distance to the player const Player * player = GameObjectManager::Instance()->GetPlayer(); if (player) { // check is the player inside the bounds of this sprite // if so then fade alpha if (player->X() > Left() && player->X() < Right() && player->Y() > Bottom() && player->Y() < Top()) { if (!mHasShown) { mHasShown = true; AudioManager::Instance()->PlaySoundEffect("boomy_intro.wav"); } } if (mHasShown && mTimeToShow > 0.0f) { if (m_alpha < 1.0f) { m_alpha += 1.4f * delta; } else { m_alpha = 1.0f; } } else { if (m_alpha > 0.0f) { m_alpha -= 0.9f * delta; } else { m_alpha = 0.0f; } } } if (mHasShown) { mTimeToShow -= delta; } UpdateToParent(); }
bool Rect::IsIntersects(const Rect& rect) const { return !( Right() < rect.Left() || rect.Right() < Left() || Bottom() < rect.Top() || rect.Bottom() < Top()); }
long CGsRegisterWriteListView::OnSize(unsigned int, unsigned int, unsigned int) { auto clientRect = GetClientRect(); Framework::Win32::CRect packetsTreeViewRect(0, Framework::Win32::PointsToPixels(30), clientRect.Right(), clientRect.Bottom()); m_packetsTreeView->SetSizePosition(packetsTreeViewRect); return TRUE; }
bool rect::Intersect( const rect& ref ) const { if( Left() > ref.Right() ) return false; if( Right() < ref.Left() ) return false; if( Top() > ref.Bottom() ) return false; if( Bottom() < ref.Top() ) return false; return true; }
void CCtrlBounds::DrawBorders(CBaseSprite* s, bool isActive, size_t d) { if (s == 0 || !s->BeginQuad(1))return; s->Quad(0 + d,Left() , Top() ,GetClientLeft() ,GetClientTop() ,zOrder -0.1f); s->Quad(1 + d,GetClientLeft() , Top() ,GetClientRight() ,GetClientTop() ,zOrder -0.1f); s->Quad(2 + d,GetClientRight() , Top() ,Right() ,GetClientTop() ,zOrder -0.1f); s->Quad(3 + d,Left() , GetClientTop() ,GetClientLeft() ,GetClientBottom() ,zOrder -0.1f); s->Quad(4 + d,GetClientLeft() , GetClientTop() ,GetClientRight() ,GetClientBottom() ,zOrder-0.11f); s->Quad(5 + d,GetClientRight() , GetClientTop() ,Right() ,GetClientBottom() ,zOrder -0.1f); s->Quad(6 + d,Left() , GetClientBottom() ,GetClientLeft() ,Bottom() ,zOrder -0.1f); s->Quad(7 + d,GetClientLeft() , GetClientBottom() ,GetClientRight() ,Bottom() ,zOrder -0.1f); s->Quad(8 + d,GetClientRight() , GetClientBottom() ,Right() ,Bottom() ,zOrder -0.1f); s->EndQuad(); }
void CMenus::RenderBackground() { //Graphics()->Clear(1,1,1); //render_sunrays(0,0); if(gs_TextureBlob == -1) gs_TextureBlob = Graphics()->LoadTexture("blob.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0); float sw = 300*Graphics()->ScreenAspect(); float sh = 300; Graphics()->MapScreen(0, 0, sw, sh); // render background color Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); //vec4 bottom(gui_color.r*0.3f, gui_color.g*0.3f, gui_color.b*0.3f, 1.0f); //vec4 bottom(0, 0, 0, 1.0f); vec4 Bottom(ms_GuiColor.r, ms_GuiColor.g, ms_GuiColor.b, 1.0f); vec4 Top(ms_GuiColor.r, ms_GuiColor.g, ms_GuiColor.b, 1.0f); IGraphics::CColorVertex Array[4] = { IGraphics::CColorVertex(0, Top.r, Top.g, Top.b, Top.a), IGraphics::CColorVertex(1, Top.r, Top.g, Top.b, Top.a), IGraphics::CColorVertex(2, Bottom.r, Bottom.g, Bottom.b, Bottom.a), IGraphics::CColorVertex(3, Bottom.r, Bottom.g, Bottom.b, Bottom.a) }; Graphics()->SetColorVertex(Array, 4); IGraphics::CQuadItem QuadItem(0, 0, sw, sh); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); // render the tiles Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); float Size = 15.0f; float OffsetTime = fmod(Client()->LocalTime()*0.15f, 2.0f); for(int y = -2; y < (int)(sw/Size); y++) for(int x = -2; x < (int)(sh/Size); x++) { Graphics()->SetColor(0,0,0,0.045f); IGraphics::CQuadItem QuadItem((x-OffsetTime)*Size*2+(y&1)*Size, (y+OffsetTime)*Size, Size, Size); Graphics()->QuadsDrawTL(&QuadItem, 1); } Graphics()->QuadsEnd(); // render border fade Graphics()->TextureSet(gs_TextureBlob); Graphics()->QuadsBegin(); Graphics()->SetColor(0,0,0,0.5f); QuadItem = IGraphics::CQuadItem(-100, -100, sw+200, sh+200); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); // restore screen { CUIRect Screen = *UI()->Screen(); Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h); } }
/* ================ idConsoleLocal::Clear ================ */ void idConsoleLocal::Clear() { int i; for ( i = 0 ; i < CON_TEXTSIZE ; i++ ) { text[i] = (idStr::ColorIndex(C_COLOR_CYAN)<<8) | ' '; } Bottom(); // go to end }
void CBitmap::OglTexCoord (void) { float h = float (m_info.texP->TW ()); m_render.u1 = float (Left ()) / h; m_render.u2 = float (Right ()) / h; h = float (m_info.texP->TH ()); m_render.v1 = float (Top ()) / h; m_render.v2 = float (Bottom ()) / h; }
bool Layout::Update(const ActionMap & actions, unsigned int tElapsed) { if (_layoutChanged) { std::vector<Control*>::iterator iter = _children.begin(); int curWide = _padding, curTall = _padding, maxHeight = 0; switch (_layout) { case None: // Don't move controls _layoutChanged = false; break; case Grid: // Grid of controls for (; iter != _children.end(); iter++) { if (curWide + (*iter)->Width() > width) { curTall += maxHeight + _padding; curWide = _padding; maxHeight = 0; } if ((*iter)->Height() > static_cast<unsigned int>(maxHeight)) maxHeight = (int) (*iter)->Height(); _moveChildRelative(*iter, curWide, curTall); curWide += (*iter)->Width() + _padding; } _layoutChanged = false; break; case HorizontalLine: // Horizontal line of controls for (; iter != _children.end(); iter++) { if (curWide + static_cast<int>((*iter)->Width()) > Right()) break; _moveChildRelative(*iter, curWide, 0); curWide += (*iter)->Width() + _padding; } _layoutChanged = false; break; case VerticalLine: // Vertical line of controls for (; iter != _children.end(); iter++) { if (curTall > Bottom()) break; _moveChildRelative(*iter, 0, curTall); curTall += (*iter)->Height() + _padding; } _layoutChanged = false; break; } } UpdateChildren(actions, tElapsed); return Collide(actions.GetInputState()->mouseX, actions.GetInputState()->mouseY); }
void CMemoryViewMIPSWnd::RefreshLayout() { auto rc = GetClientRect(); const int addressEditHeight = Framework::Win32::PointsToPixels(21); m_addressEdit->SetSize(rc.Right(), addressEditHeight); m_memoryView->SetPosition(0, addressEditHeight); m_memoryView->SetSize(rc.Right(), rc.Bottom() - addressEditHeight); }
void Rect::Merge(const Rect& rect) { float left = min(Left(), rect.Left()); float right = max(Right(), rect.Right()); float top = min(Top(), rect.Top()); float bottom = max(Bottom(), rect.Bottom()); origin.x = left; origin.y = top; size.width = right - left; size.height = bottom - top; }
//------------------------------------------------------------------------------ void BViewEditor::Init() { fBottom = 10; int bottom; if (!fClassName) { bottom = Bottom(); fClassName = new BStringView(BRect(10, bottom, 190, bottom + 20), "classname", "Element Type: "); AddControl(fClassName); } if (!fViewName) { bottom = Bottom(); fViewName = new BTextControl(BRect(10, bottom, 190, bottom + 20), "name", "View Name: ", "", new BMessage(MSG_VIEW_SET_NAME)); fViewName->SetDivider(be_plain_font->StringWidth("View Name: ")); AddControl(fViewName); } }
bool CCell::RInR(LPCRECT lpRect) { if(m_lStatus!=ST_NOMAL) return false; CRgn rgnTmp; if(!rgnTmp.CreateRectRgn(Left()-DELTA,Top()-DELTA,Right()+DELTA,Bottom()+DELTA)) return false; if(rgnTmp.RectInRegion(lpRect)) return true; else return false; }
void Draw::World(GLvoid) { dotsRemaining = 0; if(levelCom) LoadWorld(); glPushMatrix(); glTranslatef(-50.0f,0.0f,-50.0f); for(unsigned int i = 0; i < worldLayout.size(); i++) { switch(worldLayout[i]) { case 'T': Top(i); break; case 'B': Bottom(i); break; case 'L': Left(i); break; case 'R': Right(i); break; case 'U': case 'D': Corner(i); break; case 'Z': Dots(i); break; case 'X': SpawnLoc.xp = lctn[i].x; SpawnLoc.zp = lctn[i].t; SpawnLoc.yp = 1.1f; break; case 'G': //GZone(i); break; case 'Y': //Teleport(i); break; case 'W': //TPWalls(i); break; case 'S': Start(i); break; } } if(levelStr) Ghosts(); glPopMatrix(); }
Circle Capsule::CrossSection(float yPos) const { assume(yPos >= 0.f); assume(yPos <= 1.f); yPos *= Height(); float3 up = UpDirection(); float3 centerPos = Bottom() + up * yPos; if (yPos < r) // First section, between Bottom() and lower point. return Circle(centerPos, up, Sqrt(r*r - (r-yPos)*(r-yPos))); if (yPos < l.Length() + r) // Second section, between lower and upper points. return Circle(centerPos, up, r); float d = yPos - r - l.Length(); // Third section, above upper point. return Circle(centerPos, up, Sqrt(r*r - d*d)); }
long CText::HitTest(long x, long y) { if(!m_DnyAttr.m_Linked) return TK_NONE; CRect rtTemp; POINT pt; pt.x=x; pt.y=y; rtTemp.SetRect(Left(),Top(),Right(),Bottom()); if(rtTemp.PtInRect(pt)) return TK_PUSH; return TK_NONE; }
Vec2f ToolTip::calculatePreferredSize(void) const { if(getFont() == NULL) { return getPreferredSize(); } Real32 Top(0),Bottom(0),Left(0),Right(0); if(getDrawnBorder() != NULL) { getDrawnBorder()->getInsets(Left, Right, Top, Bottom); } Pnt2f TextTopLeft, TextBottomRight; getFont()->getBounds(getText(), TextTopLeft, TextBottomRight); return TextBottomRight - TextTopLeft + Vec2f(Left+Right+2, Top+Bottom+2); }
void NPCManager::Draw() { auto cam = Camera2D::GetInstance(); float camLeft = cam->Left(); float camRight = cam->Right(); float camTop = cam->Top(); float camBottom = cam->Bottom(); for (NPC * npc : m_npcList) { // TODO: instead of doing bounds checks in lots of places we can calculate // at the start of the frame and set a flag if is in view if (!npc->IsPlayerEnemy() || cam->IsObjectInView(npc)) { continue; } Vector3 indicatorPos = Vector3(npc->X(), npc->Y(), 3); if (npc->Right() < camLeft) { indicatorPos.X = camLeft + 55; } else if (npc->Left() > camRight) { indicatorPos.X = camRight - 55; } if (npc->Bottom() > camTop) { indicatorPos.Y = camTop - 55; } else if (npc->Top() < camBottom) { indicatorPos.Y = camBottom + 55; } // TODO: don't use the draw utilities as it's very slow DrawUtilities::DrawTexture(indicatorPos, Vector2(90, 90), "Media//skull_icon.png"); } }
//两条或三条线 bool PathFind::MoreLine(const Point& first,const Point& second) { bool isOK=Center(first,second); if(!isOK) { isOK=Left(first,second); } if(!isOK) { isOK=Right(first,second); } if(!isOK) { isOK=Top(first,second); } if(!isOK) { isOK=Bottom(first,second); } return isOK; }
void Layout::_moveChildRelative(Control * control, int newX, int newY) { if (_align & Center) { control->Move(x + newX - control->Width(), y + newY - control->Height()); } if (_align & Top) { control->SetY(y + newY); } if (_align & Left) { control->SetX(x + newX); } if (_align & Align::Right) { control->SetX(Right() - newX - control->Width()); } if (_align & Align::Bottom) { control->SetY(Bottom() - newY - control->Height()); } }
void CCell::DrawHotPoints(CDC *pDC) { LOGPEN tLogPen; tLogPen.lopnColor=RGB(0,0,0); tLogPen.lopnStyle=PS_DOT; tLogPen.lopnWidth.x=1; CPen tPen; tPen.CreatePenIndirect(&tLogPen); CPen *pOldPen=(CPen *)pDC->SelectObject(&tPen); CBrush *pOldBrush=(CBrush *)pDC->SelectStockObject(NULL_BRUSH); pDC->SetROP2(R2_NOTXORPEN); long x1,y1,x2,y2; UPtoLP(Left()-DELTA,Top()-DELTA,&x1,&y1); UPtoLP(Right()+DELTA,Bottom()+DELTA,&x2,&y2); pDC->Rectangle(x1,y1,x2,y2); pDC->SetROP2(R2_COPYPEN); pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush); }
long CPixelBufferView::OnMouseWheel(int x, int y, short z) { float newZoom = 0; z /= WHEEL_DELTA; if(z <= -1) { newZoom = m_zoomFactor / 2; } else if(z >= 1) { newZoom = m_zoomFactor * 2; } if(newZoom != 0) { auto clientRect = GetClientRect(); POINT mousePoint = {x, y}; ScreenToClient(m_hWnd, &mousePoint); float relPosX = static_cast<float>(mousePoint.x) / static_cast<float>(clientRect.Right()); float relPosY = static_cast<float>(mousePoint.y) / static_cast<float>(clientRect.Bottom()); relPosX = std::max(relPosX, 0.f); relPosX = std::min(relPosX, 1.f); relPosY = std::max(relPosY, 0.f); relPosY = std::min(relPosY, 1.f); relPosX = (relPosX - 0.5f) * 2; relPosY = (relPosY - 0.5f) * 2; float panModX = (1 - newZoom / m_zoomFactor) * relPosX; float panModY = (1 - newZoom / m_zoomFactor) * relPosY; m_panX += panModX; m_panY -= panModY; m_zoomFactor = newZoom; Refresh(); } return TRUE; }