OpenMiner/client/source/states/ServerLoadingState.cpp

71 lines
2.5 KiB
C++
Raw Normal View History

2019-01-12 22:42:24 +01:00
/*
* =====================================================================================
*
* OpenMiner
* Copyright (C) 2018-2020 Unarelith, Quentin Bazin <openminer@unarelith.net>
2019-01-12 22:42:24 +01:00
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
2019-01-12 22:42:24 +01:00
*
* 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
* Lesser General Public License for more details.
2019-01-12 22:42:24 +01:00
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2019-01-12 22:42:24 +01:00
*
* =====================================================================================
*/
#include <gk/core/ApplicationStateStack.hpp>
#include <gk/core/Mouse.hpp>
2019-01-12 22:42:24 +01:00
#include <gk/resource/ResourceHandler.hpp>
#include "Config.hpp"
#include "GameState.hpp"
#include "ServerLoadingState.hpp"
ServerLoadingState::ServerLoadingState(GameState &game) : m_game(game) {
2019-01-12 22:42:24 +01:00
m_shader.createProgram();
m_shader.addShader(GL_VERTEX_SHADER, "resources/shaders/basic.v.glsl");
m_shader.addShader(GL_FRAGMENT_SHADER, "resources/shaders/basic.f.glsl");
m_shader.linkProgram();
m_text.setFont(gk::ResourceHandler::getInstance().get<gk::Font>("font-default"));
m_text.setCharacterSize(8 * 6);
2019-04-13 15:06:52 +02:00
m_text.setString("Loading world...");
2019-01-12 22:42:24 +01:00
m_text.setColor(gk::Color::White);
m_text.setPosition(Config::screenWidth / 2.0f - m_text.getLocalBounds().sizeX / 2.0f, 200);
2019-01-12 22:42:24 +01:00
m_textShadow.setFont(gk::ResourceHandler::getInstance().get<gk::Font>("font-default"));
m_textShadow.setCharacterSize(8 * 6);
2019-04-13 15:06:52 +02:00
m_textShadow.setString(m_text.string());
2019-01-12 22:42:24 +01:00
m_textShadow.setColor(gk::Color{70, 70, 70, 255});
m_textShadow.setPosition(m_text.getPosition().x + 6, m_text.getPosition().y + 6);
gk::Mouse::setCursorVisible(true);
gk::Mouse::setCursorGrabbed(false);
2019-01-12 22:42:24 +01:00
}
void ServerLoadingState::update() {
m_game.client().update();
if (m_isWorldSent) {
m_stateStack->pop();
gk::Mouse::setCursorVisible(false);
gk::Mouse::setCursorGrabbed(true);
}
2019-01-12 22:42:24 +01:00
}
void ServerLoadingState::draw(gk::RenderTarget &target, gk::RenderStates states) const {
states.shader = &m_shader;
target.setView(target.getDefaultView());
target.draw(m_textShadow, states);
target.draw(m_text, states);
}