コード例 #1
0
        public static void MoveThroughMatList(int step, MatList matList)
        {
            if (matList.mats.Count <= 0)
            {
                Logger.log.Debug("Material list is empty! Ensure mod part lists are installed in ../BeatSaber/SaberForgeParts");
                return;
            }

            matList.index += step;

            if (matList.index >= matList.mats.Count)
            {
                matList.index = 0;
            }

            else if (matList.index < 0)
            {
                matList.index = matList.mats.Count - 1;
            }

            //set text
            UIFunctions.UpdateAllMatLabels();

            if (step != 0)
            {
                onMaterialChange();
            }
        }
コード例 #2
0
ファイル: Plugin.cs プロジェクト: lizfrost/SaberForge
 public static void ReloadAssets()
 {
     AssetLoader.Init();
     SaberForgeConfig.LoadConfig();
     PartEditor.UpdateSabers();
     UIFunctions.UpdateAllPartLabels();
     UIFunctions.UpdateAllMatLabels();
 }
コード例 #3
0
        //find user textures and send them to be loaded into custom materials
        public static void FindUserTextures()
        {
            List <string> imagePaths = (Directory.GetFiles(Path.Combine(Application.dataPath, "../SaberForgeAssets/UserTextures/"), "*.png", SearchOption.AllDirectories).ToList());

            Logger.log.Debug($"Found {imagePaths.Count} user textures");


            foreach (string path in imagePaths)
            {
                string fileName = path.Replace(Path.Combine(Application.dataPath, "../SaberForgeAssets/UserTextures/"), "");

                string[] fileInfo = fileName.Split('_');

                if (fileInfo.Length != 3)
                {
                    Logger.log.Debug("Invalid texture name " + fileName + ", please refer to user guide for texture naming guidelines");
                    continue;
                }

                bool customColor = false;

                if (fileInfo[1] == "cctrue")
                {
                    customColor = true;
                }
                else if (fileInfo[1] == "ccfalse")
                {
                    customColor = false;
                }
                else
                {
                    Logger.log.Debug("Invalid texture name " + fileName + ", please refer to user guide for texture naming guidelines");
                    continue;
                }

                string   textureName = fileInfo[2].Replace(".png", "");
                Material templateMat;
                MaterialInfo.MaterialType matType = MaterialInfo.MaterialType.NamePlate;



                //find template material using file name
                if (fileInfo[0] == "cutout")
                {
                    textureName += "_Cutout";

                    if (customColor)
                    {
                        templateMat = PartEditor.FindMaterialInList("FrostDragon.CoreParts.Template.Cutout_Demo_CC", PartEditor.TemplateList);
                    }

                    else
                    {
                        templateMat = PartEditor.FindMaterialInList("FrostDragon.CoreParts.Template.Cutout_Demo_NoCC", PartEditor.TemplateList);
                    }
                }
                else if (fileInfo[0] == "trans")
                {
                    textureName += "_Trans";

                    if (customColor)
                    {
                        templateMat = PartEditor.FindMaterialInList("FrostDragon.CoreParts.Template.Trans_Demo_CC", PartEditor.TemplateList);
                    }
                    else
                    {
                        templateMat = PartEditor.FindMaterialInList("FrostDragon.CoreParts.Template.Trans_Demo_NoCC", PartEditor.TemplateList);
                    }
                }
                else if (fileInfo[0] == "opaque")
                {
                    textureName += "_Opaque";

                    if (customColor)
                    {
                        templateMat = PartEditor.FindMaterialInList("FrostDragon.CoreParts.Template.Opaque_Demo_CC", PartEditor.TemplateList);
                    }
                    else
                    {
                        templateMat = PartEditor.FindMaterialInList("FrostDragon.CoreParts.Template.Opaque_Demo_NoCC", PartEditor.TemplateList);
                    }
                }
                else if (fileInfo[0] == "trail")
                {
                    textureName += "_Trail";
                    matType      = MaterialInfo.MaterialType.Trail;

                    if (customColor)
                    {
                        templateMat = PartEditor.FindMaterialInList("FrostDragon.CoreParts.Template.Basic_Trail_CC", PartEditor.TemplateList);
                    }
                    else
                    {
                        templateMat = PartEditor.FindMaterialInList("FrostDragon.CoreParts.Template.Basic_Trail_NoCC", PartEditor.TemplateList);
                    }
                }
                else if (fileInfo[0] == "flagtrail")
                {
                    textureName += "_FlagTrail";
                    matType      = MaterialInfo.MaterialType.Trail;

                    if (customColor)
                    {
                        templateMat = PartEditor.FindMaterialInList("FrostDragon.CoreParts.Template.Flag_Trail_CC", PartEditor.TemplateList);
                    }
                    else
                    {
                        templateMat = PartEditor.FindMaterialInList("FrostDragon.CoreParts.Template.Flag_Trail_NoCC", PartEditor.TemplateList);
                    }
                }
                else
                {
                    Logger.log.Debug("Invalid texture name " + fileName + ", please refer to user guide for texture naming guidelines");
                    continue;
                }

                GenerateUserMaterial(path, textureName, templateMat, customColor, matType);
            }

            //update labels
            UIFunctions.UpdateAllMatLabels();
        }