11 node.SetAttributeValue(
"Name", $
"GamepadMappingItem_{item}");
15 string itemString = item.ToString();
16 if (itemString !=
null) {
18 labelWidget.Text = r ? translated : itemString;
22 labelWidget2.Text =
string.Empty;
25 labelWidget2.Text =
ConvertGamepadName(valuesDictionary.GetValue<
object>(
"ModifierKey",
null))
34 return containerWidget;
43 return r ? translated : text;
47 public static string keyName =>
"GamepadMappingScreenKeys";
63 m_keysList.ScrollPosition = 0f;
64 m_keysList.ScrollSpeed = 0f;
65 m_keysList.ItemClicked += item => { m_keysList.SelectedItem = m_keysList.SelectedItem == item ? null : item; };
73 string selectedKeyName =
m_keysList.SelectedItem?.ToString() ??
string.Empty;
74 m_setKeyButton.IsEnabled = !
string.IsNullOrEmpty(selectedKeyName);
75 m_disableKeyButton.IsEnabled = !
string.IsNullOrEmpty(selectedKeyName);
81 string key = item.Key;
86 labelWidget.Text =
string.Empty;
90 labelWidget.Text =
ConvertGamepadName(valuesDictionary.GetValue<
object>(
"ModifierKey",
null))
97 bool hasConflict =
false;
98 if (
m_conflicts.TryGetValue(value, out List<string> valueList)) {
101 labelWidget.Color = hasConflict ? Color.Red :
Color.
White;
124 m_setKeyButton.IsChecked =
true;
129 object holdingModifierKey =
null;
144 &&
Input.IsPadButtonDownOnce(button)) {
145 if (holdingModifierKey !=
null
148 combinedKey.SetValue(
"ModifierKey", holdingModifierKey);
149 combinedKey.SetValue(
"ActionKey", button);
160 if (
Input.IsTriggerDownOnce(trigger)) {
168 m_setKeyButton.IsChecked =
false;
182 public override void Enter(
object[] parameters) {
205 string name = item.Key;
206 object obj = item.Value;
207 if (!
m_conflicts.TryGetValue(obj, out List<string> value)) {
211 if (!value.Contains(name)) {
static string ConvertToString(object value)
static object Get(Type type, string name)
static void ShowDialog(ContainerWidget parentWidget, Dialog dialog)
static IList< int > GetEnumValues(Type type)
void SetGamepadMapping(string keyName1, object value)
Dictionary< object, List< string > > m_conflicts
static string ConvertGamepadName(object obj)
BevelledButtonWidget m_setKeyButton
Widget GamepadKeyInfoWidget(object item)
BevelledButtonWidget m_disableKeyButton
BevelledButtonWidget m_gameHelpButton
bool IsWaitingForKeyInput
override void Enter(object[] parameters)
BevelledButtonWidget m_resetButton
ListPanelWidget m_keysList
Dictionary< string, ContainerWidget > m_widgetsByString
static bool HasConflict(List< string > list)
输入按键名称列表,检查是否存在冲突
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
static Dictionary< string, object > CombinedGamepadMappingSettings
static void ResetModsGamepadMappingSettings()
static Screen PreviousScreen
上一个Screen
static void GoBack(params object[] parameters)
static void SwitchScreen(string name, params object[] parameters)
static float GamepadTriggerThreshold
手柄扳机触发阈值,范围0~1,默认0.5。扳机的按压幅度只有超过这个数时才会被视为“按下”状态,越小则越容易触发。
static object GetGamepadMapping(string keyName, bool throwIfNotFound=true)
static void InitializeGamepadMappingSettings()
static void SetGamepadMapping(string keyName, object value)
仅用于修改现有手柄键位,添加键位请使用ModLoader.GetGamepadMappings