private void disableStringsToolStripMenuItem_Click(object sender, EventArgs e) { Chunk locChunk = mAssetListBox.Items[mAssetListBox.SelectedIndex] as Chunk; if (locChunk.LocHelper == null) { locChunk.LocHelper = new LocHelper(locChunk.GetAssetData()); } string userInput = MessageForm.ShowMessage("Paste String ids into the text box", "", SystemIcons.Question, true, true); if (userInput != null) { string number = StringInputDlg.GetString("Enter occurence", "Enter the occurence of the string you want to disable", "1"); int target_occurence = 1; if (Int32.TryParse(number, out target_occurence)) { string[] lines = userInput.Replace("\r\n", "\n").Split("\n".ToCharArray()); foreach (string line in lines) { if (line.Length > 0) { locChunk.LocHelper.DisableString(line, target_occurence); } } // now... // copy the data from the chunk to the in-memory data byte[] rawData = locChunk.LocHelper.GetRawData(); Array.Copy(rawData, 0, mUcfbFileHelper.Data, (int)locChunk.Start, rawData.Length); } } }
private void addStringToolStripMenuItem_Click(object sender, EventArgs e) { if (mAssetListBox.SelectedIndex > -1) { Chunk c = mAssetListBox.Items[mAssetListBox.SelectedIndex] as Chunk; if (c.Type.ToLower().StartsWith("loc")) { if (c.LocHelper == null) { c.LocHelper = new LocHelper(c.GetAssetData()); } string strId = StringInputDlg.GetString("New String Id?", "Enter text:", ""); if (strId != null) { string content = c.LocHelper.GetString(strId); string newContant = StringInputDlg.GetString("What Value?", "Enter text:", content); if (newContant.Length > 0) { c.LocHelper.AddString(strId, newContant); mUcfbFileHelper.ReplaceUcfbChunk(c, c.LocHelper.GetUcfbData(), true); ////c.Data = c.LocHelper.GetData(); // debugging only , misuse of 'Data' //c.LocHelper.DumpToFile("loc_tmp.bin"); } } } } }
private void findToolStripMenuItem_Click(object sender, EventArgs e) { string findMe = StringInputDlg.GetString("Enter item name to search for", "<item name>"); if (findMe != null) { Chunk chk = null; for (int i = 0; i < mAssetListBox.Items.Count; i++) { chk = mAssetListBox.Items[i] as Chunk; if (chk != null) { if (findMe == chk.ToString() || findMe == chk.Name) { mAssetListBox.SelectedIndex = i; return; } } } for (int i = 0; i < mAssetListBox.Items.Count; i++) { chk = mAssetListBox.Items[i] as Chunk; if (chk != null) { if (findMe == chk.Name) { mAssetListBox.SelectedIndex = i; return; } } } } }
private void getStringToolStripMenuItem_Click(object sender, EventArgs e) { string stringId = StringInputDlg.GetString("Enter string id", "It can be a hex number (starting with '0x') or the '.' seperated words like 'cheats.ammo_off'"); if (!String.IsNullOrEmpty(stringId)) { if (mAssetListBox.SelectedIndex > -1) { Chunk c = mAssetListBox.Items[mAssetListBox.SelectedIndex] as Chunk; if (c.Type.ToLower().StartsWith("loc")) { LocHelper lc = new LocHelper(c.GetAssetData()); string result = lc.GetString(stringId); if (!String.IsNullOrEmpty(result)) { mMainTextBox.Text = result; } else { mMainTextBox.Text = String.Format("StringId '{0}', not found", stringId); } } } } }
public static string GetString(string title, string message, string initialText) { StringInputDlg sid = new StringInputDlg(title, message, initialText); sid.ShowDialog(); string ret = sid.getResult(); sid.Dispose(); return(ret); }
private void RenameSelectedItem() { if (mAssetListBox.SelectedIndex > -1) { Chunk c = mAssetListBox.SelectedItem as Chunk; String newName = StringInputDlg.GetString("Enter New name", "", c.Name); if (newName != null) { RenameItem(c, newName); } } }
/// <summary> /// Prompts the user for a string to search for /// </summary> /// <returns>true if the search string was set</returns> public bool SetSearchString() { bool ret = false; if (this.SelectionLength > 0) { SearchString = this.Text.Substring(this.SelectionStart, this.SelectionLength); } string result = StringInputDlg.GetString( "Enter Search String", "Please enter text (or a regex) to search for.", SearchString); if (!result.Equals("")) { SearchString = result; ret = true; } return(ret); }
private void EnterModToolsDir() { String dir = StringInputDlg.GetString("Enter Mod Tools Directory", "", Program.ModToolsDir); dir = SetModToolsDir(dir); }
/// <summary> /// Prompt the user for input for a 'set' command /// </summary> /// <param name="input">The input string to operate on</param> /// <returns>empty string on cancel, 'SET' string when successful.</returns> public static string PromptForSetUserInput(string input) { string retVal = ""; string msg = GetPromptUserMesage(input); string location = GetSetLocation(input); while (retVal == "") { StringBuilder rangeMsg = new StringBuilder(25); String userInputValue = ""; int min = 0; int max = 0; //SET(0x2224B, {32TeamNES,28TeamNES PromptUser:Msg="Enter desired quarter length":int(1-15)} ) //SET(0x2224B, {32TeamNES,28TeamNES PromptUser:Msg="Enter desired quarter length":int(0x1-0x15)} ) //SET(0x2224B, {32TeamNES,28TeamNES PromptUser:Msg="Enter name of...":string(len=8)} ) maybe not this one. if (input.IndexOf("int", StringComparison.OrdinalIgnoreCase) > -1 && (GetHexRange(ref min, ref max, input, rangeMsg) || GetDecimalRange(ref min, ref max, input, rangeMsg))) { string rangeMessage = rangeMsg.ToString(); NumberStyles style = rangeMessage.IndexOf('x') > 0 ? NumberStyles.HexNumber : NumberStyles.Integer; string initialText = style == NumberStyles.HexNumber ? "0x" : ""; StringInputDlg dlg = new StringInputDlg(msg, rangeMessage, initialText); int userVal = Int32.MinValue; if (dlg.ShowDialog() == DialogResult.OK) { userInputValue = dlg.getResult(); if (userInputValue.StartsWith("0x")) { userInputValue = userInputValue.Substring(2); } try { userVal = Int32.Parse(userInputValue, style); if (userVal < min || userVal > max) { userVal = Int32.MinValue; throw new Exception("Invalid input."); } } catch (Exception) { ShowError(string.Format( "Error with '{0}'. Value '{1}' is invalid for range {2}", msg, userInputValue, rangeMessage)); } if (userVal > Int32.MinValue) { retVal = string.Format("SET({0}, 0x{1:x})", location, userVal); } } else { retVal = " "; // trigger us to leave the loop } dlg.Dispose(); } else { ShowError("ERROR applying line: " + input); retVal = null; } } return(retVal); }