示例#1
0
 public void EndSave(GameXmlWriter writer, Element e)
 {
     IObjectSaver saver;
     if (GetSaver(writer, e, out saver))
     {
         saver.EndSave(writer, e);
     }
 }
示例#2
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     IObjectSaver saver;
     if (GetSaver(writer, e, out saver))
     {
         saver.StartSave(writer, e);
         saver.EndSave(writer, e);
     }
 }
示例#3
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     // only save the delegate definition, not the individual implementations - they are just fields on objects
     if (!e.MetaFields[MetaFieldDefinitions.DelegateImplementation])
     {
         writer.WriteStartElement("delegate");
         writer.WriteAttributeString("name", e.Name);
         writer.WriteAttributeString("parameters", string.Join(", ", e.Fields[FieldDefinitions.ParamNames].ToArray()));
         writer.WriteAttributeString("type", e.Fields[FieldDefinitions.ReturnType]);
         writer.WriteEndElement();
     }
 }
示例#4
0
 public void Save(GameXmlWriter writer, Element element, string attribute, object value)
 {
     if (value == null) return;
     IFieldSaver saver;
     if (TryGetSaver(value.GetType(), out saver))
     {
         saver.Save(writer, element, attribute, value);
     }
     else
     {
         throw new Exception(string.Format("ERROR: No FieldSaver for attribute {0}, type: {1}", attribute, value.GetType().ToString()));
     }
 }
示例#5
0
            public override void Save(GameXmlWriter writer, Element e)
            {
                writer.WriteStartElement("dynamictemplate");
                writer.WriteAttributeString("name", e.Name);

                if (!GameSaver.m_worldModel.EditMode)
                {
                    writer.WriteString(e.Fields[FieldDefinitions.Function].Save());
                }
                else
                {
                    writer.WriteString(e.Fields[FieldDefinitions.Text]);
                }
                writer.WriteEndElement();
            }
示例#6
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("timer");
     writer.WriteAttributeString("name", e.Name);
     base.SaveFields(writer, e);
     writer.WriteEndElement();
 }
示例#7
0
 public void EndSave(GameXmlWriter writer, Element e)
 {
     writer.WriteEndElement();
 }
示例#8
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     // Resource elements should never need to be saved. They can only
     // be defined by the Core library and are there for information only
     // (specifying which additional files to include in a .quest file)
 }
示例#9
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("template");
     writer.WriteAttributeString("name", e.Fields[FieldDefinitions.TemplateName]);
     writer.WriteString(e.Fields[FieldDefinitions.Text]);
     writer.WriteEndElement();
 }
示例#10
0
            public void Save(GameXmlWriter writer, WorldModel worldModel)
            {
                ObjectSaver elementSaver = new ObjectSaver();
                elementSaver.GameSaver = GameSaver;

                IEnumerable<Element> allObjects = worldModel.Elements.GetElements(ElementType.Object);

                foreach (Element e in allObjects.Where(e => e.Parent == null && GameSaver.CanSave(e)))
                {
                    SaveObjectAndChildren(writer, allObjects, e, elementSaver);
                }
            }
示例#11
0
 public override void StartSave(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("object");
     writer.WriteAttributeString("name", e.Name);
     ObjectSaver.SaveFields(writer, e);
 }
示例#12
0
 private void SaveElementAndChildren(GameXmlWriter writer, WorldModel worldModel, Element walkThrough)
 {
     m_walkthroughSaver.StartSave(writer, walkThrough);
     foreach (Element child in worldModel.Elements.GetElements(ElementType.Walkthrough).Where(e => e.Parent == walkThrough))
     {
         SaveElementAndChildren(writer, worldModel, child);
     }
     m_walkthroughSaver.EndSave(writer, walkThrough);
 }
示例#13
0
 public void Save(GameXmlWriter writer, WorldModel worldModel)
 {
     foreach (Element walkThrough in worldModel.Elements.GetElements(ElementType.Walkthrough).Where(e => e.Parent == null))
     {
         SaveElementAndChildren(writer, worldModel, walkThrough);
     }
 }
示例#14
0
 public override void StartSave(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("turnscript");
     if (!e.Fields[FieldDefinitions.Anonymous])
     {
         writer.WriteAttributeString("name", e.Name);
     }
     ObjectSaver.SaveFields(writer, e);
 }
示例#15
0
 public void StartSave(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("tab");
     base.SaveFields(writer, e);
 }
示例#16
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     throw new NotImplementedException();
 }
示例#17
0
            public void Save(GameXmlWriter writer, WorldModel worldModel)
            {
                IEnumerable<Element> allEditors = worldModel.Elements.GetElements(ElementType.Editor);
                IEnumerable<Element> allTabs = worldModel.Elements.GetElements(ElementType.EditorTab);
                IEnumerable<Element> allControls = worldModel.Elements.GetElements(ElementType.EditorControl);

                foreach (Element editor in allEditors.Where(e => !e.MetaFields[MetaFieldDefinitions.Library]))
                {
                    m_editorSaver.StartSave(writer, editor);
                    foreach (Element tab in allTabs.Where(t => t.Parent == editor))
                    {
                        m_tabSaver.StartSave(writer, tab);
                        foreach (Element control in allControls.Where(c => c.Parent == tab))
                        {
                            m_controlSaver.Save(writer, control);
                        }
                        m_tabSaver.EndSave(writer, tab);
                    }
                    m_editorSaver.EndSave(writer, editor);
                }
            }
示例#18
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("control");
     base.SaveFields(writer, e);
     writer.WriteEndElement();
 }
示例#19
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     StartSave(writer, e);
     EndSave(writer, e);
 }
示例#20
0
文件: GameSaver.cs 项目: Pertex/Quest
 public string SaveScript(GameXmlWriter writer, IScript script, int indent)
 {
     return IndentScript(script.Save(), writer.IndentLevel + indent, writer.IndentChars);
 }
示例#21
0
            public void StartSave(GameXmlWriter writer, Element e)
            {
                writer.WriteStartElement("walkthrough");
                writer.WriteAttributeString("name", e.Name);

                QuestList<string> steps = e.Fields[FieldDefinitions.Steps];
                if (steps != null && steps.Count > 0)
                {
                    string result = string.Empty;
                    string indent = GameSaver.GetIndentChars(writer.IndentLevel + 1, writer.IndentChars);

                    foreach (string step in steps)
                    {
                        result += Environment.NewLine + indent + step;
                    }
                    result += Environment.NewLine;

                    writer.WriteStartElement("steps");
                    writer.WriteString(result);
                    writer.WriteEndElement();
                }
            }
示例#22
0
文件: GameSaver.cs 项目: Pertex/Quest
 protected virtual bool CanSaveTypeName(GameXmlWriter writer, string type, Element e)
 {
     if (writer.Mode == SaveMode.Package)
     {
         if (e.WorldModel.Elements.Get(ElementType.ObjectType, type).MetaFields[MetaFieldDefinitions.EditorLibrary])
         {
             return false;
         }
     }
     return !WorldModel.DefaultTypeNames.ContainsValue(type);
 }
示例#23
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("function");
     writer.WriteAttributeString("name", e.Name);
     if (e.Fields[FieldDefinitions.ParamNames] != null && e.Fields[FieldDefinitions.ParamNames].Count > 0)
     {
         writer.WriteAttributeString("parameters", string.Join(", ", e.Fields[FieldDefinitions.ParamNames].ToArray()));
     }
     if (!string.IsNullOrEmpty(e.Fields[FieldDefinitions.ReturnType]))
     {
         writer.WriteAttributeString("type", e.Fields[FieldDefinitions.ReturnType]);
     }
     if (e.Fields[FieldDefinitions.Script] != null)
     {
         writer.WriteString(GameSaver.SaveScript(writer, e.Fields[FieldDefinitions.Script], 0));
     }
     writer.WriteEndElement();
 }
示例#24
0
            private void SaveObjectAndChildren(GameXmlWriter writer, IEnumerable<Element> allObjects, Element e, ObjectSaver saver)
            {
                saver.StartSave(writer, e);

                foreach (Element child in allObjects)
                {
                    if (child.Parent == e)
                    {
                        SaveObjectAndChildren(writer, allObjects, child, saver);
                    }
                }

                saver.EndSave(writer, e);
            }
示例#25
0
文件: GameSaver.cs 项目: Pertex/Quest
        public string Save(SaveMode mode)
        {
            m_mode = mode;
            GameXmlWriter writer = new GameXmlWriter(mode);

            UpdateImpliedTypesCache();

            writer.WriteComment("Saved by Quest Editor v5.0");
            writer.WriteStartElement("asl");
            writer.WriteAttributeString("version", "500");
            if (mode == SaveMode.SavedGame)
            {
                writer.WriteAttributeString("original", m_worldModel.Filename);
            }

            foreach (ElementType t in Enum.GetValues(typeof(ElementType)))
            {
                if (m_elementsSavers.ContainsKey(t))
                {
                    // We have an IElementsSaver which saves all elements of a particular type at once
                    m_elementsSavers[t].Save(writer, m_worldModel);
                }
                else
                {
                    // Save the elements individually
                    IElementSaver saver;
                    if (m_elementSavers.TryGetValue(t, out saver))
                    {
                        if (saver.AutoSave)
                        {
                            foreach (Element e in m_worldModel.Elements.GetElements(t).Where(e => CanSave(e)))
                            {
                                saver.Save(writer, e);
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("ERROR: No ElementSaver for type " + t.ToString());
                    }
                }
            }

            writer.WriteEndElement();
            writer.Close();

            return writer.ToString();
        }
示例#26
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("implied");
     writer.WriteAttributeString("element", e.Fields[FieldDefinitions.Element]);
     writer.WriteAttributeString("property", e.Fields[FieldDefinitions.Property]);
     writer.WriteAttributeString("type", e.Fields[FieldDefinitions.Type]);
     writer.WriteEndElement();
 }
示例#27
0
文件: GameSaver.cs 项目: Pertex/Quest
 public abstract void Save(GameXmlWriter writer, Element e);
示例#28
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("include");
     writer.WriteAttributeString("ref", e.Fields[FieldDefinitions.Filename]);
     writer.WriteEndElement();
 }
示例#29
0
文件: GameSaver.cs 项目: Pertex/Quest
            protected void SaveFields(GameXmlWriter writer, Element e)
            {
                foreach (Element includedType in e.Fields.Types)
                {
                    if (CanSaveTypeName(writer, includedType.Name, e))
                    {
                        writer.WriteStartElement("inherit");
                        writer.WriteAttributeString("name", includedType.Name);
                        writer.WriteEndElement();
                    }
                }

                foreach (string attribute in e.Fields.FieldNames)
                {
                    if (CanSaveAttribute(attribute, e))
                    {
                        object value = e.Fields.Get(attribute);
                        m_fieldSaver.Save(writer, e, attribute, value);
                    }
                }
            }
示例#30
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("javascript");
     writer.WriteAttributeString("src", e.Fields[FieldDefinitions.Src]);
     writer.WriteEndElement();
 }