public static void DrawRegions(SpriteBatch spriteBatch) { for (int i = 0; i < HEROsModNetwork.Network.Regions.Count; i++) { HEROsModNetwork.Region region = HEROsModNetwork.Network.Regions[i]; ModUtils.DrawBorderedRect(spriteBatch, region.Color, region.Position, region.Size, 3, region.Name); } }
private void bSave_onLeftClick(object sender, EventArgs e) { if (textbox.Text.Length >= 3) { textbox.Unfocus(); HEROsModNetwork.Region region = new HEROsModNetwork.Region(textbox.Text, SelectionTool.Position, SelectionTool.Size); HEROsModNetwork.GeneralMessages.RequestCreateRegion(region); SelectionTool.Reset(); } else { SelectionTool.Reset(); Main.NewText(HEROsMod.HeroText("RegionNameTooShort")); } this.Close(); }
void bSave_onLeftClick(object sender, EventArgs e) { if (textbox.Text.Length >= 3) { textbox.Unfocus(); HEROsModNetwork.Region region = new HEROsModNetwork.Region(textbox.Text, SelectionTool.Position, SelectionTool.Size); HEROsModNetwork.GeneralMessages.RequestCreateRegion(region); SelectionTool.Reset(); } else { SelectionTool.Reset(); Main.NewText("Region name must be at least 3 characters long"); } this.Close(); }
public void PopulateRegionsList() { scrollView.ClearContent(); bCreateRegion.Visible = true; bDeleteRegion.Visible = false; bAddGroup.Visible = false; bAddPlayer.Visible = false; bBack.Visible = false; colorSlider.Visible = false; bSaveColor.Visible = false; bProtectChests.Visible = false; SelectedRegion = null; float yPos = Spacing; for (int i = 0; i < HEROsModNetwork.Network.Regions.Count; i++) { HEROsModNetwork.Region region = HEROsModNetwork.Network.Regions[i]; UIButton bEdit = new UIButton(Language.GetTextValue("LegacyInterface.48")); // "Edit" UIRect bg = new UIRect(); bg.X = LargeSpacing; bg.Y = yPos; bg.Height = bEdit.Height + SmallSpacing * 2; bg.Width = scrollView.Width - 20 - LargeSpacing * 2; yPos += bg.Height; bg.ForegroundColor = i % 2 == 0 ? Color.Transparent : Color.Blue * .1f; UILabel label = new UILabel(region.Name); label.X = Spacing; label.Y = Spacing; label.Scale = .5f; bEdit.X = bg.Width - bEdit.Width - Spacing; bEdit.Y = SmallSpacing; bEdit.Tag = i; bEdit.onLeftClick += bEdit_onLeftClick; UIRect regionColor = new UIRect(); regionColor.ForegroundColor = region.Color; regionColor.Height = bg.Height - Spacing * 2; regionColor.Width = regionColor.Height; regionColor.Y = Spacing; UILabel lX = new UILabel("X: " + region.X); UILabel lY = new UILabel("Y: " + region.Y); UILabel lWidth = new UILabel("Width: " + region.Width); UILabel lHeight = new UILabel("Height: " + region.Height); lX.Scale = .35f; lY.Scale = lX.Scale; lWidth.Scale = lX.Scale; lHeight.Scale = lX.Scale; lWidth.X = bEdit.X - 100; lHeight.X = lWidth.X; lHeight.Y = bg.Height - lHeight.Height; lX.X = lWidth.X - 75; lY.X = lX.X; lX.Y = lWidth.Y; lY.Y = lHeight.Y; regionColor.X = lX.X - regionColor.Width - Spacing; bg.AddChild(label); bg.AddChild(bEdit); bg.AddChild(lX); bg.AddChild(lY); bg.AddChild(lWidth); bg.AddChild(lHeight); bg.AddChild(regionColor); scrollView.AddChild(bg); } scrollView.ContentHeight = yPos + Spacing; }