public void SetGamePadTrigger(GamePadButton newButton, State newState, TriggerLayoutView newTrigger) { trigger = newTrigger; FillBoxWithGamePadEnum(); FillBoxWithInputTypeEnum(); FillBoxWithInputStateEnum(); trigger.TriggerType.SelectedItem = InputType.Gamepad.ToString(); trigger.TriggerKey.SelectedItem = newButton.ToString(); trigger.TriggerState.SelectedItem = newState.ToString(); }
public GamepadBind(GamePadButton bind, PlayerAction owner) : base(bind.ToString(), owner) { this.bind = bind; }
/// <summary> /// Fires once per second, every second, for the client. /// </summary> public void OncePerSecondActions() { FixMouse(); gFPS = gTicks; gTicks = 0; bool edited = false; if (CVars.system.Modified || first) { edited = true; CVars.system.Modified = false; StringBuilder cvarsave = new StringBuilder(CVars.system.CVarList.Count * 100); for (int i = 0; i < CVars.system.CVarList.Count; i++) { if (!CVars.system.CVarList[i].Flags.HasFlag(CVarFlag.ServerControl) && !CVars.system.CVarList[i].Flags.HasFlag(CVarFlag.ReadOnly) && !CVars.system.CVarList[i].Flags.HasFlag(CVarFlag.DoNotSave)) { string val = CVars.system.CVarList[i].Value; if (val.Contains('\"')) { val = "<{unescape[" + EscapeTagBase.Escape(val) + "]}>"; } cvarsave.Append("set \"" + CVars.system.CVarList[i].Name + "\" \"" + val + "\";\n"); } } lock (saveLock) { CSaveStr = cvarsave.ToString(); } } if (KeyHandler.Modified || first) { edited = true; KeyHandler.Modified = false; StringBuilder keybindsave = new StringBuilder(KeyHandler.keystonames.Count * 100); keybindsave.Append("wait 0.5;\n"); foreach (KeyValuePair <string, Key> keydat in KeyHandler.namestokeys) { CommandScript cs = KeyHandler.GetBind(keydat.Value); if (cs == null) { keybindsave.Append("unbind \"" + keydat.Key + "\";\n"); } else { keybindsave.Append("bindblock \"" + keydat.Key + "\"\n{\n" + cs.FullString("\t") + "}\n"); } } lock (saveLock) { BSaveStr = keybindsave.ToString(); } } if (Gamepad.Modified || first) { edited = true; Gamepad.Modified = false; StringBuilder gamepadbindsave = new StringBuilder(GamePadHandler.GP_BUTTON_COUNT * 256); gamepadbindsave.Append("wait 0.5;\n"); for (int i = 0; i < GamePadHandler.GP_BUTTON_COUNT; i++) { CommandScript cs = Gamepad.ButtonBinds[i]; GamePadButton button = (GamePadButton)i; if (cs == null) { gamepadbindsave.Append("gp_unbind \"" + button.ToString().ToLowerFast() + "\";\n"); } else { gamepadbindsave.Append("gp_bindblock \"" + button.ToString().ToLowerFast() + "\"\n{\n" + cs.FullString("\t") + "}\n"); } } lock (saveLock) { GPBSaveStr = gamepadbindsave.ToString(); } } if (edited) { first = false; Schedule.StartAsyncTask(SaveCFG); } ops_spike++; if (ops_spike >= 5) { ops_spike = 0; MainWorldView.ShadowSpikeTime = 0; TickSpikeTime = 0; MainWorldView.FBOSpikeTime = 0; MainWorldView.LightsSpikeTime = 0; FinishSpikeTime = 0; TWODSpikeTime = 0; TotalSpikeTime = 0; TheRegion.CrunchSpikeTime = 0; gFPS_Min = 0; gFPS_Max = 0; } for (int i = 0; i < (int)NetUsageType.COUNT; i++) { Network.UsagesLastSecond[i] = Network.UsagesThisSecond[i]; Network.UsagesThisSecond[i] = 0; } ops_extra++; if (CVars.r_compute.ValueB) { HashSet <Vector3i> handled = new HashSet <Vector3i>(); foreach (Chunk chk in TheRegion.LoadedChunks.Values) { if (chk.PosMultiplier < 5) { continue; } Vector3i slodpos = TheRegion.SLODLocFor(chk.WorldPosition); if (handled.Contains(slodpos)) { continue; } handled.Add(slodpos); if (!TheRegion.SLODs.TryGetValue(slodpos, out ChunkSLODHelper slod)) { slod = new ChunkSLODHelper() { Coordinate = slodpos, OwningRegion = TheRegion }; TheRegion.SLODs[slodpos] = slod; } Chunk[] res = TheRegion.LoadedChunks.Values.Where((c) => c.PosMultiplier >= 5 && TheRegion.SLODLocFor(c.WorldPosition) == slodpos).ToArray(); bool recomp = slod.NeedsComp; foreach (Chunk c in res) { if (c.SLODComputed && c._VBOSolid != null) { recomp = true; c.SLODMode = true; c.SLODComputed = false; slod.NeedsComp = false; } } if (recomp) { if (!VoxelComputer.Combinulate(slod, res)) { TheRegion.SLODs.Remove(slodpos); } } } List <Vector3i> needsRem = new List <Vector3i>(); foreach (ChunkSLODHelper slod in TheRegion.SLODs.Values) { if (slod.NeedsComp) { slod._VBO?.Destroy(); needsRem.Add(slod.Coordinate); continue; } int count = TheRegion.LoadedChunks.Values.Where((c) => c.PosMultiplier >= 5 && TheRegion.SLODLocFor(c.WorldPosition) == slod.Coordinate).Count(); if (count == 0) { slod._VBO?.Destroy(); needsRem.Add(slod.Coordinate); continue; } } foreach (Vector3i vec in needsRem) { TheRegion.SLODs.Remove(vec); } } else { foreach (ChunkSLODHelper slod in new List <ChunkSLODHelper>(TheRegion.SLODs.Values)) { if (slod.NeedsComp) { slod.CompileInternal(); if (slod._VBO == null) { TheRegion.SLODs.Remove(slod.Coordinate); } } else if (ops_extra > 3 && ((slod.Coordinate.ToLocation() + new Location(0.5, 0.5, 0.5)) * Constants.CHUNK_SLOD_WIDTH).DistanceSquared(Player.GetPosition()) < Constants.CHUNK_SLOD_WIDTH * Constants.CHUNK_SLOD_WIDTH * 2) { TheRegion.RecalcSLODExact(slod.Coordinate); } } } if (ops_extra > 3) { ops_extra = 0; } }
/// <summary> /// Generates a canonical display string for the specified key/modifier combination. /// </summary> private static String GenerateCanonicalDisplayString(CultureInfo culture, GamePadButton button) { return(Localization.Get(culture?.Name ?? Localization.CurrentCulture, "GAME_PAD_BUTTON_" + button.ToString())); }