3
0

MessagePopupSystemComponent.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Component/Component.h>
  10. #include <MessagePopup/MessagePopupBus.h>
  11. #include <MessagePopupManager.h>
  12. namespace MessagePopup
  13. {
  14. class MessagePopupSystemComponent
  15. : public AZ::Component
  16. , protected MessagePopupRequestBus::Handler
  17. {
  18. public:
  19. AZ_COMPONENT(MessagePopupSystemComponent, "{C950D60D-4673-4262-A44D-6A0A1A4DB341}");
  20. MessagePopupSystemComponent();
  21. static void Reflect(AZ::ReflectContext* context);
  22. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  23. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  24. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  25. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  26. protected:
  27. // MessagePopupRequestBus interface implementation
  28. AZ::u32 ShowPopup(const AZStd::string& _message, EPopupButtons _buttons) override;
  29. AZ::u32 ShowPopupWithCallback(
  30. const AZStd::string& _message,
  31. EPopupButtons _buttons,
  32. AZStd::function<void(int _button)> _callback) override;
  33. AZ::u32 ShowToasterPopup(const AZStd::string& _message, float _showTime) override;
  34. AZ::u32 ShowToasterPopupWithCallback(
  35. const AZStd::string& _message,
  36. float _showTime,
  37. AZStd::function<void(int _button)> _callback) override;
  38. bool HidePopup(AZ::u32 _popupID, int _buttonPressed) override;
  39. AZ::u32 GetNumActivePopups() const override;
  40. // AZ::Component interface implementation
  41. void Init() override;
  42. void Activate() override;
  43. void Deactivate() override;
  44. private:
  45. AZ::u32 InternalShowPopup(const AZStd::string& _message, EPopupButtons _buttons, EPopupKind _kind, AZStd::function<void(int _button)> _callback, float _showTime);
  46. bool ShowNativePopup(const AZStd::string& _message, MessagePopup::EPopupButtons _buttons, MessagePopup::EPopupKind _kind, AZStd::function<void(int _button)> _callback);
  47. MessagePopupManager m_PopupsManager;
  48. };
  49. }