nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
talk_window.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_TALK_WINDOW_H_
2#define NANOMMO_CLIENT_TALK_WINDOW_H_
3
4#include <array>
5#include <cstdint>
6#include <optional>
7#include <string>
8
9#include "protocol/chat.h"
10#include "protocol/nanommo.pb.h"
11
12namespace nanommo {
13
14/// A window to talk to an NPC, such as the storyteller, which opens when the
15/// player clicks it.
17 public:
18 void Open(uint32_t npc, std::string name);
19
20 bool open() const { return npc_.has_value(); }
21 void Close() { npc_.reset(); }
22
23 /// Draws the window, while it's open. Returns what the player says to the
24 /// NPC, once they ask, and closes.
25 std::optional<protocol::Talk> Build();
26
27 private:
28 std::optional<uint32_t> npc_;
29 std::string name_;
30 bool focus_ = false;
31 // One more for the zero at the end.
32 std::array<char, kMaxChatLength + 1> words_{};
33};
34
35} // namespace nanommo
36
37#endif // NANOMMO_CLIENT_TALK_WINDOW_H_
bool open() const
Definition talk_window.h:20
void Open(uint32_t npc, std::string name)
std::optional< protocol::Talk > Build()
Definition chat.cc:9