nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
quest_window.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_QUEST_WINDOW_H_
2#define NANOMMO_CLIENT_QUEST_WINDOW_H_
3
4#include <cstdint>
5#include <optional>
6#include <string>
7#include <utility>
8#include <vector>
9
10#include "client/animator.h"
11#include "content/content.h"
12#include "protocol/nanommo.pb.h"
13
14namespace nanommo {
15
16/// A window with the quests an NPC gives, which opens when the player clicks
17/// them.
19 public:
20 explicit QuestWindow(Content content) : content_(std::move(content)) {}
21
22 void Open(uint32_t npc, std::string name, std::vector<uint32_t> quests);
23
24 bool open() const { return npc_.has_value(); }
25 void Close() { npc_.reset(); }
26
27 /// Draws the window, while it's open: what the NPC says giving each quest,
28 /// what it asks for and what it gives, with a button to take it, how far
29 /// the player is with it, or a button to turn it in once it's done. Returns
30 /// what the player asks for, as an input with the quest to take or turn in.
31 std::optional<protocol::Input> Build(const protocol::Quests& yours);
32
33 private:
34 Content content_;
35 std::optional<uint32_t> npc_;
36 std::string name_;
37 std::vector<uint32_t> quests_;
38};
39
40/// The player's quests, on T: those they're on, and those they've done, each
41/// with who gave it, what it asks for, how far they've got, and what it gives,
42/// and a way to give one up, wherever they are.
43class QuestLog {
44 public:
45 explicit QuestLog(const Content& content) : content_(content) {}
46
47 bool visible() const { return visible_; }
48 bool* mutable_visible() { return &visible_; }
49 void Toggle() { visible_ = !visible_; }
50
51 /// Draws the window, while it's open. Returns the input that gives up the
52 /// quest picked, once the player says they're sure.
53 std::optional<protocol::Input> Build(const protocol::Quests& yours);
54
55 private:
56 const Content& content_;
57 bool visible_ = false;
58 // The quest shown, by its id, and whether we're asking if they're sure
59 // they want to give it up.
60 uint32_t picked_ = 0;
61 bool giving_up_ = false;
62};
63
64/// Marks each NPC who has a quest for the player: '?' for one they've done,
65/// to turn in, over '!' for one they can take.
66void MarkQuestGivers(std::vector<Figure>& figures, const Content& content,
67 const protocol::Quests& yours);
68
69/// The quests the player's on, on the right, from top down, under the
70/// minimap, with how many they've killed for each.
71void DrawQuestTracker(const Content& content, const protocol::Quests& yours,
72 float top);
73
74} // namespace nanommo
75
76#endif // NANOMMO_CLIENT_QUEST_WINDOW_H_
bool visible() const
std::optional< protocol::Input > Build(const protocol::Quests &yours)
bool * mutable_visible()
QuestLog(const Content &content)
QuestWindow(Content content)
std::optional< protocol::Input > Build(const protocol::Quests &yours)
void Open(uint32_t npc, std::string name, std::vector< uint32_t > quests)
Definition chat.cc:9
void MarkQuestGivers(std::vector< Figure > &figures, const Content &content, const protocol::Quests &yours)
void DrawQuestTracker(const Content &content, const protocol::Quests &yours, float top)