Commit 0abf28f4 authored by ElderLich's avatar ElderLich

Bug Fix: Fix replay Free View UI state and end notification

Fixes several replay Free View issues: opponent hand cards no longer render with bad position/shadows, the replay-ended notice is shown reliably, and the Free View button now restores its normal black background after hover/returning from replay.
parent 004d536b
...@@ -13,6 +13,7 @@ using System.Threading; ...@@ -13,6 +13,7 @@ using System.Threading;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.Playables; using UnityEngine.Playables;
using UnityEngine.Rendering;
using YgomGame.Duel; using YgomGame.Duel;
using YgomSystem.ElementSystem; using YgomSystem.ElementSystem;
using static MDPro3.Servant.OcgCore; using static MDPro3.Servant.OcgCore;
...@@ -437,12 +438,16 @@ namespace MDPro3 ...@@ -437,12 +438,16 @@ namespace MDPro3
{ {
SetFace(); SetFace();
ShowFaceDownCardOrNot(NeedShowFaceDownCard()); ShowFaceDownCardOrNot(NeedShowFaceDownCard());
RefreshHandShadowState();
} }
} }
} }
data = d; data = d;
if (model != null && p.InLocation(CardLocation.Hand) && !inAnimation) if (model != null && p.InLocation(CardLocation.Hand) && !inAnimation)
{
RefreshHandTurnByCode(); RefreshHandTurnByCode();
RefreshHandShadowState();
}
RefreshLabel(); RefreshLabel();
UpdateExDeckTop(); UpdateExDeckTop();
} }
...@@ -719,7 +724,10 @@ namespace MDPro3 ...@@ -719,7 +724,10 @@ namespace MDPro3
private static float GetOpHandBaseZ() private static float GetOpHandBaseZ()
{ {
return 17f - GetHandDepthOffsetByFov(); var baseZ = 17f;
if (CurrentReplayGodView)
baseZ += 2f;
return baseZ - GetHandDepthOffsetByFov();
} }
private static float GetHandDepthOffsetByFov() private static float GetHandDepthOffsetByFov()
...@@ -1036,6 +1044,7 @@ namespace MDPro3 ...@@ -1036,6 +1044,7 @@ namespace MDPro3
CreateModel(); CreateModel();
ModelAt(p); ModelAt(p);
ShowFaceDownCardOrNot(NeedShowFaceDownCard()); ShowFaceDownCardOrNot(NeedShowFaceDownCard());
RefreshHandShadowState();
if (IsFaceDownOnSpellZone()) if (IsFaceDownOnSpellZone())
setOverTurn = true; setOverTurn = true;
if (p.InLocation(CardLocation.Hand)) if (p.InLocation(CardLocation.Hand))
...@@ -1578,6 +1587,7 @@ namespace MDPro3 ...@@ -1578,6 +1587,7 @@ namespace MDPro3
ShowFaceDownCardOrNot(NeedShowFaceDownCard()); ShowFaceDownCardOrNot(NeedShowFaceDownCard());
RefreshHandTurnByCode(); RefreshHandTurnByCode();
RefreshHandShadowState();
if (p.InLocation(CardLocation.Deck, CardLocation.Extra)) if (p.InLocation(CardLocation.Deck, CardLocation.Extra))
Program.instance.ocgcore.DuelBGManager.ResizeDecks(); Program.instance.ocgcore.DuelBGManager.ResizeDecks();
...@@ -1592,6 +1602,23 @@ namespace MDPro3 ...@@ -1592,6 +1602,23 @@ namespace MDPro3
manager.GetElement<Transform>("Turn").localEulerAngles = new Vector3(0, 0, data.Id == 0 ? 180 : 0); manager.GetElement<Transform>("Turn").localEulerAngles = new Vector3(0, 0, data.Id == 0 ? 180 : 0);
} }
private void RefreshHandShadowState()
{
if (model == null)
return;
var mode = CurrentReplayGodView && p.InLocation(CardLocation.Hand) && !p.InMyControl()
? ShadowCastingMode.Off
: ShadowCastingMode.On;
var cardModel = manager.GetElement<Transform>("CardModel");
for (int i = 0; i < cardModel.childCount; i++)
{
var renderer = cardModel.GetChild(i).GetComponent<Renderer>();
if (renderer != null)
renderer.shadowCastingMode = mode;
}
}
public Sequence StartCardSequence(Vector3 fromPosition, Vector3 fromRotation, float interval = 0f) public Sequence StartCardSequence(Vector3 fromPosition, Vector3 fromRotation, float interval = 0f)
{ {
if (model == null) if (model == null)
......
...@@ -663,6 +663,8 @@ namespace MDPro3.Duel ...@@ -663,6 +663,8 @@ namespace MDPro3.Duel
MessageManager.Cast(endingReason); MessageManager.Cast(endingReason);
if (condition != Condition.Replay) if (condition != Condition.Replay)
Core.GetUI<OcgCoreUI>().ShowSaveReplay(); Core.GetUI<OcgCoreUI>().ShowSaveReplay();
else
Core.NotifyReplayPlaybackEnded();
} }
protected override UniTask GameMessage_UpdateData(BinaryReader reader) protected override UniTask GameMessage_UpdateData(BinaryReader reader)
......
...@@ -203,6 +203,7 @@ namespace MDPro3.Servant ...@@ -203,6 +203,7 @@ namespace MDPro3.Servant
public static bool inputMode; public static bool inputMode;
public static bool Accing; public static bool Accing;
public static bool CurrentReplayUseYRP2; public static bool CurrentReplayUseYRP2;
public static bool CurrentReplayGodView;
#endregion #endregion
...@@ -259,6 +260,7 @@ namespace MDPro3.Servant ...@@ -259,6 +260,7 @@ namespace MDPro3.Servant
{ {
base.OnExit(); base.OnExit();
CloseConnection(); CloseConnection();
CurrentReplayGodView = false;
GetUI<OcgCoreUI>().OnNor(); GetUI<OcgCoreUI>().OnNor();
} }
...@@ -706,6 +708,7 @@ namespace MDPro3.Servant ...@@ -706,6 +708,7 @@ namespace MDPro3.Servant
packages.Clear(); packages.Clear();
packages = null; packages = null;
packages = packs; packages = packs;
replayPlaybackEndedNotified = false;
allPackages.Clear(); allPackages.Clear();
foreach (Package p in packages) foreach (Package p in packages)
allPackages.Add(p); allPackages.Add(p);
...@@ -924,6 +927,7 @@ namespace MDPro3.Servant ...@@ -924,6 +927,7 @@ namespace MDPro3.Servant
private async UniTask ProcessMessage() private async UniTask ProcessMessage()
{ {
messageDispatcher.Dispose(); messageDispatcher.Dispose();
replayPlaybackEndedNotified = false;
try try
{ {
...@@ -961,12 +965,15 @@ namespace MDPro3.Servant ...@@ -961,12 +965,15 @@ namespace MDPro3.Servant
lastMessage = currentMessage; lastMessage = currentMessage;
if (packages.Count == 0) if (packages.Count == 0)
{
NotifyReplayPlaybackEnded();
break; break;
}
packages.RemoveAt(0); packages.RemoveAt(0);
if (condition == Condition.Replay && packages.Count == 0) if (condition == Condition.Replay && packages.Count == 0)
{ {
MessageManager.Cast(InterString.Get("回放播放结束。")); NotifyReplayPlaybackEnded();
break; break;
} }
} }
...@@ -974,6 +981,17 @@ namespace MDPro3.Servant ...@@ -974,6 +981,17 @@ namespace MDPro3.Servant
catch (Exception e) { Debug.Log(e); } catch (Exception e) { Debug.Log(e); }
} }
private bool replayPlaybackEndedNotified;
public void NotifyReplayPlaybackEnded()
{
if (condition != Condition.Replay || replayPlaybackEndedNotified)
return;
replayPlaybackEndedNotified = true;
MessageManager.Cast(InterString.Get("回放播放结束。"));
}
#endregion #endregion
#region PracticalizeTools #region PracticalizeTools
......
...@@ -22,6 +22,7 @@ namespace MDPro3.Servant ...@@ -22,6 +22,7 @@ namespace MDPro3.Servant
protected override void ApplyShowArrangement(int preDepth) protected override void ApplyShowArrangement(int preDepth)
{ {
base.ApplyShowArrangement(preDepth); base.ApplyShowArrangement(preDepth);
RefreshButtonMaterials();
GetUI<ReplaySelectorUI>().Print(); GetUI<ReplaySelectorUI>().Print();
} }
...@@ -44,6 +45,8 @@ namespace MDPro3.Servant ...@@ -44,6 +45,8 @@ namespace MDPro3.Servant
if (!forced && !UserInput.NeedDefaultSelect()) if (!forced && !UserInput.NeedDefaultSelect())
return; return;
if (lastSelectedReplayItem == null)
return;
lastSelectedReplayItem.GetSelectable().Select(); lastSelectedReplayItem.GetSelectable().Select();
} }
...@@ -56,10 +59,19 @@ namespace MDPro3.Servant ...@@ -56,10 +59,19 @@ namespace MDPro3.Servant
protected override void FirstLoadEvent() protected override void FirstLoadEvent()
{ {
base.FirstLoadEvent(); base.FirstLoadEvent();
RefreshButtonMaterials();
if(Program.exitOnReturn) if(Program.exitOnReturn)
GetUI<ReplaySelectorUI>().KF_Replay(replayName); GetUI<ReplaySelectorUI>().KF_Replay(replayName);
} }
private void RefreshButtonMaterials()
{
var ui = GetUI<ReplaySelectorUI>();
ui.ButtonGodView.ResetVisualState(true);
_ = Program.instance.texture_.SetCommonShopButtonMaterial(ui.ImageOut, false);
_ = Program.instance.texture_.SetCommonShopButtonMaterial(ui.ImageHover, true);
}
private string replayName; private string replayName;
public void PlayReplay(string replayName) public void PlayReplay(string replayName)
{ {
......
...@@ -514,6 +514,20 @@ namespace MDPro3.UI ...@@ -514,6 +514,20 @@ namespace MDPro3.UI
return Selectable; return Selectable;
} }
public virtual void ResetVisualState(bool clearEventSelection = false)
{
hovering = false;
pressing = false;
selected = false;
if (clearEventSelection && EventSystem.current != null
&& EventSystem.current.currentSelectedGameObject == gameObject)
EventSystem.current.SetSelectedGameObject(null);
HoverOff();
SetColor(SelectMode.Unselected, StatusMode.Normal, Selectable.interactable);
}
#endregion #endregion
#region Navigation #region Navigation
......
...@@ -87,6 +87,7 @@ namespace MDPro3.UI.ServantUI ...@@ -87,6 +87,7 @@ namespace MDPro3.UI.ServantUI
public void KF_Replay(string name, bool god = false) public void KF_Replay(string name, bool god = false)
{ {
OcgCore.CurrentReplayGodView = god;
string fileName = Program.PATH_REPLAY + name + (name.EndsWith(Program.EXPANSION_YRP) ? string.Empty : Program.EXPANSION_YRP3D); string fileName = Program.PATH_REPLAY + name + (name.EndsWith(Program.EXPANSION_YRP) ? string.Empty : Program.EXPANSION_YRP3D);
if (!File.Exists(fileName)) if (!File.Exists(fileName))
{ {
...@@ -420,6 +421,7 @@ namespace MDPro3.UI.ServantUI ...@@ -420,6 +421,7 @@ namespace MDPro3.UI.ServantUI
public void SelectLastReplayItem() public void SelectLastReplayItem()
{ {
UserInput.NextSelectionIsAxis = true; UserInput.NextSelectionIsAxis = true;
if (Program.instance.replay.lastSelectedReplayItem != null)
Program.instance.replay.lastSelectedReplayItem.GetSelectable().Select(); Program.instance.replay.lastSelectedReplayItem.GetSelectable().Select();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment