Exemple #1
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();
        }
Exemple #2
0
        private void DrawIndicatorV(Rect rect, float value, float minV, float maxV)
        {
            GUI.BeginGroup(rect);

            bool clamped = false;

            if (value < minV)
            {
                value   = minV;
                clamped = true;
            }
            if (value > maxV)
            {
                value   = maxV;
                clamped = true;
            }

            float sx = rect.width;
            float sy = rect.height;

            GUI.Box(new Rect(0, 0, sx, sy), "");

            Color color = XKCDColors.NeonGreen;

            float spacing  = (float)Math.Floor(sy * 0.11f + 0.5f);
            float middle   = (float)Math.Floor(sy * 0.5f + 0.5f);
            Rect  lineRect = new Rect(3, 0, sx - 6, 1);

            for (float y = middle + spacing; y < sy; y += spacing)
            {
                lineRect.y = y;
                Drawing.DrawRect(lineRect, color);
            }

            for (float y = middle - spacing; y > 0; y -= spacing)
            {
                lineRect.y = y;
                Drawing.DrawRect(lineRect, color);
            }

            lineRect.y      = middle - 1;
            lineRect.x      = 1;
            lineRect.width  = sx - 3;
            lineRect.height = 3;
            color           = XKCDColors.NeonBlue;

            Drawing.DrawRect(lineRect, color);

            // our box runs for 0 to sy-1
            // we do not want diamond to get clipped
            // so lowest y should be 0 and highest should be (sy-1)-9
            // center should draw at middle - 4
            float frac  = -0.5f + (value - minV) / (maxV - minV);            // range -0.5 to 0.5
            float range = (sy - 1) - 9;
            float yy    = middle + range * frac - 4;

            Color dcolor = clamped ? XKCDColors.NeonRed : XKCDColors.NeonBlue;

            Drawing.DrawDiamond(new Rect(3, yy, 15, 9), dcolor);

            GUI.EndGroup();
        }