Example #1
0
        public MainForm()
        {
            InitializeComponent();
            this.FormClosing += OnApplicationClosing;
            videoPanel.Paint += OnVideoPanelPaint;

            // enabled DoubleBuffered property (protected)
            System.Reflection.PropertyInfo aProp =
                typeof(System.Windows.Forms.Control).GetProperty(
                    "DoubleBuffered",
                    System.Reflection.BindingFlags.NonPublic |
                    System.Reflection.BindingFlags.Instance);
            aProp.SetValue(videoPanel, true, null);

            ConfigureInput();

            Console = new NesCore.Console();

            ConfigureProcessor();
            ConfigureVideo();
            ConfigureAudio();
            ConfigureControllers();
            ConfigureNstDatabase();

            gameState = GameState.Stopped;

            // cheat system
            cheatSystem = new CheatSystem(Console.Processor);
        }
Example #2
0
        public Manager()
        {
            Log = new Logger(Defaults.ManagerLogFileName)
            {
                WriteToConsole = true
            };
            Log.Info("Spectrum Plugin Manager started.");

            CheckPaths();
            InitializeSettings();

            HarmonyInstance = HarmonyInstance.Create("Spectrum.Manager");
            HarmonyInstance.PatchAll(AppDomain.CurrentDomain.GetAssemblies().First(asm => asm.GetName().Name == "Spectrum.API"));

            if (!Global.Settings.GetItem <bool>("Enabled"))
            {
                Log.Error("Spectrum is disabled. Set 'Enabled' entry to 'true' in settings to activate plugin functionality.");
                IsEnabled = false;

                return;
            }

            InitializeNetworkOverrides();

            EventRouter = new EventRouter();
            Hotkeys     = new HotkeyManager();
            Menus       = new MenuManager();

            CheatSystem = new CheatSystem(this);

            CheatSystem.CheatStateInfoReceived += (sender, args) =>
            {
                if (!G.Sys.NetworkingManager_.IsServer_)
                {
                    return;
                }


                if (args.CheatStateInfo.AnyCheatsEnabled)
                {
                    if (!Global.Settings.GetItem <bool>("AllowCheatsOnline"))
                    {
#pragma warning disable 618
                        StaticTransceivedEvent <ChatMessage.Data> .Broadcast(new ChatMessage.Data("[FF44FF]Player disconnected due to cheats not being allowed in this game.[-]"));

#pragma warning restore 618
                        UnityEngine.Network.CloseConnection(args.Sender, true);
                    }
                }
            };

            CheatSystem.CheatStateInfoFailure += (sender, args) =>
            {
                if (!G.Sys.NetworkingManager_.IsServer_)
                {
                    return;
                }

                if (Global.Settings.GetItem <bool>("KickCheatRequestFailures"))
                {
#pragma warning disable 618
                    StaticTransceivedEvent <ChatMessage.Data> .Broadcast(new ChatMessage.Data("[FF44FF]Player disconnected because of cheat state verification failure.[-]"));

#pragma warning restore 618
                    UnityEngine.Network.CloseConnection(args.Sender, true);
                }
            };

            LoadExtensions();
            StartExtensions();
        }