예제 #1
0
        // Using the magical power of Zenject™, we magically find ourselves with an instance of
        // our HUDConfigModel and the CoreGameHUDController.
        internal CanvasUtility(HUDConfigModel hudConfig,
                               MainConfigModel mainConfig,
                               [Inject(Optional = true)] GameplayCoreSceneSetupData data,
                               [Inject(Optional = true)] CoreGameHUDController coreGameHUD)
        {
            this.mainConfig = mainConfig;
            if (coreGameHUD != null)
            {
                var comboPos = coreGameHUD.GetComponentInChildren <ComboUIController>().transform.position;

                hudWidth  = Mathf.Abs(comboPos.x);
                hudHeight = comboPos.y;
                hudDepth  = comboPos.z;

                energyCanvas = EnergyPanelGO(ref coreGameHUD).GetComponent <Canvas>();

                // Hide Canvas and Multiplier if needed
                if (mainConfig.HideCombo)
                {
                    HideBaseGameHUDElement <ComboUIController>(coreGameHUD);
                }
                if (mainConfig.HideMultiplier)
                {
                    HideBaseGameHUDElement <ScoreMultiplierUIController>(coreGameHUD);
                }
            }

            RefreshAllCanvases(hudConfig, data, coreGameHUD);
        }
예제 #2
0
        // Using the magical power of Zenject™, we magically find ourselves with an instance of
        // our HUDConfigModel and the CoreGameHUDController.
        internal CanvasUtility(HUDConfigModel hudConfig,
                               MainConfigModel mainConfig,
                               [Inject(Optional = true)] GameplayCoreSceneSetupData data,
                               [Inject(Optional = true)] CoreGameHUDController coreGameHUD)
        {
            this.mainConfig = mainConfig;
            if (coreGameHUD != null)
            {
                energyCanvas = EnergyPanelGO(ref coreGameHUD).GetComponent <Canvas>();

                // Hide Canvas and Multiplier if needed
                if (mainConfig.HideCombo)
                {
                    HideBaseGameHUDElement <ComboUIController>(coreGameHUD);
                }
                if (mainConfig.HideMultiplier)
                {
                    HideBaseGameHUDElement <ScoreMultiplierUIController>(coreGameHUD);
                }
            }
            if (data != null)
            {
                HUDType = GetGameplayCoreHUDTypeForEnvironmentSize(data.environmentInfo.environmentSizeData.width);
            }

            RefreshAllCanvases(hudConfig, data, coreGameHUD);
        }
예제 #3
0
        // Using the magical power of Zenject™, we magically find ourselves with an instance of
        // our HUDConfigModel and the CoreGameHUDController.
        internal CanvasUtility(HUDConfigModel hudConfig,
                               MainConfigModel mainConfig,
                               [Inject(Optional = true)] GameplayCoreSceneSetupData data,
                               [Inject(Optional = true)] CoreGameHUDController coreGameHUD)
        {
            this.mainConfig = mainConfig;
            if (coreGameHUD != null)
            {
                hudWidth  = Mathf.Abs(coreGameHUD.GetComponentInChildren <ComboUIController>().transform.position.x);
                hudDepth  = Mathf.Abs(coreGameHUD.GetComponentInChildren <ComboUIController>().transform.position.z);
                hudHeight = Mathf.Abs(coreGameHUD.GetComponentInChildren <ComboUIController>().transform.position.y) - 1.5f;

                energyCanvas = EnergyPanelGO(ref coreGameHUD).GetComponent <Canvas>();

                // Hide Canvas and Multiplier if needed
                if (mainConfig.HideCombo)
                {
                    HideBaseGameHUDElement <ComboUIController>(coreGameHUD);
                }
                if (mainConfig.HideMultiplier)
                {
                    HideBaseGameHUDElement <ScoreMultiplierUIController>(coreGameHUD);
                }
            }
            if (data != null)
            {
                // HUDType = GetGameplayCoreHUDTypeForEnvironmentSize(data.environmentInfo.environmentType);
            }

            RefreshAllCanvases(hudConfig, data, coreGameHUD);
        }
예제 #4
0
        public override void InstallBindings()
        {
            Container.Bind <VersionUtility>().AsSingle().NonLazy();

            MainConfigModel mainConfig = Plugin.MainConfig;

            Container.Bind <MainConfigModel>().FromInstance(mainConfig);
            mainConfig.HUDConfig.MainCanvasSettings.IsMainCanvas = true;
            Container.Bind <HUDConfigModel>().FromInstance(mainConfig.HUDConfig);

            BindConfig <MissedConfigModel>(mainConfig.MissedConfig);
            BindConfig <NoteConfigModel>(mainConfig.NoteConfig);
            BindConfig <ProgressConfigModel>(mainConfig.ProgressConfig);
            BindConfig <ScoreConfigModel>(mainConfig.ScoreConfig);
            BindConfig <SpeedConfigModel>(mainConfig.SpeedConfig);
            BindConfig <SpinometerConfigModel>(mainConfig.SpinometerConfig);
            BindConfig <PBConfigModel>(mainConfig.PBConfig);
            BindConfig <CutConfigModel>(mainConfig.CutConfig);
            BindConfig <FailConfigModel>(mainConfig.FailsConfig);
            BindConfig <NotesLeftConfigModel>(mainConfig.NotesLeftConfig);

            foreach (CustomCounter customCounter in Plugin.LoadedCustomCounters.Values)
            {
                if (!mainConfig.CustomCounters.TryGetValue(customCounter.Name, out CustomConfigModel config))
                {
                    config = customCounter.ConfigDefaults;
                    mainConfig.CustomCounters.Add(customCounter.Name, config);
                }
                config.AttachedCustomCounter = customCounter;
                customCounter.Config         = config;
                BindCustomCounter(customCounter, config);
            }
        }
예제 #5
0
        public override void InstallBindings()
        {
            MainConfigModel mainConfig = Plugin.MainConfig;

            hudConfig = Container.Resolve <HUDConfigModel>();
            dataModel = Container.Resolve <PlayerDataModel>();

            if (!mainConfig.Enabled)
            {
                return;
            }

            /// LOADING IMPORTANT SHIT LIKE CANVASES AND STUFF ///
            Container.Bind <CanvasUtility>().AsSingle();

            Container.Bind <NoteCountProcessor>().To <GenericNoteCountProcessor>().AsSingle();

            /// LOADING COUNTERS ///
            Plugin.Logger.Notice("Loading counters...");

            AddCounter <MissedConfigModel, MissedCounter>();
            AddCounter <NoteConfigModel, NotesCounter>();

            if (mainConfig.ProgressConfig.Mode != ProgressMode.BaseGame)
            {
                AddCounter <ProgressConfigModel, ProgressCounter>();
            }
            else
            {
                AddCounter <ProgressConfigModel, ProgressBaseGameCounter>();
            }

            AddCounter <ScoreConfigModel, ScoreCounter>();
            AddCounter <CutConfigModel, CutCounter>();
            AddCounter <FailConfigModel, FailCounter>();
            AddCounter <NotesLeftConfigModel, NotesLeftCounter>();
            AddCounter <SpeedConfigModel, SpeedCounter>();
            AddCounter <SpinometerConfigModel, Spinometer>();


            AddCounter <PBConfigModel, PBCounter>((settings) => {
                ScoreConfigModel scoreConfig = Container.Resolve <ScoreConfigModel>();
                HUDCanvas canvasSettings     = scoreConfig.CanvasID == -1 ? hudConfig.MainCanvasSettings : hudConfig.OtherCanvasSettings[scoreConfig.CanvasID];
                return(scoreConfig.Enabled && settings.UnderScore && (dataModel.playerData.playerSpecificSettings.noTextsAndHuds ? canvasSettings.IgnoreNoTextAndHUDOption : true));
            });

            foreach (Custom.CustomCounter customCounter in Plugin.LoadedCustomCounters.Values)
            {
                AddCustomCounter(customCounter, customCounter.CounterType);
            }

            /// LOADING BROADCASTERS WITH BROADCAST IN-GAME EVENTS TO COUNTERS AND STUFF ///
            Container.BindInterfacesAndSelfTo <CounterEventBroadcaster>().AsSingle().NonLazy();
            Container.BindInterfacesAndSelfTo <NoteEventBroadcaster>().AsSingle().NonLazy();
            Container.BindInterfacesAndSelfTo <ScoreEventBroadcaster>().AsSingle().NonLazy();
            Plugin.Logger.Notice("Counters loaded!");
        }
예제 #6
0
 public static void OnLoad()
 {
     settings = Config.Config.loadSettings();
     if (Instance == null && settings.Enabled)
     {
         GameObject controller = new GameObject("Counters+ Controller");
         DontDestroyOnLoad(controller);
         Instance = controller.AddComponent <CountersController>();
         Plugin.Log("Counters+ Controller created.");
     }
 }
예제 #7
0
        public override void InstallBindings()
        {
            MainConfigModel mainConfig = Plugin.MainConfig;

            if (!mainConfig.Enabled)
            {
                return;
            }

            /// LOADING IMPORTANT SHIT LIKE CANVASES AND STUFF ///
            Container.Bind <CanvasUtility>().AsSingle();

            Container.Bind <NoteCountProcessor>().To <GenericNoteCountProcessor>().AsSingle();

            /// LOADING COUNTERS ///
            Plugin.Logger.Notice("Loading counters...");

            AddCounter <MissedConfigModel, MissedCounter>();
            AddCounter <NoteConfigModel, NotesCounter>();

            if (mainConfig.ProgressConfig.Mode != ProgressMode.BaseGame)
            {
                AddCounter <ProgressConfigModel, ProgressCounter>();
            }
            else
            {
                AddCounter <ProgressConfigModel, ProgressBaseGameCounter>();
            }

            AddCounter <ScoreConfigModel, ScoreCounter>();
            AddCounter <CutConfigModel, CutCounter>();
            AddCounter <FailConfigModel, FailCounter>();
            AddCounter <NotesLeftConfigModel, NotesLeftCounter>();
            AddCounter <SpeedConfigModel, SpeedCounter>();
            AddCounter <SpinometerConfigModel, Spinometer>();

            AddCounter <PBConfigModel, PBCounter>((settings) => {
                ScoreConfigModel scoreConfig = Container.Resolve <ScoreConfigModel>();
                HUDCanvas canvasSettings     = GrabCanvasForCounter(scoreConfig);
                return(scoreConfig.Enabled && settings.UnderScore && (dataModel.playerData.playerSpecificSettings.noTextsAndHuds ? canvasSettings.IgnoreNoTextAndHUDOption : true));
            });

            InstallCustomCounters();

            if (mainConfig.AprilFoolsTomfoolery && mainConfig.IsAprilFools)
            {
                Container.BindInterfacesAndSelfTo <AprilFools>().AsSingle().NonLazy();
            }

            /// LOADING BROADCASTERS WITH BROADCAST IN-GAME EVENTS TO COUNTERS AND STUFF ///
            Container.BindInterfacesAndSelfTo <CounterEventBroadcaster>().AsSingle().NonLazy();
            Container.BindInterfacesAndSelfTo <NoteEventBroadcaster>().AsSingle().NonLazy();
            Container.BindInterfacesAndSelfTo <ScoreEventBroadcaster>().AsSingle().NonLazy();
        }
예제 #8
0
        private MainConfigModel Deserialize(string ConfigFilePath)
        {
            XmlSerializer   serializer = new XmlSerializer(typeof(MainConfigModel));
            MainConfigModel result     = new MainConfigModel();

            using (StreamReader reader = new StreamReader(ConfigFilePath))
            {
                result = (MainConfigModel)serializer.Deserialize(reader);
            }
            return(result);
        }
예제 #9
0
 public static void OnLoad()
 {
     settings = ConfigLoader.LoadSettings();
     if (Instance == null)
     {
         GameObject controller = new GameObject("Counters+ | Controller");
         DontDestroyOnLoad(controller);
         Instance = controller.AddComponent <CountersController>();
         controller.AddComponent <VersionChecker>();
         Plugin.Log("Counters Controller created.", Plugin.LogInfo.Notice);
     }
 }
예제 #10
0
 public void OnGameSceneActive()
 {
     if (PluginManager.EnabledPlugins.Any(x => x.Id == "Counters+"))
     {
         Logger.log.Debug("Counters+ installed");
         MainConfigModel model = ConfigLoader.LoadPPConfig();
         if (model.ppConfig.Enabled)
         {
             new GameObject("PP Counter").AddComponent <PPCounter>();
         }
     }
 }
예제 #11
0
        private static MainConfig ToMainConfig(this MainConfigModel model, DirectoryPath currentDirectory)
        {
            var myDatabase = new DatabaseConfig(new Uri(model.MyDatabase.Host),
                                                (int)uint.Parse(model.MyDatabase.Port),
                                                model.MyDatabase.Username,
                                                model.MyDatabase.Password,
                                                model.MyDatabase.DatabaseName);

            var log = new LogConfig(currentDirectory.CombineFile(model.Log.LogFilePath),
                                    model.Log.Level);

            return(new MainConfig(myDatabase, log));
        }
예제 #12
0
        private void Serialize(MainConfigModel ConfigObject, string FilePath)
        {
            if (!Directory.Exists(Path.GetDirectoryName(FilePath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(FilePath));
            }

            XmlSerializer xsSubmit = new XmlSerializer(typeof(MainConfigModel));

            using (var sww = new StreamWriter(FilePath))
            {
                xsSubmit.Serialize(sww, ConfigObject);
            }
        }
예제 #13
0
        public override void InstallBindings()
        {
            Container.Bind <VersionUtility>().AsSingle().NonLazy();

            MainConfigModel mainConfig = Plugin.MainConfig;

            Container.Bind <MainConfigModel>().FromInstance(mainConfig);
            mainConfig.HUDConfig.MainCanvasSettings.IsMainCanvas = true;
            Container.Bind <HUDConfigModel>().FromInstance(mainConfig.HUDConfig);

            if (harmony != null)
            {
                harmony.UnpatchAll(HARMONY_ID);                  // Covers game restarts
            }
            harmony = new HarmonyObj(HARMONY_ID);
            Container.Bind <HarmonyObj>().WithId(HARMONY_ID).FromInstance(harmony);
            GameplayCoreSceneSetupPatch.Patch(harmony);
            CoreGameHUDControllerPatch.Patch(harmony);

            BindConfig <MissedConfigModel>(mainConfig.MissedConfig);
            BindConfig <NoteConfigModel>(mainConfig.NoteConfig);
            BindConfig <ProgressConfigModel>(mainConfig.ProgressConfig);
            BindConfig <ScoreConfigModel>(mainConfig.ScoreConfig);
            BindConfig <SpeedConfigModel>(mainConfig.SpeedConfig);
            BindConfig <SpinometerConfigModel>(mainConfig.SpinometerConfig);
            BindConfig <PBConfigModel>(mainConfig.PBConfig);
            BindConfig <CutConfigModel>(mainConfig.CutConfig);
            BindConfig <FailConfigModel>(mainConfig.FailsConfig);
            BindConfig <NotesLeftConfigModel>(mainConfig.NotesLeftConfig);

            foreach (CustomCounter customCounter in Plugin.LoadedCustomCounters.Values)
            {
                if (!mainConfig.CustomCounters.TryGetValue(customCounter.Name, out CustomConfigModel config))
                {
                    config = customCounter.ConfigDefaults;
                    mainConfig.CustomCounters.Add(customCounter.Name, config);
                }
                config.AttachedCustomCounter = customCounter;
                customCounter.Config         = config;
                BindCustomCounter(customCounter, config);
            }
        }
예제 #14
0
        public override void InstallBindings()
        {
            Container.Bind <VersionUtility>().AsSingle().NonLazy();

            MainConfigModel mainConfig = Plugin.MainConfig;

            Container.Bind <MainConfigModel>().FromInstance(mainConfig);
            mainConfig.HUDConfig.MainCanvasSettings.IsMainCanvas = true;
            Container.Bind <HUDConfigModel>().FromInstance(mainConfig.HUDConfig);

            BindConfig(mainConfig.MissedConfig);
            BindConfig(mainConfig.NoteConfig);
            BindConfig(mainConfig.ProgressConfig);
            BindConfig(mainConfig.ScoreConfig);
            BindConfig(mainConfig.SpeedConfig);
            BindConfig(mainConfig.SpinometerConfig);
            BindConfig(mainConfig.PBConfig);
            BindConfig(mainConfig.CutConfig);
            BindConfig(mainConfig.FailsConfig);
            BindConfig(mainConfig.NotesLeftConfig);
            BindConfig(mainConfig.MultiplayerRankConfig);

            foreach (CustomCounter customCounter in Plugin.LoadedCustomCounters)
            {
                if (!mainConfig.CustomCounters.TryGetValue(customCounter.Name, out CustomConfigModel config))
                {
                    config = customCounter.ConfigDefaults;
                    mainConfig.CustomCounters.Add(customCounter.Name, config);
                }

                config.DisplayName           = customCounter.Name;
                config.AttachedCustomCounter = customCounter;
                customCounter.Config         = config;
                BindCustomCounter(customCounter, config);
            }

            if (PluginManager.GetPlugin("Heck") != null)
            {
                InstallHeckCompatibility();
            }
        }
예제 #15
0
        /// <summary>
        /// 加载配置文件
        /// </summary>
        /// <returns></returns>
        private bool LoadConfig()
        {
            string configPath = ViewModel.ConfigFilePath;

            if (File.Exists(configPath))
            {
                try
                {
                    MainConfigModel = new MainConfigModel
                    {
                        FilePath              = IniFileReadUtil.ReadIniData("Main", "FilePath", null, configPath),
                        SuccessSimple         = IniFileReadUtil.ReadIniData("Main", "SuccessSimple", null, configPath),
                        SuccessSimpleLocation = IniFileReadUtil.ReadIniData("Main", "SuccessSimpleLocation", null, configPath),
                        SheetNames            = IniFileReadUtil.ReadIniData("Main", "SheetNames", null, configPath).Split(',').ToList(),
                        MainSheetName         = IniFileReadUtil.ReadIniData("Main", "MainSheetName", null, configPath),
                        TemplatePath          = IniFileReadUtil.ReadIniData("Main", "TemplatePath", null, configPath),
                        BodyParamCount        = int.Parse(IniFileReadUtil.ReadIniData("Main", "BodyParamCount", null, configPath)),
                        SubjectParamCount     = int.Parse(IniFileReadUtil.ReadIniData("Main", "SubjectParamCount", null, configPath)),
                        MailToParamCount      = int.Parse(IniFileReadUtil.ReadIniData("Main", "MailToParamCount", null, configPath)),
                        AttachmentCount       = int.Parse(IniFileReadUtil.ReadIniData("Main", "AttachmentCount", null, configPath)),
                    };
                    MailConfigModel = new MailConfigModel
                    {
                        MailTo       = IniFileReadUtil.ReadIniData("Mail", "MailTo", null, configPath),
                        MailAddress  = IniFileReadUtil.ReadIniData("Mail", "MailAddress", null, configPath),
                        MailPassword = IniFileReadUtil.ReadIniData("Mail", "MailPassword", null, configPath),
                        MailSubject  = IniFileReadUtil.ReadIniData("Mail", "MailSubject", null, configPath),
                        SMTPAddress  = IniFileReadUtil.ReadIniData("Mail", "SMTPAddress", null, configPath),
                        Port         = int.Parse(IniFileReadUtil.ReadIniData("Mail", "Port", null, configPath)),
                        EnableSsl    = bool.Parse(IniFileReadUtil.ReadIniData("Mail", "EnableSsl", null, configPath)),
                        Priority     = int.Parse(IniFileReadUtil.ReadIniData("Mail", "Priority", null, configPath)),
                    };
                    foreach (var sheetName in MainConfigModel.SheetNames)
                    {
                        SheetConfigModel sheetConfigModel = new SheetConfigModel
                        {
                            StartingLine           = int.Parse(IniFileReadUtil.ReadIniData(sheetName, "StartingLine", null, configPath)),
                            EndLine                = int.Parse(IniFileReadUtil.ReadIniData(sheetName, "EndLine", null, configPath)),
                            UniquelyIdentifiesLine = IniFileReadUtil.ReadIniData(sheetName, "UniquelyIdentifiesLine", null, configPath),
                        };
                        SheetConfigModels[sheetName] = sheetConfigModel;
                    }
                    for (int i = 0; i < MainConfigModel.BodyParamCount; i++)
                    {
                        BodyParams.Add(IniFileReadUtil.ReadIniData("BodyParams", i.ToString(), null, configPath));
                    }
                    for (int i = 0; i < MainConfigModel.SubjectParamCount; i++)
                    {
                        SubjectParams.Add(IniFileReadUtil.ReadIniData("SubjectParams", i.ToString(), null, configPath));
                    }
                    for (int i = 0; i < MainConfigModel.MailToParamCount; i++)
                    {
                        MailToParams.Add(IniFileReadUtil.ReadIniData("MailToParams", i.ToString(), null, configPath));
                    }
                    for (int i = 0; i < MainConfigModel.AttachmentCount; i++)
                    {
                        Attachments.Add(IniFileReadUtil.ReadIniData("Attachments", i.ToString(), null, configPath));
                    }
                    //加载工作簿相关内容
                    Workbook = LoadWorkbook(MainConfigModel.FilePath);
                    foreach (var sheetName in MainConfigModel.SheetNames)
                    {
                        SheetName2ExcelSheet[sheetName] = LoadWorksheet(Workbook, sheetName);
                    }
                    PushMessage("读取成功。\n");
                    return(true);
                }
                catch (Exception ex)
                {
                    PushMessage("读取失败。\n");
                    PushMessage(ex.Message + "\n");
                    return(false);
                }
            }
            else
            {
                PushMessage("找不到配置文件!\n");
                return(false);
            }
        }
예제 #16
0
 public void SaveConfig(MainConfigModel config, string MainConfigFilePath)
 {
     Serialize(config, MainConfigFilePath);
 }