Handbuch Scroll-Listen entfernt. Handbuch offen und tabs eingefügt. Upgrades eingefügt. "Garage" eingefügt. Anbindung eines echten Gameplaymanager möglich (theoretisch)

This commit is contained in:
2026-10-15 03:24:48 +02:00
parent dadd1fcad0
commit 5486444dde
132 changed files with 55540 additions and 4807 deletions
@@ -0,0 +1,49 @@
using System;
using System.Linq;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.UI;
using DepthsOfGreed.HandbookUI;
[InitializeOnLoad]
public static class HandbookInspectorValidation
{
static HandbookInspectorValidation(){if(SessionState.GetBool("InspectorValidation",false))EditorApplication.playModeStateChanged+=Ready;}
public static void Validate()
{
try
{
var scene=EditorSceneManager.OpenScene("Assets/Scenes/Tim_Test_UI.unity");
var main=UnityEngine.Object.FindFirstObjectByType<HandbookController>(FindObjectsInactive.Include);var root=main.transform;
if(!root.Find("GeneralFeedback")||!root.Find("OpenBook/ActiveTabLayer"))throw new Exception("Missing permanent UI.");
if(root.GetComponentsInChildren<ScrollRect>(true).Length>0)throw new Exception("Scroll views remain in handbook.");
var index=UnityEngine.Object.FindFirstObjectByType<HandbookIndexController>(FindObjectsInactive.Include);var iso=new SerializedObject(index);
if(iso.FindProperty("entryButtons").arraySize!=24||iso.FindProperty("filterButtons").arraySize!=5)throw new Exception("Index inspector references invalid");
var build=UnityEngine.Object.FindFirstObjectByType<BuildMenuController>(FindObjectsInactive.Include);if(new SerializedObject(build).FindProperty("categoryButtons").arraySize!=4)throw new Exception("Four build categories missing");
foreach(var sceneRoot in scene.GetRootGameObjects())foreach(var tr in sceneRoot.GetComponentsInChildren<Transform>(true))if(GameObjectUtility.GetMonoBehavioursWithMissingScriptCount(tr.gameObject)>0)throw new Exception("Missing script: "+tr.name);
var authorCount=root.GetComponentsInChildren<RectTransform>(true).Count(r=>!r.name.StartsWith("TMP"));SessionState.SetInt("InspectorRectCount",authorCount);
SessionState.SetBool("InspectorValidation",true);EditorApplication.playModeStateChanged+=Ready;EditorApplication.EnterPlaymode();
}catch(Exception e){Debug.LogException(e);EditorApplication.Exit(1);}
}
private static void Ready(PlayModeStateChange state)
{
if(state!=PlayModeStateChange.EnteredPlayMode)return;SessionState.SetBool("InspectorValidation",false);EditorApplication.playModeStateChanged-=Ready;EditorApplication.delayCall+=Run;
}
private static void Run()
{
try
{
var c=UnityEngine.Object.FindFirstObjectByType<HandbookController>();c.Open(0);var root=c.transform;
if(root.GetComponentsInChildren<RectTransform>(true).Count(r=>!r.name.StartsWith("TMP"))!=SessionState.GetInt("InspectorRectCount",0))throw new Exception("UI generated at runtime");
var menu=UnityEngine.Object.FindFirstObjectByType<BuildMenuController>();int[] expected={6,6,3,4};for(int i=0;i<4;i++){menu.SelectCategory(i);if(menu.GetComponentsInChildren<TowerCardView>().Length!=expected[i])throw new Exception("Category count incorrect: "+i);}
var p=root.GetComponent<TestPlacementController>();var catalog=AssetDatabase.LoadAssetAtPath<HandbookTowerCatalog>("Assets/HandbookData/TestTurmkatalog.asset");var gun=catalog.towers.First(t=>t.id=="ammo_0");var energy=catalog.towers.First(t=>t.id=="energy_0");
if(!p.Backend.ExecuteBuild(new BuildRequest(gun,new Vector3(3.5f,0,0))).Allowed||!p.Backend.ExecuteBuild(new BuildRequest(energy,new Vector3(0,3.5f,0))).Allowed)throw new Exception("Base placement failed");
var obj=p.Backend.BuiltObjects[0].instance;var renderer=obj.GetComponent<SpriteRenderer>();if(!renderer || !renderer.sprite || (gun.baseSprite && renderer.sprite!=gun.baseSprite) || renderer.bounds.size.x>0.8f)throw new Exception("Base sprite or placeholder scaling incorrect");
int before=p.Backend.Energy;if(!p.Backend.ExecuteUpgrade(p.Backend.BuiltObjects[0].instanceId).Allowed||p.Backend.Energy>=before)throw new Exception("Upgrade failed");
c.Open(2);var upgrades=UnityEngine.Object.FindFirstObjectByType<HandbookUpgradesController>();if(upgrades.VisibleUpgradeCount!=2)throw new Exception("Upgrade listing failed");
c.Open(3);var index=UnityEngine.Object.FindFirstObjectByType<HandbookIndexController>();if(index.VisibleEntryCount!=24)throw new Exception("All entries not displayed");int[] counts={24,12,3,4,5};for(int i=0;i<5;i++){index.SelectFilter(i);if(index.VisibleEntryCount!=counts[i])throw new Exception("Index filter count incorrect");}
index.SelectEntry(0);if(!index.SelectedEnemy)throw new Exception("Enemy detail missing");c.Open(0);c.Open(3);if(index.SelectedEnemy||index.SelectedEntry)throw new Exception("Index selection not reset");
c.Close();Debug.Log("INSPECTOR_RUNTIME_VALIDATION_OK: no runtime UI generation, sprites, 4 build categories, 5 index filters, bases, placement and upgrades passed.");EditorApplication.Exit(0);
}catch(Exception e){Debug.LogException(e);EditorApplication.Exit(1);}
}
}