public void Update() { if (selectedItem == null) { return; } titleFnt.SetText(selectedItem.GetData().name); preview = selectedItem.GetFirstTexture().Clone() as Image; if ((preview.GetTexture().Height + 20) > previewAreaHeight) { int oldPreviewHeight = previewAreaHeight; previewAreaHeight = preview.GetTexture().Height + 20; size += new Vector2i(0, (previewAreaHeight - oldPreviewHeight)); backdrop.SetSourceSize(new Vector2i(backdrop.SourceRect.Width, backdrop.SourceRect.Height + (previewAreaHeight - oldPreviewHeight))); } descFnt.SetText(selectedItem.GetData().description); userFnt.SetText(selectedItem.GetOwnerName()); useFnt.SetText(RetroEnvironment.GetLanguageManager().TryGetValue(useFnt.GetOriginalText())); pickupFnt.SetText(RetroEnvironment.GetLanguageManager().TryGetValue(pickupFnt.GetOriginalText())); rotateFnt.SetText(RetroEnvironment.GetLanguageManager().TryGetValue(rotateFnt.GetOriginalText())); moveFnt.SetText(RetroEnvironment.GetLanguageManager().TryGetValue(moveFnt.GetOriginalText())); }
internal void UpdateItemSelected(GameTime gameTime, IPageItem item) { if (item.CanGift()) { present.Update(gameTime); } else { presentDisabled.Update(gameTime); presentDisabledText.SetText(RetroEnvironment.GetLanguageManager().TryGetValue(presentDisabledText.GetOriginalText())); presentDisabledText.Update(gameTime); } buy.Update(gameTime); Amount.SetText(RetroEnvironment.GetLanguageManager().TryGetValue(Amount.GetOriginalText())); Price.SetText(RetroEnvironment.GetLanguageManager().TryGetValue(Price.GetOriginalText())); amountText.SetText("10"); amountText.Update(gameTime); Amount.Update(gameTime); Price.Update(gameTime); priceOneText.SetText((item.GetPrices()[0] * int.Parse(amountText.GetText())).ToString()); priceTwoText.SetText("+ " + (item.GetPrices()[1] * int.Parse(amountText.GetText())).ToString()); priceOneText.Update(gameTime); priceTwoText.Update(gameTime); }
public void UpdateNoItems(GameTime gameTime) { noItemsImg.Update(gameTime); noItemsHead.SetText(FontUtil.SplitToLines(RetroEnvironment.GetLanguageManager().TryGetValue(noItemsHead.GetOriginalText()), 30)); noItemsHead.Update(gameTime); noItemsBody.SetText(FontUtil.SplitToLines(RetroEnvironment.GetLanguageManager().TryGetValue(noItemsBody.GetOriginalText()), 30)); noItemsBody.Update(gameTime); openCataButton.Update(gameTime); }
//private bool processed = false; public void Update(GameTime gameTime) { if (RetroEnvironment.GetLanguageManager() != null && useLanguage) { buttonName.SetText(RetroEnvironment.GetLanguageManager().TryGetValue(buttonName.GetOriginalText())); } var mouseState = Mouse.GetState(); var mousePoint = new Point(mouseState.X, mouseState.Y); var rectangle = new Rectangle((int)Position.X, (int)Position.Y, size.X, size.Y); if (rectangle.Contains(mousePoint)) { backdrop.SetHover(true); cornerLeft.SetHover(true); cornerRight.SetHover(true); edgeTop.SetHover(true); edgeLeft.SetHover(true); edgeRight.SetHover(true); bool isClicked = mouseState.LeftButton == ButtonState.Pressed; if (!backdrop.GetActive()) { backdrop.SetClick(isClicked); cornerLeft.SetClick(isClicked); cornerRight.SetClick(isClicked); edgeTop.SetClick(isClicked); edgeLeft.SetClick(isClicked); edgeRight.SetClick(isClicked); } else { backdrop.SetClick(false); cornerLeft.SetClick(false); cornerRight.SetClick(false); edgeTop.SetClick(false); edgeLeft.SetClick(false); edgeRight.SetClick(false); } } else { backdrop.SetHover(false); cornerLeft.SetHover(false); cornerRight.SetHover(false); edgeTop.SetHover(false); edgeLeft.SetHover(false); edgeRight.SetHover(false); } cornerLeft.Update(gameTime, false); cornerRight.Update(gameTime, false); edgeTop.Update(gameTime, false); edgeLeft.Update(gameTime, false); edgeRight.Update(gameTime, false); backdrop.Update(gameTime, false); buttonName.SetPosition(new Vector2(size.X / 2 - buttonName.measureString().X / 2, size.Y / 2 - buttonName.measureString().Y / 2)); buttonName.Update(gameTime); }
public void Update(GameTime gameTime, int parentId, ref Dictionary <CatalogusPage, int> pages) { if (isOpen()) { base.Update(gameTime); rootContainer.Update(gameTime, size, headerHeight, edgeBottom.dimensions.Y); tree.Update(gameTime); items.Update(gameTime); selectItem.Update(gameTime); selectItemText.SetText(RetroEnvironment.GetLanguageManager().TryGetValue(selectItemText.GetOriginalText())); selectItemText.Update(gameTime); imgBannerLayer.Update(gameTime); if (imgBanner != null) { imgBanner.Scale = 2f; imgBanner.Update(gameTime); imgBanner.resizeCenter(size.X - 2, 90); } pageTree.Update(gameTime, position + new Vector2i(12, headerHeight + rootContainer.GetHeight() + 95 + 38)); pageItems.Update(gameTime, position + new Vector2i(202 + 4, headerHeight + rootContainer.GetHeight() + 95 + 251 + 3)); try { foreach (CataPageSection section in cataPageSections) { section.Update(gameTime, pageTree.GetPosition() - pageTree.GetScrolled(), ref pageTree); } foreach (CataItemSection section in cataItemSections) { section.Update(gameTime, pageItems.GetPosition() - pageItems.GetScrolled(), ref pageItems); } } catch { Logger.Warn("Can not render a Catalogus Body!! Soo loading???!"); } if (pageTree.texturesChanged) { Vector2i offset = new Vector2i(); for (int i = 0; i < cataPageSections.Count(); i++) { int bodySize = 0; CataPageSection section = cataPageSections[i]; section.UpdatePosition(offset, out bodySize); offset += new Vector2i(0, cataPageSections[i].GetSize().Y + 5); if (!cataPageSections[i].page.isCollapsed) { offset += new Vector2i(0, bodySize); } } SectionCombiner combiner = new SectionCombiner(); pageTree.SetContent(combiner.AddSections(cataPageSections.ToArray()).GetImages()); pageTree.SetText(combiner.AddSections(cataPageSections.ToArray()).GetFonts()); pageTree.texturesChanged = false; } if (pageItems.texturesChanged) { int cell = 0; int row = 0; int maxBody = 0; Vector2i offset = new Vector2i(0, 0); for (int i = 0; i < cataItemSections.Count(); i++) { int bodySize = 0; CataItemSection section = cataItemSections[i]; section.UpdatePosition(offset, out bodySize); offset += new Vector2i(3 + 53, 0); if (maxBody < bodySize) { maxBody = bodySize; } if (cell++ >= 6) { cell = 0; row++; offset = new Vector2i(0, row * maxBody); } } SectionCombiner combiner = new SectionCombiner(); pageItems.SetContent(combiner.AddSections(cataItemSections.ToArray()).GetImages()); pageItems.SetText(combiner.AddSections(cataItemSections.ToArray()).GetFonts()); pageItems.texturesChanged = false; } } }
public void Update(GameTime gameTime) { if (RetroEnvironment.GetLanguageManager() != null) { buttonName.SetText(RetroEnvironment.GetLanguageManager().TryGetValue(buttonName.GetOriginalText())); } buttonName.Update(gameTime); var mouseState = Mouse.GetState(); var mousePoint = new Point(mouseState.X, mouseState.Y); if (area.Contains(mousePoint)) { isHovered = true; isClicked = mouseState.LeftButton == ButtonState.Pressed; } else { isHovered = false; isClicked = false; } if (isHovered && !isClicked) { if (!t.Enabled) { buttons.ForEach(s => s.loadFrame(2)); if (backdropB.GetColor() != colorsB[0]) { backdropB.SetColor(colorsB[2]); } if (backdropT.GetColor() != colorsT[0]) { backdropT.SetColor(colorsT[2]); } } } else if (isClicked) { buttons.ForEach(s => s.loadFrame(1)); if (backdropB.GetColor() != colorsB[1]) { backdropB.SetColor(colorsB[1]); } if (backdropT.GetColor() != colorsT[1]) { backdropT.SetColor(colorsT[1]); } if (!t.Enabled) { clickAction.Invoke(); t.Enabled = true; } } else { if (!t.Enabled) { buttons.ForEach(s => s.loadFrame(0)); if (backdropB.GetColor() != colorsB[0]) { backdropB.SetColor(colorsB[0]); } if (backdropT.GetColor() != colorsT[0]) { backdropT.SetColor(colorsT[0]); } } } }
public virtual void Update(GameTime gameTime) { var mouseState = Mouse.GetState(); var mousePoint = new Point(mouseState.X, mouseState.Y); if (!clicked) { var rectangle = new Rectangle(position.X, position.Y, size.X, size.Y); if (rectangle.Contains(mousePoint)) { if (rectangle.Contains(mousePoint)) { isHover = true; if (delay.Enabled == false && mouseState.LeftButton == ButtonState.Pressed) { delay.Start(); clicked = true; } } else { isHover = false; } } edgeRight.resize(2, size.Y - cornerLeftTop.dimensions.Y - cornerLeftBottom.dimensions.Y); edgeLeft.resize(2, size.Y - cornerLeftTop.dimensions.Y - cornerLeftBottom.dimensions.Y); backdrop.resize(size.X - (edgeLeft.dimensions.X + edgeRight.dimensions.X), size.Y - (edgTop.dimensions.Y + edgeBottom.dimensions.Y)); offset = new Vector2i(0, 0); hoverIndex = -1; } else { var rectangle = new Rectangle(position.X, position.Y, size.X + offset.X, size.Y + offset.Y); if (!rectangle.Contains(mousePoint) && mouseState.LeftButton == ButtonState.Pressed) { clicked = false; } if (rectangle.Contains(mousePoint)) { hoverIndex = -1; for (int i = 0; i < items.Count(); i++) { var recItem = new Rectangle(position.X, position.Y + (16 * i), size.X, 16); if (recItem.Contains(mousePoint)) { if (delay.Enabled == false && mouseState.LeftButton == ButtonState.Pressed) { clicked = false; selectedIndex = i; items[selectedIndex].action.Invoke(); delay.Start(); } hoverIndex = i; } } } else { hoverIndex = -1; } active.Update(gameTime); hover.Update(gameTime); offset = new Vector2i(0, 16 * (items.Count - 1)); edgeRight.resize(2, size.Y + offset.Y - cornerLeftTop.dimensions.Y - cornerLeftBottom.dimensions.Y); edgeLeft.resize(2, size.Y + offset.Y - cornerLeftTop.dimensions.Y - cornerLeftBottom.dimensions.Y); backdrop.resize((size.X + offset.X) - (edgeLeft.dimensions.X + edgeRight.dimensions.X), (size.Y + offset.Y) - (edgTop.dimensions.Y + edgeBottom.dimensions.Y)); } //Basic Updates cornerLeftTop.Update(gameTime); cornerLeftBottom.Update(gameTime); cornerRightTop.Update(gameTime); cornerRightBottom.Update(gameTime); edgeLeft.Update(gameTime); edgeRight.Update(gameTime); edgTop.Update(gameTime); edgeBottom.Update(gameTime); backdrop.Update(gameTime); arrow.Update(gameTime); dotline.Update(gameTime); if (RetroEnvironment.GetLanguageManager() != null) { display.SetText(RetroEnvironment.GetLanguageManager().TryGetValue(items[selectedIndex].text)); } display.Update(gameTime); if (RetroEnvironment.GetLanguageManager() != null) { for (int i = 0; i < items.Count(); i++) { itemsText[i].SetText(RetroEnvironment.GetLanguageManager().TryGetValue(items[i].text)); } } foreach (Font font in itemsText) { font.Update(gameTime); } }