Пример #1
0
        public override bool OnMessage(GUIMessage message)
        {
            switch (message.Message)
            {
            case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT:
            {
                GUIWindowManager.OnResize();
                GUIWindowManager.PreInit();
                GUIGraphicsContext.Save();
                if (m_orgZoomVertical != GUIGraphicsContext.ZoomVertical) // only vertical zoom affects font sizes
                {
                    GUIDialogNotify dlgNotify =
                        (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                    if (dlgNotify != null)
                    {
                        dlgNotify.Reset();
                        dlgNotify.ClearAll();
                        dlgNotify.SetHeading(213);                       // UI Calibration
                        dlgNotify.SetText(GUILocalizeStrings.Get(2650)); // Reloading fonts, please wait...
                        dlgNotify.TimeOut = 1;
                        dlgNotify.DoModal(GUIWindowManager.ActiveWindow);
                    }
                    GUIFontManager.LoadFonts(Config.GetFile(Config.Dir.Skin, GUIGraphicsContext.Skin, "fonts.xml"));
                    GUIFontManager.InitializeDeviceObjects();
                }
            }
            break;

            case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
            {
                base.OnMessage(message);
                m_iSpeed          = 1;
                m_iCountU         = 0;
                m_iCountD         = 0;
                m_iCountL         = 0;
                m_iCountR         = 0;
                m_iMode           = 0;
                m_bModeLocked     = true;
                m_orgZoomVertical = GUIGraphicsContext.ZoomVertical;
                m_iLogWidth       = (int)Math.Round((float)GUIGraphicsContext.Width * (float)GUIGraphicsContext.ZoomHorizontal);
                m_iLogHeight      = (int)Math.Round((float)GUIGraphicsContext.Height * (float)GUIGraphicsContext.ZoomVertical);
                ClampLogicalScreenSize();
                UpdateControlLabel();
                return(true);
            }
            }
            return(base.OnMessage(message));
        }
Пример #2
0
        public override void OnAction(Action action)
        {
            if (action.wID == Action.ActionType.ACTION_HOME || action.wID == Action.ActionType.ACTION_SWITCH_HOME)
            {
                return;
            }

            if ((DateTime.Now.Ticks / 10000) - m_dwLastTime > 500)
            {
                m_iSpeed      = 1;
                m_iCountU     = 0;
                m_iCountD     = 0;
                m_iCountL     = 0;
                m_iCountR     = 0;
                m_bModeLocked = false;
            }
            m_dwLastTime = (DateTime.Now.Ticks / 10000);

            bool bChanged = false;
            int  iXOff    = GUIGraphicsContext.OffsetX;
            int  iYOff    = GUIGraphicsContext.OffsetY;

            int iLogWidthMin  = (int)((float)GUIGraphicsContext.Width * ZOOM_MIN);
            int iLogWidthMax  = (int)((float)GUIGraphicsContext.Width * ZOOM_MAX);
            int iLogHeightMin = (int)((float)GUIGraphicsContext.Height * ZOOM_MIN);
            int iLogHeightMax = (int)((float)GUIGraphicsContext.Height * ZOOM_MAX);

            // Check if screen res change has invalidated
            // the current sizes.
            if (ClampLogicalScreenSize())
            {
                bChanged = true;
            }

            if (action.wID == Action.ActionType.ACTION_PREVIOUS_MENU)
            {
                GUIWindowManager.ShowPreviousWindow();
                return;
            }

            if (m_iSpeed > 10)
            {
                m_iSpeed = 10; // Speed limit for accellerated cursors
            }

            switch (action.wID)
            {
            case Action.ActionType.ACTION_SELECT_ITEM:
            {
                // Cycle modes
                // Only 0,1 currently.
                if (!m_bModeLocked)
                {
                    m_iMode       = 1 - m_iMode;
                    m_bModeLocked = true;
                    bChanged      = true;
                }
            }
            break;

            case Action.ActionType.ACTION_MOVE_LEFT:
            {
                if (m_iCountL == 0)
                {
                    m_iSpeed = 1;
                }

                if (m_iMode == 1)
                {
                    // Zoom
                    if (m_iLogWidth > iLogWidthMin)
                    {
                        m_iLogWidth -= m_iSpeed;
                        bChanged     = true;
                        m_iCountL++;
                        if (m_iCountL > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountL = 1;
                        }
                    }
                }
                else
                {
                    // Offset
                    if (iXOff > -128)
                    {
                        iXOff   -= m_iSpeed;
                        bChanged = true;
                        m_iCountL++;
                        if (m_iCountL > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountL = 1;
                        }
                    }
                }
                m_iCountU = 0;
                m_iCountD = 0;
                m_iCountR = 0;
            }
            break;

            case Action.ActionType.ACTION_MOVE_RIGHT:
            {
                if (m_iCountR == 0)
                {
                    m_iSpeed = 1;
                }

                if (m_iMode == 1)
                {
                    // Zoom
                    if (m_iLogWidth < iLogWidthMax)
                    {
                        m_iLogWidth += m_iSpeed;
                        bChanged     = true;
                        m_iCountR++;
                        if (m_iCountR > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountR = 1;
                        }
                    }
                }
                else
                {
                    // Offset
                    if (iXOff < 128)
                    {
                        iXOff   += m_iSpeed;
                        bChanged = true;
                        m_iCountR++;
                        if (m_iCountR > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountR = 1;
                        }
                    }
                }

                m_iCountU = 0;
                m_iCountD = 0;
                m_iCountL = 0;
            }
            break;

            case Action.ActionType.ACTION_MOVE_UP:
            {
                if (m_iCountU == 0)
                {
                    m_iSpeed = 1;
                }

                if (m_iMode == 1)
                {
                    // Zoom
                    if (m_iLogHeight > iLogHeightMin)
                    {
                        m_iLogHeight -= m_iSpeed;
                        bChanged      = true;
                        m_iCountU++;
                        if (m_iCountU > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountU = 1;
                        }
                    }
                }
                else
                {
                    // Offset
                    if (iYOff > -128)
                    {
                        iYOff   -= m_iSpeed;
                        bChanged = true;
                        m_iCountU++;
                        if (m_iCountU > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountU = 1;
                        }
                    }
                }
                m_iCountD = 0;
                m_iCountL = 0;
                m_iCountR = 0;
            }
            break;

            case Action.ActionType.ACTION_MOVE_DOWN:
            {
                if (m_iCountD == 0)
                {
                    m_iSpeed = 1;
                }

                if (m_iMode == 1)
                {
                    // Zoom
                    if (m_iLogHeight < iLogHeightMax)
                    {
                        m_iLogHeight += m_iSpeed;
                        bChanged      = true;
                        m_iCountD++;
                        if (m_iCountD > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountD = 1;
                        }
                    }
                }
                else
                {
                    if (iYOff < 128)
                    {
                        iYOff   += m_iSpeed;
                        bChanged = true;
                        m_iCountD++;
                        if (m_iCountD > 5)
                        {
                            m_iSpeed += 1;
                            m_iCountD = 1;
                        }
                    }
                }
                m_iCountU = 0;
                m_iCountL = 0;
                m_iCountR = 0;
            }
            break;

            case Action.ActionType.ACTION_CALIBRATE_RESET:
                //if (m_iMode == 1)
                //{
                m_iLogWidth  = GUIGraphicsContext.Width;
                m_iLogHeight = GUIGraphicsContext.Height;
                //}
                //else
                //{
                iXOff = 0;
                iYOff = 0;
                //}
                bChanged  = true;
                m_iSpeed  = 1;
                m_iCountU = 0;
                m_iCountD = 0;
                m_iCountL = 0;
                m_iCountR = 0;
                break;

            case Action.ActionType.ACTION_ANALOG_MOVE:
                float fX = 2 * action.fAmount1;
                float fY = 2 * action.fAmount2;
                if (fX != 0.0 || fY != 0.0)
                {
                    bChanged = true;
                    if (m_iMode == 1)
                    {
                        m_iLogWidth  += (int)fX;
                        m_iLogHeight -= (int)fY;
                    }
                    else
                    {
                        iXOff += (int)fX;
                        if (iXOff < -128)
                        {
                            iXOff = -128;
                        }
                        if (iXOff > 128)
                        {
                            iXOff = 128;
                        }

                        iYOff -= (int)fY;
                        if (iYOff < -128)
                        {
                            iYOff = -128;
                        }
                        if (iYOff > 128)
                        {
                            iYOff = 128;
                        }
                    }
                }
                break;
            }
            // do the movement
            if (bChanged)
            {
                ClampLogicalScreenSize();
                GUIGraphicsContext.OffsetX = iXOff;
                GUIGraphicsContext.OffsetY = iYOff;

                float fZoomHorz = (float)m_iLogWidth / (float)GUIGraphicsContext.Width;
                float fZoomVert = (float)m_iLogHeight / (float)GUIGraphicsContext.Height;

                GUIGraphicsContext.ZoomHorizontal = fZoomHorz;
                GUIGraphicsContext.ZoomVertical   = fZoomVert;

                GUIGraphicsContext.OffsetX        = GUIGraphicsContext.OffsetX;
                GUIGraphicsContext.OffsetY        = GUIGraphicsContext.OffsetY;
                GUIGraphicsContext.ZoomHorizontal = GUIGraphicsContext.ZoomHorizontal;
                GUIGraphicsContext.ZoomVertical   = GUIGraphicsContext.ZoomVertical;

                GUIWindowManager.OnResize();
                GUIWindowManager.PreInit();
                UpdateControlLabel();

                ResetAllControls();
                GUIWindowManager.ResetAllControls();
            }
            base.OnAction(action);
        }