public void InitializeGuilds() { gridGuilds.Clear(); foreach (DiscordGuild guild in DTT.Instance.currentClient.Guilds.Values) { UIGuild uiGuild = new UIGuild(guild); uiGuild.Width.Pixels = 20; uiGuild.Height.Pixels = 20; uiGuild.OnClick += (a, b) => { gridMessages.Clear(); DTT.Instance.currentGuild = guild; DTT.Instance.currentChannel = guild.GetDefaultChannel(); if (Utility.texCache.ContainsKey(guild.IconUrl)) { buttonGuilds.texture = Utility.texCache[guild.IconUrl]; } string name = "#" + DTT.Instance.currentChannel.Name.Replace("_", "-"); textCurrent.SetText(name); textCurrent.Width.Pixels = name.Measure().X; textCurrent.Height.Pixels = name.Measure().Y; textCurrent.Recalculate(); Utility.DownloadLog(DTT.Instance.currentChannel); InitializeChannels(); }; string path = $"{DTT.Guilds}{guild.Id}.png"; Utility.DownloadImage(path, guild.IconUrl, texture => uiGuild.texture = texture); gridGuilds.Add(uiGuild); } }
public void ChangeLayer() { string TypeName = LayerManager.ActiveLayer.GetType().FullName; textLayer.SetText(LayerManager.names[TypeName]); textLayer.Recalculate(); imageLayer.texture = LayerManager.icons[TypeName]; }
public override void Update(GameTime gameTime) { textGeneration.SetText($"Generating: {turbine.energyGen.AsPower(true)}"); textEfficiency.SetText($"Efficiency: {Math.Round(turbine.energyGen / (float)Main.maxTilesY * 100, 2)}%"); textGeneration.Recalculate(); textEfficiency.Recalculate(); base.Update(gameTime); }
public override void Update(GameTime gameTime) { textGeneration.SetText($"Generating: {turbine.energyGen.AsPower(true)}"); textWaterTiles.SetText($"Water Tiles: {Math.Round(turbine.waterVolume / 255f, 0)}/{TEWaterTurbine.MaxWaterTiles}"); textGeneration.Recalculate(); textWaterTiles.Recalculate(); base.Update(gameTime); }
public void UpdateText() { if (!IsVisible) { return; } timeLeftText.SetText(GetTimeLeftString(MapDevice.activeMD.timeLeft)); timeLeftText.Recalculate(); }
public override void Update(GameTime gameTime) { textGeneration.SetText($"Generating: {geothermalPlant.energyGen.AsPower(true)}"); textWaterTiles.SetText($"Heat: {geothermalPlant.GetHeat().ToSI()}HU"); textGeneration.Recalculate(); textWaterTiles.Recalculate(); base.Update(gameTime); }
private void AddLine(string text, float textScale = 1, bool large = false) { var uiText = new UIText(text, textScale, large); uiText.Top.Pixels = _height; uiText.MarginBottom = 10; uiText.Recalculate(); _height += uiText.GetOuterDimensions().Height; Append(uiText); }
public override void Update(GameTime gameTime) { textGeneration.SetText($"Generating: {coalPlant.energyGen.AsPower(true)}"); textBurnTime.SetText($"Energy Left: {coalPlant.energyLeft.ToSI()}/{coalPlant.maxEnergy.ToSI()}"); textGeneration.Recalculate(); textBurnTime.Recalculate(); base.Update(gameTime); }
public override void Update(GameTime gameTime) { textGeneration.SetText($"Generating: {panel.energyGen.AsPower(true)}"); float eff = Main.dayTime ? (float)(Main.time < 13500 ? Main.time / 13500 : 13500 / (Main.time - 13500)) * 100 : 0; textEfficiency.SetText($"Efficiency: {Math.Round(eff, 2)}%"); textGeneration.Recalculate(); textEfficiency.Recalculate(); base.Update(gameTime); }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (needToRemoveLoading) { needToRemoveLoading = false; uIPanel.RemoveChild(uiLoader); } if (!updateNeeded) { return; } updateNeeded = false; filter = filterTextBox.Text; modList.Clear(); var filterResults = new UIModsFilterResults(); var visibleItems = items.Where(item => item.PassFilters(filterResults)).ToList(); if (filterResults.AnyFiltered) { var panel = new UIPanel(); panel.Width.Set(0, 1f); modList.Add(panel); var filterMessages = new List <string>(); if (filterResults.filteredByEnabled > 0) { filterMessages.Add(Language.GetTextValue("tModLoader.ModsXModsFilteredByEnabled", filterResults.filteredByEnabled)); } if (filterResults.filteredByModSide > 0) { filterMessages.Add(Language.GetTextValue("tModLoader.ModsXModsFilteredByModSide", filterResults.filteredByModSide)); } if (filterResults.filteredBySearch > 0) { filterMessages.Add(Language.GetTextValue("tModLoader.ModsXModsFilteredBySearch", filterResults.filteredBySearch)); } string filterMessage = string.Join("\n", filterMessages); var text = new UIText(filterMessage); text.Width.Set(0, 1f); text.IsWrapped = true; text.WrappedTextBottomPadding = 0; text.TextOriginX = 0f; text.Recalculate(); panel.Append(text); panel.Height.Set(text.MinHeight.Pixels + panel.PaddingTop, 0f); } modList.AddRange(visibleItems); Recalculate(); modList.ViewPosition = modListViewPosition; }
private void AddControlLine(string control, string action) { var controlText = new UIText(control); controlText.Top.Pixels = _height; controlText.MarginTop = 5; controlText.Recalculate(); _height += controlText.GetOuterDimensions().Height; var actionText = new UIText(action); actionText.Top = controlText.Top; actionText.HAlign = 1; Append(controlText); Append(actionText); }
private void UpdateCounter() { int numItems = 0; int capacity = 0; foreach (TEAbstractStorageUnit abstractStorageUnit in heart.GetStorageUnits()) { if (abstractStorageUnit is TEStorageUnit storageUnit) { numItems += storageUnit.NumItems; capacity += storageUnit.Capacity; } } int len = capacityText.Text.Length; capacityText.SetText(numItems + "/" + capacity + " Items"); if (len != capacityText.Text.Length) { capacityText.Recalculate(); } }
protected override void DrawSelf(SpriteBatch spriteBatch) { if (Main.gameMenu) { if (PlayerInput.UsingGamepad) { outerLayer2.Remove(); if (!Elements.Contains(outerLayer1)) { Append(outerLayer1); } outerLayer1.Activate(); outerLayer2.Deactivate(); Recalculate(); RecalculateChildren(); if (_labelHeight != 0f) { _textBox.Top.Pixels = _textBoxHeight; _label.Top.Pixels = _labelHeight; _textBox.Recalculate(); _label.Recalculate(); _labelHeight = (_textBoxHeight = 0f); UserInterface.ActiveInstance.ResetLasts(); } } else { outerLayer1.Remove(); if (!Elements.Contains(outerLayer2)) { Append(outerLayer2); } outerLayer2.Activate(); outerLayer1.Deactivate(); Recalculate(); RecalculateChildren(); if (_textBoxHeight == 0f) { _textBoxHeight = _textBox.Top.Pixels; _labelHeight = _label.Top.Pixels; _textBox.Top.Pixels += 50f; _label.Top.Pixels += 50f; _textBox.Recalculate(); _label.Recalculate(); UserInterface.ActiveInstance.ResetLasts(); } } } if (!Main.editSign && _edittingSign) { IngameFancyUI.Close(); return; } if (!Main.editChest && _edittingChest) { IngameFancyUI.Close(); return; } base.DrawSelf(spriteBatch); UpdateOffsetDown(); OffsetDown = 0; ShouldHideText = false; SetupGamepadPoints(spriteBatch); PlayerInput.WritingText = true; Main.instance.HandleIME(); Vector2 position = new Vector2(Main.screenWidth / 2, _textBox.GetDimensions().ToRectangle().Bottom + 32); Main.instance.DrawWindowsIMEPanel(position, 0.5f); string text = Main.GetInputText(Text, _edittingSign); if (_edittingSign && Main.inputTextEnter) { text += "\n"; } else { if (_edittingChest && Main.inputTextEnter) { ChestUI.RenameChestSubmit(Main.player[Main.myPlayer]); IngameFancyUI.Close(); return; } if (Main.inputTextEnter && CanSubmit) { Submit(); } else if (_edittingChest && Main.player[Main.myPlayer].chest < 0) { ChestUI.RenameChestCancel(); } else if (Main.inputTextEscape) { if (_edittingSign) { Main.InputTextSignCancel(); } if (_edittingChest) { ChestUI.RenameChestCancel(); } IngameFancyUI.Close(); return; } } if (IngameFancyUI.CanShowVirtualKeyboard(_keyboardContext)) { if (text != Text) { Text = text; } if (_edittingSign) { CopyTextToSign(); } if (_edittingChest) { CopyTextToChest(); } } byte b = (byte)((255 + Main.tileColor.R * 2) / 3); Color value = new Color((int)b, (int)b, (int)b, 255); _textBox.TextColor = Color.Lerp(Color.White, value, 0.2f); _label.TextColor = Color.Lerp(Color.White, value, 0.2f); position = new Vector2(Main.screenWidth / 2, _textBox.GetDimensions().ToRectangle().Bottom + 32); Main.instance.DrawWindowsIMEPanel(position, 0.5f); }
/// <summary> /// Update any text that depends on the item stats /// </summary> public void UpdateText() { if (!IsVisible) { return; } if (selectedAction == SelectedAction.None) { modifierCostText.SetText("0"); } else { modifierCostText.SetText(ModifierForge.activeForge.CalculateCost((ModifierForgeTE.ForgeAction)selectedAction).ToString()); } modifierCostText.Recalculate(); int i = 0; if (!modifiedItemSlot.item.IsAir) { AffixItemItem pomItem = modifiedItemSlot.item.GetGlobalItem <AffixItemItem>(); freeAffixCount.SetText($"[{pomItem.FreeAffixes}]"); freePrefixCount.SetText($"[{pomItem.FreePrefixes}]"); freeSuffixCount.SetText($"[{pomItem.FreeSuffixes}]"); foreach (var prefix in pomItem.prefixes) { if (i >= itemInfoText.Length) { break; } UIText iiText = itemInfoText[i]; iiText.SetText(prefix.GetForgeText(modifiedItemSlot.item)); iiText.TextColor = prefix.Color; iiText.Recalculate(); i++; } foreach (var suffix in pomItem.suffixes) { if (i >= itemInfoText.Length) { break; } UIText iiText = itemInfoText[i]; iiText.SetText(suffix.GetForgeText(modifiedItemSlot.item)); iiText.TextColor = suffix.Color; iiText.Recalculate(); i++; } } else { freeAffixCount.SetText($"[-]"); freePrefixCount.SetText($"[-]"); freeSuffixCount.SetText($"[-]"); } for (; i < itemInfoText.Length; i++) { itemInfoText[i].SetText(string.Empty); itemInfoText[i].Recalculate(); } }