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 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 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 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); } } } } }
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); }