本文整理汇总了C++中common::Rect::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::contains方法的具体用法?C++ Rect::contains怎么用?C++ Rect::contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::Rect
的用法示例。
在下文中一共展示了Rect::contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xtakeit
void TSpit::xtakeit(const ArgumentArray &args) {
// Pick up and move a marble
// First, let's figure out what marble we're now holding
uint32 &marble = _vm->_vars["themarble"];
marble = 0;
for (uint32 i = 0; i < kMarbleCount; i++) {
RivenHotspot *marbleHotspot = _vm->getCard()->getHotspotByName(s_marbleNames[i]);
if (marbleHotspot->containsPoint(getMousePosition())) {
marble = i + 1;
break;
}
}
// xtakeit() shouldn't be called if we're not on a marble hotspot
assert(marble != 0);
// Redraw the background
_vm->getCard()->drawPicture(1);
// Loop until the player lets go (or quits)
while (mouseIsDown() && !_vm->hasGameEnded()) {
_vm->doFrame();
}
// Check if we landed in a valid location and no other marble has that location
uint32 &marblePos = _vm->_vars[s_marbleNames[marble - 1]];
bool foundMatch = false;
for (int y = 0; y < 25 && !foundMatch; y++) {
for (int x = 0; x < 25 && !foundMatch; x++) {
Common::Rect testHotspot = generateMarbleGridRect(x, y);
// Let's try to place the marble!
if (testHotspot.contains(getMousePosition())) {
// Set this as the position
setMarbleX(marblePos, x);
setMarbleY(marblePos, y);
// Let's make sure no other marble is in this spot...
for (uint16 i = 0; i < kMarbleCount; i++)
if (i != marble - 1 && _vm->_vars[s_marbleNames[i]] == marblePos)
marblePos = 0;
// We have a match
foundMatch = true;
}
}
}
// If we still don't have a match, reset it to the original location
if (!foundMatch)
marblePos = 0;
// Check the new hotspots and refresh everything
marble = 0;
setMarbleHotspots();
drawMarbles();
}
示例2: addDirtyRect
void Render::addDirtyRect(Common::Rect r) {
if (_fullRefresh)
return;
// Clip rectangle
r.clip(_backGroundSurface.w, _backGroundSurface.h);
// If it is empty after clipping, we are done
if (r.isEmpty())
return;
// Check if the new rectangle is contained within another in the list
Common::List<Common::Rect>::iterator it;
for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ) {
// If we find a rectangle which fully contains the new one,
// we can abort the search.
if (it->contains(r))
return;
// Conversely, if we find rectangles which are contained in
// the new one, we can remove them
if (r.contains(*it))
it = _dirtyRects.erase(it);
else
++it;
}
// If we got here, we can safely add r to the list of dirty rects.
if (_vm->_interface->getFadeMode() != kFadeOut)
_dirtyRects.push_back(r);
}
示例3: mouseMove
void CSTimeHelp::mouseMove(Common::Point &pos) {
bool mouseIsDown = _vm->getEventManager()->getButtonState() & 1;
for (uint i = 0; i < _qars.size(); i++) {
Common::Rect thisRect = _vm->getInterface()->_dialogTextRect;
thisRect.top += 1 + i*15;
thisRect.bottom = thisRect.top + 15;
if (!thisRect.contains(pos))
continue;
if (mouseIsDown) {
if (i != _currEntry)
break;
highlightLine(i);
}
_vm->getInterface()->cursorOverHotspot();
_currHover = i;
return;
}
if (_currHover != 0xffff) {
if (_vm->getInterface()->cursorGetShape() != 3) {
unhighlightLine(_currHover);
_vm->getInterface()->cursorSetShape(1);
}
_currHover = 0xffff;
}
}
示例4: addDirtyRect
void ThemeEngine::addDirtyRect(Common::Rect r) {
// Clip the rect to screen coords
r.clip(_screen.w, _screen.h);
// If it is empty after clipping, we are done
if (r.isEmpty())
return;
// Check if the new rectangle is contained within another in the list
Common::List<Common::Rect>::iterator it;
for (it = _dirtyScreen.begin(); it != _dirtyScreen.end();) {
// If we find a rectangle which fully contains the new one,
// we can abort the search.
if (it->contains(r))
return;
// Conversely, if we find rectangles which are contained in
// the new one, we can remove them
if (r.contains(*it))
it = _dirtyScreen.erase(it);
else
++it;
}
// If we got here, we can safely add r to the list of dirty rects.
_dirtyScreen.push_back(r);
}
示例5: hotspot
bool Script::hotspot(Common::Rect rect, uint16 address, uint8 cursor) {
// Test if the current mouse position is contained in the specified rectangle
Common::Point mousepos = _vm->_system->getEventManager()->getMousePos();
bool contained = rect.contains(mousepos);
// Show hotspots when debugging
if (Common::isDebugChannelEnabled(kGroovieDebugHotspots) ||
Common::isDebugChannelEnabled(kGroovieDebugAll)) {
rect.translate(0, -80);
_vm->_graphicsMan->_foreground.frameRect(rect, 250);
_vm->_system->copyRectToScreen((byte*)_vm->_graphicsMan->_foreground.getBasePtr(0, 0), 640, 0, 80, 640, 320);
_vm->_system->updateScreen();
}
// If there's an already planned action, do nothing
if (_inputAction != -1) {
return false;
}
if (contained) {
// Change the mouse cursor
if (_newCursorStyle == 5) {
_newCursorStyle = cursor;
}
// If clicked with the mouse, jump to the specified address
if (_mouseClicked) {
_inputAction = address;
}
}
return contained;
}
示例6: frameFromStatus
MenuInputState *run() {
if (_vm->_input->getLastButtonEvent() != kMouseLeftUp) {
return this;
}
int cell = -1;
Common::Point p;
_vm->_input->getCursorPos(p);
if (_menuRect.contains(p)) {
cell = (p.x - _menuRect.left) / _cellW + 3 * ((p.y - _menuRect.top) / _cellH);
}
bool close = false;
switch (cell) {
case 4: // resume
case -1: // invalid cell
close = true;
break;
case 0: // toggle music
if (_mscStatus != -1) {
_vm->enableMusic(!_mscStatus);
_mscStatus = _vm->getMusicStatus();
_vm->_gfx->setItemFrame(_mscMenuObjId, frameFromStatus(_mscStatus));
}
break;
case 1: // toggle sfx
if (_sfxStatus != -1) {
_vm->enableSfx(!_sfxStatus);
_sfxStatus = _vm->getSfxStatus();
_vm->_gfx->setItemFrame(_sfxMenuObjId, frameFromStatus(_sfxStatus));
}
break;
case 2: // save
warning("Saving is not supported yet");
_vm->_saveLoad->saveGame();
break;
case 3: // load
warning("Loading is not supported yet");
close = _vm->_saveLoad->loadGame();
break;
case 5: // quit
return _helper->getState("quitdialog");
}
if (close) {
_vm->_gfx->freeDialogueObjects();
return 0;
}
_vm->_input->setArrowCursor();
return this;
}
示例7: hitTest
ItemPosition InventoryRenderer::hitTest(const Common::Point &p) const {
Common::Rect r;
getRect(r);
if (!r.contains(p))
return -1;
return ((p.x - _pos.x) / _props->_itemWidth) + (_props->_itemsPerLine * ((p.y - _pos.y) / _props->_itemHeight));
}
示例8: hitFrameRect
bool Animation::hitFrameRect(int x, int y) const {
if (!gfxobj) {
return false;
}
Common::Rect r;
getFrameRect(r);
return r.contains(x, y);
}
示例9: mouseDown
void CSTimeHelp::mouseDown(Common::Point &pos) {
for (uint i = 0; i < _qars.size(); i++) {
Common::Rect thisRect = _vm->getInterface()->_dialogTextRect;
thisRect.top += 1 + i*15;
thisRect.bottom = thisRect.top + 15;
if (!thisRect.contains(pos))
continue;
_currEntry = i;
highlightLine(i);
_vm->getInterface()->cursorSetShape(5);
}
}
示例10: mouseUp
void CSTimeHelp::mouseUp(Common::Point &pos) {
if (_currEntry == 0xffff || _qars[_currEntry].speech == 0) {
_vm->getInterface()->cursorSetShape(1);
end();
return;
}
Common::Rect thisRect = _vm->getInterface()->_dialogTextRect;
thisRect.top += 1 + _currEntry*15;
thisRect.bottom = thisRect.top + 15;
if (!thisRect.contains(pos))
return;
_vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, _vm->getCase()->getCurrScene()->getHelperId(), 5900 + _qars[_currEntry].speech));
_nextToProcess = _currEntry;
_askedAlready.push_back(_qars[_currEntry].text);
}
示例11:
const CloseData *LabEngine::getObject(Common::Point pos, const CloseData *closePtr) {
const CloseDataList *list;
if (!closePtr)
list = &(getViewData(_roomNum, _direction)->_closeUps);
else
list = &(closePtr->_subCloseUps);
CloseDataList::const_iterator wrkClosePtr;
for (wrkClosePtr = list->begin(); wrkClosePtr != list->end(); ++wrkClosePtr) {
Common::Rect objRect;
objRect = _utils->rectScale(wrkClosePtr->_x1, wrkClosePtr->_y1, wrkClosePtr->_x2, wrkClosePtr->_y2);
if (objRect.contains(pos))
return &(*wrkClosePtr);
}
return nullptr;
}
示例12: isPointInRectsCube
int32 HotSpot::isPointInRectsCube(const Common::Point &p) {
for (uint j = 0; j < rects.size(); j++) {
Common::Rect rect = Common::Rect(
rects[j].centerHeading - rects[j].width / 2,
rects[j].centerPitch - rects[j].height / 2,
rects[j].centerHeading + rects[j].width / 2,
rects[j].centerPitch + rects[j].height / 2);
// Make sure heading is in the correct range
Common::Point lookAt = p;
if (rect.right > 360 && lookAt.x <= rect.right - 360)
lookAt.x += 360;
if (rect.contains(lookAt))
return j;
}
return -1;
}
示例13: markDirtyRect
/**
* @brief Marks a dirty rectangle on the surface
* @param r The rectangle to be marked dirty
*/
void Surface::markDirtyRect(Common::Rect r) {
Common::List<Common::Rect>::iterator it;
r.clip(w, h);
if (r.isEmpty())
return;
it = _dirtyRects.begin();
while (it != _dirtyRects.end()) {
if (it->contains(r))
return;
if (r.contains(*it))
it = _dirtyRects.erase(it);
else
++it;
}
_dirtyRects.push_back(r);
}
示例14: isPointInRectsFrame
int32 HotSpot::isPointInRectsFrame(GameState *state, const Common::Point &p) {
for (uint j = 0; j < rects.size(); j++) {
int16 x = rects[j].centerPitch;
int16 y = rects[j].centerHeading;
int16 w = rects[j].width;
int16 h = rects[j].height;
if (y < 0) {
x = state->getVar(x);
y = state->getVar(-y);
h = -h;
}
Common::Rect rect = Common::Rect(w, h);
rect.translate(x, y);
if (rect.contains(p))
return j;
}
return -1;
}
示例15: takeItem
bool LabEngine::takeItem(Common::Point pos) {
const CloseDataList *list;
if (!_closeDataPtr) {
list = &(getViewData(_roomNum, _direction)->_closeUps);
} else if (_closeDataPtr->_closeUpType < 0) {
_conditions->inclElement(abs(_closeDataPtr->_closeUpType));
return true;
} else
list = &(_closeDataPtr->_subCloseUps);
CloseDataList::const_iterator closePtr;
for (closePtr = list->begin(); closePtr != list->end(); ++closePtr) {
Common::Rect objRect;
objRect = _utils->rectScale(closePtr->_x1, closePtr->_y1, closePtr->_x2, closePtr->_y2);
if (objRect.contains(pos) && (closePtr->_closeUpType < 0)) {
_conditions->inclElement(abs(closePtr->_closeUpType));
return true;
}
}
return false;
}