public override void OnInitialize() { base.OnInitialize(); mainPanel = new UIPanel(); width = 310; height = 610; mainPanel.SetPadding(6); mainPanel.BackgroundColor = Color.Orange * 0.7f; int top = 0; UIText text = new UIText("Projectiles:", 0.85f); text.Top.Set(top, 0f); mainPanel.Append(text); UITextPanel <string> clearProjectilesButton = new UITextPanel <string>("Clear Projectiles"); clearProjectilesButton.OnClick += (a, b) => { for (int i = 0; i < Main.maxProjectiles; i++) { if (Main.projectile[i].active) { Main.projectile[i].Kill(); if (Main.netMode == 1) { NetMessage.SendData(27, -1, -1, null, i, 0f, 0f, 0f, 0); } } } }; clearProjectilesButton.Top.Set(top, 0f); clearProjectilesButton.Width.Set(-10, 0.5f); clearProjectilesButton.HAlign = 1; clearProjectilesButton.SetPadding(4); mainPanel.Append(clearProjectilesButton); top += 20; UIText text2 = new UIText("Filter:", 0.85f); text2.Top.Set(top, 0f); mainPanel.Append(text2); searchFilter = new NewUITextBox("Search", 0.85f); searchFilter.SetPadding(0); searchFilter.OnTextChanged += () => { ValidateInput(); updateNeeded = true; }; searchFilter.Top.Set(top, 0f); searchFilter.Left.Set(text2.GetInnerDimensions().Width, 0f); searchFilter.Width.Set(-text2.GetInnerDimensions().Width, 1f); searchFilter.Height.Set(20, 0f); //searchFilter.VAlign = 0.5f; mainPanel.Append(searchFilter); top += 20; speedXDataProperty = new UIFloatRangedDataValue("SpeedX:", 0, -10, 10); speedYDataProperty = new UIFloatRangedDataValue("SpeedY:", 0, -10, 10); var ui2DRange = new UI2DRange <float>(speedXDataProperty, speedYDataProperty); ui2DRange.Top.Set(top, 0f); mainPanel.Append(ui2DRange); top += 30; ai0DataProperty = new UIFloatRangedDataValue("ai0:", 0, -10, 10); var uiRange = new UIRange <float>(ai0DataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; ai1DataProperty = new UIFloatRangedDataValue("ai1:", 0, -10, 10); uiRange = new UIRange <float>(ai1DataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; knockbackDataProperty = new UIFloatRangedDataValue("Knockback:", 0, 0, 20); uiRange = new UIRange <float>(knockbackDataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; damageDataProperty = new UIIntRangedDataValue("Damage:", 20, 0, 200); var uiRangeI = new UIRange <int>(damageDataProperty); uiRangeI.Top.Set(top, 0f); uiRangeI.Width.Set(0, 1f); mainPanel.Append(uiRangeI); top += 30; aiStyleDataProperty = new UIIntRangedDataValue("AIStyle:", -1, -1, 145); uiRangeI = new UIRange <int>(aiStyleDataProperty); uiRangeI.Top.Set(top, 0f); uiRangeI.Width.Set(0, 1f); mainPanel.Append(uiRangeI); top += 30; drawOffsetXDataProperty = new UIIntRangedDataValue("drawOffsetX:", 0, -30, 30); uiRangeI = new UIRange <int>(drawOffsetXDataProperty); uiRangeI.Top.Set(top, 0f); uiRangeI.Width.Set(0, 1f); mainPanel.Append(uiRangeI); top += 30; drawOriginOffsetXDataProperty = new UIIntRangedDataValue("drawOriginOffsetX:", 0, -30, 30); uiRangeI = new UIRange <int>(drawOriginOffsetXDataProperty); uiRangeI.Top.Set(top, 0f); uiRangeI.Width.Set(0, 1f); mainPanel.Append(uiRangeI); top += 30; drawOriginOffsetYDataProperty = new UIIntRangedDataValue("drawOriginOffsetY:", 0, -30, 30); uiRangeI = new UIRange <int>(drawOriginOffsetYDataProperty); uiRangeI.Top.Set(top, 0f); uiRangeI.Width.Set(0, 1f); mainPanel.Append(uiRangeI); top += 30; hostile = new UIBoolNDataValue("Hostile"); var hostileCheckbox = new UITriStateCheckbox(hostile); hostileCheckbox.Top.Set(top, 0f); mainPanel.Append(hostileCheckbox); top += 30; friendly = new UIBoolNDataValue("Friendly"); var friendlyCheckbox = new UITriStateCheckbox(friendly); friendlyCheckbox.Top.Set(top, 0f); mainPanel.Append(friendlyCheckbox); top += 25; pause = new UICheckbox("Pause", "Pauses All Projectiles (Prevent AI from running)"); pause.Top.Set(top, 0f); mainPanel.Append(pause); UIHoverImageButton stepButton = new UIHoverImageButton(ModdersToolkit.Instance.GetTexture("UIElements/next"), "Step"); stepButton.OnClick += (s, e) => step = true; stepButton.Top.Set(top - 6, 0f); stepButton.Left.Set(80, 0f); mainPanel.Append(stepButton); top += 25; freeze = new UICheckbox("Freeze", "Zero out velocity during PreAI for All Projectiles"); freeze.Top.Set(top, 0f); mainPanel.Append(freeze); top += 25; projectileGrid = new UIGrid(7); projectileGrid.Top.Pixels = top; //autoTrashGrid.Left.Pixels = spacing; projectileGrid.Width.Set(-25f, 1f); // leave space for scroll? projectileGrid.Height.Set(-top, 1f); projectileGrid.ListPadding = 6f; mainPanel.Append(projectileGrid); // this will initialize grid updateNeeded = true; var projectileGridScrollbar = new UIElements.FixedUIScrollbar(_userInterface); projectileGridScrollbar.SetView(100f, 1000f); projectileGridScrollbar.Top.Pixels = top; // + spacing; projectileGridScrollbar.Height.Set(-top /*- spacing*/, 1f); projectileGridScrollbar.HAlign = 1f; mainPanel.Append(projectileGridScrollbar); projectileGrid.SetScrollbar(projectileGridScrollbar); AdjustMainPanelDimensions(mainPanel); Append(mainPanel); }
public override void OnInitialize() { mainPanel = new UIPanel(); mainPanel.Left.Set(-350f, 1f); mainPanel.Top.Set(-620f, 1f); mainPanel.Width.Set(310f, 0f); mainPanel.Height.Set(520f, 0f); mainPanel.SetPadding(12); mainPanel.BackgroundColor = Color.Orange * 0.7f; int top = 0; UIText text = new UIText("Projectiles:", 0.85f); text.Top.Set(top, 0f); mainPanel.Append(text); top += 20; UIText text2 = new UIText("Filter:", 0.85f); text2.Top.Set(top, 0f); mainPanel.Append(text2); searchFilter = new NewUITextBox("Search", 0.85f); searchFilter.SetPadding(0); searchFilter.OnTextChanged += () => { ValidateInput(); updateneeded = true; }; searchFilter.Top.Set(top, 0f); searchFilter.Left.Set(text2.GetInnerDimensions().Width, 0f); searchFilter.Width.Set(0, 1f); searchFilter.Height.Set(20, 0f); //searchFilter.VAlign = 0.5f; mainPanel.Append(searchFilter); top += 20; speedXDataProperty = new UIFloatRangedDataValue("SpeedX:", 0, -10, 10); speedYDataProperty = new UIFloatRangedDataValue("SpeedY:", 0, -10, 10); var ui2DRange = new UI2DRange <float>(speedXDataProperty, speedYDataProperty); ui2DRange.Top.Set(top, 0f); mainPanel.Append(ui2DRange); top += 30; ai0DataProperty = new UIFloatRangedDataValue("ai0:", 0, -10, 10); var uiRange = new UIRange <float>(ai0DataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; ai1DataProperty = new UIFloatRangedDataValue("ai1:", 0, -10, 10); uiRange = new UIRange <float>(ai1DataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; knockbackDataProperty = new UIFloatRangedDataValue("Knockback:", 0, 0, 20); uiRange = new UIRange <float>(knockbackDataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; damageDataProperty = new UIIntRangedDataValue("Damage:", 20, 0, 200); var uiRangeI = new UIRange <int>(damageDataProperty); uiRangeI.Top.Set(top, 0f); uiRangeI.Width.Set(0, 1f); mainPanel.Append(uiRangeI); top += 30; aiStyleDataProperty = new UIIntRangedDataValue("AIStyle:", -1, -1, 145); uiRangeI = new UIRange <int>(aiStyleDataProperty); uiRangeI.Top.Set(top, 0f); uiRangeI.Width.Set(0, 1f); mainPanel.Append(uiRangeI); top += 30; hostile = new UIBoolNDataValue("Hostile"); var hostileCheckbox = new UITriStateCheckbox(hostile); hostileCheckbox.Top.Set(top, 0f); mainPanel.Append(hostileCheckbox); top += 30; friendly = new UIBoolNDataValue("Friendly"); var friendlyCheckbox = new UITriStateCheckbox(friendly); friendlyCheckbox.Top.Set(top, 0f); mainPanel.Append(friendlyCheckbox); top += 30; projectileGrid = new UIGrid(7); projectileGrid.Top.Pixels = top; //autoTrashGrid.Left.Pixels = spacing; projectileGrid.Width.Set(-25f, 1f); // leave space for scroll? projectileGrid.Height.Set(-top, 1f); projectileGrid.ListPadding = 6f; mainPanel.Append(projectileGrid); // this will initialize grid updateneeded = true; var projectileGridScrollbar = new UIElements.FixedUIScrollbar(userInterface); projectileGridScrollbar.SetView(100f, 1000f); projectileGridScrollbar.Top.Pixels = top; // + spacing; projectileGridScrollbar.Height.Set(-top /*- spacing*/, 1f); projectileGridScrollbar.HAlign = 1f; mainPanel.Append(projectileGridScrollbar); projectileGrid.SetScrollbar(projectileGridScrollbar); Append(mainPanel); }