增加画面比例修改功能,以及配套的设置界面

This commit is contained in:
ALIENJACK\alien 2024-12-27 20:36:01 +08:00
parent f998fe6b76
commit d5626f7a94
22 changed files with 339 additions and 71 deletions

View File

@ -97,6 +97,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 6774190055201401942}
- {fileID: 7813729344275964042} - {fileID: 7813729344275964042}
- {fileID: 4804966765082268001} - {fileID: 4804966765082268001}
m_Father: {fileID: 5169543666820693527} m_Father: {fileID: 5169543666820693527}
@ -492,6 +493,81 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4471d8231d16ba3469228e09d4cb3a81, type: 3} m_Script: {fileID: 11500000, guid: 4471d8231d16ba3469228e09d4cb3a81, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
--- !u!1 &8553047206489589253
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6774190055201401942}
- component: {fileID: 3110729603451971289}
- component: {fileID: 454445332755738332}
m_Layer: 5
m_Name: black
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &6774190055201401942
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8553047206489589253}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 8545038260809852605}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3110729603451971289
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8553047206489589253}
m_CullTransparentMesh: 1
--- !u!114 &454445332755738332
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8553047206489589253}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &9087746359628224422 --- !u!1 &9087746359628224422
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -143,6 +143,81 @@ AudioSource:
m_PreInfinity: 2 m_PreInfinity: 2
m_PostInfinity: 2 m_PostInfinity: 2
m_RotationOrder: 4 m_RotationOrder: 4
--- !u!1 &1832378132020391456
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8057614414535643033}
- component: {fileID: 377334483991090399}
- component: {fileID: 4271988797887364570}
m_Layer: 5
m_Name: bg
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8057614414535643033
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1832378132020391456}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4232056520494431727}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &377334483991090399
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1832378132020391456}
m_CullTransparentMesh: 1
--- !u!114 &4271988797887364570
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1832378132020391456}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &3297772745682094737 --- !u!1 &3297772745682094737
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -346,6 +421,7 @@ RectTransform:
m_LocalScale: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0, y: 0, z: 0}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 8057614414535643033}
- {fileID: 4232056521759880275} - {fileID: 4232056521759880275}
- {fileID: 1038087993597378172} - {fileID: 1038087993597378172}
m_Father: {fileID: 4232056521131536011} m_Father: {fileID: 4232056521131536011}

View File

@ -45,7 +45,7 @@ namespace AxibugEmuOnline.Client.ClientCore
#else #else
public static string PersistentDataPath => Application.persistentDataPath; public static string PersistentDataPath => Application.persistentDataPath;
#endif #endif
public static void Init(Initer initer, bool isTest = false, string testSrvIP = "") public static void Init( bool isTest = false, string testSrvIP = "")
{ {
//其他平台必要的初始化 //其他平台必要的初始化
if (UnityEngine.Application.platform == RuntimePlatform.PSP2) if (UnityEngine.Application.platform == RuntimePlatform.PSP2)
@ -53,7 +53,7 @@ namespace AxibugEmuOnline.Client.ClientCore
PSP2Init(); PSP2Init();
} }
settings = new AppSettings(initer); settings = new AppSettings();
log = new LogManager(); log = new LogManager();
LogManager.OnLog += OnNoSugarNetLog; LogManager.OnLog += OnNoSugarNetLog;
@ -64,7 +64,7 @@ namespace AxibugEmuOnline.Client.ClientCore
emu = new AppEmu(); emu = new AppEmu();
//netgame = new AppNetGame(); //netgame = new AppNetGame();
httpAPI = new HttpAPI(); httpAPI = new HttpAPI();
nesRomLib = new RomLib(EnumPlatform.NES); nesRomLib = new RomLib(EnumSupportEmuPlatform.NES);
CacheMgr = new CacheManager(); CacheMgr = new CacheManager();
roomMgr = new AppRoom(); roomMgr = new AppRoom();
share = new AppShare(); share = new AppShare();

View File

@ -17,9 +17,8 @@ namespace AxibugEmuOnline.Client
void DoReset(); void DoReset();
IControllerSetuper GetControllerSetuper(); IControllerSetuper GetControllerSetuper();
EnumPlatform Platform { get; } EnumSupportEmuPlatform Platform { get; }
uint Frame { get; } uint Frame { get; }
Vector2Int GetRawResolution();
} }
public static class IEnumCoreTool public static class IEnumCoreTool

View File

@ -5,15 +5,15 @@ namespace AxibugEmuOnline.Client
{ {
public class Initer : MonoBehaviour public class Initer : MonoBehaviour
{ {
public CanvasGroup FilterPreview => m_refs.FilterPreview; static GlobalRef m_refs;
public CanvasGroup XMBBg => m_refs.XMBBg; public static CanvasGroup FilterPreview => m_refs.FilterPreview;
public static CanvasGroup XMBBg => m_refs.XMBBg;
public static string dev_UUID; public static string dev_UUID;
[SerializeField] [SerializeField]
GameObject IMPORTENT; GameObject IMPORTENT;
GlobalRef m_refs;
#if UNITY_EDITOR #if UNITY_EDITOR
public bool bTest = false; public bool bTest = false;
@ -21,16 +21,21 @@ namespace AxibugEmuOnline.Client
#endif #endif
private void Awake() private void Awake()
{ {
m_refs = Instantiate(IMPORTENT, transform).GetComponent<GlobalRef>();
#if UNITY_EDITOR #if UNITY_EDITOR
App.Init(this, bTest, mTestSrvIP); App.Init(bTest, mTestSrvIP);
#else #else
App.Init(this); App.Init(this);
#endif #endif
dev_UUID = SystemInfo.deviceUniqueIdentifier; dev_UUID = SystemInfo.deviceUniqueIdentifier;
m_refs = Instantiate(IMPORTENT, transform).GetComponent<GlobalRef>();
}
private void Start()
{
App.settings.Filter.ShutDownFilterPreview();
App.settings.Filter.ShutDownFilter();
} }
} }
} }

View File

@ -31,7 +31,7 @@ namespace AxibugEmuOnline.Client.Manager
if (!m_emuCore.IsNull()) StopGame(); if (!m_emuCore.IsNull()) StopGame();
var roomInfo = App.roomMgr.mineRoomMiniInfo; var roomInfo = App.roomMgr.mineRoomMiniInfo;
roomInfo.FetchRomFileInRoomInfo(EnumPlatform.NES, (_, romFile) => roomInfo.FetchRomFileInRoomInfo(EnumSupportEmuPlatform.NES, (_, romFile) =>
{ {
if (!romFile.RomReady) //这个rom并没有下载,所以取消进入房间 if (!romFile.RomReady) //这个rom并没有下载,所以取消进入房间
{ {
@ -51,7 +51,7 @@ namespace AxibugEmuOnline.Client.Manager
switch (romFile.Platform) switch (romFile.Platform)
{ {
case EnumPlatform.NES: case EnumSupportEmuPlatform.NES:
m_emuCore = GameObject.Instantiate(Resources.Load<GameObject>("NES/NesEmulator")).GetComponent<IEmuCore>(); m_emuCore = GameObject.Instantiate(Resources.Load<GameObject>("NES/NesEmulator")).GetComponent<IEmuCore>();
break; break;
} }

View File

@ -1,6 +1,4 @@
using static AxibugEmuOnline.Client.FilterManager; namespace AxibugEmuOnline.Client
namespace AxibugEmuOnline.Client
{ {
public class AppSettings public class AppSettings
{ {
@ -8,11 +6,14 @@ namespace AxibugEmuOnline.Client
public BgColorSettings BgColor { get; private set; } public BgColorSettings BgColor { get; private set; }
/// <summary> 滤镜设置 </summary> /// <summary> 滤镜设置 </summary>
public FilterManager Filter { get; private set; } public FilterManager Filter { get; private set; }
/// <summary> 画面比例设置 </summary>
public ScreenScaler ScreenScaler { get; private set; }
public AppSettings(Initer initer) public AppSettings()
{ {
BgColor = new BgColorSettings(); BgColor = new BgColorSettings();
Filter = new FilterManager(initer.FilterPreview, initer.XMBBg); Filter = new FilterManager();
ScreenScaler = new ScreenScaler();
} }
} }
} }

View File

@ -1,4 +1,5 @@
using AxibugEmuOnline.Client.ClientCore; using AxibugEmuOnline.Client.ClientCore;
using Sony.Vita.Dialog;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -12,7 +13,8 @@ namespace AxibugEmuOnline.Client
public class FilterManager public class FilterManager
{ {
private List<Filter> m_filters; private List<Filter> m_filters;
private Dictionary<EnumPlatform, Filter> m_filterPlatforms = new Dictionary<EnumPlatform, Filter>(); private Dictionary<EnumSupportEmuPlatform, Filter> m_filterPlatforms = new Dictionary<EnumSupportEmuPlatform, Filter>();
private AlphaWraper m_previewFilterWraper; private AlphaWraper m_previewFilterWraper;
FilterRomSetting m_filterRomSetting; FilterRomSetting m_filterRomSetting;
/// <summary> /// <summary>
@ -20,15 +22,11 @@ namespace AxibugEmuOnline.Client
/// </summary> /// </summary>
public IReadOnlyList<Filter> Filters => m_filters; public IReadOnlyList<Filter> Filters => m_filters;
public FilterManager(CanvasGroup filterPreview, CanvasGroup mainBg) public FilterManager()
{ {
loadFilters(); loadFilters();
var json = PlayerPrefs.GetString(nameof(FilterRomSetting)); var json = PlayerPrefs.GetString(nameof(FilterRomSetting));
m_filterRomSetting = JsonUtility.FromJson<FilterRomSetting>(json) ?? new FilterRomSetting(); m_filterRomSetting = JsonUtility.FromJson<FilterRomSetting>(json) ?? new FilterRomSetting();
m_previewFilterWraper = new AlphaWraper(mainBg, filterPreview, false);
ShutDownFilterPreview();
ShutDownFilter();
} }
private void loadFilters() private void loadFilters()
@ -99,8 +97,8 @@ namespace AxibugEmuOnline.Client
Vector2 topRight = RectTransformUtility.WorldToScreenPoint(rawImage.canvas.worldCamera, corners[2]); Vector2 topRight = RectTransformUtility.WorldToScreenPoint(rawImage.canvas.worldCamera, corners[2]);
// 计算宽度和高度 // 计算宽度和高度
float width = topRight.x - bottomLeft.x; float width = Mathf.Abs(topRight.x - bottomLeft.x);
float height = topRight.y - bottomLeft.y; float height = Mathf.Abs(topRight.y - bottomLeft.y);
return new Vector2(width, height); return new Vector2(width, height);
} }
@ -109,12 +107,14 @@ namespace AxibugEmuOnline.Client
/// <summary> 关闭滤镜预览 </summary> /// <summary> 关闭滤镜预览 </summary>
public void ShutDownFilterPreview() public void ShutDownFilterPreview()
{ {
if (m_previewFilterWraper == null) m_previewFilterWraper = new AlphaWraper(Initer.XMBBg, Initer.FilterPreview, false);
m_previewFilterWraper.On = false; m_previewFilterWraper.On = false;
} }
/// <summary> 开启滤镜预览 </summary> /// <summary> 开启滤镜预览 </summary>
public void EnableFilterPreview() public void EnableFilterPreview()
{ {
if (m_previewFilterWraper == null) m_previewFilterWraper = new AlphaWraper(Initer.XMBBg, Initer.FilterPreview, false);
m_previewFilterWraper.On = true; m_previewFilterWraper.On = true;
} }

View File

@ -16,6 +16,7 @@ public class UIFilterPreviewer : MonoBehaviour
private void Update() private void Update()
{ {
App.settings.ScreenScaler.CalcScale(m_rawImg);
App.settings.Filter.ExecuteFilterRender(m_src, m_rawImg); App.settings.Filter.ExecuteFilterRender(m_src, m_rawImg);
} }
} }

View File

@ -0,0 +1,112 @@
using System;
using UnityEngine;
using UnityEngine.UI;
namespace AxibugEmuOnline.Client
{
/// <summary>
/// 实现模拟器输出画面的比例调整类
/// </summary>
public class ScreenScaler
{
/// <summary>
/// 全局设置的缩放模式
/// </summary>
public EnumScalerMode GlobalMode
{
get => (EnumScalerMode)PlayerPrefs.GetInt($"{nameof(ScreenScaler)}.GlobalMode", 0);
set => PlayerPrefs.SetInt($"{nameof(ScreenScaler)}.GlobalMode", (int)value);
}
/// <summary>
/// 获得指定平台设置的缩放模式
/// </summary>
/// <param name="platform"></param>
/// <returns></returns>
public EnumScalerMode GetMode(EnumSupportEmuPlatform platform)
{
int setVal = PlayerPrefs.GetInt($"{nameof(ScreenScaler)}.PlatMode.{platform}", -1);
if (setVal == -1)
return GlobalMode;
else
return (EnumScalerMode)setVal;
}
/// <summary>
/// 根据缩放模式设置UI的缩放
/// </summary>
/// <param name="m_rawImg"></param>
/// <param name="platform">不指定模拟器平台时,使用全局设置的缩放模式</param>
public void CalcScale(RawImage rawImg, EnumSupportEmuPlatform? platform = null)
{
var targetMode = platform == null ? GlobalMode : GetMode(platform.Value);
var resolution = GetRawResolution(platform == null ? EnumSupportEmuPlatform.NES : platform.Value);
var canvasRect = (rawImg.canvas.transform as RectTransform).rect;
switch (targetMode)
{
case EnumScalerMode.Raw:
{
float width = resolution.x / rawImg.canvas.pixelRect.width * canvasRect.width;
float height = resolution.y / rawImg.canvas.pixelRect.height * canvasRect.height;
rawImg.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);
rawImg.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);
}
break;
case EnumScalerMode.Fix:
{
bool stretchWidth = rawImg.canvas.pixelRect.width <= rawImg.canvas.pixelRect.height;
//bool stretchWidth = Mathf.Abs(resolution.x - rawImg.canvas.pixelRect.width) <= Mathf.Abs(resolution.y - rawImg.canvas.pixelRect.height);
if (stretchWidth)
{
var needWidth = rawImg.canvas.pixelRect.width;
var factor = needWidth / resolution.x;
resolution.x = (int)needWidth;
resolution.y = (int)(resolution.y * factor);
}
else
{
var needHeight = rawImg.canvas.pixelRect.height;
var factor = needHeight / resolution.y;
resolution.y = (int)needHeight;
resolution.x = (int)(resolution.x * factor);
}
float width = resolution.x / rawImg.canvas.pixelRect.width * canvasRect.width;
float height = resolution.y / rawImg.canvas.pixelRect.height * canvasRect.height;
rawImg.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, width);
rawImg.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, height);
}
break;
case EnumScalerMode.FullScreen:
{
rawImg.rectTransform.pivot = new Vector2(0.5f, 0.5f);
rawImg.rectTransform.anchorMin = new Vector2(0, 0);
rawImg.rectTransform.anchorMax = new Vector2(1, 1);
rawImg.rectTransform.sizeDelta = new Vector2(0, 0);
rawImg.rectTransform.anchoredPosition = new Vector2(0, 0);
}
break;
}
}
public Vector2Int GetRawResolution(EnumSupportEmuPlatform platform)
{
switch (platform)
{
case EnumSupportEmuPlatform.NES: return new Vector2Int(256, 240);
default: return new Vector2Int(256, 240);
}
}
/// <summary> 缩放模式 </summary>
public enum EnumScalerMode
{
/// <summary> 全屏 </summary>
FullScreen,
/// <summary> 适应 </summary>
Fix,
/// <summary> 原始 </summary>
Raw
};
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8341bf735cdfe6e49b3fa43b9a42d711

View File

@ -1,6 +1,6 @@
namespace AxibugEmuOnline.Client namespace AxibugEmuOnline.Client
{ {
public enum EnumPlatform public enum EnumSupportEmuPlatform
{ {
NES NES
} }

View File

@ -1,4 +1,4 @@
using AxibugEmuOnline.Client.ClientCore; using AxibugEmuOnline.Client.ClientCore;
using ICSharpCode.SharpZipLib.Zip; using ICSharpCode.SharpZipLib.Zip;
using System; using System;
using System.Collections; using System.Collections;
@ -13,7 +13,7 @@ namespace AxibugEmuOnline.Client
{ {
private HttpAPI.Resp_RomInfo webData; private HttpAPI.Resp_RomInfo webData;
private bool hasLocalFile; private bool hasLocalFile;
private EnumPlatform platform; private EnumSupportEmuPlatform platform;
//private UnityWebRequest downloadRequest; //private UnityWebRequest downloadRequest;
private AxiHttpProxy.SendDownLoadProxy downloadRequest; private AxiHttpProxy.SendDownLoadProxy downloadRequest;
@ -36,7 +36,7 @@ namespace AxibugEmuOnline.Client
public float Progress => IsDownloading ? downloadRequest.downloadHandler.DownLoadPr : 0; public float Progress => IsDownloading ? downloadRequest.downloadHandler.DownLoadPr : 0;
public EnumPlatform Platform => platform; public EnumSupportEmuPlatform Platform => platform;
/// <summary> 指示该Rom信息是否已填充 </summary> /// <summary> 指示该Rom信息是否已填充 </summary>
public bool InfoReady => webData != null; public bool InfoReady => webData != null;
/// <summary> 唯一标识 </summary> /// <summary> 唯一标识 </summary>
@ -61,7 +61,7 @@ namespace AxibugEmuOnline.Client
public event Action<RomFile> OnDownloadOver; public event Action<RomFile> OnDownloadOver;
public event Action OnInfoFilled; public event Action OnInfoFilled;
public RomFile(EnumPlatform platform, int index, int insidePage) public RomFile(EnumSupportEmuPlatform platform, int index, int insidePage)
{ {
this.platform = platform; this.platform = platform;
Index = index; Index = index;
@ -181,7 +181,7 @@ namespace AxibugEmuOnline.Client
} }
private RomFile() { } private RomFile() { }
public static RomFile CreateExistRom(EnumPlatform platform, string fileName) public static RomFile CreateExistRom(EnumSupportEmuPlatform platform, string fileName)
{ {
var res = new RomFile(); var res = new RomFile();
res.IsUserRom = true; res.IsUserRom = true;

View File

@ -19,14 +19,14 @@ namespace AxibugEmuOnline.Client
private Dictionary<string, RomFile> nesRomFileNameMapper = new Dictionary<string, RomFile>(); private Dictionary<string, RomFile> nesRomFileNameMapper = new Dictionary<string, RomFile>();
private HttpAPI.GetRomListAPI m_romGetFunc; private HttpAPI.GetRomListAPI m_romGetFunc;
private HttpAPI.SearchRomListAPI m_romSearchFunc; private HttpAPI.SearchRomListAPI m_romSearchFunc;
private EnumPlatform m_platform; private EnumSupportEmuPlatform m_platform;
public RomLib(EnumPlatform platform) public RomLib(EnumSupportEmuPlatform platform)
{ {
m_platform = platform; m_platform = platform;
switch (platform) switch (platform)
{ {
case EnumPlatform.NES: case EnumSupportEmuPlatform.NES:
m_romGetFunc = App.httpAPI.GetNesRomList; m_romGetFunc = App.httpAPI.GetNesRomList;
m_romSearchFunc = App.httpAPI.SearchNesRomList; m_romSearchFunc = App.httpAPI.SearchNesRomList;
break; break;

View File

@ -52,12 +52,13 @@ namespace AxibugEmuOnline.Client
var screenBuffer = NesCore.ppu.GetScreenPtr(); var screenBuffer = NesCore.ppu.GetScreenPtr();
VideoProvider.SetDrawData(screenBuffer); VideoProvider.SetDrawData(screenBuffer);
} }
VideoProvider.ApplyScreenScaler();
VideoProvider.ApplyFilterEffect(); VideoProvider.ApplyFilterEffect();
} }
public EnumPlatform Platform => EnumPlatform.NES; public EnumSupportEmuPlatform Platform => EnumSupportEmuPlatform.NES;
private CoreSupporter m_coreSupporter; private CoreSupporter m_coreSupporter;
/// <summary> /// <summary>
/// 指定ROM开始游戏 /// 指定ROM开始游戏
@ -217,10 +218,5 @@ namespace AxibugEmuOnline.Client
{ {
return ControllerMapper; return ControllerMapper;
} }
public Vector2Int GetRawResolution()
{
return new Vector2Int(256, 240);
}
} }
} }

View File

@ -82,6 +82,11 @@ namespace AxibugEmuOnline.Client
App.settings.Filter.ExecuteFilterRender(rt_gpu, Image); App.settings.Filter.ExecuteFilterRender(rt_gpu, Image);
} }
public void ApplyScreenScaler()
{
App.settings.ScreenScaler.CalcScale(Image, EnumSupportEmuPlatform.NES);
}
private unsafe void PrepareUI(uint* screenData) private unsafe void PrepareUI(uint* screenData)
{ {
if (GPUTurbo) if (GPUTurbo)

View File

@ -6,17 +6,6 @@ namespace AxibugEmuOnline.Client
{ {
public class ScreenScalerListMenuItem : VirtualSubMenuItem public class ScreenScalerListMenuItem : VirtualSubMenuItem
{ {
/// <summary> 缩放模式 </summary>
public enum EnumScalerMode
{
/// <summary> 全屏 </summary>
FullScreen,
/// <summary> 适应 </summary>
Fix,
/// <summary> 原始 </summary>
Raw
};
public override bool OnEnterItem() public override bool OnEnterItem()
{ {
App.settings.Filter.EnableFilterPreview(); App.settings.Filter.EnableFilterPreview();
@ -34,7 +23,7 @@ namespace AxibugEmuOnline.Client
protected override void GetVirtualListDatas(Action<object> datas) protected override void GetVirtualListDatas(Action<object> datas)
{ {
List<object> list = new List<object>(); List<object> list = new List<object>();
foreach (var enumValue in Enum.GetValues(typeof(EnumScalerMode))) list.Add(enumValue); foreach (var enumValue in Enum.GetValues(typeof(ScreenScaler.EnumScalerMode))) list.Add(enumValue);
datas.Invoke(list); datas.Invoke(list);
} }
} }

View File

@ -1,4 +1,5 @@
using AxibugEmuOnline.Client.UI; using AxibugEmuOnline.Client.ClientCore;
using AxibugEmuOnline.Client.UI;
namespace AxibugEmuOnline.Client namespace AxibugEmuOnline.Client
{ {
@ -8,27 +9,26 @@ namespace AxibugEmuOnline.Client
public class UI_ScalerModeItem : MenuItem, IVirtualItem public class UI_ScalerModeItem : MenuItem, IVirtualItem
{ {
public int Index { get; set; } public int Index { get; set; }
public ScreenScalerListMenuItem.EnumScalerMode Datacontext { get; private set; } public ScreenScaler.EnumScalerMode Datacontext { get; private set; }
public void SetData(object data) public void SetData(object data)
{ {
Datacontext = (ScreenScalerListMenuItem.EnumScalerMode)data; Datacontext = (ScreenScaler.EnumScalerMode)data;
UpdateView(); UpdateView();
} }
private void UpdateView() private void UpdateView()
{ {
switch (Datacontext) switch (Datacontext)
{ {
case ScreenScalerListMenuItem.EnumScalerMode.FullScreen: case ScreenScaler.EnumScalerMode.FullScreen:
SetBaseInfo("全屏", "模拟器输出画面将拉伸到全屏", null); SetBaseInfo("全屏", "模拟器输出画面将拉伸到全屏", null);
break; break;
case ScreenScalerListMenuItem.EnumScalerMode.Raw: case ScreenScaler.EnumScalerMode.Raw:
SetBaseInfo("原始尺寸", "将保持模拟器输出画面的原始分辨率", null); SetBaseInfo("原始尺寸", "将保持模拟器输出画面的原始分辨率", null);
break; break;
case ScreenScalerListMenuItem.EnumScalerMode.Fix: case ScreenScaler.EnumScalerMode.Fix:
SetBaseInfo("适应", "在保持原始画面比例的情况下适配到全屏", null); SetBaseInfo("适应", "在保持原始画面比例的情况下适配到全屏", null);
break; break;
} }
@ -37,6 +37,12 @@ namespace AxibugEmuOnline.Client
public void SetDependencyProperty(object data) public void SetDependencyProperty(object data)
{ {
SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index); SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index);
if (m_select)
{
App.settings.Filter.EnableFilterPreview();
App.settings.ScreenScaler.GlobalMode = Datacontext;
}
} }
public void Release() { } public void Release() { }

View File

@ -8,7 +8,7 @@ namespace AxibugEmuOnline.Client
public class RomListMenuItem : VirtualSubMenuItem public class RomListMenuItem : VirtualSubMenuItem
{ {
[SerializeField] [SerializeField]
protected EnumPlatform Platform; protected EnumSupportEmuPlatform Platform;
private RomLib RomLib private RomLib RomLib
{ {
@ -16,7 +16,7 @@ namespace AxibugEmuOnline.Client
{ {
switch (Platform) switch (Platform)
{ {
case EnumPlatform.NES: case EnumSupportEmuPlatform.NES:
return App.nesRomLib; return App.nesRomLib;
default: default:
throw new System.NotImplementedException($"未实现的平台 {Platform}"); throw new System.NotImplementedException($"未实现的平台 {Platform}");

View File

@ -1,4 +1,4 @@
using DG.Tweening; using DG.Tweening;
using DG.Tweening.Core; using DG.Tweening.Core;
using DG.Tweening.Plugins.Options; using DG.Tweening.Plugins.Options;
using UnityEngine; using UnityEngine;

View File

@ -86,7 +86,7 @@ namespace AxibugEmuOnline.Client
SetBaseInfo("--", $"<b>{hostNick}</b>的房间", $"{cur}/{max}"); SetBaseInfo("--", $"<b>{hostNick}</b>的房间", $"{cur}/{max}");
SetIcon(null); SetIcon(null);
roomInfo.FetchRomFileInRoomInfo(EnumPlatform.NES, (room, romFile) => roomInfo.FetchRomFileInRoomInfo(EnumSupportEmuPlatform.NES, (room, romFile) =>
{ {
if (room.RoomID != RoomID) return; if (room.RoomID != RoomID) return;

View File

@ -1,4 +1,4 @@
using AxibugEmuOnline.Client.ClientCore; using AxibugEmuOnline.Client.ClientCore;
using AxibugProtobuf; using AxibugProtobuf;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -34,7 +34,7 @@ namespace AxibugEmuOnline.Client
} }
private static Dictionary<int, RomFile> s_RomFileCahcesInRoomInfo = new Dictionary<int, RomFile>(); private static Dictionary<int, RomFile> s_RomFileCahcesInRoomInfo = new Dictionary<int, RomFile>();
public static void FetchRomFileInRoomInfo(this Protobuf_Room_MiniInfo roomInfo, EnumPlatform platform, Action<Protobuf_Room_MiniInfo, RomFile> callback) public static void FetchRomFileInRoomInfo(this Protobuf_Room_MiniInfo roomInfo, EnumSupportEmuPlatform platform, Action<Protobuf_Room_MiniInfo, RomFile> callback)
{ {
RomFile romFile; RomFile romFile;
@ -45,10 +45,10 @@ namespace AxibugEmuOnline.Client
} }
switch (platform) switch (platform)
{ {
case EnumPlatform.NES: case EnumSupportEmuPlatform.NES:
App.StartCoroutine(App.httpAPI.GetNesRomInfo(roomInfo.GameRomID, (romWebData) => App.StartCoroutine(App.httpAPI.GetNesRomInfo(roomInfo.GameRomID, (romWebData) =>
{ {
RomFile _romFile = new RomFile(EnumPlatform.NES, 0, 0); RomFile _romFile = new RomFile(EnumSupportEmuPlatform.NES, 0, 0);
_romFile.SetWebData(romWebData); _romFile.SetWebData(romWebData);
s_RomFileCahcesInRoomInfo[roomInfo.GameRomID] = _romFile; s_RomFileCahcesInRoomInfo[roomInfo.GameRomID] = _romFile;