Exemplo n.º 1
0
 public void Update()
 {
     if (Input.GetKeyDown(KeyCode.F9))
     {
         NotificationController.Notify(new Notification(
                                           _TestID % 2 == 0 ? _Bullet : null,
                                           $"Achivement Unlocked",
                                           "Unlocked achievement 'Biggest Wallet'\nCollect 300 casings in one run."
                                           )
         {
             BackgroundColor = UnityUtil.NewColorRGB(238, 188, 29),
             TitleColor      = UnityUtil.NewColorRGB(0, 0, 0),
             ContentColor    = UnityUtil.NewColorRGB(55, 55, 55)
         });
         _TestID += 1;
     }
 }
Exemplo n.º 2
0
        public override void PreGameManagerAlive()
        {
            Logger.Info("Initializing SGUI");

            GUIRoot = SGUIRoot.Setup();
            SGUIIMBackend.GetFont = (SGUIIMBackend backend) => {
                System.Console.WriteLine($"GETFONT INSTANCE: {CorePatches.MainMenuFoyerController.Instance}");
                if (CorePatches.MainMenuFoyerController.Instance?.VersionLabel == null)
                {
                    return(null);
                }
                return(FontCache.GungeonFont ?? (FontCache.GungeonFont = FontConverter.DFFontToUnityFont((dfFont)CorePatches.MainMenuFoyerController.Instance.VersionLabel.Font, 2)));
            };

            _GameObject = new GameObject("GUI");
            DontDestroyOnLoad(_GameObject);

            Logger.Info("Initializing menu controller");
            MenuController = _GameObject.AddComponent <MenuController>();
            DontDestroyOnLoad(MenuController);

            Logger.Info("Initializing notification controller");
            NotificationController = _GameObject.AddComponent <NotificationController>();
            DontDestroyOnLoad(NotificationController);

            _Bullet = UnityUtil.LoadTexture2D(Path.Combine(Paths.ResourcesFolder, "bullet.png"));

            AppDomain.CurrentDomain.UnhandledException += (obj, e) => {
                NotificationController.Notify(new Notification(
                                                  title: "An unhandled error has occured",
                                                  content: "More information in the log."
                                                  )
                {
                    BackgroundColor = UnityUtil.NewColorRGB(57, 7, 7)
                });
            };

            ModTheGungeon.ModLoader.LuaError += (info, method, e) => {
                NotificationController.Notify(new Notification(
                                                  title: $"An error has occured while loading mod {info.Name}",
                                                  content: $"The '{method}' method had raised an error. More information in the log."
                                                  )
                {
                    BackgroundColor = UnityUtil.NewColorRGB(57, 7, 7)
                });
            };

            ModTheGungeon.ErrorLoadingMod += (filename, e) => {
                NotificationController.Notify(new Notification(
                                                  title: $"An error has occured while loading '{filename}'",
                                                  content: "More information in the log."
                                                  )
                {
                    BackgroundColor = UnityUtil.NewColorRGB(57, 7, 7)
                });
            };

            ModTheGungeon.ErrorCreatingModsDirectory += (e) => {
                NotificationController.Notify(new Notification(
                                                  title: $"An error has occured while trying to create the Mods directory",
                                                  content: "More information in the log."
                                                  )
                {
                    BackgroundColor = UnityUtil.NewColorRGB(57, 7, 7)
                });
            };

            ModTheGungeon.ModsReloaded += (manual) => {
                if (manual)
                {
                    NotificationController.Notify(new Notification(
                                                      title: $"Reloaded!",
                                                      content: "All mods have been reloaded as a result of pressing the F5 key."
                                                      ));
                }
                else
                {
                    NotificationController.Notify(new Notification(
                                                      title: $"Reloaded!",
                                                      content: "All mods have been reloaded automatically as a result of at least one of them being modified."
                                                      ));
                }
            };
        }