本文整理汇总了C++中common::Rect::moveTo方法的典型用法代码示例。如果您正苦于以下问题:C++ Rect::moveTo方法的具体用法?C++ Rect::moveTo怎么用?C++ Rect::moveTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::Rect
的用法示例。
在下文中一共展示了Rect::moveTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeFrame
void Sprite::removeFrame(const uint32 frameNum) {
_frameArray[frameNum].frame->_referenceCount--;
if (_frameArray[frameNum].frame->_referenceCount == 0)
delete _frameArray[frameNum].frame;
// Calculate the new bounds
Common::Rect frameBounds;
for (uint32 i = 0; i < _numFrames; i++) {
if (i == frameNum)
continue;
Common::Rect r;
_frameArray[i].frame->getSurfaceBounds(r);
r.translate(_frameArray[i].frameLeft, _frameArray[i].frameTop);
frameBounds.extend(r);
}
_frameArray.remove_at(frameNum);
frameBounds.moveTo(_bounds.left, _bounds.top);
setBounds(frameBounds);
if (_currentFrameNum == frameNum)
triggerRedraw();
else if (_currentFrameNum != 0xffffffff && _currentFrameNum > frameNum)
--_currentFrameNum;
}
示例2: openInteraction
void NoradElevator::openInteraction() {
SpriteFrame *frame = new SpriteFrame();
frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kElevatorLabelID, true);
_elevatorControls.addFrame(frame, 0, 0);
frame = new SpriteFrame();
frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kElevatorButtonsID, true);
_elevatorControls.addFrame(frame, 0, 0);
frame = new SpriteFrame();
frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kElevatorDownOnID, true);
_elevatorControls.addFrame(frame, 0, 0);
frame = new SpriteFrame();
frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kElevatorUpOnID, true);
_elevatorControls.addFrame(frame, 0, 0);
_elevatorControls.setCurrentFrameIndex(0);
_elevatorControls.setDisplayOrder(kElevatorControlsOrder);
Common::Rect r;
frame->getSurfaceBounds(r);
r.moveTo(kNoradAlphaElevatorControlsLeft, kNoradAlphaElevatorControlsTop);
_elevatorControls.setBounds(r);
_elevatorControls.startDisplaying();
_elevatorControls.show();
}
示例3: clip
bool ASurface::clip(Common::Rect &r) {
int skip;
_leftSkip = _rightSkip = 0;
_topSkip = _bottomSkip = 0;
if (r.left > _clipWidth || r.left < 0) {
if (r.left >= 0)
return true;
skip = -r.left;
r.setWidth(r.width() - skip);
_leftSkip = skip;
r.moveTo(0, r.top);
}
int right = r.right - 1;
if (right < 0)
return true;
else if (right > _clipWidth) {
skip = right - _clipWidth;
r.setWidth(r.width() - skip);
_rightSkip = skip;
}
if (r.top > _clipHeight || r.top < 0) {
if (r.top >= 0)
return true;
skip = -r.top;
r.setHeight(r.height() - skip);
_topSkip = skip;
r.moveTo(r.left, 0);
}
int bottom = r.bottom - 1;
if (bottom < 0)
return true;
else if (bottom > _clipHeight) {
skip = bottom - _clipHeight;
_bottomSkip = skip;
r.setHeight(r.height() - skip);
}
return false;
}
示例4: getItemRect
void InventoryRenderer::getItemRect(ItemPosition pos, Common::Rect &r) {
r.setHeight(_props->_itemHeight);
r.setWidth(_props->_itemWidth);
uint16 line = pos / _props->_itemsPerLine;
uint16 col = pos % _props->_itemsPerLine;
r.moveTo(col * _props->_itemWidth, line * _props->_itemHeight);
}
示例5: timeChanged
void PanoramaScroll::timeChanged(const TimeValue newTime) {
CoordType leftPixel = (_totalWidth - _boundsWidth) * newTime / getDuration();
Common::Rect r;
_panorama.getViewBounds(r);
if (leftPixel != r.left) {
_panorama.getViewBounds(r);
r.moveTo(leftPixel, 0);
_panorama.setViewBounds(r);
triggerRedraw();
}
}
示例6: draw
void Movie::draw(const Common::Rect &r) {
Common::Rect worldBounds = _movieBox;
Common::Rect elementBounds;
getBounds(elementBounds);
worldBounds.moveTo(elementBounds.left, elementBounds.top);
Common::Rect r1 = r.findIntersectingRect(worldBounds);
Common::Rect r2 = r1;
r2.translate(_movieBox.left - elementBounds.left, _movieBox.top - elementBounds.top);
drawImage(r2, r1);
}
示例7: draw
void Picture::draw(const Common::Rect &r) {
Common::Rect surfaceBounds;
getSurfaceBounds(surfaceBounds);
Common::Rect r1 = r;
Common::Rect bounds;
getBounds(bounds);
surfaceBounds.moveTo(bounds.left, bounds.top);
r1 = r1.findIntersectingRect(surfaceBounds);
getSurfaceBounds(surfaceBounds);
Common::Rect r2 = r1;
r2.translate(surfaceBounds.left - bounds.left, surfaceBounds.top - bounds.top);
drawImage(r2, r1);
}
示例8: setCursor
void Events::setCursor(CursorId cursorId, const Common::Point &cursorPos, const Graphics::Surface &surface) {
_cursorId = cursorId;
// Get the standard cursor frame
Graphics::Surface &cursorImg = (*_cursorImages)[cursorId]._frame;
// If the X pos for the cursor image is -100, this is a special value to indicate
// the cursor should be horizontally centered
Common::Point cursorPt = cursorPos;
if (cursorPos.x == -100)
cursorPt.x = (surface.w - cursorImg.w) / 2;
// Figure total bounds needed for cursor image and passed image
Common::Rect bounds(surface.w, surface.h);
bounds.extend(Common::Rect(cursorPt.x, cursorPt.y, cursorPt.x + cursorImg.w, cursorPt.y + cursorImg.h));
Common::Rect r = bounds;
r.moveTo(0, 0);
// Form a single surface containing both frames
Surface s(r.width(), r.height());
s.fill(TRANSPARENCY);
// Draw the passed image
Common::Point drawPos;
if (cursorPt.x < 0)
drawPos.x = -cursorPt.x;
if (cursorPt.y < 0)
drawPos.y = -cursorPt.y;
s.blitFrom(surface, Common::Point(drawPos.x, drawPos.y));
// Draw the cursor image
drawPos = Common::Point(MAX(cursorPt.x, (int16)0), MAX(cursorPt.y, (int16)0));
s.transBlitFrom(cursorImg, Common::Point(drawPos.x, drawPos.y));
// Set up hotspot position for cursor, adjusting for cursor image's position within the surface
Common::Point hotspot;
if (cursorId == MAGNIFY)
hotspot = Common::Point(8, 8);
hotspot += drawPos;
// Set the cursor
setCursor(s.getRawSurface(), hotspot.x, hotspot.y);
}
示例9: addFrame
uint32 Sprite::addFrame(SpriteFrame *frame, const CoordType left, const CoordType top) {
SpriteFrameRec frameRecord;
frameRecord.frame = frame;
frameRecord.frameLeft = left;
frameRecord.frameTop = top;
_frameArray.push_back(frameRecord);
_numFrames++;
frame->_referenceCount++;
Common::Rect frameBounds;
frame->getSurfaceBounds(frameBounds);
// 9/3/96
// BB Should this be + left or - left?
frameBounds.moveTo(_bounds.left + left, _bounds.top + top);
frameBounds.extend(_bounds);
if (_bounds != frameBounds)
setBounds(frameBounds);
return _numFrames - 1;
}
示例10: handleMouseClicks
bool AgiEngine::handleMouseClicks(uint16 &key) {
// No mouse click? -> exit
if (key != AGI_MOUSE_BUTTON_LEFT)
return false;
if (!cycleInnerLoopIsActive()) {
// Only do this, when no inner loop is currently active
Common::Rect displayLineRect = _gfx->getFontRectForDisplayScreen(0, 0, FONT_COLUMN_CHARACTERS, 1);
// Common::Rect displayLineRect(_gfx->getDisplayScreenWidth(), _gfx->getDisplayFontHeight());
if (displayLineRect.contains(_mouse.pos)) {
// Mouse is inside first line of the screen
if (getFlag(VM_FLAG_MENUS_ACCESSIBLE) && _menu->isAvailable()) {
_menu->delayedExecuteViaMouse();
key = 0; // eat event
return true;
}
}
if (_text->promptIsEnabled()) {
// Prompt is currently enabled
int16 promptRow = _text->promptRow_Get();
displayLineRect.moveTo(0, promptRow * _gfx->getDisplayFontHeight());
if (displayLineRect.contains(_mouse.pos)) {
// and user clicked within the line of the prompt
showPredictiveDialog();
key = 0; // eat event
return true;
}
}
}
if (cycleInnerLoopIsActive()) {
// inner loop active, check what kind of loop it is. Then process / forward it
switch (_game.cycleInnerLoopType) {
case CYCLE_INNERLOOP_GETSTRING:
case CYCLE_INNERLOOP_GETNUMBER: {
// process in here
int16 stringRow, stringColumn, stringMaxLen;
_text->stringPos_Get(stringRow, stringColumn);
stringMaxLen = _text->stringGetMaxLen();
Common::Rect displayRect = _gfx->getFontRectForDisplayScreen(stringColumn, stringRow, stringMaxLen, 1);
if (displayRect.contains(_mouse.pos)) {
// user clicked inside the input space
showPredictiveDialog();
key = 0; // eat event
return true;
}
break;
}
case CYCLE_INNERLOOP_INVENTORY:
// TODO: forward
break;
case CYCLE_INNERLOOP_MENU_VIA_KEYBOARD:
_menu->mouseEvent(key);
key = 0; // eat event
break;
case CYCLE_INNERLOOP_SYSTEMUI_SELECTSAVEDGAMESLOT:
// TODO: forward
break;
default:
break;
}
}
return false;
}
示例11: kDisplay
reg_t GfxPaint16::kernelDisplay(const char *text, int argc, reg_t *argv) {
reg_t displayArg;
TextAlignment alignment = SCI_TEXT16_ALIGNMENT_LEFT;
int16 colorPen = -1, colorBack = -1, width = -1, bRedraw = 1;
bool doSaveUnder = false;
Common::Rect rect;
reg_t result = NULL_REG;
// Make a "backup" of the port settings (required for some SCI0LATE and
// SCI01+ only)
Port oldPort = *_ports->getPort();
// setting defaults
_ports->penMode(0);
_ports->penColor(0);
_ports->textGreyedOutput(false);
// processing codes in argv
while (argc > 0) {
displayArg = argv[0];
if (displayArg.segment)
displayArg.offset = 0xFFFF;
argc--; argv++;
switch (displayArg.offset) {
case SCI_DISPLAY_MOVEPEN:
_ports->moveTo(argv[0].toUint16(), argv[1].toUint16());
argc -= 2; argv += 2;
break;
case SCI_DISPLAY_SETALIGNMENT:
alignment = argv[0].toSint16();
argc--; argv++;
break;
case SCI_DISPLAY_SETPENCOLOR:
colorPen = argv[0].toUint16();
_ports->penColor(colorPen);
argc--; argv++;
break;
case SCI_DISPLAY_SETBACKGROUNDCOLOR:
colorBack = argv[0].toUint16();
argc--; argv++;
break;
case SCI_DISPLAY_SETGREYEDOUTPUT:
_ports->textGreyedOutput(argv[0].isNull() ? false : true);
argc--; argv++;
break;
case SCI_DISPLAY_SETFONT:
_text16->SetFont(argv[0].toUint16());
argc--; argv++;
break;
case SCI_DISPLAY_WIDTH:
width = argv[0].toUint16();
argc--; argv++;
break;
case SCI_DISPLAY_SAVEUNDER:
doSaveUnder = true;
break;
case SCI_DISPLAY_RESTOREUNDER:
bitsGetRect(argv[0], &rect);
rect.translate(-_ports->getPort()->left, -_ports->getPort()->top);
if (g_sci->getGameId() == GID_PQ3 && g_sci->getEngineState()->currentRoomNumber() == 29) {
// WORKAROUND: PQ3 calls this without calling the associated
// kDisplay(SCI_DISPLAY_SAVEUNDER) call before. Theoretically,
// this would result in no rect getting restored. However, we
// still maintain a pointer from the previous room, resulting
// in invalidated content being restored on screen, and causing
// graphics glitches. Thus, we simply don't restore a rect in
// that room. The correct fix for this would be to erase hunk
// pointers when changing rooms, but this will suffice for now,
// as restoring from a totally invalid pointer is very rare.
// Fixes bug #3037945.
} else {
bitsRestore(argv[0]);
}
kernelGraphRedrawBox(rect);
// finishing loop
argc = 0;
break;
case SCI_DISPLAY_DONTSHOWBITS:
bRedraw = 0;
break;
// 2 Dummy functions, longbow-demo is using those several times but sierra sci doesn't support them at all
// The Quest for Glory 1 EGA demo also calls kDisplay(114)
case SCI_DISPLAY_DUMMY1:
case SCI_DISPLAY_DUMMY2:
if (!g_sci->isDemo() || (g_sci->getGameId() != GID_LONGBOW && g_sci->getGameId() != GID_QFG1))
error("Unknown kDisplay argument %d", displayArg.offset);
if (displayArg.offset == SCI_DISPLAY_DUMMY2) {
if (argc) {
argc--; argv++;
} else {
error("No parameter left for kDisplay(115)");
}
}
break;
default:
SciTrackOriginReply originReply;
SciWorkaroundSolution solution = trackOriginAndFindWorkaround(0, kDisplay_workarounds, &originReply);
if (solution.type == WORKAROUND_NONE)
error("Unknown kDisplay argument (%04x:%04x) from method %s::%s (script %d, localCall %x)", PRINT_REG(displayArg), originReply.objectName.c_str(), originReply.methodName.c_str(), originReply.scriptNr, originReply.localCallOffset);
assert(solution.type == WORKAROUND_IGNORE);
//.........这里部分代码省略.........
示例12: centerElementAt
void DisplayElement::centerElementAt(const CoordType h, const CoordType v) {
Common::Rect newBounds = _bounds;
newBounds.moveTo(h - (_bounds.width() / 2), v - (_bounds.height() / 2));
setBounds(newBounds);
}
示例13: getRect
void InventoryRenderer::getRect(Common::Rect& r) const {
r.setWidth(_props->_width);
r.setHeight(_props->_itemHeight * getNumLines());
r.moveTo(_pos);
}
示例14: demo
reg_t GfxPaint16::kernelDisplay(const char *text, int argc, reg_t *argv) {
reg_t displayArg;
TextAlignment alignment = SCI_TEXT16_ALIGNMENT_LEFT;
int16 colorPen = -1, colorBack = -1, width = -1, bRedraw = 1;
bool doSaveUnder = false;
Common::Rect rect;
reg_t result = NULL_REG;
// Make a "backup" of the port settings (required for some SCI0LATE and
// SCI01+ only)
Port oldPort = *_ports->getPort();
// setting defaults
_ports->penMode(0);
_ports->penColor(0);
_ports->textGreyedOutput(false);
// processing codes in argv
while (argc > 0) {
displayArg = argv[0];
if (displayArg.getSegment())
displayArg.setOffset(0xFFFF);
argc--; argv++;
switch (displayArg.getOffset()) {
case SCI_DISPLAY_MOVEPEN:
_ports->moveTo(argv[0].toUint16(), argv[1].toUint16());
argc -= 2; argv += 2;
break;
case SCI_DISPLAY_SETALIGNMENT:
alignment = argv[0].toSint16();
argc--; argv++;
break;
case SCI_DISPLAY_SETPENCOLOR:
colorPen = argv[0].toUint16();
_ports->penColor(colorPen);
argc--; argv++;
break;
case SCI_DISPLAY_SETBACKGROUNDCOLOR:
colorBack = argv[0].toUint16();
argc--; argv++;
break;
case SCI_DISPLAY_SETGREYEDOUTPUT:
_ports->textGreyedOutput(!argv[0].isNull());
argc--; argv++;
break;
case SCI_DISPLAY_SETFONT:
_text16->SetFont(argv[0].toUint16());
argc--; argv++;
break;
case SCI_DISPLAY_WIDTH:
width = argv[0].toUint16();
argc--; argv++;
break;
case SCI_DISPLAY_SAVEUNDER:
doSaveUnder = true;
break;
case SCI_DISPLAY_RESTOREUNDER:
bitsGetRect(argv[0], &rect);
rect.translate(-_ports->getPort()->left, -_ports->getPort()->top);
bitsRestore(argv[0]);
kernelGraphRedrawBox(rect);
// finishing loop
argc = 0;
break;
case SCI_DISPLAY_DONTSHOWBITS:
bRedraw = 0;
break;
// The following three dummy calls are not supported by the Sierra SCI
// interpreter, but are erroneously called in some game scripts.
case SCI_DISPLAY_DUMMY1: // Longbow demo (all rooms) and QFG1 EGA demo (room 11)
case SCI_DISPLAY_DUMMY2: // Longbow demo (all rooms)
case SCI_DISPLAY_DUMMY3: // QFG1 EGA demo (room 11) and PQ2 (room 23)
if (!(g_sci->getGameId() == GID_LONGBOW && g_sci->isDemo()) &&
!(g_sci->getGameId() == GID_QFG1 && g_sci->isDemo()) &&
!(g_sci->getGameId() == GID_PQ2))
error("Unknown kDisplay argument %d", displayArg.getOffset());
if (displayArg.getOffset() == SCI_DISPLAY_DUMMY2) {
if (!argc)
error("No parameter left for kDisplay(115)");
argc--; argv++;
}
break;
default:
SciTrackOriginReply originReply;
SciWorkaroundSolution solution = trackOriginAndFindWorkaround(0, kDisplay_workarounds, &originReply);
if (solution.type == WORKAROUND_NONE)
error("Unknown kDisplay argument (%04x:%04x) from method %s::%s (script %d, localCall %x)",
PRINT_REG(displayArg), originReply.objectName.c_str(), originReply.methodName.c_str(),
originReply.scriptNr, originReply.localCallOffset);
assert(solution.type == WORKAROUND_IGNORE);
break;
}
}
//20140521 Text Exchange
std::map<std::string, std::string>::iterator iter;
if(g_sci->_ScriptData)
{
_ShouterInfo* pInfo = g_sci->_ScriptData->GetShouterInfo();
//.........这里部分代码省略.........
示例15: openInteraction
void PressureDoor::openInteraction() {
if (_isUpperDoor) {
_levelsMovie.initFromMovieFile("Images/Norad Alpha/Upper Levels Movie");
_levelsMovie.moveElementTo(kNoradUpperLevelsLeft, kNoradUpperLevelsTop);
} else {
_levelsMovie.initFromMovieFile("Images/Norad Alpha/Lower Levels Movie");
_levelsMovie.moveElementTo(kNoradLowerLevelsLeft, kNoradLowerLevelsTop);
}
_levelsScale = _levelsMovie.getScale();
_levelsMovie.setDisplayOrder(kPressureLevelsOrder);
_levelsMovie.startDisplaying();
_levelsMovie.setSegment(kLevelsSplashStart * _levelsScale, kLevelsSplashStop * _levelsScale);
_levelsMovie.setTime(kLevelsSplashStart * _levelsScale);
_levelsMovie.redrawMovieWorld();
_levelsMovie.show();
_pressureCallBack.setNotification(&_pressureNotification);
_pressureCallBack.initCallBack(&_levelsMovie, kCallBackAtExtremes);
_pressureCallBack.setCallBackFlag(kSplashFinished);
_pressureCallBack.scheduleCallBack(kTriggerAtStop, 0, 0);
_pressureNotification.notifyMe(this, kPressureNotificationFlags, kPressureNotificationFlags);
if (_isUpperDoor) {
_typeMovie.initFromMovieFile("Images/Norad Alpha/Upper Type Movie");
_typeMovie.moveElementTo(kNoradUpperTypeLeft, kNoradUpperTypeTop);
} else {
_typeMovie.initFromMovieFile("Images/Norad Alpha/Lower Type Movie");
_typeMovie.moveElementTo(kNoradLowerTypeLeft, kNoradLowerTypeTop);
}
_typeScale = _typeMovie.getScale();
_typeMovie.setDisplayOrder(kPressureTypeOrder);
_typeMovie.startDisplaying();
_typeMovie.setTime(kDoorSealedTime * _typeScale);
_typeMovie.redrawMovieWorld();
SpriteFrame *frame = new SpriteFrame();
if (_isUpperDoor)
frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kLowerPressureUpOffPICTID);
else
frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kUpperPressureUpOffPICTID);
_upButton.addFrame(frame, 0, 0);
frame = new SpriteFrame();
if (_isUpperDoor)
frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kLowerPressureUpOnPICTID);
else
frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kUpperPressureUpOnPICTID);
_upButton.addFrame(frame, 0, 0);
_upButton.setCurrentFrameIndex(0);
_upButton.setDisplayOrder(kPressureUpOrder);
Common::Rect r;
frame->getSurfaceBounds(r);
if (_isUpperDoor)
r.moveTo(kNoradUpperUpLeft, kNoradUpperUpTop);
else
r.moveTo(kNoradLowerUpLeft, kNoradLowerUpTop);
_upButton.setBounds(r);
_upButton.startDisplaying();
_upButton.show();
frame = new SpriteFrame();
if (_isUpperDoor)
frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kLowerPressureDownOffPICTID);
else
frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kUpperPressureDownOffPICTID);
_downButton.addFrame(frame, 0, 0);
frame = new SpriteFrame();
if (_isUpperDoor)
frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kLowerPressureDownOnPICTID);
else
frame->initFromPICTResource(((PegasusEngine *)g_engine)->_resFork, kUpperPressureDownOnPICTID);
_downButton.addFrame(frame, 0, 0);
_downButton.setCurrentFrameIndex(0);
_downButton.setDisplayOrder(kPressureDownOrder);
frame->getSurfaceBounds(r);
if (_isUpperDoor)
r.moveTo(kNoradUpperDownLeft, kNoradUpperDownTop);
else
r.moveTo(kNoradLowerDownLeft, kNoradLowerDownTop);
_downButton.setBounds(r);
_downButton.startDisplaying();
_downButton.show();
_utilityCallBack.setNotification(&_utilityNotification);
_utilityCallBack.initCallBack(&_utilityTimer, kCallBackAtTime);
_utilityNotification.notifyMe(this, kUtilityNotificationFlags, kUtilityNotificationFlags);
_utilityTimer.setMasterTimeBase(getOwner()->getNavMovie());
if (_playingAgainstRobot)
_neighborhoodNotification->notifyMe(this, kExtraCompletedFlag | kDelayCompletedFlag |
//.........这里部分代码省略.........