コード例 #1
0
 public ConvoEditor(Module mod, ParentForm p)
 {
     InitializeComponent();
     f_convo = new Convo();
     ce_mod = mod;
     prntForm = p;
 }
コード例 #2
0
 private void btnAddConvo_Click_1(object sender, EventArgs e)
 {
     Convo newConvo = new Convo();
     newConvo.ConvoFileName = "new conversation";
     prntForm.mod.moduleConvosList.Add(newConvo.ConvoFileName);
     refreshListBoxConvos();
     // should I create a new file at this point?
 }
コード例 #3
0
        private void btnAddConvo_Click_1(object sender, EventArgs e)
        {
            Convo newConvo = new Convo();

            newConvo.ConvoFileName = "new conversation";
            prntForm.mod.moduleConvosList.Add(newConvo.ConvoFileName);
            refreshListBoxConvos();
            // should I create a new file at this point?
        }
コード例 #4
0
 public static void SortConversation(Convo toSort)
 {
     int i;
     if (toSort.subNodes.Count > 0)
     {
         for (i = 0; i < toSort.subNodes.Count; i++)
         {
             SortSubNodes(toSort.subNodes[i]);
         }
     }
 }
コード例 #5
0
        public Convo GetConversation(string path, string FileName)
        {
            Convo toReturn = null;

            // deserialize JSON directly from a file
            using (StreamReader file = File.OpenText(path + "\\" + FileName))
            {
                JsonSerializer serializer = new JsonSerializer();
                toReturn = (Convo)serializer.Deserialize(file, typeof(Convo));
            }
            return(toReturn);
        }
コード例 #6
0
ファイル: DataCheck.cs プロジェクト: grannypron/IB2Toolset
 public void CheckConvos()
 {
     //look for end points on red nodes
     foreach (string convofilename in frm.mod.moduleConvosList)
     {
         convo = convo.GetConversation(frm._mainDirectory + "\\modules\\" + frm.mod.moduleName + "\\dialog\\", convofilename + ".json");
         if (convo == null)
         {
             frm.logText("CONVO ERROR: returned a null convo for " + convofilename + ", most likely couldn't find file" + Environment.NewLine);
             continue;
         }
         //go through all nodes recursively and look for end points that are red
     }
 }
コード例 #7
0
 private void btnDuplicate_Click(object sender, EventArgs e)
 {
     if ((lbxConvos.Items.Count > 0) && (lbxConvos.SelectedIndex >= 0))
     {
         //if file exists, rename the file
         string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\dialog";
         string filename = prntForm.mod.moduleConvosList[prntForm._selectedLbxConvoIndex];
         if (File.Exists(filePath + "\\" + filename + ".json"))
         {
             try
             {
                 //rename file
                 File.Copy(filePath + "\\" + filename + ".json", filePath + "\\" + filename + "-Copy.json"); // Try to move
                 try
                 {
                     //load convo
                     Convo newConvo = new Convo();
                     newConvo = newConvo.GetConversation(filePath, "\\" + filename + "-Copy.json");
                     if (newConvo == null)
                     {
                         MessageBox.Show("returned a null convo");
                     }
                     //change convo file name in convo file object properties
                     newConvo.ConvoFileName = filename + "-Copy";
                     newConvo.SaveContentConversation(filePath, "\\" + filename + "-Copy.json");
                     prntForm.mod.moduleConvosList.Add(newConvo.ConvoFileName);
                     refreshListBoxConvos();
                 }
                 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");
         }
         refreshListBoxConvos();
     }
 }
コード例 #8
0
 private void btnDuplicate_Click(object sender, EventArgs e)
 {
     if ((lbxConvos.Items.Count > 0) && (lbxConvos.SelectedIndex >= 0))
     {
         //if file exists, rename the file
         string filePath = prntForm._mainDirectory + "\\modules\\" + prntForm.mod.moduleName + "\\dialog";
         string filename = prntForm.mod.moduleConvosList[prntForm._selectedLbxConvoIndex];
         if (File.Exists(filePath + "\\" + filename + ".json"))
         {
             try
             {
                 //rename file
                 File.Copy(filePath + "\\" + filename + ".json", filePath + "\\" + filename + "-Copy.json"); // Try to move
                 try
                 {
                     //load convo
                     Convo newConvo = new Convo();
                     newConvo = newConvo.GetConversation(filePath, "\\" + filename + "-Copy.json");
                     if (newConvo == null)
                     {
                         MessageBox.Show("returned a null convo");
                     }
                     //change convo file name in convo file object properties
                     newConvo.ConvoFileName = filename + "-Copy";
                     newConvo.SaveContentConversation(filePath, "\\" + filename + "-Copy.json");
                     prntForm.mod.moduleConvosList.Add(newConvo.ConvoFileName);
                     refreshListBoxConvos();
                 }
                 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");
         }
         refreshListBoxConvos();
     }
 }
コード例 #9
0
ファイル: DataCheck.cs プロジェクト: slowdive-fan/IB2Toolset
        public void CheckConvos()
        {
            //look for end points on red nodes
            foreach (string convofilename in frm.mod.moduleConvosList)
            {
                convo = convo.GetConversation(frm._mainDirectory + "\\modules\\" + frm.mod.moduleName + "\\dialog\\", convofilename + ".json");
                if (convo == null)
                {
                    frm.logText("CONVO ERROR: returned a null convo for " + convofilename + ", most likely couldn't find file" + Environment.NewLine);
                    continue;
                }
                //go through all nodes recursively and look for end points that are red

            }
        }
コード例 #10
0
 private void ConvoEditor_Load(object sender, EventArgs e)
 {
     // load the file that has the selected node name if it exists
     string filenameOnly = ce_mod.moduleConvosList[prntForm._selectedLbxConvoIndex] + ".json";
     string dirFullPath = prntForm._mainDirectory + "\\modules\\" + ce_mod.moduleName + "\\dialog";
     if (File.Exists(dirFullPath + "\\" + filenameOnly))
     {
         openFile(dirFullPath, filenameOnly);
         if (f_convo == null)
         {
             f_convo = new Convo();
             f_convo.ConvoFileName = filenameOnly;
             //initializeConditionsTab();
             //initializeActionsTab();
             // start off by adding a base treeview node
             ContentNode contentNode = new ContentNode();
             contentNode.idNum = f_convo.NextIdNum;
             contentNode.conversationText = "root";
             f_convo.AddNodeToRoot(contentNode);
             TreeNode mainNode = new TreeNode();
             mainNode.Name = "0";
             mainNode.Text = "root";
             treeView1.Nodes.Add(mainNode);
         }
         else
         {
             //initializeConditionsTab();
             //initializeActionsTab();
         }
     }
     else
     {
         f_convo.ConvoFileName = filenameOnly;
         //initializeConditionsTab();
         //initializeActionsTab();
         // start off by adding a base treeview node
         ContentNode contentNode = new ContentNode();
         contentNode.idNum = f_convo.NextIdNum;
         contentNode.conversationText = "root";
         f_convo.AddNodeToRoot(contentNode);
         TreeNode mainNode = new TreeNode();
         mainNode.Name = "0";
         mainNode.Text = "root";
         treeView1.Nodes.Add(mainNode);
     }
     currentSelectedNode = null;
     txtImage.Text = f_convo.NpcPortraitBitmap;
     txtDefaultNpcName.Text = f_convo.DefaultNpcName;
     chkNarrator.Checked = f_convo.Narration;
     chkPartyChat.Checked = f_convo.PartyChat;
     chkMainPcOnly.Checked = f_convo.SpeakToMainPcOnly;
     SortConversation(f_convo);
     ResetOrderNumBasedOnIndex(f_convo.subNodes[0]);
     prntForm.openConvosList.Add(f_convo);
     fillScriptList();
 }
コード例 #11
0
 public void PushToUndoStack()
 {
     Convo newConvo = new Convo();
     newConvo = f_convo.Clone();
     undoConvoStack.Push(newConvo);
 }
コード例 #12
0
 private void undoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (undoConvoStack.Count > 0)
     {
         Convo newConvo = new Convo();
         newConvo = f_convo.Clone();
         redoConvoStack.Push(newConvo);
         f_convo = undoConvoStack.Pop();
         refreshTreeView();
     }
 }
コード例 #13
0
 private void tsRedo_Click(object sender, EventArgs e)
 {
     if (redoConvoStack.Count > 0)
     {
         Convo newConvo = new Convo();
         newConvo = f_convo.Clone();
         undoConvoStack.Push(newConvo);
         f_convo = redoConvoStack.Pop();
         refreshTreeView();
     }
 }
コード例 #14
0
 private void openFile(string path, string filename)
 {
     try
     {
         f_convo = f_convo.GetConversation(path, filename);
         refreshTreeView();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
     }
 }
コード例 #15
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 { }
         }
     }
 }
コード例 #16
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 { }
         }
     }
 }