private void SetButtonStates(bool enabled) { if (this.FindSweepyButton != null) { PButton.SetButtonEnabled(this.FindSweepyButton, enabled); } if (this.ResetSweepyButton != null) { PButton.SetButtonEnabled(this.ResetSweepyButton, enabled); } if (!enabled) { if ((UnityEngine.Object) this.MoveSpeedText != (UnityEngine.Object)null) { PUIElements.SetText(this.MoveSpeedText, "N/A"); } StationaryChoreRangeVisualizer choreRangeVisualizer = this.target.GetComponent <StationaryChoreRangeVisualizer>(); if ((UnityEngine.Object)choreRangeVisualizer != (UnityEngine.Object)null) { choreRangeVisualizer.x = 0; choreRangeVisualizer.width = 0; Traverse.Create(choreRangeVisualizer).Method("UpdateVisualizers").GetValue(); } if ((UnityEngine.Object) this.ProbingRadiusText != (UnityEngine.Object)null) { PUIElements.SetText(this.ProbingRadiusText, "N/A"); } } }
private void SetProbingRadiusUI(int radius) { if ((UnityEngine.Object) this.target == (UnityEngine.Object)null || (UnityEngine.Object) this.configurator == (UnityEngine.Object)null) { return; } PSliderSingle.SetCurrentValue(this.ProbingRadiusSlider, radius); StationaryChoreRangeVisualizer choreRangeVisualizer = this.target.GetComponent <StationaryChoreRangeVisualizer>(); if ((UnityEngine.Object)choreRangeVisualizer == (UnityEngine.Object)null) { return; } choreRangeVisualizer.x = -radius; choreRangeVisualizer.width = 2 + 2 * radius; Traverse.Create(choreRangeVisualizer).Method("UpdateVisualizers").GetValue(); if ((UnityEngine.Object) this.ProbingRadiusText == (UnityEngine.Object)null) { return; } PUIElements.SetText(this.ProbingRadiusText, radius.ToString("0")); }
/// <summary> /// Populates the menu with the available destroy modes. /// </summary> /// <param name="parameters">The modes to show in the menu.</param> internal void PopulateMenu(IList <DestroyFilter> parameters) { int i = 0; var prefab = ToolMenu.Instance.toolParameterMenu.widgetPrefab; ClearMenu(); foreach (var parameter in parameters) { // Create prefab based on existing Klei menu var widgetPrefab = Util.KInstantiateUI(prefab, choiceList, true); PUIElements.SetText(widgetPrefab, parameter.Title); var toggle = widgetPrefab.GetComponentInChildren <MultiToggle>(); var checkbox = toggle?.gameObject; if (checkbox != null) { // Set initial state, note that ChangeState is only called by SetCheckState // if it appears to be different, but since this executes before the // parent is active it must be set to something different var option = new DestroyMenuOption(parameter, checkbox); PCheckBox.SetCheckState(checkbox, 2); if (i == 0 || SandboxToolsPatches.AdvancedFilterEnabled) { option.State = ToolParameterMenu.ToggleState.On; } options.Add(parameter.ID, option); toggle.onClick += () => OnClick(checkbox); } else { PUtil.LogWarning("Could not find destroy menu checkbox!"); } i++; } }
/// <summary> /// Updates the displayed tool tip and text to match the current item. /// </summary> private void Update() { if (label != null) { var option = options[index]; PUIElements.SetText(label, option.Title); PUIElements.SetToolTip(label, option.ToolTip); } }
private void SetMovespeedUI(float speed) { if ((UnityEngine.Object) this.target == (UnityEngine.Object)null || (UnityEngine.Object) this.configurator == (UnityEngine.Object)null) { return; } PSliderSingle.SetCurrentValue(this.MoveSpeedSlider, speed); if ((UnityEngine.Object) this.MoveSpeedText == (UnityEngine.Object)null) { return; } PUIElements.SetText(this.MoveSpeedText, speed.ToString("0.00")); }
private void ChangeTextFieldProbingRadius(GameObject _, string radius) { if ((UnityEngine.Object) this.target == (UnityEngine.Object)null || (UnityEngine.Object) this.configurator == (UnityEngine.Object)null) { return; } int newRadius; bool converted = int.TryParse(radius, out newRadius); if (converted) { this.ChangeProbingRadius(null, newRadius); } else if ((UnityEngine.Object) this.MoveSpeedText != (UnityEngine.Object)null) { PUIElements.SetText(this.ProbingRadiusText, this.configurator.ProbingRadius.ToString("0")); } }
private void ChangeTextFieldMovespeed(GameObject _, string speed) { if ((UnityEngine.Object) this.target == (UnityEngine.Object)null || (UnityEngine.Object) this.configurator == (UnityEngine.Object)null) { return; } float newSpeed; bool converted = float.TryParse(speed, out newSpeed); if (converted) { this.ChangeMovespeed(null, newSpeed); } else if ((UnityEngine.Object) this.MoveSpeedText != (UnityEngine.Object)null) { PUIElements.SetText(this.MoveSpeedText, this.configurator.MoveSpeed.ToString("0.00")); } }