From 16b23bdc0f00d6134728514de73a4c0e85c081ad Mon Sep 17 00:00:00 2001 From: MaZiFAU <marco.alexander.zimmer@fau.de> Date: Tue, 14 Sep 2021 02:49:02 +0200 Subject: [PATCH] Fixed various introduced UI and load/store bugs --- .../UI/MainMenue/CollapsableStage.meta} | 2 +- .../CollapsableEntryCategory.prefab | 23 +++ .../CollapsableEntryCategory.prefab.meta | 0 .../CollapsableEntryStage.prefab | 21 +++ .../CollapsableEntryStage.prefab.meta | 0 .../{ => CollapsableStage}/TimeEntry.prefab | 41 +++++ .../TimeEntry.prefab.meta | 0 Assets/Scenes/Menues/MainMenue.unity | 103 ++++++++++-- Assets/Scripts/GameObjectExtensions.cs | 6 + Assets/Scripts/GenerateDemoFiles.cs | 6 +- Assets/Scripts/GlobalBehaviour.cs | 26 ++++ .../TaskCharakterAnimation.cs | 1 + .../FactHandling/FactOrganizer.cs | 5 + .../FactHandling/SolutionOrganizer.cs | 27 ++-- Assets/Scripts/Loading/Stage.cs | 59 ++++--- Assets/Scripts/Restart.cs | 2 +- Assets/Scripts/UI/InputFieldResizeFix.cs | 30 ---- .../UI/MainMenue/CollapsableStage.meta} | 2 +- .../CollapsableStage/CollapsableCategory.cs | 57 +++++++ .../CollapsableCategory.cs.meta} | 2 +- .../CollapsableStage/CollapsableStage.cs | 75 +++++++++ .../CollapsableStage.cs.meta} | 2 +- Assets/Scripts/UI/MainMenue/LegBarSizer.cs | 35 ----- Assets/Scripts/UI/MainMenue/ListLoader.cs | 3 +- .../UI/MainMenue/PageLoader.meta} | 2 +- .../{ => PageLoader}/CreateLoader.cs | 0 .../{ => PageLoader}/CreateLoader.cs.meta | 0 .../MainMenue/{ => PageLoader}/EditLoader.cs | 2 + .../{ => PageLoader}/EditLoader.cs.meta | 0 .../MainMenue/{ => PageLoader}/LocalLoader.cs | 0 .../{ => PageLoader}/LocalLoader.cs.meta | 0 .../UI/MainMenue/PageLoader/StageLoader.cs | 80 ++++++++++ .../{ => PageLoader}/StageLoader.cs.meta | 0 Assets/Scripts/UI/MainMenue/StageLoader.cs | 147 ------------------ Assets/Scripts/UI/UIToolBox.cs | 12 ++ Assets/Scripts/UI/UIToolBox.cs.meta | 11 ++ Assets/Stages/TechDemo A.JSON | 2 +- .../FactStateMachines/TechDemo A_sol.JSON | 2 +- .../ValidationSets/Stages/Stages/Stages.meta | 8 - .../Stages/Stages/Stages/Stages.meta | 8 - .../Stages/Stages/Stages/ValidationSets.meta | 8 - .../Stages/Stages/Stages/ValidationSets.meta | 8 - .../Stages/Stages/ValidationSets.meta | 8 - .../ValidationSets/Stages/ValidationSets.meta | 8 - .../Stages/ValidationSets/TechDemo A_val.JSON | 2 +- 45 files changed, 519 insertions(+), 317 deletions(-) rename Assets/{Stages/FactStateMachines.meta => Resources/Prefabs/UI/MainMenue/CollapsableStage.meta} (77%) rename Assets/Resources/Prefabs/UI/MainMenue/{ => CollapsableStage}/CollapsableEntryCategory.prefab (96%) rename Assets/Resources/Prefabs/UI/MainMenue/{ => CollapsableStage}/CollapsableEntryCategory.prefab.meta (100%) rename Assets/Resources/Prefabs/UI/MainMenue/{ => CollapsableStage}/CollapsableEntryStage.prefab (98%) rename Assets/Resources/Prefabs/UI/MainMenue/{ => CollapsableStage}/CollapsableEntryStage.prefab.meta (100%) rename Assets/Resources/Prefabs/UI/MainMenue/{ => CollapsableStage}/TimeEntry.prefab (94%) rename Assets/Resources/Prefabs/UI/MainMenue/{ => CollapsableStage}/TimeEntry.prefab.meta (100%) delete mode 100644 Assets/Scripts/UI/InputFieldResizeFix.cs rename Assets/{Stages/ValidationSets/Stages/Stages.meta => Scripts/UI/MainMenue/CollapsableStage.meta} (77%) create mode 100644 Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableCategory.cs rename Assets/Scripts/UI/{InputFieldResizeFix.cs.meta => MainMenue/CollapsableStage/CollapsableCategory.cs.meta} (83%) create mode 100644 Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableStage.cs rename Assets/Scripts/UI/MainMenue/{LegBarSizer.cs.meta => CollapsableStage/CollapsableStage.cs.meta} (83%) delete mode 100644 Assets/Scripts/UI/MainMenue/LegBarSizer.cs rename Assets/{Stages/ValidationSets/Stages.meta => Scripts/UI/MainMenue/PageLoader.meta} (77%) rename Assets/Scripts/UI/MainMenue/{ => PageLoader}/CreateLoader.cs (100%) rename Assets/Scripts/UI/MainMenue/{ => PageLoader}/CreateLoader.cs.meta (100%) rename Assets/Scripts/UI/MainMenue/{ => PageLoader}/EditLoader.cs (97%) rename Assets/Scripts/UI/MainMenue/{ => PageLoader}/EditLoader.cs.meta (100%) rename Assets/Scripts/UI/MainMenue/{ => PageLoader}/LocalLoader.cs (100%) rename Assets/Scripts/UI/MainMenue/{ => PageLoader}/LocalLoader.cs.meta (100%) create mode 100644 Assets/Scripts/UI/MainMenue/PageLoader/StageLoader.cs rename Assets/Scripts/UI/MainMenue/{ => PageLoader}/StageLoader.cs.meta (100%) delete mode 100644 Assets/Scripts/UI/MainMenue/StageLoader.cs create mode 100644 Assets/Scripts/UI/UIToolBox.cs create mode 100644 Assets/Scripts/UI/UIToolBox.cs.meta delete mode 100644 Assets/Stages/ValidationSets/Stages/Stages/Stages.meta delete mode 100644 Assets/Stages/ValidationSets/Stages/Stages/Stages/Stages.meta delete mode 100644 Assets/Stages/ValidationSets/Stages/Stages/Stages/Stages/ValidationSets.meta delete mode 100644 Assets/Stages/ValidationSets/Stages/Stages/Stages/ValidationSets.meta delete mode 100644 Assets/Stages/ValidationSets/Stages/Stages/ValidationSets.meta delete mode 100644 Assets/Stages/ValidationSets/Stages/ValidationSets.meta diff --git a/Assets/Stages/FactStateMachines.meta b/Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage.meta similarity index 77% rename from Assets/Stages/FactStateMachines.meta rename to Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage.meta index bde44ccc..d1184e6c 100644 --- a/Assets/Stages/FactStateMachines.meta +++ b/Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 60737ee80d900fc4b90e982765cf8fb3 +guid: c1e1e7867a771bf4a83d36e6ecd834a4 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Resources/Prefabs/UI/MainMenue/CollapsableEntryCategory.prefab b/Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/CollapsableEntryCategory.prefab similarity index 96% rename from Assets/Resources/Prefabs/UI/MainMenue/CollapsableEntryCategory.prefab rename to Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/CollapsableEntryCategory.prefab index 61aaabf3..86f91347 100644 --- a/Assets/Resources/Prefabs/UI/MainMenue/CollapsableEntryCategory.prefab +++ b/Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/CollapsableEntryCategory.prefab @@ -1,5 +1,22 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!114 &3259043428413803609 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2444503959598721769} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3fcacb84a86b74c45a2090ce06b71175, type: 3} + m_Name: + m_EditorClassIdentifier: + StageEntry: {fileID: 0} + StageEntryEntry: {fileID: 0} + pageMenue: {fileID: 0} + editLoader: {fileID: 0} + category: --- !u!1001 &6380381401396681238 PrefabInstance: m_ObjectHideFlags: 0 @@ -549,3 +566,9 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 6dc910db2c2bdcd4e8105fa00766c3d4, type: 3} +--- !u!1 &2444503959598721769 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 8748018465994502399, guid: 6dc910db2c2bdcd4e8105fa00766c3d4, + type: 3} + m_PrefabInstance: {fileID: 6380381401396681238} + m_PrefabAsset: {fileID: 0} diff --git a/Assets/Resources/Prefabs/UI/MainMenue/CollapsableEntryCategory.prefab.meta b/Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/CollapsableEntryCategory.prefab.meta similarity index 100% rename from Assets/Resources/Prefabs/UI/MainMenue/CollapsableEntryCategory.prefab.meta rename to Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/CollapsableEntryCategory.prefab.meta diff --git a/Assets/Resources/Prefabs/UI/MainMenue/CollapsableEntryStage.prefab b/Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/CollapsableEntryStage.prefab similarity index 98% rename from Assets/Resources/Prefabs/UI/MainMenue/CollapsableEntryStage.prefab rename to Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/CollapsableEntryStage.prefab index f1620572..39fffbe5 100644 --- a/Assets/Resources/Prefabs/UI/MainMenue/CollapsableEntryStage.prefab +++ b/Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/CollapsableEntryStage.prefab @@ -354,6 +354,21 @@ MonoBehaviour: m_FillOrigin: 0 m_UseSpriteMesh: 0 m_PixelsPerUnitMultiplier: 1 +--- !u!114 &2547866500428565422 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 983654862871083802} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 420d4b6a812c99041b2ff63b2453fefb, type: 3} + m_Name: + m_EditorClassIdentifier: + TimeEntry: {fileID: 0} + pageMenue: {fileID: 0} + editLoader: {fileID: 0} --- !u!1001 &8413164531234950117 PrefabInstance: m_ObjectHideFlags: 0 @@ -1003,6 +1018,12 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 6dc910db2c2bdcd4e8105fa00766c3d4, type: 3} +--- !u!1 &983654862871083802 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 8748018465994502399, guid: 6dc910db2c2bdcd4e8105fa00766c3d4, + type: 3} + m_PrefabInstance: {fileID: 8413164531234950117} + m_PrefabAsset: {fileID: 0} --- !u!224 &507155778653363898 stripped RectTransform: m_CorrespondingSourceObject: {fileID: 8343014991989265759, guid: 6dc910db2c2bdcd4e8105fa00766c3d4, diff --git a/Assets/Resources/Prefabs/UI/MainMenue/CollapsableEntryStage.prefab.meta b/Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/CollapsableEntryStage.prefab.meta similarity index 100% rename from Assets/Resources/Prefabs/UI/MainMenue/CollapsableEntryStage.prefab.meta rename to Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/CollapsableEntryStage.prefab.meta diff --git a/Assets/Resources/Prefabs/UI/MainMenue/TimeEntry.prefab b/Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/TimeEntry.prefab similarity index 94% rename from Assets/Resources/Prefabs/UI/MainMenue/TimeEntry.prefab rename to Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/TimeEntry.prefab index 8c713ce7..f70d1930 100644 --- a/Assets/Resources/Prefabs/UI/MainMenue/TimeEntry.prefab +++ b/Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/TimeEntry.prefab @@ -633,6 +633,41 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: -13.065 objectReference: {fileID: 0} + - target: {fileID: 4043698117328085968, guid: 59f7a79ac29f866409b5e8c706608c90, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4043698117328085968, guid: 59f7a79ac29f866409b5e8c706608c90, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode + value: 6 + objectReference: {fileID: 0} + - target: {fileID: 4043698117328085968, guid: 59f7a79ac29f866409b5e8c706608c90, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: 6153207595148985677} + - target: {fileID: 4043698117328085968, guid: 59f7a79ac29f866409b5e8c706608c90, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_CallState + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 4043698117328085968, guid: 59f7a79ac29f866409b5e8c706608c90, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: SetActive + objectReference: {fileID: 0} + - target: {fileID: 4043698117328085968, guid: 59f7a79ac29f866409b5e8c706608c90, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName + value: UnityEngine.GameObject, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 4043698117328085968, guid: 59f7a79ac29f866409b5e8c706608c90, + type: 3} + propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} - target: {fileID: 4498381424378036452, guid: 59f7a79ac29f866409b5e8c706608c90, type: 3} propertyPath: m_AnchorMax.y @@ -860,6 +895,12 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 59f7a79ac29f866409b5e8c706608c90, type: 3} +--- !u!1 &6153207595148985677 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 2501937192852105333, guid: 59f7a79ac29f866409b5e8c706608c90, + type: 3} + m_PrefabInstance: {fileID: 8636847635352710456} + m_PrefabAsset: {fileID: 0} --- !u!224 &6153207595148985676 stripped RectTransform: m_CorrespondingSourceObject: {fileID: 2501937192852105332, guid: 59f7a79ac29f866409b5e8c706608c90, diff --git a/Assets/Resources/Prefabs/UI/MainMenue/TimeEntry.prefab.meta b/Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/TimeEntry.prefab.meta similarity index 100% rename from Assets/Resources/Prefabs/UI/MainMenue/TimeEntry.prefab.meta rename to Assets/Resources/Prefabs/UI/MainMenue/CollapsableStage/TimeEntry.prefab.meta diff --git a/Assets/Scenes/Menues/MainMenue.unity b/Assets/Scenes/Menues/MainMenue.unity index e5f073ef..ec74b6b5 100644 --- a/Assets/Scenes/Menues/MainMenue.unity +++ b/Assets/Scenes/Menues/MainMenue.unity @@ -6982,7 +6982,7 @@ RectTransform: m_LocalScale: {x: 2.4, y: 2.4, z: 2.4} m_Children: - {fileID: 1760706876} - - {fileID: 1843387534} + - {fileID: 2501937192093277432} - {fileID: 321148490} m_Father: {fileID: 1409078451} m_RootOrder: 0 @@ -7015,8 +7015,6 @@ MonoBehaviour: EntryTime: {fileID: 6153207595148985677, guid: 1c1c6c2f9f2a4434ca1b3e55000a10d2, type: 3} editLoader: {fileID: 593140110} - Accomplished: {r: 0.41960785, g: 0.5686275, b: 0, a: 0.39215687} - NotYetAccomplished: {r: 0.3254902, g: 0.9137255, b: 0.7019608, a: 0.39215687} local: 0 --- !u!1001 &1742240703 PrefabInstance: @@ -7568,12 +7566,6 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: a8581491a96862248bb756703446e627, type: 3} ---- !u!224 &1843387534 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 2501937192852105332, guid: 59f7a79ac29f866409b5e8c706608c90, - type: 3} - m_PrefabInstance: {fileID: 793212044} - m_PrefabAsset: {fileID: 0} --- !u!114 &1850614785 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 3180298803578127748, guid: 30f37aa452756344ebfa932f1ef8a2ee, @@ -8545,8 +8537,6 @@ MonoBehaviour: EntryTime: {fileID: 6153207595148985677, guid: 1c1c6c2f9f2a4434ca1b3e55000a10d2, type: 3} editLoader: {fileID: 593140110} - Accomplished: {r: 0.41960785, g: 0.5686275, b: 0, a: 0.39215687} - NotYetAccomplished: {r: 0.3254902, g: 0.9137255, b: 0.7019608, a: 0.39215687} local: 1 --- !u!1001 &1491172436663537618 PrefabInstance: @@ -8560,6 +8550,91 @@ PrefabInstance: propertyPath: m_Name value: GlobalObject objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _StageAccomplished.a + value: 0.3882353 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _StageAccomplished.b + value: 0.041520078 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _StageAccomplished.g + value: 0.6886792 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _StageAccomplished.r + value: 0.029236369 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _hintAnimationDuration + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _hintAnimationEndColor.a + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _hintAnimationEndColor.b + value: 0.10588237 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _hintAnimationEndColor.g + value: 0.6342677 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _hintAnimationEndColor.r + value: 0.972549 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _StageNotYetAccomplished.a + value: 0.3882353 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _StageNotYetAccomplished.b + value: 0.6901961 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _StageNotYetAccomplished.g + value: 0.4927269 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _StageNotYetAccomplished.r + value: 0.031372562 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _hintAnimationStartColor.a + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _hintAnimationStartColor.b + value: 0.1054201 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _hintAnimationStartColor.g + value: 0.9266228 + objectReference: {fileID: 0} + - target: {fileID: 1491172435906319289, guid: 22a53293eaa728146a6f47093d22ca92, + type: 3} + propertyPath: _hintAnimationStartColor.r + value: 0.9716981 + objectReference: {fileID: 0} - target: {fileID: 1491172435906319294, guid: 22a53293eaa728146a6f47093d22ca92, type: 3} propertyPath: m_RootOrder @@ -8846,6 +8921,12 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 2b1b97ec7dcf75b4396f3da783732f82, type: 3} +--- !u!224 &2501937192093277432 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 2501937192852105332, guid: 59f7a79ac29f866409b5e8c706608c90, + type: 3} + m_PrefabInstance: {fileID: 793212044} + m_PrefabAsset: {fileID: 0} --- !u!1001 &4444013272203459599 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/GameObjectExtensions.cs b/Assets/Scripts/GameObjectExtensions.cs index 7f73e37f..f036f138 100644 --- a/Assets/Scripts/GameObjectExtensions.cs +++ b/Assets/Scripts/GameObjectExtensions.cs @@ -16,6 +16,12 @@ public static void UpdateTagActive(this GameObject root, string tag, bool enable } } + public static void DestroyAllChildren(this GameObject root) + { + for (int i = 0; i < root.transform.childCount; i++) + GameObject.Destroy(root.transform.GetChild(i).gameObject); + } + public static GameObject GetNthChild(this GameObject root, List<int> pos) { GameObject ret = root; diff --git a/Assets/Scripts/GenerateDemoFiles.cs b/Assets/Scripts/GenerateDemoFiles.cs index e1aaf4b8..0e52827f 100644 --- a/Assets/Scripts/GenerateDemoFiles.cs +++ b/Assets/Scripts/GenerateDemoFiles.cs @@ -16,17 +16,17 @@ public static void GenerateDemoA() float minimalSolutionHight = 6; // Generate Stage + // TODO? use constructor Stage demo = new Stage(); demo.number = 0; + demo.category = "Demo Category"; demo.name = "TechDemo A"; demo.scene = "RiverWorld"; demo.description = "Improvised Level\n(Loadable)"; demo.use_install_folder = true; demo.hierarchie = new List<Directories> { /*Directories.Stages*/ }; - demo.factState = new FactOrganizer(true); - demo.solution = new SolutionOrganizer(false); - + // needed to generate facts StageStatic.StageOfficial = new Dictionary<string, Stage> { { demo.name, demo }, diff --git a/Assets/Scripts/GlobalBehaviour.cs b/Assets/Scripts/GlobalBehaviour.cs index 0ecdc420..0f8ffb36 100644 --- a/Assets/Scripts/GlobalBehaviour.cs +++ b/Assets/Scripts/GlobalBehaviour.cs @@ -8,8 +8,34 @@ public class GlobalBehaviour : MonoBehaviour public static Color hintAnimationEndColor; public static float hintAnimationDuration; + public static Color StageAccomplished; + public static Color StageNotYetAccomplished; + + [SerializeField] + private Color _hintAnimationStartColor; + [SerializeField] + private Color _hintAnimationEndColor; + [SerializeField] + private float _hintAnimationDuration; + + [SerializeField] + private Color _StageAccomplished; + [SerializeField] + private Color _StageNotYetAccomplished; + void Awake() { + //GenerateDemoFiles.GenerateAll(); + + hintAnimationStartColor = _hintAnimationStartColor; + hintAnimationEndColor = _hintAnimationEndColor; + hintAnimationDuration = _hintAnimationDuration; + + StageAccomplished = _StageAccomplished; + StageNotYetAccomplished = _StageNotYetAccomplished; + + StageStatic.ShallowLoadStages(); + //DontDestroyOnLoad(gameObject); } } diff --git a/Assets/Scripts/InteractionEngine/Character_Animations/TaskCharakterAnimation.cs b/Assets/Scripts/InteractionEngine/Character_Animations/TaskCharakterAnimation.cs index 6f0320b4..347af523 100644 --- a/Assets/Scripts/InteractionEngine/Character_Animations/TaskCharakterAnimation.cs +++ b/Assets/Scripts/InteractionEngine/Character_Animations/TaskCharakterAnimation.cs @@ -77,6 +77,7 @@ void Update() startHappy(); LelvelVerifiedSolved = true; } + taskCharacterAddressed = false; return; } diff --git a/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs b/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs index 8c11aa15..bd0b0d58 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/FactOrganizer.cs @@ -526,6 +526,11 @@ public static void delete(string path) File.Delete(path); } + public void delete() + { + delete(path); + } + public void Draw(bool draw_all = false) // call this after assigning a stored instance in an empty world, that was not drawn { diff --git a/Assets/Scripts/InteractionEngine/FactHandling/SolutionOrganizer.cs b/Assets/Scripts/InteractionEngine/FactHandling/SolutionOrganizer.cs index 5feca3e1..d28a4703 100644 --- a/Assets/Scripts/InteractionEngine/FactHandling/SolutionOrganizer.cs +++ b/Assets/Scripts/InteractionEngine/FactHandling/SolutionOrganizer.cs @@ -13,7 +13,7 @@ private const string endingSol = "_sol", endingVal = "_val"; - private string path = null; + private string path_Val = null; private static List<Directories> hierVal = new List<Directories> { Directories.ValidationSets }; @@ -62,6 +62,11 @@ public SubSolution(HashSet<string> MasterIDs, List<int> SolutionIndex, FactCompa if (Comparer != null) this.Comparer = Comparer; } + + public bool IsEmpty() + { + return MasterIDs.Count == 0 && SolutionIndex.Count == 0; + } } public SolutionOrganizer(bool invoke = false): base(invoke) @@ -81,10 +86,10 @@ public List<Fact> getMasterFactsByIndex (int i) base.store(name + endingSol, hierarchie, use_install_folder); - string path_o = path; - path = CreatePathToFile(out _, name + endingVal, "JSON", hierarchie, use_install_folder); - JSONManager.WriteToJsonFile(path, this.ValidationSet.Select(e => (e.MasterIDs, e.Comparer.ToString())), 0); - path = path_o; + string path_o = path_Val; + path_Val = CreatePathToFile(out _, name + endingVal, "JSON", hierarchie, use_install_folder); + JSONManager.WriteToJsonFile(path_Val, this.ValidationSet, 0); + path_Val = path_o; hierarchie.RemoveRange(hierarchie.Count - hierVal.Count, hierVal.Count); } @@ -105,11 +110,13 @@ public static bool load(ref SolutionOrganizer set, bool draw, string name, List< FactOrganizer save = StageStatic.stage.factState; StageStatic.stage.factState = new SolutionOrganizer(false) as FactOrganizer; - loadable = FactOrganizer.load(ref StageStatic.stage.player_record.factState, draw, name + endingSol, hierarchie, use_install_folder, out Dictionary<string, string> old_to_new); + loadable = FactOrganizer.load(ref StageStatic.stage.player_record.factState + , draw, name + endingSol, hierarchie, use_install_folder, out Dictionary<string, string> old_to_new); + if (loadable) { set = (SolutionOrganizer)StageStatic.stage.factState; - set.path = path; + set.path_Val = path; } StageStatic.stage.factState = save; @@ -122,7 +129,7 @@ public static bool load(ref SolutionOrganizer set, bool draw, string name, List< foreach (var element in JsonTmp) // Parse and add { - element.MasterIDs.Select(k => old_to_new[k]); + element.MasterIDs = new HashSet<string>(element.MasterIDs.Select(k => old_to_new[k])); set.ValidationSet.Add(element); } @@ -131,6 +138,8 @@ public static bool load(ref SolutionOrganizer set, bool draw, string name, List< public new void delete() { - FactOrganizer.delete(path); + base.delete(); + if (System.IO.File.Exists(path_Val)) + System.IO.File.Delete(path_Val); } } diff --git a/Assets/Scripts/Loading/Stage.cs b/Assets/Scripts/Loading/Stage.cs index 69e6ae86..889b38cf 100644 --- a/Assets/Scripts/Loading/Stage.cs +++ b/Assets/Scripts/Loading/Stage.cs @@ -20,8 +20,8 @@ public class Stage [JsonIgnore] //TODO? update color if changed - public bool completed_once { get { return player_record_list != null && player_record_list.Aggregate(false, (last, next) => last || next.solved); } } - public List<PlayerRecord> player_record_list = null; + public bool completed_once { get { return player_record_list != null && player_record_list.Aggregate(false, (last, next) => last || next.Value.solved); } } + public Dictionary<string, PlayerRecord> player_record_list = null; [JsonIgnore] public SolutionOrganizer solution = null; @@ -50,7 +50,12 @@ private static List<Directories> private FactOrganizer hiddenState; - public Stage() { } + public Stage() + { + solution = new SolutionOrganizer(); + player_record = new PlayerRecord(record_name); + player_record_list = new Dictionary<string, PlayerRecord>(); + } public Stage(string category, int number, string name, string description, string scene, bool local = true) { @@ -63,7 +68,7 @@ public Stage(string category, int number, string name, string description, strin solution = new SolutionOrganizer(); player_record = new PlayerRecord(record_name); - player_record_list = new List<PlayerRecord>(); + player_record_list = new Dictionary<string, PlayerRecord>(); } public void CopyStates(Stage get) @@ -79,7 +84,7 @@ public void deletet_record(PlayerRecord record) hierarchie.AddRange(hierStage.AsEnumerable()); record.delete(hierarchie); - player_record_list.Remove(record); + player_record_list.Remove(record.name); hierarchie.RemoveRange(hierarchie.Count - hierStage.Count, hierStage.Count); store(); @@ -87,7 +92,7 @@ public void deletet_record(PlayerRecord record) public bool set_record(PlayerRecord record) { - if (record != null && !player_record_list.Contains(record)) + if (record != null && !player_record_list.ContainsKey(record.name)) return false; player_record = record == null ? new PlayerRecord(record_name) : record; @@ -127,14 +132,19 @@ public void SetMode(bool create) public void delete(bool player_record_too) { + hierarchie ??= new List<Directories>(); + hierarchie.AddRange(hierStage.AsEnumerable()); + solution.delete(); player_record.delete(hierarchie); if (player_record_too) foreach (var r in player_record_list) - r.delete(hierarchie); + r.Value.delete(hierarchie); if (File.Exists(path)) File.Delete(path); + + hierarchie.RemoveRange(hierarchie.Count - hierStage.Count, hierStage.Count); } public void store(bool reset = false) @@ -155,7 +165,7 @@ public void store(bool reset = false) path = path_o; hierarchie.AddRange(hierStage.AsEnumerable()); - if(solution != null) + if(solution != null && solution.ValidationSet.Count > 0 && !solution.ValidationSet.Aggregate(false, (last, next) => last || next.IsEmpty())) solution.store(name, hierarchie, use_install_folder); } @@ -163,7 +173,7 @@ public void store(bool reset = false) player_record.store(hierarchie); foreach (var track in player_record_list) - track.store(hierarchie); + track.Value.store(hierarchie); hierarchie.RemoveRange(hierarchie.Count - hierStage.Count, hierStage.Count); } @@ -200,6 +210,7 @@ public static bool ShallowLoad(ref Stage set, string path) return false; set = JSONManager.ReadFromJsonFile<Stage>(path); + set.path = path; set.hierarchie ??= new List<Directories>(); set.hierarchie.AddRange(hierStage.AsEnumerable()); @@ -216,13 +227,9 @@ public static bool ShallowLoad(ref Stage set, string name, List<Directories> hie string path = CreatePathToFile(out bool loadable, name, "JSON", hierarchie, use_install_folder); hierarchie.RemoveRange(hierarchie.Count - hierStage.Count, hierStage.Count); - if (!loadable) - return false; - set = JSONManager.ReadFromJsonFile<Stage>(path); - set.path = path; - set.hierarchie = hierarchie; - set.use_install_folder = use_install_folder; + if (!loadable || !ShallowLoad(ref set, path)) + return false; return true; } @@ -273,8 +280,16 @@ public static Dictionary<string, Stage> Grup(List<Directories> hierarchie = null return ret; } - public void Reset() + public void ResetPlay() + { + player_record = new PlayerRecord(record_name); + store(true); + } + + public void ResetSaves() { + player_record = new PlayerRecord(record_name); + player_record_list = new Dictionary<string, PlayerRecord>(); store(true); } @@ -294,13 +309,12 @@ public bool CheckSolved() player_record.solved = solved; player_record.time = time_s - player_record.time; - var pr = player_record_list.FirstOrDefault(); - int i = pr == null ? 1 : pr.name_nr; - for (; player_record_list.Exists(p => p.name_nr == i); i++) ; + int i = 0; player_record.name = record_name + "_" + i.ToString(); + for (; player_record_list.ContainsKey(player_record.name); i++) + player_record.name = record_name + "_" + i.ToString(); - player_record_list.Add(player_record); - player_record_list = player_record_list.OrderBy(p => p.time).ToList(); + player_record_list.Add(player_record.name, player_record); var old = player_record; store(true); @@ -315,13 +329,12 @@ public bool CheckSolved() public class PlayerRecord { public bool solved = false; - public float date = Time.time; // TODO: correct? + public long date = System.DateTime.Now.ToBinary(); public float time = 0; [JsonIgnore] public FactOrganizer factState = null; public string name = null; - public int name_nr = 1; private static List<Directories> hierStage = new List<Directories> { /*Directories.FactStateMachines*/ }; diff --git a/Assets/Scripts/Restart.cs b/Assets/Scripts/Restart.cs index 4a069894..686d4198 100644 --- a/Assets/Scripts/Restart.cs +++ b/Assets/Scripts/Restart.cs @@ -5,7 +5,7 @@ public class Restart : MonoBehaviour { public void LevelReset() { - StageStatic.stage.Reset(); + StageStatic.stage.ResetPlay(); Loader.LoadStage(StageStatic.stage.name, !StageStatic.stage.use_install_folder, false); } diff --git a/Assets/Scripts/UI/InputFieldResizeFix.cs b/Assets/Scripts/UI/InputFieldResizeFix.cs deleted file mode 100644 index a628641e..00000000 --- a/Assets/Scripts/UI/InputFieldResizeFix.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class InputFieldResizeFix : MonoBehaviour -{ - private Vector3 relPos; - private float origHight; - - private void Start() - { - relPos = gameObject.transform.GetChild(0).transform.localPosition; - origHight = (gameObject.transform as RectTransform).sizeDelta.y; - } - - private void Update() - { - (gameObject.transform.GetChild(0) as RectTransform).sizeDelta = - (gameObject.transform as RectTransform).sizeDelta; - - Fix(); - } - - public void Fix() - { - float newHight = (gameObject.transform as RectTransform).sizeDelta.y; - gameObject.transform.GetChild(0).transform.localPosition = relPos - - new Vector3(0, newHight - origHight, 0); - } -} diff --git a/Assets/Stages/ValidationSets/Stages/Stages.meta b/Assets/Scripts/UI/MainMenue/CollapsableStage.meta similarity index 77% rename from Assets/Stages/ValidationSets/Stages/Stages.meta rename to Assets/Scripts/UI/MainMenue/CollapsableStage.meta index d4fec80e..ce67210f 100644 --- a/Assets/Stages/ValidationSets/Stages/Stages.meta +++ b/Assets/Scripts/UI/MainMenue/CollapsableStage.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: f5d87d145cc0a314495e6253747915d1 +guid: 1ffa4b3a1bf5f1c4cb765c766f6bf7c9 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableCategory.cs b/Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableCategory.cs new file mode 100644 index 00000000..da11db8b --- /dev/null +++ b/Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableCategory.cs @@ -0,0 +1,57 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using static UIToolBox; + +public class CollapsableCategory : MonoBehaviour +{ + public GameObject StageEntry; + public GameObject StageEntryEntry; + public MenueLoader pageMenue; + public EditLoader editLoader; + + public List<Stage> content; + + public string category; + + public void Init() + { + var header = gameObject.GetNthChild(new List<int> { 0, 0 }); + + var p = DrawChildren(); + + // set text + PopulateLocalEntryList(header, new List<string> { ((int)(p * 100)).ToString() + "%", category, "" }); + + // set colour + header.GetNthChild(new List<int> { 0, 0 }).GetComponent<UnityEngine.UI.Image>().color = + p * GlobalBehaviour.StageAccomplished + (1 - p) * GlobalBehaviour.StageNotYetAccomplished; + } + + + public float DrawChildren() + { + float + cat_sum = 0, + cat_suc = 0; + + foreach (var stage in content) + { + cat_sum++; + cat_suc += System.Convert.ToInt32(stage.completed_once); + + GameObject stage_entry = Instantiate(StageEntry); + stage_entry.transform.SetParent(gameObject.GetNthChild(new List<int>{ 1 }).transform, false); + + CollapsableStage stage_beahviour = stage_entry.GetComponent<CollapsableStage>(); + stage_beahviour.stage_name = stage.name; + stage_beahviour.local = !stage.use_install_folder; + stage_beahviour.pageMenue = pageMenue; + stage_beahviour.editLoader = editLoader; + stage_beahviour.TimeEntry = StageEntryEntry; + stage_beahviour.Init(); + } + + return cat_suc / cat_sum; + } +} diff --git a/Assets/Scripts/UI/InputFieldResizeFix.cs.meta b/Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableCategory.cs.meta similarity index 83% rename from Assets/Scripts/UI/InputFieldResizeFix.cs.meta rename to Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableCategory.cs.meta index cf2992ca..fdaa7889 100644 --- a/Assets/Scripts/UI/InputFieldResizeFix.cs.meta +++ b/Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableCategory.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: aad6702387b93bf45916955d5b3dcdd2 +guid: 3fcacb84a86b74c45a2090ce06b71175 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableStage.cs b/Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableStage.cs new file mode 100644 index 00000000..968532f3 --- /dev/null +++ b/Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableStage.cs @@ -0,0 +1,75 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using static UIToolBox; + +public class CollapsableStage : MonoBehaviour +{ + public GameObject TimeEntry; + public MenueLoader pageMenue; + public EditLoader editLoader; + public string stage_name; + public bool local; + public Stage stage { get { return StageStatic.GetStage(stage_name, local); } } + + public void Init() + { + var header = gameObject.GetNthChild(new List<int> { 0, 0 }); + + // set text + PopulateLocalEntryList(header, new List<string> { stage.number.ToString(), stage.name, stage.description }); + + // set colour + header.GetNthChild(new List<int> { 0, 0 }).GetComponent<UnityEngine.UI.Image>().color = + stage.completed_once ? GlobalBehaviour.StageAccomplished : GlobalBehaviour.StageNotYetAccomplished; + + // set implicit load button (whole header) + header.GetComponent<UnityEngine.UI.Button>().onClick.AddListener(delegate { + StageStatic.devel = false; + // TODO: handle unable to load + Loader.LoadStage(stage.name, !stage.use_install_folder, false); + }); + + // set explicit edit button + header.GetNthChild(new List<int> { 3, 0 }).GetComponent<UnityEngine.UI.Button>().onClick.AddListener(delegate + { + pageMenue.SetMode(3); + editLoader.SetStage(stage.name, !stage.use_install_folder); + }); + + DrawChildren(); + } + + public void DrawChildren() + { + var record_list = stage.player_record_list.Values.OrderBy(r => r.time).ToList(); + var body = gameObject.GetNthChild(new List<int> { 1 }); + body.DestroyAllChildren(); + + for (int i = 0; i < record_list.Count; i++) + { + GameObject time_entry = Instantiate(TimeEntry); + time_entry.transform.SetParent(body.transform, false); + + PopulateLocalEntryList(time_entry, new List<string> { + (i + 1).ToString(), + "", // hidden + System.TimeSpan.FromSeconds(record_list[i].time).ToString("hh':'mm':'ss") }); + + var index = record_list[i].name; + // set delete button + time_entry.GetNthChild(new List<int> { 3, 0 }).GetComponent<UnityEngine.UI.Button>().onClick.AddListener(delegate { + stage.deletet_record(stage.player_record_list[index]); + this.Init(); + }); + // set clone button + time_entry.GetNthChild(new List<int> { 4, 0 }).GetComponent<UnityEngine.UI.Button>().onClick.AddListener(delegate { + stage.set_record(stage.player_record_list[index]); + StageStatic.devel = false; + // TODO: handle unable to load + Loader.LoadStage(stage.name, !stage.use_install_folder, true); + }); + } + } +} diff --git a/Assets/Scripts/UI/MainMenue/LegBarSizer.cs.meta b/Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableStage.cs.meta similarity index 83% rename from Assets/Scripts/UI/MainMenue/LegBarSizer.cs.meta rename to Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableStage.cs.meta index 11fba4b0..09fe02a1 100644 --- a/Assets/Scripts/UI/MainMenue/LegBarSizer.cs.meta +++ b/Assets/Scripts/UI/MainMenue/CollapsableStage/CollapsableStage.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 9a92609d9b0f447449c193ac0a6e6223 +guid: 420d4b6a812c99041b2ff63b2453fefb MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/UI/MainMenue/LegBarSizer.cs b/Assets/Scripts/UI/MainMenue/LegBarSizer.cs deleted file mode 100644 index 719f45b5..00000000 --- a/Assets/Scripts/UI/MainMenue/LegBarSizer.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -// TODO: Unused - -public class LegBarSizer : MonoBehaviour -{ - public float offset = 5; - private RectTransform transf; - - void Start() - { - transf = gameObject.GetComponent<RectTransform>(); - transf.sizeDelta = new Vector2(transf.sizeDelta.x, transf.sizeDelta.y + offset); - } - - private void RecursiveTransform(List<GameObject> children) - { - ; - } - - void Update() - { - foreach (var child in gameObject.GetComponentsInChildren<RectTransform>()) - { - if (child.Equals(transf)) - continue; - - var pos = child.position; - pos.y = transf.position.y + transf.sizeDelta.y - child.sizeDelta.y - offset; - child.position = pos; - } - } -} diff --git a/Assets/Scripts/UI/MainMenue/ListLoader.cs b/Assets/Scripts/UI/MainMenue/ListLoader.cs index 668bdd7e..c06c99bb 100644 --- a/Assets/Scripts/UI/MainMenue/ListLoader.cs +++ b/Assets/Scripts/UI/MainMenue/ListLoader.cs @@ -24,8 +24,7 @@ protected void OnDisable() protected virtual void Clear() { - for (int i = 0; i < List.transform.childCount; i++) - Destroy(List.transform.GetChild(i).gameObject); + List.DestroyAllChildren(); } protected abstract void Default(); diff --git a/Assets/Stages/ValidationSets/Stages.meta b/Assets/Scripts/UI/MainMenue/PageLoader.meta similarity index 77% rename from Assets/Stages/ValidationSets/Stages.meta rename to Assets/Scripts/UI/MainMenue/PageLoader.meta index 9c9a5064..718be5cb 100644 --- a/Assets/Stages/ValidationSets/Stages.meta +++ b/Assets/Scripts/UI/MainMenue/PageLoader.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: d3ad1da886afab24cb435eb27e6acf93 +guid: 29ea3644006fb5847a55c649ba8e0afd folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Scripts/UI/MainMenue/CreateLoader.cs b/Assets/Scripts/UI/MainMenue/PageLoader/CreateLoader.cs similarity index 100% rename from Assets/Scripts/UI/MainMenue/CreateLoader.cs rename to Assets/Scripts/UI/MainMenue/PageLoader/CreateLoader.cs diff --git a/Assets/Scripts/UI/MainMenue/CreateLoader.cs.meta b/Assets/Scripts/UI/MainMenue/PageLoader/CreateLoader.cs.meta similarity index 100% rename from Assets/Scripts/UI/MainMenue/CreateLoader.cs.meta rename to Assets/Scripts/UI/MainMenue/PageLoader/CreateLoader.cs.meta diff --git a/Assets/Scripts/UI/MainMenue/EditLoader.cs b/Assets/Scripts/UI/MainMenue/PageLoader/EditLoader.cs similarity index 97% rename from Assets/Scripts/UI/MainMenue/EditLoader.cs rename to Assets/Scripts/UI/MainMenue/PageLoader/EditLoader.cs index cf837161..30746e3c 100644 --- a/Assets/Scripts/UI/MainMenue/EditLoader.cs +++ b/Assets/Scripts/UI/MainMenue/PageLoader/EditLoader.cs @@ -63,6 +63,8 @@ private bool _Clone(bool overwrite) Stage new_stage = new Stage(category, id, name, description, scene, true); new_stage.CopyStates(original_stage); + if(!overwrite) + new_stage.ResetSaves(); StageStatic.stage = new_stage; return true; diff --git a/Assets/Scripts/UI/MainMenue/EditLoader.cs.meta b/Assets/Scripts/UI/MainMenue/PageLoader/EditLoader.cs.meta similarity index 100% rename from Assets/Scripts/UI/MainMenue/EditLoader.cs.meta rename to Assets/Scripts/UI/MainMenue/PageLoader/EditLoader.cs.meta diff --git a/Assets/Scripts/UI/MainMenue/LocalLoader.cs b/Assets/Scripts/UI/MainMenue/PageLoader/LocalLoader.cs similarity index 100% rename from Assets/Scripts/UI/MainMenue/LocalLoader.cs rename to Assets/Scripts/UI/MainMenue/PageLoader/LocalLoader.cs diff --git a/Assets/Scripts/UI/MainMenue/LocalLoader.cs.meta b/Assets/Scripts/UI/MainMenue/PageLoader/LocalLoader.cs.meta similarity index 100% rename from Assets/Scripts/UI/MainMenue/LocalLoader.cs.meta rename to Assets/Scripts/UI/MainMenue/PageLoader/LocalLoader.cs.meta diff --git a/Assets/Scripts/UI/MainMenue/PageLoader/StageLoader.cs b/Assets/Scripts/UI/MainMenue/PageLoader/StageLoader.cs new file mode 100644 index 00000000..666a7679 --- /dev/null +++ b/Assets/Scripts/UI/MainMenue/PageLoader/StageLoader.cs @@ -0,0 +1,80 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using static UIToolBox; + + +public class StageLoader : ListLoader<Stage> +{ + public GameObject EntryBody; + public GameObject EntryTime; + + public EditLoader editLoader; + + public bool local; + protected string + NoId = "", + NoStage = "-----", + NoDescr = "No Entry found, please check directory!", + NoLocal = "No local Stage\nClick [+]"; + + public override void Init() + { + StageStatic.SetStage("", local); + StageStatic.ShallowLoadStages(); + + Dictionary<string, Stage> dict = local ? + StageStatic.StageLocal : StageStatic.StageOfficial; + + var ord = local ? + dict.Values.OrderBy(s => s.category) : + dict.Values.OrderBy(s => StageStatic.Category.ContainsKey(s.category) ? StageStatic.Category[s.category] : -1); + + ord = ord.ThenBy(s => s.number); + + ListButtons(ord.ToList()); + + //scroll.verticalScrollbar.numberOfSteps = dict.Count; + } + + protected override void Default() + { + var def = Instantiate(EntryHeader); + CreateEntry(def, List, NoId, NoStage, local ? NoLocal:NoDescr, new Color(0,0,0,0)); + } + + protected override void ListButtonsWrapped(List<Stage> list) + { + GameObject category_entry = null; + CollapsableCategory category_behaviour = null; + + foreach (var cat in list.Select(s => s.category).Distinct()) + { + category_entry = Instantiate(EntryHeader); + category_entry.transform.SetParent(List.transform, false); + + category_behaviour = category_entry.GetComponent<CollapsableCategory>(); + category_behaviour.content = list.Where(s => s.category == cat).ToList(); + category_behaviour.category = cat; + category_behaviour.pageMenue = pageMenue; + category_behaviour.editLoader = editLoader; + category_behaviour.StageEntry = EntryBody; + category_behaviour.StageEntryEntry = EntryTime; + category_behaviour.Init(); + } + } + + protected void CreateEntry(GameObject entry, GameObject parent, string number, string name, string description, Color color_status) + { + entry.transform.SetParent(parent.transform, false); + + entry = entry.GetNthChild(new List<int> { 0, 0 }); + + PopulateLocalEntryList(entry, new List<string> { number, name, description }); + + entry.GetNthChild(new List<int> { 0, 0 }).GetComponent<UnityEngine.UI.Image>().color = color_status; + } + + +} diff --git a/Assets/Scripts/UI/MainMenue/StageLoader.cs.meta b/Assets/Scripts/UI/MainMenue/PageLoader/StageLoader.cs.meta similarity index 100% rename from Assets/Scripts/UI/MainMenue/StageLoader.cs.meta rename to Assets/Scripts/UI/MainMenue/PageLoader/StageLoader.cs.meta diff --git a/Assets/Scripts/UI/MainMenue/StageLoader.cs b/Assets/Scripts/UI/MainMenue/StageLoader.cs deleted file mode 100644 index dc72996c..00000000 --- a/Assets/Scripts/UI/MainMenue/StageLoader.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using UnityEngine; - - -public class StageLoader : ListLoader<Stage> -{ - public GameObject EntryBody; - public GameObject EntryTime; - - public EditLoader editLoader; - - public Color Accomplished; - public Color NotYetAccomplished; - - public bool local; - protected string - NoId = "---", - NoStage = "-----", - NoDescr = "No Entry found, please check directory!", - NoLocal = "No local Stage\nClick [+]"; - - public override void Init() - { - StageStatic.SetStage("", local); - StageStatic.ShallowLoadStages(); - - Dictionary<string, Stage> dict = local ? - StageStatic.StageLocal : StageStatic.StageOfficial; - - var ord = local ? - dict.Values.OrderBy(s => s.category) : - dict.Values.OrderBy(s => StageStatic.Category.ContainsKey(s.category) ? StageStatic.Category[s.category] : -1); - - ord = ord.ThenBy(s => s.number); - - ListButtons(ord.ToList()); - - //scroll.verticalScrollbar.numberOfSteps = dict.Count; - } - - protected override void Default() - { - var def = Instantiate(EntryHeader); - CreateEntry(def, List, NoId, NoStage, local ? NoLocal:NoDescr, new Color(0,0,0,0)); - } - - protected override void ListButtonsWrapped(List<Stage> list) - { - string current_category = ""; - GameObject category_entry = null; - float - cat_sum = 0, - cat_suc = 0; - - foreach (var stage in list) - { - if(current_category != stage.category || category_entry == null) - { - PopulateCategory(); - - current_category = stage.category; - category_entry = Instantiate(EntryHeader); - cat_sum = 0; - cat_suc = 0; - } - - cat_sum++; - cat_suc += System.Convert.ToInt32(stage.completed_once); - - GameObject stage_entry = Instantiate(EntryBody); - CreateEntry(stage_entry, category_entry.GetNthChild(new List<int> { 1 }), - stage.number.ToString(), stage.name, stage.description, - stage.completed_once ? Accomplished : NotYetAccomplished); - - stage_entry.GetNthChild(new List<int> { 0, 0 }).GetComponent<UnityEngine.UI.Button>().onClick.AddListener(delegate { - StageStatic.devel = false; - // TODO: handle unable to load - Loader.LoadStage(stage.name, local, false); - }); - - stage_entry.GetNthChild(new List<int> { 0, 0, 3, 0 }).GetComponent<UnityEngine.UI.Button>().onClick.AddListener(delegate - { - pageMenue.SetMode(3); - editLoader.SetStage(stage.name, !stage.use_install_folder); - }); - - for(int i = 0; i < stage.player_record_list.Count; i++) - { - GameObject time_entry = Instantiate(EntryTime); - time_entry.transform.SetParent(stage_entry.GetNthChild(new List<int> { 1 }).transform, false); - - PopulateLocalEntryList(time_entry, new List<string> { - (i + 1).ToString(), - stage.player_record_list[i].name_nr.ToString(), // hidden - System.TimeSpan.FromSeconds(stage.player_record_list[i].time).ToString("hh':'mm':'ss") }); - - var record = stage.player_record_list[i]; - time_entry.GetNthChild(new List<int> { 3, 0 }).GetComponent<UnityEngine.UI.Button>().onClick.AddListener(delegate { - stage.deletet_record(record); - }); - time_entry.GetNthChild(new List<int> { 4, 0 }).GetComponent<UnityEngine.UI.Button>().onClick.AddListener(delegate { - stage.set_record(record); - StageStatic.devel = false; - // TODO: handle unable to load - Loader.LoadStage(stage.name, local, true); - }); - } - } - - PopulateCategory(); - - return; - - // === local methods === - - void PopulateCategory() - { - if (category_entry != null) - { - var p = cat_suc / cat_sum; - CreateEntry(category_entry, List, - ((int) (p*100)).ToString() + "%", - current_category, "", - p * Accomplished + (1 - p) * NotYetAccomplished); - } - } - } - - private void CreateEntry(GameObject entry, GameObject parent, string number, string name, string description, Color color_status) - { - entry.transform.SetParent(parent.transform, false); - - entry = entry.GetNthChild(new List<int> { 0, 0 }); - - PopulateLocalEntryList(entry, new List<string> { number, name, description }); - - entry.GetNthChild(new List<int> { 0, 0 }).GetComponent<UnityEngine.UI.Image>().color = color_status; - } - - private void PopulateLocalEntryList(GameObject entry, List<string> input) - { - for (int i = 0; i < input.Count; i++) - entry.GetNthChild(new List<int> { i, 0, 0 }).GetComponent<TMPro.TextMeshProUGUI>().text = input[i]; - } -} diff --git a/Assets/Scripts/UI/UIToolBox.cs b/Assets/Scripts/UI/UIToolBox.cs new file mode 100644 index 00000000..5c70eb81 --- /dev/null +++ b/Assets/Scripts/UI/UIToolBox.cs @@ -0,0 +1,12 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public static class UIToolBox +{ + public static void PopulateLocalEntryList(GameObject entry, List<string> input) + { + for (int i = 0; i < input.Count; i++) + entry.GetNthChild(new List<int> { i, 0, 0 }).GetComponent<TMPro.TextMeshProUGUI>().text = input[i]; + } +} diff --git a/Assets/Scripts/UI/UIToolBox.cs.meta b/Assets/Scripts/UI/UIToolBox.cs.meta new file mode 100644 index 00000000..a813dfe2 --- /dev/null +++ b/Assets/Scripts/UI/UIToolBox.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0a18f2087e64cce40ac4daf1bde9e5b3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Stages/TechDemo A.JSON b/Assets/Stages/TechDemo A.JSON index 16d04447..bcdcce59 100644 --- a/Assets/Stages/TechDemo A.JSON +++ b/Assets/Stages/TechDemo A.JSON @@ -1 +1 @@ -{"number":0,"category":"Demo Category","name":"TechDemo A","description":"Improvised Level\n(Loadable)","scene":"RiverWorld","use_install_folder":true,"hierarchie":[],"player_record_list":[],"player_record":{"solved":false,"date":3.400165,"time":3.400165,"name":"TechDemo A_save","name_nr":1}} \ No newline at end of file +{"number":0,"category":"Demo Category","name":"TechDemo A","description":"Improvised Level\n(Loadable)","scene":"RiverWorld","use_install_folder":true,"hierarchie":[],"player_record_list":{"TechDemo A_save_1":{"solved":true,"date":176,"time":46.0341873,"name":"TechDemo A_save_1"},"TechDemo A_save_0":{"solved":true,"date":176,"time":67.78075,"name":"TechDemo A_save_0"}},"player_record":{"solved":false,"date":-8585700266226810927,"time":0.0,"name":"TechDemo A_save"}} \ No newline at end of file diff --git a/Assets/Stages/ValidationSets/FactStateMachines/TechDemo A_sol.JSON b/Assets/Stages/ValidationSets/FactStateMachines/TechDemo A_sol.JSON index 4fc21a59..73edc4f0 100644 --- a/Assets/Stages/ValidationSets/FactStateMachines/TechDemo A_sol.JSON +++ b/Assets/Stages/ValidationSets/FactStateMachines/TechDemo A_sol.JSON @@ -1 +1 @@ -{"PointFacts":[{"Point":{"x":0.0,"y":0.0,"z":0.0,"magnitude":0.0,"sqrMagnitude":0.0},"Normal":{"x":0.0,"y":1.0,"z":0.0,"magnitude":1.0,"sqrMagnitude":1.0},"Id":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/Root?fact165","Label":"A","hasCustomLabel":false,"LabelId":1},{"Point":{"x":0.0,"y":6.0,"z":0.0,"normalized":{"x":0.0,"y":1.0,"z":0.0,"magnitude":1.0,"sqrMagnitude":1.0},"magnitude":6.0,"sqrMagnitude":36.0},"Normal":{"x":0.0,"y":1.0,"z":0.0,"magnitude":1.0,"sqrMagnitude":1.0},"Id":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/Root?fact166","Label":"B","hasCustomLabel":false,"LabelId":2}],"LineFacts":[{"Distance":6.0,"Pid1":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/Root?fact165","Pid2":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/Root?fact166","Dir":{"x":0.0,"y":1.0,"z":0.0,"magnitude":1.0,"sqrMagnitude":1.0},"Id":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/Root?fact167","Label":"[AB]","hasCustomLabel":false,"LabelId":0}],"RayFacts":[],"OnLineFacts":[],"AngleFacts":[],"MetaInf":{"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/Root?fact165":{"workflow_id":0,"active":true},"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/Root?fact166":{"workflow_id":1,"active":true},"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/Root?fact167":{"workflow_id":2,"active":true}},"Workflow":[{"Id":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/Root?fact165","samestep":false,"steplink":3,"creation":true},{"Id":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/Root?fact166","samestep":true,"steplink":0,"creation":true},{"Id":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/Root?fact167","samestep":true,"steplink":0,"creation":true}],"marker":3,"worksteps":1,"backlog":0,"soft_resetted":false,"invoke":false,"MaxLabelId":2,"UnusedLabelIds":[]} \ No newline at end of file +{"PointFacts":[{"Point":{"x":0.0,"y":0.0,"z":0.0,"magnitude":0.0,"sqrMagnitude":0.0},"Normal":{"x":0.0,"y":1.0,"z":0.0,"magnitude":1.0,"sqrMagnitude":1.0},"Id":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/SituationTheory2?fact1304","Label":"A","hasCustomLabel":false,"LabelId":1},{"Point":{"x":0.0,"y":6.0,"z":0.0,"normalized":{"x":0.0,"y":1.0,"z":0.0,"magnitude":1.0,"sqrMagnitude":1.0},"magnitude":6.0,"sqrMagnitude":36.0},"Normal":{"x":0.0,"y":1.0,"z":0.0,"magnitude":1.0,"sqrMagnitude":1.0},"Id":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/SituationTheory2?fact1305","Label":"B","hasCustomLabel":false,"LabelId":2}],"LineFacts":[{"Distance":6.0,"Pid1":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/SituationTheory2?fact1304","Pid2":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/SituationTheory2?fact1305","Dir":{"x":0.0,"y":1.0,"z":0.0,"magnitude":1.0,"sqrMagnitude":1.0},"Id":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/SituationTheory2?fact1306","Label":"[AB]","hasCustomLabel":false,"LabelId":0}],"RayFacts":[],"OnLineFacts":[],"AngleFacts":[],"MetaInf":{"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/SituationTheory2?fact1304":{"workflow_id":0,"active":true},"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/SituationTheory2?fact1305":{"workflow_id":1,"active":true},"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/SituationTheory2?fact1306":{"workflow_id":2,"active":true}},"Workflow":[{"Id":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/SituationTheory2?fact1304","samestep":false,"steplink":3,"creation":true},{"Id":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/SituationTheory2?fact1305","samestep":true,"steplink":0,"creation":true},{"Id":"http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/SituationTheory2?fact1306","samestep":true,"steplink":0,"creation":true}],"marker":3,"worksteps":1,"backlog":0,"soft_resetted":false,"invoke":false,"MaxLabelId":2,"UnusedLabelIds":[]} \ No newline at end of file diff --git a/Assets/Stages/ValidationSets/Stages/Stages/Stages.meta b/Assets/Stages/ValidationSets/Stages/Stages/Stages.meta deleted file mode 100644 index d0c90440..00000000 --- a/Assets/Stages/ValidationSets/Stages/Stages/Stages.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 25abed5eccefb3949897980891aa8c99 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Stages/ValidationSets/Stages/Stages/Stages/Stages.meta b/Assets/Stages/ValidationSets/Stages/Stages/Stages/Stages.meta deleted file mode 100644 index 52f91738..00000000 --- a/Assets/Stages/ValidationSets/Stages/Stages/Stages/Stages.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 523733c2b468ecc498ccd18e72f75812 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Stages/ValidationSets/Stages/Stages/Stages/Stages/ValidationSets.meta b/Assets/Stages/ValidationSets/Stages/Stages/Stages/Stages/ValidationSets.meta deleted file mode 100644 index 2e4e234d..00000000 --- a/Assets/Stages/ValidationSets/Stages/Stages/Stages/Stages/ValidationSets.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4356a0958064d694a9444b7a41b2e6dd -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Stages/ValidationSets/Stages/Stages/Stages/ValidationSets.meta b/Assets/Stages/ValidationSets/Stages/Stages/Stages/ValidationSets.meta deleted file mode 100644 index f5ed1fd0..00000000 --- a/Assets/Stages/ValidationSets/Stages/Stages/Stages/ValidationSets.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ed0e7d8898590ac4fbe02b9e89f35973 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Stages/ValidationSets/Stages/Stages/ValidationSets.meta b/Assets/Stages/ValidationSets/Stages/Stages/ValidationSets.meta deleted file mode 100644 index f83ee171..00000000 --- a/Assets/Stages/ValidationSets/Stages/Stages/ValidationSets.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: fa36e913d068e1d4fbd84592b446c334 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Stages/ValidationSets/Stages/ValidationSets.meta b/Assets/Stages/ValidationSets/Stages/ValidationSets.meta deleted file mode 100644 index 7ac6f11f..00000000 --- a/Assets/Stages/ValidationSets/Stages/ValidationSets.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 607235716d63a18459debf0d4fc40806 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Stages/ValidationSets/TechDemo A_val.JSON b/Assets/Stages/ValidationSets/TechDemo A_val.JSON index 50baf432..ec5383c3 100644 --- a/Assets/Stages/ValidationSets/TechDemo A_val.JSON +++ b/Assets/Stages/ValidationSets/TechDemo A_val.JSON @@ -1 +1 @@ -[{"Item1":[],"Item2":"FactEquivalentsComparer"}] \ No newline at end of file +[{"MasterIDs":["http://mathhub.info/FrameIT/frameworld/integrationtests?SampleSituationSpace/SituationTheory2?fact1306"],"SolutionIndex":[],"ComparerString":"LineFactHightDirectionComparer"}] \ No newline at end of file -- GitLab