Exemplo n.º 1
0
 public void SubscribeToResizeEventHook(ResizeEventHook hook)
 {
     hook.Resized += sender =>
     {
         ActualAspectRatio   = sender.ActualAspectRatio;
         RelativeAspectRatio = sender.RelativeAspectRatio;
         CurrentWidth        = sender.CurrentWidth;
         CurrentHeight       = sender.CurrentHeight;
     };
 }
        /* Patching hardcoded values in ResolutionVariablePatcher via events. */
        private void MessagePump()
        {
            _resizeEventHook = new ResizeEventHook();
            _resolutionVariablePatcher.SubscribeToResizeEventHook(_resizeEventHook);
            _renderHooks.SubscribeToResizeEventHook(_resizeEventHook);

            while (User32_Gdi.GetMessage(out var msg, HWND.NULL, 0, 0))
            {
                User32_Gdi.TranslateMessage(msg);
                User32_Gdi.DispatchMessage(msg);
            }
        }
        /// <summary>
        /// Patches hardcoded variables unattainable without hooking.
        /// </summary>
        private void HookOnResized(ResizeEventHook sender)
        {
            // Set game resolution variables.
            float floatWidth  = sender.CurrentWidth;
            float floatHeight = sender.CurrentHeight;

            Variables.ResolutionX.SetValue(ref sender.CurrentWidth);
            Variables.ResolutionY.SetValue(ref sender.CurrentHeight);

            Variables.MaestroResolutionX.SetValue(ref floatWidth);
            Variables.MaestroResolutionY.SetValue(ref floatHeight);
        }
 public void SubscribeToResizeEventHook(ResizeEventHook hook)
 {
     hook.Resized += HookOnResized;
 }