Modular Database Tools
Extracted all inspector code for database inspector into a single class per supported field type and wrote reflection code to invoke them automatically Removed all Aetheria-specific code from database tools Database View editor is now abstract and supports arbitrary grouping of entry types; specific users must implement their own database view
This commit is contained in:
parent
48759380c5
commit
526a737a4d
72 changed files with 1674 additions and 1624 deletions
46
Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs
Normal file
46
Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class AetheriaDatabaseView : DatabaseListView
|
||||
{
|
||||
// Singleton to avoid multiple instances of window.
|
||||
private static DatabaseListView _instance;
|
||||
private string tableName;
|
||||
public static DatabaseListView Instance => _instance ? _instance : GetWindow<AetheriaDatabaseView>();
|
||||
[MenuItem("Window/Aetheria/Database Tools")]
|
||||
static void Init() => Instance.Show();
|
||||
private void Awake()
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
protected override string DatabaseName => "Aetheria";
|
||||
|
||||
protected override string FilePath => Path.Combine(new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData").FullName, "AetherDB.msgpack");
|
||||
|
||||
protected override DatabaseEntryGroup[] Groupers => new DatabaseEntryGroup[]
|
||||
{
|
||||
new DatabaseEntryGroup<SimpleCommodityData,SimpleCommodityCategory>(
|
||||
data => data.Category,
|
||||
category => Enum.GetName(typeof(SimpleCommodityCategory), category),
|
||||
(data, category) => data.Category = category ),
|
||||
new DatabaseEntryGroup<CompoundCommodityData, CompoundCommodityCategory>(
|
||||
data => data.Category,
|
||||
category => Enum.GetName(typeof(CompoundCommodityCategory), category),
|
||||
(data, category) => data.Category = category ),
|
||||
new DatabaseEntryGroup<GearData, HardpointType>(
|
||||
data => data.HardpointType,
|
||||
type => Enum.GetName(typeof(HardpointType), type),
|
||||
(data, type) => data.Hardpoint = type),
|
||||
// new DatabaseEntryGroup<GearData, Guid>(
|
||||
// data => data.Manufacturer,
|
||||
// factionID => cultCache.Get<Faction>(factionID).ShortName,
|
||||
// (data, faction) => data.Manufacturer = faction),
|
||||
new DatabaseEntryGroup<HullData, HullType>(
|
||||
data => data.HullType,
|
||||
type => Enum.GetName(typeof(HullType), type),
|
||||
(data, type) => data.HullType = type)
|
||||
};
|
||||
}
|
||||
Loading…
Reference in a new issue