From 21260491e4f21ad8974d8a05fd11134ead2ea69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= Date: Wed, 28 Sep 2016 15:59:50 +0300 Subject: [PATCH] UI|Refactor|Client: Removed GameUIWidget; view composited by ViewCompositor --- .../apps/client/include/ui/viewcompositor.h | 2 - .../client/include/ui/widgets/gameuiwidget.h | 45 ------ doomsday/apps/client/src/render/viewports.cpp | 4 +- doomsday/apps/client/src/ui/clientwindow.cpp | 16 +- .../apps/client/src/ui/viewcompositor.cpp | 54 ++++++- .../client/src/ui/widgets/gameuiwidget.cpp | 145 ------------------ 6 files changed, 58 insertions(+), 208 deletions(-) delete mode 100644 doomsday/apps/client/include/ui/widgets/gameuiwidget.h delete mode 100644 doomsday/apps/client/src/ui/widgets/gameuiwidget.cpp diff --git a/doomsday/apps/client/include/ui/viewcompositor.h b/doomsday/apps/client/include/ui/viewcompositor.h index 35528662f6..76b1dbb438 100644 --- a/doomsday/apps/client/include/ui/viewcompositor.h +++ b/doomsday/apps/client/include/ui/viewcompositor.h @@ -75,8 +75,6 @@ class ViewCompositor * * Note that the existing contents of the game view framebuffer are used as-is; the * game view needs to be redrawn separately beforehand, if needed. - * - * @param rect Rectangle in which to draw the layers. */ void drawCompositedLayers(); diff --git a/doomsday/apps/client/include/ui/widgets/gameuiwidget.h b/doomsday/apps/client/include/ui/widgets/gameuiwidget.h deleted file mode 100644 index b783375c7c..0000000000 --- a/doomsday/apps/client/include/ui/widgets/gameuiwidget.h +++ /dev/null @@ -1,45 +0,0 @@ -/** @file gameuiwidget.h Widget for legacy game UI elements. - * - * @authors Copyright © 2013 Jaakko Keränen - * @authors Copyright © 2014 Daniel Swanson - * - * @par License - * GPL: http://www.gnu.org/licenses/gpl.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. This program is distributed in the hope that it - * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. You should have received a copy of the GNU - * General Public License along with this program; if not, see: - * http://www.gnu.org/licenses - */ - -#ifndef DENG_CLIENT_GAMEUIWIDGET_H -#define DENG_CLIENT_GAMEUIWIDGET_H - -#include - -/** - * Widget that encapsulates game-side UI elements. - */ -class GameUIWidget : public de::GuiWidget -{ -public: - GameUIWidget(); - - void drawContent(); - - /** - * Determines if InFine animations will be drawn stretched to cover - * the entire view. - */ - static bool finaleStretch(); - -private: - DENG2_PRIVATE(d) -}; - -#endif // DENG_CLIENT_GAMEUIWIDGET_H diff --git a/doomsday/apps/client/src/render/viewports.cpp b/doomsday/apps/client/src/render/viewports.cpp index b21fe66691..e5ea46a136 100644 --- a/doomsday/apps/client/src/render/viewports.cpp +++ b/doomsday/apps/client/src/render/viewports.cpp @@ -63,7 +63,7 @@ #include "ui/ui_main.h" #include "ui/clientwindow.h" -#include "ui/widgets/gameuiwidget.h" +//#include "ui/widgets/gameuiwidget.h" using namespace de; using namespace world; @@ -1035,6 +1035,7 @@ static void restoreDefaultGLState() DGL_Enable(DGL_POINT_SMOOTH); } +#if 0 static void clearViewPorts() { GLbitfield bits = GL_DEPTH_BUFFER_BIT; @@ -1080,6 +1081,7 @@ static void clearViewPorts() // This is all the clearing we'll do. LIBGUI_GL.glClear(bits); } +#endif void R_RenderViewPort(int playerNum) { diff --git a/doomsday/apps/client/src/ui/clientwindow.cpp b/doomsday/apps/client/src/ui/clientwindow.cpp index 7c40da68f6..e02b1e0fe3 100644 --- a/doomsday/apps/client/src/ui/clientwindow.cpp +++ b/doomsday/apps/client/src/ui/clientwindow.cpp @@ -50,7 +50,6 @@ #include "gl/sys_opengl.h" #include "gl/gl_main.h" #include "ui/widgets/gamewidget.h" -#include "ui/widgets/gameuiwidget.h" #include "ui/widgets/busywidget.h" #include "ui/widgets/taskbarwidget.h" #include "ui/widgets/consolewidget.h" @@ -87,7 +86,6 @@ DENG2_PIMPL(ClientWindow) /// Root of the nomal UI widgets of this window. ClientRootWidget root; GameWidget *game = nullptr; - GameUIWidget *gameUI = nullptr; LabelWidget *nowPlaying = nullptr; TaskBarWidget *taskBar = nullptr; LabelWidget *taskBarBlur = nullptr; ///< Blur everything below the task bar. @@ -184,10 +182,10 @@ DENG2_PIMPL(ClientWindow) game->disable(); root.add(game); - gameUI = new GameUIWidget; + /*gameUI = new GameUIWidget; gameUI->rule().setRect(game->rule()); gameUI->disable(); - root.add(gameUI); + root.add(gameUI);*/ auto *miniGameControls = new LabelWidget; { @@ -415,8 +413,8 @@ DENG2_PIMPL(ClientWindow) case Busy: game->hide(); game->disable(); - gameUI->hide(); - gameUI->disable(); + //gameUI->hide(); + //gameUI->disable(); taskBar->disable(); busy->show(); @@ -429,8 +427,8 @@ DENG2_PIMPL(ClientWindow) game->show(); game->enable(); - gameUI->show(); - gameUI->enable(); + //gameUI->show(); + //gameUI->enable(); taskBar->enable(); break; } @@ -456,7 +454,7 @@ DENG2_PIMPL(ClientWindow) // Now that the window is ready for drawing we can enable the GameWidget. game->enable(); - gameUI->enable(); + //gameUI->enable(); // Configure a viewport immediately. GLState::current().setViewport(Rectangleui(0, 0, self.pixelWidth(), self.pixelHeight())).apply(); diff --git a/doomsday/apps/client/src/ui/viewcompositor.cpp b/doomsday/apps/client/src/ui/viewcompositor.cpp index 4101b74eeb..85ad821fe1 100644 --- a/doomsday/apps/client/src/ui/viewcompositor.cpp +++ b/doomsday/apps/client/src/ui/viewcompositor.cpp @@ -18,10 +18,17 @@ #include "ui/viewcompositor.h" #include "ui/clientwindow.h" +#include "ui/infine/finaleinterpreter.h" +#include "ui/infine/finalepagewidget.h" +#include "ui/editors/edit_bias.h" +#include "render/rend_main.h" #include "render/viewports.h" #include "world/p_players.h" +#include "world/map.h" +#include "api_console.h" #include "api_render.h" #include "clientapp.h" +#include "dd_main.h" #include #include @@ -113,6 +120,15 @@ DENG2_PIMPL(ViewCompositor) viewFramebuf.glDeinit(); frameDrawable.clear(); } + + static void setupProjectionForFinale(dgl_borderedprojectionstate_t *bp) + { + GL_ConfigureBorderedProjection(bp, BPF_OVERDRAW_CLIP | + (!App_World().hasMap()? BPF_OVERDRAW_MASK : 0), + SCREENWIDTH, SCREENHEIGHT, + DENG_GAMEVIEW_WIDTH, DENG_GAMEVIEW_HEIGHT, + scalemode_t(Con_GetByte("rend-finale-stretch"))); + } }; ViewCompositor::ViewCompositor() @@ -196,7 +212,7 @@ void ViewCompositor::drawCompositedLayers() // Game HUD. { - /// @todo HUD rendering probably doesn't need the vdWindow. + /// @todo HUD rendering probably doesn't need the vdWindow (maybe for the automap?). auto const *vp = R_CurrentViewPort(); RectRaw vpGeometry(vp->geometry.topLeft.x, vp->geometry.topLeft.y, @@ -220,27 +236,53 @@ void ViewCompositor::drawCompositedLayers() } } + DGL_MatrixMode(DGL_PROJECTION); + DGL_PopMatrix(); + // Finale. { - + if (App_InFineSystem().finaleInProgess()) + { + dgl_borderedprojectionstate_t bp; + d->setupProjectionForFinale(&bp); + GL_BeginBorderedProjection(&bp); + for (Finale *finale : App_InFineSystem().finales()) + { + finale->interpreter().page(FinaleInterpreter::Anims).draw(); + finale->interpreter().page(FinaleInterpreter::Texts).draw(); + } + GL_EndBorderedProjection(&bp); + } } // Non-map game screens. { - + // Draw any full window game graphics. + if (gx.DrawWindow) + { + Size2Raw const dimensions(DENG_GAMEVIEW_WIDTH, DENG_GAMEVIEW_HEIGHT); + gx.DrawWindow(&dimensions); + } } // Legacy engine/debug UIs (stuff from the old Net_Drawer). { + // Draw the widgets of the Shadow Bias Editor (if active). + SBE_DrawGui(); + // Debug visualizations. + if (App_World().hasMap() && App_World().map().hasLightGrid()) + { + Rend_LightGridVisual(App_World().map().lightGrid()); + } + Net_Drawer(); + Sfx_ChannelDrawer(); } // Restore the default drawing state. R_UseViewPort(nullptr); displayPlayer = oldDisplayPlayer; - DGL_MatrixMode(DGL_PROJECTION); - DGL_PopMatrix(); - + GLState::considerNativeStateUndefined(); GLState::pop().apply(); } diff --git a/doomsday/apps/client/src/ui/widgets/gameuiwidget.cpp b/doomsday/apps/client/src/ui/widgets/gameuiwidget.cpp deleted file mode 100644 index 82e53b5399..0000000000 --- a/doomsday/apps/client/src/ui/widgets/gameuiwidget.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/** @file gameuiwidget.cpp Widget for legacy game UI elements. - * - * @authors Copyright © 2013 Jaakko Keränen - * @authors Copyright © 2014-2015 Daniel Swanson - * - * @par License - * GPL: http://www.gnu.org/licenses/gpl.html - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. This program is distributed in the hope that it - * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General - * Public License for more details. You should have received a copy of the GNU - * General Public License along with this program; if not, see: - * http://www.gnu.org/licenses - */ - -#include "de_base.h" -#include "ui/widgets/gameuiwidget.h" - -#include - -#include "api_console.h" -#include "ui/editors/edit_bias.h" - -#include "audio/sfxchannel.h" // debug visual -#include "network/net_main.h" -#include "gl/gl_main.h" - -#include "world/map.h" - -#include "render/rend_main.h" - -#include "ui/busyvisual.h" -#include "ui/infine/finaleinterpreter.h" -#include "ui/infine/finalepagewidget.h" - -using namespace de; - -static void setupProjectionForFinale(dgl_borderedprojectionstate_t *bp) -{ - GL_ConfigureBorderedProjection(bp, BPF_OVERDRAW_CLIP | - (!App_World().hasMap()? BPF_OVERDRAW_MASK : 0), - SCREENWIDTH, SCREENHEIGHT, - DENG_GAMEVIEW_WIDTH, DENG_GAMEVIEW_HEIGHT, - scalemode_t(Con_GetByte("rend-finale-stretch"))); -} - -DENG2_PIMPL(GameUIWidget) -{ - Impl(Public *i) : Base(i) - {} - - void draw() - { - if (App_GameLoaded()) - { - //R_RenderViewPorts(HUDLayer); - - // Draw finales. - if (App_InFineSystem().finaleInProgess()) - { - dgl_borderedprojectionstate_t bp; - //dd_bool bordered; - - setupProjectionForFinale(&bp); - GL_BeginBorderedProjection(&bp); - - /*bordered = (FI_ScriptActive() && FI_ScriptCmdExecuted()); - if (bordered) - { - // Draw using the special bordered projection. - GL_ConfigureBorderedProjection(&borderedProjection); - GL_BeginBorderedProjection(&borderedProjection); - }*/ - - for (Finale *finale : App_InFineSystem().finales()) - { - finale->interpreter().page(FinaleInterpreter::Anims).draw(); - finale->interpreter().page(FinaleInterpreter::Texts).draw(); - } - - GL_EndBorderedProjection(&bp); - - //if (bordered) - // GL_EndBorderedProjection(&borderedProjection); - } - - // Draw any full window game graphics. - if (gx.DrawWindow) - { - Size2Raw dimensions(DENG_GAMEVIEW_WIDTH, DENG_GAMEVIEW_HEIGHT); - gx.DrawWindow(&dimensions); - } - } - - // Draw the widgets of the Shadow Bias Editor (if active). - SBE_DrawGui(); - - /* - * Draw debug information. - */ - if (App_World().hasMap() && App_World().map().hasLightGrid()) - { - Rend_LightGridVisual(App_World().map().lightGrid()); - } - Net_Drawer(); - Sfx_ChannelDrawer(); - - DGL_End(); - } -}; - -GameUIWidget::GameUIWidget() : GuiWidget("game_ui"), d(new Impl(this)) -{} - -void GameUIWidget::drawContent() -{ - if (isDisabled() || !GL_IsFullyInited()) - return; - - GLState::push().apply(); - - /* - Rectanglei pos; - if (hasChangedPlace(pos)) - { - // Automatically update if the widget is resized. - d->updateSize(); - }*/ - - d->draw(); - - GLState::considerNativeStateUndefined(); - GLState::pop().apply(); -} - -bool GameUIWidget::finaleStretch() //static -{ - dgl_borderedprojectionstate_t bp; - setupProjectionForFinale(&bp); - return (bp.scaleMode == SCALEMODE_STRETCH); -}