Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private void updateTextureSet(bool useDefaults)
        {
            if (mpf == null)
            {
                return;
            }
            TextureSet s = KSPShaderLoader.getTextureSet(currentTextureSet);

            RecoloringData[] colors = useDefaults ? s.maskColors : getSectionColors(string.Empty);
            Material         fm     = mpf.FairingMaterial;

            if (fm != null)
            {
                s.textureData[0].enable(fm, colors);
            }
            foreach (ProceduralFairings.FairingPanel fp in mpf.Panels)
            {
                s.enable(fp.go, colors);
            }
            if (useDefaults)
            {
                recolorHandler.setColorData(colors);
            }
            SSTUModInterop.onPartTextureUpdated(part);
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        public void enableTextureSet(string name, RecoloringData[] userColors)
        {
            TextureSet s = KSPShaderLoader.getTextureSet(name);

            if (s != null)
            {
                s.enable(root, userColors);
            }
        }
Ejemplo n.º 5
0
        private void updateTextureSet(bool useDefaults)
        {
            TextureSet s = KSPShaderLoader.getTextureSet(currentTextureSet);

            RecoloringData[] colors = useDefaults ? s.maskColors : getSectionColors(string.Empty);
            model.enableTextureSet(currentTextureSet, colors);
            if (useDefaults)
            {
                recolorHandler.setColorData(colors);
            }
            SSTUModInterop.onPartTextureUpdated(part);
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
        public void enableTextureSet(string name, RecoloringData[] userColors)
        {
            TextureSet set = KSPShaderLoader.getTextureSet(name);

            if (set != null)
            {
                set.enable(rootObject, userColors);
            }
            else
            {
                MonoBehaviour.print("ERROR: " + name + " is not a valid texture set for fairing.");
            }
        }
Ejemplo n.º 8
0
        //IRecolorable override
        public TextureSet getSectionTexture(string section)
        {
            switch (name)
            {
            case "Decoupler":
                return(KSPShaderLoader.getTextureSet(currentTextureSet));

            case "Engines":
                return(engineModels.currentTextureSet);

            default:
                return(KSPShaderLoader.getTextureSet(currentTextureSet));
            }
        }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
        private void updateTextureSet(bool useDefaults)
        {
            TextureSet s = KSPShaderLoader.getTextureSet(currentTextureSet);

            RecoloringData[] colors = useDefaults ? s.maskColors : getSectionColors(string.Empty);
            int len = fairingParts.Length;

            for (int i = 0; i < len; i++)
            {
                fairingParts[i].fairingBase.enableTextureSet(currentTextureSet, colors);
            }
            if (useDefaults)
            {
                recolorHandler.setColorData(colors);
            }
            updateOpacity();
            SSTUModInterop.onPartTextureUpdated(part);
        }
Ejemplo n.º 11
0
 //IRecolorable override
 public TextureSet getSectionTexture(string section)
 {
     return(KSPShaderLoader.getTextureSet(currentTextureSet));
 }
Ejemplo n.º 12
0
        //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");
        }