Conquer Space 0.0.0
A space themed grand strategy game set in the near future, with realistic orbital mechanics, and an emphasis on economics and politics.
gui.h
Go to the documentation of this file.
1/* Conquer Space
2 * Copyright (C) 2021-2023 Conquer Space
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#define IMGUI_USER_CONFIG "engine/imconfig.h"
20
21#include <fmt/format.h>
22#include <imgui.h>
23#include <imgui_node_editor.h>
24#include <imgui_stdlib.h>
25#include <implot.h>
26
27#include <map>
28#include <string>
29#include <utility>
30
31namespace ed = ax::NodeEditor;
32
33namespace ImPlot {
34template <typename T>
35IMPLOT_API void PlotPieChart(std::map<std::string, T>&, double x, double y, double radius, bool normalize = false,
36 const char* label_fmt = "%.1f", double angle0 = 90);
37} // namespace ImPlot
38
39namespace ImGui {
40template <typename... Args>
41IMGUI_API void TextFmt(fmt::format_string<Args...> fmt, Args&&... args) {
42 auto s = fmt::format(fmt, std::forward<Args>(args)...);
43 Text("%s", s.c_str());
44}
45
46template <typename... Args>
47IMGUI_API void TextFmtColored(const ImVec4& color, fmt::format_string<Args...> fmt, Args&&... args) {
48 auto s = fmt::format(fmt, std::forward<Args>(args)...);
49 TextColored(color, "%s", s.c_str());
50}
51
52template <typename... Args>
53IMGUI_API bool SelectableFmt(fmt::format_string<Args...> fmt, bool* p_selected, ImGuiSelectableFlags flags,
54 const ImVec2& size, Args&&... args) {
55 auto s = fmt::format(fmt, std::forward<Args>(args)...);
56 return Selectable(s.c_str(), p_selected, flags, size);
57}
58
59template <typename... Args>
60IMGUI_API bool SelectableFmt(fmt::format_string<Args...> fmt, bool* p_selected, ImGuiSelectableFlags flags,
61 Args&&... args) {
62 auto s = fmt::format(fmt, std::forward<Args>(args)...);
63 return Selectable(s.c_str(), p_selected, flags, ImVec2(0, 0));
64}
65
66template <typename... Args>
67IMGUI_API bool SelectableFmt(fmt::format_string<Args...> fmt, bool* p_selected, Args&&... args) {
68 auto s = fmt::format(fmt, std::forward<Args>(args)...);
69 return Selectable(s.c_str(), p_selected, 0, ImVec2(0, 0));
70}
71} // namespace ImGui
72
73namespace ax::Drawing {
74enum class IconType : ImU32 { Flow, Circle, Square, Grid, RoundSquare, Diamond };
75
76void DrawIcon(ImDrawList* drawList, const ImVec2& a, const ImVec2& b, IconType type, bool filled, ImU32 color,
77 ImU32 innerColor);
78
79void Icon(const ImVec2& size, IconType type, bool filled, const ImVec4& color = ImVec4(1, 1, 1, 1),
80 const ImVec4& innerColor = ImVec4(0, 0, 0, 0));
81} // namespace ax::Drawing
Definition: gui.h:39
IMGUI_API void TextFmt(fmt::format_string< Args... > fmt, Args &&... args)
Definition: gui.h:41
IMGUI_API void TextFmtColored(const ImVec4 &color, fmt::format_string< Args... > fmt, Args &&... args)
Definition: gui.h:47
IMGUI_API bool SelectableFmt(fmt::format_string< Args... > fmt, bool *p_selected, ImGuiSelectableFlags flags, const ImVec2 &size, Args &&... args)
Definition: gui.h:53
Definition: gui.cpp:22
IMPLOT_API void PlotPieChart(std::map< std::string, T > &map, double x, double y, double radius, bool normalize, const char *fmt, double angle0)
Definition: gui.cpp:45
Definition: gui.h:73
IconType
Definition: gui.h:74
void DrawIcon(ImDrawList *drawList, const ImVec2 &a, const ImVec2 &b, IconType type, bool filled, ImU32 color, ImU32 innerColor)
Definition: gui.cpp:155
void Icon(const ImVec2 &size, IconType type, bool filled, const ImVec4 &color=ImVec4(1, 1, 1, 1), const ImVec4 &innerColor=ImVec4(0, 0, 0, 0))
Definition: gui.cpp:294
@ Text
Definition: vfs.h:27