makeUniqueTrackName() public static method

public static makeUniqueTrackName ( string name, List &trackList, bool renaming ) : string
name string
trackList List
renaming bool
return string
Ejemplo n.º 1
0
        public void startNewTrack()
        {
            Debug.Log("Starting new Track");
            recording = true;


            //create new Track
            activeTrack = new Track(); //initializes with TrackName = activeVessel.Name

            CraftLoader.saveCraftToFile();

            activeTrack.TrackName = Utilities.makeUniqueTrackName(activeTrack.TrackName, ref allTracks, false);
            allTracks.Add(activeTrack);
            updateCurrentTrack();
        }
Ejemplo n.º 2
0
        protected override void DrawWindowContents(int windowID)
        {
            GUILayout.BeginVertical(); // BEGIN outer container

            GUILayout.BeginHorizontal();
            GUILayout.Label("Track Name:");
            newName = GUILayout.TextField(newName);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Description:");
            newDescription = GUILayout.TextField(newDescription);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Color");

            GUILayout.BeginVertical();
            float h, s, v;

            Utilities.ColorToHSV(newColor, out h, out s, out v);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Hue");
            h = GUILayout.HorizontalSlider(h, 0, 360);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Sat.");
            s = GUILayout.HorizontalSlider(s, 0, 1);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Val.");
            v        = GUILayout.HorizontalSlider(v, 0, 1);
            newColor = Utilities.ColorFromHSV(h, s, v);
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            Utilities.SetTextureColor(colorTex, 32, 32, this.newColor);
            //this.colorStyle = new GUIStyle();
            //colorStyle.normal.textColor = this.newColor;
            //GUIStyle generic_style = new GUIStyle();
            //GUI.skin.box = generic_style;
            //GUI.Box(new Rect(x, y, w, h), rgb_texture);

            if (GUILayout.Button(colorTex))
            {
                // Show the color dialog.
                ExplorerTrackBehaviour.Instance.colorDlg = new ColorPicker(this);
                ExplorerTrackBehaviour.Instance.colorDlg.Awake();
                ExplorerTrackBehaviour.Instance.colorDlg.SetVisible(true);
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Draw Sampling:");
            sampling = GUILayout.HorizontalSlider(sampling, 1, 10);
            GUILayout.Label("" + (int)sampling + "x");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Line Width (m):");
            float sliderPos = lineWidthToSliderPos(lineWidth);

            sliderPos = GUILayout.HorizontalSlider(sliderPos, 1, 12);
            lineWidth = sliderPosToLineWidth(sliderPos);
            GUILayout.Label("" + lineWidth + "m");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Direction marker radius:");
            markerRadiusFactor = GUILayout.HorizontalSlider(markerRadiusFactor, 2, 50);
            GUILayout.Label("" + lineWidth * markerRadiusFactor + "m");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Number of direction markers:");
            numMarkers = GUILayout.HorizontalSlider(numMarkers, 0, 20);
            GUILayout.Label("" + (int)numMarkers);
            GUILayout.EndHorizontal();

            colliders = GUILayout.Toggle(colliders, "Activate Replay Colliders");

            GUILayout.BeginHorizontal();
            GUILayout.Label("Replay End Action:");
            selectedActionIndex = GUILayout.SelectionGrid(selectedActionIndex, new string[] { "Stop", "Loop", "OffRails", "Delete" }, 4);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Loop closure time:");
            loopTime = GUILayout.HorizontalSlider(loopTime, 0, 100);
            GUILayout.Label("" + (int)loopTime + "s");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("OK"))
            {
                string newUniqueName = Utilities.makeUniqueTrackName(newName, ref trackList, true);
                if (File.Exists(Utilities.TrackPath + track.TrackName + ".trk"))
                {
                    File.Move(Utilities.TrackPath + track.TrackName + ".trk", Utilities.TrackPath + newUniqueName + ".trk");
                }

                track.TrackName      = newUniqueName;
                track.Description    = newDescription;
                track.LineColor      = newColor;
                track.SamplingFactor = (int)sampling;
                track.LineWidth      = lineWidth;
                track.ConeRadiusToLineWidthFactor = markerRadiusFactor;
                track.NumDirectionMarkers         = (int)numMarkers;
                track.LoopClosureTime             = (int)loopTime;
                track.ReplayColliders             = colliders;
                track.EndAction = (Track.EndActions)selectedActionIndex;

                track.Modified = true;

                track.setupRenderer();
                mainWindow.updateColorTextures();
                SetVisible(false);
                Save(new ConfigNode(GetConfigNodeName()));//Does nothing...
            }

            if (GUILayout.Button("Cancel"))
            {
                SetVisible(false);
            }

            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }