public bool Initialize(List<string> backgroundSections, List<string> foregroundSections, bool isHorizontal, string buttonText, ButtonTextAlignment alignment, int xPos, int yPos, int width, int height, int fixedSize, int variableSize, Random r, out string reason) { _xPos = xPos; _yPos = yPos; _width = width; _height = height; _fixedSize = fixedSize; _variableSize = variableSize; _alignment = alignment; backgroundImage = new BBUniStretchableImage(); foregroundImage = new BBUniStretchableImage(); if (!backgroundImage.Initialize(xPos, yPos, width, height, fixedSize, variableSize, isHorizontal, backgroundSections, r, out reason)) { return false; } if (!foregroundImage.Initialize(xPos, yPos, width, height, fixedSize, variableSize, isHorizontal, foregroundSections, r, out reason)) { return false; } _label = new BBLabel(); if (!_label.Initialize(0, 0, buttonText, Color.White, out reason)) { return false; } Reset(); reason = null; return true; }
public bool Initialize(string backgroundSprite, string foregroundSprite, string buttonText, ButtonTextAlignment alignment, int xPos, int yPos, int width, int height, Random r, out string reason) { return Initialize(backgroundSprite, foregroundSprite, buttonText, string.Empty, alignment, xPos, yPos, width, height, r, out reason); }
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; }
public bool Initialize(string backgroundSprite, string foregroundSprite, string buttonText, string font, ButtonTextAlignment alignment, int xPos, int yPos, int width, int height, Random r, out string reason, int xTextOffset = 0, int yTextOffset = 0) { _backgroundSprite = SpriteManager.GetSprite(backgroundSprite, r); _foregroundSprite = SpriteManager.GetSprite(foregroundSprite, r); if (backgroundSprite == null || foregroundSprite == null) { reason = string.Format("One of those sprites does not exist in sprites.xml: \"{0}\" or \"{1}\"", backgroundSprite, foregroundSprite); return false; } _xPos = xPos; _yPos = yPos; _width = width; _height = height; _xTextOffset = xTextOffset; _yTextOffset = yTextOffset; _alignment = alignment; _label = new BBLabel(); if (string.IsNullOrEmpty(font)) { if (!_label.Initialize(0, 0, buttonText, Color.White, out reason)) { return false; } } else { if (!_label.Initialize(0, 0, buttonText, Color.White, font, out reason)) { return false; } } SetText(buttonText); Reset(); reason = null; return true; }