public KeySettingItem TestConflict(KeySettingItem itemToSet, KeyCode newKey, IKeyJoyAccessor accessor) { int[] masks = new int[] { 0xff, 0x03, 0x05, 0x09, 0x11, 0x21 }; int n = mKeySettingLists.Length; int idx = 0; for (int i = 0; i < n; i++) { if (0 <= System.Array.IndexOf(mKeySettingLists[i], itemToSet)) { for (int j = 0; j < n; j++) { if ((masks[i] & (1 << j)) != 0 && 0 != (idx = accessor.FindInArray(mKeySettingLists[j], newKey))) { if (idx < 0) { idx = -idx; } return(mKeySettingLists[j][idx - 1]); } } } } return(null); }
void SetJoy(bool state) { m_OpCtrlBtnsParent.SetActive(state); if (!state && _bApply) { // set joy into _keySetting if (_joyToSet != InputControlType.None && _joyToSet != _keySetting._joy) { #if ConflictMsgOn KeySettingItem itemConflict = null; // UIOption.Instance.TestConflict(this, _joyToSet, s_joyAccessor); if (itemConflict != null) { MessageBox_N.ShowYNBox(PELocalization.GetString(8000178), () => { s_joyAccessor.Set(this, _joyToSet); }); } else { s_joyAccessor.Set(this, _joyToSet); } #else if (!UIOption.Instance.TrySetKey(this, _joyToSet, s_joyAccessor)) { if (OptionUIHintFadeCtrl.Instance != null) { OptionUIHintFadeCtrl.Instance.AddOneHint(PELocalization.GetString(8000172)); } } #endif } } else { _joyToSet = _keySetting._joy; } mCtrlContent.text = _keySetting._joy.ToString(); }
bool TrySetKeyInOther(KeySettingItem itemToSet, KeyCode newKey, IKeyJoyAccessor accessor, int cur) { tmpIdx[cur] = accessor.FindInArray(mKeySettingLists[cur], newKey); if (tmpIdx[cur] < 0) { return(false); // Can not set because locked } KeyCode oldKey = accessor.Get(itemToSet); if (tmpIdx[cur] > 0) { accessor.Set(mKeySettingLists[cur][tmpIdx[cur] - 1], oldKey); } else { tmpIdx[0] = accessor.FindInArray(mKeySettingLists[0], newKey); if (tmpIdx[0] < 0) { return(false); // Can not set because locked } if (tmpIdx[0] > 0) { if (!TrySetKeyInCommon(mKeySettingLists[0][tmpIdx[0] - 1], oldKey, accessor, (-1 & ~(1 << cur)))) { return(false); } } } accessor.Set(itemToSet, newKey); return(true); }
public bool TrySetKey(KeySettingItem itemToSet, KeyCode newKey, IKeyJoyAccessor accessor) { // Special for common settings if (0 <= System.Array.IndexOf(mKeySettingLists[0], itemToSet)) { return(TrySetKeyInCommon(itemToSet, newKey, accessor, -1)); } for (int i = 1; i < 4; i++) { if (0 <= System.Array.IndexOf(mKeySettingLists[i], itemToSet)) { return(TrySetKeyInOther(itemToSet, newKey, accessor, i)); } } return(false); }
void SetKey(bool state) { this.m_OpKeyBtnsParent.SetActive(state); if (!state && _bApply) { // set key into _keySetting if (_keyToSet != KeyCode.None && _keyToSet != _keySetting._key) { #if ConflictMsgOn KeySettingItem itemConflict = UIOption.Instance.TestConflict(this, _keyToSet, s_keyAccessor); if (itemConflict != null) { //if(_keyToSet != KeyCode.Mouse0 && _keyToSet != KeyCode.Mouse1) //{ // //lw:2017.7.10:快捷键冲突时,忽略玩家输入,即设置必定不成功 // MessageBox_N.ShowOkBox(PELocalization.GetString(8000178)); //} //else //{ MessageBox_N.ShowYNBox(PELocalization.GetString(8000178), () => { s_keyAccessor.Set(this, _keyToSet); }); // } } else { s_keyAccessor.Set(this, _keyToSet); } #else if (!UIOption.Instance.TrySetKey(this, _keyToSet, s_keyAccessor)) { if (OptionUIHintFadeCtrl.Instance != null) { OptionUIHintFadeCtrl.Instance.AddOneHint(PELocalization.GetString(8000172)); } } #endif } } else { _keyToSet = _keySetting._key; } mKeyContent.text = _keySetting._key.ToStr(); }
bool TrySetKeyInCommon(KeySettingItem itemToSet, KeyCode newKey, IKeyJoyAccessor accessor, int conflictMask = -1) { tmpIdx[0] = accessor.FindInArray(mKeySettingLists[0], newKey); if (tmpIdx[0] < 0) { return(false); // Can not set because locked } KeyCode oldKey = accessor.Get(itemToSet); if (tmpIdx[0] > 0) { accessor.Set(mKeySettingLists[0][tmpIdx[0] - 1], oldKey); } else { for (int i = 1; i < 4; i++) { if (((1 << i) & conflictMask) == 0) { tmpIdx[i] = 0; continue; } tmpIdx[i] = accessor.FindInArray(mKeySettingLists[i], newKey); if (tmpIdx[i] < 0) { return(false); // Can not set because locked } } for (int i = 1; i < 4; i++) { if (tmpIdx[i] > 0) { accessor.Set(mKeySettingLists[i][tmpIdx[i] - 1], oldKey); } } } accessor.Set(itemToSet, newKey); return(true); }
public InputControlType Get(KeySettingItem item) { return(item._keySetting._joy); }
KeyCode IKeyJoyAccessor.Get(KeySettingItem item) { return(KeyCode.None); }
public void Set(KeySettingItem item, KeyCode keyToSet) { }
public void Set(KeySettingItem item, InputControlType keyToSet) { item._keySetting._joy = keyToSet; item.mCtrlContent.text = keyToSet.ToString(); }
public KeyCode Get(KeySettingItem item) { return(item._keySetting._key); }
public void Set(KeySettingItem item, KeyCode keyToSet) { item._keySetting._key = keyToSet; item.mKeyContent.text = keyToSet.ToStr(); }
void CreatKeyList(ref KeySettingItem[] _array, int _count, KeyCategory _keycate) { if (_array == null) { KeyCategoryItem cateitem = Instantiate(mCategoryPrefab) as KeyCategoryItem; cateitem.transform.parent = mKeysSetGrid.transform; cateitem.transform.localScale = Vector3.one; cateitem.transform.localPosition = Vector3.zero; cateitem.transform.localRotation = Quaternion.identity; cateitem.mStringID = (int)_keycate; _array = new KeySettingItem[_count]; for (int i = 0; i < _count; i++) { KeySettingItem addItem = Instantiate(mPerfab) as KeySettingItem; addItem.transform.parent = mKeysSetGrid.transform; addItem.transform.localScale = Vector3.one; addItem.transform.localPosition = Vector3.zero; addItem.transform.localRotation = Quaternion.identity; addItem.gameObject.name = "KeySetting" + i; switch (_keycate) { case KeyCategory.Common: addItem._keySetting = new PeInput.KeyJoySettingPair(PeInput.SettingsAll[0][i]); addItem._keySettingName = PeInput.StrIdOfGeneral(i); break; case KeyCategory.Character: addItem._keySetting = new PeInput.KeyJoySettingPair(PeInput.SettingsAll[1][i]); addItem._keySettingName = PeInput.StrIdOfChrCtrl(i); break; case KeyCategory.Construct: addItem._keySetting = new PeInput.KeyJoySettingPair(PeInput.SettingsAll[2][i]); addItem._keySettingName = PeInput.StrIdOfBuildMd(i); break; case KeyCategory.Carrier: addItem._keySetting = new PeInput.KeyJoySettingPair(PeInput.SettingsAll[3][i]); addItem._keySettingName = PeInput.StrIdOfVehicle(i); break; } _array[i] = addItem; } } else { for (int i = 0; i < _count; i++) { switch (_keycate) { case KeyCategory.Common: _array[i]._keySetting = new PeInput.KeyJoySettingPair(PeInput.SettingsAll[0][i]); _array[i]._keySettingName = PeInput.StrIdOfGeneral(i); break; case KeyCategory.Character: _array[i]._keySetting = new PeInput.KeyJoySettingPair(PeInput.SettingsAll[1][i]); _array[i]._keySettingName = PeInput.StrIdOfChrCtrl(i); break; case KeyCategory.Construct: _array[i]._keySetting = new PeInput.KeyJoySettingPair(PeInput.SettingsAll[2][i]); _array[i]._keySettingName = PeInput.StrIdOfBuildMd(i); break; case KeyCategory.Carrier: _array[i]._keySetting = new PeInput.KeyJoySettingPair(PeInput.SettingsAll[3][i]); _array[i]._keySettingName = PeInput.StrIdOfVehicle(i); break; } } } }