yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
ghost_preview_feedback.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_DUNGEON_INTERACTION_GHOST_PREVIEW_FEEDBACK_H_
2#define YAZE_APP_EDITOR_DUNGEON_INTERACTION_GHOST_PREVIEW_FEEDBACK_H_
3
4#include <algorithm>
5#include <cstddef>
6#include <string_view>
7
9#include "imgui/imgui.h"
10
11namespace yaze::editor {
12
14 kNormal = 0,
17};
18
20 size_t max_count) {
21 if (max_count == 0) {
23 }
24 if (current_count >= max_count) {
26 }
27 if (current_count + 1 == max_count) {
29 }
31}
32
33inline ImVec4 GetPlacementAccentColor(const AgentUITheme& theme,
35 const ImVec4& normal_color) {
36 switch (state) {
38 return theme.status_error;
40 return theme.status_warning;
42 default:
43 return normal_color;
44 }
45}
46
47inline std::string_view GetPlacementCapacityStatusText(
49 switch (state) {
51 return "ROOM FULL";
53 return "LAST SLOT";
55 default:
56 return {};
57 }
58}
59
60inline std::string_view GetPlacementCapacityTooltipSuffix(
62 switch (state) {
64 return "Placement blocked";
66 return "Last available slot";
68 default:
69 return {};
70 }
71}
72
73inline void DrawPlacementCapacityBadge(ImDrawList* draw_list,
74 const ImVec2& badge_min,
75 const AgentUITheme& theme,
77 std::string_view primary_text) {
78 if (state == PlacementCapacityState::kNormal || primary_text.empty()) {
79 return;
80 }
81
82 const ImVec4 accent =
83 GetPlacementAccentColor(theme, state, theme.text_primary);
84 const std::string_view status_text = GetPlacementCapacityStatusText(state);
85 const ImVec2 primary_size = ImGui::CalcTextSize(primary_text.data());
86 const ImVec2 status_size = ImGui::CalcTextSize(status_text.data());
87 const float width = std::max(primary_size.x, status_size.x) + 14.0f;
88 const float height = primary_size.y + status_size.y + 14.0f;
89 const ImVec2 badge_max(badge_min.x + width, badge_min.y + height);
90
91 draw_list->AddRectFilled(
92 badge_min, badge_max,
93 ImGui::GetColorU32(ImVec4(accent.x, accent.y, accent.z, 0.18f)), 5.0f);
94 draw_list->AddRect(
95 badge_min, badge_max,
96 ImGui::GetColorU32(ImVec4(accent.x, accent.y, accent.z, 0.92f)), 5.0f, 0,
97 2.0f);
98 draw_list->AddText(ImVec2(badge_min.x + 7.0f, badge_min.y + 4.0f),
99 ImGui::GetColorU32(theme.text_primary),
100 primary_text.data());
101 draw_list->AddText(
102 ImVec2(badge_min.x + 7.0f, badge_min.y + 8.0f + primary_size.y),
103 ImGui::GetColorU32(ImVec4(accent.x, accent.y, accent.z, 1.0f)),
104 status_text.data());
105}
106
107inline ImVec4 GetPlacementSummaryColor(const AgentUITheme& theme,
108 size_t current_count, size_t max_count,
109 const ImVec4& normal_color) {
111 theme, GetPlacementCapacityState(current_count, max_count), normal_color);
112}
113
114} // namespace yaze::editor
115
116#endif // YAZE_APP_EDITOR_DUNGEON_INTERACTION_GHOST_PREVIEW_FEEDBACK_H_
Editors are the view controllers for the application.
ImVec4 GetPlacementSummaryColor(const AgentUITheme &theme, size_t current_count, size_t max_count, const ImVec4 &normal_color)
std::string_view GetPlacementCapacityStatusText(PlacementCapacityState state)
void DrawPlacementCapacityBadge(ImDrawList *draw_list, const ImVec2 &badge_min, const AgentUITheme &theme, PlacementCapacityState state, std::string_view primary_text)
ImVec4 GetPlacementAccentColor(const AgentUITheme &theme, PlacementCapacityState state, const ImVec4 &normal_color)
std::string_view GetPlacementCapacityTooltipSuffix(PlacementCapacityState state)
PlacementCapacityState GetPlacementCapacityState(size_t current_count, size_t max_count)
Centralized theme colors for Agent UI components.
Definition agent_theme.h:19