Sort() public static méthode

Sorts the given missions with the given method
public static Sort ( List missions, SortBy sortBy ) : void
missions List Missions.
sortBy SortBy Sort by.
Résultat void
Exemple #1
0
        /// <summary>
        /// Loads the given mission package
        /// </summary>
        /// <returns>The mission package.</returns>
        /// <param name="path">Path.</param>
        public MissionPackage loadMissionPackage(String path)
        {
            MissionPackage pkg = (MissionPackage)parser.readFile(path);

            Mission.Sort(pkg.Missions, pkg.ownOrder ? SortBy.PACKAGE_ORDER : SortBy.NAME);
            return(pkg);
        }
Exemple #2
0
        /// <summary>
        /// Draws the mission package browser window
        /// </summary>
        /// <param name="id">Identifier.</param>
        private void drawPackageWindow(int id)
        {
            GUI.skin = HighLogic.Skin;
            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical(GUILayout.Width(530));
            if (GUILayout.Button(sortStrings[currentSort], styleButton, GUILayout.Width(500)))
            {
                nextSort();
                Mission.Sort(currentPackage.Missions, currentSort);
            }
            packageScrollPosition = GUILayout.BeginScrollView(packageScrollPosition, GUILayout.Width(500));

            foreach (Mission m in currentPackage.Missions)
            {
                Status s = calculateStatus(m, false, null);
                GUILayout.BeginHorizontal(GUILayout.Width(450));
                GUIStyle style = styleButton;

                if (s.requiresAnotherMission)
                {
                    style = styleRedButton;
                }

                if (m == currentPreviewMission)
                {
                    style = styleGreenButton;
                }

                if (GUILayout.Button(m.name + "\n" + m.reward + CurrencySuffix, style, GUILayout.Width(350)))
                {
                    currentPreviewMission = manager.reloadMission(m, activeVessel);
                }

                if (s.missionAlreadyFinished)
                {
                    GUILayout.Label(iconFinished, GUILayout.MaxWidth(50), GUILayout.MaxHeight(50), GUILayout.ExpandWidth(false),
                                    GUILayout.Width(50), GUILayout.Height(50));
                }
                else
                {
                    foreach (Mission.Category c in iconDictionary.Keys)
                    {
                        if (m.category.Has(c))
                        {
                            GUILayout.Label(iconDictionary[c], GUILayout.MaxWidth(50), GUILayout.MaxHeight(50), GUILayout.ExpandWidth(false),
                                            GUILayout.Width(50), GUILayout.Height(50));
                        }
                    }
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            previewMissionScrollPosition = GUILayout.BeginScrollView(previewMissionScrollPosition);

            // Show the description text if no mission is currently selected
            if (currentPreviewMission == null)
            {
                GUILayout.Label(currentPackage.description, styleText);
            }
            else
            {
                // otherwise draw the mission parameters
                drawMission(currentPreviewMission, calculateStatus(currentPreviewMission, false, activeVessel));
            }
            GUILayout.EndScrollView();

            GUILayout.BeginHorizontal();
            if (currentPreviewMission != null)
            {
                if (GUILayout.Button("Select mission"))
                {
                    // we also reset the hiddenGoals field
                    hiddenGoals           = new List <MissionGoal> ();
                    currentMission        = currentPreviewMission;
                    currentPreviewMission = null;
                    packageWindow(false);
                }

                if (currentPreviewMission.randomized && GUILayout.Button("Discard"))
                {
                    manager.discardRandomMission(currentPreviewMission);
                    currentPreviewMission = manager.reloadMission(currentPreviewMission, activeVessel);
                }
            }

            if (GUILayout.Button("Close"))
            {
                packageWindow(false);
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            GUI.DragWindow();
        }