private void mButton4_Click(object sender, EventArgs e) { var input = InputWindow.Ask(this, "Steam Workshop URL", "Insert the URL to the Steam Workshop item", new InputWindow.NonEmptyValidator()); if (input == null) { return; } try { var parsed = HttpUtility.ParseQueryString(new Uri(input).Query).Get("id"); var lg = ulong.Parse(parsed); if (lg > 100000) { mod.SetUploadedId(lg); mod.Refresh(); var wsid = mod.GetUploadedId(); if (wsid > 0) { label6.Text = "WorkshopId: " + wsid; mButton4.Visible = false; } } } catch (Exception ex) { GUI.MessageBox.Show("Invalid input: " + input + "\n" + ex.Message + "\n\n" + ex.ToString()); } }
private void lblAuthor_Click(object sender, EventArgs e) { var iw = InputWindow.Ask(this, "Author", "Enter the mod author", null, lblAuthor.Text); if (iw != null) { if (lblAuthor.Text != iw) { lblAuthor.Text = iw; HasUnsavedChanges = true; } } }
private void label5_Click(object sender, EventArgs e) { var iw = InputWindow.Ask(this, "Version", "Enter the mod version", new InputWindow.NonEmptyValidator(), label5.Text); if (iw != null) { if (label5.Text != iw) { label5.Text = iw; HasUnsavedChanges = true; } } }
private void modFolderName_Click(object sender, EventArgs e) { var iw = InputWindow.Ask(this, "Mod folder name", "Enter the mod folder name", new InputWindow.ModNameValidator(), modFolderName.Text); if (iw != null) { if (modFolderName.Text != iw) { modFolderName.Text = iw; HasUnsavedChanges = true; } } }
public static string Ask(Control parent, string title, string text, InputValidator validator = null, string def = "", bool multiline = false) { if (MainWindow.Instance.InvokeRequired) { var output = ""; MainWindow.Instance.Invoke(new MethodInvoker(() => { output = InputWindow.Ask(parent, title, text, validator); })); return(output); } var t = new InputWindow(); if (parent == null) { parent = Form.ActiveForm; } if (parent == null && MainWindow.Instance is MainWindow) { parent = MainWindow.Instance; } t.Validator = validator; t.label1.Text = text; t.Text = title; t.InputBox.Text = def; t.StartPosition = FormStartPosition.CenterParent; if (multiline) { t.InputBox.Location = new System.Drawing.Point(t.InputBox.Location.X, t.InputBox.Location.Y - t.InputBox.Height); t.InputBox.Multiline = true; t.label1.Height -= t.InputBox.Height; t.InputBox.ScrollBars = ScrollBars.Vertical; t.InputBox.WordWrap = true; t.InputBox.Height *= 2; } if (t.ShowDialog(parent.FindForm()) == DialogResult.OK) { return(t.InputBox.Text); } return(null); }
private void mButton4_Click(object sender, EventArgs e) { string modsRoot = Path.Combine(Program.ProcFactory.GetGamePath(), @"HatinTimeGame\Mods"); var modName = InputWindow.Ask(this, "New mod", "Please enter mod folder name", new InputWindow.ModNameValidator()); if (modName == null) { return; } string modPath = Path.Combine(modsRoot, modName); string modInfoPath = Path.Combine(modPath, "modinfo.ini"); Directory.CreateDirectory(modPath); Directory.CreateDirectory(Path.Combine(modPath, "Classes")); Directory.CreateDirectory(Path.Combine(modPath, "Content")); Directory.CreateDirectory(Path.Combine(modPath, "Maps")); Directory.CreateDirectory(Path.Combine(modPath, "Localization")); Directory.CreateDirectory(Path.Combine(modPath, "Localization", "INT")); using (StreamWriter sW = File.CreateText(modInfoPath)) { sW.WriteLine("[Info]"); sW.WriteLine("name=" + modName); sW.WriteLine("author=\"Me\""); sW.WriteLine("description=\"Hello this is my all new mod!\""); sW.WriteLine("version=\"1.0.0\""); sW.WriteLine("is_cheat=false"); sW.WriteLine("icon=icon.jpg"); } modListControl1.ReloadList(() => { var mod = modListControl1.GetMod(modName); var mp = ModProperties.GetPropertiesWindowForMod(mod); if (mp != null) { mp.Show(); mp.WindowState = FormWindowState.Normal; mp.Focus(); } else { new ModProperties(mod).Show(); } }); }