コード例 #1
0
 void Apply()
 {
     ADialog ad=new ADialog();
     ad.id=dialog_id;
     ad.comment=comment;
     ad.dialog=stepdialogs;
     int write = dw.AddToXML(ad);
     if(write==DialogWriter.IDNOTAVAILBLE)
     {
         SwNotification("Dialog ID Not Available.");
     }
     else if(write==DialogWriter.WRITEFAILED)
     {
         SwNotification("Cannot Find the Dialog File.");
     }
     else
     {
         SwNotification("Successfully Add the Dialog into the System.");
     }
 }
コード例 #2
0
 void Apply()
 {
     ADialog ad = new ADialog();
     ad.id = edit_id;
     ad.comment = comment;
     ad.dialog = stepdialogs;
     dw.RemoveFromXML(edit_id);
     int write = dw.AddToXML(ad);
     if (write == DialogWriter.IDNOTAVAILBLE)
     {
         SwNotification("Something Wrong in the Apply Process.");
     }
     else if (write == DialogWriter.WRITEFAILED)
     {
         SwNotification("Cannot Find the Dialog File.");
     }
     else
     {
         SwNotification("Successfully Apply the Dialog.");
     }
 }
コード例 #3
0
 public int AddToXML(ADialog _dialog)
 {
     if(file == null)
         return WRITEFAILED;
     if (!CheckIDAvailble(_dialog.id))
         return IDNOTAVAILBLE;
     //root of the data
     XmlElement data = file.CreateElement("data");
     data.SetAttribute("id",_dialog.id);
     data.SetAttribute("comment", _dialog.comment);
     dialog_node.AppendChild(data);
     foreach(StepDialog sd in _dialog.dialog)
     {
         XmlElement stepdialog = file.CreateElement("text");
         stepdialog.SetAttribute("order",sd.order);
         stepdialog.SetAttribute("speaker", sd.speaker);
         stepdialog.SetAttribute("aud", sd.audio);
         stepdialog.InnerText = sd.text;
         data.AppendChild(stepdialog);
     }
     file.Save("Assets\\Resources\\dialog.xml");
     if (File.Exists("Assets\\Resources\\dialog.xml.meta"))
         File.Delete("Assets\\Resources\\dialog.xml.meta");
     return WRITESUCCESS;
 }
コード例 #4
0
 public ADialog GetDialog(string id)
 {
     XmlNodeList dialogs = dialog_node.ChildNodes;
     ADialog result = new ADialog();
     result.dialog = new List<StepDialog>();
     foreach (XmlElement di in dialogs)
     {
         if(di.GetAttribute("id")==id)
         {
             result.id = id;
             result.comment = di.GetAttribute("comment");
             XmlNodeList steps = di.ChildNodes;
             foreach(XmlElement sd in steps)
             {
                 StepDialog stepdialog = new StepDialog();
                 stepdialog.order = sd.GetAttribute("order");
                 stepdialog.speaker = sd.GetAttribute("speaker");
                 stepdialog.audio = sd.GetAttribute("aud");
                 stepdialog.text = sd.InnerText;
                 result.dialog.Add(stepdialog);
             }
             result.dialog.Sort((a, b) =>
             {
                 if (int.Parse(a.order) > int.Parse(b.order))
                     return 1;
                 if (int.Parse(a.order) == int.Parse(b.order))
                     return 0;
                 return -1;
             });
             return result;
         }
     }
     result.id = "null";
     return result;
 }