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 "ZScream tip: Dungeon layout mirrors ZScream — room canvas "
19 "center, selectors left, inspector on the right (Settings can "
20 "swap sides).",
21 ToastType::kInfo, 9.0f, true});
23 "ZScream tip: .yaze / .yazeproj projects track ROM + settings. "
24 "You can also open .zsproj files when available.",
25 ToastType::kInfo, 9.0f, true});
27 "ZScream tip: Save Scope lets you choose ROM vs project vs "
28 "both — check File → Save Scope before writing.",
29 ToastType::kInfo, 9.0f, false});
32 "ZScream tip: Tile16 palette + paint tools live in the "
33 "overworld sidebar (tile16 selector / workbench) — same role as "
34 "ZScream's tile picker.",
35 ToastType::kInfo, 9.0f, true});
37 "ZScream tip: This ROM has ZSCustomOverworld ASM. Area sizes, "
38 "BG colors, and overlays depend on v1/v2/v3 — check Map "
39 "Properties for version-gated fields.",
40 ToastType::kInfo, 10.0f, true});
42 "ZScream tip: Screen Editor → Overworld Map edits pause-menu "
43 "map art. Playable world tiles stay in the Overworld editor.",
44 ToastType::kInfo, 9.0f, true});
45}
46
48 if (!definition.id || !definition.message) {
49 return;
50 }
51 catalog_[definition.id] = definition;
52}
53
54bool FeatureHintManager::MaybeShow(std::string_view id) {
55 if (!IsEnabled() || !toast_manager_ || id.empty()) {
56 return false;
57 }
58 if (IsDismissed(id)) {
59 return false;
60 }
61 auto it = catalog_.find(std::string(id));
62 if (it == catalog_.end()) {
63 return false;
64 }
65
66 const FeatureHintDefinition& hint = it->second;
67 if (hint.offer_guide && guide_callback_) {
68 toast_manager_->Show(hint.message, hint.type, hint.ttl_seconds,
69 "Open guide", guide_callback_);
70 } else {
71 toast_manager_->Show(hint.message, hint.type, hint.ttl_seconds);
72 }
73 Dismiss(id);
74 return true;
75}
76
77void FeatureHintManager::Dismiss(std::string_view id) {
78 if (!user_settings_ || id.empty()) {
79 return;
80 }
81 auto& dismissed = user_settings_->prefs().dismissed_feature_hints;
82 if (dismissed.insert(std::string(id)).second) {
83 Persist();
84 }
85}
86
87bool FeatureHintManager::IsDismissed(std::string_view id) const {
88 if (!user_settings_ || id.empty()) {
89 return false;
90 }
91 const auto& dismissed = user_settings_->prefs().dismissed_feature_hints;
92 return dismissed.find(std::string(id)) != dismissed.end();
93}
94
96 if (!user_settings_) {
97 return true;
98 }
100}
101
103 if (!user_settings_) {
104 return;
105 }
106 if (user_settings_->prefs().feature_hints_enabled == enabled) {
107 return;
108 }
110 Persist();
111}
112
114 if (!user_settings_) {
115 return;
116 }
118 Persist();
119}
120
122 if (!user_settings_) {
123 return 0;
124 }
126}
127
129 if (user_settings_) {
130 (void)user_settings_->Save();
131 }
132}
133
134} // namespace editor
135} // 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