From 25aea138e18ecf6ed31b2f4e54e86f6384b4e0ae Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Tue, 7 Jan 2025 13:51:18 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8DRom=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UIPrefabs/SubMenuItemTemplates/Game_NES_Template.prefab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/SubMenuItemTemplates/Game_NES_Template.prefab b/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/SubMenuItemTemplates/Game_NES_Template.prefab index 5ef1fc3f..aa8146cd 100644 --- a/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/SubMenuItemTemplates/Game_NES_Template.prefab +++ b/AxibugEmuOnline.Client/Assets/Resources/UIPrefabs/SubMenuItemTemplates/Game_NES_Template.prefab @@ -476,7 +476,7 @@ MonoBehaviour: SelectScale: 1 UnSelectScale: 1 RomGroupRoot: {fileID: 3086674949377227884} - Platform: 0 + Platform: 1 SearchKey: --- !u!114 &5700455559359757662 MonoBehaviour: From 7acb2883e9e8f56cf5f8f4366792af891b663389 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Tue, 7 Jan 2025 13:52:14 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=86=85UI(InGameUI)?= =?UTF-8?q?=E4=BE=A7=E8=BE=B9=E6=A0=8F=E5=A2=9E=E5=8A=A0=E7=BC=A9=E6=94=BE?= =?UTF-8?q?=E6=AF=94=E4=BE=8B=E8=AE=BE=E7=BD=AE,=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E5=8D=95=E7=8B=AC=E4=BB=A5=E6=A8=A1=E6=8B=9F=E5=99=A8=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E4=B8=BA=E5=8D=95=E4=BD=8D=E8=AE=BE=E7=BD=AE=E7=BC=A9?= =?UTF-8?q?=E6=94=BE=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppMain/Manager/AppSettings/ScreenScaler.cs | 12 ++++++++++++ .../Assets/Script/AppMain/Manager/RomLib/RomLib.cs | 10 ++-------- .../Script/AppMain/UI/GamesUI/RomListMenuItem.cs | 1 - .../Assets/Script/AppMain/UI/InGameUI/InGameUI.cs | 1 + 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/ScreenScaler.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/ScreenScaler.cs index afabf2e2..228542ab 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/ScreenScaler.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/ScreenScaler.cs @@ -32,6 +32,18 @@ namespace AxibugEmuOnline.Client return (EnumScalerMode)setVal; } + public bool IsSetMode(RomPlatformType platform) + { + int setVal = PlayerPrefs.GetInt($"{nameof(ScreenScaler)}.PlatMode.{platform}", -1); + return setVal != -1; + } + + public void SetMode(RomPlatformType platform, EnumScalerMode? mode) + { + int setVal = mode == null ? -1 : (int)mode; + PlayerPrefs.SetInt($"{nameof(ScreenScaler)}.PlatMode.{platform}", setVal); + } + /// /// 根据缩放模式设置UI的缩放 /// diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/RomLib.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/RomLib.cs index 3df00135..fef19578 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/RomLib.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/RomLib.cs @@ -135,10 +135,7 @@ namespace AxibugEmuOnline.Client { FetchPageCmd.Remove(page); SaveRomInfoFromWeb(resp); - }, - //TODO 平台参数 - AxibugProtobuf.RomPlatformType.Nes, - lastSearchKey, pageNo, PAGE_SIZE); + }, m_platform, lastSearchKey, pageNo, PAGE_SIZE); } else { @@ -146,10 +143,7 @@ namespace AxibugEmuOnline.Client { FetchPageCmd.Remove(page); SaveRomInfoFromWeb(resp); - }, - //TODO 平台参数 - AxibugProtobuf.RomPlatformType.Nes, - pageNo, PAGE_SIZE); + }, m_platform, pageNo, PAGE_SIZE); } } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/GamesUI/RomListMenuItem.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/GamesUI/RomListMenuItem.cs index 8da6736a..5a7241fa 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/GamesUI/RomListMenuItem.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/GamesUI/RomListMenuItem.cs @@ -1,6 +1,5 @@ using AxibugEmuOnline.Client.ClientCore; using AxibugProtobuf; -using System; using System.Collections.Generic; using UnityEngine; diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs index 99c5c089..e650c4e8 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs @@ -42,6 +42,7 @@ namespace AxibugEmuOnline.Client m_stepPerformer = new StepPerformer(this); menus.Add(new InGameUI_FilterSetting(this)); + menus.Add(new InGameUI_Scaler(this)); menus.Add(new InGameUI_Reset(this)); menus.Add(new InGameUI_SaveState(this)); menus.Add(new InGameUI_LoadState(this)); From 0628c4439d8d58a4d822f1852c8873c6cb9ece98 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Tue, 7 Jan 2025 14:11:02 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=BC=A9=E6=94=BE=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E7=B1=BB=E6=96=87=E4=BB=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AppMain/UI/InGameUI/InGameUI_Scaler.cs | 80 +++++++++++++++++++ .../UI/InGameUI/InGameUI_Scaler.cs.meta | 2 + 2 files changed, 82 insertions(+) create mode 100644 AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs create mode 100644 AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs.meta diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs new file mode 100644 index 00000000..012a0bab --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs @@ -0,0 +1,80 @@ +using AxibugEmuOnline.Client.ClientCore; +using System; +using System.Collections.Generic; +using UnityEngine; +using static AxibugEmuOnline.Client.ScreenScaler; + +namespace AxibugEmuOnline.Client +{ + public class InGameUI_Scaler : ExpandMenu + { + private List m_subMenus = new List(); + + public InGameUI_Scaler(InGameUI inGameUI) : base("屏幕比例", null) + { + m_subMenus.Add(new Scale(inGameUI, null)); + foreach (EnumScalerMode scaleModeValue in Enum.GetValues(typeof(EnumScalerMode))) + { + m_subMenus.Add(new Scale(inGameUI, scaleModeValue)); + } + } + + protected override List GetOptionMenus() + { + return m_subMenus; + } + + public class Scale : ExecuteMenu + { + private EnumScalerMode? m_mode; + private InGameUI m_gameUI; + + public override bool IsApplied + { + get + { + if (m_gameUI.Core.IsNull()) return false; + + var isSetMode = App.settings.ScreenScaler.IsSetMode(m_gameUI.Core.Platform); + + if (m_mode == null && !isSetMode) + { + return true; + } + else if (isSetMode && m_mode.HasValue) + { + var mode = App.settings.ScreenScaler.GetMode(m_gameUI.Core.Platform); + return mode == m_mode.Value; + } + else return false; + } + } + + public Scale(InGameUI inGameUI, EnumScalerMode? mode) : base(ModeToName(mode), null) + { + m_mode = mode; + m_gameUI = inGameUI; + } + + public override void OnExcute(OptionUI optionUI, ref bool cancelHide) + { + App.settings.ScreenScaler.SetMode(m_gameUI.Core.Platform, m_mode); + } + + static string ModeToName(EnumScalerMode? mode) + { + if (mode == null) return "使用全局设置"; + else + { + switch (mode.Value) + { + case EnumScalerMode.FullScreen: return "全屏"; + case EnumScalerMode.Raw: return "原始尺寸"; + case EnumScalerMode.Fix: return "适应"; + default: throw new Exception($"Not Support Mode : {mode.Value}"); + } + } + } + } + } +} \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs.meta b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs.meta new file mode 100644 index 00000000..6cf22a5d --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_Scaler.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 2703b2b6867eb344386509ff36bf1459 \ No newline at end of file From 7eaa208c786e70a704d9b17633d28c64e2f38e58 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Tue, 7 Jan 2025 14:11:35 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E6=A8=A1=E6=8B=9F?= =?UTF-8?q?=E5=99=A8=E6=A0=B8=E5=BF=83=E6=8E=A5=E5=8F=A3IEmuCore=E5=90=84?= =?UTF-8?q?=E4=B8=AA=E6=96=B9=E6=B3=95=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Script/AppMain/IEmuCore.cs | 16 ++++++++++++++-- .../Assets/Script/AppMain/Manager/AppEmu.cs | 2 +- .../Script/AppMain/NesEmulator/NesEmulator.cs | 5 ----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/IEmuCore.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/IEmuCore.cs index 1583993d..44841572 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/IEmuCore.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/IEmuCore.cs @@ -7,18 +7,30 @@ namespace AxibugEmuOnline.Client { GameObject gameObject { get; } + /// 获得模拟器核心中的状态快照对象 object GetState(); + /// 获得模拟器核心中的状态快照字节数据 byte[] GetStateBytes(); + /// 加载状态快照 + /// 该对象应该来自核心的方法的返回值,或是从返回的byte数组构建 void LoadState(object state); + /// 加载状态快照 + /// 该对象应该来自核心的返回的byte数组 void LoadStateFromBytes(byte[] data); + /// 暂停核心推帧 void Pause(); + /// 恢复核心推帧(从Pause状态恢复) void Resume(); - void SetupScheme(); + /// 启动模拟器逻辑 MsgBool StartGame(RomFile romFile); + /// 重置核心,通常由模拟器核心提供的功能 void DoReset(); + /// 获得模拟器核心的控制器设置器 + /// IControllerSetuper GetControllerSetuper(); - + /// 核心所属平台 RomPlatformType Platform { get; } + /// 获取当前模拟器帧序号,在加载快照和Reset后,应当重置为0 uint Frame { get; } } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs index d994bb40..db5da709 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs @@ -63,7 +63,7 @@ namespace AxibugEmuOnline.Client.Manager LaunchUI.Instance.HideMainMenu(); InGameUI.Instance.Show(romFile, m_emuCore); - m_emuCore.SetupScheme(); + CommandDispatcher.Instance.Current = CommandDispatcher.Instance.Gaming; m_controllerSetuper = m_emuCore.GetControllerSetuper(); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesEmulator.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesEmulator.cs index b6977b31..8532f5b2 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesEmulator.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/NesEmulator/NesEmulator.cs @@ -103,11 +103,6 @@ namespace AxibugEmuOnline.Client NesCore.Reset(); } - public void SetupScheme() - { - CommandDispatcher.Instance.Current = CommandDispatcher.Instance.Gaming; - } - public void LoadState(object state) { NesCore.LoadState((State)state);