Second commit
This commit is contained in:
commit
36840f3ad4
999 files changed
+61364
No files matched your search
@@ -0,0 +1,181 @@
|
||||
//
|
||||
// This file is part of the Tremble package by Tiny Goose.
|
||||
// Copyright (c) 2024-2026 TinyGoose Ltd., All Rights Reserved.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TinyGoose.Tremble.Editor
|
||||
{
|
||||
[ManualPage("Debug/Sanity Check")]
|
||||
public class DebugSanityCheckPage : ManualPageBase
|
||||
{
|
||||
private PrefabNameLookup m_PrefabNameLookup;
|
||||
private MapTypeLookup m_MapTypeLookup;
|
||||
|
||||
private readonly Dictionary<Type, MonoScript> m_TypeToMonoScript = new();
|
||||
|
||||
private int m_SelectedTabIdx = 0;
|
||||
private readonly string[] m_TabNames = new[] { "Basics", "Entities" };
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
TrembleSyncSettings syncSettings = TrembleSyncSettings.Get();
|
||||
m_PrefabNameLookup = new(syncSettings);
|
||||
m_MapTypeLookup = new(syncSettings);
|
||||
}
|
||||
|
||||
protected override void OnGUI()
|
||||
{
|
||||
Tabs(ref m_SelectedTabIdx, m_TabNames);
|
||||
|
||||
switch (m_SelectedTabIdx)
|
||||
{
|
||||
case 0:
|
||||
OnBasicsGUI();
|
||||
break;
|
||||
case 1:
|
||||
OnEntitiesGUI();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBasicsGUI()
|
||||
{
|
||||
Text("This page will verify that Tremble is installed and working correctly!");
|
||||
|
||||
// TB?
|
||||
bool trenchBroomInstalled = !TrenchBroomUtil.TrenchBroomPath.IsNullOrEmpty();
|
||||
CheckListItem("TrenchBroom installed and detected?", trenchBroomInstalled);
|
||||
|
||||
if (!trenchBroomInstalled)
|
||||
{
|
||||
Callout("If TrenchBroom is installed, but not detected here, open it",
|
||||
"and Tremble should detect its location!");
|
||||
}
|
||||
|
||||
// Installed game into TB?
|
||||
bool gameFolderExists = Directory.Exists(TrenchBroomUtil.GetGameFolder());
|
||||
CheckListItem("TrenchBroom game folder exists?", gameFolderExists, "Sync to create it!", TrembleEditorAPI.SyncToTrenchBroom);
|
||||
|
||||
bool gameInstalledInTBPrefs = TrenchBroomUtil.DoesEnginePathExistInTrenchBroomPrefs();
|
||||
CheckListItem("TrenchBroom knows game location?", gameInstalledInTBPrefs, "Sync to create it!", TrembleEditorAPI.SyncToTrenchBroom);
|
||||
|
||||
// BaseQ3 folder
|
||||
bool baseQ3FolderExists = Directory.Exists(TrembleConsts.BASEQ3_PATH);
|
||||
CheckListItem("BaseQ3 folder exists in Library?", baseQ3FolderExists, "Sync to create it!", TrembleEditorAPI.SyncToTrenchBroom);
|
||||
|
||||
// DLL loaded?
|
||||
bool dllIsLoaded = Q3Map2Dll.IsLoaded;
|
||||
CheckListItem("Q3Map2 DLL loaded successfully?", dllIsLoaded);
|
||||
}
|
||||
|
||||
private void OnEntitiesGUI()
|
||||
{
|
||||
Foldout("Prefab Entities", () =>
|
||||
{
|
||||
Text("The following are the prefabs that Tremble knows about:");
|
||||
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
{
|
||||
foreach (string prefabPath in m_PrefabNameLookup.AllPrefabPaths)
|
||||
{
|
||||
GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(prefabPath);
|
||||
|
||||
m_PrefabNameLookup.TryGetMapNameFromPrefabPath(prefabPath, out string mapName);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.PrefixLabel(mapName);
|
||||
EditorGUILayout.ObjectField(prefab, typeof(GameObject), false);
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
});
|
||||
|
||||
Foldout("Point Entities", () =>
|
||||
{
|
||||
Text("The following are the [PointEntity] MonoBehaviours that Tremble knows about:");
|
||||
|
||||
bool wasAnyPresent = false;
|
||||
|
||||
foreach (Type type in m_MapTypeLookup.AllTypes)
|
||||
{
|
||||
if (!m_MapTypeLookup.TryGetMapNameFromClass(type, out string mapName))
|
||||
{
|
||||
Text($"Invalid: '{type.Name}' - no map name known!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!m_MapTypeLookup.TryGetEntityTypeFromMapName(mapName, out EntityType entityType) || entityType != EntityType.Point)
|
||||
continue;
|
||||
|
||||
DisabledTypeField(type, mapName);
|
||||
wasAnyPresent = true;
|
||||
}
|
||||
|
||||
if (!wasAnyPresent)
|
||||
{
|
||||
Text("There are none (which might be fine)!");
|
||||
}
|
||||
});
|
||||
|
||||
Foldout("Brush Entities", () =>
|
||||
{
|
||||
Text("The following are the [BrushEntity] MonoBehaviours that Tremble knows about:");
|
||||
bool wasAnyPresent = false;
|
||||
|
||||
foreach (Type type in m_MapTypeLookup.AllTypes)
|
||||
{
|
||||
if (!m_MapTypeLookup.TryGetMapNameFromClass(type, out string mapName))
|
||||
{
|
||||
Text($"Invalid: '{type.Name}' - no map name known!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!m_MapTypeLookup.TryGetEntityTypeFromMapName(mapName, out EntityType entityType) || entityType != EntityType.Brush)
|
||||
continue;
|
||||
|
||||
DisabledTypeField(type, mapName);
|
||||
wasAnyPresent = true;
|
||||
}
|
||||
|
||||
if (!wasAnyPresent)
|
||||
{
|
||||
Text("There are none (which might be fine)!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void DisabledTypeField(Type type, string label)
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
{
|
||||
if (!m_TypeToMonoScript.TryGetValue(type, out MonoScript monoScript))
|
||||
{
|
||||
GameObject go = new("Tester");
|
||||
MonoBehaviour mb = (MonoBehaviour)go.AddComponent(type);
|
||||
monoScript = MonoScript.FromMonoBehaviour(mb);
|
||||
m_TypeToMonoScript[type] = monoScript;
|
||||
|
||||
GameObject.DestroyImmediate(go);
|
||||
}
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUILayout.PrefixLabel(label);
|
||||
EditorGUILayout.ObjectField(monoScript, typeof(MonoScript), false);
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7c8885112604038b963d644ebbb4ead
|
||||
timeCreated: 1726483054
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 277805
|
||||
packageName: Tremble - Map Importer
|
||||
packageVersion: 1.11.1
|
||||
assetPath: Assets/Tremble/Editor/Manual/Pages/Debug/DebugSanityCheckPage.cs
|
||||
uploadId: 939664
|
||||
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// This file is part of the Tremble package by Tiny Goose.
|
||||
// Copyright (c) 2024-2026 TinyGoose Ltd., All Rights Reserved.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
|
||||
namespace TinyGoose.Tremble.Editor
|
||||
{
|
||||
[ManualPage("Debug/Entity Explorer")]
|
||||
public class DebugShowEntitiesPage : ManualPageBase
|
||||
{
|
||||
private FgdWriter m_FgdWriter;
|
||||
|
||||
private string[] m_ClassList;
|
||||
private int m_SelectedClassIdx = 0;
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
m_FgdWriter = TrembleSync.GatherEntities();
|
||||
|
||||
m_ClassList = m_FgdWriter.BaseClasses
|
||||
.Select(bc => $"@BaseClass {bc.Name}")
|
||||
.Concat(m_FgdWriter.Classes.Select(c => $"@{c.Type}Class {c.Name}"))
|
||||
.Prepend("(select a class...)")
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
protected override void OnGUI()
|
||||
{
|
||||
m_SelectedClassIdx = EditorGUILayout.Popup(m_SelectedClassIdx, m_ClassList);
|
||||
|
||||
int selectedClassIdx = m_SelectedClassIdx - 1;
|
||||
if (selectedClassIdx < 0)
|
||||
{
|
||||
Text("Select a class above to see its entity definition!");
|
||||
return;
|
||||
}
|
||||
|
||||
FgdClass entityClass = (selectedClassIdx < m_FgdWriter.BaseClasses.Count)
|
||||
? m_FgdWriter.BaseClasses[selectedClassIdx]
|
||||
: m_FgdWriter.Classes[selectedClassIdx - m_FgdWriter.BaseClasses.Count];
|
||||
|
||||
MemoryStream memoryStream = new();
|
||||
|
||||
// Write to memory
|
||||
using StreamWriter writer = new(memoryStream, Encoding.ASCII);
|
||||
entityClass.WriteFgd(writer, TrembleSyncSettings.Get().ImportScale);
|
||||
writer.Flush();
|
||||
|
||||
// Rewind and read
|
||||
memoryStream.Position = 0;
|
||||
using StreamReader reader = new(memoryStream, Encoding.ASCII);
|
||||
string snippet = reader.ReadToEnd().Replace("\t", " ");
|
||||
|
||||
CodeWithHeader($"[{entityClass.Type}] {entityClass.Name}", snippet);
|
||||
|
||||
Text("Above is how the entity is passed to TrenchBroom. If you're familiar with FGD files,",
|
||||
"this will look very familiar! If not, you basically are looking to make sure the name",
|
||||
"is what you would expect, and any fields that you wish to edit on entities of that",
|
||||
"class are present.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2dc49cc1fab340b8a6d97e6fbff9fe66
|
||||
timeCreated: 1726387089
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 277805
|
||||
packageName: Tremble - Map Importer
|
||||
packageVersion: 1.11.1
|
||||
assetPath: Assets/Tremble/Editor/Manual/Pages/Debug/DebugShowEntitiesPage.cs
|
||||
uploadId: 939664
|
||||
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// This file is part of the Tremble package by Tiny Goose.
|
||||
// Copyright (c) 2024-2026 TinyGoose Ltd., All Rights Reserved.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TinyGoose.Tremble.Editor
|
||||
{
|
||||
[ManualPage("Debug/Material Explorer")]
|
||||
public class DebugShowMaterialsPage : ManualPageBase
|
||||
{
|
||||
private readonly Dictionary<string, List<Texture>> m_Textures = new();
|
||||
|
||||
protected override void OnInit()
|
||||
{
|
||||
int texSize = TrembleSyncSettings.Get().MaterialExportSize.ToIntSize();
|
||||
|
||||
string texturesPath = TrembleConsts.BASE_MATERIALS_PATH;
|
||||
foreach (string dir in Directory.GetDirectories(texturesPath))
|
||||
{
|
||||
string[] pngFiles = Directory.GetFiles(dir, "*.png");
|
||||
if (pngFiles.Length == 0)
|
||||
continue;
|
||||
|
||||
List<Texture> textures = new(pngFiles.Length);
|
||||
|
||||
foreach (string textureFile in pngFiles)
|
||||
{
|
||||
byte[] textureBytes = File.ReadAllBytes(textureFile);
|
||||
|
||||
Texture2D texture = new(texSize, texSize);
|
||||
texture.name = Path.GetFileNameWithoutExtension(textureFile);
|
||||
texture.LoadImage(textureBytes);
|
||||
|
||||
textures.Add(texture);
|
||||
}
|
||||
|
||||
m_Textures[Path.GetFileName(dir)] = textures;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDeInit()
|
||||
{
|
||||
foreach (List<Texture> textures in m_Textures.Values)
|
||||
{
|
||||
foreach (Texture texture in textures)
|
||||
{
|
||||
Texture.DestroyImmediate(texture);
|
||||
}
|
||||
}
|
||||
|
||||
m_Textures.Clear();
|
||||
}
|
||||
|
||||
protected override void OnGUI()
|
||||
{
|
||||
float thumbnailSize = 64f * ManualStyles.Scale;
|
||||
float labelSize = thumbnailSize + 40f * ManualStyles.Scale;
|
||||
int numWide = Mathf.Max(1, Mathf.FloorToInt(PageWidth / labelSize) - 2);
|
||||
|
||||
foreach (string textureFolder in m_Textures.Keys)
|
||||
{
|
||||
H1(textureFolder);
|
||||
{
|
||||
int cell = 0;
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
foreach (Texture texture in m_Textures[textureFolder])
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
{
|
||||
GUILayout.BeginHorizontal(GUILayout.Width(labelSize));
|
||||
{
|
||||
GUILayout.Space((labelSize - thumbnailSize) / 2f);
|
||||
GUIContent content = new(texture, texture.name);
|
||||
GUILayout.Box(content, GUILayout.Width(thumbnailSize), GUILayout.Height(thumbnailSize));
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Label(texture.name, ManualStyles.Styles.CenteredGreyMiniLabel, GUILayout.Width(labelSize));
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// New row?
|
||||
if (++cell >= numWide)
|
||||
{
|
||||
cell = 0;
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.Space(1f);
|
||||
GUILayout.BeginHorizontal();
|
||||
}
|
||||
}
|
||||
|
||||
if (cell <= numWide)
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1d737f97a4f45c193f15ac0551af98e
|
||||
timeCreated: 1726390246
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 277805
|
||||
packageName: Tremble - Map Importer
|
||||
packageVersion: 1.11.1
|
||||
assetPath: Assets/Tremble/Editor/Manual/Pages/Debug/DebugShowMaterialsPage.cs
|
||||
uploadId: 939664
|
||||
Reference in new issue
Block a user