/// <summary> /// The button is centered on the position; /// </summary> /// <param name="_parent"></param> public UiMainMenuButton(int _x, int _y, MenuButtonType _type, NxOverlay _parent) : base(_parent) { x = _x; y = _y; m_Type = _type; //background Color = EDColors.getColor(EDColors.ORANGE, 0.2f); m_originRec = new Rectangle(x - (WIDTH / 2), y - (HEIGHT / 2), WIDTH, HEIGHT); m_background = new NxRectangle(m_originRec.X, m_originRec.Y, m_originRec.Width, m_originRec.Height, Color); Add(m_background); //Title m_TopText = new NxSimpleText(x, m_background.y + 5, getMenuTitle(), EDColors.ORANGE, 34, NxFonts.EuroCapital); m_TopText.centerHorizontal = true; Add(m_TopText); //Icon m_Icon = new NxImage(m_background.x + (WIDTH - ICON_SIZE) / 2, m_background.y + 50, ResHelper.GetResourceImage(Assembly.GetExecutingAssembly(), getIconPath())); Add(m_Icon); //Bottom Text int _botHeight = 80; int _padding = 5; m_BottomText = new NxTextbox(m_background.x + _padding, m_background.y + (HEIGHT - _botHeight) - _padding, WIDTH - _padding * 2, _botHeight, getBottomText(), EDColors.ORANGE, 19); m_BottomText.showBounds = true; m_BottomText.boundColors = EDColors.getColor(EDColors.ORANGE, .5f); Add(m_BottomText); }
public PlayerCardData card; //card type attached to this button, if any /// <summary> /// the button is set up to correspond to the given LOCAL level file /// </summary> public void setLevel(FileInfo file) { //load the levelData using (FileStream stream = new FileStream(file.FullName, FileMode.Open)) level = LevelData.Load(stream, file.Name, file.FullName); buttonText.text = file.Name; //set button text levelButtonText(); //set text for this button buttonType = MenuButtonType.level; //this is now a level button }
public MenuButtonComponent(MenuButtonType type, ButtonAction buttonAction, string normalTexturePath, string highlightTexturePath, Vector2 position, RenderLayer layer) { IsActive = false; Ishighlighted = false; Type = type; Use = buttonAction; NormalTexturePath = normalTexturePath; HighlightTexturePath = highlightTexturePath; Position = position; Layer = layer; }
/// <summary> /// [COROUTINE] the button is set up to correspond to the given REMOTE level file. The web request does not need to be complete before calling. /// while loading, this will be a text button. Once loading is complete, it becomes a level button. /// </summary> public IEnumerator setLevel(WWW request) { //set up placeholder info during loading buttonText.text = "Loading...(" + request.url + ")"; buttonType = MenuButtonType.text; //wait for the request to load yield return(request); //show error if there was one if (request.error != null) { Debug.LogError(request.error); buttonText.text = request.error; buttonText.color = Color.white; setColor(Color.red); yield break; } //or, if we were successful, create a new stream and fill it with the contents of the web request: using (MemoryStream levelStream = new MemoryStream()) //create the stream { StreamWriter writer = new StreamWriter(levelStream); //used to write to it writer.Write(request.text); //write contents of the request writer.Flush(); //make sure it gets processed levelStream.Position = 0; //send the stream back to the start //figure out the file name string fileName = ""; if (request.url.Contains("file://")) { //special, simplified handling for access of web player through file:/// fileName = Path.GetFileName(request.url); } else { //usual handling for access of web player through the web or a connection to localhost System.Uri address = new System.Uri(request.url); //fetch address from the web request fileName = Path.GetFileName(address.LocalPath); //set button text to the file name (we know it's a file already, or we would have errored earlier) fileName = fileName.Replace("%20", " "); //replace URL special sequence "%20" with the ' ' it is meant to represent. } //now we can finally setup the level button level = LevelData.Load(levelStream, fileName, request.url); //load the levelData levelButtonText(); //set text for this button buttonType = MenuButtonType.level; //this is now a usable level button } }
public virtual void OnMenuButtonPressed(MenuButtonType menuButtonType) { if (!this.isActive) { return; } switch (menuButtonType) { case MenuButtonType.EXIT: Application.Quit(); break; case MenuButtonType.STARTGAME: OnStartNewGame(); break; case MenuButtonType.LOADGAME: OnLoadGame(); break; } this.isActive = false; }
public void OnMenuButtonPressed(MenuButtonType menuButtonType) { if (!this.isActive) { return; } switch (menuButtonType) { case MenuButtonType.EXIT: Application.Quit(); break; case MenuButtonType.STARTGAME: //go to startgame break; case MenuButtonType.LOADINTRO: //go to load intro break; } this.isActive = false; }
/// <summary> /// sets up the button by setting the text directly (note: only use on text buttons, as the other types set the text automatically) /// </summary> public void setButtonText(string text) { buttonText.text = text; buttonType = MenuButtonType.text; }
/// <summary> /// the button is set up to correspond to the given PlayerCardData /// </summary> private void setCard(PlayerCardData newCard) { card = newCard; buttonText.text = newCard.cardName; buttonType = MenuButtonType.card; }
/// <summary> /// the button is set up to correspond to the given XMLDeck /// </summary> public void setDeck(XMLDeck newXDeck) { xDeck = newXDeck; //set deck buttonText.text = xDeck.name; buttonType = MenuButtonType.deck; }
public MenuButton(MenuButtonType type, Rectangle surface, string textureLocation) { this.menuButtonType = type; this.surface = surface; this.textureLocation = textureLocation; }