public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { var db = s.Owner as MegaloScriptDatabase; bool reading = s.IsReading; s.StreamAttributeEnum("type", ref Type); s.StreamAttribute("name", ref Name); bool read_only = IsReadOnly; s.StreamAttributeOpt("readonly", ref read_only, Predicates.IsTrue); if (db.SerializeValueTypeReference(s, "paramTypeEnum", ref EnumValueType, isOptional: true)) { Flags |= MegaloScriptProtoVariableReferenceMemberFlags.HasDataType; } if (db.SerializeValueTypeReference(s, "paramValueType", ref ValueType, isOptional: true)) { Flags |= MegaloScriptProtoVariableReferenceMemberFlags.HasDataValue; s.StreamAttribute("paramValueName", ref ValueName); } if (reading) { if (read_only) { Flags |= MegaloScriptProtoVariableReferenceMemberFlags.Readonly; } } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { var build = s.IsWriting ? BuildHandle : Engine.EngineBuildHandle.None; using (s.EnterCursorBookmark("Game")) Engine.EngineBuildHandle.Serialize(s, ref build); if (s.IsReading) { // #TODO_BLAM: validate build handle? BuildHandle = build; } s.StreamElementEnum("Content", ref Type); s.StreamElement("TimeStamp", ref Timestamp); s.WriteComment(this, _this => _this.Timestamp.ToString(System.Globalization.CultureInfo.InvariantCulture)); s.StreamElement("SessionSalt", ref SessionSalt, NumeralBase.Hex); SerializeActivity(s); s.StreamElementEnum("Engine", ref EngineType); s.StreamAttributeOpt("unk4_", ref unk4, Predicates.IsNotNone); s.StreamAttributeOpt("megaloCategory", ref MegaloCategoryIndex, Predicates.IsNotNone); s.StreamAttributeOpt("engineIcon", ref EngineIconIndex, Predicates.IsNotNone); s.StreamAttribute("unkA_", ref unkA); s.StreamAttribute("unkB_", ref unkB); s.StreamElement("Author", ref Author); }
public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { base.Serialize(s); using (s.EnterCursorBookmark("Powerups")) { Predicate <PlayerTraits> traits_are_changed = obj => !obj.IsUnchanged; using (var bm = s.EnterCursorBookmarkOpt("Red", Red, traits_are_changed)) if (bm.IsNotNull) { s.StreamAttribute("duration", ref RedDuration); s.StreamObject(Red); } using (var bm = s.EnterCursorBookmarkOpt("Blue", Blue, traits_are_changed)) if (bm.IsNotNull) { s.StreamAttribute("duration", ref BlueDuration); s.StreamObject(Blue); } using (var bm = s.EnterCursorBookmarkOpt("Yellow", Yellow, traits_are_changed)) if (bm.IsNotNull) { s.StreamAttribute("duration", ref YellowDuration); s.StreamObject(Yellow); } } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttribute("staticDb", ref StaticDatabaseFile); s.StreamAttribute("megaloDb", ref MegaloDatabaseFile); }
public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { s.StreamAttribute(kXmlAttrDbId, ref mDbId); s.StreamAttribute(kXmlAttrVersion, ref mVersion); XML.XmlUtil.Serialize(s, Params, BTriggerParam.kBListExplicitIndexXmlParams); }
public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { base.Serialize(s); s.StreamAttribute(kXmlAttrInvert, ref mInvert); s.StreamAttribute(kXmlAttrAsync, ref mAsync); s.StreamAttribute(kXmlAttrAsyncParameterKey, ref mAsyncParameterKey); }
public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { base.Serialize(s); s.StreamAttribute(kXmlAttrDbId, ref mDbId); s.StreamAttribute(kXmlAttrVersion, ref mVersion); // Stream it last, so when we save it ourselves, the (relatively) fixed width stuff comes first // XML.XmlUtil.StreamInternString(s, kXmlAttrType, ref mTypeStr, false); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttribute("R", ref Red); s.StreamAttribute("G", ref Green); s.StreamAttribute("B", ref Blue); s.StreamAttributeOpt("A", ref Transparent, Predicates.IsTrue); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamCursor(ref mName); s.StreamAttribute("ikRange", ref mIKRange); s.StreamAttribute("linkCount", ref mLinkCount); s.StreamAttributeOpt("x", ref mAxisPositioning.X, Predicates.IsNotZero); s.StreamAttributeOpt("z", ref mAxisPositioning.Z, Predicates.IsNotZero); }
internal static void SigIdNamePairToStream <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s, KeyValuePair <int, string> pair) where TDoc : class where TCursor : class { int key = pair.Key; string value = pair.Value; s.StreamAttribute(kSigIdAttributeName, ref key); s.StreamAttribute(kNameAttirbuteName, ref key); }
public override void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { base.Serialize(s); using (s.EnterCursorBookmark("ContentHeader")) { s.StreamAttribute("buildMajor", ref mBuildMajor); s.StreamAttribute("buildMinor", ref mBuildMinor); s.StreamObject(Data); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { //if (s.IsReading) s.ReadCursorName(ref mType); s.StreamAttributeEnum(kXmlAttrType, ref mType); s.StreamAttribute(kXmlAttrSigId, ref mSigID); s.StreamAttribute(DatabaseNamedObject.kXmlAttrNameN, ref mName); s.StreamAttributeOpt(kXmlAttrOptional, ref mOptional, Predicates.IsTrue); s.StreamCursorEnum(ref mVarType); }
internal static KeyValuePair <int, string> SigIdNamePairFromStream <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { int key = TypeExtensions.kNone; string value = null; s.StreamAttribute(kSigIdAttributeName, ref key); s.StreamAttribute(kNameAttirbuteName, ref value); return(new KeyValuePair <int, string>(key, value)); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttribute("foreground", ref ForegroundIndex); s.StreamAttribute("background", ref BackgroundIndex); s.StreamAttribute("primaryColor", ref PrimaryColor); s.StreamAttribute("secondaryColor", ref SecondaryColor); s.StreamAttribute("backgroundColor", ref BackgroundColor); s.StreamAttributeOpt("flags", ref Flags, Predicates.IsNotZero); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { if (s.IsReading) { s.ReadCursorName(ref mType); } s.StreamAttribute(kXmlAttrSigId, ref mSigID); s.StreamAttribute(DatabaseNamedObject.kXmlAttrNameN, ref mName); s.StreamAttribute(kXmlAttrOptional, ref mOptional); s.StreamCursor(ref mVarID); }
public virtual void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttributeEnumOpt("flags", ref Flags, f => f != 0, true); using (s.EnterCursorBookmark("Round")) { s.StreamAttribute("timeLimit", ref RoundTimeLimit); s.StreamAttribute("limit", ref RoundLimit); s.StreamAttribute("earlyVictoryWinCount", ref EarlyVictoryWinCount); s.StreamAttribute("suddenDeathTimeLimit", ref SuddenDeathTimeLimit); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttribute("bitLength", ref BitLength); if (!NoEncoding) { s.StreamAttribute("min", ref Min); s.StreamAttribute("max", ref Max); s.StreamAttributeOpt("isSigned", ref IsSigned, Predicates.IsTrue); s.StreamAttributeOpt("flag1", ref Flag1, Predicates.IsFalse); } s.StreamAttribute("name", ref Name); }
protected override void SerializeImpl <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) { base.SerializeImpl(s); s.StreamAttribute("fireTeamsEnabled", ref FireTeamsEnabled); s.StreamAttribute("symmetricGametype", ref SymmetricGametype); if (mEncodingVersion >= kEncodingVersionTU1) { using (var bm = s.EnterCursorBookmarkOpt("TU1", TU1, obj => !obj.IsUnchanged)) if (bm.IsNotNull) { s.StreamObject(TU1); } } }
protected virtual void SerializeImpl <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { using (s.EnterCursorBookmark("SerializeFlags")) s.StreamCursorEnum(ref TagElementStreamSerializeFlags, true); s.StreamAttribute("encoding", ref mEncodingVersion, NumeralBase.Hex); s.StreamAttribute("version", ref EngineVersion); // Must come first. Most of the other variant data contains string references SerializeLocaleStrings(s); using (var bm = s.EnterCursorBookmarkOpt("PlayerTraits", PlayerTraits, Predicates.HasItems)) if (bm.IsNotNull) { s.StreamableElements("entry", PlayerTraits, this, _this => _this.NewMegaloPlayerTraits()); } using (var bm = s.EnterCursorBookmarkOpt("UserDefinedOptions", UserDefinedOptions, Predicates.HasItems)) if (bm.IsNotNull) { s.StreamableElements("entry", UserDefinedOptions); } if (!s.StreamAttributeOpt("engineIcon", ref EngineIconIndex, Predicates.IsNotNone)) { EngineIconIndex = TypeExtensions.kNone; } if (!s.StreamAttributeOpt("engineCategory", ref EngineCategory, Predicates.IsNotNone)) { EngineCategory = TypeExtensions.kNone; } using (var bm = s.EnterCursorBookmarkOpt("MapPermissions", MapPermissions, mp => !mp.IsDefault)) if (bm.IsNotNull) { s.StreamObject(MapPermissions); } using (var bm = s.EnterCursorBookmarkOpt("PlayerRatingParams", PlayerRatingParameters, prp => !prp.IsDefault)) if (bm.IsNotNull) { s.StreamObject(PlayerRatingParameters); } else { PlayerRatingParameters.RevertToDefault(); } s.StreamAttributeOpt("scoreToWinRound", ref ScoreToWinRound, Predicates.IsNotZero); SerializeOptionToggles(s); }
internal static void SerializeTypeName <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s, string keyName, ref string typeName) where TDoc : class where TCursor : class { s.StreamAttribute(keyName, ref typeName); }
public virtual void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttribute("typeIndex", ref TypeIndex); SerializeTypeName(s, kAttributeKeyName, ref TypeName); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { using (s.EnterUserDataBookmark(this)) { s.StreamAttributeOpt("name", this, obj => EcfName, Predicates.IsNotNullOrEmpty); s.StreamAttributeOpt("ext", this, obj => EcfFileExtension, Predicates.IsNotNullOrEmpty); using (s.EnterCursorBookmark("Header")) { s.StreamAttribute("id", this, obj => HeaderId, NumeralBase.Hex); s.StreamAttributeOpt("ChunkExtraDataSize", this, obj => ChunkExtraDataSize, Predicates.IsNotZero, NumeralBase.Hex); } using (var bm = s.EnterCursorBookmarkOpt("Chunks", Chunks, Predicates.HasItems)) s.StreamableElements("C", Chunks, obj => obj.HasPossibleFileData); } // #NOTE leaving this as an exercise for the caller instead, so they can yell when something is culled #if false if (s.IsReading) { CullChunksPossiblyWithoutFileData(); } #endif }
static void StreamSystemPrototypeKey <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s, BlamEngine engine, ref Values.KGuid systemGuid) where TDoc : class where TCursor : class { s.StreamAttribute("guid", ref systemGuid); if (s.IsReading) { string invalid_guid_msg = null; if (systemGuid == Values.KGuid.Empty) { invalid_guid_msg = "Invalid system guid: "; } else if (EngineRegistry.TryGetRegisteredSystem(systemGuid) == null) { invalid_guid_msg = "Unknown system guid: "; } if (invalid_guid_msg != null) { s.ThrowReadException(new System.IO.InvalidDataException( invalid_guid_msg + systemGuid.ToString(Values.KGuid.kFormatHyphenated, Util.InvariantCultureInfo))); } } }
protected static void StreamValue <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s, string valueName, ref string value, bool useInnerText, bool useElement, bool internValue, bool toLower) where TDoc : class where TCursor : class { if (useInnerText) { s.StreamCursor(ref value); } else if (useElement) { s.StreamElement(valueName, ref value); } else if (valueName != null) { s.StreamAttribute(valueName, ref value); } if (s.IsReading) { if (toLower) { value = value.ToLowerInvariant(); } if (internValue) { value = string.Intern(value); } } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttribute("Max", ref mMax); s.StreamCursor(ref mCount); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttribute("duration", ref Duration); s.StreamObject(Traits); }
internal bool SerializeValueTypeReference <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s, string attributeName, ref MegaloScriptValueType type, bool isOptional = false) where TDoc : class where TCursor : class { bool streamed = true; bool reading = s.IsReading; string type_name = reading ? null : ValueTypeNames[type.NameIndex]; if (isOptional) { streamed = s.StreamAttributeOpt(attributeName, ref type_name, ValueTypeNameIsNotNone); if (!streamed && reading) { type_name = kNoValueTypeName; } } else { s.StreamAttribute(attributeName, ref type_name); } if (reading) { type = GetValueType(type_name); } return(streamed); }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { using (s.EnterCursorBookmark("Language")) { s.StreamAttribute("name", ref mLanguage); if (s.IsReading) { var temp_list = new List <LocString>(); bool is_sorted = true; LocString prev_str = null; foreach (var n in s.ElementsByName("String")) { using (s.EnterCursorBookmark(n)) { var str = new LocString(); str.Serialize(s); temp_list.Add(str); if (is_sorted && prev_str != null && prev_str.ID >= str.ID) { is_sorted = false; } prev_str = str; } } if (!is_sorted) { temp_list.Sort((x, y) => x.ID.CompareTo(y.ID)); } int last_id = temp_list[temp_list.Count - 1].ID; UsedIndices.Length = last_id + 1; mDoNotUpdateUsedIndices = true; foreach (var str in temp_list) { int id = str.ID; if (UsedIndices[id]) { s.ThrowReadException(new System.IO.InvalidDataException(string.Format( "Duplicate LocString: #{0} '{1}'", str.ID, str.Text))); } UsedIndices[id] = true; } this.AddRange(temp_list); mDoNotUpdateUsedIndices = false; } else if (s.IsWriting) { s.WriteStreamableElements("String", this); } } }
internal static void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s, MegaloScriptModel model, ref MegaloScriptModelObjectHandle handle) where TDoc : class where TCursor : class { bool reading = s.IsReading; var type = reading ? MegaloScriptModelObjectType.None : handle.Type; int id = reading ? TypeExtensions.kNone : handle.Id; s.StreamAttributeEnum("type", ref type); if (!model.TagElementStreamSerializeFlags.EmbedObjectsWriteSansIds()) { s.StreamAttribute(MegaloScriptModelObject.kIdAttributeName, ref id); } else if (reading) { handle = CreateForWriteSansId(model, type).Handle; } // handle will already be valid if the above case is hit if (reading && handle.Type == MegaloScriptModelObjectType.None) { handle = new MegaloScriptModelObjectHandle(type, id); } }
public void Serialize <TDoc, TCursor>(IO.TagElementStream <TDoc, TCursor, string> s) where TDoc : class where TCursor : class { s.StreamAttribute("size_", ref Size); s.StreamObject(Loadout); }