// Copyright (c) Microsoft Corporation. 
// Licensed under the MIT license. 

using Simplygon.Unity;
using SimplygonUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEditor.IMGUI.Controls;
using UnityEngine;

namespace SimplygonUI
{
    public class SimplygonCascadedLODDropdownFactory
    {
        ISimplygonPipelineDropdownCallback Callback;
        public SimplygonCascadedLODDropdownFactory(ISimplygonPipelineDropdownCallback callback)
        {
            Callback = callback;
        }

        public void BuildItems(GenericMenu menu)
        {           
            foreach (var pipeline in SimplygonPipelineDatabase.PipelineTemplates)
            {
                string menuPath = "Cascaded LOD/" + pipeline.MenuPath;
                menu.AddItem(new GUIContent(menuPath), false, OnItemSelected, pipeline);
            }
        }

        void OnItemSelected(object item)
        {
            Callback.NewCascadedLODComponentSelected(item as SimplygonPipeline);
        }
    }
}
