yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
wasm_error_handler.h
Go to the documentation of this file.
1#ifndef YAZE_APP_PLATFORM_WASM_ERROR_HANDLER_H_
2#define YAZE_APP_PLATFORM_WASM_ERROR_HANDLER_H_
3
4#ifdef __EMSCRIPTEN__
5
6#include <atomic>
7#include <functional>
8#include <string>
9
10namespace yaze {
11namespace platform {
12
17enum class ToastType { kInfo, kSuccess, kWarning, kError };
18
27class WasmErrorHandler {
28 public:
34 static void ShowError(const std::string& title, const std::string& message);
35
41 static void ShowWarning(const std::string& title, const std::string& message);
42
48 static void ShowInfo(const std::string& title, const std::string& message);
49
56 static void Toast(const std::string& message,
57 ToastType type = ToastType::kInfo, int duration_ms = 3000);
58
64 static void ShowProgress(const std::string& task, float progress);
65
69 static void HideProgress();
70
76 static void Confirm(const std::string& message,
77 std::function<void(bool)> callback);
78
83 static void Initialize();
84
85 private:
86 // Prevent instantiation
87 WasmErrorHandler() = delete;
88 ~WasmErrorHandler() = delete;
89
90 // Track if handler is initialized (thread-safe)
91 static std::atomic<bool> initialized_;
92
93 // Counter for generating unique callback IDs (thread-safe)
94 static std::atomic<int> callback_counter_;
95};
96
97} // namespace platform
98} // namespace yaze
99
100#endif // __EMSCRIPTEN__
101
102#endif // YAZE_APP_PLATFORM_WASM_ERROR_HANDLER_H_
constexpr const char * kWarning
constexpr const char * kError
constexpr const char * kInfo
constexpr const char * kSuccess