From 4852eb533bbf331f75e6d1171bfec9e202917db9 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Fri, 20 Oct 2023 03:15:55 +0200 Subject: [PATCH] update texcoords of quads which have AUTO_VIRTUAL* set properly move auto size vars & handling to PauseQuad, since not every quad needs this. --- Aquaria/Avatar.h | 3 +- Aquaria/DSQ.cpp | 90 ++++++++++++++++------------------------- Aquaria/DSQ.h | 10 ++--- Aquaria/Game.cpp | 15 ++++--- Aquaria/Game.h | 7 ++-- Aquaria/InGameMenu.cpp | 22 +++++----- Aquaria/ModSelector.cpp | 4 +- Aquaria/ModSelector.h | 6 +-- BBGE/Quad.cpp | 35 ++++++++++------ BBGE/Quad.h | 5 +-- 10 files changed, 98 insertions(+), 99 deletions(-) diff --git a/Aquaria/Avatar.h b/Aquaria/Avatar.h index 36d4f2a..24d8254 100644 --- a/Aquaria/Avatar.h +++ b/Aquaria/Avatar.h @@ -419,7 +419,8 @@ protected: void onEnterState(int action) OVERRIDE; void onExitState(int action) OVERRIDE; std::vectortargetQuads; - Quad *blinder, *fader, *tripper; + PauseQuad *blinder, *tripper; + Quad *fader; void applyBlindEffects(); void removeBlindEffects(); diff --git a/Aquaria/DSQ.cpp b/Aquaria/DSQ.cpp index ed24966..4318825 100644 --- a/Aquaria/DSQ.cpp +++ b/Aquaria/DSQ.cpp @@ -861,7 +861,8 @@ void DSQ::init() precacher.setBaseDir(this->getBaseTexturePath()); precacher.precacheTex("loading/*.png"); - Quad *loadbg = new Quad; + PauseQuad *loadbg = new PauseQuad; + loadbg->pauseLevel = 99; loadbg->position = Vector(400,300); loadbg->color = Vector(0.06f, 0.06f, 0.08f); loadbg->followCamera = 1; @@ -1012,7 +1013,8 @@ void DSQ::init() addRenderObject(versionLabel, LR_REGISTER_TEXT); - subbox = new Quad(); + subbox = new PauseQuad(); + subbox->pauseLevel = 99; subbox->position = Vector(400,580); subbox->alpha = 0; subbox->alphaMod = 0.7f; @@ -1051,7 +1053,8 @@ void DSQ::init() achievement_text->setAlign(ALIGN_LEFT); addRenderObject(achievement_text, LR_SUBTITLES); - cutscene_bg = new Quad(); + cutscene_bg = new PauseQuad(); + cutscene_bg->pauseLevel = 99; cutscene_bg->autoWidth = AUTO_VIRTUALWIDTH; cutscene_bg->color = 0; cutscene_bg->alphaMod = 0.75; @@ -1108,8 +1111,9 @@ void DSQ::init() debugLog("6"); - overlay = new Quad; + overlay = new PauseQuad; { + overlay->pauseLevel = 99; overlay->position = Vector(400,300,3); overlay->color = 0; overlay->autoWidth = AUTO_VIRTUALWIDTH; @@ -1119,8 +1123,9 @@ void DSQ::init() } addRenderObject(overlay, LR_OVERLAY); - overlay2 = new Quad; + overlay2 = new PauseQuad; { + overlay2->pauseLevel = 99; overlay2->position = Vector(400,300); overlay2->color = 0; overlay2->autoWidth = AUTO_VIRTUALWIDTH; @@ -1130,8 +1135,9 @@ void DSQ::init() } addRenderObject(overlay2, LR_OVERLAY); - overlay3 = new Quad; + overlay3 = new PauseQuad; { + overlay3->pauseLevel = 99; overlay3->position = Vector(400,300); overlay3->color = 0; overlay3->autoWidth = AUTO_VIRTUALWIDTH; @@ -1141,8 +1147,9 @@ void DSQ::init() } addRenderObject(overlay3, LR_OVERLAY); - overlayRed = new Quad; + overlayRed = new PauseQuad; { + overlayRed->pauseLevel = 99; overlayRed->position = Vector(400,300); overlayRed->color = Vector(1,0,0); overlayRed->alphaMod = 0.5; @@ -1153,8 +1160,9 @@ void DSQ::init() } addRenderObject(overlayRed, LR_OVERLAY); - sceneColorOverlay = new Quad; + sceneColorOverlay = new PauseQuad; { + sceneColorOverlay->pauseLevel = 99; sceneColorOverlay->position = Vector(400,300); sceneColorOverlay->color = Vector(1,1,1); sceneColorOverlay->alpha = 1; @@ -1165,8 +1173,9 @@ void DSQ::init() } addRenderObject(sceneColorOverlay, LR_SCENE_COLOR); - tfader = new Quad; + tfader = new PauseQuad; { + tfader->pauseLevel = 99; tfader->position = Vector(400,300,3); tfader->color = 0; tfader->autoWidth = AUTO_VIRTUALWIDTH; @@ -1176,6 +1185,19 @@ void DSQ::init() } addRenderObject(tfader, LR_TRANSITION); + blackout = new PauseQuad; + { + blackout->pauseLevel = 99; + blackout->color = 0; + blackout->autoWidth = AUTO_VIRTUALWIDTH; + blackout->autoHeight = AUTO_VIRTUALHEIGHT; + blackout->followCamera = 1; + blackout->position = Vector(400,300); + blackout->alphaMod = 0.75f; + blackout->alpha = 0; + } + addRenderObject(blackout, LR_MENU); + screenTransition = new AquariaScreenTransition(); { screenTransition->position = Vector(400,300); @@ -2356,16 +2378,7 @@ void DSQ::doModSelect() void DSQ::createModSelector() { - blackout = new Quad; - blackout->color = 0; - blackout->autoWidth = AUTO_VIRTUALWIDTH; - blackout->autoHeight = AUTO_VIRTUALHEIGHT; - blackout->followCamera = 1; - blackout->position = Vector(400,300); - blackout->alphaMod = 0.75f; - blackout->alpha = 0; blackout->alpha.interpolateTo(1, 0.2f); - addRenderObject(blackout, LR_MENU); modSelectorScr = new ModSelectorScreen(); modSelectorScr->position = Vector(400,300); @@ -2434,13 +2447,7 @@ void DSQ::unloadMods() void DSQ::clearModSelector() { - if (blackout) - { - blackout->setLife(1); - blackout->setDecayRate(2); - blackout->fadeAlphaWithLife = 1; - blackout = 0; - } + blackout->alpha.interpolateTo(0, 0.5f); if(modSelectorScr) { @@ -2481,18 +2488,7 @@ void DSQ::createSaveSlots(SaveSlotMode ssm) float t = 0.3f; - - blackout = new Quad; - blackout->color = 0; - blackout->autoWidth = AUTO_VIRTUALWIDTH; - blackout->autoHeight = AUTO_VIRTUALHEIGHT; - blackout->followCamera = 1; - blackout->position = Vector(400,300); - blackout->alphaMod = 0.75f; - blackout->alpha = 0; blackout->alpha.interpolateTo(1, 0.5f); - addRenderObject(blackout, LR_MENU); - menu[1] = new Quad("gui/save-menu", Vector(400,300)); menu[1]->alpha = 0; @@ -2659,8 +2655,7 @@ void DSQ::hideSaveSlotCrap() { clearMenu(); - if (blackout) - blackout->alpha = 0; + blackout->alpha = 0; if (saveSlotPageCount) saveSlotPageCount->alpha = 0; @@ -2673,23 +2668,8 @@ void DSQ::clearSaveSlots(bool trans) sound->playSfx("menu-close"); } float t = 0.3f; - if (blackout) - { - if (!trans) - { - blackout->setLife(1); - blackout->setDecayRate(10); - if (blackout->alpha.x > 0) - blackout->fadeAlphaWithLife = 1; - } - else - { - blackout->setLife(1); - blackout->setDecayRate(1); - if (blackout->alpha.x > 0) - blackout->fadeAlphaWithLife = 1; - } - } + blackout->alpha.interpolateTo(0, trans ? 1.0f : 0.1f); + if (saveSlotPageCount) { saveSlotPageCount->setLife(1); diff --git a/Aquaria/DSQ.h b/Aquaria/DSQ.h index 21024fb..0c0c85c 100644 --- a/Aquaria/DSQ.h +++ b/Aquaria/DSQ.h @@ -146,8 +146,8 @@ public: void setCursor(CursorType type); Quad *cursor, *cursorGlow, *cursorBlinker; - Quad *overlay, *tfader, *overlay2, *overlay3, *overlayRed; - Quad *sceneColorOverlay; + PauseQuad *overlay, *tfader, *overlay2, *overlay3, *overlayRed; + PauseQuad *sceneColorOverlay; Quad *bar_left, *bar_right, *bar_up, *bar_down; Quad *barFade_left, *barFade_right; @@ -344,7 +344,7 @@ public: Quad *achievement_box; BitmapText *subtext; - Quad *subbox; + PauseQuad *subbox; BmpFont font, smallFont, subsFont, goldFont, smallFontRed; TTFFont fontArialSmall, fontArialBig, fontArialSmallest; @@ -390,7 +390,7 @@ public: protected: - Quad *cutscene_bg; + PauseQuad *cutscene_bg; BitmapText *cutscene_text; BitmapText *cutscene_text2; @@ -424,7 +424,7 @@ protected: void onStopVoice(); Entity **iter; - Quad *blackout; + PauseQuad *blackout; void updatepecue(float dt); std::vector pecue; diff --git a/Aquaria/Game.cpp b/Aquaria/Game.cpp index f60f475..eb2a223 100644 --- a/Aquaria/Game.cpp +++ b/Aquaria/Game.cpp @@ -2546,8 +2546,9 @@ void Game::applyState() dsq->clearEntities(); dsq->tilemgr.clearTiles(); - damageSprite = new Quad; + damageSprite = new PauseQuad; { + damageSprite->pauseLevel = 99; damageSprite->setTexture("damage"); damageSprite->alpha = 0; damageSprite->autoWidth = AUTO_VIRTUALWIDTH; @@ -2560,8 +2561,9 @@ void Game::applyState() Vector mousePos(400,490); - controlHint_bg = new Quad; + controlHint_bg = new PauseQuad; { + controlHint_bg->pauseLevel = 99; controlHint_bg->followCamera = 1; controlHint_bg->position = Vector(400,500); controlHint_bg->color = 0; @@ -3416,7 +3418,8 @@ void Game::toggleHelpScreen(bool on, const std::string &label) data += "\n\n" + stringbank.get(2032) + "\n\n"; dsq->continuity.statsAndAchievements->appendStringData(data); - helpBG = new Quad; + helpBG = new PauseQuad; + helpBG->pauseLevel = 99; //helpBG->color = 0; helpBG->setTexture("brick"); helpBG->setRepeatScale(Vector(2, 2)); @@ -3428,7 +3431,8 @@ void Game::toggleHelpScreen(bool on, const std::string &label) helpBG->followCamera = 1; addRenderObject(helpBG, LR_HELP); - helpBG2 = new Quad; + helpBG2 = new PauseQuad; + helpBG2->pauseLevel = 99; helpBG2->color = 0; helpBG2->alphaMod = 0.5; helpBG2->setWidth(620); @@ -4710,7 +4714,8 @@ void Game::removeState() core->cameraPos = Vector(0,0); sceneColor.stop(); - controlHint_mouseLeft = controlHint_mouseRight = controlHint_mouseMiddle = controlHint_mouseBody = controlHint_bg = controlHint_image = 0; + controlHint_mouseLeft = controlHint_mouseRight = controlHint_mouseMiddle = controlHint_mouseBody = controlHint_image = 0; + controlHint_bg = 0; controlHint_text = 0; miniMapRender = 0; diff --git a/Aquaria/Game.h b/Aquaria/Game.h index 3ca9e7c..38d3c4b 100644 --- a/Aquaria/Game.h +++ b/Aquaria/Game.h @@ -293,7 +293,7 @@ public: void warpToSceneFromNode(Path *p); Vector fromPosition; - Quad *damageSprite; + PauseQuad *damageSprite; void toggleDamageSprite(bool on); @@ -419,7 +419,7 @@ protected: void onHelpUp(); void onHelpDown(); bool helpWasPaused; - Quad *helpBG, *helpBG2; + PauseQuad *helpBG, *helpBG2; AquariaMenuItem *helpUp, *helpDown, *helpCancel; TTFText *helpText; bool inHelpScreen; @@ -445,8 +445,9 @@ protected: void updateCursor(float dt); - Quad *controlHint_mouseLeft, *controlHint_mouseRight, *controlHint_mouseBody, *controlHint_mouseMiddle, *controlHint_bg, *controlHint_image; + Quad *controlHint_mouseLeft, *controlHint_mouseRight, *controlHint_mouseBody, *controlHint_mouseMiddle, *controlHint_image; Quad *controlHint_shine; + PauseQuad *controlHint_bg; bool controlHint_ignoreClear; BitmapText *controlHint_text; diff --git a/Aquaria/InGameMenu.cpp b/Aquaria/InGameMenu.cpp index 5a9957b..795b5f8 100644 --- a/Aquaria/InGameMenu.cpp +++ b/Aquaria/InGameMenu.cpp @@ -1214,16 +1214,18 @@ void InGameMenu::show(bool ignoreInput, bool optionsOnly, MenuPage menuPage) if (optionsOnly) { - menu_blackout = new Quad; - menu_blackout->color = 0; - menu_blackout->autoWidth = AUTO_VIRTUALWIDTH; - menu_blackout->autoHeight = AUTO_VIRTUALHEIGHT; - menu_blackout->followCamera = 1; - menu_blackout->position = Vector(400,300); - menu_blackout->alphaMod = 0.75; - menu_blackout->alpha = 0; - menu_blackout->alpha.interpolateTo(1, 0.5); - game->addRenderObject(menu_blackout, LR_AFTER_EFFECTS); + PauseQuad *q = new PauseQuad; + q->color = 0; + q->pauseLevel = 99; + q->autoWidth = AUTO_VIRTUALWIDTH; + q->autoHeight = AUTO_VIRTUALHEIGHT; + q->followCamera = 1; + q->position = Vector(400,300); + q->alphaMod = 0.75; + q->alpha = 0; + q->alpha.interpolateTo(1, 0.5); + game->addRenderObject(q, LR_AFTER_EFFECTS); + menu_blackout = q; menuBg2->alpha = 0; } diff --git a/Aquaria/ModSelector.cpp b/Aquaria/ModSelector.cpp index aa75d86..1b8a793 100644 --- a/Aquaria/ModSelector.cpp +++ b/Aquaria/ModSelector.cpp @@ -41,13 +41,14 @@ static bool _modname_cmp(const ModIcon *a, const ModIcon *b) } ModSelectorScreen::ModSelectorScreen() - : Quad() + : PauseQuad() , ActionMapper() , dlText(dsq->smallFont) , gotServerList(false) , currentPanel(-1) , subtext(dsq->subsFont) { + pauseLevel = 99; followCamera = 1; shareAlphaWithChildren = false; alpha = 1; @@ -260,6 +261,7 @@ void ModSelectorScreen::init() showPanel(0); + subbox.pauseLevel = 99; subbox.position = Vector(0,260); subbox.alpha = 0; subbox.alphaMod = 0.7f; diff --git a/Aquaria/ModSelector.h b/Aquaria/ModSelector.h index fb9fb0e..baed439 100644 --- a/Aquaria/ModSelector.h +++ b/Aquaria/ModSelector.h @@ -141,7 +141,7 @@ protected: int x, y; }; -class ModSelectorScreen : public Quad, public ActionMapper +class ModSelectorScreen : public PauseQuad, public ActionMapper { public: ModSelectorScreen(); @@ -166,7 +166,7 @@ public: AquariaMenuItem arrowUp, arrowDown; void setSubText(const std::string& s); - + virtual void action(int actionID, int state, int source, InputDevice device) {} protected: @@ -175,7 +175,7 @@ protected: MenuBasicBar rightbar; size_t currentPanel; BitmapText subtext; - Quad subbox; + PauseQuad subbox; float subFadeT; }; diff --git a/BBGE/Quad.cpp b/BBGE/Quad.cpp index 3bae54b..f9665ea 100644 --- a/BBGE/Quad.cpp +++ b/BBGE/Quad.cpp @@ -49,8 +49,6 @@ void Quad::initQuad() borderAlpha = 0.5; repeatToFillScale = Vector(1,1); - autoWidth = autoHeight = 0; - renderBorder = false; renderCenter = true; width = 2; height = 2; @@ -292,16 +290,6 @@ void Quad::onUpdate(float dt) { RenderObject::onUpdate(dt); - if (autoWidth == AUTO_VIRTUALWIDTH) - width = core->getVirtualWidth(); - else if (autoWidth == AUTO_VIRTUALHEIGHT) - width = core->getVirtualHeight(); - - if (autoHeight == AUTO_VIRTUALWIDTH) - height = core->getVirtualWidth(); - else if (autoHeight == AUTO_VIRTUALHEIGHT) - height = core->getVirtualHeight(); - if (grid && alpha.x > 0 && alphaMod > 0) { grid->update(dt); @@ -341,7 +329,7 @@ void Quad::onSetTexture() } } -PauseQuad::PauseQuad() : Quad(), pauseLevel(0), positionSnapTo(0) +PauseQuad::PauseQuad() : Quad(), pauseLevel(0), positionSnapTo(0), autoWidth(0), autoHeight(0) { addType(SCO_PAUSEQUAD); } @@ -352,6 +340,27 @@ PauseQuad::~PauseQuad() void PauseQuad::onUpdate(float dt) { + if(autoWidth || autoHeight) + { + float w = width, h = height; + if (autoWidth == AUTO_VIRTUALWIDTH) + w = core->getVirtualWidth(); + else if (autoWidth == AUTO_VIRTUALHEIGHT) + w = core->getVirtualHeight(); + + if (autoHeight == AUTO_VIRTUALWIDTH) + h = core->getVirtualWidth(); + else if (autoHeight == AUTO_VIRTUALHEIGHT) + h = core->getVirtualHeight(); + + if(w != width || h != height) + { + width = w; + height = h; + updateTexCoords(); + } + } + if (positionSnapTo) this->position = *positionSnapTo; diff --git a/BBGE/Quad.h b/BBGE/Quad.h index 3d6877e..9f076e5 100644 --- a/BBGE/Quad.h +++ b/BBGE/Quad.h @@ -87,7 +87,7 @@ public: TexCoordBox texcoords; // TODO: this should be a bitmask - char autoWidth, autoHeight; + bool renderQuad, renderCenter, renderBorder; float borderAlpha; @@ -119,6 +119,7 @@ public: PauseQuad(); virtual ~PauseQuad(); int pauseLevel; + char autoWidth, autoHeight; void setPositionSnapTo(InterpolatedVector *positionSnapTo); protected: @@ -137,7 +138,5 @@ public: float collideRadius; }; -#define QUAD(x) Quad *x = new Quad; addRenderObject(x); - #endif