You need to sign in or sign up before continuing.
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;
using TMPro;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Rendering;
using YgomGame.Duel;
using YgomSystem.ElementSystem;
using static MDPro3.Servant.OcgCore;
......@@ -437,12 +438,16 @@ namespace MDPro3
{
SetFace();
ShowFaceDownCardOrNot(NeedShowFaceDownCard());
RefreshHandShadowState();
}
}
}
data = d;
if (model != null && p.InLocation(CardLocation.Hand) && !inAnimation)
{
RefreshHandTurnByCode();
RefreshHandShadowState();
}
RefreshLabel();
UpdateExDeckTop();
}
......@@ -719,7 +724,10 @@ namespace MDPro3
private static float GetOpHandBaseZ()
{
return 17f - GetHandDepthOffsetByFov();
var baseZ = 17f;
if (CurrentReplayGodView)
baseZ += 2f;
return baseZ - GetHandDepthOffsetByFov();
}
private static float GetHandDepthOffsetByFov()
......@@ -1036,6 +1044,7 @@ namespace MDPro3
CreateModel();
ModelAt(p);
ShowFaceDownCardOrNot(NeedShowFaceDownCard());
RefreshHandShadowState();
if (IsFaceDownOnSpellZone())
setOverTurn = true;
if (p.InLocation(CardLocation.Hand))
......@@ -1578,6 +1587,7 @@ namespace MDPro3
ShowFaceDownCardOrNot(NeedShowFaceDownCard());
RefreshHandTurnByCode();
RefreshHandShadowState();
if (p.InLocation(CardLocation.Deck, CardLocation.Extra))
Program.instance.ocgcore.DuelBGManager.ResizeDecks();
......@@ -1592,6 +1602,23 @@ namespace MDPro3
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)
{
if (model == null)
......
......@@ -663,6 +663,8 @@ namespace MDPro3.Duel
MessageManager.Cast(endingReason);
if (condition != Condition.Replay)
Core.GetUI<OcgCoreUI>().ShowSaveReplay();
else
Core.NotifyReplayPlaybackEnded();
}
protected override UniTask GameMessage_UpdateData(BinaryReader reader)
......
......@@ -203,6 +203,7 @@ namespace MDPro3.Servant
public static bool inputMode;
public static bool Accing;
public static bool CurrentReplayUseYRP2;
public static bool CurrentReplayGodView;
#endregion
......@@ -259,6 +260,7 @@ namespace MDPro3.Servant
{
base.OnExit();
CloseConnection();
CurrentReplayGodView = false;
GetUI<OcgCoreUI>().OnNor();
}
......@@ -706,6 +708,7 @@ namespace MDPro3.Servant
packages.Clear();
packages = null;
packages = packs;
replayPlaybackEndedNotified = false;
allPackages.Clear();
foreach (Package p in packages)
allPackages.Add(p);
......@@ -924,6 +927,7 @@ namespace MDPro3.Servant
private async UniTask ProcessMessage()
{
messageDispatcher.Dispose();
replayPlaybackEndedNotified = false;
try
{
......@@ -961,12 +965,15 @@ namespace MDPro3.Servant
lastMessage = currentMessage;
if (packages.Count == 0)
{
NotifyReplayPlaybackEnded();
break;
}
packages.RemoveAt(0);
if (condition == Condition.Replay && packages.Count == 0)
{
MessageManager.Cast(InterString.Get("回放播放结束。"));
NotifyReplayPlaybackEnded();
break;
}
}
......@@ -974,6 +981,17 @@ namespace MDPro3.Servant
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
#region PracticalizeTools
......
......@@ -22,6 +22,7 @@ namespace MDPro3.Servant
protected override void ApplyShowArrangement(int preDepth)
{
base.ApplyShowArrangement(preDepth);
RefreshButtonMaterials();
GetUI<ReplaySelectorUI>().Print();
}
......@@ -44,6 +45,8 @@ namespace MDPro3.Servant
if (!forced && !UserInput.NeedDefaultSelect())
return;
if (lastSelectedReplayItem == null)
return;
lastSelectedReplayItem.GetSelectable().Select();
}
......@@ -56,10 +59,19 @@ namespace MDPro3.Servant
protected override void FirstLoadEvent()
{
base.FirstLoadEvent();
RefreshButtonMaterials();
if(Program.exitOnReturn)
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;
public void PlayReplay(string replayName)
{
......
......@@ -514,6 +514,20 @@ namespace MDPro3.UI
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
#region Navigation
......
......@@ -87,6 +87,7 @@ namespace MDPro3.UI.ServantUI
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);
if (!File.Exists(fileName))
{
......@@ -420,7 +421,8 @@ namespace MDPro3.UI.ServantUI
public void SelectLastReplayItem()
{
UserInput.NextSelectionIsAxis = true;
Program.instance.replay.lastSelectedReplayItem.GetSelectable().Select();
if (Program.instance.replay.lastSelectedReplayItem != null)
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