Ejemplo n.º 1
0
        public override void Render(float timePassed)
        {
            base.Render(timePassed);
            //RenderDlg(timePassed);

            if (null == coverArtTexture)
            {
                return;
            }

            if (null != imgCoverArt)
            {
                float x = (float)imgCoverArt.XPosition;
                float y = (float)imgCoverArt.YPosition;
                int   width;
                int   height;
                GUIGraphicsContext.Correct(ref x, ref y);

                int maxWidth  = imgCoverArt.Width;
                int maxHeight = imgCoverArt.Height;
                GUIGraphicsContext.GetOutputRect(coverArtTextureWidth, coverArtTextureHeight, maxWidth, maxHeight, out width,
                                                 out height);

                GUIFontManager.Present();
                Util.Picture.RenderImage(coverArtTexture, (int)x, (int)y, width, height, coverArtTextureWidth,
                                         coverArtTextureHeight, 0, 0, true);
            }
        }
        public void RevertSkin()
        {
            //int ActiveWindowID = GUIWindowManager.ActiveWindow;
            // Change skin back to OutdatedSkinName
            GUIGraphicsContext.Skin = _userSkin;
            GUITextureManager.Clear();
            GUITextureManager.Init();
            SkinSettings.Load();
            GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml"));
            GUIFontManager.InitializeDeviceObjects();
            GUIExpressionManager.ClearExpressionCache();
            GUIControlFactory.ClearReferences();
            GUIControlFactory.LoadReferences(GUIGraphicsContext.GetThemedSkinFile(@"\references.xml"));
            GUIWindowManager.OnResize();
            //GUIWindowManager.ActivateWindow(ActiveWindowID);

            using (Settings xmlreader = new MPSettings())
            {
                xmlreader.SetValue("general", "skinobsoletecount", 0);
                if (!GUIGraphicsContext.Fullscreen)
                {
                    try
                    {
                        GUIGraphicsContext.form.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("OnSkinChanged exception:{0}", ex.ToString());
                        Log.Error(ex);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static void Render(float timePassed)
        {
            if (GUIGraphicsContext.BlankScreen)
            {
                return;
            }
            int videoLayer = (int)LayerType.Video;

            if (GUIGraphicsContext.ShowBackground == false)
            {
                if (_layers[videoLayer] != null)
                {
                    if (_layers[videoLayer].ShouldRenderLayer())
                    {
                        _layers[videoLayer].RenderLayer(timePassed);
                        GUIFontManager.Present();
                    }
                }
            }
            for (int i = 0; i < MAX_LAYERS; ++i)
            {
                if (_layers[i] != null)
                {
                    if (_layers[i].ShouldRenderLayer())
                    {
                        if (GUIGraphicsContext.ShowBackground == false && i == videoLayer)
                        {
                            continue;
                        }
                        _layers[i].RenderLayer(timePassed);
                        GUIFontManager.Present();
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void OnSkinChanged()
        {
            // Backup the buttons, needed later
            BackupButtons();

            // Set the skin to the selected skin and reload GUI
            GUIGraphicsContext.Skin = _btnSkin.Label;
            SaveSettings();
            GUITextureManager.Clear();
            GUITextureManager.Init();
            SkinSettings.Load();
            GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml"));
            GUIFontManager.InitializeDeviceObjects();
            GUIExpressionManager.ClearExpressionCache();
            GUIControlFactory.ClearReferences();
            GUIControlFactory.LoadReferences(GUIGraphicsContext.GetThemedSkinFile(@"\references.xml"));
            GUIWindowManager.OnResize();
            GUIWindowManager.ActivateWindow(GetID);
            GUIControl.FocusControl(GetID, _btnSkin.GetID);

            // Apply the selected buttons again, since they are cleared when we reload
            RestoreButtons();
            using (Settings xmlreader = new MPSettings())
            {
                xmlreader.SetValue("general", "skinobsoletecount", 0);
                if (!GUIGraphicsContext.Fullscreen)
                {
                    try
                    {
                        var border = new Size(GUIGraphicsContext.form.Width - GUIGraphicsContext.form.ClientSize.Width,
                                              GUIGraphicsContext.form.Height - GUIGraphicsContext.form.ClientSize.Height);
                        if (GUIGraphicsContext.SkinSize.Width + border.Width <= GUIGraphicsContext.currentScreen.WorkingArea.Width &&
                            GUIGraphicsContext.SkinSize.Height + border.Height <= GUIGraphicsContext.currentScreen.WorkingArea.Height)
                        {
                            GUIGraphicsContext.form.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height);
                        }
                        else
                        {
                            double ratio = Math.Min((double)(GUIGraphicsContext.currentScreen.WorkingArea.Width - border.Width) / GUIGraphicsContext.SkinSize.Width,
                                                    (double)(GUIGraphicsContext.currentScreen.WorkingArea.Height - border.Height) / GUIGraphicsContext.SkinSize.Height);
                            GUIGraphicsContext.form.ClientSize = new Size((int)(GUIGraphicsContext.SkinSize.Width * ratio), (int)(GUIGraphicsContext.SkinSize.Height * ratio));
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error("OnSkinChanged exception:{0}", ex.ToString());
                        Log.Error(ex);
                    }
                }
            }
            if (BassMusicPlayer.Player != null && BassMusicPlayer.Player.VisualizationWindow != null)
            {
                BassMusicPlayer.Player.VisualizationWindow.Reinit();
            }

            // Send a message that the skin has changed.
            var msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SKIN_CHANGED, 0, 0, 0, 0, 0, null);

            GUIGraphicsContext.SendMessage(msg);
        }
Ejemplo n.º 5
0
        private static void InsertGroupHeader(int index, string groupLabel)
        {
            // create label text
            string labelText = "--- " + groupLabel + " ";
            float  textwidth = 0; float textheight = 0;
            int    iterationCap = 100;

            while (textwidth <= Browser.Facade.ListLayout().Width)
            {
                GUIFontManager.GetFont(Browser.Facade.ListLayout().FontName).GetTextExtent(labelText, ref textwidth, ref textheight);
                labelText += "-";

                if (iterationCap-- <= 0)
                {
                    break;
                }
            }
            // remove 1 char
            labelText = labelText.Substring(0, labelText.Length - 1);

            GUIListItem groupItem = new GUIListItem();

            groupItem.Label3 = labelText;  // use the textColor3

            Browser.Facade.Insert(index, groupItem);

            groupItem.OnItemSelected += new MediaPortal.GUI.Library.GUIListItem.ItemSelectedHandler(onGroupHeaderSelected);
        }
Ejemplo n.º 6
0
        private static void GetCharFonSize(int fontSize, ref int width, ref int height)
        {
            float w1 = 0, w2 = 0, h1 = 0, h2 = 0;

            GUIFontManager.MeasureText("_", ref w1, ref h1, fontSize);
            GUIFontManager.MeasureText("__", ref w2, ref h2, fontSize);

            width  = (int)(w2 - w1);
            height = (int)h1;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Create a banner image of the specified Size, outputting the input text on it
        /// </summary>
        /// <param name="sizeImage">Size of the image to be generated</param>
        /// <param name="label">Text to be output on the image</param>
        /// <returns>a bitmap object</returns>
        private static Bitmap drawSimpleBanner(Size sizeImage, string label)
        {
            Bitmap   image = new Bitmap(sizeImage.Width, sizeImage.Height);
            Graphics gph   = Graphics.FromImage(image);
            //gph.FillRectangle(new SolidBrush(Color.FromArgb(50, Color.White)), new Rectangle(0, 0, sizeImage.Width, sizeImage.Height));
            GUIFont fontList = GUIFontManager.GetFont(s_sFontName);
            Font    font     = new Font(fontList.FontName, 36);

            gph.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            gph.DrawString(label, font, new SolidBrush(Color.FromArgb(200, Color.White)), 5, (sizeImage.Height - font.GetHeight()) / 2);
            gph.Dispose();
            return(image);
        }
Ejemplo n.º 8
0
        private void OnSkinChanged()
        {
            // Backup the buttons, needed later
            BackupButtons();

            // Set the skin to the selected skin and reload GUI
            GUIGraphicsContext.Skin = btnSkin.Label;
            SaveSettings();
            GUITextureManager.Clear();
            GUITextureManager.Init();
            SkinSettings.Load();
            GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml"));
            GUIFontManager.InitializeDeviceObjects();
            GUIExpressionManager.ClearExpressionCache();
            GUIControlFactory.ClearReferences();
            GUIControlFactory.LoadReferences(GUIGraphicsContext.GetThemedSkinFile(@"\references.xml"));
            GUIWindowManager.OnResize();
            GUIWindowManager.ActivateWindow(GetID);
            GUIControl.FocusControl(GetID, btnSkin.GetID);

            // Apply the selected buttons again, since they are cleared when we reload
            RestoreButtons();
            using (Settings xmlreader = new MPSettings())
            {
                xmlreader.SetValue("general", "skinobsoletecount", 0);
                bool autosize = xmlreader.GetValueAsBool("gui", "autosize", true);
                if (autosize && !GUIGraphicsContext.Fullscreen)
                {
                    try
                    {
                        GUIGraphicsContext.form.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height);
                        //Form.ActiveForm.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("OnSkinChanged exception:{0}", ex.ToString());
                        Log.Error(ex);
                    }
                }
            }
            if (BassMusicPlayer.Player != null && BassMusicPlayer.Player.VisualizationWindow != null)
            {
                BassMusicPlayer.Player.VisualizationWindow.Reinit();
            }

            // Send a message that the skin has changed.
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SKIN_CHANGED, 0, 0, 0, 0, 0, null);

            GUIGraphicsContext.SendMessage(msg);
        }
Ejemplo n.º 9
0
 private void OnLanguageChanged()
 {
     // Backup the buttons, needed later
     BackupButtons();
     SaveSettings();
     GUILocalizeStrings.ChangeLanguage(_btnLanguage.Label);
     GUIFontManager.LoadFonts(GUIGraphicsContext.GetThemedSkinFile(@"\fonts.xml"));
     GUIFontManager.InitializeDeviceObjects();
     GUIWindowManager.OnResize();
     GUIWindowManager.ActivateWindow(GetID); // without this you cannot change skins / lang any more..
     GUIControl.FocusControl(GetID, _btnLanguage.GetID);
     // Apply the selected buttons again, since they are cleared when we reload
     RestoreButtons();
 }
Ejemplo n.º 10
0
        public void RenderDlg(float timePassed)
        {
            lock (this) {
                // render the parent window
                if (null != m_pParentWindow)
                {
                    m_pParentWindow.Render(timePassed);
                }

                GUIFontManager.Present();
                // render this dialog box
                base.Render(timePassed);
            }
        }
Ejemplo n.º 11
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));
        }
Ejemplo n.º 12
0
        public override void Render(float timePassed)
        {
            base.Render(timePassed);
            if (null == m_pTexture)
            {
                return;
            }
            float x = imgPicture.XPosition;
            float y = imgPicture.YPosition;
            int   width;
            int   height;

            GUIGraphicsContext.Correct(ref x, ref y);

            GUIFontManager.Present();
            GUIGraphicsContext.GetOutputRect(m_iTextureWidth, m_iTextureHeight, imgPicture.Width, imgPicture.Height, out width,
                                             out height);
            Util.Picture.RenderImage(m_pTexture, (int)x, (int)y, width, height, m_iTextureWidth, m_iTextureHeight, 0, 0,
                                     true);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Drawing a 'NEW' stamp on top of an existing banner.
        /// </summary>
        /// <param name="origBanner">Original banner.</param>
        /// <returns>The new banner.</returns>
        private static Bitmap drawNewBanner(Bitmap origBanner, ImageType type)
        {
            if (origBanner == null)
            {
                return(null);
            }

            string newStampLocation = Helper.GetThemedSkinFile(ThemeType.Image, "tvseries_newlabel.png");
            Image  newImage         = LoadImageFastFromFile(newStampLocation);

            Graphics gph = Graphics.FromImage(origBanner);

            try
            {
                if (newImage != null)
                {
                    Bitmap newStamp = new Bitmap(newImage);
                    if (type == ImageType.poster)
                    {
                        gph.DrawImage(newStamp, SkinSettings.PosterNewStampPosX, SkinSettings.PosterNewStampPosY);
                    }
                    else
                    {
                        gph.DrawImage(newStamp, SkinSettings.WideBannerNewStampPosX, SkinSettings.WideBannerNewStampPosY);
                    }
                }
                else
                {
                    gph.FillRectangle(new SolidBrush(Color.FromArgb(150, Color.White)), new Rectangle(((origBanner.Width - 200) / 2), ((origBanner.Height - 100) / 2), 200, 100));
                    GUIFont fontList = GUIFontManager.GetFont(s_sFontName);
                    Font    font     = new Font(fontList.FontName, 50);
                    gph.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
                    gph.DrawString("New", font, new SolidBrush(Color.FromArgb(200, Color.Red)), ((origBanner.Width - 180) / 2), (origBanner.Height - font.GetHeight()) / 2);
                }
            }
            finally
            {
                gph.Dispose();
            }
            return(origBanner);
        }
Ejemplo n.º 14
0
        public void RevertSkin()
        {
            //int ActiveWindowID = GUIWindowManager.ActiveWindow;
            // Change skin back to OutdatedSkinName
            GUIGraphicsContext.Skin = _userSkin;
            GUITextureManager.Clear();
            GUITextureManager.Init();
            GUIFontManager.LoadFonts(GUIGraphicsContext.Skin + @"\fonts.xml");
            GUIFontManager.InitializeDeviceObjects();
            GUIExpressionManager.ClearExpressionCache();
            GUIControlFactory.ClearReferences();
            GUIControlFactory.LoadReferences(GUIGraphicsContext.Skin + @"\references.xml");
            GUIWindowManager.OnResize();
            //GUIWindowManager.ActivateWindow(ActiveWindowID);
            using (Settings xmlreader = new MPSettings())
            {
                xmlreader.SetValue("general", "skinobsoletecount", 0);
                bool autosize = xmlreader.GetValueAsBool("gui", "autosize", true);
                if (autosize && !GUIGraphicsContext.Fullscreen)
                {
                    try
                    {
                        GUIGraphicsContext.form.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height);
                        //Form.ActiveForm.ClientSize = new Size(GUIGraphicsContext.SkinSize.Width, GUIGraphicsContext.SkinSize.Height);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("OnSkinChanged exception:{0}", ex.ToString());
                        Log.Error(ex);
                    }
                }
            }

            if (BassMusicPlayer.Player != null && BassMusicPlayer.Player.VisualizationWindow != null)
            {
                BassMusicPlayer.Player.VisualizationWindow.Reinit();
            }
        }
Ejemplo n.º 15
0
        public override void PostRender(float timePassed, int iLayer)
        {
            if (!m_bEnabled)
            {
                return;
            }
            if (iLayer != 1)
            {
                return;
            }
            CheckFocus();

            // Check auto hide topbar
            if (GUIGraphicsContext.TopBarHidden != m_bTopBarHidden)
            {
                // Rest to new settings
                m_bTopBarHidden = GUIGraphicsContext.TopBarHidden;
                m_bTopBarHide   = GUIGraphicsContext.TopBarHidden;
                m_bTopBarEffect = false;

                m_iMoveUp = 0;
                if (m_bTopBarHidden)
                {
                    m_iMoveUp = m_iTopbarRegion;
                }
                foreach (CPosition pos in _listPositions)
                {
                    int y = (int)pos.YPos - m_iMoveUp;
                    //y += GUIGraphicsContext.OverScanTop;     // already done
                    pos.control.SetPosition((int)pos.XPos, y);
                }
            }
            else if (m_bTopBarHidden != m_bTopBarHide)
            {
                m_bTopBarEffect = true;
            }

            if (GUIGraphicsContext.AutoHideTopBar)
            {
                // Check autohide timeout
                if (m_bFocused)
                {
                    m_bTopBarHide = false;
                    GUIGraphicsContext.TopBarTimeOut = DateTime.Now;
                }

                TimeSpan ts = DateTime.Now - GUIGraphicsContext.TopBarTimeOut;
                if ((ts.TotalSeconds > m_iAutoHideTimeOut) && !m_bTopBarHide)
                {
                    // Hide topbar with effect
                    m_bTopBarHide = true;
                    m_iMoveUp     = 0;
                }

                if (m_bTopBarEffect)
                {
                    if (m_bTopBarHide)
                    {
                        m_iMoveUp += HIDE_SPEED;
                        if (m_iMoveUp >= m_iTopbarRegion)
                        {
                            m_bTopBarHidden = true;
                            GUIGraphicsContext.TopBarHidden = true;
                            m_bTopBarEffect = false;
                        }
                    }
                    else
                    {
                        m_bTopBarHidden = false;
                        GUIGraphicsContext.TopBarHidden = false;
                        m_iMoveUp = 0;
                    }

                    foreach (CPosition pos in _listPositions)
                    {
                        int y = (int)pos.YPos - m_iMoveUp;
                        //y += GUIGraphicsContext.OverScanTop;  // already done
                        pos.control.SetPosition((int)pos.XPos, y);
                    }
                }
            }

            if (GUIGraphicsContext.TopBarHidden)
            {
                return;
            }

            GUIFontManager.Present();
            base.Render(timePassed);
        }
Ejemplo n.º 16
0
        private void InternalPresentImage(int width, int height, int arWidth, int arHeight, bool isRepaint)
        {
            if (_reEntrant)
            {
                Log.Error("PlaneScene: re-entrancy in PresentImage");
                return;
            }
            if (GUIGraphicsContext.CurrentState == GUIGraphicsContext.State.LOST)
            {
                return;
            }
            try
            {
                //Direct3D.Surface backBuffer=null;
                _debugStep = 0;
                _reEntrant = true;
                GUIGraphicsContext.InVmr9Render = true;
                if (width > 0 && height > 0)
                {
                    _vmr9Util.VideoWidth        = width;
                    _vmr9Util.VideoHeight       = height;
                    _vmr9Util.VideoAspectRatioX = arWidth;
                    _vmr9Util.VideoAspectRatioY = arHeight;
                    _arVideoWidth  = arWidth;
                    _arVideoHeight = arHeight;
                }

                //if we're stopping then just return
                float timePassed = GUIGraphicsContext.TimePassed;
                if (_stopPainting)
                {
                    return;
                }
                //sanity checks
                if (GUIGraphicsContext.DX9Device == null)
                {
                    return;
                }
                if (GUIGraphicsContext.DX9Device.Disposed)
                {
                    return;
                }
                if (GUIWindowManager.IsSwitchingToNewWindow)
                {
                    return; //dont present video during window transitions
                }

                _debugStep = 1;
                if (_renderTarget != null)
                {
                    if (!_renderTarget.Disposed)
                    {
                        GUIGraphicsContext.DX9Device.SetRenderTarget(0, _renderTarget);
                    }
                }

                _debugStep = 2;

                //first time, fade in the video in 12 steps
                int iMaxSteps = 12;
                if (_fadeFrameCounter < iMaxSteps)
                {
                    // fade in
                    int iStep = 0xff / iMaxSteps;
                    if (_fadingIn)
                    {
                        _diffuseColor   = iStep * _fadeFrameCounter;
                        _diffuseColor <<= 24;
                        _diffuseColor  |= 0xffffff;
                    }
                    else
                    {
                        _diffuseColor   = (iMaxSteps - iStep) * _fadeFrameCounter;
                        _diffuseColor <<= 24;
                        _diffuseColor  |= 0xffffff;
                    }
                    _fadeFrameCounter++;
                }
                else
                {
                    //after 12 steps, just present the video texture
                    _diffuseColor = 0xFFffffff;
                }

                _debugStep = 3;
                //get desired video window
                if (width > 0 && height > 0 && _textureAddress != 0)
                {
                    Size nativeSize = new Size(width, height);
                    _shouldRenderTexture = SetVideoWindow(nativeSize);
                }
                else
                {
                    _shouldRenderTexture = false;
                }

                //clear screen
                GUIGraphicsContext.DX9Device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0);

                _debugStep = 5;
                GUIGraphicsContext.DX9Device.BeginScene();
                try
                {
                    if (!GUIGraphicsContext.BlankScreen)
                    {
                        // Render GUI + Video surface
                        GUIGraphicsContext.RenderGUI.RenderFrame(timePassed);
                        GUIFontManager.Present();
                    }
                }
                finally
                {
                    GUIGraphicsContext.DX9Device.EndScene();
                }

                GUIGraphicsContext.DX9Device.Present();
                _debugStep = 20;
            }
            catch (DeviceLostException)
            {
                GUIGraphicsContext.CurrentState = GUIGraphicsContext.State.LOST;
                Log.Warn("Planescene caught DeviceLostException in InternalPresentImage");
            }
            catch (DirectXException dex)
            {
                if (dex.ErrorCode == -2005530508 || // GPU_HUNG
                    dex.ErrorCode == -2005530512)   // GPU_REMOVED
                {
                    Log.Info("Planescene caught GPU_HUNG in InternalPresentImage");
                    GUIGraphicsContext.CurrentState = GUIGraphicsContext.State.LOST;
                }
            }
            catch (Exception ex)
            {
                GUIGraphicsContext.CurrentState = GUIGraphicsContext.State.LOST;
                Log.Error("Planescene({0},{1},{2},{3},{4},{5},{6}):Unhandled exception in:",
                          width, height, arWidth, arHeight, _textureAddress, isRepaint, _debugStep);
                Log.Error(ex);
            }
            finally
            {
                _reEntrant = false;
                GUIGraphicsContext.InVmr9Render = false;
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Creates a font object based on the given name
        /// </summary>
        /// <param name="name">Name of the font</param>
        /// <returns>Font </returns>
        protected static Font getFont(String name)
        {
            GUIFont guiFont = GUIFontManager.GetFont(name);

            return(new Font(guiFont.FileName, guiFont.FontSize, guiFont.FontStyle));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Create a grid.
        /// </summary>
        /// <param name="labels">The labels to fill the grid with.</param>
        /// <param name="score">The Score to display.</param>
        /// <param name="startLine">The first line to display.</param>
        private void CreateGrid(string[][] labels, BaseScore score, int startLine, int startColumn)
        {
            bool overRight  = false;
            bool overDown   = false;
            int  lineNumber = 0;
            int  colNumber  = 0;

            IScoreBuilder <GUIControl> bld = ScoreFactory.Instance.GetBuilder <GUIControl>(score);

            bld.Styles      = m_center.Styles.ToList().AsReadOnly();
            bld.UseAltColor = m_center.Setup.UseAltColor;

            GUIFont font = GUIFontManager.GetFont(tbxDetails.FontName);
            int     fontSize = font.FontSize;
            int     charHeight = 0, charWidth = 0;

            GetCharFonSize(fontSize, ref charWidth, ref charHeight);
            bld.SetFont(tbxDetails.FontName, tbxDetails.TextColor, tbxDetails.ColourDiffuse, fontSize, charWidth, charHeight);

            // add controls to screen
            try
            {
                m_scoreGroup.Visibility = System.Windows.Visibility.Hidden;
                IList <GUIControl> controls = bld.Build(score, labels,
                                                        startLine, startColumn,
                                                        tbxDetails.XPosition, tbxDetails.YPosition, tbxDetails.Width, tbxDetails.Height,
                                                        this.CreateControl,
                                                        out overRight, out overDown, out lineNumber, out colNumber);

                foreach (GUIControl c in controls)
                {
                    c.AllocResources();
                    m_scoreGroup.AddControl(c);
                }
            }
            catch (Exception exc)
            {
                Tools.LogError(">>>>>>> Error in Create Grid", exc);
            }
            finally
            {
                m_scoreGroup.Visibility = System.Windows.Visibility.Visible;
            }

            #region Set for Next page
            if (overRight)
            {
                // keep current line
                m_currentColumn += tbxDetails.Width;
                ShowNextButton(true);
            }
            else
            {
                // reset current column
                m_currentColumn = 0;

                if (overDown)
                {
                    m_currentLine = lineNumber - 1;
                    ShowNextButton(true);
                }
                else
                {
                    // no more pages
                    m_currentLine = 0;
                }
            }
            #endregion
        }
Ejemplo n.º 19
0
    public override void AllocResources()
    {
        base.AllocResources();

        m_Font = GUIFontManager.GetFont((m_strFont != "" && m_strFont != "-") ? m_strFont : "font18");

        if (m_imgTexture != null)
        {
            m_imgTexture.AllocResources();
        }

        if (m_imgTextureFocused != null)
        {
            m_imgTextureFocused.AllocResources();
        }

        if (m_imgGuide != null)
        {
            if (m_imgGuide[0] != null)
            {
                m_imgGuide[0].AllocResources();
            }

            if (m_imgGuide[1] != null)
            {
                m_imgGuide[1].AllocResources();
            }
        }

        if (m_imgBlocks != null)
        {
            foreach (GUIImage image in m_imgBlocks)
            {
                image.AllocResources();
            }
        }

        if (m_imgGuide[0] != null)
        {
            m_imgGuide[0].Height = m_nBoardHeight - (m_cyBlock * 2);
            m_imgGuide[0].SetPosition(m_nBoardX - (m_imgGuide[0].Width + 2),
                                      ((m_nBoardY + m_cyBlock) + (Game.Height * m_cyBlock)) - m_imgGuide[0].Height);
        }

        if (m_imgGuide[1] != null)
        {
            m_imgGuide[1].Height = m_nBoardHeight - (m_cyBlock * 2);
            m_imgGuide[1].SetPosition(m_nBoardX + m_nBoardWidth + 2,
                                      ((m_nBoardY + m_cyBlock) + (Game.Height * m_cyBlock)) - m_imgGuide[1].Height);
        }

        if (m_imgBlocksGlow != null)
        {
            foreach (GUIImage image in m_imgBlocksGlow)
            {
                image.AllocResources();
            }
        }

        // we must use local variables for the following transform or we'll lose the original next
        // block positions and experience problems if the user performs multiple fullscreen toggles
        int nNextBlockX = m_nNextBlockX;
        int nNextBlockY = m_nNextBlockY;

        GUIGraphicsContext.ScalePosToScreenResolution(ref nNextBlockX, ref nNextBlockY);

        if (m_imgBlocksNext != null)
        {
            foreach (GUIImage image in m_imgBlocksNext)
            {
                image.AllocResources();

                if (m_nNextBlockAlign == Alignment.ALIGN_LEFT)
                {
                    image.SetPosition(nNextBlockX, nNextBlockY - (image.Height / 2));
                }
                else if (m_nNextBlockAlign == Alignment.ALIGN_CENTER)
                {
                    image.SetPosition(nNextBlockX - (image.Width / 2), nNextBlockY - (image.Height / 2));
                }
                else if (m_nNextBlockAlign == Alignment.ALIGN_RIGHT)
                {
                    image.SetPosition(nNextBlockX - image.Width, nNextBlockY - (image.Height / 2));
                }
            }
        }
    }
Ejemplo n.º 20
0
    public override void FinalizeConstruction()
    {
        base.FinalizeConstruction();

        m_Font = GUIFontManager.GetFont((m_strFont != "" && m_strFont != "-") ? m_strFont : "font18");

        if (m_strTexture != "" && m_strTexture != "-")
        {
            m_imgTexture = new GUIImage(_parentControlId, 9998, _positionX, _positionY, this.Width, this.Height, m_strTexture,
                                        m_dwColorDiffuse);
        }

        if (m_strTextureFocused != "" && m_strTextureFocused != "-")
        {
            m_imgTextureFocused = new GUIImage(_parentControlId, 9999, _positionX, _positionY, this.Width, this.Height,
                                               m_strTextureFocused, m_dwColorDiffuse);
        }

        m_imgGuide = new GUIImage[2];

        m_nBoardWidth  = (m_nBoardWidth == -99999) ? this.Width : m_nBoardWidth;
        m_nBoardHeight = (m_nBoardHeight == -99999) ? this.Height : m_nBoardHeight;

        m_cyBlock     = m_nBoardHeight / (Game.Height + 2);
        m_cxBlock     = m_cyBlock;
        m_nBoardWidth = m_cxBlock * Game.Width;

        m_nBoardX = (m_nBoardX == -99999) ? _positionX + ((this.Width - (m_cxBlock * Game.Width)) / 2) : m_nBoardX;
        m_nBoardY = (m_nBoardY == -99999) ? _positionY + ((this.Height - (m_cyBlock * Game.Height)) / 2) : m_nBoardY;
        m_nBoardY = m_nBoardY - m_cyBlock;

        m_imgBlocks = new GUIImage[]
        {
            new GUIImage(_parentControlId, 10001, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_red.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10002, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_blue.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10003, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_gray.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10004, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_yellow.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10005, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_cyan.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10006, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_orange.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10007, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_green.png"), m_dwColorDiffuse),
        };

        m_imgBlocksGlow = new GUIImage[]
        {
            new GUIImage(_parentControlId, 10011, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_red_glow.png"), m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10012, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_blue_glow.png"), m_dwColorDiffuse)
            ,
            new GUIImage(_parentControlId, 10013, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_gray_glow.png"), m_dwColorDiffuse)
            ,
            new GUIImage(_parentControlId, 10014, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_yellow_glow.png"),
                         m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10015, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_cyan_glow.png"), m_dwColorDiffuse)
            ,
            new GUIImage(_parentControlId, 10016, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_orange_glow.png"),
                         m_dwColorDiffuse),
            new GUIImage(_parentControlId, 10017, _positionX, _positionY, m_cxBlock, m_cyBlock,
                         GUIGraphicsContext.GetThemedSkinFile(@"\media\tetris\block_green_glow.png"), m_dwColorDiffuse)
            ,
        };

        m_strStart    = GUILocalizeStrings.Get(19010);
        m_strPaused   = GUILocalizeStrings.Get(19011);
        m_strGameOver = GUILocalizeStrings.Get(19012);

        m_imgBlocksNext = new GUIImage[7];

        if (m_strTextureO != "" && m_strTextureO != "-")
        {
            m_imgBlocksNext[0] = new GUIImage(_parentControlId, 10021, _positionX, _positionY, 0, 0, m_strTextureO,
                                              m_dwColorDiffuse);
        }

        if (m_strTextureI != "" && m_strTextureI != "-")
        {
            m_imgBlocksNext[1] = new GUIImage(_parentControlId, 10022, _positionX, _positionY, 0, 0, m_strTextureI,
                                              m_dwColorDiffuse);
        }

        if (m_strTextureS != "" && m_strTextureS != "-")
        {
            m_imgBlocksNext[2] = new GUIImage(_parentControlId, 10023, _positionX, _positionY, 0, 0, m_strTextureS,
                                              m_dwColorDiffuse);
        }

        if (m_strTextureZ != "" && m_strTextureZ != "-")
        {
            m_imgBlocksNext[3] = new GUIImage(_parentControlId, 10024, _positionX, _positionY, 0, 0, m_strTextureZ,
                                              m_dwColorDiffuse);
        }

        if (m_strTextureL != "" && m_strTextureL != "-")
        {
            m_imgBlocksNext[4] = new GUIImage(_parentControlId, 10025, _positionX, _positionY, 0, 0, m_strTextureL,
                                              m_dwColorDiffuse);
        }

        if (m_strTextureT != "" && m_strTextureT != "-")
        {
            m_imgBlocksNext[5] = new GUIImage(_parentControlId, 10026, _positionX, _positionY, 0, 0, m_strTextureT,
                                              m_dwColorDiffuse);
        }

        if (m_strTextureJ != "" && m_strTextureJ != "-")
        {
            m_imgBlocksNext[6] = new GUIImage(_parentControlId, 10027, _positionX, _positionY, 0, 0, m_strTextureJ,
                                              m_dwColorDiffuse);
        }

        if (m_imgBlocksNext != null)
        {
            foreach (GUIImage image in m_imgBlocksNext)
            {
                if (image != null)
                {
                    image.ScaleToScreenResolution();
                }
            }
        }

        if (m_strTextureLeft != "" && m_strTextureLeft != "-")
        {
            m_imgGuide[0] = new GUIImage(_parentControlId, 9996, _positionX, _positionY, 0, 0, m_strTextureLeft,
                                         m_dwColorDiffuse);
        }

        if (m_strTextureRight != "" && m_strTextureRight != "-")
        {
            m_imgGuide[1] = new GUIImage(_parentControlId, 9997, _positionX, _positionY, 0, 0, m_strTextureRight,
                                         m_dwColorDiffuse);
        }
    }