Example #1
0
        private void DrawZ(float line)
        {
            var leftLabel = new GUIStyle();
            leftLabel.alignment = TextAnchor.UpperLeft;
            leftLabel.normal.textColor = Color.white;

            GUI.Label(new Rect(LeftIndent, ContentTop + line * entryHeight, 60, entryHeight), "Altitude",
                leftLabel);
            float textFieldWidth = 80;
            var fwdFieldRect = new Rect(LeftIndent + contentWidth - textFieldWidth,
                ContentTop + line * entryHeight, textFieldWidth, entryHeight);
            _guiZ = GUI.TextField(fwdFieldRect, _guiZ);
        }
        private void DrawNameEntry(float line)
        {
            var leftLabel = new GUIStyle();

            leftLabel.alignment        = TextAnchor.UpperLeft;
            leftLabel.normal.textColor = Color.white;

            GUI.Label(new Rect(LeftIndent, ContentTop + line * entryHeight, 60, entryHeight), "Name",
                      leftLabel);
            float textFieldWidth = 140;
            var   fwdFieldRect   = new Rect(LeftIndent + contentWidth - textFieldWidth,
                                            ContentTop + line * entryHeight, textFieldWidth, entryHeight);

            GPSname = GUI.TextField(fwdFieldRect, GPSname);
        }
Example #3
0
        /// <summary>
        /// Darws the Info window where the new saved partfile can be configured
        /// </summary>
        /// <param name="windowID"></param>
        private void HandleInfoWindow(int windowID)
        {
            float    margin       = 5f;
            float    height       = 20;
            float    posH         = height;
            float    columnWidth  = (Constants.guiInfoWindowW - (margin * 5)) / 4;
            float    columnHeight = (Constants.guiInfoWindowH - ((height + margin) * 2));
            float    scrollwidth  = columnWidth - 20.0f;
            GUIStyle style        = new GUIStyle();

            for (int i = 0; i < 4; i++)
            {
                _guiInfoWindowColoumns[i] = new Rect((margin * (i + 1)) + (columnWidth * i), height, columnWidth, columnHeight);
                posH = height;
                switch (i)
                {
                case 0:
                {
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Name:");
                    posH += height + margin;
                    //_welder.Name = _textFieldTitle.DrawAdvancedGUITextField(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), _welder.Name, 100, (int)this.state);
                    _welder.Name = GUI.TextField(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), _welder.Name, 100);
                    posH        += height + margin;
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Title:");
                    posH += height + margin;
                    //_welder.Title = _textFieldTitle.DrawAdvancedGUITextField(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), _welder.Title, 100, (int)this.state);
                    _welder.Title = GUI.TextField(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), _welder.Title, 100);
                    posH         += height + margin;
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Description:");
                    posH += height + margin;
                    //_welder.Description = _textAreaDescription.DrawAdvancedGUITextArea(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, 7 * height + 6 * margin), _welder.Description, 600, (int)this.state);
                    _welder.Description = GUI.TextArea(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, 8 * height + 7 * margin), _welder.Description, 600);
                    posH += 8 * height + 8 * margin;
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Symmetry:");
                    posH += height + margin;
                    _welder.stringStackSymmetry = GUI.TextField(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), _welder.stringStackSymmetry, 100);
                }
                break;

                case 1:
                {
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Category:");
                    posH += height + margin;
                    Rect _cetegoryBox = new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height);
                    posH += height + margin;
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "RequiredTech:");
                    posH += height + margin;
                    Rect _techBox = new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height);
                    posH += height + margin;
                    Rect _vesselTypeBox = new Rect();
                    if (_welder.vesselTypeList.Count > 0)
                    {
                        GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "VesselType:");
                        posH          += height + margin;
                        _vesselTypeBox = new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height);
                        posH          += height + margin;
                    }
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("Nb Parts: {0}", _welder.NbParts));
                    posH += height + margin;
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("Cost: {0:F2}", _welder.Cost));
                    posH += height + margin;
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("Mass: {0:F3} / {1:F3}", _welder.Mass, _welder.WetMass));
                    posH += height + margin;
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("Temp: {0:F1}", _welder.MaxTemp));
                    posH += height + margin;
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("B Force: {0:F3}", _welder.BreakingForce));
                    posH += height + margin;
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("B Torque: {0:F3}", _welder.BreakingTorque));
                    posH += height + margin;
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), string.Format("Drag: {0:F3} / {1:F3}", _welder.MinDrag, _welder.MaxDrag));

                    if (_techDropdown.IsOpen || _catDropdown.IsOpen)
                    {
                        GUI.Box(_vesselTypeBox, _welder.vesselType);
                    }
                    else
                    {
                        if (_welder.vesselTypeList.Count > 0)
                        {
                            _welder.vesselType = _welder.vesselTypeList[_vesselTypeDropdown.Show(_vesselTypeBox)];
                        }
                    }

                    if (_catDropdown.IsOpen)
                    {
                        GUI.Box(_techBox, _welder.techRequire);
                    }
                    else
                    {
                        _welder.techRequire = _welder.techList[_techDropdown.Show(_techBox)];
                    }
                    _catDropdown.SelectedItemIndex = (int)_welder.Category;
                    _welder.Category = (PartCategories)_catDropdown.Show(_cetegoryBox);
                }
                break;

                case 2:
                {
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Modules:");
                    posH += height + margin;
                    string[] modulenames = _welder.Modules;
                    _scrollMod             = GUI.BeginScrollView(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, (height * 14 + margin * 13)), _scrollMod, new Rect(0, 0, scrollwidth, modulenames.Length > 14 ? 345 + (modulenames.Length - 14) * (height + margin) : 345), false, true);
                    style.wordWrap         = false;
                    style.normal.textColor = Color.white;
                    posH = 0;
                    foreach (string modulename in modulenames)
                    {
                        GUI.Label(new Rect(2, posH, scrollwidth, height), modulename, style);
                        posH += height + margin;
                    }
                    GUI.EndScrollView();
                }
                break;

                case 3:
                {
                    GUI.Label(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, height), "Resources:");
                    posH += height + margin;
                    string[] resourcesdata = _welder.Resources;
                    _scrollRes             = GUI.BeginScrollView(new Rect(_guiInfoWindowColoumns[i].x, posH, columnWidth, (height * 14 + margin * 13)), _scrollRes, new Rect(0, 0, scrollwidth, resourcesdata.Length > 14 ? 345 + (resourcesdata.Length - 14) * (height + margin) : 345), false, true);
                    style.wordWrap         = false;
                    style.normal.textColor = Color.white;
                    posH = 0;
                    foreach (string resname in resourcesdata)
                    {
                        GUI.Label(new Rect(2, posH, scrollwidth, height), resname, style);
                        posH += height + margin;
                    }
                    GUI.EndScrollView();
                }
                break;

                default:
                {
                    GUI.Label(new Rect(0, posH, columnWidth, height), "Broken GUI Column:");
                }
                break;
                }
            }

            if (!WelderNameNotUsed())
            {
                style.normal.textColor = Color.red;
                GUI.Label(new Rect(margin, columnHeight + margin, columnWidth * 1.5f, height), Constants.guiNameUsed, style);
            }
            if (!isSymmetryNumber())
            {
                style.normal.textColor = Color.red;
                GUI.Label(new Rect(margin, height + columnHeight + margin, columnWidth * 1.5f, height), Constants.guiSymmetryNotNumbered, style);
            }


            if (!string.IsNullOrEmpty(_welder.Name))
            {
                if (GUI.Button(new Rect(_guiInfoWindowColoumns[1].x + columnWidth * 0.5f, height + columnHeight + margin, columnWidth * 0.5f, height), Constants.guiSave))
                {
                    //check if the file exist
                    string welding_pathname = this.welding_pathname;                     // Cache the built pathname
                    if (!File <UbioZurWeldingLtd> .Local.Exists(welding_pathname))
                    {
                        //create the file (why? LisiasT)
                        L.StreamWriter partfile = File <UbioZurWeldingLtd> .Local.CreateText(welding_pathname);

                        partfile.Close();

                        WriteCfg(welding_pathname);
                        this.state = DisplayState.savedWindow;
                    }
                    else
                    {
                        this.state = DisplayState.overwriteDial;
                    }
                }
            }
            else
            {
                GUI.Box(new Rect(_guiInfoWindowColoumns[1].x + columnWidth * 0.5f, height + columnHeight + margin, columnWidth * 0.5f, height), Constants.guiSave);
            }
            if (GUI.Button(new Rect(_guiInfoWindowColoumns[2].x, height + columnHeight + margin, columnWidth * 0.5f, height), Constants.guiCancel))
            {
                this.state = DisplayState.none;
                ClearEditor();
            }
            GUI.DragWindow();
        }
        private static void OnWindow(int winID)
        {
            rwyListLength = Rwy.customRunways.Count * 40;

            rwyListVector = GUI.BeginScrollView(new Rect(10, 20, 150, 270), rwyListVector, new Rect(0, 0, 135, rwyListLength + 35));

            if (GUI.Button(new Rect(2, 0, 130, 30), "Create Runway"))
            {
                tempRwy  = new NavUtilLib.Runway();
                isNewRwy = true;
            }

            for (int i = 0; i < Rwy.customRunways.Count; i++)
            {
                if (i == Rwy.cRwyIdx && !isNewRwy)
                {
                    if (GUI.Button(new Rect(2, (i * 40) + 40, 130, 30), "* " + Rwy.customRunways[i].ident))
                    {
                        Rwy.cRwyIdx = i;
                        tempRwy     = Rwy.customRunways[i];
                        isNewRwy    = false;
                    }
                }
                else
                {
                    if (GUI.Button(new Rect(2, (i * 40) + 40, 130, 30), Rwy.customRunways[i].ident))
                    {
                        Rwy.cRwyIdx = i;
                        tempRwy     = Rwy.customRunways[i];
                        isNewRwy    = false;
                    }
                }
            }
            GUI.EndScrollView();
            //begin runway info area

            GUI.Label(new Rect(170, 20, 200, 20), "Runway Ident");

            GUI.Label(new Rect(170, 70, 150, 20), "Runway Heading");

            GUI.Label(new Rect(170, 120, 150, 20), "Runway Elevation (m)");



            GUI.Label(new Rect(170, 185, 240, 20), "Marker distance from current point (m)");

            GUI.Label(new Rect(190, 200, 60, 20), " Inner");
            GUI.Label(new Rect(260, 200, 60, 20), " Middle");
            GUI.Label(new Rect(330, 200, 60, 20), " Outer");


            //isNewRwy


            //only difference is textbox vs label
            if (isNewRwy)
            {
                GUI.Label(new Rect(340, 70, 85, 20), "Auto Hdg?");
                useAutoHdg = GUI.Toggle(new Rect(350, 90, 20, 20), useAutoHdg, "");

                GUI.Label(new Rect(340, 120, 85, 20), "Auto Elevation?");
                useAutoElevation = GUI.Toggle(new Rect(350, 140, 20, 20), useAutoElevation, "");


                tempRwy.ident = GUI.TextField(new Rect(170, 40, 200, 20), tempRwy.ident);

                GUI.Label(new Rect(340, 70, 85, 20), "Auto Hdg?");
                useAutoHdg = GUI.Toggle(new Rect(350, 90, 20, 20), useAutoHdg, "");
                if (useAutoHdg)
                {
                    tempRwy.hdg = (float)Math.Round(FlightGlobals.ship_heading, 2);

                    GUI.Label(new Rect(170, 90, 150, 20), tempRwy.hdg.ToString() + "°");
                }
                else
                {
                    tempRwy.hdg = Convert.ToSingle(GUI.TextField(new Rect(170, 90, 150, 20), Convert.ToString(tempRwy.hdg)));
                }

                GUI.Label(new Rect(340, 120, 85, 20), "Auto Alt?");
                useAutoElevation = GUI.Toggle(new Rect(350, 140, 20, 20), useAutoElevation, "");
                if (useAutoElevation)
                {
                    tempRwy.altMSL = (float)Math.Round(FlightGlobals.ActiveVessel.altitude, 1);

                    GUI.Label(new Rect(170, 140, 150, 20), Convert.ToString(tempRwy.altMSL) + "m");
                }
                else
                {
                    tempRwy.altMSL = Convert.ToSingle(GUI.TextField(new Rect(170, 140, 150, 20), Convert.ToString(tempRwy.altMSL)));
                }



                GUI.Label(new Rect(170, 165, 120, 20), "Use Marker Becons?");
                makeMarkers = GUI.Toggle(new Rect(350, 168, 20, 20), makeMarkers, "");


                if (makeMarkers)
                {
                    tempRwy.innerMarkerDist = Convert.ToSingle(GUI.TextField(new Rect(190, 220, 60, 20), Convert.ToString(tempRwy.innerMarkerDist)));

                    tempRwy.middleMarkerDist = Convert.ToSingle(GUI.TextField(new Rect(260, 220, 60, 20), Convert.ToString(tempRwy.middleMarkerDist)));
                    tempRwy.outerMarkerDist  = Convert.ToSingle(GUI.TextField(new Rect(330, 220, 60, 20), Convert.ToString(tempRwy.outerMarkerDist)));

                    if (tempRwy.innerMarkerDist < -500)
                    {
                        tempRwy.innerMarkerDist = -500;
                    }


                    if (tempRwy.middleMarkerDist < -500)
                    {
                        tempRwy.middleMarkerDist = -500;
                    }


                    if (tempRwy.outerMarkerDist < -500)
                    {
                        tempRwy.outerMarkerDist = -500;
                    }
                }
            }
            else
            {
                GUI.Label(new Rect(170, 40, 200, 20), tempRwy.ident);

                GUI.Label(new Rect(170, 90, 150, 20), tempRwy.hdg.ToString() + "°");
                GUI.Label(new Rect(170, 140, 150, 20), Convert.ToString(tempRwy.altMSL) + "m");

                if (tempRwy.innerMarkerDist > -500)
                {
                    GUI.Label(new Rect(190, 220, 60, 20), tempRwy.innerMarkerDist.ToString() + "m");
                }
                else
                {
                    GUI.Label(new Rect(190, 220, 60, 20), "  N/A");
                }

                if (tempRwy.middleMarkerDist > -500)
                {
                    GUI.Label(new Rect(260, 220, 60, 20), tempRwy.middleMarkerDist.ToString() + "m");
                }
                else
                {
                    GUI.Label(new Rect(260, 220, 60, 20), "  N/A");
                }

                if (tempRwy.outerMarkerDist > -500)
                {
                    GUI.Label(new Rect(330, 220, 60, 20), tempRwy.outerMarkerDist.ToString() + "m");
                }
                else
                {
                    GUI.Label(new Rect(330, 220, 60, 20), "  N/A");
                }
            }

            if (isNewRwy)
            {
                if (GUI.Button(new Rect(170, 250, 200, 20), "Create Runway"))
                {
                    //create the runway and add to database
                    tempRwy.body        = FlightGlobals.currentMainBody.bodyName;
                    tempRwy.gsLatitude  = (float)FlightGlobals.ship_latitude;
                    tempRwy.gsLongitude = (float)FlightGlobals.ship_longitude;

                    Vector2d loc = NavUtilLib.Utils.CalcCoordinatesFromInitialPointBearingDistance(new Vector2d(tempRwy.gsLatitude, tempRwy.gsLongitude), tempRwy.hdg, 1000, FlightGlobals.currentMainBody.Radius);

                    tempRwy.locLatitude  = (float)loc.x;
                    tempRwy.locLongitude = (float)loc.y;

                    if (!makeMarkers)
                    {
                        tempRwy.innerMarkerDist  = -1000;
                        tempRwy.middleMarkerDist = -1000;
                        tempRwy.outerMarkerDist  = -1000;
                    }


                    Rwy.customRunways.Add(tempRwy);
                    Rwy.currentBodyRunways.Add(tempRwy);

                    Rwy.cRwyIdx = Rwy.customRunways.FindIndex(r => r.ident == tempRwy.ident);

                    WriteCustomRwys();

                    isNewRwy = false;
                }
            }
            else
            {
                //show delete button
                if (GUI.Button(new Rect(170, 250, 200, 20), "Delete This Runway"))
                {
                    Rwy.allRunways.Remove(Rwy.customRunways[Rwy.cRwyIdx]);
                    if (Rwy.currentBodyRunways.Contains(Rwy.customRunways[Rwy.cRwyIdx]))
                    {
                        Rwy.currentBodyRunways.Remove(Rwy.customRunways[Rwy.cRwyIdx]);
                    }
                    Rwy.customRunways.Remove(Rwy.customRunways[Rwy.cRwyIdx]);

                    WriteCustomRwys();

                    Rwy.cRwyIdx = 0;

                    isNewRwy = true;
                    tempRwy  = new NavUtilLib.Runway();
                }
            }
            GUI.DragWindow();
        }