Esempio n. 1
0
 public LogicTreeEditor(Module m, ParentForm p)
 {
     InitializeComponent();
     lt = new LogicTree();
     mod = m;
     prntForm = p;
 }
Esempio n. 2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     LogicTree newConvo = new LogicTree();
     newConvo.Filename = "newLogicTree";
     prntForm.mod.moduleLogicTreesList.Add(newConvo.Filename);
     refreshListBoxLogicTrees();
     // should I create a new file at this point?
 }
Esempio n. 3
0
 public static void SortLogicTree(LogicTree toSort)
 {
     int i;
     if (toSort.SubNodes.Count > 0)
     {
         for (i = 0; i < toSort.SubNodes.Count; i++)
         {
             SortSubNodes(toSort.SubNodes[i]);
         }
     }
 }
Esempio n. 4
0
 private void btnDuplicate_Click(object sender, EventArgs e)
 {
     if ((lbxLogicTrees.Items.Count > 0) && (lbxLogicTrees.SelectedIndex >= 0))
     {
         //if file exists, rename the file
         string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\logictree";
         string filename = prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex];
         if (File.Exists(filePath + "\\" + filename + ".json"))
         {
             try
             {
                 //rename file
                 File.Copy(filePath + "\\" + filename + ".json", filePath + "\\" + filename + "-Copy.json"); // Try to move
                 try
                 {
                     //load convo
                     LogicTree newConvo = new LogicTree();
                     newConvo = newConvo.GetLogicTree(filePath, "\\" + filename + "-Copy.json");
                     if (newConvo == null)
                     {
                         MessageBox.Show("returned a null LogicTree");
                     }
                     //change convo file name in convo file object properties
                     newConvo.Filename = filename + "-Copy";
                     newConvo.SaveLogicTree(filePath, "\\" + filename + "-Copy.json");
                     prntForm.mod.moduleLogicTreesList.Add(newConvo.Filename);
                     refreshListBoxLogicTrees();
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show("failed to open file: " + ex.ToString());
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.ToString()); // Write error
             }
         }
         else
         {
             MessageBox.Show("File: " + filename + ".json does not exist in the dialog folder");
         }
         refreshListBoxLogicTrees();
     }
 }
Esempio n. 5
0
 private void btnRename_Click(object sender, EventArgs e)
 {
     if ((lbxLogicTrees.Items.Count > 0) && (lbxLogicTrees.SelectedIndex >= 0))
     {
         RenameDialog newName = new RenameDialog();
         DialogResult result = newName.ShowDialog();
         if (result == System.Windows.Forms.DialogResult.OK)
         {
             try
             {
                 #region New Logic Tree
                 if (prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] == "newLogicTree")
                 {
                     //if file exists, rename the file
                     string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\logictree";
                     if (File.Exists(filePath + "\\" + prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] + ".json"))
                     {
                         try
                         {
                             //rename file
                             File.Move(filePath + "\\" + prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] + ".json", filePath + "\\" + newName.RenameText + ".json"); // Try to move
                             try
                             {
                                 //load area
                                 LogicTree newConvo = new LogicTree();
                                 newConvo = newConvo.GetLogicTree(filePath, "\\" + newName.RenameText + ".json");
                                 if (newConvo == null)
                                 {
                                     MessageBox.Show("returned a null LogicTree");
                                 }
                                 //change area file name in area file object properties
                                 newConvo.Filename = newName.RenameText;
                                 newConvo.SaveLogicTree(filePath, "\\" + newName.RenameText + ".json");
                                 prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] = 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.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] = newName.RenameText;
                     }
                     refreshListBoxLogicTrees();
                 }
                 #endregion
                 #region Existing Logic Tree
                 else
                 {
                     DialogResult sure = MessageBox.Show("Are you sure you wish to change the Logic Tree name and the LogicTree 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 + "\\logictree";
                         if (File.Exists(filePath + "\\" + prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] + ".json"))
                         {
                             try
                             {
                                 //rename file
                                 File.Move(filePath + "\\" + prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] + ".json", filePath + "\\" + newName.RenameText + ".json"); // Try to move
                                 try
                                 {
                                     //load convo
                                     LogicTree newConvo = new LogicTree();
                                     newConvo = newConvo.GetLogicTree(filePath, "\\" + newName.RenameText + ".json");
                                     if (newConvo == null)
                                     {
                                         MessageBox.Show("returned a null LogicTree");
                                     }
                                     //change convo file name in convo file object properties
                                     newConvo.Filename = newName.RenameText;
                                     newConvo.SaveLogicTree(filePath, "\\" + newName.RenameText + ".json");
                                     prntForm.mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] = 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.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] = newName.RenameText;
                         }
                         refreshListBoxLogicTrees();
                     }
                 }
                 #endregion
             }
             catch { }
         }
     }
 }
Esempio n. 6
0
 private void LogicTreeEditor_Load(object sender, EventArgs e)
 {
     // load the file that has the selected node name if it exists
     string filenameOnly = mod.moduleLogicTreesList[prntForm._selectedLbxLogicTreeIndex] + ".json";
     string dirFullPath = prntForm._mainDirectory + "\\modules\\" + mod.moduleName + "\\logictree";
     if (File.Exists(dirFullPath + "\\" + filenameOnly))
     {
         openFile(dirFullPath, filenameOnly);
         if (lt == null)
         {
             lt = new LogicTree();
             lt.Filename = filenameOnly;
             LogicTreeNode contentNode = new LogicTreeNode();
             contentNode.idNum = lt.NextIdNum;
             contentNode.nodeText = "root";
             lt.AddNodeToRoot(contentNode);
             TreeNode mainNode = new TreeNode();
             mainNode.Name = "0";
             mainNode.Text = "root";
             treeView1.Nodes.Add(mainNode);
         }
         else
         {
             //initializeConditionsTab();
             //initializeActionsTab();
         }
     }
     else
     {
         lt.Filename = filenameOnly;
         LogicTreeNode contentNode = new LogicTreeNode();
         contentNode.idNum = lt.NextIdNum;
         contentNode.nodeText = "root";
         lt.AddNodeToRoot(contentNode);
         TreeNode mainNode = new TreeNode();
         mainNode.Name = "0";
         mainNode.Text = "root";
         treeView1.Nodes.Add(mainNode);
     }
     currentSelectedNode = null;
     SortLogicTree(lt);
     ResetOrderNumBasedOnIndex(lt.SubNodes[0]);
     prntForm.openLogicTreesList.Add(lt);
     fillScriptList();
 }
Esempio n. 7
0
 public void PushToUndoStack()
 {
     LogicTree newConvo = new LogicTree();
     newConvo = lt.Clone();
     undoConvoStack.Push(newConvo);
 }
Esempio n. 8
0
 private void undoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (undoConvoStack.Count > 0)
     {
         LogicTree newConvo = new LogicTree();
         newConvo = lt.Clone();
         redoConvoStack.Push(newConvo);
         lt = undoConvoStack.Pop();
         refreshTreeView();
     }
 }
Esempio n. 9
0
 private void tsRedo_Click(object sender, EventArgs e)
 {
     if (redoConvoStack.Count > 0)
     {
         LogicTree newConvo = new LogicTree();
         newConvo = lt.Clone();
         undoConvoStack.Push(newConvo);
         lt = redoConvoStack.Pop();
         refreshTreeView();
     }
 }
Esempio n. 10
0
 private void openFile(string path, string filename)
 {
     try
     {
         lt = lt.GetLogicTree(path, filename);
         refreshTreeView();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
     }
 }