private void renameToolStripMenuItem_Click(object sender, EventArgs e) { try { ListViewItem item = null; if (tabControlSubfiles.SelectedTab == tabPageXXSubfiles) { if (xxSubfilesList.SelectedItems.Count > 0) { item = xxSubfilesList.SelectedItems[0]; } } else if (tabControlSubfiles.SelectedTab == tabPageXASubfiles) { if (xaSubfilesList.SelectedItems.Count > 0) { item = xaSubfilesList.SelectedItems[0]; } } else if (tabControlSubfiles.SelectedTab == tabPageImageSubfiles) { if (imageSubfilesList.SelectedItems.Count > 0) { item = imageSubfilesList.SelectedItems[0]; } } else if (tabControlSubfiles.SelectedTab == tabPageSoundSubfiles) { if (soundSubfilesList.SelectedItems.Count > 0) { item = soundSubfilesList.SelectedItems[0]; } } else if (tabControlSubfiles.SelectedTab == tabPageOtherSubfiles) { if (otherSubfilesList.SelectedItems.Count > 0) { item = otherSubfilesList.SelectedItems[0]; } } if (item != null) { using (FormPPRename renameForm = new FormPPRename(item)) { if (renameForm.ShowDialog() == DialogResult.OK) { IWriteFile subfile = (IWriteFile)item.Tag; string oldName = subfile.Name; string newName = (string)Gui.Scripting.RunScript(EditorVar + ".RenameSubfile(subfile=\"" + subfile.Name + "\", newName=\"" + renameForm.NewName + "\")"); Changed = Changed; item.Text = newName; if (tabControlSubfiles.SelectedTab == tabPageXXSubfiles || tabControlSubfiles.SelectedTab == tabPageXASubfiles || tabControlSubfiles.SelectedTab == tabPageOtherSubfiles) { if (ChildParserVars.ContainsKey(oldName)) { string value = ChildParserVars[oldName]; ChildParserVars.Remove(oldName); ChildParserVars.Add(newName, value); } if (ChildForms.ContainsKey(oldName)) { DockContent value = ChildForms[oldName]; ChildForms.Remove(oldName); ChildForms.Add(newName, value); value.Text = newName; value.ToolTipText = Editor.Parser.FilePath + @"\" + newName; } } InitSubfileLists(false); } } } } catch (Exception ex) { Utility.ReportException(ex); } }
private void renameToolStripMenuItem_Click(object sender, EventArgs e) { try { ListViewItem item = null; if (tabControlSubfiles.SelectedTab == tabPageXXSubfiles) { if (xxSubfilesList.SelectedItems.Count > 0) { item = xxSubfilesList.SelectedItems[0]; } } else if (tabControlSubfiles.SelectedTab == tabPageXASubfiles) { if (xaSubfilesList.SelectedItems.Count > 0) { item = xaSubfilesList.SelectedItems[0]; } } else if (tabControlSubfiles.SelectedTab == tabPageImageSubfiles) { if (imageSubfilesList.SelectedItems.Count > 0) { item = imageSubfilesList.SelectedItems[0]; } } else if (tabControlSubfiles.SelectedTab == tabPageSoundSubfiles) { if (soundSubfilesList.SelectedItems.Count > 0) { item = soundSubfilesList.SelectedItems[0]; } } else if (tabControlSubfiles.SelectedTab == tabPageOtherSubfiles) { if (otherSubfilesList.SelectedItems.Count > 0) { item = otherSubfilesList.SelectedItems[0]; } } if (item != null) { using (FormPPRename renameForm = new FormPPRename(item)) { if (renameForm.ShowDialog() == DialogResult.OK) { IWriteFile subfile = (IWriteFile)item.Tag; string newName = (string)Gui.Scripting.RunScript(EditorVar + ".RenameSubfile(subfile=\"" + subfile.Name + "\", newName=\"" + renameForm.NewName + "\")"); item.Text = newName; item.ListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); if (tabControlSubfiles.SelectedTab == tabPageXXSubfiles) { if (ChildParserVars.ContainsKey(subfile.Name)) { string value = ChildParserVars[subfile.Name]; ChildParserVars.Remove(subfile.Name); ChildParserVars.Add(newName, value); } if (ChildForms.ContainsKey(subfile.Name)) { DockContent value = ChildForms[subfile.Name]; ChildForms.Remove(subfile.Name); ChildForms.Add(newName, value); value.Text = newName; value.ToolTipText = Editor.Parser.FilePath + @"\" + newName; } } else if (tabControlSubfiles.SelectedTab == tabPageXASubfiles) { if (ChildParserVars.ContainsKey(subfile.Name)) { string value = ChildParserVars[subfile.Name]; ChildParserVars.Remove(subfile.Name); ChildParserVars.Add(newName, value); } if (ChildForms.ContainsKey(subfile.Name)) { DockContent value = ChildForms[subfile.Name]; ChildForms.Remove(subfile.Name); ChildForms.Add(newName, value); value.Text = newName; value.ToolTipText = Editor.Parser.FilePath + @"\" + newName; } } InitSubfileLists(); } } } } catch (Exception ex) { Utility.ReportException(ex); } }
private void renameToolStripMenuItem_Click(object sender, EventArgs e) { try { ListView subfilesList = null; if (tabControlAssets.SelectedTab == tabPageAnimators) { subfilesList = animatorsList; } else if (tabControlAssets.SelectedTab == tabPageImages) { subfilesList = imagesList; } else if (tabControlAssets.SelectedTab == tabPageSounds) { subfilesList = soundsList; } else if (tabControlAssets.SelectedTab == tabPageMaterials) { subfilesList = materialsList; } else if (tabControlAssets.SelectedTab == tabPageOthers) { subfilesList = othersList; } if (subfilesList.SelectedItems.Count != 1) { return; } ListViewItem item = subfilesList.SelectedItems[0]; using (FormPPRename renameForm = new FormPPRename(item)) { if (renameForm.ShowDialog() == DialogResult.OK) { Animator anim = item.Tag as Animator; bool vAnimator = Editor.VirtualAnimators.Contains(anim); int componentIdx = Editor.Parser.Cabinet.Components.IndexOf(vAnimator ? anim.m_GameObject.asset : (Component)item.Tag); string oldName = item.Text; if (!vAnimator) { oldName += Editor.Parser.Cabinet.Components[componentIdx].pathID; } if ((bool)Gui.Scripting.RunScript(EditorVar + ".SetAssetName(componentIndex=" + componentIdx + ", name=\"" + renameForm.NewName + "\")")) { if (tabControlAssets.SelectedTab == tabPageAnimators) { string newName = renameForm.NewName; if (!vAnimator) { newName += Editor.Parser.Cabinet.Components[componentIdx].pathID; } if (ChildParserVars.ContainsKey(oldName)) { string value = ChildParserVars[oldName]; ChildParserVars.Remove(oldName); ChildParserVars.Add(newName, value); } if (ChildForms.ContainsKey(oldName)) { DockContent value = ChildForms[oldName]; ChildForms.Remove(oldName); ChildForms.Add(newName, value); value.Tag = newName; value.Text = renameForm.NewName; value.ToolTipText = Editor.Parser.FilePath + @"\" + renameForm.NewName; } } Changed = Changed; InitSubfileLists(false); } else { Report.ReportLog(((Component)item.Tag).classID1 + " asset could not be renamed."); } } } } catch (Exception ex) { Utility.ReportException(ex); } }