Exemplo n.º 1
0
 private void btnRename_Click(object sender, EventArgs e)
 {
     if ((lbxContainers.Items.Count > 0) && (lbxContainers.SelectedIndex >= 0))
     {
         RenameDialog newName = new RenameDialog();
         DialogResult result  = newName.ShowDialog();
         if (result == System.Windows.Forms.DialogResult.OK)
         {
             try
             {
                 prntForm.containersList[prntForm._selectedLbxContainerIndex].containerTag = newName.RenameText;
                 refreshListBoxContainers();
             }
             catch { }
         }
     }
 }
Exemplo n.º 2
0
 private void btnRename_Click(object sender, EventArgs e)
 {
     if ((lbxConvos.Items.Count > 0) && (lbxConvos.SelectedIndex >= 0))
     {
         RenameDialog newName = new RenameDialog();
         DialogResult result  = newName.ShowDialog();
         if (result == System.Windows.Forms.DialogResult.OK)
         {
             /*try
              * {
              *  prntForm.mod.ModuleConvosList[prntForm._selectedLbxConvoIndex] = newName.RenameText;
              *  refreshListBoxConvos();
              * }
              * catch { }
              */
             try
             {
                 #region New Convo
                 if (prntForm.mod.moduleConvosList[prntForm._selectedLbxConvoIndex] == "new conversation")
                 {
                     //if file exists, rename the file
                     string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\dialog";
                     if (File.Exists(filePath + "\\" + prntForm.mod.moduleConvosList[prntForm._selectedLbxConvoIndex] + ".json"))
                     {
                         try
                         {
                             //rename file
                             File.Move(filePath + "\\" + prntForm.mod.moduleConvosList[prntForm._selectedLbxConvoIndex] + ".json", filePath + "\\" + newName.RenameText + ".json"); // Try to move
                             try
                             {
                                 //load area
                                 Convo newConvo = new Convo();
                                 newConvo = newConvo.GetConversation(filePath, "\\" + newName.RenameText + ".json");
                                 if (newConvo == null)
                                 {
                                     MessageBox.Show("returned a null convo");
                                 }
                                 //change area file name in area file object properties
                                 newConvo.ConvoFileName = newName.RenameText;
                                 newConvo.SaveContentConversation(filePath, "\\" + newName.RenameText + ".json");
                                 prntForm.mod.moduleConvosList[prntForm._selectedLbxConvoIndex] = newName.RenameText;
                             }
                             catch (Exception ex)
                             {
                                 MessageBox.Show("failed to open file: " + ex.ToString());
                             }
                         }
                         catch (Exception ex)
                         {
                             MessageBox.Show(ex.ToString()); // Write error
                         }
                     }
                     else
                     {
                         prntForm.mod.moduleConvosList[prntForm._selectedLbxConvoIndex] = newName.RenameText;
                     }
                     refreshListBoxConvos();
                 }
                 #endregion
                 #region Existing Convo
                 else
                 {
                     DialogResult sure = MessageBox.Show("Are you sure you wish to change the conversation name and the conversation file name? (make sure to update any references to this conversation name such as creature attached convo name and scripts)", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
                     if (sure == System.Windows.Forms.DialogResult.Yes)
                     {
                         //if file exists, rename the file
                         string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\dialog";
                         if (File.Exists(filePath + "\\" + prntForm.mod.moduleConvosList[prntForm._selectedLbxConvoIndex] + ".json"))
                         {
                             try
                             {
                                 //rename file
                                 File.Move(filePath + "\\" + prntForm.mod.moduleConvosList[prntForm._selectedLbxConvoIndex] + ".json", filePath + "\\" + newName.RenameText + ".json"); // Try to move
                                 try
                                 {
                                     //load convo
                                     Convo newConvo = new Convo();
                                     newConvo = newConvo.GetConversation(filePath, "\\" + newName.RenameText + ".json");
                                     if (newConvo == null)
                                     {
                                         MessageBox.Show("returned a null convo");
                                     }
                                     //change convo file name in convo file object properties
                                     newConvo.ConvoFileName = newName.RenameText;
                                     newConvo.SaveContentConversation(filePath, "\\" + newName.RenameText + ".json");
                                     prntForm.mod.moduleConvosList[prntForm._selectedLbxConvoIndex] = newName.RenameText;
                                 }
                                 catch (Exception ex)
                                 {
                                     MessageBox.Show("failed to open file: " + ex.ToString());
                                 }
                             }
                             catch (Exception ex)
                             {
                                 MessageBox.Show(ex.ToString()); // Write error
                             }
                         }
                         else
                         {
                             prntForm.mod.moduleConvosList[prntForm._selectedLbxConvoIndex] = newName.RenameText;
                         }
                         refreshListBoxConvos();
                     }
                 }
                 #endregion
             }
             catch { }
         }
     }
 }
Exemplo n.º 3
0
 private void btnRename_Click(object sender, EventArgs e)
 {
     if ((lbxAreas.Items.Count > 0) && (lbxAreas.SelectedIndex >= 0))
     {
         RenameDialog newName = new RenameDialog();
         DialogResult result  = newName.ShowDialog();
         if (result == System.Windows.Forms.DialogResult.OK)
         {
             try
             {
                 #region New Area
                 if (prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] == "new area")
                 {
                     //if file exists, rename the file
                     string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\areas";
                     if (File.Exists(filePath + "\\" + prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] + ".lvl"))
                     {
                         try
                         {
                             //rename file
                             File.Move(filePath + "\\" + prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] + ".lvl", filePath + "\\" + newName.RenameText + ".lvl"); // Try to move
                             try
                             {
                                 //load area
                                 Area newArea = new Area();
                                 newArea = newArea.loadAreaFile(filePath + "\\" + newName.RenameText + ".lvl");
                                 if (newArea == null)
                                 {
                                     MessageBox.Show("returned a null area");
                                 }
                                 //change area file name in area file object properties
                                 newArea.Filename = newName.RenameText;
                                 newArea.saveAreaFile(filePath + "\\" + newName.RenameText + ".lvl");
                                 prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] = newName.RenameText;
                             }
                             catch (Exception ex)
                             {
                                 MessageBox.Show("failed to open file: " + ex.ToString());
                             }
                         }
                         catch (Exception ex)
                         {
                             MessageBox.Show(ex.ToString()); // Write error
                         }
                     }
                     else
                     {
                         prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] = newName.RenameText;
                     }
                     refreshListBoxAreas();
                 }
                 #endregion
                 #region Existing Area
                 else
                 {
                     DialogResult sure = MessageBox.Show("Are you sure you wish to change the area name and the area file name? (make sure to update any references to this area name such as transitions and scripts)", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
                     if (sure == System.Windows.Forms.DialogResult.Yes)
                     {
                         //if file exists, rename the file
                         string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\areas";
                         if (File.Exists(filePath + "\\" + prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] + ".lvl"))
                         {
                             try
                             {
                                 //rename file
                                 File.Move(filePath + "\\" + prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] + ".lvl", filePath + "\\" + newName.RenameText + ".lvl"); // Try to move
                                 try
                                 {
                                     //load area
                                     Area newArea = new Area();
                                     newArea = newArea.loadAreaFile(filePath + "\\" + newName.RenameText + ".lvl");
                                     if (newArea == null)
                                     {
                                         MessageBox.Show("returned a null area");
                                     }
                                     //change area file name in area file object properties
                                     newArea.Filename = newName.RenameText;
                                     newArea.saveAreaFile(filePath + "\\" + newName.RenameText + ".lvl");
                                     prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] = newName.RenameText;
                                 }
                                 catch (Exception ex)
                                 {
                                     MessageBox.Show("failed to open file: " + ex.ToString());
                                 }
                             }
                             catch (Exception ex)
                             {
                                 MessageBox.Show(ex.ToString()); // Write error
                             }
                         }
                         else
                         {
                             prntForm.mod.moduleAreasList[prntForm._selectedLbxAreaIndex] = newName.RenameText;
                         }
                         refreshListBoxAreas();
                     }
                 }
                 #endregion
             }
             catch { }
         }
     }
 }
Exemplo n.º 4
0
 private void btnRename_Click(object sender, EventArgs e)
 {
     if ((lbxIBScripts.Items.Count > 0) && (lbxIBScripts.SelectedIndex >= 0))
     {
         string       scriptname = prntForm.mod.moduleIBScriptsList[prntForm._selectedLbxIBScriptIndex];
         RenameDialog newName    = new RenameDialog();
         DialogResult result     = newName.ShowDialog();
         if (result == System.Windows.Forms.DialogResult.OK)
         {
             try
             {
                 #region New IB Script
                 if (scriptname == "newIBScript")
                 {
                     //if file exists, rename the file
                     string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\ibscript";
                     if (File.Exists(filePath + "\\" + scriptname + ".ibs"))
                     {
                         try
                         {
                             //rename file
                             File.Move(filePath + "\\" + scriptname + ".ibs", filePath + "\\" + newName.RenameText + ".ibs");
                             try
                             {
                                 prntForm.mod.moduleIBScriptsList[prntForm._selectedLbxIBScriptIndex] = newName.RenameText;
                             }
                             catch (Exception ex)
                             {
                                 MessageBox.Show("failed to open file: " + ex.ToString());
                             }
                         }
                         catch (Exception ex)
                         {
                             MessageBox.Show(ex.ToString()); // Write error
                         }
                     }
                     else
                     {
                         prntForm.mod.moduleIBScriptsList[prntForm._selectedLbxIBScriptIndex] = newName.RenameText;
                     }
                     refreshListBoxIBScripts();
                 }
                 #endregion
                 #region Existing IB Script
                 else
                 {
                     DialogResult sure = MessageBox.Show("Are you sure you wish to change this IB Script's file name? (make sure to update any references to this LogicTree name such as script hooks and trigger events)", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);
                     if (sure == System.Windows.Forms.DialogResult.Yes)
                     {
                         //if file exists, rename the file
                         string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\ibscript";
                         if (File.Exists(filePath + "\\" + scriptname + ".ibs"))
                         {
                             try
                             {
                                 //rename file
                                 File.Move(filePath + "\\" + scriptname + ".ibs", filePath + "\\" + newName.RenameText + ".ibs");
                                 try
                                 {
                                     prntForm.mod.moduleIBScriptsList[prntForm._selectedLbxIBScriptIndex] = newName.RenameText;
                                 }
                                 catch (Exception ex)
                                 {
                                     MessageBox.Show("failed to open file: " + ex.ToString());
                                 }
                             }
                             catch (Exception ex)
                             {
                                 MessageBox.Show(ex.ToString()); // Write error
                             }
                         }
                         else
                         {
                             prntForm.mod.moduleIBScriptsList[prntForm._selectedLbxIBScriptIndex] = newName.RenameText;
                         }
                         refreshListBoxIBScripts();
                     }
                 }
                 #endregion
             }
             catch { }
         }
     }
 }