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:
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/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/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);
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));
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