nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
help_window.cc
Go to the documentation of this file.
2
3#include <imgui.h>
4
5#include <array>
6#include <string>
7
8#include "absl/strings/str_cat.h"
9#include "client/menu.h"
10#include "client/theme.h"
11#include "client/translations.h"
12#include "extras/IconsFontAwesome6.h"
13
14namespace nanommo {
15
16namespace {
17
18// A line of a page, in the player's language, after a dot, wrapped to the
19// page.
20void Line(const char* text) {
21 ImGui::Bullet();
22 ImGui::TextWrapped("%s", Tr(text));
23}
24
25} // namespace
26
28 if (!visible_) {
29 return;
30 }
31 const ImVec2 display = ImGui::GetIO().DisplaySize;
32 ImGui::SetNextWindowPos({display.x / 2.0f, display.y * 0.45f},
33 ImGuiCond_FirstUseEver, {0.5f, 0.5f});
34 ImGui::SetNextWindowSize(Ui(ImVec2{720.0f, 460.0f}));
35 if (!BeginPanel("Help", &visible_,
36 ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings |
37 ImGuiWindowFlags_NoCollapse)) {
38 EndPanel();
39 return;
40 }
41 // Each with its English name as its ID, as the settings' pages are.
42 struct Tab {
43 Page page;
44 const char* icon;
45 const char* name;
46 };
47 static constexpr std::array<Tab, 7> kPages = {{
48 {Page::kMoving, ICON_FA_PERSON_WALKING, N_("Moving")},
49 {Page::kFighting, ICON_FA_HAND_FIST, N_("Fighting")},
50 {Page::kItems, ICON_FA_BAG_SHOPPING, N_("Items")},
51 {Page::kQuests, ICON_FA_SCROLL, N_("Quests")},
52 {Page::kGuilds, ICON_FA_SHIELD_HALVED, N_("Guilds and duels")},
53 {Page::kChat, ICON_FA_COMMENTS, N_("Chat")},
54 {Page::kKeys, ICON_FA_KEYBOARD, N_("Keys")},
55 }};
56 ImGui::BeginChild("Pages", {Ui(190.0f), 0.0f});
57 for (const auto& [page, icon, name] : kPages) {
58 ImGui::PushStyleVar(ImGuiStyleVar_SelectableTextAlign, {0.0f, 0.5f});
59 const std::string label = absl::StrCat(icon, " ", Tr(name), "###", name);
60 if (ImGui::Selectable(label.c_str(), page_ == page, 0, {0.0f, Ui(34.0f)})) {
61 page_ = page;
62 }
63 ImGui::PopStyleVar();
64 }
65 ImGui::EndChild();
66 ImGui::SameLine(0.0f, Ui(16.0f));
67 ImGui::BeginChild("Page");
68 switch (page_) {
69 case Page::kMoving:
70 ImGui::SeparatorText(Tr("Moving"));
71 Line("W A S D, or the arrows, walk, and Shift runs.");
72 Line(
73 "Double-click the ground, or click a place on the map (M), and you "
74 "walk there, round what's in the way.");
75 Line(
76 "Q and E, or the right button held down, turn the camera, and the "
77 "mouse wheel zooms in and out.");
78 Line("A gate takes you to another land.");
79 break;
80 case Page::kFighting:
81 ImGui::SeparatorText(Tr("Fighting"));
82 Line(
83 "Click a monster to pick it. Its name and health show over it, and "
84 "in the frame at the top.");
85 Line(
86 "Space swings what you hold at the monster you picked. Too far "
87 "away, you run up to it first.");
88 Line(
89 "1 to 9 use the skills on the hotbar, and with Shift, those on its "
90 "second row. Trainers teach you more of them.");
91 Line(
92 "A monster's attack shows on the ground before it lands, filling "
93 "as it comes: step out of its shape.");
94 Line("When you die, wait for the count, then click Respawn.");
95 break;
96 case Page::kItems:
97 ImGui::SeparatorText(Tr("Items"));
98 Line("What a monster drops goes into your bag (I).");
99 Line(
100 "Double-click an item to use it, wear it, or take it off. Or drag "
101 "it onto your character (C).");
102 Line("Drag an item out of the bag to throw it away.");
103 Line(
104 "Crafting (K) makes something from what's in your bag, over a few "
105 "seconds. Moving, or being hit, stops it, and nothing's lost.");
106 Line("To trade with someone, type /trade and their name in the chat.");
107 break;
108 case Page::kQuests:
109 ImGui::SeparatorText(Tr("Quests"));
110 Line(
111 "Someone with a ! over them has a quest for you. Click them to "
112 "take it.");
113 Line(
114 "A ? over them means you've done it: click them again to turn it "
115 "in, for your prize.");
116 Line("The quests you're on show in the top right, under the minimap.");
117 Line(
118 "T opens your quests: how far you've got with each, what it gives, "
119 "and a way to give one up, which its giver then gives again.");
120 break;
121 case Page::kGuilds:
122 ImGui::SeparatorText(Tr("Guilds and duels"));
123 Line(
124 "G opens your guild: found one, ask people in, and see who's "
125 "online.");
126 Line("To ask someone to a duel, type /duel and their name in the chat.");
127 Line(
128 "A guild's leader can type /war and another guild's name, to ask "
129 "it to war for 30 minutes. Its players' names are red, and you can "
130 "fight them anywhere.");
131 break;
132 case Page::kChat:
133 ImGui::SeparatorText(Tr("Chat"));
134 Line("Enter opens the chat, and Enter again sends what you typed.");
135 Line("/g and a space first talks to your guild.");
136 Line(
137 "/trade, /duel or /war and a name asks for a trade, a duel or a "
138 "war.");
139 break;
140 case Page::kKeys:
141 ImGui::SeparatorText(Tr("Keys"));
142 BuildKeys();
143 break;
144 }
145 ImGui::EndChild();
146 EndPanel();
147}
148
149} // namespace nanommo
Definition chat.cc:9
constexpr const char * N_(const char *text)
bool BeginPanel(const char *name, bool *open, ImGuiWindowFlags flags, float alpha)
Definition theme.cc:320
float Ui(float points)
Definition theme.h:67
void EndPanel()
Definition theme.cc:379
const char * Tr(const char *text)
void BuildKeys()
Definition menu.cc:82