From eb6b25256b87fee4f070531524bf560cd0bc2849 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Tue, 6 May 2025 10:43:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84:AfterPushFrame=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=B8=BAprotected=E6=96=B9=E6=B3=95,=E5=8E=9F?= =?UTF-8?q?=E5=85=88=E8=B7=B3=E5=B8=A7=E9=80=BB=E8=BE=91=E4=BB=8EInGameUI?= =?UTF-8?q?=E7=A7=BB=E5=85=A5EmuCore=E5=9F=BA=E7=B1=BB=E4=B8=AD=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0,=E5=8E=9F=E5=85=88InGameUI.IsNetPlay=E7=A7=BB?= =?UTF-8?q?=E5=85=A5EmuCore.IsNetPlay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Emulator/EssgeeEmulator/UEssgee.cs | 2 +- .../AppMain/Emulator/MameEmulator/UMAME.cs | 2 +- .../MameEmulator/UniInterface/UniKeyboard.cs | 2 +- .../Emulator/NesEmulator/NesEmulator.cs | 2 +- .../StoicGooseEmulator/UStoicGoose.cs | 2 +- .../Assets/Script/AppMain/Manager/AppEmu.cs | 12 +++---- .../Script/AppMain/UI/InGameUI/InGameUI.cs | 34 +++---------------- .../UI/InGameUI/InGameUI_LoadStateQuick.cs | 4 +-- .../AppMain/UI/InGameUI/InGameUI_Reset.cs | 4 +-- .../UI/InGameUI/InGameUI_SaveStateQuick.cs | 4 +-- 10 files changed, 22 insertions(+), 46 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/EssgeeEmulator/UEssgee.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/EssgeeEmulator/UEssgee.cs index 69ef9530..4945f129 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/EssgeeEmulator/UEssgee.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/EssgeeEmulator/UEssgee.cs @@ -167,7 +167,7 @@ public class UEssgee : EmuCore return mUniKeyboard.DoLocalPressedKeys(); } - public override void AfterPushFrame() + protected override void AfterPushFrame() { } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/MameEmulator/UMAME.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/MameEmulator/UMAME.cs index 253836be..13e0eb28 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/MameEmulator/UMAME.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/MameEmulator/UMAME.cs @@ -179,7 +179,7 @@ public class UMAME : EmuCore return mUniKeyboard.DoLocalPressedKeys(); } - public override void AfterPushFrame() + protected override void AfterPushFrame() { mFPS.text = ($"fpsv {mUniVideoPlayer.videoFPS.ToString("F2")} fpsa {mUniSoundPlayer.audioFPS.ToString("F2")} ,Idx:{App.roomMgr.netReplay?.mCurrClientFrameIdx},RIdx:{App.roomMgr.netReplay?.mRemoteFrameIdx},RForward:{App.roomMgr.netReplay?.mRemoteForwardCount} ,RD:{App.roomMgr.netReplay?.mRemoteForwardCount} ,D:{App.roomMgr.netReplay?.mDiffFrameCount} ,Q:{App.roomMgr.netReplay?.mNetReplayQueue.Count}"); } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/MameEmulator/UniInterface/UniKeyboard.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/MameEmulator/UniInterface/UniKeyboard.cs index 92b63622..924701bb 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/MameEmulator/UniInterface/UniKeyboard.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/MameEmulator/UniInterface/UniKeyboard.cs @@ -65,7 +65,7 @@ public class UniKeyboard : MonoBehaviour, IKeyboard public ulong GetPressedKeys() { - if (InGameUI.Instance.IsNetPlay) + if (InGameUI.Instance.Core.IsNetPlay) return CurrRemoteInpuAllData; else return CurrLocalInpuAllData; diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/NesEmulator.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/NesEmulator.cs index 69cf14d7..e5f8062b 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/NesEmulator.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/NesEmulator/NesEmulator.cs @@ -149,7 +149,7 @@ namespace AxibugEmuOnline.Client } - public override unsafe void AfterPushFrame() + protected override unsafe void AfterPushFrame() { var screenBuffer = NesCore.ppu.GetScreenPtr(); VideoProvider.SetDrawData(screenBuffer); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/StoicGooseEmulator/UStoicGoose.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/StoicGooseEmulator/UStoicGoose.cs index 7ec435cb..5d1705e3 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/StoicGooseEmulator/UStoicGoose.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/StoicGooseEmulator/UStoicGoose.cs @@ -145,7 +145,7 @@ public class UStoicGoose : EmuCore throw new NotImplementedException(); } - public override void AfterPushFrame() + protected override void AfterPushFrame() { throw new NotImplementedException(); } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs index d53608f6..52332280 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs @@ -11,7 +11,7 @@ namespace AxibugEmuOnline.Client.Manager /// unity的c#实现有bug,以接口类型保存的monobehaviour引用,!=和==运算符没有调用到monobehaviour重写过的运算符 /// 但是Equals方法可以,所以,这个接口判断为空请使用Equals /// - private IEmuCore m_emuCore; + private EmuCore m_emuCore; private IControllerSetuper m_controllerSetuper; @@ -19,7 +19,7 @@ namespace AxibugEmuOnline.Client.Manager /// unity的c#实现有bug,以接口类型保存的monobehaviour引用,!=和==运算符没有调用到monobehaviour重写过的运算符 /// 但是Equals方法可以,所以,这个接口判断为空请使用Equals /// - public IEmuCore Core => m_emuCore; + public EmuCore Core => m_emuCore; public AppEmu() { @@ -53,14 +53,14 @@ namespace AxibugEmuOnline.Client.Manager switch (romFile.Platform) { case RomPlatformType.Nes: - m_emuCore = GameObject.Instantiate(Resources.Load("NES/NesEmulator")).GetComponent(); + m_emuCore = GameObject.Instantiate(Resources.Load("NES/NesEmulator")).GetComponent(); break; case RomPlatformType.Cps1: case RomPlatformType.Cps2: case RomPlatformType.Igs: case RomPlatformType.Neogeo: case RomPlatformType.ArcadeOld: - m_emuCore = GameObject.Instantiate(Resources.Load("MAME/UMAME")).GetComponent(); + m_emuCore = GameObject.Instantiate(Resources.Load("MAME/UMAME")).GetComponent(); break; case RomPlatformType.MasterSystem: case RomPlatformType.GameGear: @@ -69,11 +69,11 @@ namespace AxibugEmuOnline.Client.Manager case RomPlatformType.ColecoVision: case RomPlatformType.Sc3000: case RomPlatformType.Sg1000: - m_emuCore = GameObject.Instantiate(Resources.Load("EssgeeUnity/EssgeeUnity")).GetComponent(); + m_emuCore = GameObject.Instantiate(Resources.Load("EssgeeUnity/EssgeeUnity")).GetComponent(); break; case RomPlatformType.WonderSwan: case RomPlatformType.WonderSwanColor: - m_emuCore = GameObject.Instantiate(Resources.Load("StoicGooseUnity/StoicGooseUnity")).GetComponent(); + m_emuCore = GameObject.Instantiate(Resources.Load("StoicGooseUnity/StoicGooseUnity")).GetComponent(); break; } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs index 6a8b0dea..3ed9dd31 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs @@ -20,20 +20,7 @@ namespace AxibugEmuOnline.Client public override bool Enable => gameObject.activeInHierarchy; - /// 指示该游戏实例是否处于联机模式 - public bool IsNetPlay - { - get - { - if (!App.user.IsLoggedIn) return false; - if (App.roomMgr.mineRoomMiniInfo == null) return false; - if (App.roomMgr.RoomState <= RoomGameState.OnlyHost) return false; - - return true; - } - } - - public IEmuCore Core { get; private set; } + public EmuCore Core { get; private set; } protected override void Awake() { @@ -69,18 +56,7 @@ namespace AxibugEmuOnline.Client //fluash netMsg NetMsg.Instance.DequeueNesMsg(); - if (!Core.PushEmulatorFrame()) return; - - if (IsNetPlay) //skip frame handle - { - var skipFrameCount = App.roomMgr.netReplay.GetSkipFrameCount(); - if (skipFrameCount > 0) App.log.Debug($"SKIP FRAME : {skipFrameCount} ,CF:{App.roomMgr.netReplay.mCurrClientFrameIdx},RFIdx:{App.roomMgr.netReplay.mRemoteFrameIdx},RForward:{App.roomMgr.netReplay.mRemoteForwardCount} ,queue:{App.roomMgr.netReplay.mNetReplayQueue.Count}"); - for (var i = 0; i < skipFrameCount; i++) - if (!Core.PushEmulatorFrame()) - break; - } - - Core.AfterPushFrame(); + Core.PushEmulatorFrame(); } protected override void OnDestroy() @@ -103,7 +79,7 @@ namespace AxibugEmuOnline.Client return m_state; } - public void Show(RomFile currentRom, IEmuCore core) + public void Show(RomFile currentRom, EmuCore core) { m_delayCreateRoom = false; m_state = null; //清空游戏快照 @@ -186,14 +162,14 @@ namespace AxibugEmuOnline.Client { OverlayManager.PopSideBar(menus, 0, PopMenu_OnHide); - if (!IsNetPlay) //单人模式暂停模拟器 + if (!Core.IsNetPlay) //单人模式暂停模拟器 Core.Pause(); } //菜单关闭时候 private void PopMenu_OnHide() { - if (!IsNetPlay) //单人模式恢复模拟器的暂停 + if (!Core.IsNetPlay) //单人模式恢复模拟器的暂停 Core.Resume(); } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_LoadStateQuick.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_LoadStateQuick.cs index b4b39e24..0fa39a39 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_LoadStateQuick.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_LoadStateQuick.cs @@ -3,7 +3,7 @@ public class InGameUI_LoadStateQuick : ExecuteMenu { private InGameUI m_gameUI; - public override bool Visible => !m_gameUI.IsNetPlay && m_gameUI.GetQuickState() != null; + public override bool Visible => !m_gameUI.Core.IsNetPlay && m_gameUI.GetQuickState() != null; public override string Name => "快速读取"; public InGameUI_LoadStateQuick(InGameUI gameUI) @@ -13,7 +13,7 @@ public override void OnExcute(OptionUI optionUI, ref bool cancelHide) { - if (m_gameUI.IsNetPlay) return; + if (m_gameUI.Core.IsNetPlay) return; object state = m_gameUI.GetQuickState(); if (state != null) diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Reset.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Reset.cs index a804dd66..32db8a89 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Reset.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Reset.cs @@ -6,7 +6,7 @@ namespace AxibugEmuOnline.Client { private InGameUI m_gameUI; public override string Name => "复位"; - public override bool Visible => !m_gameUI.IsNetPlay || App.roomMgr.IsHost; + public override bool Visible => !m_gameUI.Core.IsNetPlay || App.roomMgr.IsHost; public InGameUI_Reset(InGameUI gameUI) { @@ -15,7 +15,7 @@ namespace AxibugEmuOnline.Client public override void OnExcute(OptionUI optionUI, ref bool cancelHide) { - if (!m_gameUI.IsNetPlay) + if (!m_gameUI.Core.IsNetPlay) { App.emu.ResetGame(); } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_SaveStateQuick.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_SaveStateQuick.cs index f8a51a1b..c8e5c506 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_SaveStateQuick.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_SaveStateQuick.cs @@ -7,7 +7,7 @@ namespace AxibugEmuOnline.Client { private InGameUI m_gameUI; - public override bool Visible => !m_gameUI.IsNetPlay; + public override bool Visible => !m_gameUI.Core.IsNetPlay; public override string Name => "快速保存"; public InGameUI_SaveStateQuick(InGameUI gameUI) @@ -17,7 +17,7 @@ namespace AxibugEmuOnline.Client public override void OnExcute(OptionUI optionUI, ref bool cancelHide) { - if (m_gameUI.IsNetPlay) return; + if (m_gameUI.Core.IsNetPlay) return; Stopwatch sw = Stopwatch.StartNew(); object state = m_gameUI.Core.GetState();