示例#1
0
        private GUIContent buildButton(PartCategories category)
        {
            Texture texture = iconHelper.GetIcon(category).iconNormal;
            string  title   = PartCategories.Pods.Description();

            return(new GUIContent(texture, title));
        }
        public override void Draw()
        {
            GUIStyle mySty = new GUIStyle(GUI.skin.button);
            mySty.normal.textColor = mySty.focused.textColor = Color.white;
            mySty.hover.textColor = mySty.active.textColor = Color.yellow;
            mySty.onNormal.textColor = mySty.onFocused.textColor = mySty.onHover.textColor = mySty.onActive.textColor = Color.green;
            mySty.padding = new RectOffset(8, 8, 8, 8);

            GUILayout.BeginHorizontal();
            {
                categoriesScrollPosition = GUILayout.BeginScrollView(categoriesScrollPosition, GUILayout.MinWidth(300),
                                                                     GUILayout.MinHeight(600));
                {
                    foreach (PartCategories categories in _availableParts.Keys)
                    {

                        if (GUILayout.Button(categories.ToString())) //GUILayout.Button is "true" when clicked
                        {
                            _selectedCategory = categories;

                        }
                    }
                }
                GUILayout.EndScrollView();

                partScrollPosition = GUILayout.BeginScrollView(partScrollPosition, GUILayout.MinWidth(600), GUILayout.MinHeight(600));
                {
                    if (_selectedCategory != PartCategories.none)
                    {
                        foreach (AvailablePart availablePart in _availableParts[_selectedCategory])
                        {
                            string title = availablePart.title;
                            var oreUnitsRequired = _printer.GetRequiredOreUnits(availablePart);
                            if (GUILayout.Button(title + " (" + oreUnitsRequired + " ore units required)", mySty,
                                                 GUILayout.ExpandWidth(true))) //GUILayout.Button is "true" when clicked
                            {


                                ((KspUIWindow)Parent)?.Close();
                                _printer.BeginBuild(availablePart);
                  





                            }
                        }
                    }
                }
                GUILayout.EndScrollView();
            }
            GUILayout.EndHorizontal();
            //DragWindow makes the window draggable. The Rect specifies which part of the window it can by dragged by, and is 
            //clipped to the actual boundary of the window. You can also pass no argument at all and then the window can by
            //dragged by any part of it. Make sure the DragWindow command is AFTER all your other GUI input stuff, or else
            //it may "cover up" your controls and make them stop responding to the mouse.
            GUI.DragWindow(new Rect(0, 0, 10000, 20));
        }
示例#3
0
 public bool CategoryEnabled(PartCategories cat)
 {
     if (EnabledCategories.Count == 0)
     {
         return(true);
     }
     return(EnabledCategories.Contains(cat));
 }
示例#4
0
        private Dictionary <string, PartContent> GetAvailableContents(PartCategories category)
        {
            var edct = new Dictionary <string, PartContent>();

            foreach (AvailablePart avPart in PartLoader.LoadedPartsList)
            {
                if (avPart.category == category && ResearchAndDevelopment.PartModelPurchased(avPart))
                {
                    PartContent.Get(edct, avPart.name);
                }
            }
            return(edct);
        }
    private List <Part> extractPartOfType(List <Part> parts, PartCategories type)
    {
        List <Part> ret = new List <Part>();

        foreach (Part part in parts)
        {
            if (part.partInfo.category == type)
            {
                ret.Add(part);
            }
        }

        return(ret);
    }
        /*/// <summary>
         * /// Remove the fuction filte category
         * /// </summary>
         * private void RemoveFunctionFilter()
         * {
         *  if (PartCategorizer.Instance != null)
         *  {
         *      PartCategorizer.Category Filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == filterName);
         *      if (Filter != null)
         *      {
         *          PartCategorizer.Category subFilter = Filter.subcategories.Find(f => f.button.categoryName == functionFilterName);
         *          if (subFilter != null)
         *          {
         *              subFilter.DeleteSubcategory();
         *          }
         *      }
         *  }
         * }
         *
         * /// <summary>
         * /// Remove the fuction filte category
         * /// </summary>
         * private void AddFunctionFilter()
         * {
         *  if (PartCategorizer.Instance != null)
         *  {
         *      PartCategorizer.Category Filter = PartCategorizer.Instance.filters.Find(f => f.button.categoryName == filterName);
         *      if (Filter != null)
         *      {
         *          PartCategorizer.Category subFilter = Filter.subcategories.Find(f => f.button.categoryName == functionFilterName);
         *          if (subFilter != null)
         *          {
         *              subFilter.DeleteSubcategory();
         *          }
         *      }
         *  }
         * }
         *
         * /// <summary>
         * /// Add the stored categories to all the parts of KPBS
         * /// </summary>
         * private void AddPartCategories()
         * {
         *  if (partCategories != null)
         *  {
         *      List<AvailablePart> parts = PartLoader.Instance.loadedParts.FindAll(ap => ap.name.StartsWith("KKAOSS"));
         *      for (int i = 0; i < parts.Count; i++)
         *      {
         *          if (partCategories.ContainsKey(parts[i].name))
         *          {
         *              parts[i].category = partCategories[parts[i].name];
         *          }
         *      }
         *  }
         * }
         *
         * /// <summary>
         * /// Remove the categories from all parts of KPBS
         * /// </summary>
         * private void RemovePartCategories()
         * {
         *  List<AvailablePart> parts = PartLoader.Instance.loadedParts.FindAll(ap => ap.name.StartsWith("KKAOSS"));
         *  for (int i = 0; i < parts.Count; i++)
         *  {
         *      parts[i].category = PartCategories.none;
         *  }
         * }*/

        /**
         * Filter the parts by their manufacturer
         *
         * @param[in] part : the part to test
         * @param[in] category : the category of the part
         *
         * @return[bool] true when categories match, else false
         */
        private bool filterCategories(AvailablePart part, PartCategories category, int index)
        {
            if (index >= KerbetrotterConfiguration.Instance().FilterSettings.Length)
            {
                Debug.LogError("[KerbetrotterTools] invalid index for category filter: " + index);
                return(false);
            }

            KerbetrotterFilterSettings filterSettings = KerbetrotterConfiguration.Instance().FilterSettings[index];

            //return false when the part is not included by the filter
            if (!part.name.StartsWith(filterSettings.IncludeFilter) || (!string.IsNullOrEmpty(filterSettings.ExcludeFilter) && part.name.StartsWith(filterSettings.ExcludeFilter)))
            {
                return(false);
            }
            return(partCategories[index][part.name] == category);
        }
示例#7
0
        private void Rehash()
        {
            //TODO Filter out unresearched parts
            HashedEnabledPartNames.Clear();
            EnabledCategories.Clear();
            bool firstRound = true;

            foreach (PartTag tag in EnabledTags)
            {
                if (firstRound || ConfigHandler.Instance.UnionFilter)
                {
                    firstRound = false;
                    HashedEnabledPartNames.UnionWith(tag.VisibleParts);
                    EnabledCategories.UnionWith(tag.VisiblePartCategories);
                }
                else
                {
                    HashedEnabledPartNames.IntersectWith(tag.VisibleParts);
                    EnabledCategories.IntersectWith(tag.VisiblePartCategories);
                }
            }
            if (ConfigHandler.Instance.DisplayAllOnEmptyFilter && EnabledCategories.Count == 0 || EnabledTags.Count == 0)
            {
                EditorPartList.Instance.ShowTabs();
            }
            else
            {
                PartCategories selectedCategory = (PartCategories)EditorPartList.Instance.categorySelected;
                EditorPartList.Instance.HideTabs();
                EditorPartList.Instance.ShowTab(EditorPartList.Instance.tabs.Length - 1);
                foreach (PartCategories category in EnabledCategories)
                {
                    if (category != PartCategories.none)
                    {
                        if (!EnabledCategories.Contains((PartCategories)EditorPartList.Instance.categorySelected))
                        {
                            EditorPartList.Instance.ForceSelectTab(category);
                            selectedCategory = category;
                        }
                        EditorPartList.Instance.ShowTab(category);
                    }
                }
            }
        }
示例#8
0
        private Dictionary <AvailablePart, int> GetAvailableContents(PartCategories category)
        {
            Dictionary <AvailablePart, int> edct = new Dictionary <AvailablePart, int>();

            foreach (AvailablePart avPart in PartLoader.LoadedPartsList)
            {
                KASModuleGrab grabModule = avPart.partPrefab.GetComponent <KASModuleGrab>();
                if (grabModule)
                {
                    if (grabModule.storable)
                    {
                        if (avPart.category == category)
                        {
                            edct.Add(avPart, 0);
                        }
                    }
                }
            }
            return(edct);
        }
 /**
  * Filter the parts by their manufacturer
  *
  * @param[in] part : the part to test
  * @param[in] category : the category of the part
  *
  * @return[bool] true when categories match, else false
  */
 private bool filterCategories(AvailablePart part, PartCategories category)
 {
     return (part.name.StartsWith("KKAOSS") && (part.category == category));
 }
示例#10
0
        public override void OnRender()
        {
            try
            {
                List <Part> parts = EditorLogic.fetch.ship != null ? EditorLogic.fetch.ship.Parts : new List <Part>();

                this.highlight.BeginTracking();

                GUILayout.BeginVertical();

#if false
                // If Blizzy's toolbar is available, give the user the option to pick the stock toolbar.
                if (ToolbarManager.ToolbarAvailable)
#endif
                {
                    //bool stockToolbar = PartWizardPlugin.ToolbarIsStock;
                    bool stockToolbar = GUILayout.Toggle(PartWizardPlugin.ToolbarIsStock, Localized.UseStockToolbar, GUILayout.Width(200));
                    if (stockToolbar != PartWizardPlugin.ToolbarIsStock)
                    {
#if false
                        PartWizardPlugin.ToolbarTypeToggleActive = true;
#endif
                        PartWizardPlugin.ToolbarIsStock = stockToolbar;
                        PartWizardPlugin.Instance.SaveToolbarConfiguration();
                    }
                }

                #region Display Mode Control

                GUILayout.BeginHorizontal();
                this.viewType = (ViewType)GUIControls.HorizontalToggleSet((int)this.viewType, this.viewTypeContents, this.selectedViewTypeStyle, this.unselectedViewTypeStyle);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                GUILayout.Label("Sort by:");
                this.sortBy = (SortBy)GUIControls.HorizontalToggleSet((int)this.sortBy, this.sortTypeContents, this.selectedViewTypeStyle, this.unselectedViewTypeStyle);
                GUILayout.EndHorizontal();

                List <Part> buyableParts = null;

                if (this.viewType == ViewType.Hidden)
                {
                    parts = parts.FindAll((p) => { return(p.partInfo.category == PartCategories.none); });
                }
                else if (this.viewType == ViewType.Unavailable)
                {
                    parts = parts.FindAll((p) => {
                        bool result = false;

                        // Get the R&D technology state for the current part.
                        ProtoTechNode techState = ResearchAndDevelopment.Instance.GetTechState(p.partInfo.TechRequired);

                        // If there is a state or the technology is locked or the part hasn't been purchased...
                        if (techState == null || techState.state != RDTech.State.Available || !techState.partsPurchased.Contains(p.partInfo))
                        {
                            // ...add it to the list.
                            result = true;
                        }

                        return(result);
                    });
                    Debug.Log("total # buyable part: " + parts.Count.ToString());
                    // Stash the filtered list in to the buyable list.
                    buyableParts = parts;
                    // Create a new collection with a copy of all the buyable parts.
                    parts = new List <Part>(buyableParts);
                    // Create a hash set to act as a filter for duplicate parts.
                    HashSet <string> duplicatePartFilter = new HashSet <string>();
                    // Remove each part that has already been added to the hash filter.
                    parts.RemoveAll((p) => !duplicatePartFilter.Add(p.name));

                    // Here parts is a list of unique buyable parts and buyableParts is all of the buyable parts, including duplicates.
                    Debug.Log("total # buyable part after dup filter: " + parts.Count.ToString());
                }

                #endregion
                if (parts != null && parts.Count > 0)
                {
                    switch (sortBy)
                    {
                    case SortBy.Name:
                        parts.Sort((p, q) => p.partInfo.title.CompareTo(q.partInfo.title));
                        break;

                    case SortBy.StageAsc:
                        if (this.viewType != ViewType.Unavailable)
                        {
                            parts.Sort((p, q) => p.inverseStage.CompareTo(q.inverseStage));
                        }
                        else
                        {
                            parts.Sort((p, q) => p.partInfo.title.CompareTo(q.partInfo.title));
                        }
                        break;

                    case SortBy.StageDesc:
                        if (this.viewType != ViewType.Unavailable)
                        {
                            parts.Sort((q, p) => p.inverseStage.CompareTo(q.inverseStage));
                        }
                        else
                        {
                            parts.Sort((p, q) => p.partInfo.title.CompareTo(q.partInfo.title));
                        }
                        break;
                    }
                }
                #region Part List

                GUILayout.BeginVertical(GUIControls.PanelStyle);

                this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, false, false);

                int totalEntryCost   = 0;
                int visiblePartCount = 0;
                int lastStage        = 0;
                if (parts != null && parts.Count > 0)
                {
                    lastStage = parts[0].inverseStage;
                }

                if (this.viewType == ViewType.Category)
                {
                    if (GUILayout.Button(Localized.ViewAll))
                    {
                        for (int i = 0; i < visibleCategories.Length; i++)
                        {
                            visibleCategories[i] = true;
                        }
                    }
                    if (GUILayout.Button(Localized.Clear))
                    {
                        for (int i = 0; i < visibleCategories.Length; i++)
                        {
                            visibleCategories[i] = false;
                        }
                    }

                    for (PartCategories partCategories = PartCategories.Propulsion; partCategories < PartCategories.Coupling; partCategories++)
                    {
                        // Need to add one to the PartCategories because "none" is a -1, and some parts have a category = none
                        visibleCategories[(int)partCategories + 1] = GUILayout.Toggle(visibleCategories[(int)partCategories + 1], partCategories.ToString(), toggleStyle);
                    }
                }
                else if (this.viewType == ViewType.Resources)
                {
                    if (GUILayout.Button(Localized.ViewAll))
                    {
                        foreach (ResourceInfo resourceInfo in this.availableResources.Values)
                        {
                            resourceInfo.Visible = true;
                        }
                    }

                    if (GUILayout.Button(Localized.Clear))
                    {
                        foreach (ResourceInfo resourceInfo in this.availableResources.Values)
                        {
                            resourceInfo.Visible = false;
                        }
                    }

                    foreach (string availableResource in this.availableResources.Keys)
                    {
                        bool resourceVisible = GUILayout.Toggle(this.availableResources[availableResource].Visible, availableResource, toggleStyle);

                        this.availableResources[availableResource].Visible = resourceVisible;
                    }
                }
                else
                {
                    foreach (Part part in parts)
                    {
                        // Reset part name label color to default; some conditions may change the color to indicate various things.
                        labelStyle.normal.textColor = PartWizardWindow.DefaultPartNameColor;
                        // Check if this part's category is currently visible.
                        // Need to add one to the PartCategories because "none" is a -1, and some parts have a category = none
                        if (visibleCategories[(int)part.partInfo.category + 1])
                        {
                            // The part's category is visible, now check resource conditions to determine final visibility.
                            bool partVisible = false;

                            if (this.availableResources[Localized.ShowPartsWithoutResources].Visible && part.Resources.Count == 0)
                            {
                                partVisible = true;
                            }
                            else
                            {
                                foreach (PartResource partResource in part.Resources)
                                {
                                    if (this.availableResources[partResource.resourceName].Visible)
                                    {
                                        partVisible = true;
                                        break;
                                    }
                                }
                            }
                            if (partVisible)
                            {
                                totalEntryCost += part.partInfo.entryCost;
                                visiblePartCount++;

                                GUIControls.BeginMouseOverHorizontal();

                                bool actionEditorPartButtonMouseOver = false;

                                #region Part Label

                                if (sortBy == SortBy.StageAsc || sortBy == SortBy.StageDesc)
                                {
                                    if (lastStage != part.inverseStage)
                                    {
                                        lastStage = part.inverseStage;
                                    }
                                    GUILayout.Label(lastStage.ToString() + ": ");
                                }
                                if (EditorLogic.fetch.editorScreen != EditorScreen.Actions)
                                {
                                    // Check compound parts for integrity.
                                    if (part is CompoundPart)
                                    {
                                        CompoundPart compoundPart = (CompoundPart)part;
                                        if (compoundPart.attachState == CompoundPart.AttachState.Detached || compoundPart.attachState == CompoundPart.AttachState.Attaching || compoundPart.target == compoundPart.parent)
                                        {
                                            labelStyle.normal.textColor = Color.red;
                                        }
                                    }
                                    labelStyle.fixedWidth = 250;
                                    GUILayout.Label(new GUIContent(part.partInfo.title, part.partInfo.name), labelStyle);
                                }
                                else
                                {
                                    Log.Write("EditorScreen.Actions, part: " + part.partInfo.title);
                                    if (GUIControls.MouseOverButton(new GUIContent(part.partInfo.title, part.partInfo.name), out actionEditorPartButtonMouseOver, this.actionEditorModePartButtonStyle))
                                    {
                                        // Each part gets the EditorActionPartSelector added to it when the editor switches to the Actions screen. (And it
                                        // gets taken away when leaving that screen.)
                                        EditorActionPartSelector selector = part.GetComponent <EditorActionPartSelector>();

                                        // Make sure we have it...
                                        if (selector != null)
                                        {
                                            // ...and select it.
                                            selector.Select();

                                            Log.Write("Action editor selecting part {0}.", part.name);
                                        }
                                    }
                                }

                                #endregion

                                // Adds space between the part name and the buttons (if any) associated with the part.
                                GUILayout.FlexibleSpace();

                                // Only enable the following buttons if there is no actively selected part, but we want to have them drawn.
                                GUI.enabled = EditorLogic.SelectedPart == null;

                                bool deleted = false;                   // Will be set to true if the delete button was pressed.
                                bool bought  = false;                   // Will be set to true if the buy button was pressed.

                                bool breakSymmetryMouseOver = false;    // Will be set to true if the mouse is over the part's break symmetry button.
                                bool deleteButtonMouseOver  = false;    // Will be set to true if the mouse is over the part's delete button.
                                bool buyButtonMouseOver     = false;    // Will be set to true if the mouse is over the part's buy button.

                                string deleteTooltip = default(string);
                                string buyTooltip    = default(string);

                                if (this.viewType == ViewType.All || this.viewType == ViewType.Hidden)
                                {
                                    #region Break Symmetry Button

                                    string breakabilityReport = default(string);
                                    GUI.enabled = EditorLogic.SelectedPart == null && EditorLogic.fetch.editorScreen == EditorScreen.Parts && PartWizard.HasBreakableSymmetry(part, out breakabilityReport);

                                    string breakSymmetryTooltip = GUI.enabled ? Localized.BreakSymmetryDescription : default(string);

                                    breakSymmetryMouseOver = false;
                                    if (GUIControls.MouseOverButton(new GUIContent(Localized.BreakSymmetryButtonText, breakSymmetryTooltip), out breakSymmetryMouseOver, Configuration.PartActionButtonWidth))
                                    {
                                        this.symmetryEditorWindow.Part = part;

                                        if (!this.symmetryEditorWindow.Visible)
                                        {
                                            this.symmetryEditorWindow.Show(this);

                                            // Short circuit the mouse over for breaking symmetry when showing the Symmetry Editor in case it appears over top of this
                                            // button and immediately begins highlighting parts. This would cause *this* window's highlighting to be stuck on the part.
                                            breakSymmetryMouseOver = false;
                                        }
                                    }

                                    breakSymmetryMouseOver &= GUI.enabled;  // Clear mouse over flag if the symmetry button was disabled.

                                    #endregion

                                    #region Delete Button

                                    GUI.enabled = EditorLogic.SelectedPart == null && EditorLogic.fetch.editorScreen == EditorScreen.Parts && PartWizard.IsDeleteable(part);

                                    deleteTooltip = GUI.enabled
                                        ? ((part.symmetryCounterparts.Count == 0) ? Localized.DeletePartSingularDescription : Localized.DeletePartPluralDescription)
                                        : default(string);

                                    if (GUIControls.MouseOverButton(new GUIContent(Localized.DeletePartButtonText, deleteTooltip), out deleteButtonMouseOver, Configuration.PartActionButtonWidth))
                                    {
                                        PartWizard.Delete(part);

                                        // Set a flag so additional GUI logic can decide what to do in the case where a part is deleted.
                                        deleted = true;
                                    }

                                    deleteButtonMouseOver &= GUI.enabled;   // Clear mouse over flag if the delete button was disabled.

                                    #endregion
                                }
                                else // this.viewType == ViewType.Unavailable
                                {
                                    #region Buy Button

                                    GUI.enabled = EditorLogic.SelectedPart == null && (double)part.partInfo.entryCost <= Funding.Instance.Funds && PartWizard.IsBuyable(part);

                                    buyTooltip = GUI.enabled ? string.Format(Localized.BuyPartDescriptionTextFormat, part.partInfo.entryCost) : default(string);

                                    if (GUIControls.MouseOverButton(new GUIContent(Localized.BuyPartButtonText, buyTooltip), out buyButtonMouseOver, Configuration.PartActionButtonWidth))
                                    {
                                        Log.Write("Buying part {0}.", part.name);

                                        PartWizard.Buy(part, true);

                                        // Set a flag so additional GUI logic can decide what to do in the case where a part is bought.
                                        bought = true;
                                    }

                                    buyButtonMouseOver &= GUI.enabled;  // Clear mouse over flag if the buy button was disabled.

                                    #endregion
                                }

                                GUI.enabled = true;

                                bool groupMouseOver = false;
                                GUIControls.EndMouseOverHorizontal(out groupMouseOver);     // End of row for this part.

                                // If we deleted a part, then just jump out of the loop since the parts list has been modified.
                                if (deleted || bought)
                                {
                                    break;
                                }

                                #region Part Highlighting Control

                                if (breakSymmetryMouseOver)
                                {
                                    this.highlight.Add(part, Configuration.HighlightColorEditableSymmetryRoot, Configuration.HighlightColorEditableSymmetryCounterparts, true);
                                }
                                else if (deleteButtonMouseOver)
                                {
                                    this.highlight.Add(part, Configuration.HighlightColorDeletablePart, Configuration.HighlightColorDeletableCounterparts, true);
                                }
                                else if (buyButtonMouseOver)
                                {
                                    // TODO: Duplicate code!
                                    buyableParts.ForEach((p) => {
                                        if (part.name == p.name)
                                        {
                                            this.highlight.Add(p, Configuration.HighlightColorBuyablePart);
                                        }
                                    });
                                }
                                else if (groupMouseOver)
                                {
                                    if (viewType != ViewType.Unavailable)
                                    {
                                        Color highlightColor            = (part == EditorLogic.RootPart) ? Configuration.HighlightColorRootPart : Configuration.HighlightColorSinglePart;
                                        Color counterpartHighlightColor = Configuration.HighlightColorCounterparts;

                                        if (EditorLogic.fetch.editorScreen == EditorScreen.Actions)
                                        {
                                            highlightColor            = Configuration.HighlightColorActionEditorTarget;
                                            counterpartHighlightColor = Configuration.HighlightColorActionEditorTarget;
                                        }

                                        this.highlight.Add(part, highlightColor, counterpartHighlightColor, false);
                                    }
                                    else
                                    {
                                        // TODO: Duplicate code!
                                        buyableParts.ForEach((p) => {
                                            if (part.name == p.name)
                                            {
                                                Log.Write("Highlighting 2 part: " + part.partInfo.title);
                                                this.highlight.Add(p, Configuration.HighlightColorBuyablePart, false);
                                            }
                                        });
                                    }
                                }
                                else if (actionEditorPartButtonMouseOver)
                                {
                                    Log.Write("Highlighting part: " + part.partInfo.title);
                                    this.highlight.Add(part, Configuration.HighlightColorActionEditorTarget, Configuration.HighlightColorActionEditorTarget);
                                }

                                #endregion
                            }
                        }
                    }
                }

                GUILayout.EndScrollView();

                GUILayout.EndVertical();

                if (viewType == ViewType.Unavailable)
                {
                    int  buyableEntryCost = 0;
                    bool enableBulkBuy    = false;

                    foreach (Part p in parts)
                    {
                        buyableEntryCost += p.partInfo.entryCost;

                        enableBulkBuy |= PartWizard.IsBuyable(p);
                    }

                    GUI.enabled = parts.Count > 0 && (double)buyableEntryCost <= Funding.Instance.Funds && enableBulkBuy;

                    bool buyAllMouseOver = false;
                    if (GUIControls.MouseOverButton(new GUIContent(string.Format(Localized.BuyAllButtonTextFormat, buyableEntryCost)), out buyAllMouseOver))
                    {
                        foreach (Part part in parts)
                        {
                            if (PartWizard.IsBuyable(part))
                            {
                                Log.Write("Buying part {0}.", part.name);

                                PartWizard.Buy(part, false);
                            }
                        }

                        PartWizard.SaveGame();
                    }

                    // TODO: Highlight all parts that will be bought by clicking Buy All.
                    if (buyAllMouseOver)
                    {
                        buyableParts.ForEach((p) => {
                            this.highlight.Add(p, Configuration.HighlightColorBuyablePart);
                        });
                    }

                    GUI.enabled = true;
                }

                #endregion

                #region Status Area

                // Push everything above this up, otherwise it will be centered vertically.
                GUILayout.FlexibleSpace();

                if (viewType == ViewType.All || viewType == ViewType.Hidden || viewType == ViewType.Unavailable)
                {
                    string status = default(string);

                    if (!string.IsNullOrEmpty(GUI.tooltip))
                    {
                        if (parts.Count != 1)
                        {
                            status = string.Format(CultureInfo.CurrentCulture, Localized.StatusLabelPluralTooltipTextFormat, visiblePartCount, GUI.tooltip, parts.Count - visiblePartCount);
                        }
                        else
                        {
                            status = string.Format(CultureInfo.CurrentCulture, Localized.StatusLabelSingularTooltipTextFormat, visiblePartCount, GUI.tooltip, parts.Count - visiblePartCount);
                        }
                    }
                    else
                    {
                        if (parts.Count != 1)
                        {
                            status = string.Format(CultureInfo.CurrentCulture, Localized.StatusLabelPluralTextFormat, visiblePartCount, parts.Count - visiblePartCount);
                        }
                        else
                        {
                            status = string.Format(CultureInfo.CurrentCulture, Localized.StatusLabelSingularTextFormat, visiblePartCount, parts.Count - visiblePartCount);
                        }
                    }

                    GUILayout.Label(status, this.tooltipLabelStyle);
                }

                #endregion

                GUILayout.EndVertical();

                if (this.Visible && this.mouseOver)
                {
                    this.highlight.EndTracking();
                }
                else
                {
                    this.highlight.CancelTracking();
                }
            }
            catch (Exception e)
            {
                Log.Write("PartWizardWindow.OnRender() unexpected exception caught.");

                Log.Write(e.Message);
                Log.Write(e.StackTrace);

                this.highlight.CancelTracking();

                throw;
            }
            finally
            {
                GUI.DragWindow();
            }
        }
 public RUI.Icons.Selectable.Icon GetIcon(PartCategories category)
 {
     return(IconLoader.GetIcon(iconNames[category]));
 }
示例#12
0
 private static void InventoryCategoryChanged(PartCategories category)
 {
     InventoryForCategory.Clear();
     InventoryCommonNames.Clear();
     foreach (KeyValuePair<string, int> entry in KCT_GameStates.PartInventory)
     {
         string name = entry.Key;
         string baseName = name.Split(',').Length == 1 ? name : name.Split(',')[0];
         AvailablePart aPart = KCT_Utilities.GetAvailablePartByName(baseName);
         if (aPart != null)
         {
             PartCategories aPartCategory = aPart.category;
             if (aPartCategory == PartCategories.Propulsion)
                 aPartCategory = PartCategories.Engine;
             if (aPartCategory == category)
             {
                 string tweakscale = "";
                 if (name.Split(',').Length == 2)
                     tweakscale = "," + name.Split(',')[1];
                 name = aPart.title + tweakscale;
                 if (!InventoryForCategory.ContainsKey(entry.Key))
                 {
                     InventoryForCategory.Add(entry.Key, entry.Value);
                     InventoryCommonNames.Add(entry.Key, name);
                 }
             }
         }
     }
 }
示例#13
0
 /// <summary>
 /// Returns the texture associated with this <see cref="PartCategories"/>.
 /// </summary>
 /// <param name="category">The part category to get the texture for.</param>
 /// <returns>The texture associated with the part category.</returns>
 public static Texture GetTexture(this PartCategories category)
 {
     return(GameDatabase.Instance.GetTexture(Program.ModPath + "Resources/" + category.ToString(), false));
 }
示例#14
0
 public FilterCategory(PartCategories category)
 {
     Category = category;
 }
示例#15
0
 public FilterCategory(PartCategories category)
 {
     Category = category;
 }
示例#16
0
 private Dictionary<string, PartContent> GetAvailableContents(PartCategories category)
 {
     var edct = new Dictionary<string, PartContent>();
     foreach (AvailablePart avPart in PartLoader.LoadedPartsList)
     {
         if (avPart.category == category && ResearchAndDevelopment.PartModelPurchased(avPart))
             PartContent.Get(edct, avPart.name);
     }
     return edct;
 }
示例#17
0
 /**
  * Filter the parts by their manufacturer
  *
  * @param[in] part : the part to test
  * @param[in] category : the category of the part
  *
  * @return[bool] true when categories match, else false
  */
 private bool filterCategories(AvailablePart part, PartCategories category)
 {
     return(part.name.StartsWith("KKAOSS") && (part.category == category));
 }
示例#18
0
 private Dictionary<AvailablePart, int> GetAvailableContents(PartCategories category)
 {
     Dictionary<AvailablePart, int> edct = new Dictionary<AvailablePart, int>();
     foreach (AvailablePart avPart in PartLoader.LoadedPartsList)
     {
         KASModuleGrab grabModule = avPart.partPrefab.GetComponent<KASModuleGrab>();
         if (grabModule)
         {
             if (grabModule.storable)
             {
                 if (avPart.category == category)
                 {
                     edct.Add(avPart, 0);
                 }
             }
         }
     }
     return edct;
 }