// Copyright (c) 2015 - 2023 Doozy Entertainment. All Rights Reserved.
// This code can only be used under the standard Unity Asset Store End User License Agreement
// A Copy of the EULA APPENDIX 1 is available at http://unity3d.com/company/legal/as_terms
using System;
using System.Collections.Generic;
using System.Linq;
using Doozy.Editor.Common.Extensions;
using Doozy.Editor.EditorUI;
using Doozy.Editor.EditorUI.Components;
using Doozy.Editor.EditorUI.Utils;
using Doozy.Editor.Reactor.Internal;
using Doozy.Runtime.Colors;
using Doozy.Runtime.Common.Extensions;
using Doozy.Runtime.Reactor.Extensions;
using Doozy.Runtime.Reactor.Reactions;
using Doozy.Runtime.UIElements.Extensions;
using UnityEditor;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UIElements;
using EditorStyles = Doozy.Editor.EditorUI.EditorStyles;
using Object = UnityEngine.Object;
// ReSharper disable MemberCanBePrivate.Global
namespace Doozy.Editor.Reactor.Components
{
///
/// Sprite Animation Info VisualElement
///
public class SpriteAnimationInfo : VisualElement, IDisposable
{
public TemplateContainer templateContainer { get; }
public VisualElement layoutContainer { get; }
public VisualElement content { get; }
public Image previewImageContainer { get; }
public Image previewImage { get; }
public VisualElement detailsContainer { get; }
public Label animationName { get; }
public Label numberOfFrames { get; }
public Label textureSize { get; }
public VisualElement playerContainer { get; }
public Label pathLabel { get; }
public Texture2DReaction reaction { get; private set; }
public FluidButton playForwardButton { get; private set; }
public FluidButton playReversedButton { get; private set; }
public FluidButton setSpriteButton { get; private set; }
public Slider playerSlider { get; private set; }
public SerializedProperty arrayProperty { get; }
public List textures { get; } = new List();
public int frameCount => arrayProperty?.arraySize ?? 0;
private const float PLAYER_SPACING = DesignUtils.k_Spacing * 0.5f;
public UnityAction spriteSetter { get; set; }
public void Dispose()
{
reaction?.Recycle();
playForwardButton?.Recycle();
playReversedButton?.Recycle();
setSpriteButton?.Recycle();
}
public SpriteAnimationInfo(SerializedProperty arrayProperty)
{
this.arrayProperty = arrayProperty;
Add(templateContainer = EditorLayouts.Reactor.AnimationInfo.CloneTree());
templateContainer
.AddStyle(EditorStyles.Reactor.AnimationInfo);
layoutContainer = templateContainer.Q(nameof(layoutContainer));
content = layoutContainer.Q(nameof(content));
previewImageContainer = content.Q(nameof(previewImageContainer));
previewImage = previewImageContainer.Q(nameof(previewImage));
detailsContainer = content.Q(nameof(detailsContainer));
animationName = detailsContainer.Q