} //private void OnErrorDisplay() /* * Display the info window */ private void OnInfoWindow(int windowID) { float margin = 2.5f; float quarterpos = Constants.guiInfoWindowW * 0.25f; float quarterwidth = quarterpos - margin - margin; float height = 20.0f; float inith = height; float posh = inith; //First Colomn GUI.Label(new Rect(margin, posh, quarterwidth, height), "Name"); posh += height; _welder.Name = GUI.TextField(new Rect(margin, posh, quarterwidth, height), _welder.Name, 100); posh += height; GUI.Label(new Rect(margin, posh, quarterwidth, height), "Title"); posh += height; _welder.Title = GUI.TextField(new Rect(margin, posh, quarterwidth, height), _welder.Title, 100); posh += height; GUI.Label(new Rect(margin, posh, quarterwidth, height), "Description"); posh += height; _welder.Description = GUI.TextArea(new Rect(margin, posh, quarterwidth, 6 * height), _welder.Description, 200); posh += 6 * height; //Second posh = inith; float posw = quarterpos + margin; GUI.Label(new Rect(posw, posh, quarterwidth, height), "Category"); posh += height; _catDropdown.SelectedItemIndex = (int)_welder.Category; int SelectedCat = _catDropdown.Show(new Rect(posw, posh, quarterwidth, height)); _welder.Category = (PartCategories)SelectedCat; if (!_catDropdown.IsOpen) { posh += height; GUI.Label(new Rect(posw, posh, quarterwidth, height), string.Format("Nb Parts: {0}", _welder.NbParts)); posh += height; GUI.Label(new Rect(posw, posh, quarterwidth, height), string.Format("Cost: {0}", _welder.Cost)); posh += height; GUI.Label(new Rect(posw, posh, quarterwidth, height), string.Format("Mass: {0} / {1}", _welder.Mass, _welder.WetMass)); posh += height; GUI.Label(new Rect(posw, posh, quarterwidth, height), string.Format("T: {0}", _welder.MaxTemp)); posh += height; GUI.Label(new Rect(posw, posh, quarterwidth, height), string.Format("F: {0}", _welder.BreakingForce)); posh += height; GUI.Label(new Rect(posw, posh, quarterwidth, height), string.Format("T: {0}", _welder.BreakingTorque)); posh += height; GUI.Label(new Rect(posw, posh, quarterwidth, height), string.Format("Drag: {0} / {1}", _welder.MinDrag, _welder.MaxDrag)); } //Module posh = inith; posw = (quarterpos * 2.0f) + margin; GUI.Label(new Rect(posw, posh, quarterwidth, height), "Modules"); posh += height; float scrollwidth = quarterwidth - 20.0f; _scrollMod = GUI.BeginScrollView(new Rect(posw, posh, quarterwidth, 10 * height), _scrollMod, new Rect(0, 0, scrollwidth, 200.0f), false, true); posh = 0.0f; string[] modulenames = _welder.Modules; GUIStyle style = new GUIStyle(); style.wordWrap = false; style.normal.textColor = Color.white; foreach (string modulename in modulenames) { GUI.Label(new Rect(0, posh, scrollwidth, height), modulename, style); posh += height; } GUI.EndScrollView(); //Res posh = inith; posw = (quarterpos * 3.0f) + margin; GUI.Label(new Rect(posw, posh, quarterwidth, height), "Resources"); posh += height; _scrollRes = GUI.BeginScrollView(new Rect(posw, posh, quarterwidth, 10 * height), _scrollRes, new Rect(0, 0, scrollwidth, 200.0f), false, true); posh = 0.0f; string[] resourcesdata = _welder.Resources; foreach (string resdata in resourcesdata) { GUI.Label(new Rect(0, posh, scrollwidth, height), resdata, style); posh += height; } GUI.EndScrollView(); bool nameOk = WelderNameNotUsed(); if (!nameOk) { style.normal.textColor = Color.red; GUI.Label(new Rect(margin, 13 * height, 2 * quarterpos, height), Constants.guiNameUsed, style); } else if (!string.IsNullOrEmpty(_welder.Name)) { if (GUI.Button(new Rect(2 * quarterpos, 13 * height, quarterwidth * 0.5f, height), Constants.guiSave)) { //check if the file exist string dirpath = string.Format("{0}{1}/{2}", Constants.weldPartPath, _welder.Category.ToString(), _welder.Name); string filepath = dirpath + Constants.weldPartFile; if (!File.Exists(filepath)) { if (!Directory.Exists(dirpath)) { Directory.CreateDirectory(dirpath); } //create the file StreamWriter partfile = File.CreateText(filepath); partfile.Close(); WriteCfg(filepath); _state = DisplayState.savedWindow; } else { _state = DisplayState.overwriteDial; } } } if (GUI.Button(new Rect(3 * quarterpos, 13 * height, quarterwidth * 0.5f, height), Constants.guiCancel)) { ClearEditor(); _state = DisplayState.none; } GUI.DragWindow(); } //private void OnWarningDisplay(int windowID)
/// <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 dirpath = FileManager.PATHNAME(Constants.weldPartPath, _welder.Category.ToString(), _welder.Name); if (!System.IO.File.Exists( _config.useNamedCfgFile ? FileManager.PATHNAME(filepath, _welder.Name, string.Format("{0}.cfg", _welder.Name)) : FileManager.PATHNAME(filepath, _welder.Name, Constants.weldPartDefaultFile) )) { if (!Directory.Exists(dirpath)) { Directory.CreateDirectory(dirpath); } //create the file StreamWriter partfile = System.IO.File.CreateText(_config.useNamedCfgFile ? FileManager.PATHNAME(filepath, _welder.Name, string.Format("{0}.cfg", _welder.Name)) : FileManager.PATHNAME(filepath, _welder.Name, Constants.weldPartDefaultFile) ); partfile.Close(); WriteCfg(filepath); 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(); }