/// <summary> /// On Screen Display feature: /// Clear, and hide the keybind panel. /// Populate with items, which can be keyboard shortcuts or hardcoded mouse clicks. /// </summary> /// <param name="items">List of <see cref="OsdItem"/> to display.</param> public static void Display(List <OsdItem> items) { MainMenuWindow mainMenu = ModUI.Instance.MainMenu; Hide(); // Deactivate old items, and destroy them. Also remove them from the panel till Unity // is happy to delete them. foreach (Transform c in mainMenu.OnscreenDisplayPanel.transform) { c.gameObject.SetActive(false); UnityEngine.Object.Destroy(c.gameObject); } // mainMenu.KeybindsPanel.transform.DetachChildren(); // Populate the panel with the items using (var builder = new UiBuilder <U.UPanel>(mainMenu.OnscreenDisplayPanel)) { foreach (var item in items) { item.Build(builder); } } if (items.Count > 0 && mainMenu.OnscreenDisplayPanel.GetUIView() != null) { mainMenu.OnscreenDisplayPanel.opacity = 1f; // fully visible, opaque } // Recalculate now UResizer.UpdateControl(mainMenu); }
/// <summary>Resize everything in MainMenu to fit the new panel contents.</summary> public static void Done() { MainMenuWindow mainMenu = ModUI.Instance.MainMenu; // Recalculate now UResizer.UpdateControl(mainMenu); }
/// <summary> /// Forces speedlimit palette buttons to be updated, and active button also is highlighted. /// </summary> public void UpdatePaletteButtonsOnClick() { foreach (SpeedLimitPaletteButton b in this.palettePanel_.PaletteButtons) { b.ApplyButtonSkin(); b.UpdateSpeedlimitButton(); } UResizer.UpdateControl(this); // force window relayout }
private void OnVisibilityChanged(UIComponent component, bool value) { VersionLabel.enabled = value; if (StatsLabel != null) { // might not exist StatsLabel.enabled = Options.showPathFindStats && value; } UResizer.UpdateControl(this); }
/// <summary> /// Update the info label with explanation what the user currently sees. /// </summary> /// <param name="multiSegmentMode">Whether user is holding shift to edit road length.</param> /// <param name="editDefaults">Whether user is seeing segment speed limits.</param> /// <param name="showLanes">Whether separate limits per lane are visible.</param> public void UpdateModeInfoLabel(bool multiSegmentMode, bool editDefaults, bool showLanes) { var sb = new StringBuilder(15); // initial capacity of stringBuilder var translation = Translation.SpeedLimits; //-------------------------- // Current editing mode //-------------------------- sb.Append(editDefaults ? translation.Get("Editing default limits per road type") : (showLanes ? translation.Get("Editing lane speed limit overrides") : translation.Get("Editing speed limit overrides for segments"))); sb.Append(".\n"); // //-------------------------- // // Keyboard modifier hints // //-------------------------- // if (!editDefaults) { // // In defaults and lanes mode Shift is not working // sb.Append(translation.ColorizeKeybind("UI.Key:Shift edit multiple")); // sb.Append(".\n"); // } // // sb.Append(editDefaults // ? translation.ColorizeKeybind("UI.Key:Alt show overrides") // : translation.ColorizeKeybind("UI.Key:Alt show defaults")); // sb.Append(".\n"); // // sb.Append(translation.ColorizeKeybind("UI.Key:PageUp/PageDown switch underground")); // sb.Append(". "); this.ModeDescriptionLabel.text = sb.ToString(); UResizer.UpdateControl(this); }
/// <summary> /// When form building is finished, recalculates all nested sizes and places stuff /// according to sizes and positions configured in USizePosition members of form controls. /// </summary> public void Done() { UResizer.UpdateControl(this.Control); }