External Database Entries + Name File Cleaning + Faction Allegiance
DatabaseCache now reads and stores entry types marked ExternalEntry from separate files in their own folder Updated name file cleaning code and re-cleaned name files Disabled planet generation (very slow) Fixed wormhole traversal - can now explore galaxy Added faction allegiance matrix and slider inspector code
This commit is contained in:
parent
73651bf16a
commit
d8127c2240
84 changed files with 411 additions and 843 deletions
|
|
@ -199,7 +199,10 @@ public class DatabaseInspector : EditorWindow
|
|||
else if (type == typeof(Dictionary<Guid, float>))
|
||||
{
|
||||
var dict = (Dictionary<Guid, float>) field.GetValue(obj);
|
||||
Inspect(field.Name.SplitCamelCase(), ref dict, link.EntryType);
|
||||
var ranged = field.GetCustomAttribute<RangedFloatAttribute>();
|
||||
if(ranged != null)
|
||||
Inspect(field.Name.SplitCamelCase(), ref dict, link.EntryType, ranged.Min, ranged.Max);
|
||||
else Inspect(field.Name.SplitCamelCase(), ref dict, link.EntryType);
|
||||
}
|
||||
else if (type == typeof(List<BlueprintStatEffect>))
|
||||
{
|
||||
|
|
@ -851,6 +854,65 @@ public class DatabaseInspector : EditorWindow
|
|||
}
|
||||
}
|
||||
|
||||
public void Inspect(string label, ref Dictionary<Guid,float> value, Type referenceType, float min, float max)
|
||||
{
|
||||
Space();
|
||||
LabelField(label, EditorStyles.boldLabel);
|
||||
|
||||
using (var v = new VerticalScope(GUI.skin.box))
|
||||
{
|
||||
if (value.Count == 0)
|
||||
{
|
||||
using (var h = new HorizontalScope(_list.ListItemStyle))
|
||||
{
|
||||
GUILayout.Label("Drag from list to add item");
|
||||
}
|
||||
}
|
||||
foreach (var ingredient in value.ToArray())
|
||||
{
|
||||
using (var h = new HorizontalScope(_list.ListItemStyle))
|
||||
{
|
||||
var entry = DatabaseCache.Get(ingredient.Key);
|
||||
if (entry == null)
|
||||
{
|
||||
value.Remove(ingredient.Key);
|
||||
GUI.changed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(entry is INamedEntry named)
|
||||
GUILayout.Label(named.EntryName);
|
||||
else GUILayout.Label(entry.ID.ToString());
|
||||
value[ingredient.Key] = Slider(value[ingredient.Key], min, max);
|
||||
|
||||
var rect = GetControlRect(false, GUILayout.Width(EditorGUIUtility.singleLineHeight));
|
||||
GUI.DrawTexture(rect, Icons.Instance.minus, ScaleMode.StretchToFill, true, 1, LabelColor, 0, 0);
|
||||
if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
|
||||
value.Remove(ingredient.Key);
|
||||
}
|
||||
}
|
||||
|
||||
if (v.rect.Contains(Event.current.mousePosition))
|
||||
{
|
||||
var dragData = DragAndDrop.GetGenericData("Item");
|
||||
var isId = dragData is Guid guid;
|
||||
var dragEntry = isId ? DatabaseCache.Get(guid) : null;
|
||||
var correctType = referenceType.IsInstanceOfType(dragEntry);
|
||||
if(Event.current.type == EventType.DragUpdated)
|
||||
DragAndDrop.visualMode = correctType ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.Rejected;
|
||||
else if(Event.current.type == EventType.DragPerform)
|
||||
{
|
||||
if (isId && correctType)
|
||||
{
|
||||
DragAndDrop.AcceptDrag();
|
||||
value[guid] = max;
|
||||
GUI.changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Inspect(string label, ref List<Guid> value, Type entryType)
|
||||
{
|
||||
Space();
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class DatabaseListView : EditorWindow
|
|||
{
|
||||
//_filePath = ;
|
||||
// Create database cache
|
||||
_databaseCache = new DatabaseCache();
|
||||
_databaseCache = new DatabaseCache(_filePath);
|
||||
|
||||
var onInsert = new Action<DatabaseEntry>(entry =>
|
||||
{
|
||||
|
|
@ -162,16 +162,16 @@ public class DatabaseListView : EditorWindow
|
|||
}
|
||||
using (var h = new HorizontalScope())
|
||||
{
|
||||
_fileName = TextField(_fileName);
|
||||
//_fileName = TextField(_fileName);
|
||||
if (GUILayout.Button("Save"))
|
||||
{
|
||||
_databaseCache.Save(_filePath);
|
||||
_databaseCache.Save();
|
||||
Debug.Log("Local DB Cache Saved!");
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Load"))
|
||||
{
|
||||
_databaseCache.Load(_filePath);
|
||||
_databaseCache.Load();
|
||||
Debug.Log("Loaded DB From Local Cache!");
|
||||
}
|
||||
}
|
||||
|
|
@ -411,7 +411,7 @@ public class DatabaseListView : EditorWindow
|
|||
}
|
||||
}
|
||||
|
||||
var entries = _databaseCache.AllEntries.Where(item => !(item is ItemData)).ToArray();
|
||||
//var entries = _databaseCache.AllEntries.Where(item => !(item is ItemData)).ToArray();
|
||||
for (var i = 0; i < _entryTypes.Length; i++)
|
||||
{
|
||||
using (var h = new HorizontalScope(ListItemStyle))
|
||||
|
|
@ -424,7 +424,7 @@ public class DatabaseListView : EditorWindow
|
|||
if (_entryFoldouts[i])
|
||||
{
|
||||
int index = 0;
|
||||
foreach (var entry in entries.Where(e=>e.GetType()==_entryTypes[i]).OrderBy(entry=>entry is INamedEntry namedEntry ? namedEntry.EntryName : entry.ID.ToString()))
|
||||
foreach (var entry in _databaseCache.GetAll(_entryTypes[i]).OrderBy(entry=>entry is INamedEntry namedEntry ? namedEntry.EntryName : entry.ID.ToString()))
|
||||
{
|
||||
index++;
|
||||
var style = ListItemStyle;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using MessagePack;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
|
@ -28,6 +29,11 @@ public class NameTools : EditorWindow
|
|||
NameTools window = (NameTools)EditorWindow.GetWindow(typeof(NameTools));
|
||||
window.Show();
|
||||
}
|
||||
|
||||
bool HasNonASCIIChars(string str)
|
||||
{
|
||||
return (System.Text.Encoding.UTF8.GetByteCount(str) != str.Length);
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
|
|
@ -40,14 +46,17 @@ public class NameTools : EditorWindow
|
|||
|
||||
if (GUILayout.Button("Save Name Files"))
|
||||
{
|
||||
var database = new DatabaseCache();
|
||||
RegisterResolver.Register();
|
||||
var nameFilesDirectory = ActionGameManager.GameDataDirectory.CreateSubdirectory("NameFile");
|
||||
foreach (var nameFile in NameFiles)
|
||||
{
|
||||
var entry = new NameFile();
|
||||
entry.Names = nameFile.text.Split('\n');
|
||||
database.Add(entry);
|
||||
var entry = new NameFile
|
||||
{
|
||||
Name = nameFile.name,
|
||||
Names = nameFile.text.Split('\n')
|
||||
};
|
||||
File.WriteAllBytes(Path.Combine(nameFilesDirectory.FullName, $"{entry.ID.ToString()}.msgpack"), MessagePackSerializer.Serialize((DatabaseEntry) entry));
|
||||
}
|
||||
database.Save(Path.Combine(ActionGameManager.GameDataDirectory.FullName, "Names.msgpack"));
|
||||
}
|
||||
|
||||
nameFile = (TextAsset) EditorGUILayout.ObjectField("Name File", nameFile, typeof(TextAsset), false);
|
||||
|
|
@ -61,22 +70,20 @@ public class NameTools : EditorWindow
|
|||
{
|
||||
var lines = nameFile.text.Split('\n');
|
||||
using StreamWriter outputFile = new StreamWriter(Path.Combine(Application.dataPath, nameFile.name + ".csv"));
|
||||
var names = new HashSet<string>();
|
||||
foreach (var line in lines)
|
||||
{
|
||||
if (!_stripNumberTokens)
|
||||
var tokens = line.Split(',', ' ');
|
||||
foreach (var t in tokens)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(line) && Regex.IsMatch(line, "^[\\x00-\\x7F]+$") && !char.IsDigit(line[0]))
|
||||
if (!HasNonASCIIChars(t))
|
||||
{
|
||||
outputFile.WriteLine(line.Trim());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var tokens = line.Split('_', '-', ' ');
|
||||
if(!(tokens.Any(t => t.Length == 2 && char.IsUpper(t[0]) && char.IsUpper(t[1]))))
|
||||
//if (Regex.IsMatch(line, "^[\\x00-\\x7F]+$") && !tokens.Any(t=>int.TryParse(t, out _)) && !tokens.Any(t=>t=="AM"||t=="FM"||t=="TV"))
|
||||
{
|
||||
outputFile.WriteLine(line.Trim());
|
||||
var s = new string(t.Where(c => char.IsLetter(c) || c == '-' || c == '`' || c == '\'').ToArray()).Trim().Trim('`','-');
|
||||
if(s.Length >= minWordLength && !names.Contains(s))
|
||||
{
|
||||
names.Add(s);
|
||||
outputFile.WriteLine(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue