ScriptCanvasBoolDataInterface.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 <GraphCanvas/Components/NodePropertyDisplay/BooleanDataInterface.h>
  10. #include "ScriptCanvasDataInterface.h"
  11. namespace ScriptCanvasEditor
  12. {
  13. class ScriptCanvasBoolDataInterface
  14. : public ScriptCanvasDataInterface<GraphCanvas::BooleanDataInterface>
  15. {
  16. public:
  17. AZ_CLASS_ALLOCATOR(ScriptCanvasBoolDataInterface, AZ::SystemAllocator);
  18. ScriptCanvasBoolDataInterface(const AZ::EntityId& nodeId, const ScriptCanvas::SlotId& slotId)
  19. : ScriptCanvasDataInterface(nodeId, slotId)
  20. {
  21. }
  22. ~ScriptCanvasBoolDataInterface() = default;
  23. // BooleanDataInterface
  24. bool GetBool() const override
  25. {
  26. const ScriptCanvas::Datum* object = GetSlotObject();
  27. if (object)
  28. {
  29. const bool* retVal = object->GetAs<bool>();
  30. if (retVal)
  31. {
  32. return (*retVal);
  33. }
  34. }
  35. return false;
  36. }
  37. void SetBool(bool enabled) override
  38. {
  39. ScriptCanvas::ModifiableDatumView datumView;
  40. ModifySlotObject(datumView);
  41. if (datumView.IsValid())
  42. {
  43. datumView.SetAs(enabled);
  44. PostUndoPoint();
  45. PropertyGridRequestBus::Broadcast(&PropertyGridRequests::RefreshPropertyGrid);
  46. }
  47. }
  48. };
  49. }