Beispiel #1
0
            public override void Save(GameXmlWriter writer, Element element, string attribute, object value)
            {
                QuestList <Element> list = (QuestList <Element>)value;
                string saveString        = String.Join("; ", list.Select(e => e.Name).ToArray());

                base.WriteAttribute(writer, element, attribute, "objectlist", saveString);
            }
Beispiel #2
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("type");
     writer.WriteAttributeString("name", e.Name);
     SaveFields(writer, e);
     writer.WriteEndElement();
 }
Beispiel #3
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("type");
     writer.WriteAttributeString("name", e.Name);
     SaveFields(writer, e);
     writer.WriteEndElement();
 }
Beispiel #4
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();
 }
Beispiel #5
0
            protected void SaveFields(GameXmlWriter writer, Element e)
            {
                // reverse Types list when saving as it's a Stack, and we want to
                // save types in the same order as they were loaded
                foreach (Element includedType in e.Fields.Types.Reverse())
                {
                    if (CanSaveTypeName(writer, includedType.Name, e))
                    {
                        writer.WriteStartElement("inherit");
                        writer.WriteAttributeString("name", includedType.Name);
                        writer.WriteEndElement();
                    }
                }

                IEnumerable <string> fieldNames = e.Fields.FieldNames;

                if (writer.Mode != SaveMode.Editor)
                {
                    fieldNames = fieldNames.Union(e.Fields.FieldExtensionNames);
                }

                foreach (string attribute in fieldNames)
                {
                    if (CanSaveAttribute(attribute, e))
                    {
                        object value = e.Fields.Get(attribute);
                        m_fieldSaver.Save(writer, e, attribute, value);
                    }
                }
            }
Beispiel #6
0
            public override void Save(GameXmlWriter writer, Element element, string attribute, object value)
            {
                IScript script      = (IScript)value;
                string  savedScript = GameSaver.SaveScript(writer, script, 1);

                base.WriteAttribute(writer, element, attribute, "script", savedScript);
            }
Beispiel #7
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();
 }
Beispiel #8
0
        public void Save(GameXmlWriter writer, Element element, string attribute, object value)
        {
            if (value == null)
            {
                return;
            }
            IFieldSaver saver;

            if (TryGetSaver(value.GetType(), out saver))
            {
                try
                {
                    saver.Save(writer, element, attribute, value);
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Failed to save field '{0}.{1}' with value '{2}' - {3}",
                                                      element.Name, attribute, value, ex.Message), ex);
                }
            }
            else
            {
                throw new Exception(string.Format("ERROR: No FieldSaver for attribute {0}, type: {1}", attribute, value.GetType()));
            }
        }
Beispiel #9
0
 private bool GetSaver(GameXmlWriter writer, Element e, out IObjectSaver saver)
 {
     if (!m_savers.TryGetValue(e.Type, out saver))
     {
         throw new Exception("ERROR: No ObjectSaver for type " + e.Type.ToString());
     }
     return(true);
 }
Beispiel #10
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();
 }
Beispiel #11
0
            public void EndSave(GameXmlWriter writer, Element e)
            {
                IObjectSaver saver;

                if (GetSaver(writer, e, out saver))
                {
                    saver.EndSave(writer, e);
                }
            }
Beispiel #12
0
 public override void StartSave(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("turnscript");
     if (writer.Mode == SaveMode.SavedGame || !e.Fields[FieldDefinitions.Anonymous])
     {
         writer.WriteAttributeString("name", e.Name);
     }
     ObjectSaver.SaveFields(writer, e);
 }
Beispiel #13
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);
                }
            }
Beispiel #14
0
 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));
 }
Beispiel #15
0
 public void Save(GameXmlWriter writer, WorldModel worldModel)
 {
     if (!writer.Options.IncludeWalkthrough)
     {
         return;
     }
     foreach (Element walkThrough in worldModel.Elements.GetElements(ElementType.Walkthrough).Where(e => e.Parent == null))
     {
         SaveElementAndChildren(writer, worldModel, walkThrough);
     }
 }
Beispiel #16
0
            public void Save(GameXmlWriter writer, WorldModel worldModel)
            {
                ObjectSaver elementSaver = new ObjectSaver();
                elementSaver.GameSaver = GameSaver;

                IEnumerable<Element> allObjects = worldModel.Elements.GetElements(ElementType.Object).OrderBy(o => o.MetaFields[MetaFieldDefinitions.SortIndex]);

                foreach (Element e in allObjects.Where(e => e.Parent == null && GameSaver.CanSave(e)))
                {
                    SaveObjectAndChildren(writer, allObjects, e, elementSaver);
                }
            }
Beispiel #17
0
            public override void Save(GameXmlWriter writer, Element e)
            {
                string filename = e.Fields[FieldDefinitions.Filename];

                if (string.IsNullOrEmpty(filename))
                {
                    return;
                }
                writer.WriteStartElement("include");
                writer.WriteAttributeString("ref", filename);
                writer.WriteEndElement();
            }
Beispiel #18
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();
     }
 }
Beispiel #19
0
 protected override bool CanSaveTypeName(GameXmlWriter writer, string type, Element e)
 {
     if (!base.CanSaveTypeName(writer, type, e))
     {
         return(false);
     }
     if (e.Type == ObjectType.Command && e.Fields[FieldDefinitions.IsVerb] && type == "defaultverb")
     {
         return(false);
     }
     return(true);
 }
Beispiel #20
0
            public override void Save(GameXmlWriter writer, Element e)
            {
                string filename = e.Fields[FieldDefinitions.Src];

                if (string.IsNullOrEmpty(filename))
                {
                    return;
                }
                writer.WriteStartElement("javascript");
                writer.WriteAttributeString("src", filename);
                writer.WriteEndElement();
            }
Beispiel #21
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();
     }
 }
Beispiel #22
0
            public void Save(GameXmlWriter writer, WorldModel worldModel)
            {
                ObjectSaver elementSaver = new ObjectSaver();

                elementSaver.GameSaver = GameSaver;

                IEnumerable <Element> allObjects = worldModel.Elements.GetElements(ElementType.Object).OrderBy(o => o.MetaFields[MetaFieldDefinitions.SortIndex]);

                foreach (Element e in allObjects.Where(e => e.Parent == null && GameSaver.CanSave(e)))
                {
                    SaveObjectAndChildren(writer, allObjects, e, elementSaver);
                }
            }
Beispiel #23
0
            private void SaveObjectAndChildren(GameXmlWriter writer, IEnumerable<Element> allObjects, Element e, ObjectSaver saver)
            {
                saver.StartSave(writer, e);
                IEnumerable<Element> orderedChildren = from child in allObjects
                                                       where child.Parent == e
                                                       orderby child.MetaFields[MetaFieldDefinitions.SortIndex]
                                                       select child;

                foreach (Element child in orderedChildren)
                {
                    SaveObjectAndChildren(writer, allObjects, child, saver);
                }

                saver.EndSave(writer, e);
            }
Beispiel #24
0
            private void SaveObjectAndChildren(GameXmlWriter writer, IEnumerable <Element> allObjects, Element e, ObjectSaver saver)
            {
                saver.StartSave(writer, e);
                IEnumerable <Element> orderedChildren = from child in allObjects
                                                        where child.Parent == e
                                                        orderby child.MetaFields[MetaFieldDefinitions.SortIndex]
                                                        select child;

                foreach (Element child in orderedChildren)
                {
                    SaveObjectAndChildren(writer, allObjects, child, saver);
                }

                saver.EndSave(writer, e);
            }
Beispiel #25
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();
            }
Beispiel #26
0
            public override void Save(GameXmlWriter writer, Element element, string attribute, object value)
            {
                writer.WriteStartElement(attribute);
                if (element == null || !GameSaver.IsImpliedType(element, attribute, "list"))
                {
                    writer.WriteAttributeString("type", "list");
                }

                QuestList <object> list = (QuestList <object>)value;

                foreach (var item in list)
                {
                    FieldSaver.SaveValue(writer, "value", item);
                }
                writer.WriteEndElement();
            }
Beispiel #27
0
 public override void StartSave(GameXmlWriter writer, Element e)
 {
     if (e.Fields[FieldDefinitions.IsVerb])
     {
         writer.WriteStartElement("verb");
     }
     else
     {
         writer.WriteStartElement("command");
     }
     if (writer.Mode == SaveMode.SavedGame || !e.Fields[FieldDefinitions.Anonymous])
     {
         writer.WriteAttributeString("name", e.Name);
     }
     ObjectSaver.SaveFields(writer, e);
 }
Beispiel #28
0
            private void SaveElementAndChildren(GameXmlWriter writer, WorldModel worldModel, Element walkThrough)
            {
                m_walkthroughSaver.StartSave(writer, walkThrough);

                IEnumerable <Element> orderedChildren = from child in worldModel.Elements.GetElements(ElementType.Walkthrough)
                                                        where child.Parent == walkThrough
                                                        orderby child.MetaFields[MetaFieldDefinitions.SortIndex]
                                                        select child;

                foreach (Element child in orderedChildren)
                {
                    SaveElementAndChildren(writer, worldModel, child);
                }

                m_walkthroughSaver.EndSave(writer, walkThrough);
            }
Beispiel #29
0
 public override void StartSave(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("exit");
     if (writer.Mode == SaveMode.SavedGame || !e.Fields[FieldDefinitions.Anonymous])
     {
         writer.WriteAttributeString("name", e.Name);
     }
     if (!string.IsNullOrEmpty(e.Fields[FieldDefinitions.Alias]))
     {
         writer.WriteAttributeString("alias", e.Fields[FieldDefinitions.Alias]);
     }
     if (e.Fields[FieldDefinitions.To] != null)
     {
         writer.WriteAttributeString("to", e.Fields[FieldDefinitions.To].Name);
     }
     ObjectSaver.SaveFields(writer, e);
 }
Beispiel #30
0
        public void SaveValue(GameXmlWriter writer, string xmlElementName, object value)
        {
            if (value == null)
            {
                return;
            }
            IFieldSaver saver;

            if (TryGetSaver(value.GetType(), out saver))
            {
                saver.Save(writer, xmlElementName, value);
            }
            else
            {
                throw new Exception(string.Format("ERROR: No ValueSaver for XML element {0}, type: {1}", xmlElementName, value.GetType()));
            }
        }
Beispiel #31
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();
 }
Beispiel #32
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();
 }
Beispiel #33
0
            public void Save(GameXmlWriter writer, Element element, string attribute, object value)
            {
                writer.WriteStartElement(attribute);
                if (element == null || !GameSaver.IsImpliedType(element, attribute, "scriptdictionary"))
                {
                    writer.WriteAttributeString("type", "scriptdictionary");
                }

                QuestDictionary <IScript> dictionary = (QuestDictionary <IScript>)value;

                foreach (var item in dictionary)
                {
                    writer.WriteStartElement("item");
                    writer.WriteAttributeString("key", item.Key);
                    writer.WriteString(GameSaver.SaveScript(writer, item.Value, 0));
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
Beispiel #34
0
            public override void Save(GameXmlWriter writer, Element element, string attribute, object value)
            {
                bool boolVal = (bool)value;

                if (boolVal)
                {
                    if (attribute.Contains(" "))
                    {
                        base.WriteAttribute(writer, element, attribute, "boolean", "true");
                    }
                    else
                    {
                        writer.WriteElementString(attribute, null);
                    }
                }
                else
                {
                    base.WriteAttribute(writer, element, attribute, "boolean", "false");
                }
            }
Beispiel #35
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).OrderBy(t => t.MetaFields[MetaFieldDefinitions.SortIndex]))
                    {
                        m_tabSaver.StartSave(writer, tab);
                        foreach (Element control in allControls.Where(c => c.Parent == tab).OrderBy(c => c.MetaFields[MetaFieldDefinitions.SortIndex]))
                        {
                            m_controlSaver.Save(writer, control);
                        }
                        m_tabSaver.EndSave(writer, tab);
                    }
                    m_editorSaver.EndSave(writer, editor);
                }
            }
Beispiel #36
0
            public override void Save(GameXmlWriter writer, Element element, string attribute, object value)
            {
                writer.WriteStartElement(attribute);
                if (element == null || !GameSaver.IsImpliedType(element, attribute, TypeName))
                {
                    writer.WriteAttributeString("type", TypeName);
                }

                var dictionary = (QuestDictionary <T>)value;

                foreach (var item in dictionary)
                {
                    writer.WriteStartElement("item");
                    writer.WriteStartElement("key");
                    writer.WriteString(item.Key);
                    writer.WriteEndElement();
                    WriteXml(writer, item.Value);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
Beispiel #37
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);
     }
 }
Beispiel #38
0
 public abstract void StartSave(GameXmlWriter writer, Element e);
Beispiel #39
0
 public abstract void EndSave(GameXmlWriter writer, Element e);
Beispiel #40
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     StartSave(writer, e);
     EndSave(writer, e);
 }
Beispiel #41
0
 protected override bool CanSaveTypeName(GameXmlWriter writer, string type, Element e)
 {
     if (!base.CanSaveTypeName(writer, type, e)) return false;
     if (e.Type == ObjectType.Command && e.Fields[FieldDefinitions.IsVerb] && type == "defaultverb") return false;
     return true;
 }
Beispiel #42
0
 public override void StartSave(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("exit");
     if (writer.Mode == SaveMode.SavedGame || !e.Fields[FieldDefinitions.Anonymous])
     {
         writer.WriteAttributeString("name", e.Name);
     }
     if (!string.IsNullOrEmpty(e.Fields[FieldDefinitions.Alias]))
     {
         writer.WriteAttributeString("alias", e.Fields[FieldDefinitions.Alias]);
     }
     if (e.Fields[FieldDefinitions.To] != null)
     {
         writer.WriteAttributeString("to", e.Fields[FieldDefinitions.To].Name);
     }
     ObjectSaver.SaveFields(writer, e);
 }
Beispiel #43
0
 public override void EndSave(GameXmlWriter writer, Element e)
 {
     writer.WriteEndElement();
 }
Beispiel #44
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("output");
     base.SaveFields(writer, e);
     writer.WriteEndElement();
 }
Beispiel #45
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     throw new NotImplementedException();
 }
Beispiel #46
0
 public void Save(GameXmlWriter writer, WorldModel worldModel)
 {
     if (!writer.Options.IncludeWalkthrough) return;
     foreach (Element walkThrough in worldModel.Elements.GetElements(ElementType.Walkthrough).Where(e => e.Parent == null))
     {
         SaveElementAndChildren(writer, worldModel, walkThrough);
     }
 }
Beispiel #47
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)
 }
Beispiel #48
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();
 }
Beispiel #49
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     string filename = e.Fields[FieldDefinitions.Filename];
     if (string.IsNullOrEmpty(filename)) return;
     writer.WriteStartElement("include");
     writer.WriteAttributeString("ref", filename);
     writer.WriteEndElement();
 }
Beispiel #50
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 = Utility.GetIndentChars(writer.IndentLevel + 1, writer.IndentChars);

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

                    writer.WriteStartElement("steps");
                    writer.WriteAttributeString("type", GameSaver.Version <= WorldModelVersion.v530 ? "list" : "simplestringlist");
                    writer.WriteString(result);
                    writer.WriteEndElement();
                }
            }
Beispiel #51
0
 public override void StartSave(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("game");
     writer.WriteAttributeString("name", e.Fields.GetString("gamename"));
     ObjectSaver.SaveFields(writer, e);
 }
Beispiel #52
0
 public void StartSave(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("tab");
     base.SaveFields(writer, e);
 }
Beispiel #53
0
 public override void StartSave(GameXmlWriter writer, Element e)
 {
     if (e.Fields[FieldDefinitions.IsVerb])
     {
         writer.WriteStartElement("verb");
     }
     else
     {
         writer.WriteStartElement("command");
     }
     if (writer.Mode == SaveMode.SavedGame || !e.Fields[FieldDefinitions.Anonymous])
     {
         writer.WriteAttributeString("name", e.Name);
     }
     ObjectSaver.SaveFields(writer, e);
 }
Beispiel #54
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).OrderBy(t => t.MetaFields[MetaFieldDefinitions.SortIndex]))
                    {
                        m_tabSaver.StartSave(writer, tab);
                        foreach (Element control in allControls.Where(c => c.Parent == tab).OrderBy(c => c.MetaFields[MetaFieldDefinitions.SortIndex]))
                        {
                            m_controlSaver.Save(writer, control);
                        }
                        m_tabSaver.EndSave(writer, tab);
                    }
                    m_editorSaver.EndSave(writer, editor);
                }
            }
Beispiel #55
0
 public override void StartSave(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("turnscript");
     if (writer.Mode == SaveMode.SavedGame || !e.Fields[FieldDefinitions.Anonymous])
     {
         writer.WriteAttributeString("name", e.Name);
     }
     ObjectSaver.SaveFields(writer, e);
 }
Beispiel #56
0
 public void EndSave(GameXmlWriter writer, Element e)
 {
     IObjectSaver saver;
     if (GetSaver(writer, e, out saver))
     {
         saver.EndSave(writer, e);
     }
 }
Beispiel #57
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     string filename = e.Fields[FieldDefinitions.Src];
     if (string.IsNullOrEmpty(filename)) return;
     writer.WriteStartElement("javascript");
     writer.WriteAttributeString("src", filename);
     writer.WriteEndElement();
 }
Beispiel #58
0
            private void SaveElementAndChildren(GameXmlWriter writer, WorldModel worldModel, Element walkThrough)
            {
                m_walkthroughSaver.StartSave(writer, walkThrough);

                IEnumerable<Element> orderedChildren = from child in worldModel.Elements.GetElements(ElementType.Walkthrough)
                                                       where child.Parent == walkThrough
                                                       orderby child.MetaFields[MetaFieldDefinitions.SortIndex]
                                                       select child;

                foreach (Element child in orderedChildren)
                {
                    SaveElementAndChildren(writer, worldModel, child);
                }

                m_walkthroughSaver.EndSave(writer, walkThrough);
            }
Beispiel #59
0
 private bool GetSaver(GameXmlWriter writer, Element e, out IObjectSaver saver)
 {
     if (!m_savers.TryGetValue(e.Type, out saver))
     {
         throw new Exception("ERROR: No ObjectSaver for type " + e.Type.ToString());
     }
     return true;
 }
Beispiel #60
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();
            }