protected virtual void setMainTankModuleFromEditor(String newMainTank, bool updateSymmetry) { SingleModelData newModule = Array.Find(mainTankModules, m => m.name == newMainTank); currentMainTankModule.destroyCurrentModel(); currentMainTankModule = newModule; currentMainTankModule.setupModel(part, getTankRootTransform(false), ModelOrientation.CENTRAL); currentTankType = newModule.name; if (!currentMainTankModule.isValidTextureSet(currentTankTexture)) { currentTankTexture = currentMainTankModule.getDefaultTextureSet(); } currentMainTankModule.enableTextureSet(currentTankTexture); currentMainTankModule.updateTextureUIControl(this, "currentTankTexture", currentTankTexture); updateUIScaleControls(); updateEditorStats(true); if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent <SSTUModularFuelTank>().setMainTankModuleFromEditor(newMainTank, false); } } SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); }
public override void OnStart(StartState state) { base.OnStart(state); initialize(); string[] groupNames = TankSet.getSetNames(tankSets); this.updateUIChooseOptionControl("currentTankSet", groupNames, groupNames, true, currentTankSet); string[] names = currentTankSetModule.getModelNames(); string[] descs = currentTankSetModule.getTankDescriptions(); this.updateUIChooseOptionControl("currentTankType", names, descs, true, currentTankType); if (maxTankDiameter == minTankDiameter) { Fields["currentTankDiameter"].guiActiveEditor = false; } else { this.updateUIFloatEditControl("currentTankDiameter", minTankDiameter, maxTankDiameter, tankDiameterIncrement * 2, tankDiameterIncrement, tankDiameterIncrement * 0.05f, true, currentTankDiameter); } updateAvailableVariants(); updateUIScaleControls(); currentNoseModule.updateTextureUIControl(this, "currentNoseTexture", currentNoseTexture); currentMainTankModule.updateTextureUIControl(this, "currentTankTexture", currentTankTexture); currentMountModule.updateTextureUIControl(this, "currentMountTexture", currentMountTexture); bool useModelSelectionGUI = HighLogic.CurrentGame.Parameters.CustomParams <SSTUGameSettings>().useModelSelectGui; Events["selectNoseEvent"].guiActiveEditor = useModelSelectionGUI; Events["selectMountEvent"].guiActiveEditor = useModelSelectionGUI; Fields["currentTankDiameter"].uiControlEditor.onFieldChanged = tankDiameterUpdated; Fields["currentTankVerticalScale"].uiControlEditor.onFieldChanged = tankHeightScaleUpdated; Fields["currentTankSet"].uiControlEditor.onFieldChanged = tankSetUpdated; Fields["currentTankType"].uiControlEditor.onFieldChanged = tankTypeUpdated; Fields["currentNoseType"].uiControlEditor.onFieldChanged = noseTypeUpdated; Fields["currentMountType"].uiControlEditor.onFieldChanged = mountTypeUpdated; Fields["currentNoseTexture"].uiControlEditor.onFieldChanged = onNoseTextureUpdated; Fields["currentTankTexture"].uiControlEditor.onFieldChanged = onTankTextureUpdated; Fields["currentMountTexture"].uiControlEditor.onFieldChanged = onMountTextureUpdated; Fields["currentTankSet"].guiActiveEditor = tankSets.Length > 1; Fields["currentTankType"].guiActiveEditor = currentTankSetModule.Length > 1; Fields["currentNoseType"].guiActiveEditor = !useModelSelectionGUI && noseModules.Length > 1; Fields["currentMountType"].guiActiveEditor = !useModelSelectionGUI && mountModules.Length > 1; SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); if (HighLogic.LoadedSceneIsEditor) { GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorVesselModified)); } }
private void setBottomEditor(string newBottom, bool updateSymmetry) { currentBottom = newBottom; SingleModelData prev = bottomModule; bottomModule.destroyCurrentModel(); bottomModule = SingleModelData.findModel(bottomModules, currentBottom); bottomModule.setupModel(getBottomRoot(false), ModelOrientation.BOTTOM); onModelChanged(prev, bottomModule); if (!bottomModule.isValidTextureSet(currentBottomTexture)) { currentBottomTexture = bottomModule.getDefaultTextureSet(); } bottomModule.enableTextureSet(currentBottomTexture); bottomModule.updateTextureUIControl(this, "currentBottomTexture", currentBottomTexture); if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent <SSTUModularStationCore>().setBottomEditor(newBottom, false); } } }
private void setCoreEditor(string newCore, bool updateSymmetry) { currentCore = newCore; SingleModelData prev = coreModule; coreModule.destroyCurrentModel(); coreModule = SingleModelData.findModel(coreModules, currentCore); coreModule.setupModel(getCoreRoot(false), ModelOrientation.CENTRAL); onModelChanged(prev, coreModule); if (!coreModule.isValidTextureSet(currentCoreTexture)) { currentCoreTexture = coreModule.getDefaultTextureSet(); } coreModule.enableTextureSet(currentCoreTexture); coreModule.updateTextureUIControl(this, "currentCoreTexture", currentCoreTexture); if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent <SSTUModularStationCore>().setCoreEditor(newCore, false); } } }
private void setTopEditor(string newTop, bool updateSymmetry) { currentTop = newTop; SingleModelData prev = topModule; topModule.destroyCurrentModel(); topModule = SingleModelData.findModel(topModules, currentTop); topModule.setupModel(getTopRoot(false), ModelOrientation.TOP); onModelChanged(prev, topModule); if (!topModule.isValidTextureSet(currentTopTexture)) { currentTopTexture = topModule.getDefaultTextureSet(); } topModule.enableTextureSet(currentTopTexture); topModule.updateTextureUIControl(this, "currentTopTexture", currentTopTexture); if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent <SSTUModularStationCore>().setTopEditor(newTop, false); } } }
/// <summary> /// Restores ModelData instances from config node data, and populates the 'currentModule' instances with the currently enabled modules. /// </summary> private void loadConfigData() { ConfigNode node = SSTUStockInterop.getPartModuleConfig(part, this); ConfigNode[] tankNodes = node.GetNodes("TANK"); ConfigNode[] mountNodes = node.GetNodes("CAP"); ConfigNode[] fuelNodes = node.GetNodes("FUELTYPE"); ConfigNode[] limitNodes = node.GetNodes("TECHLIMIT"); mainTankModules = SingleModelData.parseModels(tankNodes); int len = mountNodes.Length; ConfigNode mountNode; List <MountModelData> noses = new List <MountModelData>(); List <MountModelData> mounts = new List <MountModelData>(); for (int i = 0; i < len; i++) { mountNode = mountNodes[i]; if (mountNode.GetBoolValue("useForNose", true)) { mountNode.SetValue("nose", "true"); noses.Add(new MountModelData(mountNode)); } if (mountNode.GetBoolValue("useForMount", true)) { mountNode.SetValue("nose", "false"); mounts.Add(new MountModelData(mountNode)); } } mountModules = mounts.ToArray(); noseModules = noses.ToArray(); topNodeNames = SSTUUtils.parseCSV(topManagedNodeNames); bottomNodeNames = SSTUUtils.parseCSV(bottomManagedNodeNames); currentMainTankModule = Array.Find(mainTankModules, m => m.name == currentTankType); if (currentMainTankModule == null) { MonoBehaviour.print("ERROR: Could not locate tank type for: " + currentTankType + ". reverting to first available tank type."); currentMainTankModule = mainTankModules[0]; currentTankType = currentMainTankModule.name; } currentNoseModule = Array.Find(noseModules, m => m.name == currentNoseType); if (currentNoseModule == null) { MonoBehaviour.print("ERROR: Could not locate nose type for: " + currentNoseType + ". reverting to first available nose type."); currentNoseModule = noseModules[0]; currentNoseType = currentNoseModule.name; } currentMountModule = Array.Find(mountModules, m => m.name == currentMountType); if (currentMountModule == null) { MonoBehaviour.print("ERROR: Could not locate mount type for: " + currentMountType + ". reverting to first available mount type."); currentMountModule = mountModules[0]; currentMountType = currentMountModule.name; } if (!currentMainTankModule.isValidTextureSet(currentTankTexture)) { currentTankTexture = currentMainTankModule.getDefaultTextureSet(); } if (!currentNoseModule.isValidTextureSet(currentNoseTexture)) { currentNoseTexture = currentNoseModule.getDefaultTextureSet(); } if (!currentMountModule.isValidTextureSet(currentMountTexture)) { currentMountTexture = currentMountModule.getDefaultTextureSet(); } currentNoseModule.updateTextureUIControl(this, "currentNoseTexture", currentNoseTexture); currentMainTankModule.updateTextureUIControl(this, "currentTankTexture", currentTankTexture); currentMountModule.updateTextureUIControl(this, "currentMountTexture", currentMountTexture); }
private void setTopEditor(string newTop, bool updateSymmetry) { currentTop = newTop; SingleModelData prev = topModule; topModule.destroyCurrentModel(); topModule = SingleModelData.findModel(topModules, currentTop); topModule.setupModel(getTopRoot(false), ModelOrientation.TOP); onModelChanged(prev, topModule); if (!topModule.isValidTextureSet(currentTopTexture)) { currentTopTexture = topModule.getDefaultTextureSet(); } topModule.enableTextureSet(currentTopTexture); topModule.updateTextureUIControl(this, "currentTopTexture", currentTopTexture); if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent<SSTUModularStationCore>().setTopEditor(newTop, false); } } }
private void setCoreEditor(string newCore, bool updateSymmetry) { currentCore = newCore; SingleModelData prev = coreModule; coreModule.destroyCurrentModel(); coreModule = SingleModelData.findModel(coreModules, currentCore); coreModule.setupModel(getCoreRoot(false), ModelOrientation.CENTRAL); onModelChanged(prev, coreModule); if (!coreModule.isValidTextureSet(currentCoreTexture)) { currentCoreTexture = coreModule.getDefaultTextureSet(); } coreModule.enableTextureSet(currentCoreTexture); coreModule.updateTextureUIControl(this, "currentCoreTexture", currentCoreTexture); if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent<SSTUModularStationCore>().setCoreEditor(newCore, false); } } }
private void setBottomEditor(string newBottom, bool updateSymmetry) { currentBottom = newBottom; SingleModelData prev = bottomModule; bottomModule.destroyCurrentModel(); bottomModule = SingleModelData.findModel(bottomModules, currentBottom); bottomModule.setupModel(getBottomRoot(false), ModelOrientation.BOTTOM); onModelChanged(prev, bottomModule); if (!bottomModule.isValidTextureSet(currentBottomTexture)) { currentBottomTexture = bottomModule.getDefaultTextureSet(); } bottomModule.enableTextureSet(currentBottomTexture); bottomModule.updateTextureUIControl(this, "currentBottomTexture", currentBottomTexture); if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent<SSTUModularStationCore>().setBottomEditor(newBottom, false); } } }
protected virtual void setNoseModuleFromEditor(String newNoseType, bool updateSymmetry) { currentNoseType = newNoseType; SingleModelData newModule = Array.Find(noseModules, m => m.name == newNoseType); currentNoseModule.destroyCurrentModel(); currentNoseModule = newModule; newModule.setupModel(getNoseRootTransform(false), ModelOrientation.TOP); currentNoseType = newModule.name; if (!currentNoseModule.isValidTextureSet(currentNoseTexture)) { currentNoseTexture = currentNoseModule.getDefaultTextureSet(); } currentNoseModule.enableTextureSet(currentNoseTexture); currentNoseModule.updateTextureUIControl(this, "currentNoseTexture", currentNoseTexture); updateEditorStats(true); if (updateSymmetry) { foreach (Part p in part.symmetryCounterparts) { p.GetComponent<SSTUModularFuelTank>().setNoseModuleFromEditor(newNoseType, false); } } SSTUStockInterop.fireEditorUpdate(); SSTUModInterop.onPartGeometryUpdate(part, true); }