public static void ReloadAssets() { AssetLoader.Init(); SaberForgeConfig.LoadConfig(); PartEditor.UpdateSabers(); UIFunctions.UpdateAllPartLabels(); UIFunctions.UpdateAllMatLabels(); }
public static SFCustomSlider CreateSliderPanel(Transform parent, string panelLabel, PartEditor.PartAdjustment partAdjustment) { RectTransform newPanel = CreateRectPanel(parent, panelLabel); // RectTransform sliderPanel = new GameObject("SliderPanel", typeof(RectTransform)).GetComponent<RectTransform>(); // SetRect(sliderPanel, newPanel, new Vector2(0, 0), new Vector2(1, 1), new Vector2(21, 0), new Vector2(-50, 10)); // Sliders currently broken in BSUI, yoinked code to implement fix SFCustomSlider slider = new GameObject("CustomUISlider").AddComponent <SFCustomSlider>(); GameObject.DontDestroyOnLoad(slider.gameObject); slider.Scrollbar = GameObject.Instantiate(Resources.FindObjectsOfTypeAll <HMUI.RangeValuesTextSlider>().First(s => s.name != "CustomUISlider"), parent, false); SetRect(slider.Scrollbar.GetComponent <RectTransform>(), newPanel, new Vector2(0, 0), new Vector2(1, 1), new Vector2(21, 0), new Vector2(-50, 10)); slider.Scrollbar.name = "CustomUISlider"; slider.Scrollbar.transform.SetParent(parent, false); slider.Scrollbar.numberOfSteps = (int)((partAdjustment.maxValue - partAdjustment.minValue) / partAdjustment.increment) + 1; slider.MinValue = slider.Scrollbar.minValue = partAdjustment.minValue; slider.MaxValue = slider.Scrollbar.maxValue = partAdjustment.maxValue; slider.IsIntValue = false; slider.Scrollbar.value = partAdjustment.value; UpdateSliderLabel(slider, partAdjustment.value); slider.Scrollbar.valueDidChangeEvent += delegate(RangeValuesTextSlider rangeValuesTextSlider, float value) { UpdateSliderLabel(slider, value); PartEditor.AdjustPartTransform(partAdjustment, value); }; return(slider); }
public static GameObject CreateMaterialSwapPanel(Transform parent, PartEditor.MatList matList, string panelLabel) { RectTransform newPanel = CreateRectPanel(parent, panelLabel); TextMeshProUGUI matNameText = BeatSaberUI.CreateText(newPanel, "mat name", new Vector2(20, 0), new Vector2(30, 10)); matNameText.alignment = TextAlignmentOptions.Center; matNameText.fontSize = 4; HoverHint matHoverHint = BeatSaberUI.AddHintText(matNameText.gameObject.GetComponent <RectTransform>(), "hint"); LabelTextGroup textGroup = new LabelTextGroup(matNameText, matHoverHint, matList); matTextGroups.Add(textGroup); //cry BeatSaberUI.CreateUIButton(newPanel, "DecButton", new Vector2(0, 0), new Vector2(8, 8), delegate { PartEditor.MoveThroughMatList(-1, matList); }); BeatSaberUI.CreateUIButton(newPanel, "IncButton", new Vector2(50, 0), new Vector2(8, 8), delegate { PartEditor.MoveThroughMatList(1, matList); }); //to set name and hint strings UpdateMatLabelText(textGroup); return(newPanel.gameObject); }
public static GameObject CreateModelSwapPanel(Transform parent, PartEditor.PartList partList, string panelLabel) { RectTransform newPanel = CreateRectPanel(parent, panelLabel); TextMeshProUGUI partNameText = BeatSaberUI.CreateText(newPanel, "part name", new Vector2(20, 0), new Vector2(30, 10)); partNameText.alignment = TextAlignmentOptions.Center; partNameText.fontSize = 4; HoverHint modelHoverHint = BeatSaberUI.AddHintText(partNameText.gameObject.GetComponent <RectTransform>(), "hint"); LabelTextGroup textGroup = new LabelTextGroup(partNameText, modelHoverHint, partList); partTextGroups.Add(textGroup); //cry delegate won't let me pass int as a ref, hence faff with index arrays BeatSaberUI.CreateUIButton(newPanel, "DecButton", new Vector2(0, 0), new Vector2(8, 8), delegate { PartEditor.MoveThroughPartList(-1, partList); }); BeatSaberUI.CreateUIButton(newPanel, "IncButton", new Vector2(50, 0), new Vector2(8, 8), delegate { PartEditor.MoveThroughPartList(1, partList); }); //to set name and hint strings UpdatePartLabelText(textGroup); return(newPanel.gameObject); }
//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(); }