Ejemplo n.º 1
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();
     }
 }
Ejemplo n.º 2
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();
            }
Ejemplo n.º 3
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("timer");
     writer.WriteAttributeString("name", e.Name);
     base.SaveFields(writer, e);
     writer.WriteEndElement();
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 5
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("javascript");
     writer.WriteAttributeString("src", e.Fields[FieldDefinitions.Src]);
     writer.WriteEndElement();
 }
Ejemplo n.º 6
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("include");
     writer.WriteAttributeString("ref", e.Fields[FieldDefinitions.Filename]);
     writer.WriteEndElement();
 }
Ejemplo n.º 7
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();
 }
Ejemplo n.º 8
0
            public void Save(GameXmlWriter writer, Element element, string attribute, object value)
            {
                writer.WriteStartElement(attribute);
                if (!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();
            }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
 public override void Save(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("control");
     base.SaveFields(writer, e);
     writer.WriteEndElement();
 }
Ejemplo n.º 11
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);
 }
Ejemplo n.º 12
0
 public override void StartSave(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("object");
     writer.WriteAttributeString("name", e.Name);
     ObjectSaver.SaveFields(writer, e);
 }
Ejemplo n.º 13
0
 public override void StartSave(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("exit");
     if (!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);
 }
Ejemplo n.º 14
0
 public override void StartSave(GameXmlWriter writer, Element e)
 {
     if (e.Fields[FieldDefinitions.IsVerb])
     {
         writer.WriteStartElement("verb");
     }
     else
     {
         writer.WriteStartElement("command");
     }
     if (!e.Fields[FieldDefinitions.Anonymous])
     {
         writer.WriteAttributeString("name", e.Name);
     }
     ObjectSaver.SaveFields(writer, e);
 }
Ejemplo n.º 15
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();
                }
            }
Ejemplo n.º 16
0
 public void StartSave(GameXmlWriter writer, Element e)
 {
     writer.WriteStartElement("tab");
     base.SaveFields(writer, e);
 }
Ejemplo n.º 17
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();
 }
Ejemplo n.º 18
0
            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);
                    }
                }
            }
Ejemplo n.º 19
0
 protected void WriteAttribute(GameXmlWriter writer, Element element, string attribute, string type, string value)
 {
     writer.WriteStartElement(attribute);
     if (!GameSaver.IsImpliedType(element, attribute, type) || value.Length == 0)
     {
         writer.WriteAttributeString("type", type);
     }
     writer.WriteString(value);
     writer.WriteEndElement();
 }