/* * Copyright (c) Contributors to the Open 3D Engine Project. * For complete copyright and license terms please see the LICENSE at the root of this distribution. * * SPDX-License-Identifier: Apache-2.0 OR MIT * */ #include "BoolTrack.h" #include #include "UiAnimSerialize.h" ////////////////////////////////////////////////////////////////////////// UiBoolTrack::UiBoolTrack() : m_bDefaultValue(true) { } ////////////////////////////////////////////////////////////////////////// void UiBoolTrack::GetKeyInfo([[maybe_unused]] int index, const char*& description, float& duration) { description = 0; duration = 0; } ////////////////////////////////////////////////////////////////////////// void UiBoolTrack::GetValue(float time, bool& value) { value = m_bDefaultValue; CheckValid(); int nkeys = static_cast(m_keys.size()); if (nkeys < 1) { return; } int key = 0; while ((key < nkeys) && (time >= m_keys[key].time)) { key++; } if (m_bDefaultValue) { value = !(key & 1); // True if even key. } else { value = (key & 1); // False if even key. } } ////////////////////////////////////////////////////////////////////////// void UiBoolTrack::SetValue([[maybe_unused]] float time, [[maybe_unused]] const bool& value, [[maybe_unused]] bool bDefault) { Invalidate(); } ////////////////////////////////////////////////////////////////////////// void UiBoolTrack::SetDefaultValue(const bool bDefaultValue) { m_bDefaultValue = bDefaultValue; } ////////////////////////////////////////////////////////////////////////// template<> inline void TUiAnimTrack::Reflect(AZ::SerializeContext* serializeContext) { serializeContext->ClassDeprecate("TUiAnimTrack_IBoolKey", "{7C2942C1-0ACE-404E-BF2B-E095A1B69A5B}", [](AZ::SerializeContext& context, AZ::SerializeContext::DataElementNode& rootElement) { AZStd::vector childNodeElements; for (int index = 0; index < rootElement.GetNumSubElements(); ++index) { childNodeElements.push_back(rootElement.GetSubElement(index)); } // Convert the rootElement now, the existing child DataElmentNodes are now removed rootElement.Convert>(context); for (AZ::SerializeContext::DataElementNode& childNodeElement : childNodeElements) { rootElement.AddElement(AZStd::move(childNodeElement)); } return true; }); serializeContext->Class >() ->Version(1) ->Field("Flags", &TUiAnimTrack::m_flags) ->Field("Range", &TUiAnimTrack::m_timeRange) ->Field("ParamType", &TUiAnimTrack::m_nParamType) ->Field("ParamData", &TUiAnimTrack::m_componentParamData) ->Field("Keys", &TUiAnimTrack::m_keys); } ////////////////////////////////////////////////////////////////////////// void UiBoolTrack::Reflect(AZ::SerializeContext* serializeContext) { TUiAnimTrack::Reflect(serializeContext); serializeContext->Class >() ->Version(1) ; }