private void loadConfigData() { recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]); ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData); ConfigNode[] textureNodes = node.GetNodes("TEXTURESET"); string[] textureSetNames = TextureSet.getTextureSetNames(textureNodes); string[] titles = TextureSet.getTextureSetTitles(textureNodes); TextureSet currentTextureSetData = KSPShaderLoader.getTextureSet(currentTextureSet); if (currentTextureSetData == null) { currentTextureSet = textureSetNames[0]; currentTextureSetData = KSPShaderLoader.getTextureSet(currentTextureSet); initializedColors = false; } if (!initializedColors) { initializedColors = true; recolorHandler.setColorData(currentTextureSetData.maskColors); } fairingMaterial = currentTextureSetData.textureData[0].createMaterial("SSTUFairingMaterial"); Fields["currentTextureSet"].guiActiveEditor = textureNodes.Length > 1; this.updateUIChooseOptionControl("currentTextureSet", textureSetNames, titles, true, currentTextureSet); }
private void initialize() { if (initialized) { return; } initialized = true; recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]); mpf = part.GetComponent <ModuleProceduralFairing>(); ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData); ConfigNode[] textureNodes = node.GetNodes("TEXTURESET"); string[] names = TextureSet.getTextureSetNames(textureNodes); string[] titles = TextureSet.getTextureSetTitles(textureNodes); TextureSet t = KSPShaderLoader.getTextureSet(currentTextureSet); if (t == null) { currentTextureSet = names[0]; t = KSPShaderLoader.getTextureSet(currentTextureSet); initializedColors = false; } if (!initializedColors) { initializedColors = true; recolorHandler.setColorData(t.maskColors); } this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet); Fields[nameof(currentTextureSet)].guiActiveEditor = names.Length > 1; }
private void initialize() { if (initialized) { return; } initialized = true; recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]); ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData); ConfigNode[] textureNodes = node.GetNodes("TEXTURESET"); string[] names = TextureSet.getTextureSetNames(textureNodes); string[] titles = TextureSet.getTextureSetTitles(textureNodes); TextureSet currentTextureSetData = KSPShaderLoader.getTextureSet(currentTextureSet); if (currentTextureSetData == null) { currentTextureSet = names[0]; currentTextureSetData = KSPShaderLoader.getTextureSet(currentTextureSet); initializedColors = false; } if (!initializedColors) { initializedColors = true; recolorHandler.setColorData(currentTextureSetData.maskColors); } this.updateUIChooseOptionControl("currentTextureSet", names, titles, true, currentTextureSet); Fields[nameof(currentTextureSet)].guiActiveEditor = textureNodes.Length > 1; fairingMaterial = currentTextureSetData.textureData[0].createMaterial("SSTUFairingMaterial"); fuelType = VolumeContainerLoader.getPreset(fuelPreset); Transform modelBase = part.transform.FindRecursive("model"); setupEngineModels(modelBase, node); minHeight = engineModels.model.modelDefinition.height * getEngineScale(); Transform root = modelBase.FindOrCreate(baseTransformName); Transform collider = modelBase.FindOrCreate("InterstageFairingBaseCollider"); fairingBase = new InterstageDecouplerModel(root.gameObject, collider.gameObject, 0.25f, cylinderSides, numberOfPanels, wallThickness); updateEditorFields(); buildFairing(); updateTextureSet(false); updateNodePositions(false); if (!initializedResources && (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)) { initializedResources = true; updateResources(); } updatePartMass(); updateEngineThrust(); }
private void initialize() { if (initialized) { return; } initialized = true; recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]); ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData); ConfigNode[] textureNodes = node.GetNodes("TEXTURESET"); string[] names = TextureSet.getTextureSetNames(textureNodes); string[] titles = TextureSet.getTextureSetTitles(textureNodes); TextureSet t = KSPShaderLoader.getTextureSet(currentTextureSet); if (t == null) { currentTextureSet = names[0]; t = KSPShaderLoader.getTextureSet(currentTextureSet); initializedColors = false; } if (!initializedColors) { initializedColors = true; recolorHandler.setColorData(t.maskColors); } this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet); fairingMaterial = t.textureData[0].createMaterial("SSTUFairingMaterial"); Transform tr = part.transform.FindRecursive("model").FindOrCreate("PetalAdapterRoot"); fairingBase = new InterstageFairingContainer(tr.gameObject, cylinderSides, numberOfPanels, wallThickness); UVMap uvs = UVMap.GetUVMapGlobal(uvMap); fairingBase.outsideUV = uvs.getArea("outside"); fairingBase.insideUV = uvs.getArea("inside"); fairingBase.edgesUV = uvs.getArea("edges"); validateStraightHeight(); rebuildFairing(false);//will create fairing using default / previously saved fairing configuration setPanelRotations(currentRotation); if (panelsJettisoned) { fairingBase.destroyFairing(); } updateGuiState(); }
//creates/recreates FairingData instances from data from config node and any persistent node (if applicable) private void loadFairingData(ConfigNode node) { recolorHandler = new RecoloringHandler(Fields[nameof(customColorData)]); ConfigNode[] fairingNodes = node.GetNodes("FAIRING"); fairingParts = new SSTUNodeFairingData[fairingNodes.Length]; Transform modelBase = part.transform.FindRecursive("model"); Transform parent; SSTUNodeFairing[] cs = part.GetComponents <SSTUNodeFairing>(); int l = Array.IndexOf(cs, this); int moduleIndex = l; for (int i = 0; i < fairingNodes.Length; i++) { parent = modelBase.FindOrCreate(fairingName + "-" + moduleIndex + "-" + i); fairingParts[i] = new SSTUNodeFairingData(); fairingParts[i].load(fairingNodes[i], parent.gameObject); if (fairingParts[i].canAdjustTop) { enableTopDiameterControls = true; if (guiTopDiameter < 0) { guiTopDiameter = fairingParts[i].topRadius * 2f; } else { fairingParts[i].topRadius = guiTopDiameter * 0.5f; } } if (fairingParts[i].canAdjustBottom) { enableBottomDiameterControls = true; if (guiBottomDiameter < 0) { guiBottomDiameter = fairingParts[i].bottomRadius * 2f; } else { fairingParts[i].bottomRadius = guiBottomDiameter * 0.5f; } } } //reload fairing data from persistence; //it -should- already match the guiTopDiameter/guiBottomDiameter (or else was already corrupted/invalid when saved out). if (!String.IsNullOrEmpty(persistentDataString)) { String[] datas = SSTUUtils.parseCSV(persistentDataString, ":"); int length = datas.Length; for (int i = 0; i < length; i++) { fairingParts[i].loadPersistence(datas[i]); } } ConfigNode[] textureNodes = node.GetNodes("TEXTURESET"); string[] names = TextureSet.getTextureSetNames(textureNodes); string[] titles = TextureSet.getTextureSetTitles(textureNodes); TextureSet t = KSPShaderLoader.getTextureSet(currentTextureSet); if (t == null) { currentTextureSet = names[0]; t = KSPShaderLoader.getTextureSet(currentTextureSet); initializedColors = false; } if (!initializedColors) { initializedColors = true; recolorHandler.setColorData(t.maskColors); } this.updateUIChooseOptionControl(nameof(currentTextureSet), names, titles, true, currentTextureSet); fairingMaterial = t.textureData[0].createMaterial("SSTUFairingMaterial"); }