/// <summary>
 /// Singular 'enable texture set' function to be used by internal and external plugin code.  Optionally calls recursively
 /// to update symmetry counterparts if 'symmetry' parameter is true.<para/>
 /// </summary>
 /// <param name="name"></param>
 /// <param name="symmetry"></param>
 public void enableTextureSet(string name, bool symmetry, bool userInput)
 {
     if (textureSets == null)
     {
         return;
     }
     //TODO - validate input texture set name; log error if invalid
     currentTextureSet = name;
     textureSets.enableCurrentSet(getModelTransforms(), userInput);
     TextureCallbacks.onTextureSetChanged(part);
     if (symmetry)
     {
         this.actionWithSymmetry(m =>
         {
             m.enableTextureSet(name, false, userInput);
         });
     }
 }
        /// <summary>
        /// Restores texture set data and either loads default texture set or saved texture set (if any)
        /// </summary>
        private void initialize()
        {
            if (textureSets != null)
            {
                //already initialized from OnLoad (prefab, some in-editor parts)
                return;
            }
            ConfigNode node = Utils.parseConfigNode(configNodeData);

            string[] setNames = node.GetStringValues("textureSet", true);
            textureSets = new TextureSetContainer(this, Fields[nameof(currentTextureSet)], Fields[nameof(persistentData)], setNames);
            if (string.IsNullOrEmpty(currentTextureSet))
            {
                currentTextureSet = setNames[0];
            }
            this.updateUIChooseOptionControl(nameof(currentTextureSet), textureSets.getTextureSetNames(), textureSets.getTextureSetTitles(), true, currentTextureSet);
            textureSets.enableCurrentSet(getModelTransforms());
            Fields[nameof(currentTextureSet)].guiName = sectionName;
        }
        /// <summary>
        /// Restores texture set data and either loads default texture set or saved texture set (if any)
        /// </summary>
        private void initialize()
        {
            if (textureSets != null)
            {
                //already initialized from OnLoad (prefab, some in-editor parts)
                return;
            }
            ConfigNode node = Utils.parseConfigNode(configNodeData);

            string[] setNames        = node.GetStringValues("textureSet", false);
            string   modelShaderName = node.GetStringValue("modelShader");

            List <TextureSet> allSets = new List <TextureSet>();

            if (!string.IsNullOrEmpty(modelShaderName))
            {
                TextureSet set = TexturesUnlimitedLoader.getModelShaderTextureSet(modelShaderName);
                if (set != null)
                {
                    allSets.Add(set);
                }
            }
            TextureSet[] sets = TexturesUnlimitedLoader.getTextureSets(setNames);
            for (int i = 0; i < sets.Length; i++)
            {
                allSets.Add(sets[i]);
            }
            ConfigNode[] fullNodeSets = node.GetNodes("KSP_TEXTURE_SET");
            for (int i = 0; i < fullNodeSets.Length; i++)
            {
                allSets.Add(new TextureSet(fullNodeSets[i], "create"));
            }

            textureSets = new TextureSetContainer(this, Fields[nameof(currentTextureSet)], Fields[nameof(persistentData)], allSets);
            if (string.IsNullOrEmpty(currentTextureSet))
            {
                currentTextureSet = allSets[0].name;
            }
            this.updateUIChooseOptionControl(nameof(currentTextureSet), textureSets.getTextureSetNames(), textureSets.getTextureSetTitles(), true, currentTextureSet);
            textureSets.enableCurrentSet(getModelTransforms(), false);
            Fields[nameof(currentTextureSet)].guiName = sectionName;
        }
Esempio n. 4
0
 public void setSectionColors(string name, RecoloringData[] colors)
 {
     textureSets.setCustomColors(colors);
     textureSets.enableCurrentSet(getModelTransforms());
 }