Exemple #1
0
        void Start()
        {
            myCfg = Config;

            formatter = new BinaryFormatter();
            LoadSaveData();



            //CustomStackSizeConfig.Reload();
            //foreach (var item in CustomStackSizeConfig)
            //{
            //    Debug.LogError(item.Key.Key);
            //    Debug.LogError(item.Value.BoxedValue);
            //}
            SortWhenApply = base.Config.Bind <bool>("1 | Sort when Apply |", "SortWhenApply", false, "If enabled, it will automatically sort all Storages when you apply a new Stack-Size.");
            KeyConfig     = base.Config.Bind <KeyCode>("2 | UI-Key |", "HotKey", KeyCode.K, "Binds a HotKey for opening/closing the StackSizeEditor UI");

            var ab = AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("StackSizeEditor.takiui"));

            ScrollViewCanvas = ab.LoadAsset <GameObject>("myCanvas");
            EntryPrefab      = ab.LoadAsset <GameObject>("myEntryCanvas");

            //if (ScrollViewCanvas == null)
            //{
            //    Debug.LogWarning("canvas is null");
            //}
            //else
            //{
            //    Debug.LogWarning("canvas is NOT null");
            //}

            myCanvas = Instantiate <GameObject>(ScrollViewCanvas);
            //myScrollView.renderMode = RenderMode.ScreenSpaceOverlay;
            //myScrollView.enabled = true;

            foreach (var dropdown in myCanvas.GetComponentsInChildren <Dropdown>())
            {
                //Debug.LogWarning($"Dropdown found: {dropdown.name}");
                switch (dropdown.name)
                {
                case "myDropdownSortBy":
                    dropdown.onValueChanged.AddListener(delegate { DropDownSortByValueChanged(dropdown.value); });
                    break;

                case "myDropdownSortReverse":
                    dropdown.onValueChanged.AddListener(delegate { DropDownReverseValueChanged(dropdown.value); });
                    break;

                default:
                    break;
                }
            }

            foreach (var button in myCanvas.GetComponentsInChildren <Button>())
            {
                //Debug.LogWarning($"Button found: {button.name}");
                switch (button.name)
                {
                case "ButtonLoadList":
                    button.onClick.AddListener(delegate { LoadList(SortBy, Reverse); });
                    break;

                case "ButtonSortInvs":
                    button.onClick.AddListener(delegate { SortAllStorages(); });
                    break;

                case "ButtonClose":
                    button.onClick.AddListener(delegate { CloseUI(); });
                    break;

                default:
                    break;
                }
            }

            foreach (var toggle in myCanvas.GetComponentsInChildren <Toggle>())
            {
                switch (toggle.gameObject.name)
                {
                case "ToggleSortWhenApply":
                    toggle.isOn = SortWhenApply.Value;
                    toggle.onValueChanged.AddListener(delegate { SortWhenApplyToggleValChanged(toggle.isOn); });
                    break;

                default:
                    break;
                }
            }

            InputField tmpMaxWarpersInputField = myCanvas.transform.FindChildRecur("MaxWarpersInputField").GetComponent <InputField>();

            myCanvas.transform.FindChildRecur("ButtonSetMaxWarpers").GetComponent <Button>().onClick.AddListener(delegate { SetMaxWarpers(tmpMaxWarpersInputField); });
            tmpMaxWarpersInputField.text = (StackSizeEditorPlugin.saveData.maxWarpers == 0 ? "20" : StackSizeEditorPlugin.saveData.maxWarpers.ToString());

            //foreach (var imageitem in myCanvas.GetComponentsInChildren<Image>())
            //{
            //    switch (imageitem.name)
            //    {
            //        case "ImageThumbnail":
            //            Debug.LogWarning($"{imageitem.name} found");
            //            thumb = imageitem;
            //            break;
            //        default:
            //            break;
            //    }
            //}

            foreach (var inputField in myCanvas.GetComponentsInChildren <InputField>())
            {
                switch (inputField.name)
                {
                case "myInputField":
                    myInputField = inputField;
                    break;

                default:
                    break;
                }
            }

            //foreach (var textItem in myCanvas.GetComponentsInChildren<Text>())
            //{
            //    switch (textItem.name)
            //    {
            //        case "HeaderText":
            //            myHeaderText = textItem;
            //            myHeaderText.enabled = false; // init hide error message
            //            break;
            //        default:
            //            break;
            //    }
            //}

            //Debug.LogError("Start Canvas Search");
            foreach (var canvas in myCanvas.GetComponentsInChildren <Canvas>())
            {
                //Debug.LogError(canvas.name);
                switch (canvas.name)
                {
                case "CanvasMain":
                    //Debug.LogWarning("Found CanvasMain!!! ########");
                    myCanvasMain = canvas;
                    break;

                case "CanvasHeader":
                    //Debug.LogWarning("Found CanvasHeader!!! ########");
                    myCanvasHeader = canvas;
                    canvas.gameObject.AddComponent <DragWindow>();
                    break;

                default:
                    break;
                }
            }

            foreach (var item in myCanvasMain.GetComponentsInChildren <RectTransform>())
            {
                switch (item.gameObject.name)
                {
                case "myScrollViewContent":

                    myScrollViewContent = item.gameObject;

                    //foreach (Transform child in item.transform)
                    //{
                    //    Destroy(child.gameObject);
                    //}
                    break;

                default:
                    break;
                }
            }

            myCanvas.SetActive(false);
        }
Exemple #2
0
        public void Awake()
        {
            floatProperties.Add("_Cull");
            floatProperties.Add("_BlueChannelBias");
            floatProperties.Add("_BlueChannelSmoothness");
            floatProperties.Add("_ColorsOn");
            floatProperties.Add("_DecalLayer");
            floatProperties.Add("_Depth");
            floatProperties.Add("_DitherOn");
            floatProperties.Add("_EliteBrightnessMax");
            floatProperties.Add("_EliteBrightnessMin");
            floatProperties.Add("_EliteIndex");
            floatProperties.Add("_EmPower");
            floatProperties.Add("_EnableCutout");
            floatProperties.Add("_Fade");
            floatProperties.Add("_FadeBias");
            floatProperties.Add("_FlowEmissionStrength");
            floatProperties.Add("_FlowHeightBias");
            floatProperties.Add("_FlowHeightPower");
            floatProperties.Add("_FlowMaskStrength");
            floatProperties.Add("_FlowNormalStrength");
            floatProperties.Add("_FlowSpeed");
            floatProperties.Add("_FlowTextureScaleFactor");
            floatProperties.Add("_FlowmapOn");
            floatProperties.Add("_ForceSpecOn");
            floatProperties.Add("_FresnelBoost");
            floatProperties.Add("_FresnelPower");
            floatProperties.Add("_GreenChannelBias");
            floatProperties.Add("_GreenChannelSmoothness");
            floatProperties.Add("_LimbPrimeMask");
            floatProperties.Add("_LimbRemovalOn");
            floatProperties.Add("_NormalStrength");
            floatProperties.Add("_PrintBias");
            floatProperties.Add("_PrintBoost");
            floatProperties.Add("_PrintDirection");
            floatProperties.Add("_PrintEmissionToAlbedoLerp");
            floatProperties.Add("_PrintOn");
            floatProperties.Add("_RampInfo");
            floatProperties.Add("_SliceAlphaDepth");
            floatProperties.Add("_SliceBandHeight");
            floatProperties.Add("_SliceHeight");
            floatProperties.Add("_Smoothness");
            floatProperties.Add("_SpecularExponent");
            floatProperties.Add("_SpecularStrength");
            floatProperties.Add("_SplatmapOn");
            floatProperties.Add("_SplatmapTileScale");
            floatProperties.Add("_FEON");
            floatProperties.Add("_SrcBlend");
            floatProperties.Add("_DstBlend");
            floatProperties.Add("_InvFade");
            floatProperties.Add("_AlphaBias");
            floatProperties.Add("_AlphaBoost");
            floatProperties.Add("_Boost");
            floatProperties.Add("_CalcTextureAlphaOn");
            floatProperties.Add("_CloudOffsetOn");
            floatProperties.Add("_CloudsOn");
            floatProperties.Add("_DisableRemapOn");
            floatProperties.Add("_ExternalAlpha");
            floatProperties.Add("_FadeCloseDistance");
            floatProperties.Add("_FadeCloseOn");
            floatProperties.Add("_FresnelOn");
            floatProperties.Add("_InternalSimpleBlendMode");
            floatProperties.Add("_OffsetAmount");
            floatProperties.Add("_UseUV1On");
            floatProperties.Add("_VertexAlphaOn");
            floatProperties.Add("_VertexColorOn");
            floatProperties.Add("_VertexOffsetOn");

            colorProperties.Add("_EmColor");

            directory = Application.dataPath;
            directory = System.IO.Path.GetFullPath(System.IO.Path.Combine(directory, @"..\BepInEx\skins"));


            myConfig = new ConfigFile(@"BepInEx\skins\RyanSkinAPI.cfg", true);

            On.RoR2.SurvivorCatalog.Init += (orig) =>
            {
                orig();

                foreach (SurvivorDef survivorDef in SurvivorCatalog.allSurvivorDefs)
                {
                    //Skip 'finished'  prefabs. This is for custom survivors that do skins differently in an incompatible way to the RyanSkinAPI.
                    if (survivorDef.bodyPrefab && survivorDef.bodyPrefab.CompareTag("Finish"))
                    {
                        continue;
                    }

                    AddComponents(survivorDef);

                    if (myConfig.Bind <bool>(new ConfigDefinition("", "DumpBoilerplates"), false).Value)
                    {
                        base.Logger.LogInfo("Dumping " + survivorDef.name);

                        DumpDefaultSkins(survivorDef.bodyPrefab.gameObject);
                    }
                }

                foreach (string ModFolder in Directory.EnumerateDirectories(directory))
                {
                    foreach (string SkinFolder in Directory.EnumerateDirectories(ModFolder))
                    {
                        foreach (string SkinConfig in Directory.EnumerateFiles(SkinFolder))
                        {
                            if (SkinConfig.EndsWith("Skin.cfg"))
                            {
                                string[] newpath = SkinConfig.Split(new string[] { @"\" }, StringSplitOptions.RemoveEmptyEntries);

                                string     RelativePath = @"BepInEx\skins\" + newpath[newpath.Length - 3] + @"\" + newpath[newpath.Length - 2] + @"\" + newpath[newpath.Length - 1];
                                ConfigFile config       = new ConfigFile(RelativePath, false);
                                string     body         = config.Bind <string>("", "CharacterBodyName", "null").Value;

                                pendingSkins.Add(new PendingSkin()
                                {
                                    config = config, bodyName = body, SkinFolder = SkinFolder
                                });
                            }
                        }
                    }
                }
                ;

                foreach (SurvivorDef survivorDef in SurvivorCatalog.allSurvivorDefs)
                {
                    //Skip finished bodies.
                    if (survivorDef.bodyPrefab.CompareTag("Finish"))
                    {
                        continue;
                    }

                    foreach (PendingSkin pendingSkin in pendingSkins)
                    {
                        if (survivorDef.bodyPrefab.name == pendingSkin.bodyName)
                        {
                            AddSkin(survivorDef, pendingSkin.SkinFolder, pendingSkin.config);
                        }
                    }
                }
            };
        }
Exemple #3
0
 internal ConfigEntry(ConfigFile configFile,
                      ConfigDefinition definition,
                      T defaultValue,
                      ConfigDescription configDescription) : base(configFile, definition, typeof(T),
                                                                  defaultValue, configDescription) =>