public override void InitializeComponents() { var self = this; float yOffset = 0f; var textElem = new UIText("Adjust Sound Emitter", 1f, true); this.InnerContainer.Append((UIElement)textElem); yOffset += 48f; this.InitializeWidgetsForType(ref yOffset); this.IntializeWidgetsForStyle(ref yOffset); this.InitializeWidgetsForVolume(ref yOffset); this.InitializeWidgetsForPitch(ref yOffset); this.InitializeWidgetsForDelay(ref yOffset); yOffset -= 28f; var applyButton = new UITextPanelButton(UITheme.Vanilla, "Apply"); applyButton.Top.Set(yOffset + 50f, 0f); applyButton.Left.Set(-64f, 1f); applyButton.Height.Set(applyButton.GetOuterDimensions().Height + 4f, 0f); applyButton.OnClick += (_, __) => { self.Close(); self.ApplySettingsToCurrentItem(); }; this.InnerContainer.Append((UIElement)applyButton); }
//////////////// /// <summary> /// Initializes components. /// </summary> public override void InitializeComponents() { var self = this; var title = new UIText(this.TitleText); this.InnerContainer.Append((UIElement)title); this.ConfirmButton = new UITextPanelButton(this.Theme, "Ok"); this.ConfirmButton.Top.Set(-32f, 1f); this.ConfirmButton.Left.Set(-192f, 0.5f); this.ConfirmButton.Width.Set(128f, 0f); this.ConfirmButton.OnClick += (_, __) => { self.OnReply(true); self.SetDialogToClose = true; DialogManager.Instance.UnsetForcedModality(); }; this.InnerContainer.Append(this.ConfirmButton); this.CancelButton = new UITextPanelButton(this.Theme, "Cancel"); this.CancelButton.Top.Set(-32f, 1f); this.CancelButton.Left.Set(64f, 0.5f); this.CancelButton.Width.Set(128f, 0f); this.CancelButton.OnClick += (_, __) => { self.OnReply(false); self.SetDialogToClose = true; DialogManager.Instance.UnsetForcedModality(); }; this.InnerContainer.Append(this.CancelButton); }
private void AddTabButton(string title) { UIControlPanelTab tab = this.Tabs[title]; int idx = this.TabTitleOrder[title]; int posX = UIControlPanel.TabButtonWidth * idx; var button = new UITextPanelButton(tab.Theme, title); button.Left.Set((float)posX, 0f); button.Top.Set(-UIControlPanel.TabButtonHeight, 0f); button.Width.Set(UIControlPanel.TabButtonWidth, 0f); button.Height.Set(UIControlPanel.TabButtonHeight, 0f); button.OnClick += (_, __) => { this.ChangeToTabIf(title); }; this.MidContainer.Append(button); this.OuterContainer.Recalculate(); // this.TabButtons.Add(button); this.TabButtonsByName[title] = button; this.TabButtonHover[title] = false; }
//////////////// public override void InitializeComponents() { var self = this; var title = new UIText(this.TitleText); this.InnerContainer.Append((UIElement)title); this.ConfirmButton = new UITextPanelButton(this.Theme, "Ok"); this.ConfirmButton.Top.Set(-32f, 1f); this.ConfirmButton.Left.Set(-192f, 0.5f); this.ConfirmButton.Width.Set(128f, 0f); this.ConfirmButton.OnClick += delegate(UIMouseEvent evt, UIElement listening_element) { self.ConfirmAction(); self.SetDialogToClose = true; DialogManager.Instance.UnsetForcedModality(); }; this.InnerContainer.Append(this.ConfirmButton); this.CancelButton = new UITextPanelButton(this.Theme, "Cancel"); this.CancelButton.Top.Set(-32f, 1f); this.CancelButton.Left.Set(64f, 0.5f); this.CancelButton.Width.Set(128f, 0f); this.CancelButton.OnClick += delegate(UIMouseEvent evt, UIElement listening_element) { if (self.CancelAction != null) { self.CancelAction.Invoke(); } self.SetDialogToClose = true; DialogManager.Instance.UnsetForcedModality(); }; this.InnerContainer.Append(this.CancelButton); }
//////////////// private void ApplyTabButtonMouseInteractivity(int idx) { UITextPanelButton button = this.TabButtons[idx]; if (!button.GetOuterDimensions().ToRectangle().Contains(Main.mouseX, Main.mouseY)) { if (this.TabButtonHover[idx]) { this.TabButtonHover[idx] = false; button.MouseOut(new UIMouseEvent(button, new Vector2(Main.mouseX, Main.mouseY))); } return; } if (!this.TabButtonHover[idx]) { this.TabButtonHover[idx] = true; ReflectionHelpers.Set(button, "_isMouseHovering", true); } var evt = new UIMouseEvent(button, new Vector2(Main.mouseX, Main.mouseY)); button.MouseOver(evt); if (Main.mouseLeft && Main.mouseLeftRelease) { button.Click(evt); } }
//////////////// private void InitializeComponents() { this.OuterContainer = new UIElement(); this.OuterContainer.Width.Set(UIControlPanel.ContainerWidth, 0f); this.OuterContainer.Height.Set(UIControlPanel.ContainerHeight + UIControlPanel.TabButtonHeight, 0f); //this.OuterContainer.MaxWidth.Set( UIControlPanel.ContainerWidth, 0f ); //this.OuterContainer.MaxHeight.Set( UIControlPanel.ContainerHeight, 0f ); this.OuterContainer.HAlign = 0f; //this.MainElement.BackgroundColor = ControlPanelUI.MainBgColor; //this.MainElement.BorderColor = ControlPanelUI.MainEdgeColor; this.Append(this.OuterContainer); this.RecalculateContainerDimensions(); this.MidContainer = new UIThemedPanel(this.Theme, false); this.MidContainer.SetPadding(0f); this.MidContainer.PaddingTop = UIControlPanel.TabButtonHeight; this.MidContainer.Width.Set(0f, 1f); this.MidContainer.Height.Set(0f, 1f); this.MidContainer.HAlign = 0f; this.OuterContainer.Append((UIElement)this.MidContainer); var closeButton = new UITextPanelButton(this.Theme, "X"); closeButton.Top.Set(-24f, 0f); closeButton.Left.Set(-24f, 1f); closeButton.Width.Set(24f, 0f); closeButton.Height.Set(24f, 0f); closeButton.OnMouseOver += (_, __) => this.Theme.ApplyButtonLit(closeButton); closeButton.OnMouseOut += (_, __) => this.Theme.ApplyButton(closeButton); closeButton.OnClick += (_, __) => { this.Close(); Main.PlaySound(SoundID.MenuClose); }; this.MidContainer.Append(closeButton); this.InnerContainer = this.CurrentTab; this.InnerContainer.Width.Set(0f, 1f); this.InnerContainer.Height.Set(0f, 1f); this.InnerContainer.PaddingBottom = UIControlPanel.TabButtonHeight; this.MidContainer.Append((UIElement)this.InnerContainer); this.InnerContainer.Initialize(); this.IsInitialized = true; foreach (var kv in this.Tabs) { this.InitializeTab(kv.Key, kv.Value); } UIControlPanel.DefaultTabButtonColor = this.Theme.ButtonTextColor; }
private void ApplyTabButtonMouseOut(string tabName) { UITextPanelButton button = this.TabButtonsByName[tabName]; if (this.TabButtonHover[tabName]) { this.TabButtonHover[tabName] = false; Timers.RunNow(() => { button.MouseOut(new UIMouseEvent(button, new Vector2(Main.mouseX, Main.mouseY))); }); } }
//////////////// /// <summary> /// Initializes elements of this prompt. /// </summary> public override void OnInitialize() { this.Width.Set(this.MyWidth, 0f); this.Height.Set(this.MyHeight, 0f); this.MaxWidth.Set(this.MyWidth, 0f); this.MaxHeight.Set(this.MyHeight, 0f); this.HAlign = 0f; this.Recalculate(); var title = new UIText(this.TitleText); this.Append((UIElement)title); this.ConfirmButton = new UITextPanelButton(this.Theme, "Ok"); this.ConfirmButton.Top.Set(-32f, 1f); this.ConfirmButton.Left.Set((this.CancelAction != null ? -192f : -64f), 0.5f); this.ConfirmButton.Width.Set(128f, 0f); this.ConfirmButton.OnClick += (_, __) => { this.ConfirmAction(); Timers.SetTimer("ModLibs_UIPromptPanel_Remove_" + this.GetHashCode(), 0, false, () => { this.Remove(); return(false); }); }; this.Append(this.ConfirmButton); if (this.CancelAction != null) { this.CancelButton = new UITextPanelButton(this.Theme, "Cancel"); this.CancelButton.Top.Set(-32f, 1f); this.CancelButton.Left.Set(64f, 0.5f); this.CancelButton.Width.Set(128f, 0f); this.CancelButton.OnClick += (_, __) => { this.CancelAction.Invoke(); Timers.SetTimer("ModLibs_UIPromptPanel_Remove_" + this.GetHashCode(), 0, false, () => { this.Remove(); return(false); }); }; this.Append(this.CancelButton); } this.RefreshTheme(); }
public void OnPostSetupContent() { if (Main.dedServ) { return; } var button = new UITextPanelButton(UITheme.Vanilla, "Open Mod Config Folder"); button.Top.Set(11f, 0f); button.Left.Set(-104f, 0.5f); button.Width.Set(208f, 0f); button.Height.Set(20f, 0f); button.OnClick += (UIMouseEvent evt, UIElement listeningElement) => { string fullpath = Main.SavePath + Path.DirectorySeparatorChar + HamstarHelpersConfigData.RelativePath; try { Process.Start(fullpath); } catch (Exception) { } }; Func <UIState, UIElement> get_top_row = delegate(UIState ui) { Type ui_type = ui.GetType(); FieldInfo ui_container_field = ui_type.GetField("uIPanel", BindingFlags.Instance | BindingFlags.NonPublic); UIPanel ui_container = (UIPanel)ui_container_field.GetValue(ui); Type ui_container_type = ui_container.GetType(); FieldInfo ui_container_elems_field = ui_container_type.GetField("Elements", BindingFlags.Instance | BindingFlags.NonPublic); List <UIElement> ui_container_elems = (List <UIElement>)ui_container_elems_field.GetValue(ui_container); return((UIElement)ui_container_elems[2]); }; Action <UIState> on_load = delegate(UIState ui) { UIElement elem = get_top_row(ui); elem.Append(button); }; Action <UIState> on_unload = delegate(UIState ui) { UIElement elem = get_top_row(ui); elem.RemoveChild(button); }; MenuUI.AddMenuLoader("UIMods", "ModHelpers: Mod Menu Config Folder Button", on_load, on_unload); }
public DialogueChoices( string dialogue, Texture2D portrait, int height, IList <string> choices, Action <string> onChoice) { if (Main.netMode == NetmodeID.Server) { return; } var singleton = ModContent.GetInstance <DialogueChoices>(); this.DialogueElem = singleton.DialogueElem; this.PortraitElem = singleton.PortraitElem; this.TextElem = singleton.TextElem; this.TextElem.SetText(dialogue); this.PortraitElem.SetImage(portrait); this.DialogueElem.Height.Set(height, 0f); int i = 0; foreach (string choice in choices) { string thisChoice = choice; var choiceElem = new UITextPanelButton(UITheme.Vanilla, thisChoice); choiceElem.Left.Set(i * 96f, 0f); choiceElem.Top.Set(-40f, 1f); choiceElem.Width.Set(96f, 0f); choiceElem.OnClick += (_, __) => { onChoice(thisChoice); }; this.DialogueElem.AppendThemed(choiceElem); this.ChoiceButtons.Add(choiceElem); i++; } this.DialogueElem.Recalculate(); this.DialogueElem.Show(); this.DialogueElem.Recalculate(); }
private static void InitializeOpenConfigButton() { var button = new UITextPanelButton(UITheme.Vanilla, "Open Mod Config Folder"); button.Top.Set(11f, 0f); button.Left.Set(-104f, 0.5f); button.Width.Set(208f, 0f); button.Height.Set(20f, 0f); button.OnClick += (UIMouseEvent evt, UIElement listeningElement) => { string fullpath = Main.SavePath + Path.DirectorySeparatorChar + HamstarHelpersConfigData.RelativePath; try { Process.Start(fullpath); } catch (Exception) { } }; var buttonWidgetCtx = new WidgetMenuContext(button, true); MenuContextService.AddMenuContext("UIMods", "ModHelpers: Mod Menu Config Folder Button", buttonWidgetCtx); }
private void ApplyTabButtonMouseOver(string tabName) { UITextPanelButton button = this.TabButtonsByName[tabName]; var evt = new UIMouseEvent(button, new Vector2(Main.mouseX, Main.mouseY)); if (!this.TabButtonHover[tabName]) { this.TabButtonHover[tabName] = true; ReflectionLibraries.Set(button, "_isMouseHovering", true); Timers.RunNow(() => button.MouseOver(evt)); } if (Main.mouseLeft && Main.mouseLeftRelease) { Timers.RunNow(() => { button.Click(evt); }); } }
//////////////// private void ApplyTabButtonMouseInteractivity(string tabName) { UITextPanelButton button = this.TabButtonsByName[tabName]; if (button.GetOuterDimensions().ToRectangle().Contains(Main.mouseX, Main.mouseY)) { this.ApplyTabButtonMouseOver(tabName); } else { this.ApplyTabButtonMouseOut(tabName); } if (tabName == this.CurrentTabName) { button.TextColor = Color.Yellow; } else { button.TextColor = UIControlPanel.DefaultTabButtonColor; } }
//////////////// public override void OnInitialize() { this.Width.Set(this.MyWidth, 0f); this.Height.Set(this.MyHeight, 0f); this.MaxWidth.Set(this.MyWidth, 0f); this.MaxHeight.Set(this.MyHeight, 0f); this.HAlign = 0f; this.Recalculate(); var title = new UIText(this.TitleText); this.Append((UIElement)title); this.ConfirmButton = new UITextPanelButton(this.Theme, "Ok"); this.ConfirmButton.Top.Set(-32f, 1f); this.ConfirmButton.Left.Set((this.CancelAction != null ? -192f : -64f), 0.5f); this.ConfirmButton.Width.Set(128f, 0f); this.ConfirmButton.OnClick += delegate(UIMouseEvent evt, UIElement listeningElement) { this.ConfirmAction(); this.Remove(); }; this.Append(this.ConfirmButton); if (this.CancelAction != null) { this.CancelButton = new UITextPanelButton(this.Theme, "Cancel"); this.CancelButton.Top.Set(-32f, 1f); this.CancelButton.Left.Set(64f, 0.5f); this.CancelButton.Width.Set(128f, 0f); this.CancelButton.OnClick += delegate(UIMouseEvent evt, UIElement listeningElement) { this.CancelAction.Invoke(); this.Remove(); }; this.Append(this.CancelButton); } this.Theme.ApplyPanel(this); }
//////////////// private void AddTabCloseButton(string title) { UIControlPanelTab tab = this.Tabs[title]; var closeButton = new UITextPanelButton(tab.Theme, "X"); closeButton.Top.Set(-8f, 0f); closeButton.Left.Set(-16f, 1f); closeButton.Width.Set(24f, 0f); closeButton.Height.Set(24f, 0f); closeButton.OnClick += (_, __) => { this.Close(); Main.PlaySound(SoundID.MenuClose); }; closeButton.OnMouseOver += (_, __) => { tab.Theme.ApplyButtonLit(closeButton); }; closeButton.OnMouseOut += (_, __) => { tab.Theme.ApplyButton(closeButton); }; tab.Append(closeButton); }
//////////////// private void InitializeTabButtons(ref float yOffset) { // Main tab button var mainTabBut = new UITextPanelButton(UITheme.Vanilla, "Main Tab"); mainTabBut.Top.Set(yOffset, 0f); //mainTabBut.Left.Set(-235f, 1f); mainTabBut.Height.Set(mainTabBut.GetOuterDimensions().Height + 4f, 0f); mainTabBut.OnClick += (_, __) => { this.SwitchTab(HologramUITab.Main); }; this.InnerContainer.Append((UIElement)mainTabBut); // Color tab button var colorTabBut = new UITextPanelButton(UITheme.Vanilla, "Color Tab"); colorTabBut.Top.Set(yOffset, 0f); colorTabBut.Left.Set(-472f, 1f); colorTabBut.Height.Set(colorTabBut.GetOuterDimensions().Height - 4f, 0f); colorTabBut.OnClick += (_, __) => { this.SwitchTab(HologramUITab.Color); }; this.InnerContainer.Append((UIElement)colorTabBut); // Shader tab button var shaderTabBut = new UITextPanelButton(UITheme.Vanilla, "Shader Tab"); shaderTabBut.Top.Set(yOffset, 0f); shaderTabBut.Left.Set(-372f, 1f); shaderTabBut.Height.Set(shaderTabBut.GetOuterDimensions().Height - 4f, 0f); shaderTabBut.OnClick += (_, __) => { this.SwitchTab(HologramUITab.Shader); }; this.InnerContainer.Append((UIElement)shaderTabBut); yOffset += 36; }
//////////////// public virtual void ApplyButton(UITextPanelButton panel) { panel.BackgroundColor = this.ButtonBgColor; panel.BorderColor = this.ButtonEdgeColor; panel.TextColor = this.ButtonTextColor; }
public override void InitializeComponents() { var self = this; var self_theme = this.Theme.Clone(); this.OuterContainer.Height.Set(-256, 1f); this.OuterContainer.MaxHeight.Set(-256, 1f); this.SetTopPosition(MenuItem.MenuTopPos - 68f, 0f, false); this.RecalculateMe(); //// this.Header = new UITextPanel <string>("Server Browser", 0.8f, true); this.Header.HAlign = 0.5f; this.Header.Top.Set(-35f, 0f); this.Header.SetPadding(15f); this.OuterContainer.Append((UIElement)this.Header); this.Theme.ApplyHeader(this.Header); //// var theme_button_theme = UITheme.Vanilla.Clone(); var theme_button = new UITextPanelButton(theme_button_theme, "B", 0.8f); theme_button.Top.Set(-8f, 0f); theme_button.Left.Set(-12f, 1f); theme_button.Width.Set(16f, 0f); theme_button.Height.Set(16f, 0f); theme_button.OnClick += delegate(UIMouseEvent evt, UIElement listening_element) { if (theme_button.Text == "B") { theme_button.SetText("R"); this.Theme.Switch(UITheme.Vanilla); theme_button_theme.Switch(self_theme); } else { theme_button.SetText("B"); this.Theme.Switch(self_theme); theme_button_theme.Switch(UITheme.Vanilla); } theme_button.RefreshTheme(); this.RefreshTheme(); }; this.InnerContainer.Append((UIElement)theme_button); //// this.SortByNameButton = new UITextPanelButton(this.Theme, "Sort by name", 1.2f); this.SortByNameButton.Top.Set(12f, 0f); this.SortByNameButton.Left.Set(0f, 0f); this.SortByNameButton.Width.Set(128f, 0f); this.SortByNameButton.Height.Set(32f, 0f); this.SortByNameButton.OnClick += delegate(UIMouseEvent evt, UIElement listening_element) { this.SortServerListByName(); }; this.InnerContainer.Append((UIElement)this.SortByNameButton); this.SortByPingButton = new UITextPanelButton(this.Theme, "Sort by ping", 1.2f); this.SortByPingButton.Top.Set(12f, 0f); this.SortByPingButton.Left.Set(128f + 12f, 0f); this.SortByPingButton.Width.Set(128f, 0f); this.SortByPingButton.Height.Set(32f, 0f); this.SortByPingButton.OnClick += delegate(UIMouseEvent evt, UIElement listening_element) { this.SortServerListByPing(); }; this.InnerContainer.Append((UIElement)this.SortByPingButton); this.SortByPlayersButton = new UITextPanelButton(this.Theme, "Sort by players", 1.2f); this.SortByPlayersButton.Top.Set(12f, 0f); this.SortByPlayersButton.Left.Set(256f + 14.5f, 0f); this.SortByPlayersButton.Width.Set(136f, 0f); this.SortByPlayersButton.Height.Set(32f, 0f); this.SortByPlayersButton.OnClick += delegate(UIMouseEvent evt, UIElement listening_element) { this.SortServerListByPlayers(); }; this.InnerContainer.Append((UIElement)this.SortByPlayersButton); this.FilterByModInput = new UITextField(this.Theme, "Enter mod filter"); this.FilterByModInput.Top.Set(12f, 0f); this.FilterByModInput.Left.Set(-320f, 1f); this.FilterByModInput.Width.Set(160f, 0f); this.FilterByModInput.Height.Set(32f, 0f); this.FilterByModInput.PaddingTop += 4f; this.FilterByModInput.OnTextChange += delegate(object sender, EventArgs e) { this.FilterServerListByMod(((TextInputEventArgs)e).Text); }; this.InnerContainer.Append((UIElement)this.FilterByModInput); this.FilterByNameInput = new UITextField(this.Theme, "Enter text filter"); this.FilterByNameInput.Top.Set(12f, 0f); this.FilterByNameInput.Left.Set(-160f, 1f); this.FilterByNameInput.Width.Set(160f, 0f); this.FilterByNameInput.Height.Pixels = 32f; this.FilterByNameInput.PaddingTop += 4f; this.FilterByNameInput.OnTextChange += delegate(object sender, EventArgs e) { this.FilterServerListByText(((TextInputEventArgs)e).Text); }; this.InnerContainer.Append((UIElement)this.FilterByNameInput); //// this.LockedFilterButton = new UITextPanelButton(this.Theme, "All", 0.65f); this.LockedFilterButton.Top.Set(42f, 0f); this.LockedFilterButton.Left.Set(-72f, 1f); this.LockedFilterButton.Width.Set(72f, 0f); this.LockedFilterButton.Height.Pixels = 16f; this.LockedFilterButton.OnClick += delegate(UIMouseEvent evt, UIElement listening_element) { this.CycleFilterServerListByLocked(); if (this.PasswordFilterMode == 0) { this.LockedFilterButton.SetText("All"); } else if (this.PasswordFilterMode >= 1) { this.LockedFilterButton.SetText("Locked"); } else { this.LockedFilterButton.SetText("Open"); } }; this.InnerContainer.Append((UIElement)this.LockedFilterButton); //// var server_name_col_label = new UIText("World Name", 0.75f); server_name_col_label.Top.Set(46f, 0f); server_name_col_label.Left.Set(UIServerDataElement.WorldLabelLeft + 8f, 0f); this.InnerContainer.Append((UIElement)server_name_col_label); var uptime_col_label = new UIText("Up Time", 0.75f); uptime_col_label.Top.Set(46f, 0f); uptime_col_label.Left.Set(UIServerDataElement.UptimeLabelLeft + 8f, 0f); this.InnerContainer.Append((UIElement)uptime_col_label); var ping_col_label = new UIText("Ping", 0.75f); ping_col_label.Top.Set(46f, 0f); ping_col_label.Left.Set(UIServerDataElement.PingLabelLeft + 8f, 0f); this.InnerContainer.Append((UIElement)ping_col_label); var prog_col_label = new UIText("Progress", 0.75f); prog_col_label.Top.Set(46f, 0f); prog_col_label.Left.Set(UIServerDataElement.WorldProgressLabelLeft + 8f, 0f); this.InnerContainer.Append((UIElement)prog_col_label); var event_col_label = new UIText("Current Event", 0.75f); event_col_label.Top.Set(46f, 0f); event_col_label.Left.Set(UIServerDataElement.WorldEventLabelLeft + 8f, 0f); this.InnerContainer.Append((UIElement)event_col_label); //// this.ServerList = new UIServerBrowserList(this.Theme); this.ServerList.Top.Set(60f, 0f); this.ServerList.Width.Set(0f, 1f); this.ServerList.Height.Set(-74f, 1f); this.ServerList.HAlign = 0f; this.ServerList.SetPadding(4f); this.ServerList.PaddingTop = 0.0f; this.ServerList.Initialize(); this.InnerContainer.Append((UIElement)this.ServerList); this.ServerListErr = new UIText("", 1f); this.ServerListErr.Top.Set(60f + 8f, 0f); this.ServerListErr.Left.Set(-128, 0.5f); this.ServerListErr.Width.Set(256, 0f); this.InnerContainer.Append((UIElement)this.ServerListErr); //// var modrecommend_url = new UIWebUrl(this.Theme, "Trouble choosing mods?", "https://sites.google.com/site/terrariamodsuggestions/", true, 0.86f); modrecommend_url.Top.Set(-12f, 1f); modrecommend_url.Left.Set(0f, 0f); modrecommend_url.Width.Set(172f, 0f); this.InnerContainer.Append((UIElement)modrecommend_url); var support_url = new UIWebUrl(this.Theme, "Help me improve uptime!", "https://www.patreon.com/hamstar0", true, 0.86f); support_url.Top.Set(-12f, 1f); support_url.Left.Set(-176f, 1f); support_url.Width.Set(176f, 0f); this.InnerContainer.Append((UIElement)support_url); }
public void AddCloseButton(UITextPanelButton button) { this.Append(button); }
private void InitializeMe() { var self = this; string server_name = this.Data.WorldName.Length > 20 ? this.Data.WorldName.Substring(0, 18) + "..." : this.Data.WorldName; TimeSpan uptime = this.Data.GetTimeSpan(); this.SetPadding(4f); this.Width.Set(0f, 1f); this.Height.Set(48f, 0f); var world_label = new UIText(server_name); world_label.Left.Set(UIServerDataElement.WorldLabelLeft, 0f); world_label.Top.Set(UIServerDataElement.WorldLabelTop, 0f); this.Append((UIElement)world_label); var uptime_label = new UIText(uptime.ToString()); uptime_label.Left.Set(UIServerDataElement.UptimeLabelLeft, 0f); uptime_label.Top.Set(UIServerDataElement.UptimeLabelTop, 0f); this.Append((UIElement)uptime_label); var ping_label = new UIText(this.Data.AveragePing + "ms"); ping_label.Left.Set(UIServerDataElement.PingLabelLeft, 0f); ping_label.Top.Set(UIServerDataElement.PingLabelTop, 0f); this.Append((UIElement)ping_label); var world_prog_label = new UIText(this.Data.WorldProgress); world_prog_label.Left.Set(UIServerDataElement.WorldProgressLabelLeft, 0f); world_prog_label.Top.Set(UIServerDataElement.WorldProgressLabelTop, 0f); this.Append((UIElement)world_prog_label); var world_event_label = new UIText(this.Data.WorldEvent); world_event_label.Left.Set(UIServerDataElement.WorldEventLabelLeft, 0f); world_event_label.Top.Set(UIServerDataElement.WorldEventLabelTop, 0f); this.Append((UIElement)world_event_label); //// var ip_label = new UIText("IP: " + this.Data.ServerIP + ":" + this.Data.Port, 0.8f); ip_label.Left.Set(UIServerDataElement.IPLabelLeft, 0f); ip_label.Top.Set(UIServerDataElement.IPLabelTop, 0f); this.Append((UIElement)ip_label); var player_count_label = new UIText("Players: " + this.Data.PlayerCount + "/" + this.Data.MaxPlayerCount, 0.8f); player_count_label.Left.Set(UIServerDataElement.PlayerCountLabelLeft, 0f); player_count_label.Top.Set(UIServerDataElement.PlayerCountLabelTop, 0f); this.Append((UIElement)player_count_label); var player_pvp_count_label = new UIText("PVPers: " + this.Data.PlayerPvpCount + "/" + this.Data.PlayerCount, 0.8f); player_pvp_count_label.Left.Set(UIServerDataElement.PlayerPvpCountLabelLeft, 0f); player_pvp_count_label.Top.Set(UIServerDataElement.PlayerPvpCountLabelTop, 0f); this.Append((UIElement)player_pvp_count_label); var teams_count_label = new UIText("Teams: " + this.Data.TeamsCount, 0.8f); teams_count_label.Left.Set(UIServerDataElement.TeamsCountLabelLeft, 0f); teams_count_label.Top.Set(UIServerDataElement.TeamsCountLabelTop, 0f); this.Append((UIElement)teams_count_label); //// /*string[] mod_list = this.Data.Mods.Select( kv => kv.Key + " " + kv.Value ) * .OrderBy(k=>k) * .ToArray(); * * var mods = new UIText( string.Join(", ", mod_list), 0.7f ); * mods.Left.Set( UIServerDataElement.ModsLabelLeft, 0f ); * mods.Top.Set( UIServerDataElement.ModsLabelTop + offset_y, 0f ); * mods.Width.Set( 0f, 1f ); * this.Append( (UIElement)mods );*/ //// if (this.Data.Motd != "") { int line_height = 16; string[] motd_chunks = UIServerDataElement.GetMotdLines(this.Data.Motd, 96); for (int i = 0; i < motd_chunks.Length; i++) { //LogHelpers.Log( "motd "+i+" "+motd_chunks[i]+", "+ ( i * 24f )+" - "+(line_height * motd_chunks.Length) ); var motd_label = new UIText(motd_chunks[i], 0.8f); motd_label.Left.Set(UIServerDataElement.MotdLabelLeft, 0f); motd_label.Top.Set(UIServerDataElement.MotdLabelTop + (i * line_height), 0f); this.Append((UIElement)motd_label); } this.Height.Set(this.Height.Pixels + (line_height * motd_chunks.Length) + (motd_chunks.Length > 0 ? 4 : 0), 0f); } //// this.JoinButton = new UITextPanelButton(this.Theme, "Join"); this.JoinButton.Top.Set(16f, 0f); this.JoinButton.Left.Set(-128f, 1f); this.JoinButton.Width.Set(128f, 0f); this.JoinButton.Height.Set(12f, 0f); this.JoinButton.OnClick += delegate(UIMouseEvent evt, UIElement listening_element) { this.PreJoinAction(this.Data.ServerIP, this.Data.Port); try { NetHelpers.JoinServer(this.Data.ServerIP, this.Data.Port); } catch (Exception e) { LogHelpers.Log(e.ToString()); } }; this.Append((UIElement)this.JoinButton); //// if (this.Data.IsPassworded && Main.itemTexture[327] != null) { Texture2D tex = Main.itemTexture[327]; var lock_icon = new UIImage(tex); lock_icon.Top.Set(17f, 0f); lock_icon.Left.Set(-116f, 1f); lock_icon.Width.Set(tex.Width, 0f); lock_icon.Height.Set(tex.Height, 0f); this.Append((UIElement)lock_icon); } }