private void DisplayRemainingRocketCount() { if (!DisplayRocketCount) { return; } if (cameraController == null) { return; } if (cameraController.activeCamera == null) { return; } if (cameraController.activeCamera.CamMode == FixedCameraBlock.Mode.FirstPerson) { if (playerGroupedRockets.TryGetValue(StatMaster.isMP ? PlayerMachine.GetLocal().Player.NetworkId : 0, out groupedRockets)) { string textString = ""; foreach (var group in groupedRockets) { textString += KeyCodeConverter.GetKey(group.Key).ToString() + ": " + group.Value.Count + Environment.NewLine; } GUI.Box(counterRect, LanguageManager.Instance.CurrentLanguage.RemainingRockets + Environment.NewLine + textString, groupedRocketsCounterStyle); } } }
public override void DeSerialize(XData raw) { var keyArray = (string[])(XStringArray)raw; var newKeyArray = new string[keyArray.Length]; // replace bad keys for (int i = 0; i < keyArray.Length; ++i) { if (uint.TryParse(keyArray[i], out uint keyId) && keyId > MaxKey) { newKeyArray[i] = KeyCodeConverter.GetKey(KeyPlaceHolder); } else { newKeyArray[i] = keyArray[i]; } } base.DeSerialize(new XStringArray("", newKeyArray)); for (int i = 0; i < keyArray.Length; ++i) { var key = keyArray[i]; if (!uint.TryParse(key, out uint extKey) || extKey < MaxKey) { continue; } UpdatedKeyCodes[i] = extKey; } UpdateText(); InvokeKeysChanged(); }
KeyCode ToKey(string value) { if (!KeyCodeConverter.GetKey(value, out KeyCode code)) { throw new Exception("Invalid key " + value); // should never happen } return(code); }
private void KeyCaptureCombo_SelectedIndexChanged(object sender, EventArgs e) { if (locked) { return; } PreferenceManager.Database.ScreenCopyColorKey = KeyCodeConverter.GetKey(KeyCaptureCombo.SelectedIndex); }
private void CopyToClipboardCombo_SelectedIndexChanged(object sender, EventArgs e) { if (locked) { return; } PreferenceManager.Database.CopyToClipboardKey = KeyCodeConverter.GetKey(KeyCopyToClipboard.SelectedIndex); }
public override void Deserialize(DataReader reader) { ScreenCopyColorKeyModifier = KeyCodeConverter.GetAltKey(reader.ReadInt32()); ScreenCopyColorKey = KeyCodeConverter.GetKey(reader.ReadInt32()); CopyToClipboardKey = KeyCodeConverter.GetKey(reader.ReadInt32()); CopyToClipboardKeyModifier = KeyCodeConverter.GetAltKey(reader.ReadInt32()); ColorSize = reader.ReadInt32(); ThemeColor = (JColorStyle)reader.ReadInt32(); Theme = (JThemeStyle)reader.ReadInt32(); FirstTime = reader.ReadBoolean(); AutoCopyToClipboard = reader.ReadBoolean(); StayOnTop = reader.ReadBoolean(); ClipboardFormatingType = reader.ReadInt32(); FormatTemplate = reader.ReadString(); }
public string SerializeKey(uint x) { if (x > MaxKey) { return(x.ToString()); } try { return(KeyCodeConverter.GetKey((KeyCode)x)); } catch { return(x.ToString()); } }
private void OnGUI() { if (iAmLockedByRocket && DisplayWarning) { if (cameraController != null) { if (cameraController.activeCamera != null) { if (cameraController.activeCamera.CamMode == FixedCameraBlock.Mode.FirstPerson) { DrawBorder(); GUI.Box(warningRect, "Missile Alert", missileWarningStyle); } } } } if (DisplayRocketCount) { if (cameraController != null) { if (cameraController.activeCamera != null) { if (cameraController.activeCamera.CamMode == FixedCameraBlock.Mode.FirstPerson) { if (playerGroupedRockets.TryGetValue(StatMaster.isMP ? PlayerMachine.GetLocal().Player.NetworkId : 0, out Dictionary <KeyCode, HashSet <TimedRocket> > groupedRockets)) { string textString = ""; foreach (var group in groupedRockets) { textString += KeyCodeConverter.GetKey(group.Key).ToString() + ": " + group.Value.Count + Environment.NewLine; } GUI.Box(counterRect, LanguageManager.remainingRockets + Environment.NewLine + textString, groupedRocketsCounterStyle); } } } } } }
public IEnumerable <uint> ParseText(string value, uint[] origKeys) { var keyParts = value.Split(';'); var cnt = keyParts.Length > origKeys.Length ? origKeys.Length : keyParts.Length; for (int i = 0; i < cnt; ++i) { if (uint.TryParse(keyParts[i], out uint val)) { yield return(val); } else { if (KeyCodeConverter.GetKey(keyParts[i], out KeyCode code)) { yield return((uint)code); } else { yield return(origKeys[i]); } } } }
bool IsKey(string value) { return(KeyCodeConverter.GetKey(value, out KeyCode code)); }