forked from sin365/AxibugEmuOnline
Legacy改名,不再使用inputsystem
This commit is contained in:
parent
d7269175cd
commit
e0a87a2737
@ -3,10 +3,10 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
{
|
{
|
||||||
public class GamingChanger_Legacy : CommandChanger
|
public class GamingChanger : CommandChanger
|
||||||
{
|
{
|
||||||
Dictionary<KeyCode, EnumCommand> m_uiKeyMapper = new Dictionary<KeyCode, EnumCommand>();
|
Dictionary<KeyCode, EnumCommand> m_uiKeyMapper = new Dictionary<KeyCode, EnumCommand>();
|
||||||
public GamingChanger_Legacy()
|
public GamingChanger()
|
||||||
{
|
{
|
||||||
m_uiKeyMapper[KeyCode.Escape] = EnumCommand.OptionMenu;
|
m_uiKeyMapper[KeyCode.Escape] = EnumCommand.OptionMenu;
|
||||||
|
|
@ -1,17 +1,13 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
{
|
{
|
||||||
|
|
||||||
public class NormalChanger_Legacy : CommandChanger
|
public class NormalChanger : CommandChanger
|
||||||
{
|
{
|
||||||
Dictionary<KeyCode, EnumCommand> m_uiKeyMapper = new Dictionary<KeyCode, EnumCommand>();
|
Dictionary<KeyCode, EnumCommand> m_uiKeyMapper = new Dictionary<KeyCode, EnumCommand>();
|
||||||
public NormalChanger_Legacy()
|
public NormalChanger()
|
||||||
{
|
{
|
||||||
m_uiKeyMapper[KeyCode.A] = EnumCommand.SelectItemLeft;
|
m_uiKeyMapper[KeyCode.A] = EnumCommand.SelectItemLeft;
|
||||||
m_uiKeyMapper[KeyCode.D] = EnumCommand.SelectItemRight;
|
m_uiKeyMapper[KeyCode.D] = EnumCommand.SelectItemRight;
|
@ -40,7 +40,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
private void loadConfig()
|
private void loadConfig()
|
||||||
{
|
{
|
||||||
m_keyListener = MapperSetter.GetKey_Legacy(m_controllerIndex, m_buttonType);
|
m_keyListener = MapperSetter.GetKey(m_controllerIndex, m_buttonType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,13 +95,13 @@ namespace AxibugEmuOnline.Client
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IKeyListener GetKey_Legacy(int controllerInput, EnumButtonType nesConBtnType)
|
public static IKeyListener GetKey(int controllerInput, EnumButtonType nesConBtnType)
|
||||||
{
|
{
|
||||||
string configKey = $"NES_{controllerInput}_{nesConBtnType}";
|
string configKey = $"NES_{controllerInput}_{nesConBtnType}";
|
||||||
|
|
||||||
if (PlayerPrefs.HasKey(configKey))
|
if (PlayerPrefs.HasKey(configKey))
|
||||||
{
|
{
|
||||||
return new KeyListener_Legacy(PlayerPrefs.GetString(configKey));
|
return new KeyListener(PlayerPrefs.GetString(configKey));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -110,31 +110,31 @@ namespace AxibugEmuOnline.Client
|
|||||||
return defaultKeyCode;
|
return defaultKeyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyListener_Legacy GetDefaultKey()
|
KeyListener GetDefaultKey()
|
||||||
{
|
{
|
||||||
switch (controllerInput)
|
switch (controllerInput)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
if (nesConBtnType == EnumButtonType.LEFT) return new KeyListener_Legacy(KeyCode.A, KeyCode.Joystick1Button12);
|
if (nesConBtnType == EnumButtonType.LEFT) return new KeyListener(KeyCode.A);
|
||||||
if (nesConBtnType == EnumButtonType.RIGHT) return new KeyListener_Legacy(KeyCode.D, KeyCode.Joystick1Button13);
|
if (nesConBtnType == EnumButtonType.RIGHT) return new KeyListener(KeyCode.D);
|
||||||
if (nesConBtnType == EnumButtonType.UP) return new KeyListener_Legacy(KeyCode.W, KeyCode.Joystick1Button10);
|
if (nesConBtnType == EnumButtonType.UP) return new KeyListener(KeyCode.W);
|
||||||
if (nesConBtnType == EnumButtonType.DOWN) return new KeyListener_Legacy(KeyCode.S, KeyCode.Joystick1Button11);
|
if (nesConBtnType == EnumButtonType.DOWN) return new KeyListener(KeyCode.S);
|
||||||
if (nesConBtnType == EnumButtonType.START) return new KeyListener_Legacy(KeyCode.B, KeyCode.Joystick1Button7);
|
if (nesConBtnType == EnumButtonType.START) return new KeyListener(KeyCode.B);
|
||||||
if (nesConBtnType == EnumButtonType.SELECT) return new KeyListener_Legacy(KeyCode.V, KeyCode.Joystick1Button6);
|
if (nesConBtnType == EnumButtonType.SELECT) return new KeyListener(KeyCode.V);
|
||||||
if (nesConBtnType == EnumButtonType.A) return new KeyListener_Legacy(KeyCode.K, KeyCode.Joystick1Button1);
|
if (nesConBtnType == EnumButtonType.A) return new KeyListener(KeyCode.K);
|
||||||
if (nesConBtnType == EnumButtonType.B) return new KeyListener_Legacy(KeyCode.J, KeyCode.Joystick1Button2);
|
if (nesConBtnType == EnumButtonType.B) return new KeyListener(KeyCode.J);
|
||||||
if (nesConBtnType == EnumButtonType.MIC) return new KeyListener_Legacy(KeyCode.M, KeyCode.Joystick1Button12);
|
if (nesConBtnType == EnumButtonType.MIC) return new KeyListener(KeyCode.M);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (nesConBtnType == EnumButtonType.LEFT) return new KeyListener_Legacy(KeyCode.Delete, KeyCode.Joystick2Button12);
|
if (nesConBtnType == EnumButtonType.LEFT) return new KeyListener(KeyCode.Delete);
|
||||||
if (nesConBtnType == EnumButtonType.RIGHT) return new KeyListener_Legacy(KeyCode.PageDown, KeyCode.Joystick2Button13);
|
if (nesConBtnType == EnumButtonType.RIGHT) return new KeyListener(KeyCode.PageDown);
|
||||||
if (nesConBtnType == EnumButtonType.UP) return new KeyListener_Legacy(KeyCode.Home, KeyCode.Joystick2Button10);
|
if (nesConBtnType == EnumButtonType.UP) return new KeyListener(KeyCode.Home);
|
||||||
if (nesConBtnType == EnumButtonType.DOWN) return new KeyListener_Legacy(KeyCode.End, KeyCode.Joystick2Button11);
|
if (nesConBtnType == EnumButtonType.DOWN) return new KeyListener(KeyCode.End);
|
||||||
if (nesConBtnType == EnumButtonType.START) return new KeyListener_Legacy(KeyCode.PageUp, KeyCode.Joystick2Button7);
|
if (nesConBtnType == EnumButtonType.START) return new KeyListener(KeyCode.PageUp);
|
||||||
if (nesConBtnType == EnumButtonType.SELECT) return new KeyListener_Legacy(KeyCode.Insert, KeyCode.Joystick2Button6);
|
if (nesConBtnType == EnumButtonType.SELECT) return new KeyListener(KeyCode.Insert);
|
||||||
if (nesConBtnType == EnumButtonType.A) return new KeyListener_Legacy(KeyCode.Keypad5, KeyCode.Joystick2Button1);
|
if (nesConBtnType == EnumButtonType.A) return new KeyListener(KeyCode.Keypad5);
|
||||||
if (nesConBtnType == EnumButtonType.B) return new KeyListener_Legacy(KeyCode.Keypad4, KeyCode.Joystick2Button2);
|
if (nesConBtnType == EnumButtonType.B) return new KeyListener(KeyCode.Keypad4);
|
||||||
if (nesConBtnType == EnumButtonType.MIC) return new KeyListener_Legacy(KeyCode.KeypadPeriod, KeyCode.Joystick2Button12);
|
if (nesConBtnType == EnumButtonType.MIC) return new KeyListener(KeyCode.KeypadPeriod);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,56 +149,36 @@ namespace AxibugEmuOnline.Client
|
|||||||
bool IsPressing();
|
bool IsPressing();
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct KeyListener_Legacy : IKeyListener
|
public struct KeyListener : IKeyListener
|
||||||
{
|
{
|
||||||
private KeyCode[] m_keys;
|
private KeyCode m_key;
|
||||||
|
|
||||||
public KeyListener_Legacy(params KeyCode[] keys)
|
public KeyListener(KeyCode key)
|
||||||
{
|
{
|
||||||
m_keys = keys;
|
m_key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 从配置表字符串构建
|
/// 从配置表字符串构建
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="confStr">以:分割的键值字符串</param>
|
public KeyListener(string confStr)
|
||||||
public KeyListener_Legacy(string confStr)
|
|
||||||
{
|
{
|
||||||
m_keys = new KeyCode[2];
|
m_key = KeyCode.None;
|
||||||
|
|
||||||
var temp = confStr.Split(':');
|
if (int.TryParse(confStr, out int result))
|
||||||
m_keys = new KeyCode[temp.Length];
|
m_key = (KeyCode)result;
|
||||||
for (int i = 0; i < temp.Length; i++)
|
|
||||||
{
|
|
||||||
if (int.TryParse(temp[i], out int result))
|
|
||||||
m_keys[i] = (KeyCode)result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsPressing()
|
public readonly bool IsPressing()
|
||||||
{
|
{
|
||||||
if (m_keys == null || m_keys.Length == 0) return false;
|
if (Input.GetKey(m_key)) return true;
|
||||||
|
|
||||||
foreach (var key in m_keys)
|
|
||||||
{
|
|
||||||
if (Input.GetKey(key)) return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
if (m_keys == null || m_keys.Length == 0) return string.Empty;
|
return ((int)(m_key)).ToString();
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
for (int i = 0; i < m_keys.Length; i++)
|
|
||||||
{
|
|
||||||
var keyVal = (int)m_keys[i];
|
|
||||||
sb.Append(keyVal);
|
|
||||||
if (i != m_keys.Length - 1) sb.Append(':');
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.ToString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,11 +36,11 @@ namespace AxibugEmuOnline.Client
|
|||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
||||||
//初始化command监视器
|
//初始化command监视器
|
||||||
m_listener = new CommandListener_Legacy();
|
m_listener = new CommandListener();
|
||||||
|
|
||||||
//初始化键位修改器
|
//初始化键位修改器
|
||||||
Normal = new NormalChanger_Legacy();
|
Normal = new NormalChanger();
|
||||||
Gaming = new GamingChanger_Legacy();
|
Gaming = new GamingChanger();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
|
@ -3,7 +3,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
{
|
{
|
||||||
public class CommandListener_Legacy : ICommandListener
|
public class CommandListener : ICommandListener
|
||||||
{
|
{
|
||||||
Dictionary<KeyCode, EnumCommand> m_keyMapper = new Dictionary<KeyCode, EnumCommand>();
|
Dictionary<KeyCode, EnumCommand> m_keyMapper = new Dictionary<KeyCode, EnumCommand>();
|
||||||
List<CommandState> m_commands = new List<CommandState>();
|
List<CommandState> m_commands = new List<CommandState>();
|
Loading…
Reference in New Issue
Block a user