예제 #1
0
        public bool Initialize(int x, int y, int width, int height, StretchableImageType backgroundImage, GameMain gameMain, bool moveable, Random r, out string reason)
        {
            _xPos = x;
            _yPos = y;
            _windowWidth = width;
            _windowHeight = height;
            this._moveable = moveable;

            _moving = false;
            _gameMain = gameMain;

            _backGroundImage = new BBStretchableImage();
            if (!_backGroundImage.Initialize(x, y, width, height, backgroundImage, r, out reason))
            {
                return false;
            }
            reason = null;
            return true;
        }
예제 #2
0
        public bool Initialize(int x, int y, int width, int height, StretchableImageType backgroundImage, GameMain gameMain, bool moveable, Random r, out string reason)
        {
            _xPos         = x;
            _yPos         = y;
            _windowWidth  = width;
            _windowHeight = height;
            _moveable     = moveable;

            _moving   = false;
            _gameMain = gameMain;

            _backGroundImage = new BBStretchableImage();
            if (!_backGroundImage.Initialize(x, y, width, height, backgroundImage, r, out reason))
            {
                return(false);
            }
            reason = null;
            return(true);
        }
예제 #3
0
        public bool Initialize(string buttonText, ButtonTextAlignment alignment, StretchableImageType background, StretchableImageType foreground, int xPos, int yPos, int width, int height, Random r, out string reason)
        {
            _xPos = xPos;
            _yPos = yPos;
            _width = width;
            _height = height;
            _alignment = alignment;

            _backgroundImage = new BBStretchableImage();
            _foregroundImage = new BBStretchableImage();

            if (!_backgroundImage.Initialize(xPos, yPos, width, height, background, r, out reason))
            {
                return false;
            }
            if (!_foregroundImage.Initialize(xPos, yPos, width, height, foreground, r, out reason))
            {
                return false;
            }

            _label = new BBLabel();
            if (!_label.Initialize(0, 0, string.Empty, Color.White, out reason))
            {
                return false;
            }
            SetText(buttonText);

            Reset();
            _timeSinceClick = 10; //10 seconds will exceed any double-click max interval
            _doubleClicked = false;

            reason = null;
            return true;
        }
예제 #4
0
        public bool Initialize(int x, int y, int width, int height, StretchableImageType type, Random r, out string reason)
        {
            xPos = x;
            yPos = y;

            switch (type)
            {
                case StretchableImageType.TextBox:
                    {
                        sectionWidth = 30;
                        sectionHeight = 13;
                        sections = new List<BBSprite>();
                        var tempSprite = SpriteManager.GetSprite("TextTL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TextTL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TextTC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TextTC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TextTR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TextTR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TextCL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TextCL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TextCC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TextCC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TextCR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TextCR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TextBL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TextBL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TextBC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TextBC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TextBR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TextBR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                    }
                    break;
                case StretchableImageType.ThinBorderBG:
                {
                    sectionWidth = 30;
                    sectionHeight = 13;
                    sections = new List<BBSprite>();
                    var tempSprite = SpriteManager.GetSprite("ThinBorderBGTL", r);
                    if (tempSprite == null)
                    {
                        reason = "Failed to get \"ThinBorderBGTL\" from sprites.xml.";
                        return false;
                    }
                    sections.Add(tempSprite);
                    tempSprite = SpriteManager.GetSprite("ThinBorderBGTC", r);
                    if (tempSprite == null)
                    {
                        reason = "Failed to get \"ThinBorderBGTC\" from sprites.xml.";
                        return false;
                    }
                    sections.Add(tempSprite);
                    tempSprite = SpriteManager.GetSprite("ThinBorderBGTR", r);
                    if (tempSprite == null)
                    {
                        reason = "Failed to get \"ThinBorderBGTR\" from sprites.xml.";
                        return false;
                    }
                    sections.Add(tempSprite);
                    tempSprite = SpriteManager.GetSprite("ThinBorderBGCL", r);
                    if (tempSprite == null)
                    {
                        reason = "Failed to get \"ThinBorderBGCL\" from sprites.xml.";
                        return false;
                    }
                    sections.Add(tempSprite);
                    tempSprite = SpriteManager.GetSprite("ThinBorderBGCC", r);
                    if (tempSprite == null)
                    {
                        reason = "Failed to get \"ThinBorderBGCC\" from sprites.xml.";
                        return false;
                    }
                    sections.Add(tempSprite);
                    tempSprite = SpriteManager.GetSprite("ThinBorderBGCR", r);
                    if (tempSprite == null)
                    {
                        reason = "Failed to get \"ThinBorderBGCR\" from sprites.xml.";
                        return false;
                    }
                    sections.Add(tempSprite);
                    tempSprite = SpriteManager.GetSprite("ThinBorderBGBL", r);
                    if (tempSprite == null)
                    {
                        reason = "Failed to get \"ThinBorderBGBL\" from sprites.xml.";
                        return false;
                    }
                    sections.Add(tempSprite);
                    tempSprite = SpriteManager.GetSprite("ThinBorderBGBC", r);
                    if (tempSprite == null)
                    {
                        reason = "Failed to get \"ThinBorderBGBC\" from sprites.xml.";
                        return false;
                    }
                    sections.Add(tempSprite);
                    tempSprite = SpriteManager.GetSprite("ThinBorderBGBR", r);
                    if (tempSprite == null)
                    {
                        reason = "Failed to get \"ThinBorderBGBR\" from sprites.xml.";
                        return false;
                    }
                    sections.Add(tempSprite);
                } break;
                case StretchableImageType.ThinBorderFG:
                    {
                        sectionWidth = 30;
                        sectionHeight = 13;
                        sections = new List<BBSprite>();
                        var tempSprite = SpriteManager.GetSprite("ThinBorderFGTL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThinBorderFGTL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThinBorderFGTC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThinBorderFGTC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThinBorderFGTR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThinBorderFGTR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThinBorderFGCL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThinBorderFGCL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThinBorderFGCC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThinBorderFGCC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThinBorderFGCR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThinBorderFGCR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThinBorderFGBL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThinBorderFGBL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThinBorderFGBC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThinBorderFGBC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThinBorderFGBR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThinBorderFGBR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                    } break;
                case StretchableImageType.TinyButtonBG:
                    {
                        sectionWidth = 10;
                        sectionHeight = 10;
                        sections = new List<BBSprite>();
                        var tempSprite = SpriteManager.GetSprite("TinyButtonBGTL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonBGTL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonBGTC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonBGTC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonBGTR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonBGTR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonBGCL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonBGCL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonBGCC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonBGCC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonBGCR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonBGCR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonBGBL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonBGBL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonBGBC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonBGBC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonBGBR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonBGBR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                    } break;
                case StretchableImageType.TinyButtonFG:
                    {
                        sectionWidth = 10;
                        sectionHeight = 10;
                        sections = new List<BBSprite>();
                        var tempSprite = SpriteManager.GetSprite("TinyButtonFGTL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonFGTL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonFGTC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonFGTC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonFGTR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonFGTR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonFGCL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonFGCL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonFGCC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonFGCC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonFGCR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonFGCR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonFGBL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonFGBL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonFGBC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonFGBC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("TinyButtonFGBR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"TinyButtonFGBR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                    } break;
                case StretchableImageType.MediumBorder:
                    {
                        sectionWidth = 60;
                        sectionHeight = 60;
                        sections = new List<BBSprite>();
                        var tempSprite = SpriteManager.GetSprite("MediumBorderBGTL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"MediumBorderBGTL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("MediumBorderBGTC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"MediumBorderBGTC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("MediumBorderBGTR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"MediumBorderBGTR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("MediumBorderBGCL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"MediumBorderBGCL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("MediumBorderBGCC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"MediumBorderBGCC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("MediumBorderBGCR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"MediumBorderBGCR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("MediumBorderBGBL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"MediumBorderBGBL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("MediumBorderBGBC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"MediumBorderBGBC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("MediumBorderBGBR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"MediumBorderBGBR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                    } break;
                case StretchableImageType.ThickBorder:
                    {
                        sectionWidth = 200;
                        sectionHeight = 200;
                        sections = new List<BBSprite>();
                        var tempSprite = SpriteManager.GetSprite("ThickBorderBGTL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThickBorderBGTL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThickBorderBGTC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThickBorderBGTC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThickBorderBGTR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThickBorderBGTR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThickBorderBGCL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThickBorderBGCL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThickBorderBGCC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThickBorderBGCC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThickBorderBGCR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThickBorderBGCR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThickBorderBGBL", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThickBorderBGBL\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThickBorderBGBC", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThickBorderBGBC\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                        tempSprite = SpriteManager.GetSprite("ThickBorderBGBR", r);
                        if (tempSprite == null)
                        {
                            reason = "Failed to get \"ThickBorderBGBR\" from sprites.xml.";
                            return false;
                        }
                        sections.Add(tempSprite);
                    }
                    break;
            }

            horizontalStretchLength = (width - (sectionWidth * 2));
            verticalStretchLength = (height - (sectionHeight * 2));

            if (horizontalStretchLength < 0)
            {
                horizontalStretchLength = 0;
            }
            if (verticalStretchLength < 0)
            {
                verticalStretchLength = 0;
            }

            reason = null;
            return true;
        }