本文整理汇总了C++中common::Rect类的典型用法代码示例。如果您正苦于以下问题:C++ Rect类的具体用法?C++ Rect怎么用?C++ Rect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Rect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseEvents
TestExitStatus EventTests::mouseEvents() {
Testsuite::clearScreen();
Common::String info = "Testing Mouse events.\n "
"Any movement/click generated by L/R/M mouse buttons or the mouse wheel should be detected.\n"
"Press X to exit";
if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
Testsuite::logPrintf("Info! Skipping test : keyboard events\n");
return kTestSkipped;
}
Common::EventManager *eventMan = g_system->getEventManager();
Common::Point pt(0, 30);
Common::Rect rectInfo = Testsuite::writeOnScreen("Generate mouse events make L/R/M button clicks, move wheel", pt);
pt.y += 15;
Testsuite::writeOnScreen("Press X to exit", pt);
pt.y = 70;
Common::Rect rectLB = Testsuite::writeOnScreen("Left-button click : Not tested", pt);
pt.y += 15;
Common::Rect rectRB = Testsuite::writeOnScreen("Right-button click : Not tested", pt);
pt.y += 15;
Common::Rect rectMB = Testsuite::writeOnScreen("Middle-button click : Not tested", pt);
pt.y += 15;
Common::Rect rectWheel = Testsuite::writeOnScreen("Wheel Movements : Not tested", pt);
// Init Mouse Palette
GFXtests::initMousePalette();
Common::Rect finishZone = drawFinishZone();
bool quitLoop = false;
TestExitStatus passed = kTestPassed;
// handle all mouse events
Common::Event event;
while (!quitLoop) {
// Show mouse
CursorMan.showMouse(true);
g_system->updateScreen();
while (eventMan->pollEvent(event)) {
// Quit if explicitly requested
if (Engine::shouldQuit()) {
return passed;
}
switch (event.type) {
case Common::EVENT_MOUSEMOVE:
// Movements havee already been tested in GFX
break;
case Common::EVENT_LBUTTONDOWN:
Testsuite::clearScreen(rectInfo);
Testsuite::writeOnScreen("Mouse left-button pressed", Common::Point(rectInfo.left, rectInfo.top));
break;
case Common::EVENT_RBUTTONDOWN:
Testsuite::clearScreen(rectInfo);
Testsuite::writeOnScreen("Mouse right-button pressed", Common::Point(rectInfo.left, rectInfo.top));
break;
case Common::EVENT_WHEELDOWN:
Testsuite::clearScreen(rectInfo);
Testsuite::writeOnScreen("Mouse wheel moved down", Common::Point(rectInfo.left, rectInfo.top));
Testsuite::writeOnScreen("Wheel Movements : Done!", Common::Point(rectWheel.left, rectWheel.top));
break;
case Common::EVENT_MBUTTONDOWN:
Testsuite::clearScreen(rectInfo);
Testsuite::writeOnScreen("Mouse middle-button pressed ", Common::Point(rectInfo.left, rectInfo.top));
break;
case Common::EVENT_LBUTTONUP:
Testsuite::clearScreen(rectInfo);
if (finishZone.contains(eventMan->getMousePos())) {
quitLoop = true;
}
Testsuite::writeOnScreen("Mouse left-button released", Common::Point(rectInfo.left, rectInfo.top));
Testsuite::writeOnScreen("Left-button clicks : Done!", Common::Point(rectLB.left, rectLB.top));
break;
case Common::EVENT_RBUTTONUP:
Testsuite::clearScreen(rectInfo);
Testsuite::writeOnScreen("Mouse right-button released", Common::Point(rectInfo.left, rectInfo.top));
Testsuite::writeOnScreen("Right-button clicks : Done!", Common::Point(rectRB.left, rectRB.top));
break;
case Common::EVENT_WHEELUP:
Testsuite::clearScreen(rectInfo);
Testsuite::writeOnScreen("Mouse wheel moved up", Common::Point(rectInfo.left, rectInfo.top));
Testsuite::writeOnScreen("Wheel Movements : Done!", Common::Point(rectWheel.left, rectWheel.top));
break;
case Common::EVENT_MBUTTONUP:
Testsuite::clearScreen(rectInfo);
Testsuite::writeOnScreen("Mouse middle-button released ", Common::Point(rectInfo.left, rectInfo.top));
Testsuite::writeOnScreen("Middle-button clicks : Done!", Common::Point(rectMB.left, rectMB.top));
break;
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == Common::KEYCODE_x) {
Testsuite::clearScreen(rectInfo);
Testsuite::writeOnScreen("Exit requested", Common::Point(rectInfo.left, rectInfo.top));
quitLoop = true;
}
break;
default:
break;
}
//.........这里部分代码省略.........
示例2: playVideo
void ZVision::playVideo(Video::VideoDecoder &videoDecoder, const Common::Rect &destRect, bool skippable) {
byte bytesPerPixel = videoDecoder.getPixelFormat().bytesPerPixel;
uint16 origWidth = videoDecoder.getWidth();
uint16 origHeight = videoDecoder.getHeight();
uint scale = 1;
// If destRect is empty, no specific scaling was requested. However, we may choose to do scaling anyway
if (destRect.isEmpty()) {
// Most videos are very small. Therefore we do a simple 2x scale
if (origWidth * 2 <= 640 && origHeight * 2 <= 480) {
scale = 2;
}
} else {
// Assume bilinear scaling. AKA calculate the scale from just the width.
// Also assume that the scaling is in integral intervals. AKA no 1.5x scaling
// TODO: Test ^these^ assumptions
scale = destRect.width() / origWidth;
// TODO: Test if we need to support downscale.
}
uint16 pitch = origWidth * bytesPerPixel;
uint16 finalWidth = origWidth * scale;
uint16 finalHeight = origHeight * scale;
byte *scaledVideoFrameBuffer;
if (scale != 1) {
scaledVideoFrameBuffer = new byte[finalWidth * finalHeight * bytesPerPixel];
}
uint16 x = ((WINDOW_WIDTH - finalWidth) / 2) + destRect.left;
uint16 y = ((WINDOW_HEIGHT - finalHeight) / 2) + destRect.top;
_clock.stop();
videoDecoder.start();
// Only continue while the video is still playing
while (!shouldQuit() && !videoDecoder.endOfVideo() && videoDecoder.isPlaying()) {
// Check for engine quit and video stop key presses
while (!videoDecoder.endOfVideo() && videoDecoder.isPlaying() && _eventMan->pollEvent(_event)) {
switch (_event.type) {
case Common::EVENT_KEYDOWN:
switch (_event.kbd.keycode) {
case Common::KEYCODE_q:
if (_event.kbd.hasFlags(Common::KBD_CTRL))
quitGame();
break;
case Common::KEYCODE_SPACE:
if (skippable) {
videoDecoder.stop();
}
break;
default:
break;
}
default:
break;
}
}
if (videoDecoder.needsUpdate()) {
const Graphics::Surface *frame = videoDecoder.decodeNextFrame();
if (frame) {
if (scale != 1) {
scaleBuffer((const byte *)frame->getPixels(), scaledVideoFrameBuffer, origWidth, origHeight, bytesPerPixel, scale);
_system->copyRectToScreen(scaledVideoFrameBuffer, pitch * 2, x, y, finalWidth, finalHeight);
} else {
_system->copyRectToScreen((const byte *)frame->getPixels(), pitch, x, y, finalWidth, finalHeight);
}
}
}
// Always update the screen so the mouse continues to render
_system->updateScreen();
_system->delayMillis(videoDecoder.getTimeToNextFrame());
}
_clock.start();
if (scale != 1) {
delete[] scaledVideoFrameBuffer;
}
}
示例3: draw
//.........这里部分代码省略.........
// Merge area
userInterface.mergeFrom(&userInterface._surface, dirtyArea._bounds,
Common::Point(dirtyArea._bounds.left, dirtyArea._bounds.top));
} else {
// Copy area
userInterface.blitFrom(userInterface._surface, dirtyArea._bounds,
Common::Point(dirtyArea._bounds.left, dirtyArea._bounds.top));
}
}
}
for (uint idx = 0; idx < size(); ++idx) {
DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
UISlot &slot = (*this)[idx];
int slotType = slot._flags;
if (slotType >= IMG_STATIC) {
dirtyArea.setUISlot(&slot);
if (!updateFlag)
slotType &= ~0x40;
dirtyArea._textActive = slotType > 0;
slot._flags &= 0x40;
}
}
userInterface._dirtyAreas.merge(1, userInterface._uiSlots.size());
for (uint idx = 0; idx < size(); ++idx) {
DirtyArea *dirtyArea = &userInterface._dirtyAreas[idx];
UISlot &slot = (*this)[idx];
if (slot._flags >= IMG_STATIC && !(slot._flags & 0x40)) {
if (!dirtyArea->_active) {
do {
dirtyArea = dirtyArea->_mergedArea;
} while (!dirtyArea->_active);
}
if (dirtyArea->_textActive) {
SpriteAsset *asset = scene._sprites[slot._spritesIndex];
// Get the frame details
int frameNumber = ABS(slot._frameNumber);
bool flipped = slot._frameNumber < 0;
if (slot._segmentId == IMG_SPINNING_OBJECT) {
MSprite *sprite = asset->getFrame(frameNumber - 1);
userInterface.transBlitFrom(*sprite, slot._position,
sprite->getTransparencyIndex());
} else {
MSprite *sprite = asset->getFrame(frameNumber - 1);
if (flipped) {
MSurface *spr = sprite->flipHorizontal();
userInterface.mergeFrom(spr, spr->getBounds(), slot._position,
sprite->getTransparencyIndex());
spr->free();
delete spr;
} else {
userInterface.mergeFrom(sprite, sprite->getBounds(), slot._position,
sprite->getTransparencyIndex());
}
}
}
}
}
// Mark areas of the screen surface for updating
if (updateFlag) {
for (uint idx = 0; idx < size(); ++idx) {
DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
if (dirtyArea._active && dirtyArea._textActive &&
dirtyArea._bounds.width() > 0 && dirtyArea._bounds.height() > 0) {
// Flag area of screen as needing update
Common::Rect r = dirtyArea._bounds;
r.translate(0, scene._interfaceY);
//_vm->_screen->copyRectToScreen(r);
}
}
}
// Post-processing to remove slots no longer needed
for (int idx = (int)size() - 1; idx >= 0; --idx) {
UISlot &slot = (*this)[idx];
if (slot._flags < IMG_STATIC) {
if (delFlag || updateFlag)
remove_at(idx);
else if (slot._flags > -20)
slot._flags -= 20;
} else {
if (updateFlag)
slot._flags &= ~0x40;
else
slot._flags |= 0x40;
}
}
}
示例4: SELECTOR
void GfxControls32::kernelTexteditChange(reg_t controlObject) {
SciEvent curEvent;
uint16 maxChars = 40; //readSelectorValue(_segMan, controlObject, SELECTOR(max)); // TODO
reg_t textReference = readSelector(_segMan, controlObject, SELECTOR(text));
GfxFont *font = _cache->getFont(readSelectorValue(_segMan, controlObject, SELECTOR(font)));
Common::String text;
uint16 textSize;
bool textChanged = false;
bool textAddChar = false;
Common::Rect rect;
if (textReference.isNull())
error("kEditControl called on object that doesnt have a text reference");
text = _segMan->getString(textReference);
// TODO: Finish this
warning("kEditText ('%s')", text.c_str());
return;
uint16 cursorPos = 0;
//uint16 oldCursorPos = cursorPos;
bool captureEvents = true;
EventManager* eventMan = g_sci->getEventManager();
while (captureEvents) {
curEvent = g_sci->getEventManager()->getSciEvent(SCI_EVENT_KEYBOARD | SCI_EVENT_PEEK);
if (curEvent.type == SCI_EVENT_NONE) {
eventMan->getSciEvent(SCI_EVENT_KEYBOARD); // consume the event
} else {
textSize = text.size();
switch (curEvent.type) {
case SCI_EVENT_MOUSE_PRESS:
// TODO: Implement mouse support for cursor change
break;
case SCI_EVENT_KEYBOARD:
switch (curEvent.character) {
case SCI_KEY_BACKSPACE:
if (cursorPos > 0) {
cursorPos--; text.deleteChar(cursorPos);
textChanged = true;
}
eventMan->getSciEvent(SCI_EVENT_KEYBOARD); // consume the event
break;
case SCI_KEY_DELETE:
if (cursorPos < textSize) {
text.deleteChar(cursorPos);
textChanged = true;
}
eventMan->getSciEvent(SCI_EVENT_KEYBOARD); // consume the event
break;
case SCI_KEY_HOME: // HOME
cursorPos = 0; textChanged = true;
eventMan->getSciEvent(SCI_EVENT_KEYBOARD); // consume the event
break;
case SCI_KEY_END: // END
cursorPos = textSize; textChanged = true;
eventMan->getSciEvent(SCI_EVENT_KEYBOARD); // consume the event
break;
case SCI_KEY_LEFT: // LEFT
if (cursorPos > 0) {
cursorPos--; textChanged = true;
}
eventMan->getSciEvent(SCI_EVENT_KEYBOARD); // consume the event
break;
case SCI_KEY_RIGHT: // RIGHT
if (cursorPos + 1 <= textSize) {
cursorPos++; textChanged = true;
}
eventMan->getSciEvent(SCI_EVENT_KEYBOARD); // consume the event
break;
case 3: // returned in SCI1 late and newer when Control - C is pressed
if (curEvent.modifiers & SCI_KEYMOD_CTRL) {
// Control-C erases the whole line
cursorPos = 0; text.clear();
textChanged = true;
}
eventMan->getSciEvent(SCI_EVENT_KEYBOARD); // consume the event
break;
case SCI_KEY_UP:
case SCI_KEY_DOWN:
case SCI_KEY_ENTER:
case SCI_KEY_ESC:
case SCI_KEY_TAB:
case SCI_KEY_SHIFT_TAB:
captureEvents = false;
break;
default:
if ((curEvent.modifiers & SCI_KEYMOD_CTRL) && curEvent.character == 'c') {
// Control-C in earlier SCI games (SCI0 - SCI1 middle)
// Control-C erases the whole line
cursorPos = 0; text.clear();
textChanged = true;
} else if (curEvent.character > 31 && curEvent.character < 256 && textSize < maxChars) {
// insert pressed character
textAddChar = true;
textChanged = true;
}
eventMan->getSciEvent(SCI_EVENT_KEYBOARD); // consume the event
//.........这里部分代码省略.........
示例5: GetFontId
// Draws a text in rect.
void GfxText16::Box(const char *text, uint16 languageSplitter, bool show, const Common::Rect &rect, TextAlignment alignment, GuiResourceId fontId) {
int16 textWidth, maxTextWidth, textHeight, charCount;
int16 offset = 0;
int16 hline = 0;
GuiResourceId previousFontId = GetFontId();
int16 previousPenColor = _ports->_curPort->penClr;
bool doubleByteMode = false;
const char *curTextPos = text;
const char *curTextLine = text;
if (fontId != -1)
SetFont(fontId);
else
fontId = previousFontId;
// Reset reference code rects
_codeRefRects.clear();
_codeRefTempRect.left = _codeRefTempRect.top = -1;
maxTextWidth = 0;
while (*curTextPos) {
// We need to check for Shift-JIS every line
// Police Quest 2 PC-9801 often draws English + Japanese text during the same call
if (g_sci->getLanguage() == Common::JA_JPN) {
if (SwitchToFont900OnSjis(curTextPos, languageSplitter))
doubleByteMode = true;
}
charCount = GetLongest(curTextPos, rect.width(), fontId);
if (charCount == 0)
break;
Width(curTextLine, 0, charCount, fontId, textWidth, textHeight, true);
maxTextWidth = MAX<int16>(maxTextWidth, textWidth);
switch (alignment) {
case SCI_TEXT16_ALIGNMENT_RIGHT:
offset = rect.width() - textWidth;
break;
case SCI_TEXT16_ALIGNMENT_CENTER:
offset = (rect.width() - textWidth) / 2;
break;
case SCI_TEXT16_ALIGNMENT_LEFT:
offset = 0;
break;
default:
warning("Invalid alignment %d used in TextBox()", alignment);
}
_ports->moveTo(rect.left + offset, rect.top + hline);
if (show) {
Show(curTextLine, 0, charCount, fontId, previousPenColor);
} else {
Draw(curTextLine, 0, charCount, fontId, previousPenColor);
}
hline += textHeight;
curTextLine = curTextPos;
}
SetFont(previousFontId);
_ports->penColor(previousPenColor);
if (doubleByteMode) {
// Kanji is written by pc98 rom to screen directly. Because of
// GetLongest() behavior (not cutting off the last char, that causes a
// new line), results in the script thinking that the text would need
// less space. The coordinate adjustment in fontsjis.cpp handles the
// incorrect centering because of that and this code actually shows all
// of the chars - if we don't do this, the scripts will only show most
// of the chars, but the last few pixels won't get shown most of the
// time.
Common::Rect kanjiRect = rect;
_ports->offsetRect(kanjiRect);
kanjiRect.left &= 0xFFC;
kanjiRect.right = kanjiRect.left + maxTextWidth;
kanjiRect.bottom = kanjiRect.top + hline;
kanjiRect.left *= 2; kanjiRect.right *= 2;
kanjiRect.top *= 2; kanjiRect.bottom *= 2;
_screen->copyDisplayRectToScreen(kanjiRect);
}
}
示例6: getFontCharacterRect
void ShaderRenderer::draw2DText(const Common::String &text, const Common::Point &position) {
OpenGLTexture *glFont = static_cast<OpenGLTexture *>(_font);
// The font only has uppercase letters
Common::String textToDraw = text;
textToDraw.toUppercase();
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
if (_prevText != textToDraw || _prevTextPosition != position) {
_prevText = textToDraw;
_prevTextPosition = position;
float x = position.x / _currentViewport.getWidth();
float y = position.y / _currentViewport.getHeight();
float *bufData = new float[16 * textToDraw.size()];
float *cur = bufData;
for (uint i = 0; i < textToDraw.size(); i++) {
Common::Rect textureRect = getFontCharacterRect(textToDraw[i]);
float w = textureRect.width() / _currentViewport.getWidth();
float h = textureRect.height() / _currentViewport.getHeight();
float cw = textureRect.width() / (float)glFont->internalWidth;
float ch = textureRect.height() / (float)glFont->internalHeight;
float cx = textureRect.left / (float)glFont->internalWidth;
float cy = textureRect.top / (float)glFont->internalHeight;
const float charData[] = {
cx, cy + ch, x, y,
cx + cw, cy + ch, x + w, y,
cx + cw, cy, x + w, y + h,
cx, cy, x, y + h,
};
memcpy(cur, charData, 16 * sizeof(float));
cur += 16;
x += (textureRect.width() - 3) / _currentViewport.getWidth();
}
glBindBuffer(GL_ARRAY_BUFFER, _textVBO);
glBufferSubData(GL_ARRAY_BUFFER, 0, textToDraw.size() * 16 * sizeof(float), bufData);
delete[] bufData;
}
_textShader->use();
glBindTexture(GL_TEXTURE_2D, glFont->id);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _quadEBO);
glDrawElements(GL_TRIANGLES, 6 * textToDraw.size(), GL_UNSIGNED_SHORT, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
}
示例7: 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;
}
}
// now drawing the text
_text16->Size(rect, text, -1, width);
rect.moveTo(_ports->getPort()->curLeft, _ports->getPort()->curTop);
// Note: This code has been found in SCI1 middle and newer games. It was
// previously only for SCI1 late and newer, but the LSL1 interpreter contains
//.........这里部分代码省略.........
示例8: drawAllScores
void DeathMenu::drawAllScores() {
Surface numbers;
numbers.getImageFromPICTFile("Images/Death Screens/Numbers.pict");
Common::Rect scoreBounds;
GameScoreType caldoriaTotal = 0;
switch (_deathReason) {
case kDeathCardBomb:
case kDeathShotBySinclair:
case kDeathSinclairShotDelegate:
case kDeathNuclearExplosion:
case kDeathGassedInNorad:
case kDeathWokeUpNorad:
case kDeathArrestedInNorad:
case kDeathSubDestroyed:
case kDeathRobotThroughNoradDoor:
case kDeathRobotSubControlRoom:
case kDeathWrongShuttleLock:
case kDeathArrestedInMars:
case kDeathRunOverByPod:
case kDeathDidntGetOutOfWay:
case kDeathReactorBurn:
case kDeathDidntFindMarsBomb:
case kDeathDidntDisarmMarsBomb:
case kDeathNoMaskInMaze:
case kDeathNoAirInMaze:
case kDeathGroundByMazebot:
case kDeathMissedOreBucket:
case kDeathDidntLeaveBucket:
case kDeathRanIntoCanyonWall:
case kDeathRanIntoSpaceJunk:
case kDeathDidntStopPoison:
case kDeathArrestedInWSC:
case kDeathHitByPlasma:
case kDeathShotOnCatwalk:
case kPlayerWonGame:
caldoriaTotal += kMaxCaldoriaTSAScoreAfter;
scoreBounds = Common::Rect(kDeathScreenScoreLeft, kDeathScreenScoreTop - kDeathScreenScoreSkipVert * 5,
kDeathScreenScoreLeft + kDeathScreenScoreWidth, kDeathScreenScoreTop - kDeathScreenScoreSkipVert * 5 + kDeathScreenScoreHeight);
drawScore(GameState.getGandhiScore(), kMaxGandhiScore, scoreBounds, &numbers);
scoreBounds.translate(0, kDeathScreenScoreSkipVert);
drawScore(GameState.getWSCScore(), kMaxWSCScore, scoreBounds, &numbers);
scoreBounds.translate(0, kDeathScreenScoreSkipVert);
drawScore(GameState.getNoradScore(), kMaxNoradScore, scoreBounds, &numbers);
scoreBounds.translate(0, kDeathScreenScoreSkipVert);
drawScore(GameState.getMarsScore(), kMaxMarsScore, scoreBounds, &numbers);
// fall through
case kDeathFallOffCliff:
case kDeathEatenByDinosaur:
case kDeathStranded:
case kDeathShotByTSARobots:
scoreBounds = Common::Rect(kDeathScreenScoreLeft, kDeathScreenScoreTop - kDeathScreenScoreSkipVert,
kDeathScreenScoreLeft + kDeathScreenScoreWidth, kDeathScreenScoreTop - kDeathScreenScoreSkipVert + kDeathScreenScoreHeight);
drawScore(GameState.getPrehistoricScore(), kMaxPrehistoricScore, scoreBounds, &numbers);
// fall through
case kDeathUncreatedInCaldoria:
case kDeathUncreatedInTSA:
scoreBounds = Common::Rect(kDeathScreenScoreLeft, kDeathScreenScoreTop, kDeathScreenScoreLeft + kDeathScreenScoreWidth,
kDeathScreenScoreTop + kDeathScreenScoreHeight);
caldoriaTotal += kMaxCaldoriaTSAScoreBefore;
drawScore(GameState.getCaldoriaTSAScore(), caldoriaTotal, scoreBounds, &numbers);
scoreBounds = Common::Rect(kDeathScreenScoreLeft, kDeathScreenScoreTop - kDeathScreenScoreSkipVert * 6,
kDeathScreenScoreLeft + kDeathScreenScoreWidth, kDeathScreenScoreTop - kDeathScreenScoreSkipVert * 6 + kDeathScreenScoreHeight);
drawScore(GameState.getTotalScore(), kMaxTotalScore, scoreBounds, &numbers);
break;
}
}
示例9: Window
Window *GfxPorts::addWindow(const Common::Rect &dims, const Common::Rect *restoreRect, const char *title, uint16 style, int16 priority, bool draw) {
// Find an unused window/port id
uint id = PORTS_FIRSTWINDOWID;
while (id < _windowsById.size() && _windowsById[id]) {
if (_windowsById[id]->counterTillFree) {
// port that is already disposed, but not freed yet
freeWindow((Window *)_windowsById[id]);
_freeCounter--;
break; // reuse the handle
// we do this especially for sq4cd. it creates and disposes the
// inventory window all the time, but reuses old handles as well
// this worked somewhat under the original interpreter, because
// it put the new window where the old was.
}
++id;
}
if (id == _windowsById.size())
_windowsById.push_back(0);
assert(0 < id && id < 0xFFFF);
Window *pwnd = new Window(id);
Common::Rect r;
if (!pwnd) {
error("Can't open window");
return 0;
}
_windowsById[id] = pwnd;
// KQ1sci, KQ4, iceman, QfG2 always add windows to the back of the list.
// KQ5CD checks style.
// Hoyle3-demo also always adds to the back (#3036763).
bool forceToBack = (getSciVersion() <= SCI_VERSION_1_EGA_ONLY) ||
(g_sci->getGameId() == GID_HOYLE3 && g_sci->isDemo());
if (!forceToBack && (style & SCI_WINDOWMGR_STYLE_TOPMOST))
_windowList.push_front(pwnd);
else
_windowList.push_back(pwnd);
openPort(pwnd);
r = dims;
// This looks fishy, but it's exactly what Sierra did. They removed last
// bit of the left dimension in their interpreter. It seems Sierra did it
// for EGA byte alignment (EGA uses 1 byte for 2 pixels) and left it in
// their interpreter even in the newer VGA games.
r.left = r.left & 0xFFFE;
if (r.width() > _screen->getWidth()) {
// We get invalid dimensions at least at the end of sq3 (script bug!).
// Same happens very often in lsl5, sierra sci didnt fix it but it looked awful.
// Also happens frequently in the demo of GK1.
warning("Fixing too large window, left: %d, right: %d", dims.left, dims.right);
r.left = 0;
r.right = _screen->getWidth() - 1;
if ((style != _styleUser) && !(style & SCI_WINDOWMGR_STYLE_NOFRAME))
r.right--;
}
pwnd->rect = r;
if (restoreRect)
pwnd->restoreRect = *restoreRect;
pwnd->wndStyle = style;
pwnd->hSaved1 = pwnd->hSaved2 = NULL_REG;
pwnd->bDrawn = false;
if ((style & SCI_WINDOWMGR_STYLE_TRANSPARENT) == 0)
pwnd->saveScreenMask = (priority == -1 ? GFX_SCREEN_MASK_VISUAL : GFX_SCREEN_MASK_VISUAL | GFX_SCREEN_MASK_PRIORITY);
if (title && (style & SCI_WINDOWMGR_STYLE_TITLE)) {
pwnd->title = title;
}
r = pwnd->rect;
if ((style != _styleUser) && !(style & SCI_WINDOWMGR_STYLE_NOFRAME)) {
r.grow(1);
if (style & SCI_WINDOWMGR_STYLE_TITLE) {
r.top -= 10;
r.bottom++;
}
}
pwnd->dims = r;
// Clip window, if needed
Common::Rect wmprect = _wmgrPort->rect;
// Handle a special case for Dr. Brain 1 Mac. When hovering the mouse cursor
// over the status line on top, the game scripts try to draw the game's icon
// bar above the current port, by specifying a negative window top, so that
// the end result will be drawn 10 pixels above the current port. This is a
// hack by Sierra, and is only limited to user style windows. Normally, we
// should not clip, same as what Sierra does. However, this will result in
// having invalid rectangles with negative coordinates. For this reason, we
// adjust the containing rectangle instead.
if (pwnd->dims.top < 0 && g_sci->getPlatform() == Common::kPlatformMacintosh &&
(style & SCI_WINDOWMGR_STYLE_USER) && _wmgrPort->top + pwnd->dims.top >= 0) {
// Offset the final rect top by the requested pixels
wmprect.top += pwnd->dims.top;
}
//.........这里部分代码省略.........
示例10: drawWindow
void GfxPorts::drawWindow(Window *pWnd) {
if (pWnd->bDrawn)
return;
int16 wndStyle = pWnd->wndStyle;
pWnd->bDrawn = true;
Port *oldport = setPort(_wmgrPort);
penColor(0);
if ((wndStyle & SCI_WINDOWMGR_STYLE_TRANSPARENT) == 0) {
pWnd->hSaved1 = _paint16->bitsSave(pWnd->restoreRect, GFX_SCREEN_MASK_VISUAL);
if (pWnd->saveScreenMask & GFX_SCREEN_MASK_PRIORITY) {
pWnd->hSaved2 = _paint16->bitsSave(pWnd->restoreRect, GFX_SCREEN_MASK_PRIORITY);
if ((wndStyle & SCI_WINDOWMGR_STYLE_USER) == 0)
_paint16->fillRect(pWnd->restoreRect, GFX_SCREEN_MASK_PRIORITY, 0, 15);
}
}
// drawing frame,shadow and title
if ((getSciVersion() >= SCI_VERSION_1_LATE) ? !(wndStyle & _styleUser) : wndStyle != _styleUser) {
Common::Rect r = pWnd->dims;
if (!(wndStyle & SCI_WINDOWMGR_STYLE_NOFRAME)) {
r.top++;
r.left++;
_paint16->frameRect(r);// draw shadow
r.translate(-1, -1);
_paint16->frameRect(r);// draw actual window frame
if (wndStyle & SCI_WINDOWMGR_STYLE_TITLE) {
if (getSciVersion() <= SCI_VERSION_0_LATE) {
// draw a black line between titlebar and actual window content for SCI0
r.bottom = r.top + 10;
_paint16->frameRect(r);
}
r.grow(-1);
if (getSciVersion() <= SCI_VERSION_0_LATE)
_paint16->fillRect(r, GFX_SCREEN_MASK_VISUAL, 8); // grey titlebar for SCI0
else
_paint16->fillRect(r, GFX_SCREEN_MASK_VISUAL, 0); // black titlebar for SCI01+
if (!pWnd->title.empty()) {
int16 oldcolor = getPort()->penClr;
penColor(_screen->getColorWhite());
_text16->Box(pWnd->title.c_str(), true, r, SCI_TEXT16_ALIGNMENT_CENTER, 0);
penColor(oldcolor);
}
r.grow(+1);
r.bottom = pWnd->dims.bottom - 1;
r.top += 9;
}
r.grow(-1);
}
if (!(wndStyle & SCI_WINDOWMGR_STYLE_TRANSPARENT))
_paint16->fillRect(r, GFX_SCREEN_MASK_VISUAL, pWnd->backClr);
_paint16->bitsShow(pWnd->dims);
}
setPort(oldport);
}
示例11: 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 |
//.........这里部分代码省略.........
示例12: readSelector
reg_t GfxText32::createTextBitmap(reg_t textObject, uint16 maxWidth, uint16 maxHeight) {
reg_t stringObject = readSelector(_segMan, textObject, SELECTOR(text));
// The object in the text selector of the item can be either a raw string
// or a Str object. In the latter case, we need to access the object's data
// selector to get the raw string.
if (_segMan->isHeapObject(stringObject))
stringObject = readSelector(_segMan, stringObject, SELECTOR(data));
Common::String text = _segMan->getString(stringObject);
// HACK: The character offsets of the up and down arrow buttons are off by one
// in GK1, for some unknown reason. Fix them here.
if (text.size() == 1 && (text[0] == 29 || text[0] == 30)) {
text.setChar(text[0] + 1, 0);
}
GuiResourceId fontId = readSelectorValue(_segMan, textObject, SELECTOR(font));
GfxFont *font = _cache->getFont(fontId);
bool dimmed = readSelectorValue(_segMan, textObject, SELECTOR(dimmed));
int16 alignment = readSelectorValue(_segMan, textObject, SELECTOR(mode));
uint16 foreColor = readSelectorValue(_segMan, textObject, SELECTOR(fore));
uint16 backColor = readSelectorValue(_segMan, textObject, SELECTOR(back));
Common::Rect nsRect = g_sci->_gfxCompare->getNSRect(textObject);
uint16 width = nsRect.width() + 1;
uint16 height = nsRect.height() + 1;
// Limit rectangle dimensions, if requested
if (maxWidth > 0)
width = maxWidth;
if (maxHeight > 0)
height = maxHeight;
// Upscale the coordinates/width if the fonts are already upscaled
if (_screen->fontIsUpscaled()) {
width = width * _screen->getDisplayWidth() / _screen->getWidth();
height = height * _screen->getDisplayHeight() / _screen->getHeight();
}
int entrySize = width * height + BITMAP_HEADER_SIZE;
reg_t memoryId = _segMan->allocateHunkEntry("TextBitmap()", entrySize);
writeSelector(_segMan, textObject, SELECTOR(bitmap), memoryId);
byte *memoryPtr = _segMan->getHunkPointer(memoryId);
memset(memoryPtr, backColor, entrySize);
byte *bitmap = memoryPtr + BITMAP_HEADER_SIZE;
// Save totalWidth, totalHeight
WRITE_LE_UINT16(memoryPtr, width);
WRITE_LE_UINT16(memoryPtr + 2, height);
int16 charCount = 0;
uint16 curX = 0, curY = 0;
const char *txt = text.c_str();
int16 textWidth, textHeight, totalHeight = 0, offsetX = 0, offsetY = 0;
uint16 start = 0;
// Calculate total text height
while (*txt) {
charCount = GetLongest(txt, width, font);
if (charCount == 0)
break;
Width(txt, 0, (int16)strlen(txt), fontId, textWidth, textHeight, true);
totalHeight += textHeight;
txt += charCount;
while (*txt == ' ')
txt++; // skip over breaking spaces
}
txt = text.c_str();
// Draw text in buffer
while (*txt) {
charCount = GetLongest(txt, width, font);
if (charCount == 0)
break;
Width(txt, start, charCount, fontId, textWidth, textHeight, true);
switch (alignment) {
case SCI_TEXT32_ALIGNMENT_RIGHT:
offsetX = width - textWidth;
break;
case SCI_TEXT32_ALIGNMENT_CENTER:
// Center text both horizontally and vertically
offsetX = (width - textWidth) / 2;
offsetY = (height - totalHeight) / 2;
break;
case SCI_TEXT32_ALIGNMENT_LEFT:
offsetX = 0;
break;
default:
warning("Invalid alignment %d used in TextBox()", alignment);
}
for (int i = 0; i < charCount; i++) {
unsigned char curChar = txt[i];
font->drawToBuffer(curChar, curY + offsetY, curX + offsetX, foreColor, dimmed, bitmap, width, height);
curX += font->getCharWidth(curChar);
}
//.........这里部分代码省略.........
示例13: prepareBackground
void RenderManager::prepareBackground() {
_backgroundDirtyRect.clip(_backgroundWidth, _backgroundHeight);
RenderTable::RenderState state = _renderTable.getRenderState();
if (state == RenderTable::PANORAMA) {
// Calculate the visible portion of the background
Common::Rect viewPort(_workingWidth, _workingHeight);
viewPort.translate(-(_screenCenterX - _backgroundOffset), 0);
Common::Rect drawRect = _backgroundDirtyRect;
drawRect.clip(viewPort);
// Render the visible portion
if (!drawRect.isEmpty()) {
blitSurfaceToSurface(_currentBackgroundImage, drawRect, _backgroundSurface, _screenCenterX - _backgroundOffset + drawRect.left, drawRect.top);
}
// Mark the dirty portion of the surface
_backgroundSurfaceDirtyRect = _backgroundDirtyRect;
_backgroundSurfaceDirtyRect.translate(_screenCenterX - _backgroundOffset, 0);
// Panorama mode allows the user to spin in circles. Therefore, we need to render
// the portion of the image that wrapped to the other side of the screen
if (_backgroundOffset < _screenCenterX) {
viewPort.moveTo(-(_screenCenterX - (_backgroundOffset + _backgroundWidth)), 0);
drawRect = _backgroundDirtyRect;
drawRect.clip(viewPort);
if (!drawRect.isEmpty())
blitSurfaceToSurface(_currentBackgroundImage, drawRect, _backgroundSurface, _screenCenterX - (_backgroundOffset + _backgroundWidth) + drawRect.left, drawRect.top);
Common::Rect tmp = _backgroundDirtyRect;
tmp.translate(_screenCenterX - (_backgroundOffset + _backgroundWidth), 0);
if (!tmp.isEmpty())
_backgroundSurfaceDirtyRect.extend(tmp);
} else if (_backgroundWidth - _backgroundOffset < _screenCenterX) {
viewPort.moveTo(-(_screenCenterX + _backgroundWidth - _backgroundOffset), 0);
drawRect = _backgroundDirtyRect;
drawRect.clip(viewPort);
if (!drawRect.isEmpty())
blitSurfaceToSurface(_currentBackgroundImage, drawRect, _backgroundSurface, _screenCenterX + _backgroundWidth - _backgroundOffset + drawRect.left, drawRect.top);
Common::Rect tmp = _backgroundDirtyRect;
tmp.translate(_screenCenterX + _backgroundWidth - _backgroundOffset, 0);
if (!tmp.isEmpty())
_backgroundSurfaceDirtyRect.extend(tmp);
}
} else if (state == RenderTable::TILT) {
// Tilt doesn't allow wrapping, so we just do a simple clip
Common::Rect viewPort(_workingWidth, _workingHeight);
viewPort.translate(0, -(_screenCenterY - _backgroundOffset));
Common::Rect drawRect = _backgroundDirtyRect;
drawRect.clip(viewPort);
if (!drawRect.isEmpty())
blitSurfaceToSurface(_currentBackgroundImage, drawRect, _backgroundSurface, drawRect.left, _screenCenterY - _backgroundOffset + drawRect.top);
// Mark the dirty portion of the surface
_backgroundSurfaceDirtyRect = _backgroundDirtyRect;
_backgroundSurfaceDirtyRect.translate(0, _screenCenterY - _backgroundOffset);
} else {
if (!_backgroundDirtyRect.isEmpty())
blitSurfaceToSurface(_currentBackgroundImage, _backgroundDirtyRect, _backgroundSurface, _backgroundDirtyRect.left, _backgroundDirtyRect.top);
_backgroundSurfaceDirtyRect = _backgroundDirtyRect;
}
// Clear the dirty rect since everything is clean now
_backgroundDirtyRect = Common::Rect();
_backgroundSurfaceDirtyRect.clip(_workingWidth, _workingHeight);
}
示例14: copyDisplayRectToScreen
/**
* This copies a rect to screen w/o scaling adjustment and is only meant to be
* used on hires graphics used in upscaled hires mode.
*/
void GfxScreen::copyDisplayRectToScreen(const Common::Rect &rect) {
if (!_upscaledHires)
error("copyDisplayRectToScreen: not in upscaled hires mode");
g_system->copyRectToScreen(_activeScreen + rect.top * _displayWidth + rect.left, _displayWidth, rect.left, rect.top, rect.width(), rect.height());
}
示例15: setupCameraPerspective
void ShaderRenderer::setupCameraPerspective(float pitch, float heading, float fov) {
Renderer::setupCameraPerspective(pitch, heading, fov);
Common::Rect frame = frameViewport();
glViewport(frame.left, frame.top, frame.width(), frame.height());
}