74 lines
1.9 KiB
C#
74 lines
1.9 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BITKit;
|
|
using BITKit.GameEditor;
|
|
using BITKit.UX;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace BITFALL.LootSystem
|
|
{
|
|
public class LootTableEditor : ScriptableObjectGroupEditor<ScriptableLootTable>
|
|
{
|
|
protected override string AssetsPath => "Assets/Artists/Configs/LootSystem/";
|
|
[MenuItem("Tools/ScriptableObjectEditor/LootTable Editor")]
|
|
public static void Open()
|
|
{
|
|
var window = GetWindow<LootTableEditor>();
|
|
window.titleContent = new GUIContent("LootTable Editor");
|
|
|
|
window.Show();
|
|
}
|
|
protected override void BindItem(VisualElement arg1, int arg2)
|
|
{
|
|
var item = List[arg2];
|
|
var container = new UXContainer(arg1);
|
|
|
|
arg1.userData = item;
|
|
|
|
container.contextLabel.text = item.Name;
|
|
container.icon.style.backgroundImage = item.Icon;
|
|
|
|
var color = ScriptableItem.GetQualityColor(item.Quality);
|
|
color.a = 0.2f;
|
|
arg1.style.backgroundColor = color;
|
|
}
|
|
|
|
protected override void ItemsChosen(IEnumerable<object> obj)
|
|
{
|
|
base.ItemsChosen(obj);
|
|
var selected = obj.FirstOrDefault() as ScriptableLootTable;
|
|
var icons = _container.Create<VisualElement>();
|
|
icons.style.flexDirection = FlexDirection.Row;
|
|
foreach (var table in selected.Tables)
|
|
{
|
|
try
|
|
{
|
|
var container = icons.Create<VisualElement>();
|
|
var icon = container.Create<VisualElement>();
|
|
|
|
container.style.flexDirection = FlexDirection.Column;
|
|
|
|
icon.style.backgroundImage = table.Item.SquareIcon;
|
|
icon.style.width = 64;
|
|
icon.style.height = 64;
|
|
|
|
var progressBar = container.Create<ProgressBar>();
|
|
progressBar.title = table.Item.Name;
|
|
progressBar.value = table.Probability;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.LogException(e);
|
|
}
|
|
|
|
}
|
|
icons.BringToFront();
|
|
}
|
|
}
|
|
}
|
|
|