﻿/* Copyright (C) Itseez3D, Inc. - All Rights Reserved
* You may not use this file except in compliance with an authorized license
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* UNLESS REQUIRED BY APPLICABLE LAW OR AGREED BY ITSEEZ3D, INC. IN WRITING, SOFTWARE DISTRIBUTED UNDER THE LICENSE IS DISTRIBUTED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED
* See the License for the specific language governing permissions and limitations under the License.
* Written by Itseez3D, Inc. <support@avatarsdk.com>, November 2020
*/

using ItSeez3D.AvatarSdk.Cloud.GLTF;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

namespace ItSeez3D.AvatarSdkSamples.Cloud
{
	public class FullbodyOutfitManager : MonoBehaviour
	{
		public Dropdown OutfitsDropDown = null;

		private IOutfitsProvider provider = null;

		void AddOptions(List<string> options)
		{
			options.Insert(0, "Naked");
			OutfitsDropDown.AddOptions(options);
		}

		internal void UpdateData(IOutfitsProvider outfitsProvider, int idx = 0)
		{
			OutfitsDropDown.onValueChanged.RemoveAllListeners();
			this.provider = outfitsProvider;
			OutfitsDropDown.ClearOptions();
			if (provider.GetOutfits().Count == 0)
			{
				gameObject.SetActive(false);
			}
			else
			{
				gameObject.SetActive(true);
				AddOptions(provider.GetOutfits());
				OutfitsDropDown.value = idx+1;
				provider.ShowOutfit(idx);
				OutfitsDropDown.onValueChanged.AddListener((int outfitIdx) =>
				{
					provider.ShowOutfit(outfitIdx-1);
				});
			}
		}
	}
}
