public void LateUpdate() { //MonoBehaviour.print("Checking late update1: " + needsStatusUpdate + " :: " + needsRebuilt); if (externalUpdateData != null) { updateFromExternalData(externalUpdateData); } //MonoBehaviour.print("Checking late update2: " + needsStatusUpdate + " :: " + needsRebuilt); if (needsStatusUpdate) { updateFairingStatus(); } //MonoBehaviour.print("Checking late update3: " + needsStatusUpdate + " :: " + needsRebuilt); if (needsRebuilt) { rebuildFairing(); updatePersistentDataString(); ROTStockInterop.fireEditorUpdate(); needsGuiUpdate = true; needsRebuilt = false; } if (needsGuiUpdate) { updateGuiState(); needsGuiUpdate = false; } if (HighLogic.LoadedSceneIsEditor && fairingParts != null) { updateOpacity(); } }
/// <summary> /// Initialize the UI controls, including default values, and specifying delegates for their 'onClick' methods.<para/> /// All UI based interaction code will be defined/run through these delegates. /// </summary> private void initializeUI() { Action <ModuleROTank> modelChangedAction = (m) => { m.updateModulePositions(); m.updateDimensions(); m.updateAttachNodes(true); m.updateFairing(true); m.updateAvailableVariants(); m.updateDragCubes(); ROTModInterop.updateResourceVolume(m.part); }; //set up the core variant UI control string[] variantNames = ROTUtils.getNames(variantSets.Values, m => m.variantName); this.updateUIChooseOptionControl(nameof(currentVariant), variantNames, variantNames, true, currentVariant); Fields[nameof(currentVariant)].guiActiveEditor = variantSets.Count > 1; Fields[nameof(currentVariant)].uiControlEditor.onFieldChanged = (a, b) => { //TODO find variant set for the currently enabled core model //query the index from that variant set ModelDefinitionVariantSet prevMdvs = getVariantSet(coreModule.definition.name); //this is the index of the currently selected model within its variant set int previousIndex = prevMdvs.indexOf(coreModule.layoutOptions); //grab ref to the current/new variant set ModelDefinitionVariantSet mdvs = getVariantSet(currentVariant); //and a reference to the model from same index out of the new set ([] call does validation internally for IAOOBE) ModelDefinitionLayoutOptions newCoreDef = mdvs[previousIndex]; //now, call model-selected on the core model to update for the changes, including symmetry counterpart updating. this.actionWithSymmetry(m => { m.currentVariant = currentVariant; m.coreModule.modelSelected(newCoreDef.definition.name); modelChangedAction(m); }); }; Fields[nameof(currentDiameter)].uiControlEditor.onFieldChanged = (a, b) => { this.actionWithSymmetry(m => { if (m != this) { m.currentDiameter = this.currentDiameter; } modelChangedAction(m); m.prevDiameter = m.currentDiameter; }); ROTStockInterop.fireEditorUpdate(); }; Fields[nameof(currentVScale)].uiControlEditor.onFieldChanged = (a, b) => { this.actionWithSymmetry(m => { if (m != this) { m.currentVScale = this.currentVScale; } modelChangedAction(m); }); ROTStockInterop.fireEditorUpdate(); }; Fields[nameof(currentNose)].uiControlEditor.onFieldChanged = (a, b) => { noseModule.modelSelected(a, b); this.actionWithSymmetry(modelChangedAction); ROTStockInterop.fireEditorUpdate(); }; Fields[nameof(currentCore)].uiControlEditor.onFieldChanged = (a, b) => { coreModule.modelSelected(a, b); this.actionWithSymmetry(modelChangedAction); ROTStockInterop.fireEditorUpdate(); }; Fields[nameof(currentMount)].uiControlEditor.onFieldChanged = (a, b) => { mountModule.modelSelected(a, b); this.actionWithSymmetry(modelChangedAction); ROTStockInterop.fireEditorUpdate(); }; //------------------MODEL DIAMETER SWITCH UI INIT---------------------// if (maxDiameter == minDiameter) { Fields[nameof(currentDiameter)].guiActiveEditor = false; } else { this.updateUIFloatEditControl(nameof(currentDiameter), minDiameter, maxDiameter, diameterLargeStep, diameterSmallStep, diameterSlideStep, true, currentDiameter); } Fields[nameof(currentVScale)].guiActiveEditor = enableVScale; //------------------MODULE TEXTURE SWITCH UI INIT---------------------// Fields[nameof(currentNoseTexture)].uiControlEditor.onFieldChanged = noseModule.textureSetSelected; Fields[nameof(currentCoreTexture)].uiControlEditor.onFieldChanged = coreModule.textureSetSelected; Fields[nameof(currentMountTexture)].uiControlEditor.onFieldChanged = mountModule.textureSetSelected; if (HighLogic.LoadedSceneIsEditor) { GameEvents.onEditorShipModified.Add(new EventData <ShipConstruct> .OnEvent(onEditorVesselModified)); } }