TWINE: renamed clip methods

and synced drawHoloObj with original source code
This commit is contained in:
Martin Gerhardy 2023-01-20 17:06:11 +01:00
parent 0aab461f60
commit 6fc57dd947
9 changed files with 52 additions and 54 deletions

View File

@ -288,15 +288,13 @@ void Holomap::drawHolomapText(int32 centerx, int32 top, const char *title) {
_engine->_text->drawText(x, y, title);
}
void Holomap::drawHoloObj(const IVec3 &angle, int32 x, int32 y) {
_engine->_renderer->setAngleCamera(x, y, 0);
const IVec3 &destPos = _engine->_renderer->longWorldRot(0, 0, 1000);
_engine->_renderer->setPosCamera(0, 0, 0);
_engine->_renderer->setBaseRotation(angle);
_engine->_renderer->setCameraRotation(0, 0, distance(zDistanceTrajectory));
_engine->_interface->resetClip();
void Holomap::drawHoloObj(const IVec3 &angle, int32 alpha, int32 beta) {
_engine->_renderer->setAngleCamera(alpha, beta, 0);
const IVec3 &m = _engine->_renderer->worldRotatePoint(IVec3(0, 0, 1000));
_engine->_renderer->setFollowCamera(0, 0, 0, angle.x, angle.y, angle.z, distance(zDistanceTrajectory));
_engine->_interface->unsetClip();
Common::Rect dirtyRect;
_engine->_renderer->renderIsoModel(destPos, x, y, LBAAngles::ANGLE_0, _engine->_resources->_holomapPointModelPtr, dirtyRect);
_engine->_renderer->renderIsoModel(m, alpha, beta, LBAAngles::ANGLE_0, _engine->_resources->_holomapPointModelPtr, dirtyRect);
_engine->copyBlockPhys(dirtyRect);
}
@ -336,7 +334,7 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
}
_engine->exitSceneryView();
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
_engine->_screens->clearScreen();
initHoloDatas();
@ -425,7 +423,7 @@ void Holomap::drawHolomapTrajectory(int32 trajectoryIndex) {
_engine->_screens->clearScreen();
_engine->setPalette(_engine->_screens->_paletteRGBA);
_engine->_gameState->init3DGame();
_engine->_interface->loadClip();
_engine->_interface->restoreClip();
_engine->_text->initSceneTextBank();
_engine->_input->enableKeyMap(mainKeyMapId);
@ -520,7 +518,7 @@ void Holomap::holoMap() {
_engine->_screens->fadeToBlack(_engine->_screens->_paletteRGBA);
_engine->_sound->stopSamples();
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
_engine->_screens->clearScreen();
_engine->_screens->fadeToBlack(_engine->_screens->_paletteRGBA);
@ -618,7 +616,7 @@ void Holomap::holoMap() {
const Common::Rect &rect = _engine->centerOnScreenX(scale(300), 0, scale(330));
// clip reduces the bad effect of https://bugs.scummvm.org/ticket/12074
// but it's not part of the original code
_engine->_interface->saveClip();
_engine->_interface->memoClip();
_engine->_interface->setClip(rect);
_engine->_interface->drawFilledRect(rect, COLOR_BLACK);
_engine->_renderer->setInverseAngleCamera(xRot, yRot, 0);
@ -628,7 +626,7 @@ void Holomap::holoMap() {
_engine->_renderer->setCameraRotation(0, 0, distance(ZOOM_BIG_HOLO));
drawHoloMap(holomapImagePtr, holomapImageSize);
drawListPos(xRot, yRot, 0, true);
_engine->_interface->loadClip();
_engine->_interface->restoreClip();
drawHolomapText(_engine->width() / 2, 25, "HoloMap");
if (automove) {
// draw cursor
@ -656,7 +654,7 @@ void Holomap::holoMap() {
_engine->_scene->_betaLight = betaLightTmp;
_engine->_gameState->init3DGame();
_engine->_interface->loadClip();
_engine->_interface->restoreClip();
_engine->_input->enableKeyMap(mainKeyMapId);
_engine->_text->initSceneTextBank();

View File

@ -196,15 +196,15 @@ bool Interface::setClip(const Common::Rect &rect) {
return true;
}
void Interface::saveClip() {
_savedClip = _clip;
void Interface::memoClip() {
_memoClip = _clip;
}
void Interface::loadClip() {
_clip = _savedClip;
void Interface::restoreClip() {
_clip = _memoClip;
}
void Interface::resetClip() {
void Interface::unsetClip() {
_clip = _engine->rect();
}

View File

@ -36,7 +36,7 @@ class TwinEEngine;
class Interface {
private:
TwinEEngine *_engine;
Common::Rect _savedClip;
Common::Rect _memoClip;
public:
Interface(TwinEEngine *engine);
@ -67,9 +67,9 @@ public:
void drawFilledRect(const Common::Rect &rect, uint8 colorIndex);
bool setClip(const Common::Rect &rect);
void saveClip(); // saveTextWindow
void loadClip(); // loadSavedTextWindow
void resetClip();
void memoClip(); // saveTextWindow
void restoreClip(); // loadSavedTextWindow
void unsetClip();
};
} // namespace TwinE

View File

@ -971,7 +971,7 @@ void Menu::drawKeys(int32 left, int32 top) {
}
void Menu::drawInfoMenu(int16 left, int16 top, int16 width) {
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
const int16 height = 80;
const Common::Rect rect(left, top, left + width, top + height);
drawRectBorders(rect);
@ -1035,8 +1035,8 @@ void Menu::drawBehaviour(int32 left, int32 top, HeroBehaviourType behaviour, int
drawRectBorders(boxRectCopy);
}
_engine->_interface->saveClip();
_engine->_interface->resetClip();
_engine->_interface->memoClip();
_engine->_interface->unsetClip();
if (behaviour == _engine->_actor->_heroBehaviour) {
const int titleOffset = 10;
@ -1067,7 +1067,7 @@ void Menu::drawBehaviour(int32 left, int32 top, HeroBehaviourType behaviour, int
_engine->_renderer->renderBehaviourModel(boxRect, -600, angle, *_behaviourEntity, _moveMenu);
_engine->_interface->loadClip();
_engine->_interface->restoreClip();
}
void Menu::prepareAndDrawBehaviour(int32 left, int32 top, int32 angle, HeroBehaviourType behaviour) {
@ -1217,7 +1217,7 @@ void Menu::drawItem(int32 left, int32 top, int32 item) {
_itemAngle[item] += LBAAngles::ANGLE_2;
_engine->_interface->setClip(rect);
_engine->_renderer->draw3dObject(itemX, itemY, _engine->_resources->_inventoryTable[item], _itemAngle[item], 15000);
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
if (item == InventoryItems::kGasItem) {
_engine->_text->setFontColor(COLOR_WHITE);
const Common::String &inventoryNumGas = Common::String::format("%d", _engine->_gameState->_inventoryNumGas);
@ -1236,7 +1236,7 @@ void Menu::drawInventoryItems(int32 left, int32 top) {
for (int32 item = 0; item < NUM_INVENTORY_ITEMS; item++) {
drawItem(left, top, item);
}
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
}
void Menu::processInventoryMenu() {

View File

@ -339,7 +339,7 @@ void Redraw::processDrawListShadows(const DrawListStruct &drawCmd) {
addRedrawArea(_engine->_interface->_clip);
_engine->_debugScene->drawClip(renderRect);
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
}
void Redraw::processDrawListActors(const DrawListStruct &drawCmd, bool bgRedraw) {
@ -360,7 +360,7 @@ void Redraw::processDrawListActors(const DrawListStruct &drawCmd, bool bgRedraw)
}
if (!_engine->_renderer->affObjetIso(delta.x, delta.y, delta.z, LBAAngles::ANGLE_0, actor->_beta, LBAAngles::ANGLE_0, _engine->_resources->_bodyData[actor->_body], renderRect)) {
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
return;
}
@ -384,7 +384,7 @@ void Redraw::processDrawListActors(const DrawListStruct &drawCmd, bool bgRedraw)
_engine->_debugScene->drawClip(_engine->_interface->_clip);
}
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
}
void Redraw::processDrawListActorSprites(const DrawListStruct &drawCmd, bool bgRedraw) {
@ -444,7 +444,7 @@ void Redraw::processDrawListActorSprites(const DrawListStruct &drawCmd, bool bgR
}
_engine->_debugScene->drawClip(renderRect);
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
}
}
@ -482,7 +482,7 @@ void Redraw::processDrawListExtras(const DrawListStruct &drawCmd) {
// show clipping area
//drawRectBorders(renderRect);
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
}
}
@ -617,7 +617,7 @@ void Redraw::processDrawList(DrawListStruct *drawList, int32 drawListPos, bool b
processDrawListExtras(drawCmd);
}
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
}
}
@ -689,7 +689,7 @@ void Redraw::renderOverlays() {
addRedrawArea(_engine->_interface->_clip);
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
break;
}
case OverlayType::koNumberRange: {
@ -714,7 +714,7 @@ void Redraw::renderOverlays() {
_engine->_text->drawText(renderRect.left, renderRect.top, text);
addRedrawArea(_engine->_interface->_clip);
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
break;
}
case OverlayType::koInventoryItem: {
@ -730,7 +730,7 @@ void Redraw::renderOverlays() {
_engine->_menu->drawRectBorders(rect);
addRedrawArea(rect);
_engine->_gameState->init3DGame();
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
break;
}
case OverlayType::koText: {
@ -755,7 +755,7 @@ void Redraw::renderOverlays() {
_engine->_text->drawText(renderRect.left, renderRect.top, text);
addRedrawArea(_engine->_interface->_clip);
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
break;
}
}
@ -796,7 +796,7 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // AffScene
int32 tmp_projPosX = _projPosScreen.x;
int32 tmp_projPosY = _projPosScreen.y;
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
if (bgRedraw) {
_engine->freezeTime(false);
@ -836,7 +836,7 @@ void Redraw::redrawEngineActions(bool bgRedraw) { // AffScene
renderOverlays();
renderText();
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
// need to be here to fade after drawing all actors in scene
if (_engine->_scene->_needChangeScene == SCENE_CEILING_GRID_FADE_2) {
@ -892,7 +892,7 @@ void Redraw::drawBubble(int32 actorIdx) {
if (_engine->_interface->setClip(renderRect)) {
_engine->_grid->drawSprite(renderRect.left, renderRect.top, spritePtr);
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
}
}

View File

@ -1771,7 +1771,7 @@ void Renderer::renderBehaviourModel(const Common::Rect &rect, int32 y, int32 ang
} else {
affObjetIso(0, y, 0, LBAAngles::ANGLE_0, angle, LBAAngles::ANGLE_0, bodyData, dummy);
}
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
}
void Renderer::draw3dObject(int32 x, int32 y, const BodyData &bodyData, int32 angle, int32 cameraZoom) {

View File

@ -102,7 +102,7 @@ void GameState::initHeroVars() {
void GameState::initEngineVars() {
debug(2, "Init engine variables");
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
_engine->_scene->_alphaLight = LBAAngles::ANGLE_315;
_engine->_scene->_betaLight = LBAAngles::ANGLE_334;
@ -349,7 +349,7 @@ void GameState::doFoundObj(InventoryItems item) {
_engine->_music->stopMusic();
_engine->_text->initDial(TextBankId::Inventory_Intro_and_Holomap);
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
_engine->_text->initItemFoundText(item);
_engine->_text->initDialogueBox();
@ -372,7 +372,7 @@ void GameState::doFoundObj(InventoryItems item) {
int16 itemAngle = LBAAngles::ANGLE_0;
for (;;) {
FrameMarker frame(_engine, 66);
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
_engine->_redraw->_currNumOfRedrawBox = 0;
_engine->_redraw->blitBackgroundAreas();
_engine->_interface->drawTransparentBox(boxRect, 4);
@ -385,7 +385,7 @@ void GameState::doFoundObj(InventoryItems item) {
_engine->_menu->drawRectBorders(boxRect);
_engine->_redraw->addRedrawArea(boxRect);
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
init3DGame();
if (_engine->_animations->setModelAnimation(currentAnimState, currentAnimData, bodyData, &_engine->_scene->_sceneHero->_animTimerData)) {
@ -401,7 +401,7 @@ void GameState::doFoundObj(InventoryItems item) {
_engine->_redraw->addRedrawArea(modelRect);
if (textState == ProgressiveTextState::ContinueRunning) {
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
textState = _engine->_text->updateProgressiveText();
} else {
_engine->_text->fadeInRemainingChars();
@ -443,7 +443,7 @@ void GameState::doFoundObj(InventoryItems item) {
_engine->_text->stopVox(_engine->_text->_currDialTextEntry);
_engine->_scene->_sceneHero->_animTimerData = tmpAnimTimer;
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
}
void GameState::processGameChoices(TextId choiceIdx) {
@ -528,7 +528,7 @@ void GameState::processGameoverAnimation() {
_engine->delaySkip(2000);
_engine->_interface->resetClip();
_engine->_interface->unsetClip();
_engine->restoreFrontBuffer();
init3DGame();

View File

@ -659,11 +659,11 @@ bool Text::displayText(TextId index, bool showText, bool playVox, bool loop) {
bool Text::drawTextProgressive(TextId index, bool playVox, bool loop) {
_engine->exitSceneryView();
_engine->_interface->saveClip();
_engine->_interface->resetClip();
_engine->_interface->memoClip();
_engine->_interface->unsetClip();
_engine->saveFrontBuffer();
const bool aborted = displayText(index, _engine->_cfgfile.FlagDisplayText, playVox, loop);
_engine->_interface->loadClip();
_engine->_interface->restoreClip();
return aborted;
}

View File

@ -597,7 +597,7 @@ void TwinEEngine::initAll() {
_scene->_sceneHero = _scene->getActor(OWN_ACTOR_SCENE_INDEX);
// Set clip to fullscreen by default, allows main menu to render properly after load
_interface->resetClip();
_interface->unsetClip();
// getting configuration file
initConfigurations();