Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Assets/Gothic-Core/Scenes/MainMenu.unity
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &64750182 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1879303798920566507, guid: a0af29d97abd24d4c8382b6da4017660, type: 3}
m_PrefabInstance: {fileID: 2140893076}
m_PrefabAsset: {fileID: 0}
--- !u!4 &64750183 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2283093842980008316, guid: a0af29d97abd24d4c8382b6da4017660, type: 3}
Expand Down Expand Up @@ -233,15 +228,16 @@ PrefabInstance:
propertyPath: m_Name
value: Gothic-logo
objectReference: {fileID: 0}
- target: {fileID: 6793405629452684711, guid: d905c6fd3294c82478f4edf887cac0a9, type: 3}
propertyPath: _tutorialHandler
value:
objectReference: {fileID: 64750182}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d905c6fd3294c82478f4edf887cac0a9, type: 3}
--- !u!1 &197676827 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 5443751599501581721, guid: d905c6fd3294c82478f4edf887cac0a9, type: 3}
m_PrefabInstance: {fileID: 197676826}
m_PrefabAsset: {fileID: 0}
--- !u!4 &505140342 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 7389606469834037353, guid: 962bda2b335a56f48a6f7159a9e824d8, type: 3}
Expand Down Expand Up @@ -831,6 +827,10 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4906976065703679581, guid: a0af29d97abd24d4c8382b6da4017660, type: 3}
propertyPath: _logo
value:
objectReference: {fileID: 197676827}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
Expand Down
6 changes: 6 additions & 0 deletions Assets/Gothic-Core/Scripts/Adapters/UI/Menus/MenuHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public class MenuHandler : MonoBehaviour
// Cached MainMenu tree hierarchy of submenus (load, save, settings) and their children (sub-settings, settings fields)
public AbstractMenuInstance MainMenuHierarchy { get; private set; }

/// <summary>
/// The open (sub)menu, null while none is open.
/// </summary>
public GameObject CurrentMenu =>
_currentMenu.IsNullOrEmpty() ? null : _menuList.GetValueOrDefault(_currentMenu);

private void Awake()
{
InitializeMenus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ namespace Gothic.Core.Adapters.UI
{
public class GothicLogoHandler : MonoBehaviour, IPointerClickHandler
{
[SerializeField]
private GameObject _tutorialHandler;

[SerializeField]
private float _minBrightness = 0.7f;
[SerializeField]
Expand Down Expand Up @@ -52,22 +49,19 @@ private void Update()


/// <summary>
/// Counts as a poke for the Marvin mode activation and toggles the tutorial.
/// The click completing the Marvin pokes doesn't toggle the tutorial, otherwise it would stay open
/// Counts as a poke for the Marvin mode activation and raises GothicLogoClicked (the VR help panels listen).
/// The click completing the Marvin pokes doesn't raise it, otherwise the help would stay open
/// (open, close, open).
/// </summary>
public void OnPointerClick(PointerEventData eventData)
{
GlobalEventDispatcher.MarvinLogoPoked.Invoke(eventData);

if (_tutorialHandler == null)
return;

var marvinService = ReflexProjectInstaller.DIContainer.Resolve<MarvinService>();
if (marvinService.IsLogoPokeComplete)
return;

_tutorialHandler.gameObject.SetActive(!_tutorialHandler.gameObject.activeSelf);
GlobalEventDispatcher.GothicLogoClicked.Invoke(gameObject);
}

private void OnDestroy()
Expand Down
3 changes: 3 additions & 0 deletions Assets/Gothic-Core/Scripts/GlobalEventDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,5 +357,8 @@ public enum HandSide
public static readonly UnityEvent<bool> MarvinModeChanged = new();
// The Gothic-Unity logo in the menu got clicked. VR uses the event data to vibrate the clicking hand.
public static readonly UnityEvent<PointerEventData> MarvinLogoPoked = new();
// The Gothic logo in the menu got clicked (not the click completing the Marvin pokes). GameObject is the
// logo - the VR help panels switch on their own logo only.
public static readonly UnityEvent<GameObject> GothicLogoClicked = new();
}
}
24 changes: 15 additions & 9 deletions Assets/Gothic-VR/Resources/VR/Prefabs/UI/Tutorials.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,12 @@ MonoBehaviour:
- {fileID: 5472245296572471787}
- {fileID: 5481992129443507305}
- {fileID: 5433034135938690309}
_logo: {fileID: 0}
_panels:
- {fileID: 8031915468319420437}
- {fileID: 2574759379074861209}
- {fileID: 2355034974786271543}
_hiddenWhileShown: []
--- !u!1 &2287991555969460976
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1072,15 +1078,15 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &6046098125727991837
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2355034974786271543}
m_LocalRotation: {x: -0.11839155, y: 0.41745764, z: 0.054959342, w: 0.8992731}
m_LocalRotation: {x: 0, y: 0.42103583, z: 0, w: 0.90704405}
m_LocalPosition: {x: 0, y: 0, z: -2.857143}
m_LocalScale: {x: 0.5, y: 0.5, z: 1}
m_ConstrainProportionsScale: 0
Expand All @@ -1093,7 +1099,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 5, y: 5.2}
m_AnchoredPosition: {x: 5, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!223 &7154765183792889945
Expand Down Expand Up @@ -1203,15 +1209,15 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &8641483639200414027
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2574759379074861209}
m_LocalRotation: {x: -0.1305262, y: 0, z: 0, w: 0.9914449}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.5, y: 0.5, z: 1}
m_ConstrainProportionsScale: 0
Expand All @@ -1224,7 +1230,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 5.2}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!223 &3364244922444394401
Expand Down Expand Up @@ -4976,15 +4982,15 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &2721688293221894282
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8031915468319420437}
m_LocalRotation: {x: -0.11839155, y: -0.41745764, z: -0.054959342, w: 0.8992731}
m_LocalRotation: {x: 0, y: 0.42103574, z: 0, w: -0.90704405}
m_LocalPosition: {x: 0, y: 0, z: -2.857143}
m_LocalScale: {x: 0.5, y: 0.5, z: 1}
m_ConstrainProportionsScale: 0
Expand All @@ -4997,7 +5003,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: -5, y: 5.2}
m_AnchoredPosition: {x: -5, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!223 &8480462646933472547
Expand Down
40 changes: 31 additions & 9 deletions Assets/Gothic-VR/Resources/VR/Prefabs/VR - Player XRI.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -5331,6 +5331,11 @@ Transform:
m_CorrespondingSourceObject: {fileID: 2282871596405899006, guid: cd095a3981bb372429f6df026b1dec73, type: 3}
m_PrefabInstance: {fileID: 389902283970083402}
m_PrefabAsset: {fileID: 0}
--- !u!1 &8202939263791807834 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8412591900964177680, guid: cd095a3981bb372429f6df026b1dec73, type: 3}
m_PrefabInstance: {fileID: 389902283970083402}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &2518208126512905943
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -5892,15 +5897,16 @@ PrefabInstance:
propertyPath: m_Name
value: Gothic-logo
objectReference: {fileID: 0}
- target: {fileID: 6793405629452684711, guid: d905c6fd3294c82478f4edf887cac0a9, type: 3}
propertyPath: _tutorialHandler
value:
objectReference: {fileID: 4635703751691790106}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d905c6fd3294c82478f4edf887cac0a9, type: 3}
--- !u!1 &651131927819320523 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 5443751599501581721, guid: d905c6fd3294c82478f4edf887cac0a9, type: 3}
m_PrefabInstance: {fileID: 4793340960506667346}
m_PrefabAsset: {fileID: 0}
--- !u!224 &6971875092960890840 stripped
RectTransform:
m_CorrespondingSourceObject: {fileID: 2469183434187583114, guid: d905c6fd3294c82478f4edf887cac0a9, type: 3}
Expand Down Expand Up @@ -6056,6 +6062,11 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 442d7862e66282348b7a8c3c0dffdc95, type: 3}
--- !u!1 &2599487134210044051 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 8412591900964177680, guid: 442d7862e66282348b7a8c3c0dffdc95, type: 3}
m_PrefabInstance: {fileID: 5813227951801890691}
m_PrefabAsset: {fileID: 0}
--- !u!4 &5693358733919242621 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2282871596405899006, guid: 442d7862e66282348b7a8c3c0dffdc95, type: 3}
Expand Down Expand Up @@ -6175,16 +6186,27 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4906976065703679581, guid: a0af29d97abd24d4c8382b6da4017660, type: 3}
propertyPath: _logo
value:
objectReference: {fileID: 651131927819320523}
- target: {fileID: 4906976065703679581, guid: a0af29d97abd24d4c8382b6da4017660, type: 3}
propertyPath: _hiddenWhileShown.Array.size
value: 2
objectReference: {fileID: 0}
- target: {fileID: 4906976065703679581, guid: a0af29d97abd24d4c8382b6da4017660, type: 3}
propertyPath: '_hiddenWhileShown.Array.data[0]'
value:
objectReference: {fileID: 2599487134210044051}
- target: {fileID: 4906976065703679581, guid: a0af29d97abd24d4c8382b6da4017660, type: 3}
propertyPath: '_hiddenWhileShown.Array.data[1]'
value:
objectReference: {fileID: 8202939263791807834}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a0af29d97abd24d4c8382b6da4017660, type: 3}
--- !u!1 &4635703751691790106 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1879303798920566507, guid: a0af29d97abd24d4c8382b6da4017660, type: 3}
m_PrefabInstance: {fileID: 6503748551157953009}
m_PrefabAsset: {fileID: 0}
--- !u!4 &5039203737416974477 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 2283093842980008316, guid: a0af29d97abd24d4c8382b6da4017660, type: 3}
Expand Down
89 changes: 86 additions & 3 deletions Assets/Gothic-VR/Scripts/Adapters/UI/Menus/TutorialHandler.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,57 @@
using Gothic.Core.Services.Meshes;
using Gothic.Core.Services.Vm;
using Gothic.Core;
using Gothic.Core.Adapters.UI.Menus;
using Gothic.Core.Const;
using Gothic.Core.Logging;
using Reflex.Attributes;
using UnityEngine;
using UnityEngine.UI;
using Logger = Gothic.Core.Logging.Logger;

namespace Gothic.VR.Adapters.UI.Menus
{
/// <summary>
/// Shows the VR help panels when its Gothic logo is clicked and hides them on the next click.
/// The panels take the menus' places: the menus in _hiddenWhileShown and the open Gothic menu
/// (MenuHandler.CurrentMenu) are hidden meanwhile. The next MenuOpened (back button, menu reopened after a close)
/// brings the menus back.
/// </summary>
public class TutorialHandler : MonoBehaviour
{
[SerializeField] private Image[] _backgroundImages;

[Tooltip("The Gothic logo whose clicks show and hide the panels.")]
[SerializeField] private GameObject _logo;
[Tooltip("The help panels to show and hide (Quest2, Hero Slots, Help).")]
[SerializeField] private GameObject[] _panels;
[Tooltip("Side menus hidden while the panels are shown (status, quest log). The open Gothic menu is " +
"always hidden. Empty in the main menu scene.")]
[SerializeField] private GameObject[] _hiddenWhileShown;

[Inject] private readonly VmService _vmService;
[Inject] private readonly TextureService _textureService;


private bool _isShown;
private MenuHandler _menuHandler;
private GameObject _hiddenMenu;


private void Awake()
{
gameObject.SetActive(false);
SetActive(_panels, false);

// MenuHandler opens its first menu before this Awake (it activates first), so it's asked on show.
_menuHandler = GetComponentInParent<MenuHandler>(true);

GlobalEventDispatcher.GothicLogoClicked.AddListener(OnGothicLogoClicked);
GlobalEventDispatcher.MenuOpened.AddListener(OnMenuOpened);
}

private void Start()
{
var backPic = _textureService.GetMaterial(_vmService.BackPic);

foreach (var image in _backgroundImages)
{
image.material = backPic;
Expand All @@ -35,5 +62,61 @@ private void Start()
if (onTop != null)
onTop.Apply();
}

private void OnDestroy()
{
GlobalEventDispatcher.GothicLogoClicked.RemoveListener(OnGothicLogoClicked);
GlobalEventDispatcher.MenuOpened.RemoveListener(OnMenuOpened);
}

private void OnGothicLogoClicked(GameObject logo)
{
if (logo != _logo)
return;

_isShown = !_isShown;
SetActive(_panels, _isShown);
SetActive(_hiddenWhileShown, !_isShown);

if (_isShown)
{
_hiddenMenu = _menuHandler != null ? _menuHandler.CurrentMenu : null;
if (_hiddenMenu != null)
_hiddenMenu.SetActive(false);
}
else
{
if (_hiddenMenu != null)
_hiddenMenu.SetActive(true);
_hiddenMenu = null;
}

Logger.Log($"[TutorialHandler] Help panels {(_isShown ? "shown" : "hidden")}", LogCat.Ui);
}

/// <summary>
/// MenuHandler activated the new menu itself: only the panels and side menus switch back.
/// </summary>
private void OnMenuOpened(GameObject menu)
{
if (!_isShown)
return;

_isShown = false;
_hiddenMenu = null;
SetActive(_panels, false);
SetActive(_hiddenWhileShown, true);

Logger.Log("[TutorialHandler] Help panels hidden, menu opened", LogCat.Ui);
}

private static void SetActive(GameObject[] gameObjects, bool isActive)
{
foreach (var go in gameObjects)
{
if (go != null)
go.SetActive(isActive);
}
}
}
}
Loading