private void CreateFloatFieldControl(Base parent, int x, ref int y, string name, string labelText, int min, int max, float increment, float initialValue) { Label label = new Label(parent); label.Name = $"{name}Label"; label.Text = labelText; label.SetPosition(x, y + 3); label.Alignment = Pos.CenterV | Pos.Left; NumericUpDownEx upDown = new NumericUpDownEx(parent); upDown.Name = $"{name}NumUpDown"; upDown.Min = min; upDown.Max = max; upDown.Increment = increment; upDown.Value = initialValue; upDown.SetPosition(x + 110, y); upDown.ValueChanged += OnNumericUpDownValueChanged; y += 25; }
private void CreateOffsetsTabPageControls(TabButton tab, string name) { Base page = tab.Page; page.Name = $"{name}Page"; Label label = new Label(page); label.Name = $"{name}Label"; label.Text = "Model "; label.SetPosition(12, 5 + 3); label.Alignment = Pos.CenterV | Pos.Left; ComboBox comboBox = new ComboBox(page); comboBox.Name = $"{name}ComboBox"; comboBox.SetPosition(60, 5); comboBox.Width += 20; comboBox.AddItem("New...", $"{name}ComboBoxItemNew"); int j = 1; foreach (KeyValuePair <string, VehicleData> entry in Plugin.Settings.Vehicles.Data) { comboBox.AddItem(entry.Key, $"{name}ComboBoxItem{j++}", new Model(entry.Key)); } comboBox.SelectByText(Plugin.Settings.Vehicles.Data.First().Key); comboBox.ItemSelected += OnOffsetsComboBoxItemSelected; Vector3 v = Plugin.Settings.Vehicles.Data.First().Value.Offset; string[] vecComponents = "X,Y,Z".Split(','); for (int i = 0; i < vecComponents.Length; i++) { string vecComp = vecComponents[i]; int x = 250; int y = 5 + 30 * i; Label vecCompLabel = new Label(page); vecCompLabel.Name = $"{name}{vecComp}Label"; vecCompLabel.Text = vecComp; vecCompLabel.SetPosition(x, y + 3); vecCompLabel.Alignment = Pos.CenterV | Pos.Left; NumericUpDownEx upDown = new NumericUpDownEx(page); upDown.Name = $"{name}{vecComp}NumUpDown"; upDown.Min = -999; upDown.Max = 999; upDown.Increment = 0.01f; upDown.Value = v[i]; upDown.SetPosition(x + 15, y); upDown.ValueChanged += OnOffsetsNumericUpDownValueChanged; } Button saveButton = new Button(page); saveButton.Name = $"{name}SaveButton"; saveButton.Text = "Save "; saveButton.Width = 150; saveButton.SetPosition(12, 50); saveButton.Clicked += OnOffsetsSaveButtonClicked; saveButton.SetToolTipText("Saves all offsets to the vehicle settings file"); if (Game.LocalPlayer.Character.IsInAnyVehicle(false)) { Model m = Game.LocalPlayer.Character.CurrentVehicle.Model; comboBox.SelectByUserData(m); } }