private void initializeGUI()
        {
            bool useModelSelectionGUI = HighLogic.CurrentGame.Parameters.CustomParams <SSTUGameSettings>().useModelSelectGui;

            string[] names = SingleModelData.getAvailableModelNames(topDockModules, this);
            this.updateUIChooseOptionControl("currentTopDock", names, names, true, currentTopDock);
            Fields["currentTopDock"].uiControlEditor.onFieldChanged = onTopDockChanged;
            Fields["currentTopDock"].guiActiveEditor = names.Length > 1;

            names = SingleModelData.getValidSelectionNames(part, topModules, topNodeNames);
            this.updateUIChooseOptionControl("currentTop", names, names, true, currentTop);
            Fields["currentTop"].uiControlEditor.onFieldChanged = onTopChanged;
            Fields["currentTop"].guiActiveEditor     = !useModelSelectionGUI && names.Length > 1;
            Events["selectTopEvent"].guiActiveEditor = useModelSelectionGUI && names.Length > 1;

            names = SingleModelData.getModelNames(coreModules);
            this.updateUIChooseOptionControl("currentCore", names, names, true, currentCore);
            Fields["currentCore"].uiControlEditor.onFieldChanged = onCoreChanged;
            Fields["currentCore"].guiActiveEditor = coreModules.Length > 1;

            names = SingleModelData.getValidSelectionNames(part, bottomModules, bottomNodeNames);
            this.updateUIChooseOptionControl("currentBottom", names, names, true, currentBottom);
            Fields["currentBottom"].uiControlEditor.onFieldChanged = onBottomChanged;
            Fields["currentBottom"].guiActiveEditor     = !useModelSelectionGUI && names.Length > 1;
            Events["selectBottomEvent"].guiActiveEditor = useModelSelectionGUI && names.Length > 1;

            names = SingleModelData.getAvailableModelNames(bottomDockModules, this);
            this.updateUIChooseOptionControl("currentBottomDock", names, names, true, currentBottomDock);
            Fields["currentBottomDock"].uiControlEditor.onFieldChanged = onBottomDockChanged;
            Fields["currentBottomDock"].guiActiveEditor = names.Length > 1;

            names = SolarData.getNames(solarModules, part, this);
            this.updateUIChooseOptionControl("currentSolar", names, names, true, currentSolar);
            Fields["currentSolar"].uiControlEditor.onFieldChanged = onSolarChanged;
            Fields["currentSolar"].guiActiveEditor = names.Length > 1;

            names = topModule.modelDefinition.getTextureSetNames();
            this.updateUIChooseOptionControl("currentTopTexture", names, names, true, currentTopTexture);
            Fields["currentTopTexture"].uiControlEditor.onFieldChanged = onTopTextureChanged;
            Fields["currentTopTexture"].guiActiveEditor = names.Length > 1;

            names = coreModule.modelDefinition.getTextureSetNames();
            this.updateUIChooseOptionControl("currentCoreTexture", names, names, true, currentCoreTexture);
            Fields["currentCoreTexture"].uiControlEditor.onFieldChanged = onCoreTextureChanged;
            Fields["currentCoreTexture"].guiActiveEditor = names.Length > 1;

            names = bottomModule.modelDefinition.getTextureSetNames();
            this.updateUIChooseOptionControl("currentBottomTexture", names, names, true, currentBottomTexture);
            Fields["currentBottomTexture"].uiControlEditor.onFieldChanged = onBottomTextureChanged;
            Fields["currentBottomTexture"].guiActiveEditor = names.Length > 1;
        }
 public static string[] getNames(SolarData[] data, Part part, PartModule module)
 {
     List<string> names = new List<string>();
     int len = data.Length;
     for (int i = 0; i < len; i++)
     {
         names.Add(data[i].name);
         //if (string.IsNullOrEmpty(data[i].upgradeName) || module.upgradesApplied.Contains(data[i].upgradeName))
         //{
         //    names.Add(data[i].name);
         //}
     }
     return names.ToArray();
 }
 private void setSolarEditor(string newSolar, bool updateSymmetry)
 {
     currentSolar = newSolar;
     solarModule.disable();
     solarModule = Array.Find(solarModules, m => m.name == currentSolar);//TODO cleanup
     solarModule.enable(getSolarRoot(false), coreModule.currentVerticalPosition);
     updateSolarModules();
     updateCost();
     updateMass();
     updateDragCubes();
     updateGUI();
     SSTUStockInterop.fireEditorUpdate();//update editor for mass/cost values
     if (updateSymmetry)
     {
         foreach (Part p in part.symmetryCounterparts)
         {
             p.GetComponent <SSTUModularStationCore>().setSolarEditor(newSolar, false);
         }
     }
 }
 private void setSolarEditor(string newSolar, bool updateSymmetry)
 {
     currentSolar = newSolar;
     solarModule.disable();
     solarModule = Array.Find(solarModules, m => m.name == currentSolar);//TODO cleanup
     solarModule.enable(getSolarRoot(false), coreModule.currentVerticalPosition);
     updateSolarModules();
     updateCost();
     updateMass();
     updateDragCubes();
     updateGUI();
     SSTUStockInterop.fireEditorUpdate();//update editor for mass/cost values
     if (updateSymmetry)
     {
         foreach (Part p in part.symmetryCounterparts)
         {
             p.GetComponent<SSTUModularStationCore>().setSolarEditor(newSolar, false);
         }
     }
 }
        private void init(bool start)
        {
            if (initialized) { return; }
            initialized = true;

            topNodeNames = SSTUUtils.parseCSV(topManagedNodes);
            bottomNodeNames = SSTUUtils.parseCSV(bottomManagedNodes);
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            coreModules = SingleModelData.parseModels(node.GetNodes("CORE"));

            List<ConfigNode> tops = new List<ConfigNode>();
            List<ConfigNode> bottoms = new List<ConfigNode>();
            ConfigNode[] mNodes = node.GetNodes("CAP");
            ConfigNode mNode;
            int len = mNodes.Length;
            for (int i = 0; i < len; i++)
            {
                mNode = mNodes[i];
                if (mNode.GetBoolValue("useForTop", true)) { tops.Add(mNode); }
                if (mNode.GetBoolValue("useForBottom", true)) { bottoms.Add(mNode); }
            }
            topModules = SingleModelData.parseModels(tops.ToArray());
            bottomModules = SingleModelData.parseModels(bottoms.ToArray());
            tops.Clear();
            bottoms.Clear();

            mNodes = node.GetNodes("DOCK");
            len = mNodes.Length;
            for (int i = 0; i < len; i++)
            {
                mNode = mNodes[i];
                if (mNode.GetBoolValue("useForTop", true)) { tops.Add(mNode); }
                if (mNode.GetBoolValue("useForBottom", true)) { bottoms.Add(mNode); }
            }
            topDockModules = SingleModelData.parseModels(tops.ToArray());
            bottomDockModules = SingleModelData.parseModels(bottoms.ToArray());
            tops.Clear();
            bottoms.Clear();

            mNodes = node.GetNodes("SOLAR");
            len = mNodes.Length;
            solarModules = new SolarData[len];
            for (int i = 0; i < len; i++)
            {
                mNode = mNodes[i];
                solarModules[i] = new SolarData(mNode);
            }

            topDockModule = SingleModelData.findModel(topDockModules, currentTopDock);
            topModule = SingleModelData.findModel(topModules, currentTop);
            coreModule = SingleModelData.findModel(coreModules, currentCore);
            bottomModule = SingleModelData.findModel(bottomModules, currentBottom);
            bottomDockModule = SingleModelData.findModel(bottomDockModules, currentBottomDock);
            solarModule = Array.Find(solarModules, m => m.name == currentSolar);//TODO cleanup
            if (!topModule.isValidTextureSet(currentTopTexture)) { currentTopTexture = topModule.getDefaultTextureSet(); }
            if (!coreModule.isValidTextureSet(currentCoreTexture)) { currentCoreTexture = coreModule.getDefaultTextureSet(); }
            if (!bottomModule.isValidTextureSet(currentBottomTexture)) { currentBottomTexture = bottomModule.getDefaultTextureSet(); }
            restoreModels();
            updateModulePositions();
            updateMass();
            updateCost();
            updateAttachNodes(false);
            if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)
            {
                ModuleDockingNode[] mdns = part.GetComponents<ModuleDockingNode>();
                if (mdns.Length > 0)
                {
                    if (topDockModule.model != null)
                    {
                        topDockPartModule = mdns[0];
                    }
                    if (bottomDockModule.model != null)
                    {
                        bottomDockPartModule = mdns.Length > 1 ? mdns[1] : mdns[0];
                    }
                }
                updateDockingModules(start);
            }
            //resources are updated in Start(), to ensure that the dependent modules have loaded
        }
        private void init(bool start)
        {
            if (initialized)
            {
                return;
            }
            initialized = true;

            topNodeNames    = SSTUUtils.parseCSV(topManagedNodes);
            bottomNodeNames = SSTUUtils.parseCSV(bottomManagedNodes);
            ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData);

            coreModules = SingleModelData.parseModels(node.GetNodes("CORE"));

            List <ConfigNode> tops    = new List <ConfigNode>();
            List <ConfigNode> bottoms = new List <ConfigNode>();

            ConfigNode[] mNodes = node.GetNodes("CAP");
            ConfigNode   mNode;
            int          len = mNodes.Length;

            for (int i = 0; i < len; i++)
            {
                mNode = mNodes[i];
                if (mNode.GetBoolValue("useForTop", true))
                {
                    tops.Add(mNode);
                }
                if (mNode.GetBoolValue("useForBottom", true))
                {
                    bottoms.Add(mNode);
                }
            }
            topModules    = SingleModelData.parseModels(tops.ToArray());
            bottomModules = SingleModelData.parseModels(bottoms.ToArray());
            tops.Clear();
            bottoms.Clear();

            mNodes = node.GetNodes("DOCK");
            len    = mNodes.Length;
            for (int i = 0; i < len; i++)
            {
                mNode = mNodes[i];
                if (mNode.GetBoolValue("useForTop", true))
                {
                    tops.Add(mNode);
                }
                if (mNode.GetBoolValue("useForBottom", true))
                {
                    bottoms.Add(mNode);
                }
            }
            topDockModules    = SingleModelData.parseModels(tops.ToArray());
            bottomDockModules = SingleModelData.parseModels(bottoms.ToArray());
            tops.Clear();
            bottoms.Clear();

            mNodes       = node.GetNodes("SOLAR");
            len          = mNodes.Length;
            solarModules = new SolarData[len];
            for (int i = 0; i < len; i++)
            {
                mNode           = mNodes[i];
                solarModules[i] = new SolarData(mNode);
            }

            topDockModule    = SingleModelData.findModel(topDockModules, currentTopDock);
            topModule        = SingleModelData.findModel(topModules, currentTop);
            coreModule       = SingleModelData.findModel(coreModules, currentCore);
            bottomModule     = SingleModelData.findModel(bottomModules, currentBottom);
            bottomDockModule = SingleModelData.findModel(bottomDockModules, currentBottomDock);
            solarModule      = Array.Find(solarModules, m => m.name == currentSolar);//TODO cleanup

            //validate selections for sub-modules that may require unlocks
            if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)
            {
                if (!topDockModule.isAvailable(upgradesApplied))
                {
                    topDockModule = Array.Find(topDockModules, m => m.isAvailable(upgradesApplied));
                }
                if (!bottomDockModule.isAvailable(upgradesApplied))
                {
                    bottomDockModule = Array.Find(bottomDockModules, m => m.isAvailable(upgradesApplied));
                }
                if (!solarModule.isAvailable(this))
                {
                    solarModule = Array.Find(solarModules, m => m.isAvailable(this));
                }
                currentTopDock    = topDockModule.name;
                currentBottomDock = bottomDockModule.name;
                currentSolar      = solarModule.name;
            }

            if (!topModule.isValidTextureSet(currentTopTexture))
            {
                currentTopTexture = topModule.getDefaultTextureSet();
            }
            if (!coreModule.isValidTextureSet(currentCoreTexture))
            {
                currentCoreTexture = coreModule.getDefaultTextureSet();
            }
            if (!bottomModule.isValidTextureSet(currentBottomTexture))
            {
                currentBottomTexture = bottomModule.getDefaultTextureSet();
            }

            restoreModels();
            updateModulePositions();
            updateMass();
            updateCost();
            updateAttachNodes(false);
            if (HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight)
            {
                ModuleDockingNode[] mdns = part.GetComponents <ModuleDockingNode>();
                if (mdns.Length > 0)
                {
                    if (topDockModule.model != null)
                    {
                        topDockPartModule = mdns[0];
                    }
                    if (bottomDockModule.model != null)
                    {
                        bottomDockPartModule = mdns.Length > 1 ? mdns[1] : mdns[0];
                    }
                }
                updateDockingModules(start);
            }
            //resources are updated in Start(), to ensure that the dependent modules have loaded
        }