private IOperation BuildMouseInterceptorOperation()
        {
            var mouseInterceptor = new MouseInterceptor(ModuleLogger(nameof(MouseInterceptor)), nativeMethods, context.Settings.Mouse);
            var operation        = new MouseInterceptorOperation(context, logger, mouseInterceptor);

            return(operation);
        }
Пример #2
0
        private IOperation BuildMouseInterceptorOperation()
        {
            var mouseInterceptor = new MouseInterceptor(new ModuleLogger(logger, nameof(MouseInterceptor)), configuration.Settings.Mouse);
            var operation        = new MouseInterceptorOperation(logger, mouseInterceptor, nativeMethods);

            return(operation);
        }
Пример #3
0
        static TextBox()
        {
            _sharedInterceptor            = new MouseInterceptor();
            _sharedInterceptor.MouseLeft += delegate { _sharedInterceptor.Hide(); };
            _sharedInterceptor.LeftMouseButtonReleased += delegate { _sharedInterceptor.Hide(); };

            // This is needed to ensure that the textbox is *actually* unfocused
            _sharedUnfocusLabel = new System.Windows.Forms.Label {
                Location = new System.Drawing.Point(-200, 0),
                Parent   = BlishHud.Form
            };

            _textureTextbox = Content.GetTexture("textbox");
        }
Пример #4
0
        /// <summary>
        /// Run the Player
        /// </summary>
        /// <param name="screenSaver"></param>
        private static void RunClient(bool screenSaver)
        {
            Trace.WriteLine(new LogMessage("Main", "Client Started"), LogType.Info.ToString());

            KeyInterceptor.SetHook();
            if (screenSaver)
            {
                MouseInterceptor.SetHook();
            }

            MainWindow windowMain = new MainWindow(screenSaver);

            windowMain.ShowDialog();

            KeyInterceptor.UnsetHook();
            if (screenSaver)
            {
                MouseInterceptor.UnsetHook();
            }
        }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        if (UniversalReference.MouseScreenPosDelta != new Vector2(0, 0))
        {
            if (ActivelyAiming)
            {
                gunRotatorHand.AimGun(UniversalReference.MouseWorldPos);
            }
            else
            {
                gunRotatorHand.HoldGun(UniversalReference.MouseWorldPos);
            }
        }

        Vector2 MouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        entity.LookingToward = MouseWorldPos;

        //true if looking right, false if looking left
        bool LookingRight = entity.LookingToward.x > transform.position.x;


        //decreasing active cooldowns
        if (CurrShootingWindDownDuration > 0)
        {
            //when decreasing cooldowns, always use Time.deltaTime (the time it took to render last frame, in seconds) - framerate independent
            CurrShootingWindDownDuration -= Time.deltaTime;
        }
        if (CurrShootingCooldown > 0)
        {
            CurrShootingCooldown -= Time.deltaTime;
        }


        //inaccuracy
        Inaccuracy += UniversalReference.PlayerRb.velocity.magnitude / 30;

        //inaccuracy starts decreasing only when it has not increased
        if (Inaccuracy <= InaccuracyInLastFrame && InaccuracyRecoveryBlock <= 0)
        {
            if (Inaccuracy > InaccuracyMin)
            {
                Inaccuracy -= Time.deltaTime * InaccuracyRecoveryFactor; //decreased by 1 every second (can be different for balance purposes)
            }
        }

        if (InaccuracyRecoveryBlock > 0)
        {
            InaccuracyRecoveryBlock -= Time.deltaTime;
        }

        if (Inaccuracy > InaccuracyMax)
        {
            Inaccuracy = InaccuracyMax;
        }
        if (Inaccuracy < InaccuracyMin)
        {
            Inaccuracy = InaccuracyMin;
        }

        InaccuracyInLastFrame = Inaccuracy;

        /*
         *
         * //when not firing/aiming, hold the gun in resting position
         * if(Input.GetKey(KeyCode.Mouse0) || Input.GetKey(KeyCode.Mouse1) || CurrShootingWindDownDuration > 0)
         * {
         *  smg.ActivelyAiming = true;
         * }
         * else
         * {
         *  smg.ActivelyAiming = false;
         * }
         *
         */

        #region  Movement

        //movement vector will hold information about direction, speed is added after, in Entity script
        //you cannot walk when mouse is dragging a window, that causes problems (though MovementVector has to be set to 0 stop previous movement)
        Vector2 MovementVector = new Vector2(0, 0);
        if (MouseInterceptor.IsMouseAvailable())
        {
            if (Input.GetKey(KeybindManager.MoveUp))
            {
                MovementVector += new Vector2(0, 1);
                LegsManager.RequestRunUp(LookingRight);
            }
            if (Input.GetKey(KeybindManager.MoveDown))
            {
                MovementVector += new Vector2(0, -1);
                LegsManager.RequestRunDown(LookingRight);
            }
            if (Input.GetKey(KeybindManager.MoveLeft))
            {
                MovementVector += new Vector2(-1, 0);
                LegsManager.RequestRunLeft(LookingRight);
            }
            if (Input.GetKey(KeybindManager.MoveRight))
            {
                MovementVector += new Vector2(1, 0);
                LegsManager.RequestRunRight(LookingRight);
            }
            entity.MoveInDirection(MovementVector);
        }

        if (MovementVector.x < 0.01f && MovementVector.x > -0.01f && MovementVector.y < 0.01f && MovementVector.y > -0.01f)
        {
            LegsManager.RequestIdle(entity.LookingToward);
        }

        #endregion


        float HealthRatio = entity.Health / entity.MaxHealth;
        if (HealthRatio < 0.5f)
        {
            LowHealthOverlay.color = new Color(LowHealthOverlay.color.r, LowHealthOverlay.color.g, LowHealthOverlay.color.b,
                                               (0.5f - HealthRatio) * 0.85f
                                               );
        }
        else
        {
            LowHealthOverlay.color = new Color(LowHealthOverlay.color.r, LowHealthOverlay.color.g, LowHealthOverlay.color.b, 0);
        }

        #region StuffForTestingPurposes

        if (Input.GetKeyDown(KeyCode.F10))
        {
            //export navmap as text

            //hard path means Drive:/path - the complete path, not relative to application directory
            NavTestStatic.ExportNavMap();

            Debug.Log("hi");
        }

        if (Input.GetKeyUp(KeyCode.T))
        {
            AlphabetManager.SpawnFloatingText("Hi!", new Vector3(transform.position.x, transform.position.y, -35));
        }

        if (Input.GetKey(KeyCode.P))
        {
            SpamParticlesToFuckWithFramerate();
        }
        if (Input.GetKey(KeyCode.O))
        {
            SpamOptimisedParticlesToFuckWithFramerate();
        }
        if (Input.GetKey(KeyCode.I))
        {
            SpamListParticlesToFuckWithFramerate();
        }


        #endregion

        #region CheatCodes

        if (CheatManager.LastCheat == "GODMODE" || CheatManager.LastCheat == "GM")
        {
            entity.MaxHealth     = float.MaxValue;
            entity.Health        = float.MaxValue;
            entity.BaseMoveSpeed = 25;
        }

        if (CheatManager.LastCheat == "NUKE")
        {
            //ExplosionFrag.SpawnOriginal(Util.Vector3To2Int(transform.position), 100, 10);
            ExplosionFrag.SpawnOriginal(Util.Vector3To2Int(transform.position), 100);
        }

        if (CheatManager.LastCheat == "KILLALL" || CheatManager.LastCheat == "KA")
        {
            foreach (Entity e in GameObject.FindObjectsOfType <Entity>())
            {
                if (e.Team == Entity.team.Enemy)
                {
                    Destroy(e.gameObject);
                }
            }
        }

        if (CheatManager.LastCheat == "NAVDRAW") // Nav Draw
        {
            for (int x = 0; x < NavTestStatic.MapWidth; x++)
            {
                for (int y = 0; y < NavTestStatic.MapHeight; y++)
                {
                    if (!NavTestStatic.IsTileWalkable(x, y))
                    {
                        GameObject go = new GameObject();
                        go.transform.position = new Vector3(x, y, -10);
                        go.AddComponent <SpriteRenderer>().sprite = UniversalReference.Pixel;
                        go.GetComponent <SpriteRenderer>().color  = new Color(1, 0, 0, 0.6f);
                    }
                }
            }
        }

        if (CheatManager.LastCheat == "NAVDRAWLIGHT") // Nav Draw Light
        {
            for (int x = 0; x < NavTestStatic.MapWidth; x++)
            {
                for (int y = 0; y < NavTestStatic.MapHeight; y++)
                {
                    if (!NavTestStatic.CanLightPassThroughTile(x, y))
                    {
                        GameObject go = new GameObject();
                        go.transform.position = new Vector3(x, y, -10);
                        go.AddComponent <SpriteRenderer>().sprite = UniversalReference.Pixel;
                        go.GetComponent <SpriteRenderer>().color  = new Color(1, 1, 0, 0.6f);
                    }
                }
            }
        }

        if (CheatManager.LastCheat == "NAVDRAWEXPLOSION") // Nav Draw Explosion
        {
            for (int x = 0; x < NavTestStatic.MapWidth; x++)
            {
                for (int y = 0; y < NavTestStatic.MapHeight; y++)
                {
                    if (!NavTestStatic.CanExplosionPassThroughTile(new Vector2Int(x, y)))
                    {
                        GameObject go = new GameObject();
                        go.transform.position = new Vector3(x, y, -10);
                        go.AddComponent <SpriteRenderer>().sprite = UniversalReference.Pixel;
                        go.GetComponent <SpriteRenderer>().color  = new Color(1, 0.5f, 0, 0.6f);
                    }
                }
            }
        }


        //deals 10 000 damage to every enemy entity
        if (CheatManager.LastCheat == "KARTHUS") // Karthus
        {
            foreach (Entity e in GameObject.FindObjectsOfType <Entity>())
            {
                if (e.Team == Entity.team.Enemy)
                {
                    e.TakeDamage(10000, DamagerInflicter.WeaponTypes.Undefined);
                }
            }
        }


        //sets every enemy entity's base movespeed to 0
        if (CheatManager.LastCheat == "FREEZE") // Freeze
        {
            foreach (Entity e in GameObject.FindObjectsOfType <Entity>())
            {
                if (e.Team == Entity.team.Enemy)
                {
                    e.BaseMoveSpeed = 0;
                }
            }
        }


        //sets every enemy entity's team to player
        if (CheatManager.LastCheat == "CHARM") // Charm
        {
            foreach (Entity e in GameObject.FindObjectsOfType <Entity>())
            {
                if (e.Team == Entity.team.Enemy)
                {
                    e.Team = Entity.team.Player;
                }
            }
        }

        //teleport player to cursor location
        if (CheatManager.LastCheat == "TP") // Tp (teleport)
        {
            Vector2 Target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            transform.position = new Vector3(Target.x, Target.y, 0);
        }


        //deals 10 000 damage to every environment object
        if (CheatManager.LastCheat == "EARTHQUAKE") // Earthquake
        {
            //not doing this with simple foreach as something messes with the collection, i think its the wallsegments or something
            //EDIT: the problem still exists, only +- 90% of walls are destroyed, some remain, and can be destroyed by weapons, but not with this

            EnvironmentObject[] e = GameObject.FindObjectsOfType <EnvironmentObject>();
            int limit             = e.Length;

            for (int i = 0; i < limit; i++)
            {
                if (e[i] != null)
                {
                    e[i].TakeDamage(10000);
                }
            }
        }



        #endregion

        #region Input

        if (Input.GetKeyDown(KeybindManager.UseItem))
        {
            if (CurrentlyEquippedItem != null)
            {
                CurrentlyEquippedItem.DoYourThing();
            }
        }

        if (Input.GetKeyUp(KeyCode.F5))
        {
            SaverLoader.QuickSave(spriteManagerHand);
        }

        //quickload
        if (Input.GetKeyUp(KeyCode.F6))
        {
            SaverLoader.QuickLoad(spriteManagerHand);

            //Debug.Log("Quickload Complete.");
        }

        if (Input.GetKey(KeybindManager.MousePrimary) && MouseInterceptor.IsMouseAvailable())
        {
            CurrentlyEquippedWeapon.TryShooting(MouseWorldPos);
        }
        if (Input.GetKey(KeybindManager.AltFire))
        {
            CurrentlyEquippedWeapon.TryAltFire();
            CurrentlyEquippedWeapon.TryAltFire(MouseWorldPos);
        }
        if (Input.GetKey(KeybindManager.Reload))
        {
            CurrentlyEquippedWeapon.ForceReload();
        }

        #endregion
    }
Пример #6
0
        static int Main(string[] args)
        {
            NativeMethods.SetErrorMode(NativeMethods.SetErrorMode(0) |
                                       ErrorModes.SEM_NOGPFAULTERRORBOX |
                                       ErrorModes.SEM_FAILCRITICALERRORS |
                                       ErrorModes.SEM_NOOPENFILEERRORBOX);


            // Ensure our process has the highest priority
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;

            Application.SetCompatibleTextRenderingDefault(false);

#if !DEBUG
            // Catch unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.ThreadException           += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
#endif

            // Add the Xibo Tracelistener
            Trace.Listeners.Add(new XiboTraceListener());

            try
            {
                // Check for any passed arguments
                if (args.Length > 0)
                {
                    if (args[0].ToString() == "o")
                    {
                        RunSettings();
                    }
                    else
                    {
                        switch (args[0].ToLower().Trim().Substring(0, 2))
                        {
                        // Preview the screen saver
                        case "/p":
                            // args[1] is the handle to the preview window
                            KeyInterceptor.SetHook();
                            MouseInterceptor.SetHook();
                            RunClient(new IntPtr(long.Parse(args[1])));
                            KeyInterceptor.UnsetHook();
                            MouseInterceptor.UnsetHook();
                            break;

                        // Show the screen saver
                        case "/s":
                            KeyInterceptor.SetHook();
                            MouseInterceptor.SetHook();
                            RunClient(true);
                            KeyInterceptor.UnsetHook();
                            MouseInterceptor.UnsetHook();
                            break;

                        // Configure the screesaver's settings
                        case "/c":
                            // Show the settings form
                            RunSettings();
                            break;

                        // Show the screen saver
                        default:
                            KeyInterceptor.SetHook();
                            MouseInterceptor.SetHook();
                            RunClient(true);
                            KeyInterceptor.UnsetHook();
                            MouseInterceptor.UnsetHook();
                            break;
                        }
                    }
                }
                else
                {
                    // Add a message filter
                    Application.AddMessageFilter(KeyStore.Instance);

                    // No arguments were passed - we run the usual client
                    RunClient();
                }
            }
            catch (Exception ex)
            {
                HandleUnhandledException(ex);
            }

            // Always flush at the end
            Trace.WriteLine(new LogMessage("Main", "Application Finished"), LogType.Info.ToString());
            Trace.Flush();

            return(0);
        }
Пример #7
0
        static int Main(string[] args)
        {
            NativeMethods.SetErrorMode(NativeMethods.SetErrorMode(0) |
                                       ErrorModes.SEM_NOGPFAULTERRORBOX |
                                       ErrorModes.SEM_FAILCRITICALERRORS |
                                       ErrorModes.SEM_NOOPENFILEERRORBOX);

            // Do we need to initialise CEF?
            if (ApplicationSettings.Default.UseCefWebBrowser)
            {
                try
                {
                    CefRuntime.Load();
                }
                catch (DllNotFoundException ex)
                {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(1);
                }
                catch (CefRuntimeException ex)
                {
                    MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(2);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(3);
                }

                var settings = new CefSettings();
                settings.MultiThreadedMessageLoop = true;
                settings.SingleProcess            = false;
                settings.LogSeverity         = CefLogSeverity.Disable;
                settings.LogFile             = "cef.log";
                settings.ResourcesDirPath    = System.IO.Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetEntryAssembly().CodeBase).LocalPath);
                settings.RemoteDebuggingPort = 20480;

                CefRuntime.Initialize(new CefMainArgs(args), settings, null, IntPtr.Zero);
            }

            // Ensure our process has the highest priority
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;

            Application.SetCompatibleTextRenderingDefault(false);

#if !DEBUG
            // Catch unhandled exceptions
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.ThreadException           += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
#endif

            // Add the Xibo Tracelistener
            Trace.Listeners.Add(new XiboTraceListener());

            try
            {
                // Check for any passed arguments
                if (args.Length > 0)
                {
                    if (args[0].ToString() == "o")
                    {
                        RunSettings();
                    }
                    else
                    {
                        switch (args[0].ToLower().Trim().Substring(0, 2))
                        {
                        // Preview the screen saver
                        case "/p":
                            // args[1] is the handle to the preview window
                            KeyInterceptor.SetHook();
                            MouseInterceptor.SetHook();
                            RunClient(new IntPtr(long.Parse(args[1])));
                            KeyInterceptor.UnsetHook();
                            MouseInterceptor.UnsetHook();
                            break;

                        // Show the screen saver
                        case "/s":
                            KeyInterceptor.SetHook();
                            MouseInterceptor.SetHook();
                            RunClient(true);
                            KeyInterceptor.UnsetHook();
                            MouseInterceptor.UnsetHook();
                            break;

                        // Configure the screesaver's settings
                        case "/c":
                            // Show the settings form
                            RunSettings();
                            break;

                        // Show the screen saver
                        default:
                            KeyInterceptor.SetHook();
                            MouseInterceptor.SetHook();
                            RunClient(true);
                            KeyInterceptor.UnsetHook();
                            MouseInterceptor.UnsetHook();
                            break;
                        }
                    }
                }
                else
                {
                    // Add a message filter
                    Application.AddMessageFilter(KeyStore.Instance);

                    // No arguments were passed - we run the usual client
                    RunClient();
                }
            }
            catch (Exception ex)
            {
                HandleUnhandledException(ex);
            }

            // Always flush at the end
            Trace.WriteLine(new LogMessage("Main", "Application Finished"), LogType.Info.ToString());
            Trace.Flush();

            if (ApplicationSettings.Default.UseCefWebBrowser)
            {
                CefRuntime.Shutdown();
            }

            return(0);
        }
Пример #8
0
        protected override void OnStartup(StartupEventArgs e)
        {
            NativeMethods.SetErrorMode(NativeMethods.SetErrorMode(0) |
                                       ErrorModes.SEM_NOGPFAULTERRORBOX |
                                       ErrorModes.SEM_FAILCRITICALERRORS |
                                       ErrorModes.SEM_NOOPENFILEERRORBOX);

            // Ensure our process has the highest priority
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;

            //Application.SetCompatibleTextRenderingDefault(false);

#if !DEBUG
            // Catch unhandled exceptions
            //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            //Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            //TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
#endif
            // Add the Xibo Tracelistener

            Trace.Listeners.Add(new XiboTraceListener());

            //e.Args is the string[] of command line argruments

            try
            {
                // Check for any passed arguments
                if (e.Args.Length > 0)
                {
                    if (e.Args[0].ToString() == "o")
                    {
                        RunSettings();
                    }
                    else
                    {
                        //RunClient();
                        switch (e.Args[0].ToLower().Trim().Substring(0, 2))
                        //switch (argvalue)
                        {
                        // Preview the screen saver
                        case "/p":
                            // args[1] is the handle to the preview window
                            KeyInterceptor.SetHook();
                            MouseInterceptor.SetHook();
                            RunClient(new IntPtr(long.Parse(e.Args[1])));
                            KeyInterceptor.UnsetHook();
                            MouseInterceptor.UnsetHook();
                            break;

                        // Show the screen saver
                        case "/s":
                            KeyInterceptor.SetHook();
                            MouseInterceptor.SetHook();
                            RunClient(true);
                            KeyInterceptor.UnsetHook();
                            MouseInterceptor.UnsetHook();
                            break;

                        // Configure the screesaver's settings
                        case "/c":
                            // Show the settings form
                            RunSettings();
                            break;

                        // Show the screen saver
                        default:
                            KeyInterceptor.SetHook();
                            MouseInterceptor.SetHook();
                            RunClient(true);
                            KeyInterceptor.UnsetHook();
                            MouseInterceptor.UnsetHook();
                            break;
                        }
                    }
                }
                else
                {
                    RunClient();
                }
            }
            catch (Exception ex)
            {
                HandleUnhandledException(ex);
            }
        }