10 node.SetAttributeValue(
"Name", $
"KeyboardMappingItem_{item}");
14 string itemString = item.ToString();
15 if (itemString !=
null) {
17 labelWidget.Text = r ? translated : itemString;
21 return containerWidget;
24 public const string fName =
"KeyboardMappingScreen";
25 public const string keyName =
"KeyboardMappingScreenKeys";
40 m_keysList.ItemWidgetFactory = (Func<object, Widget>)Delegate.Combine(
m_keysList.ItemWidgetFactory,
KeyInfoWidget);
41 m_keysList.ScrollPosition = 0f;
42 m_keysList.ScrollSpeed = 0f;
43 m_keysList.ItemClicked += item => { m_keysList.SelectedItem = m_keysList.SelectedItem == item ? null : item; };
51 string selectedKeyName =
m_keysList.SelectedItem?.ToString() ??
string.Empty;
52 m_setKeyButton.IsEnabled = !
string.IsNullOrEmpty(selectedKeyName);
53 m_disableKeyButton.IsEnabled = !
string.IsNullOrEmpty(selectedKeyName);
61 if (value is
Key valueKey
62 && valueKey ==
Key.Null) {
63 labelWidget.Text =
string.Empty;
68 labelWidget.Text = r ? translated : text;
69 bool hasConflict =
false;
70 if (
m_conflicts.TryGetValue(value, out List<string> valueList)) {
73 labelWidget.Color = hasConflict ? Color.Red :
Color.
White;
96 m_setKeyButton.IsChecked =
true;
104 &&
Input.IsKeyDown(key)) {
111 if (
Input.IsMouseButtonDown(mouseButton)) {
119 m_setKeyButton.IsChecked =
false;
133 public override void Enter(
object[] parameters) {
156 string name = item.Key;
157 object obj = item.Value;
158 if (!
m_conflicts.TryGetValue(obj, out List<string> value)) {
159 value =
new List<string>();
162 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)
static bool HasConflict(List< string > list)
输入按键名称列表,检查是否存在冲突
BevelledButtonWidget m_resetButton
BevelledButtonWidget m_gameHelpButton
BevelledButtonWidget m_setKeyButton
ListPanelWidget m_keysList
Dictionary< object, List< string > > m_conflicts
Widget KeyInfoWidget(object item)
Dictionary< string, ContainerWidget > m_widgetsByString
bool IsWaitingForKeyInput
override void Enter(object[] parameters)
void SetKeyboardMapping(string keyName1, object value)
BevelledButtonWidget m_disableKeyButton
static string Get(string className, int key)
获取在当前语言类名键对应的字符串
static Dictionary< string, object > CombinedKeyboardMappingSettings
static void ResetModsKeyboardMappingSettings()
static Screen PreviousScreen
上一个Screen
static void GoBack(params object[] parameters)
static void SwitchScreen(string name, params object[] parameters)
static object GetKeyboardMapping(string keyName, bool throwIfNotFound=true)
static void SetKeyboardMapping(string keyName, object value)
仅用于修改现有键盘鼠标键位,添加键位请使用ModLoader.GetKeyboardMappings
static void InitializeKeyboardMappingSettings()