| 1 | // This file is part of Dust Racing 2D. |
| 2 | // Copyright (C) 2015 Jussi Lind <[email protected]> |
| 3 | // |
| 4 | // Dust Racing 2D is free software: you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation, either version 3 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // Dust Racing 2D is distributed in the hope that it will be useful, |
| 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | // GNU General Public License for more details. |
| 12 | // |
| 13 | // You should have received a copy of the GNU General Public License |
| 14 | // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>. |
| 15 | |
| 16 | #include "intro.hpp" |
| 17 | #include "game.hpp" |
| 18 | #include "renderer.hpp" |
| 19 | |
| 20 | #include <MCAssetManager> |
| 21 | #include <MCGLShaderProgram> |
| 22 | #include <MCSurface> |
| 23 | #include <MCTextureText> |
| 24 | |
| 25 | Intro::Intro() |
| 26 | : m_back(MCAssetManager::surfaceManager().surface("intro")) |
| 27 | , m_font(MCAssetManager::textureFontManager().font(Game::instance().fontName())) |
| 28 | { |
| 29 | m_back->setShaderProgram(Renderer::instance().program("menu")); |
| 30 | m_back->setColor(MCGLColor(1.0f, 1.0f, 1.0f, 1.0f)); |
| 31 | } |
| 32 | |
| 33 | void Intro::setDimensions(int width, int height) |
| 34 | { |
| 35 | OverlayBase::setDimensions(width, height); |
| 36 | } |
| 37 | |
| 38 | void Intro::render() |
| 39 | { |
| 40 | const int w2 = width() / 2; |
| 41 | const int h2 = height() / 2; |
| 42 | assert(w2 > 0 && h2 > 0); |
| 43 | m_back->bind(); |
| 44 | m_back->setSize(width(), width() * m_back->height() / m_back->width()); |
| 45 | m_back->render(nullptr, { static_cast<float>(w2), static_cast<float>(h2), 0 }, 0); |
| 46 | |
| 47 | static auto version = QString("v") + VERSION; |
| 48 | static MCTextureText versionText(version.toStdWString()); |
| 49 | versionText.setGlyphSize(20, height() / 32); |
| 50 | versionText.setColor({ 0.75f, 0.75f, 0.75f }); |
| 51 | versionText.render( |
| 52 | versionText.height(m_font), |
| 53 | versionText.height(m_font), nullptr, m_font, false); |
| 54 | } |