static void Main(string[] args)
        {
            Console.CancelKeyPress += HandleCancelKeyPress;

            var presenter        = new ConsolePresenter();
            var quitManager      = new ConsoleQuitManager();
            var saveStateManager = new SaveStateManager();
            var worldGenerator   = new WorldGenerator(new InputReader(), new InputValidator());

            var controller = new GameController(presenter, quitManager, saveStateManager, worldGenerator);

            try
            {
                var world = controller.InitialiseFirstWorld(args);
                controller.Run(world);
            }
            catch (InvalidInputException e)
            {
                presenter.PrintMessage(e.Message, "Red");
            }
            catch (Exception e)
            {
                presenter.PrintMessage($"Unknown error occurred: {e.Message}", "Red");
            }
            Console.CursorVisible = true;
        }
Example #2
0
        public async Task Self_Ready()
        {
            //inits
            DataManager.pp_songs               = Utils.InitPpSong();
            DataManager.people_spam            = new Dictionary <ulong, int>();
            DataManager.actions                = new Dictionary <string, Actions.Action>();
            DataManager.otherActions           = new List <Actions.OtherActions.AOtherAction>();
            DataManager.nsfw_content_inprocess = new Dictionary <IUserMessage, IUserMessage>();
            DataManager.actions_used           = SaveStateManager.Load <Dictionary <string, int> >(DataManager.Binary.POP_ACTIONS_FILE) ?? new Dictionary <string, int>();

            //register des actions
            ActionUtils.RegisterActions("DiscordBot.Actions.CommandActions");
            ActionUtils.RegisterActions("DiscordBot.Actions.AdminActions");
            ActionUtils.RegisterActions("DiscordBot.Actions.DeleteActions");
            ActionUtils.RegisterActions("DiscordBot.Actions.OtherActions");

            //mes setups
            Utils.Init();

            try {
                if (!Utils.IsTestBot)
                {
                    //Thread qui regarde les nouveaux scans
                    new Thread(ThreadUtils.QwerteeThread).Start();
                    new Thread(new JapscanMangaCrawler().Crawl).Start();
                }
                new Thread(ThreadUtils.EmptyPeopleSpamStack).Start();
            }
            catch (System.Exception e) {
                e.Display("Problème Threads Self_Ready");
                await Channels.Problems.SendMessagesAsync(e.Message);
            }

            await Channels.Debugs.SendMessageAsync("Bot ready");
        }
Example #3
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            EmuApi.InitDll();
            ConfigManager.Config.Video.ApplyConfig();
            EmuApi.InitializeEmu(ConfigManager.HomeFolder, Handle, ctrlRenderer.Handle, false, false, false);

            ConfigManager.Config.InitializeDefaults();
            ConfigManager.Config.ApplyConfig();

            _displayManager = new DisplayManager(this, ctrlRenderer, pnlRenderer, mnuMain, ctrlRecentGames);
            _displayManager.UpdateViewerSize();
            _shortcuts = new ShortcutHandler(_displayManager);

            _notifListener = new NotificationListener();
            _notifListener.OnNotification += OnNotificationReceived;

            SaveStateManager.InitializeStateMenu(mnuSaveState, true, _shortcuts);
            SaveStateManager.InitializeStateMenu(mnuLoadState, false, _shortcuts);

            BindShortcuts();

            ctrlRecentGames.Initialize();
            ResizeRecentGames();

            _commandLine.LoadGameFromCommandLine();
            if (!EmuRunner.IsRunning())
            {
                ctrlRecentGames.Visible = true;
            }

            this.Resize += frmMain_Resize;
        }
Example #4
0
 void Start()
 {
     EventDispatcher.StartListening(Vars.LocalClientDisconnect, LocalClientDisconnect);
     EventDispatcher.StartListening(Vars.ServerHandleDisconnect, ServerHandleDisconnect);
     InvokeRepeating("CheckWinState", 0, 1f);
     UiM      = UIManager.Instance;
     SaveData = SaveStateManager.Instance;
     LocalManager.Instance.GameRunning = true;
     CameraControl.Instance.Invoke("ShowAll", 1f);
 }
Example #5
0
        private void OnNotificationReceived(NotificationEventArgs e)
        {
            switch (e.NotificationType)
            {
            case ConsoleNotificationType.GameLoaded:
                this.BeginInvoke((Action)(() => {
                    UpdateDebuggerMenu();
                    ctrlRecentGames.Visible = false;
                    SaveStateManager.UpdateStateMenu(mnuLoadState, false);
                    SaveStateManager.UpdateStateMenu(mnuSaveState, true);

                    RomInfo romInfo = EmuApi.GetRomInfo();
                    this.Text = "Mesen-S - " + romInfo.GetRomName();

                    if (DebugWindowManager.HasOpenedWindow)
                    {
                        DebugWorkspaceManager.GetWorkspace();
                    }
                }));
                break;

            case ConsoleNotificationType.BeforeEmulationStop:
                this.Invoke((Action)(() => {
                    DebugWindowManager.CloseAll();
                }));
                break;

            case ConsoleNotificationType.EmulationStopped:
                this.BeginInvoke((Action)(() => {
                    this.Text = "Mesen-S";
                    UpdateDebuggerMenu();
                    ctrlRecentGames.Initialize();
                    ctrlRecentGames.Visible = true;
                    ResizeRecentGames();
                    if (_displayManager.ExclusiveFullscreen)
                    {
                        _displayManager.SetFullscreenState(false);
                    }
                }));
                break;

            case ConsoleNotificationType.ResolutionChanged:
                this.BeginInvoke((Action)(() => {
                    _displayManager.UpdateViewerSize();
                }));
                break;

            case ConsoleNotificationType.ExecuteShortcut:
                this.BeginInvoke((Action)(() => {
                    _shortcuts.ExecuteShortcut((EmulatorShortcut)e.Parameter);
                }));
                break;
            }
        }
Example #6
0
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else if (Instance != this)
     {
         Destroy(gameObject);
     }
 }
Example #7
0
        protected override void OnShown(EventArgs e)
        {
            base.OnShown(e);

            EmuApi.InitDll();
            bool showUpgradeMessage = UpdateHelper.PerformUpgrade();

            ConfigManager.Config.Video.ApplyConfig();
            EmuApi.InitializeEmu(ConfigManager.HomeFolder, Handle, ctrlRenderer.Handle, false, false, false);

            ConfigManager.Config.InitializeDefaults();
            ConfigManager.Config.ApplyConfig();

            _displayManager = new DisplayManager(this, ctrlRenderer, pnlRenderer, mnuMain, ctrlRecentGames);
            _displayManager.SetScaleBasedOnWindowSize();
            _shortcuts = new ShortcutHandler(_displayManager);

            _notifListener = new NotificationListener();
            _notifListener.OnNotification += OnNotificationReceived;

            _commandLine.LoadGameFromCommandLine();

            SaveStateManager.InitializeStateMenu(mnuSaveState, true, _shortcuts);
            SaveStateManager.InitializeStateMenu(mnuLoadState, false, _shortcuts);
            BindShortcuts();

            Task.Run(() => {
                Thread.Sleep(25);
                this.BeginInvoke((Action)(() => {
                    ResizeRecentGames();
                    ctrlRecentGames.Initialize();

                    if (!EmuRunner.IsRunning())
                    {
                        ctrlRecentGames.Visible = true;
                    }
                }));
            });

            if (showUpgradeMessage)
            {
                MesenMsgBox.Show("UpgradeSuccess", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            if (ConfigManager.Config.Preferences.AutomaticallyCheckForUpdates)
            {
                UpdateHelper.CheckForUpdates(true);
            }

            InBackgroundHelper.StartBackgroundTimer();
            this.Resize += frmMain_Resize;
        }
Example #8
0
        public async Task Self_Ready()
        {
            //inits
            DataManager.database               = new Database();
            DataManager.pp_songs               = Utils.InitPpSong();
            DataManager.mangasData             = Utils.InitMangasData();
            DataManager.people_spam            = new Dictionary <ulong, int>();
            DataManager.actions                = new Dictionary <string, Actions.Action>();
            DataManager.otherActions           = new List <Actions.OtherActions.AOtherAction>();
            DataManager.nsfw_content_inprocess = new Dictionary <IUserMessage, IUserMessage>();
            DataManager.baned_people           = SaveStateManager.Load <List <ulong> >(DataManager.Binary.BANNED_FILE) ?? new List <ulong>();
            DataManager.actions_used           = SaveStateManager.Load <Dictionary <string, int> >(DataManager.Binary.POP_ACTIONS_FILE) ?? new Dictionary <string, int>();

            //TODO déplacer ça dans la config
            ActionUtils.RegisterActions("DiscordBot.Actions.CommandActions");
            ActionUtils.RegisterActions("DiscordBot.Actions.AdminActions");
            ActionUtils.RegisterActions("DiscordBot.Actions.DeleteActions");
            ActionUtils.RegisterActions("DiscordBot.Actions.OtherActions");

            //mes setups
            Utils.Init();
            DataManager.guild = DataManager._client.GetGuild(309407896070782976);

            try {
                if (!Utils.IsTestBot)
                {
                    //Thread qui regarde les nouveaux scans
                    new Thread(ThreadUtils.MangasCrawlerOnLireScanV2).Start();
                }

                new Thread(ThreadUtils.EmptyBannedPeopleStack).Start();
            }
            catch (System.Exception e) {
                e.DisplayException("Threads ready");
                await Channels.Problems.SendMessagesAsync(e.Message);
            }

            await Channels.Debugs.SendMessageAsync("Bot ready");
        }
Example #9
0
 private void mnuSaveState_DropDownOpening(object sender, EventArgs e)
 {
     SaveStateManager.UpdateStateMenu(mnuSaveState, true);
 }
Example #10
0
        private void OnNotificationReceived(NotificationEventArgs e)
        {
            switch (e.NotificationType)
            {
            case ConsoleNotificationType.GameLoaded:
                CheatCodes.ApplyCheats();

                this.BeginInvoke((Action)(() => {
                    UpdateDebuggerMenu();
                    ctrlRecentGames.Visible = false;
                    SaveStateManager.UpdateStateMenu(mnuLoadState, false);
                    SaveStateManager.UpdateStateMenu(mnuSaveState, true);

                    RomInfo romInfo = EmuApi.GetRomInfo();
                    this.Text = "Mesen-S - " + romInfo.GetRomName();

                    if (DebugWindowManager.HasOpenedWindow)
                    {
                        DebugWorkspaceManager.GetWorkspace();
                    }
                }));
                break;

            case ConsoleNotificationType.BeforeEmulationStop:
                this.Invoke((Action)(() => {
                    DebugWindowManager.CloseAll();
                }));
                break;

            case ConsoleNotificationType.GameResumed:
                this.BeginInvoke((Action)(() => {
                    //Ensure mouse is hidden when game is resumed
                    CursorManager.OnMouseMove(ctrlRenderer);
                }));
                break;

            case ConsoleNotificationType.EmulationStopped:
                this.BeginInvoke((Action)(() => {
                    this.Text = "Mesen-S";
                    UpdateDebuggerMenu();
                    ShowGameScreen(GameScreenMode.RecentGames);
                    ResizeRecentGames();
                    if (_displayManager.ExclusiveFullscreen)
                    {
                        _displayManager.SetFullscreenState(false);
                    }
                }));
                break;

            case ConsoleNotificationType.ResolutionChanged:
                this.BeginInvoke((Action)(() => {
                    _displayManager.UpdateViewerSize();
                }));
                break;

            case ConsoleNotificationType.ExecuteShortcut:
                this.BeginInvoke((Action)(() => {
                    _shortcuts.ExecuteShortcut((EmulatorShortcut)e.Parameter);
                }));
                break;

            case ConsoleNotificationType.MissingFirmware:
                this.Invoke((Action)(() => {
                    MissingFirmwareMessage msg = (MissingFirmwareMessage)Marshal.PtrToStructure(e.Parameter, typeof(MissingFirmwareMessage));
                    FirmwareHelper.RequestFirmwareFile(msg);
                }));
                break;
            }
        }