public SuccessMissionPopup(string missionName, string missionTime) : base() { // background this.background = new UIRectElement(0.5, 0.5, 0.3, 0.2, UIColor.BLACK, 200); this.add(this.background); // title this.title = new UITextElement("Mission réussie", 0.5, 0.3, 1.5, true, Font.Pricedown, UIColor.GTA_YELLOW); this.add(this.title); // mission name this.content = new UITextElement(missionName, 0.5, 0.42, 1.2, true, Font.HouseScript, UIColor.WHITE); this.add(this.content); // top separator this.add(new UIRectElement(0.5, 0.515, 0.25, 0.002, UIColor.WHITE, 255)); // mission time this.content = new UITextElement(missionTime, 0.5, 0.525, 0.475, true, Font.ChaletLondon, UIColor.WHITE); this.add(this.content); // bottom separator this.add(new UIRectElement(0.5, 0.57, 0.25, 0.002, UIColor.WHITE, 255)); // helper this.infos = new UITextElement(INFOS, 0.5, 0.9, 0.6, true, Font.HouseScript, UIColor.WHITE); this.add(this.infos); }
public void ResolveUsingDefaultPathNoAttr() { MockApplication app = MockApplication.Setup <DefaultPathElementNoAttr>(); Assert.IsInstanceOf <DefaultPathElementNoAttr>(app.RootElement); UITextElement textElement = TestUtils.AssertInstanceOfAndReturn <UITextElement>(app.RootElement[0]); Assert.AreEqual("Default Path! No Attr", textElement.text.Trim()); }
public void TemplateStructure_SlotOverride_UseDefault() { MockApplication app = MockApplication.Setup <TemplateStructure_SlotOverrideDefault_Main>(); Assert.IsInstanceOf <TemplateStructure_SlotOverrideDefault_Expand>(app.RootElement[0]); Assert.IsInstanceOf <UITextElement>(app.RootElement[0][0][0]); UITextElement textElement = (UITextElement)app.RootElement[0][0][0]; Assert.AreEqual("Override failed", textElement.GetText().Trim()); }
public ConfirmationPopup(string text_title, string text_content) : base(false) { // background this.background = new UIRectElement(0, 0, 2, 2, UIColor.BLACK, 230); this.add(this.background); // title this.title = new UITextElement(text_title, 0.5, 0.4, 2, true, Font.Pricedown, UIColor.GTA_YELLOW); this.add(this.title); // top separator this.add(new UIRectElement(0.5, 0.525, 0.9, 0.002, UIColor.WHITE, 255)); // content this.content = new UITextElement(text_content, 0.5, 0.530, 0.475, true, Font.ChaletLondon, UIColor.WHITE); this.add(this.content); // bottom separator this.add(new UIRectElement(0.5, 0.58, 0.9, 0.002, UIColor.WHITE, 255)); // helper this.infos = new UITextElement(INFOS, 0.5, 0.9, 0.6, true, Font.HouseScript, UIColor.WHITE); this.add(this.infos); GUIManager.Instance.menu.OnControlPressed += (GTA.Control control) => { if (this.isVisible()) { if (control == GTA.Control.PhoneSelect) { this.accept(); } if (control == GTA.Control.PhoneCancel) { this.refuse(); } } }; GUIManager.Instance.menu.OnKeysPressedEvent += (Keys key) => { if (this.isVisible()) { if (key == Keys.Enter) { this.accept(); } if (key == Keys.Escape) { this.refuse(); } } }; }
public void TemplateStructure_SlotOverride_Extern_ExternDefault() { MockApplication app = MockApplication.Setup <TemplateStructure_SlotOverride_Extern_ExternDefault_Main>(); Assert.IsInstanceOf <TemplateStructure_SlotOverride_Extern_ExternDefault_Exposer>(app.RootElement[0]); Assert.IsInstanceOf <TemplateStructure_SlotOverride_Extern_ExternDefault_Definer>(app.RootElement[0][0]); Assert.IsInstanceOf <UISlotOverride>(app.RootElement[0][0][0]); Assert.IsInstanceOf <UITextElement>(app.RootElement[0][0][0][0]); UITextElement textElement = (UITextElement)app.RootElement[0][0][0][0]; Assert.AreEqual("Override from exposer layer", textElement.GetText().Trim()); }
private void AddLeftMenuOption(UIElement leftMenu, MenuItem item, int index, int row = 0) { int maxT = 11; int placeRow = row + (index / options); string placeText = item.Name; if (placeText.Length > maxT + 3) { placeText = placeText.Substring(0, maxT) + "..."; } index = index % options; UIElement button = UIElement.GetImage(PyDraw.getBorderedRectangle(optionWidth, optionHeight - 1, Color.White * 0.2f, 1, Color.White), row == 0 ? Color.CornflowerBlue : Color.LightGreen, item.Id, 1, 0, UIHelper.GetTopLeft(placeRow * (optionWidth + 1), index * (optionHeight + 1), optionWidth, optionHeight - 1)).WithInteractivity(update: UpdateItem, click: ClickItem); float textScale = Math.Min(0.5f * menuScale, 0.7f); if (LocalizedContentManager.CurrentLanguageLatin && menuFont1 != "" && menuFont1 != null) { textScale *= cFontAdjust; } UITextElement text = new UITextElement(placeText, Game1.smallFont, Color.White, textScale, 1, positioner: UIHelper.GetCentered()); if (LocalizedContentManager.CurrentLanguageLatin && menuFont1 != "" && menuFont1 != null) { text.WithFont(menuFont1); } button.Z = row; button.Add(text); leftMenu.Add(button); if (item.Special) { PyTK.PyUtils.setDelayedAction(100, () => button.ClickAction(Point.Zero, false, true, false, button)); } if (row > 0) { button.Disable(); button.Visible = false; text.Visible = false; } for (int i = 0; i < item.Children.Count; i++) { if (item.Children[i] is MenuItem child) { AddLeftMenuOption(leftMenu, child, i, row + 1); } } }
public Intro(Game game) { Game = game; Delay = TimeSpan.FromSeconds(3); Appearance = TimeSpan.FromSeconds(1); Font = new Font("Microsoft Sans Serif", 24, FontStyle.Bold, GraphicsUnit.Pixel); StringFormat = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; Title = new UITextElement("Tetris", Font, null, 0, 0, StringFormat); SubTitle = new UITextElement("By Yura Ruban", Font, null, 0, 0, StringFormat); }
public GameOverScreen(Game game, int scores) { Game = game; Scores = scores; Font font = new Font("Microsoft Sans Serif", 28, FontStyle.Bold, GraphicsUnit.Pixel); Font fontBtn = new Font("Microsoft Sans Serif", 14, FontStyle.Bold, GraphicsUnit.Pixel); StringFormat format = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; GameOverText = new UITextElement("GAME OVER", font, Brushes.White, game.CanvasWidth / 2, game.CanvasHeight / 2 - 16, format); ScoresText = new UITextElement("Yours score: " + Scores, font, Brushes.White, game.CanvasWidth / 2, game.CanvasHeight / 2 + 16, format); BackToMenuButton = new UIButtonElement("BACK TO MENU", game.CanvasWidth / 2 - 100, (int)(game.CanvasHeight * 0.7), 200, 30, Brushes.LightGray, Brushes.Gray, Brushes.Black, Brushes.White, fontBtn); }
public void setObjectiveTime(string text) { if (String.IsNullOrWhiteSpace(text)) { return; } this.objectiveTime = text; if (this.objectiveTimeTextElement == null) { this.objectiveTimeTextElement = new UITextElement(this.advice, 0.1, 0.13, 0.5f, true, GTA.Font.ChaletComprimeCologne, UIColor.WHITE); this.add(this.objectiveTimeTextElement); } this.objectiveTimeTextElement.setText(this.objectiveTime); }
public void setAdvice(string text) { if (String.IsNullOrWhiteSpace(text)) { return; } this.advice = text; if (this.adviceTextElement == null) { this.adviceTextElement = new UITextElement(this.advice, 0.5, 0.25, 0.7f, true, GTA.Font.ChaletComprimeCologne, UIColor.GREEN); this.add(this.adviceTextElement); } this.adviceTextElement.setText(this.advice); }
public TetrisGame(Game game, GameOptions gameOptions) { GameOptions = gameOptions; Game = game; Grid = new Block[Cols][]; for (int i = 0; i < Cols; i++) { Grid[i] = new Block[Rows]; } Font font = new Font("Microsoft Sans Serif", 14, FontStyle.Bold, GraphicsUnit.Pixel); NextFigure = new UITextElement("Next figure: ", font, Brushes.White, RightX, BlockWH * 2); ScoreUI = new UITextElement(ScoreText, font, Brushes.White, RightX, BlockWH * 10); FigureFactory = new FigureFactory(Cols, Rows, BlockWH); FigureChange += OnFigureChange; FigureChange += OnRowDestroy; FigureChange(); }
public LoadingPopup(string text_title, string text_content) : base() { // background this.background = new UIRectElement(0, 0, 2, 2, UIColor.BLACK, 230); this.add(this.background); // title this.title = new UITextElement(text_title, 0.5, 0.4, 2, true, Font.Pricedown, UIColor.GTA_YELLOW); this.add(this.title); // top separator this.add(new UIRectElement(0.5, 0.525, 0.9, 0.002, UIColor.WHITE, 255)); // content this.content = new UITextElement(text_content, 0.5, 0.530, 0.475, true, Font.ChaletLondon, UIColor.WHITE); this.add(this.content); // bottom separator this.add(new UIRectElement(0.5, 0.58, 0.9, 0.002, UIColor.WHITE, 255)); }
internal override BaseUIElement convertFromLuaData(BaseUIElement bue) { UITextElement utl; if (bue == null) { utl = new UITextElement(); } else { try { utl = bue as UITextElement; } catch (Exception) { utl = new UITextElement(); } } Reload(); return(utl); }
public static string GetText(UIElement element) { UITextElement textEl = element as UITextElement; return(textEl.text.Trim()); }
private UIElement GetMenuForLocation(GameLocation location, NPC npc = null, bool artifacts = false, bool structure = false) { var lmenu = UIElement.GetContainer("Location Menu " + location.Name, positioner: UIHelper.GetCentered(0, 0, 1f, 1f)); float textScale = 1.4f; if (LocalizedContentManager.CurrentLanguageLatin && menuFont2 != "" && menuFont2 != null) { textScale *= cFontAdjust; } var lname = !structure ? location.Name : location.uniqueName.Value; if (i18n.GetTranslations().ToList().Exists(t => t.Key == "location." + lname)) { lname = i18n.Get("location." + lname); } var lmenuHead = new UITextElement(lname, Game1.dialogueFont, Color.White, textScale, positioner: UIHelper.GetTopCenter(0, 5)); var back = location.Map.GetLayer("Back"); double w = back.LayerWidth; double h = back.LayerHeight; double s = (h / w); int tw = (menuWidth / 2) - (4 * margins); int th = (int)(tw * s); if (th > menuHeight * 0.75f) { s = (w / h); th = (int)(menuHeight * 0.75f); tw = (int)(th * s); } var lmenuViewer = UIElement.GetImage(PyDraw.getWhitePixel(), Color.Green, positioner: UIHelper.GetTopCenter(0, 50, tw, th)); var lmenuWarp = new UITextElement($"{i18n.Get("menu.locations.warp")} (X:0 Y:0)", Game1.dialogueFont, Color.White, textScale, positioner: UIHelper.GetTopCenter(0, th + 60)); var lmenuLoading = new UITextElement(i18n.Get("menu.locations.loading"), Game1.dialogueFont, Color.White, textScale, positioner: UIHelper.GetCentered()); lmenuViewer.Add(lmenuLoading); if (LocalizedContentManager.CurrentLanguageLatin && menuFont2 != "" && menuFont2 != null) { lmenuHead.WithFont(menuFont2); lmenuWarp.WithFont(menuFont2); lmenuLoading.WithFont(menuFont2); } lmenu.Add(lmenuViewer); Point tPoint = new Point(0, 0); lmenuViewer.WithInteractivity(update: (t, el) => { PlatoWarpMenuMod.GetLocationShot(location, () => { Texture2D screen = PlatoWarpMenuMod.LastScreen; if (PlatoWarpMenuMod.instance.config.UseTempFolder) { screen = Helper.Content.Load <Texture2D>(Path.Combine("Temp", (location.isStructure.Value ? location.uniqueName.Value : location.Name) + ".png")); } var image = UIElement.GetImage(screen, Color.White, positioner: el.Positioner); image.WithInteractivity(click: (point, right, released, hold, imageContainer) => { if (released && !right) { if (!location.isTileLocationTotallyClearAndPlaceableIgnoreFloors(new Vector2(tPoint.X, tPoint.Y))) { return; } Game1.activeClickableMenu = null; Game1.player.warpFarmer(new Warp(0, 0, structure ? location.uniqueName.Value : location.Name, tPoint.X, tPoint.Y, false)); } }, hover: (point, drag, imageContainer) => { var rect = imageContainer.Bounds; int x = (int)(((point.X - rect.X) / (double)rect.Width) * location.Map.GetLayer("Back").LayerWidth); int y = (int)(((point.Y - rect.Y) / (double)rect.Height) * location.Map.GetLayer("Back").LayerHeight); tPoint = new Point(x, y); lmenuWarp.Text = $"{i18n.Get("menu.locations.warp")} (X:{ (int)x} Y:{(int)y})"; if (!location.isTileLocationTotallyClearAndPlaceableIgnoreFloors(new Vector2(x, y))) { lmenuWarp.TextColor = Color.Red; } else { lmenuWarp.TextColor = Color.White; } }); lmenu.Add(image); lmenu.Remove(lmenuViewer); lmenu.UpdateBounds(); if (npc != null) { var rect = image.Bounds; int mx = (int)((npc.getTileX() / (double)location.Map.GetLayer("Back").LayerWidth) * rect.Width); int my = (int)((npc.getTileY() / (double)location.Map.GetLayer("Back").LayerHeight) * rect.Height); var lmenuMarker = UIElement.GetImage(CircleMarker, Color.Magenta * 0.6f, positioner: UIHelper.GetTopLeft(mx - 12, my - 12, 33, 33)); image.Add(lmenuMarker); } if (artifacts) { foreach (var spot in location.Objects.Keys.Where(o => location.Objects[o].ParentSheetIndex == 590)) { var rect = image.Bounds; int mx = (int)((spot.X / (double)location.Map.GetLayer("Back").LayerWidth) * rect.Width); int my = (int)((spot.Y / (double)location.Map.GetLayer("Back").LayerHeight) * rect.Height); var lmenuMarker = UIElement.GetImage(CircleMarker, Color.Red, positioner: UIHelper.GetTopLeft(mx - 5, my - 5, 11, 11)); image.Add(lmenuMarker); } } }); el.WithoutInteractivity(true); }); lmenu.Add(lmenuHead); lmenu.Add(lmenuWarp); return(lmenu); }
public static UIElement GetElementForFolder(string folder) { if (folder == null) { folder = "Null"; } bool active = TextureLoader.getFolderName() == folder; UIElement element = new UIElement(folder, UIHelper.Fill, 0, UIHelper.PlainTheme, Color.White, active ? 1f : 0.75f, false).AsSelectable("Folder", (s, e) => { e.Opacity = s ? 1f : 0.7f; e.GetElementById(e.Id + "_BgName").Color = s ? Color.DarkCyan : Color.Black; if (s) { Game1.playSound("coin"); } if (e.Base != null) { if (s) { foreach (UIElement selected in e.Base.GetSelected()) { if (selected != e) { selected.Deselect(); } } } if (!s) { if ((new List <UIElement>(e.Base.GetSelected())).Count == 0) { e.Select(); } } } if (s) { setFolder(e.Id); } }).WithInteractivity(hover: (point, hoverIn, e) => { if (e.IsSelected) { return; } if (hoverIn != e.WasHover) { Game1.playSound("smallSelect"); } if (hoverIn) { e.Opacity = e.IsSelected ? 1f : 0.9f; } else { e.Opacity = e.IsSelected ? 1f : 0.75f; } }); element.IsSelected = active; element.Overflow = true; int LastX = 0; float i = 0; bool scaled = false; if (folder == "Vanilla") { List <NPC> npcs = new List <NPC>(); for (int c = 0; c < numPortraits; c++) { NPC npc = null; while (npc == null || npcs.Contains(npc)) { npc = Utility.getRandomTownNPC(); } npcs.Add(npc); Texture2D p = Game1.content.Load <Texture2D>(@"Portraits/" + npc.Name); if (p is Texture2D portrait) { Texture2D t = portrait is ScaledTexture2D st ? st.STexture : portrait; int mx = Math.Max(t.Width / 2, 64); Rectangle s = new Rectangle(0, 0, mx, mx); int w = listElementHeight - margin * 2; int x = LastX + margin; LastX = x + w; i++; UIElement pic = UIElement.GetImage(portrait, Color.White, folder + "_Portrait_" + npc.Name, 1f / (i + 1), 0, UIHelper.GetTopLeft(x, margin, w)).WithSourceRectangle(s); element.Add(pic); } } } else { foreach (var texture in TextureLoader.pTextures.Where(k => k.Key.StartsWith(folder))) { if (texture.Value is Texture2D portrait) { if (i >= numPortraits) { i++; continue; } if (portrait is ScaledTexture2D || scaled) { scaled = true; } Texture2D t = portrait is ScaledTexture2D st ? st.STexture : portrait; int mx = Math.Max(t.Width / 2, 64); Rectangle s = new Rectangle(0, 0, mx, mx); int w = listElementHeight - margin * 2; int x = LastX + margin; LastX = x + w; i++; UIElement pic = UIElement.GetImage(portrait, Color.White, folder + "_Portrait_" + texture.Key, 1f / (i + 1), 0, UIHelper.GetTopLeft(x, margin, w)).WithSourceRectangle(s); element.Add(pic); } } } UITextElement name = new UITextElement(folder, Game1.smallFont, Color.White, 0.5f, 1f, folder + "_Name", 2, UIHelper.GetTopLeft(margin, margin)); UITextElement num = new UITextElement(folder == "Vanilla" ? " " : i.ToString(), Game1.tinyFont, Color.Black, 1f, 1f, folder + "_Num", 2, UIHelper.GetBottomRight(-1 * margin, -1 * margin)); var size = (Game1.smallFont.MeasureString(folder) * 0.5f).toPoint(); var scaleText = scaled ? "128+" : "64"; var scaleSize = (Game1.smallFont.MeasureString("XX") * 0.5f).toPoint(); int sIBSize = Math.Max(scaleSize.X, scaleSize.Y) + margin * 2; Point bgSize = new Point(size.X + margin * 4, size.Y + margin * 2); Texture2D bgName = PyTK.PyDraw.getFade(bgSize.X * 4, bgSize.Y * 4, Color.White * 0.8f, Color.Transparent); UIElement nameBg = UIElement.GetImage(bgName, active ? Color.DarkCyan : Color.Black, folder + "_BgName", 1, 1, UIHelper.GetTopLeft(0, 0, bgSize.X)); UIElement scaleInfoText = new UITextElement(scaleText, Game1.smallFont, Color.White, 0.5f, 1, folder + "_Scale", 2, UIHelper.GetCentered()); UIElement scaleInfoBackground = UIElement.GetImage(PyDraw.getCircle((int)(sIBSize * (scaled ? 4 : 1)), Color.White), Color.LightGray, folder + "_ScaleBG", 1, 1, UIHelper.GetTopRight(-1 * margin, margin, sIBSize)); scaleInfoBackground.Add(scaleInfoText); element.Add(name); element.Add(num); element.Add(scaleInfoBackground); element.Add(nameBg); return(element); }