Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 96/dialog subtitles #166

Merged
merged 19 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface IInteractionAdapter
float GetFrameRate();
GameObject CreatePlayerController(Scene scene, Vector3 position = default, Quaternion rotation = default);
void CreateVRDeviceSimulator();
void LockPlayerInPlaceCutscene();
BoroBongo marked this conversation as resolved.
Show resolved Hide resolved
void LockPlayerInPlace();
void UnlockPlayer();
void TeleportPlayerTo(Vector3 position, Quaternion rotation = default);
Expand Down
15 changes: 15 additions & 0 deletions Assets/UnZENity-Core/Scripts/Adapter/ISubtitlesAdapter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using GUZ.Core.Data;
using UnityEngine;
using ZenKit.Daedalus;

namespace GUZ.Core.Adapter
{
public interface ISubtitlesAdapter
{
public void ShowDialog(GameObject npcGo);
public void HideDialog();
public void HideDialogImmediate();
public void FillDialog(string npcName, string text);
}
}
1 change: 1 addition & 0 deletions Assets/UnZENity-Core/Scripts/GameContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static class GameContext

public static IInteractionAdapter InteractionAdapter;
public static IDialogAdapter DialogAdapter;
public static ISubtitlesAdapter SubtitlesAdapter;
public static IGameVersionAdapter GameVersionAdapter;

public enum Controls
Expand Down
3 changes: 3 additions & 0 deletions Assets/UnZENity-Core/Scripts/Globals/GameData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public static class Dialogs
public static List<InfoInstance> Instances = new();
public static bool IsInDialog;

// I'm too stupid to make it work through vfs need someone to help here
public static CutsceneLibrary CutsceneLibrary = new($"{GameGlobals.Settings.Gothic1Path}\\_work\\DATA\\scripts\\Content\\CUTSCENE\\Ou.csl");
BoroBongo marked this conversation as resolved.
Show resolved Hide resolved

public static int GestureCount;

public static class CurrentDialog
Expand Down
7 changes: 7 additions & 0 deletions Assets/UnZENity-Core/Scripts/Manager/DialogManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public static void StartDialog(GameObject npcGo, NpcProperties properties, bool
{
GameData.Dialogs.IsInDialog = true;

// WIP: locking movement
GameContext.InteractionAdapter.LockPlayerInPlaceCutscene();

// We are already inside a sub-dialog
if (GameData.Dialogs.CurrentDialog.Options.Any())
{
Expand Down Expand Up @@ -227,7 +230,11 @@ public static void StopDialog()
GameData.Dialogs.CurrentDialog.Options.Clear();
GameData.Dialogs.IsInDialog = false;

// WIP: unlocking movement
GameContext.InteractionAdapter.UnlockPlayer();

GameContext.DialogAdapter.HideDialog();
GameContext.SubtitlesAdapter.HideDialog();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using GUZ.Core.Globals;
using GUZ.Core.Manager;
using UnityEngine;
using ZenKit;
using ZenKit.Daedalus;
using Random = UnityEngine.Random;

namespace GUZ.Core.Npc.Actions.AnimationActions
Expand All @@ -31,8 +33,11 @@ public override void Start()
// If NPC talked before, we stop it immediately (As some audio samples are shorter than the actual animation)
AnimationCreator.StopAnimation(NpcGo);


NpcHelper.GetHeroGameObject().GetComponent<AudioSource>().PlayOneShot(audioClip);
// FIXME - Show subtitles somewhere next to Hero (== ourself/main camera)
// FIXME - Show subtitles somewhere next to Hero (== ourself/main camera) PrintDialog()
PrintDialog();

}
// NPC
else
Expand All @@ -46,7 +51,24 @@ public override void Start()
Props.NpcSound.PlayOneShot(audioClip);

// FIXME - Show subtitles above NPC
PrintDialog();
}
}

private void PrintDialog()
{
// FIXME - Show subtitles somewhere next to Hero (== ourself/main camera)
var currentMessage = GameData.Dialogs.CutsceneLibrary.Blocks.Find(x => x.Name == OutputName).Message;
NpcInstance foo = (NpcInstance)GameData.GothicVm.GlobalHero;
BoroBongo marked this conversation as resolved.
Show resolved Hide resolved
if(_isHeroSpeaking){
Debug.Log($"PrintDialog: {{ Hero: {currentMessage.Text}}}");
BoroBongo marked this conversation as resolved.
Show resolved Hide resolved
GameContext.SubtitlesAdapter.FillDialog(foo.GetName(NpcNameSlot.Slot0), currentMessage.Text);
}
else{
Debug.Log($"PrintDialog: {{ NPC: {currentMessage.Text}}}");
GameContext.SubtitlesAdapter.FillDialog(Props.NpcInstance.GetName(ZenKit.Daedalus.NpcNameSlot.Slot0), currentMessage.Text);
}
GameContext.SubtitlesAdapter.ShowDialog(Props.Go);
}

/// <summary>
Expand Down Expand Up @@ -95,6 +117,7 @@ public override bool IsFinished()
AnimationCreator.StopHeadMorphAnimation(Props, HeadMorph.HeadMorphType.Viseme);
}

GameContext.SubtitlesAdapter.HideDialog();
return true;
}

Expand Down
1 change: 1 addition & 0 deletions Assets/UnZENity-Flat/Scripts/FlatContextBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protected override void RegisterControlModule(GameContext.Controls controls)

GameContext.InteractionAdapter = new FlatInteractionAdapter();
GameContext.DialogAdapter = null; // TBD
GameContext.SubtitlesAdapter = null; // TBD
}

protected override void RegisterGameVersionModule(GameVersion version)
Expand Down
10 changes: 10 additions & 0 deletions Assets/UnZENity-Flat/Scripts/FlatInteractionAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ public void UnlockPlayer()
// Not yet implemented
}

public void LockPlayerInPlaceCutscene()
{
// Not yet implemented
}

public void UnlockPlayerInPlaceCutscene()
{
// Not yet implemented
}

public void TeleportPlayerTo(Vector3 position, Quaternion rotation = default)
{
_playerController.transform.SetLocalPositionAndRotation(position, rotation);
Expand Down
Loading
Loading