Conquer Space 0.0.0
A space themed grand strategy game set in the near future, with realistic orbital mechanics, and an emphasis on economics and politics.
loadingscene.h
Go to the documentation of this file.
1/* Conquer Space
2 * Copyright (C) 2021-2025 Conquer Space
3 *
4 * This program 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 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <RmlUi/Core/DataModelHandle.h>
20
21#include <atomic>
22#include <memory>
23#include <thread>
24
25#include "client/scenes/scene.h"
27
28namespace cqsp::client::scene {
29// First loading scene when the game starts
30class LoadingScene : public ClientScene {
31 public:
32 explicit LoadingScene(engine::Application& app);
34
35 void Init();
36 void Update(float deltaTime);
37 void Ui(float deltaTime);
38 void Render(float deltaTime);
39
40 /*
41 * Function to load in a thread.
42 */
43 void LoadResources();
44
45 private:
47
48 std::atomic<bool> m_done_loading;
49
50 std::unique_ptr<std::thread> thread;
51
52 std::atomic<float> percentage;
53
55
56 Rml::ElementDocument* document;
57
58 void LoadFont();
59 bool need_halt = false;
60
62 int current = 0;
63 int max = 0;
65
66 Rml::DataModelHandle model_handle;
67};
68} // namespace cqsp::client::scene
Definition: assetloader.h:44
Definition: scene.h:23
Definition: loadingscene.h:30
float windowWidth
Definition: loadingscene.h:46
std::atomic< bool > m_done_loading
Definition: loadingscene.h:48
LoadingScene(engine::Application &app)
Definition: loadingscene.cpp:45
void Render(float deltaTime)
Definition: loadingscene.cpp:134
std::unique_ptr< std::thread > thread
Definition: loadingscene.h:50
float windowHeight
Definition: loadingscene.h:46
bool need_halt
Definition: loadingscene.h:59
asset::AssetLoader assetLoader
Definition: loadingscene.h:54
std::atomic< float > percentage
Definition: loadingscene.h:52
void Init()
Definition: loadingscene.cpp:56
void LoadFont()
Definition: loadingscene.cpp:148
void Update(float deltaTime)
Definition: loadingscene.cpp:78
struct cqsp::client::scene::LoadingScene::LoadingDataModel loading_data
void LoadResources()
Definition: loadingscene.cpp:136
Rml::DataModelHandle model_handle
Definition: loadingscene.h:66
Rml::ElementDocument * document
Definition: loadingscene.h:56
~LoadingScene()
Definition: loadingscene.cpp:50
void Ui(float deltaTime)
Definition: loadingscene.cpp:118
Definition: application.h:48
Definition: loadingscene.cpp:43
int current
Definition: loadingscene.h:62