/// <summary> /// Draws a single action group button. /// </summary> /// <param name="group">The action group button to draw.</param> /// <param name="textOnly">True the button should contain text instead of images.</param> private void DrawActionGroupSelectorButton(KSPActionGroup group, bool textOnly) { List <BaseAction> actions = PartManager.GetBaseActionAttachedToActionGroup(group); GUIContent content; // Configure the button if (textOnly) { content = new GUIContent( group.displayDescription() + (actions.Count > 0 ? " " + Localizer.Format(Localizer.GetStringByTag("#autoLOC_AGM_150"), actions.Count) : null), Localizer.Format(Localizer.GetStringByTag("#autoLOC_AGM_104"), group.displayDescription())); } else { content = new GUIContent( actions.Count > 0 ? actions.Count.ToString(CultureInfo.InvariantCulture) : string.Empty, group.GetTexture(), string.Format(CultureInfo.InvariantCulture, Localizer.Format(Localizer.GetStringByTag("#autoLOC_AGM_104"), group.displayDescription()))); } // Create the button if (GUILayout.Toggle(group == this.currentSelectedActionGroup, content, textOnly ? Style.Button : Style.ButtonIcon)) { this.SelectedActionGroup = group; } }
/// <summary> /// Performed actions queued in <see cref="modifiedActions"/>. /// </summary> private void UpdateActionLists() { // Remove actions between paints to prevent iteration and GUIClips errors if (this.modifiedActions.Count > 0) { foreach (KeyValuePair <BaseAction, ActionModifyState> action in this.modifiedActions) { if (action.Value == ActionModifyState.Remove) { Program.AddDebugLog("Removing action with name: " + action.Key.name); this.SelectedActionGroup.RemoveAction(action.Key); } else { Program.AddDebugLog("Adding action with name: " + action.Key.name); this.SelectedActionGroup.AddAction(action.Key); } } this.assignedActionsDirty = true; this.modifiedActions.Clear(); } if (this.assignedActionsDirty) { this.assignedActions = PartManager.GetBaseActionAttachedToActionGroup(this.SelectedActionGroup); this.assignedActions.Sort((ba1, ba2) => ba1.listParent.part.GetInstanceID().CompareTo(ba2.listParent.part.GetInstanceID())); this.assignedActionsDirty = false; } }