Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/frontend/StarPopupInterface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/frontend/StarPopupInterface.cpp')
-rw-r--r--source/frontend/StarPopupInterface.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/source/frontend/StarPopupInterface.cpp b/source/frontend/StarPopupInterface.cpp
new file mode 100644
index 0000000..65b1f54
--- /dev/null
+++ b/source/frontend/StarPopupInterface.cpp
@@ -0,0 +1,30 @@
+#include "StarPopupInterface.hpp"
+#include "StarGuiReader.hpp"
+#include "StarRoot.hpp"
+#include "StarLabelWidget.hpp"
+#include "StarRandom.hpp"
+#include "StarAssets.hpp"
+
+namespace Star {
+
+PopupInterface::PopupInterface() {
+ auto assets = Root::singleton().assets();
+
+ GuiReader reader;
+
+ reader.registerCallback("close", [=](Widget*) { dismiss(); });
+ reader.registerCallback("ok", [=](Widget*) { dismiss(); });
+
+ reader.construct(assets->json("/interface/windowconfig/popup.config:paneLayout"), this);
+}
+
+void PopupInterface::displayMessage(String const& message, String const& title, String const& subtitle, Maybe<String> const& onShowSound) {
+ setTitleString(title, subtitle);
+ fetchChild<LabelWidget>("message")->setText(message);
+ show();
+ auto sound = onShowSound.value(Random::randValueFrom(Root::singleton().assets()->json("/interface/windowconfig/popup.config:onShowSound").toArray(), "").toString());
+ if (!sound.empty())
+ context()->playAudio(sound);
+}
+
+}