yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
feature_hint_manager.cc
Go to the documentation of this file.
2
4
5namespace yaze {
6namespace editor {
7
10 "Coming from ZScream? yaze maps the same editors into a modern "
11 "workspace — open the concept guide for a side-by-side map.",
12 ToastType::kInfo, 12.0f, /*offer_guide=*/true});
14 "ZScream tip: Overworld edits live here. Pause-menu map art is "
15 "Screen Editor → Overworld Map (not this canvas).",
16 ToastType::kInfo, 9.0f, true});
18 "Browse room tools on the left. Inspect selections and "
19 "preview rooms on the right.",
20 ToastType::kInfo, 9.0f, true});
22 "ZScream tip: .yaze / .yazeproj projects track ROM + settings. "
23 "You can also open .zsproj files when available.",
24 ToastType::kInfo, 9.0f, true});
26 "ZScream tip: Save Scope lets you choose ROM vs project vs "
27 "both — check File → Save Scope before writing.",
28 ToastType::kInfo, 9.0f, false});
31 "ZScream tip: Tile16 palette + paint tools live in the "
32 "overworld sidebar (tile16 selector / workbench) — same role as "
33 "ZScream's tile picker.",
34 ToastType::kInfo, 9.0f, true});
36 "ZScream tip: This ROM has ZSCustomOverworld ASM. Area sizes, "
37 "BG colors, and overlays depend on v1/v2/v3 — check Map "
38 "Properties for version-gated fields.",
39 ToastType::kInfo, 10.0f, true});
41 "ZScream tip: Screen Editor → Overworld Map edits pause-menu "
42 "map art. Playable world tiles stay in the Overworld editor.",
43 ToastType::kInfo, 9.0f, true});
44}
45
47 if (!definition.id || !definition.message) {
48 return;
49 }
50 catalog_[definition.id] = definition;
51}
52
53bool FeatureHintManager::MaybeShow(std::string_view id) {
54 if (!IsEnabled() || !toast_manager_ || id.empty()) {
55 return false;
56 }
57 if (IsDismissed(id)) {
58 return false;
59 }
60 auto it = catalog_.find(std::string(id));
61 if (it == catalog_.end()) {
62 return false;
63 }
64
65 const FeatureHintDefinition& hint = it->second;
66 if (hint.offer_guide && guide_callback_) {
67 toast_manager_->Show(hint.message, hint.type, hint.ttl_seconds,
68 "Open guide", guide_callback_);
69 } else {
70 toast_manager_->Show(hint.message, hint.type, hint.ttl_seconds);
71 }
72 Dismiss(id);
73 return true;
74}
75
76void FeatureHintManager::Dismiss(std::string_view id) {
77 if (!user_settings_ || id.empty()) {
78 return;
79 }
80 auto& dismissed = user_settings_->prefs().dismissed_feature_hints;
81 if (dismissed.insert(std::string(id)).second) {
82 Persist();
83 }
84}
85
86bool FeatureHintManager::IsDismissed(std::string_view id) const {
87 if (!user_settings_ || id.empty()) {
88 return false;
89 }
90 const auto& dismissed = user_settings_->prefs().dismissed_feature_hints;
91 return dismissed.find(std::string(id)) != dismissed.end();
92}
93
95 if (!user_settings_) {
96 return true;
97 }
99}
100
102 if (!user_settings_) {
103 return;
104 }
105 if (user_settings_->prefs().feature_hints_enabled == enabled) {
106 return;
107 }
109 Persist();
110}
111
113 if (!user_settings_) {
114 return;
115 }
117 Persist();
118}
119
121 if (!user_settings_) {
122 return 0;
123 }
125}
126
128 if (user_settings_) {
129 (void)user_settings_->Save();
130 }
131}
132
133} // namespace editor
134} // namespace yaze
void Dismiss(std::string_view id)
Mark dismissed without showing (e.g. user opened the guide manually).
bool IsDismissed(std::string_view id) const
void RegisterHint(FeatureHintDefinition definition)
Register or replace a hint definition (tests / future packs).
bool MaybeShow(std::string_view id)
void ResetDismissed()
Clear all dismissed ids and persist. Tips can fire again.
std::unordered_map< std::string, FeatureHintDefinition > catalog_
void RegisterBuiltinHints()
Register built-in ZScream migrant tips. Safe to call more than once.
void Show(const std::string &message, ToastType type=ToastType::kInfo, float ttl_seconds=3.0f, std::string action_label={}, std::function< void()> on_action=nullptr)
constexpr const char * kZScreamDungeon
constexpr const char * kZScreamZso
constexpr const char * kZScreamOverworld
constexpr const char * kZScreamWelcome
constexpr const char * kZScreamSave
constexpr const char * kZScreamTile16
constexpr const char * kZScreamScreenMap
constexpr const char * kZScreamProjects
bool offer_guide
When true and a guide callback is set, toast shows an "Open guide" button.
std::unordered_set< std::string > dismissed_feature_hints