nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
loading.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_LOADING_H_
2#define NANOMMO_CLIENT_LOADING_H_
3
4#include <array>
5#include <string>
6
7namespace nanommo {
8
9/// When a screen covers the world, while the world isn't there yet, kept apart
10/// from raylib and ImGui so that it can be tested without a window. It covers
11/// the world from the moment we enter one, or go into a new land, until the
12/// land is built. Then it fades, and the fog lifts off the land, nearest
13/// first, so that the land comes out of its sky instead of appearing at once.
14class Loading {
15 public:
16 /// In seconds.
17 static constexpr float kFade = 0.4f;
18 static constexpr float kLift = 1.5f;
19
20 /// Covers the world from the next frame on.
21 void Cover();
22
23 /// Whether the last frame drawn was covered, so that a land built now,
24 /// which holds up the next frame, is built behind the cover.
25 bool covered() const { return stage_ == Stage::kCovered; }
26
27 /// Whether the cover's up, or going up.
28 bool covering() const {
29 return stage_ == Stage::kCovering || stage_ == Stage::kCovered;
30 }
31
32 /// The land is built, so the cover fades and the fog lifts.
33 void Lift();
34
35 /// Moves on by the frame's time, once the frame is drawn.
36 void Update(float seconds);
37
38 /// How much of the screen the cover hides, from 0 to 1.
39 float cover() const;
40
41 /// How far the fog has lifted, from 0, where it hides all but what's
42 /// nearest, to 1, the land's own fog.
43 float clear() const;
44
45 private:
46 enum class Stage { kNone, kCovering, kCovered, kLifting };
47
48 Stage stage_ = Stage::kNone;
49 float time_ = 0.0f;
50};
51
52/// Draws the cover over everything else, as much of it as cover says, in the
53/// sky's colour, with the title in the middle and a line under it.
54void DrawLoadingScreen(float cover, const std::array<float, 3>& sky,
55 const std::string& title, const std::string& line);
56
57} // namespace nanommo
58
59#endif // NANOMMO_CLIENT_LOADING_H_
static constexpr float kLift
Definition loading.h:18
float clear() const
Definition loading.cc:70
void Lift()
The land is built, so the cover fades and the fog lifts.
Definition loading.cc:35
float cover() const
How much of the screen the cover hides, from 0 to 1.
Definition loading.cc:57
void Cover()
Covers the world from the next frame on.
Definition loading.cc:28
static constexpr float kFade
In seconds.
Definition loading.h:17
bool covering() const
Whether the cover's up, or going up.
Definition loading.h:28
bool covered() const
Definition loading.h:25
void Update(float seconds)
Moves on by the frame's time, once the frame is drawn.
Definition loading.cc:40
Definition chat.cc:9
void DrawLoadingScreen(float cover, const std::array< float, 3 > &sky, const std::string &title, const std::string &line)
Definition loading.cc:83