nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
guild_window.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_GUILD_WINDOW_H_
2#define NANOMMO_CLIENT_GUILD_WINDOW_H_
3
4#include <array>
5#include <cstdint>
6#include <optional>
7#include <string>
8
9#include "protocol/nanommo.pb.h"
10
11namespace nanommo {
12
13/// What a rank is called: Leader, Officer or Member.
14const char* RankName(protocol::Rank rank);
15
16/// How long a war has left, in minutes and seconds, such as 29:05.
17std::string TimeLeft(uint32_t seconds);
18
19/// Your guild, in a window of its own, which G opens and closes: a name to
20/// found one with while you're in none, and its name and your rank once you
21/// are, its war while it's in one, and a name to ask someone in by, for an
22/// officer or the leader.
24 public:
25 bool* mutable_visible() { return &visible_; }
26 bool visible() const { return visible_; }
27 void Toggle() { visible_ = !visible_; }
28
29 /// A guild asked you to join, which the window asks you about, open or not,
30 /// until you answer or the invitation runs out.
31 void Invited(protocol::GuildInvite invite);
32
33 /// Draws the question, if a guild asked, and the window, while it's open,
34 /// for you, by your character's id. A right-click on someone in the roster
35 /// opens a menu of what your rank lets you do to theirs. Returns what the
36 /// player asks for, which the server does, or says in the chat why not.
37 std::optional<protocol::GuildAction> Build(const protocol::Guild& yours,
38 uint32_t you);
39
40 private:
41 std::optional<protocol::GuildAction> BuildQuestion();
42 /// Asks the leader whether to disband the guild, for everyone in it.
43 std::optional<protocol::GuildAction> BuildDisband(const std::string& guild);
44
45 bool visible_ = false;
46 /// The name of a guild to found: up to 24 letters, and the end.
47 std::array<char, 25> name_{};
48 /// The name of a player to ask in: up to 16 characters, and the end.
49 std::array<char, 17> player_{};
50 std::optional<protocol::GuildInvite> invite_;
51 /// When it came, in ImGui's seconds.
52 double invited_at_ = 0.0;
53 bool disbanding_ = false;
54 /// How long the war had left as its news came, in seconds, and when that
55 /// was, in ImGui's seconds, which it counts down from.
56 uint32_t war_left_ = 0;
57 double war_news_at_ = 0.0;
58};
59
60} // namespace nanommo
61
62#endif // NANOMMO_CLIENT_GUILD_WINDOW_H_
void Invited(protocol::GuildInvite invite)
bool visible() const
std::optional< protocol::GuildAction > Build(const protocol::Guild &yours, uint32_t you)
Definition chat.cc:9
const char * RankName(protocol::Rank rank)
What a rank is called: Leader, Officer or Member.
std::string TimeLeft(uint32_t seconds)
How long a war has left, in minutes and seconds, such as 29:05.