public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); bool haveproximityrange = false; bool hasnewobjectinfo = false; int tmpSpawnListSize = 0; ArrayList tmpSubGroup = null; ArrayList tmpSequentialResetTime = null; ArrayList tmpSequentialResetTo = null; ArrayList tmpKillsNeeded = null; ArrayList tmpRequireSurface = null; ArrayList tmpRestrictKillsToSubgroup = null; ArrayList tmpClearOnAdvance = null; ArrayList tmpMinDelay = null; ArrayList tmpMaxDelay = null; ArrayList tmpNextSpawn = null; ArrayList tmpDisableSpawn = null; ArrayList tmpPackRange = null; ArrayList tmpSpawnsPer = null; switch( version ) { case 30: { m_AllowNPCTriggering = reader.ReadBool(); goto case 29; } case 29: { tmpSpawnListSize = reader.ReadInt(); tmpSpawnsPer = new ArrayList( tmpSpawnListSize ); for( int i = 0; i < tmpSpawnListSize; ++i ) { int spawnsper = reader.ReadInt(); tmpSpawnsPer.Add( spawnsper ); } goto case 28; } case 28: { if( version < 29 ) tmpSpawnListSize = reader.ReadInt(); tmpPackRange = new ArrayList( tmpSpawnListSize ); for( int i = 0; i < tmpSpawnListSize; ++i ) { int packrange = reader.ReadInt(); tmpPackRange.Add( packrange ); } goto case 27; } case 27: { if( version < 28 ) tmpSpawnListSize = reader.ReadInt(); tmpDisableSpawn = new ArrayList( tmpSpawnListSize ); for( int i = 0; i < tmpSpawnListSize; ++i ) { bool disablespawn = reader.ReadBool(); tmpDisableSpawn.Add( disablespawn ); } goto case 26; } case 26: { m_SpawnOnTrigger = reader.ReadBool(); m_FirstModified = reader.ReadDateTime(); m_LastModified = reader.ReadDateTime(); goto case 25; } case 25: { goto case 24; } case 24: { if( version < 27 ) tmpSpawnListSize = reader.ReadInt(); tmpRestrictKillsToSubgroup = new ArrayList( tmpSpawnListSize ); tmpClearOnAdvance = new ArrayList( tmpSpawnListSize ); tmpMinDelay = new ArrayList( tmpSpawnListSize ); tmpMaxDelay = new ArrayList( tmpSpawnListSize ); tmpNextSpawn = new ArrayList( tmpSpawnListSize ); for( int i = 0; i < tmpSpawnListSize; ++i ) { bool restrictkills = reader.ReadBool(); bool clearadvance = reader.ReadBool(); double mind = reader.ReadDouble(); double maxd = reader.ReadDouble(); DateTime nextspawn = reader.ReadDeltaTime(); tmpRestrictKillsToSubgroup.Add( restrictkills ); tmpClearOnAdvance.Add( clearadvance ); tmpMinDelay.Add( mind ); tmpMaxDelay.Add( maxd ); tmpNextSpawn.Add( nextspawn ); } bool hasitems = reader.ReadBool(); if( hasitems ) { m_ShowBoundsItems = reader.ReadItemList(); } goto case 23; } case 23: { IsInactivated = reader.ReadBool(); SmartSpawning = reader.ReadBool(); goto case 22; } case 22: { SkillTrigger = reader.ReadString(); // note this will also register the skill m_skill_that_triggered = (SkillName)reader.ReadInt(); m_FreeRun = reader.ReadBool(); m_mob_who_triggered = reader.ReadMobile(); goto case 21; } case 21: { m_DespawnTime = reader.ReadTimeSpan(); goto case 20; } case 20: { if( version < 24 ) tmpSpawnListSize = reader.ReadInt(); tmpRequireSurface = new ArrayList( tmpSpawnListSize ); for( int i = 0; i < tmpSpawnListSize; ++i ) { bool requiresurface = reader.ReadBool(); tmpRequireSurface.Add( requiresurface ); } goto case 19; } case 19: { m_ConfigFile = reader.ReadString(); m_OnHold = reader.ReadBool(); m_HoldSequence = reader.ReadBool(); m_FirstModifiedBy = reader.ReadString(); m_LastModifiedBy = reader.ReadString(); // deserialize the keyword tag list int tagcount = reader.ReadInt(); m_KeywordTagList = new ArrayList( tagcount ); for( int i = 0; i < tagcount; i++ ) { BaseXmlSpawner.KeywordTag tag = new BaseXmlSpawner.KeywordTag( null, this ); tag.Deserialize( reader ); } goto case 18; } case 18: { m_AllowGhostTriggering = reader.ReadBool(); goto case 17; } case 17: { if( version < 25 ) { // the textentrybooks are deleted on deserialization so no need to track them reader.ReadItem(); } goto case 16; } case 16: { hasnewobjectinfo = true; m_SequentialSpawning = reader.ReadInt(); TimeSpan seqdelay = reader.ReadTimeSpan(); m_SeqEnd = DateTime.Now + seqdelay; if( version < 20 ) { tmpSpawnListSize = reader.ReadInt(); } tmpSubGroup = new ArrayList( tmpSpawnListSize ); tmpSequentialResetTime = new ArrayList( tmpSpawnListSize ); tmpSequentialResetTo = new ArrayList( tmpSpawnListSize ); tmpKillsNeeded = new ArrayList( tmpSpawnListSize ); for( int i = 0; i < tmpSpawnListSize; ++i ) { int subgroup = reader.ReadInt(); double resettime = reader.ReadDouble(); int resetto = reader.ReadInt(); int killsneeded = reader.ReadInt(); tmpSubGroup.Add( subgroup ); tmpSequentialResetTime.Add( resettime ); tmpSequentialResetTo.Add( resetto ); tmpKillsNeeded.Add( killsneeded ); } m_RegionName = reader.ReadString(); // 2004.02.08 :: Omega Red goto case 15; } case 15: { m_ExternalTriggering = reader.ReadBool(); m_ExternalTrigger = reader.ReadBool(); goto case 14; } case 14: { m_NoItemTriggerName = reader.ReadString(); goto case 13; } case 13: { m_GumpState = reader.ReadString(); goto case 12; } case 12: { int todtype = reader.ReadInt(); switch( todtype ) { case (int)TODModeType.Gametime: m_TODMode = TODModeType.Gametime; break; case (int)TODModeType.Realtime: m_TODMode = TODModeType.Realtime; break; } goto case 11; } case 11: { m_KillReset = reader.ReadInt(); m_skipped = reader.ReadBool(); m_spawncheck = reader.ReadInt(); goto case 10; } case 10: { m_SetPropertyItem = reader.ReadItem(); goto case 9; } case 9: { m_TriggerProbability = reader.ReadDouble(); goto case 8; } case 8: { m_MobPropertyName = reader.ReadString(); m_MobTriggerName = reader.ReadString(); m_PlayerPropertyName = reader.ReadString(); goto case 7; } case 7: { m_SpeechTrigger = reader.ReadString(); goto case 6; } case 6: { m_ItemTriggerName = reader.ReadString(); goto case 5; } case 5: { m_ProximityTriggerMessage = reader.ReadString(); m_ObjectPropertyItem = reader.ReadItem(); m_ObjectPropertyName = reader.ReadString(); m_killcount = reader.ReadInt(); goto case 4; } case 4: { haveproximityrange = true; m_ProximityRange = reader.ReadInt(); m_ProximityTriggerSound = reader.ReadInt(); m_proximityActivated = reader.ReadBool(); m_durActivated = reader.ReadBool(); m_refractActivated = reader.ReadBool(); m_StackAmount = reader.ReadInt(); m_TODStart = reader.ReadTimeSpan(); m_TODEnd = reader.ReadTimeSpan(); m_MinRefractory = reader.ReadTimeSpan(); m_MaxRefractory = reader.ReadTimeSpan(); if( m_refractActivated == true ) { TimeSpan delay = reader.ReadTimeSpan(); DoTimer3( delay ); } if( m_durActivated == true ) { TimeSpan delay = reader.ReadTimeSpan(); DoTimer2( delay ); } goto case 3; } case 3: { m_ShowContainerStatic = reader.ReadItem() as Static; goto case 2; } case 2: { m_Duration = reader.ReadTimeSpan(); goto case 1; } case 1: { m_UniqueId = reader.ReadString(); m_HomeRangeIsRelative = reader.ReadBool(); goto case 0; } case 0: { m_Name = reader.ReadString(); // backward compatibility with old name storage if( m_Name != null && m_Name != String.Empty ) Name = m_Name; m_X = reader.ReadInt(); m_Y = reader.ReadInt(); m_Width = reader.ReadInt(); m_Height = reader.ReadInt(); if( m_Width == m_Height ) m_SpawnRange = m_Width / 2; else m_SpawnRange = -1; if( !haveproximityrange ) { m_ProximityRange = -1; } m_WayPoint = reader.ReadItem() as WayPoint; m_Group = reader.ReadBool(); m_MinDelay = reader.ReadTimeSpan(); m_MaxDelay = reader.ReadTimeSpan(); m_Count = reader.ReadInt(); m_Team = reader.ReadInt(); m_HomeRange = reader.ReadInt(); m_Running = reader.ReadBool(); if( m_Running == true ) { TimeSpan delay = reader.ReadTimeSpan(); DoTimer( delay ); } // Read in the size of the spawn object list int SpawnListSize = reader.ReadInt(); m_SpawnObjects = new ArrayList( SpawnListSize ); for( int i = 0; i < SpawnListSize; ++i ) { string TypeName = reader.ReadString(); int TypeMaxCount = reader.ReadInt(); SpawnObject TheSpawnObject = new SpawnObject( TypeName, TypeMaxCount ); m_SpawnObjects.Add( TheSpawnObject ); string typeName = BaseXmlSpawner.ParseObjectType( TypeName ); // does it have a substitution that might change its validity? // if so then let it go if( typeName == null || ((SpawnerType.GetType( typeName ) == null) && (!BaseXmlSpawner.IsTypeOrItemKeyword( typeName ) && typeName.IndexOf( '{' ) == -1 && !typeName.StartsWith( "*" ) && !typeName.StartsWith( "#" ))) ) { if( m_WarnTimer == null ) m_WarnTimer = new WarnTimer2(); m_WarnTimer.Add( Location, Map, TypeName ); this.status_str = "invalid type: " + typeName; } // Read in the number of spawns already int SpawnedCount = reader.ReadInt(); TheSpawnObject.SpawnedObjects = new ArrayList( SpawnedCount ); for( int x = 0; x < SpawnedCount; ++x ) { int serial = reader.ReadInt(); if( serial < -1 ) { // minusone is reserved for unknown types by default // minustwo on is used for referencing keyword tags int tagserial = -1 * (serial + 2); // get the tag with that serial and add it BaseXmlSpawner.KeywordTag t = BaseXmlSpawner.GetFromTagList( this, tagserial ); if( t != null ) { TheSpawnObject.SpawnedObjects.Add( t ); } } else { IEntity e = World.FindEntity( serial ); if( e != null ) TheSpawnObject.SpawnedObjects.Add( e ); } } } // now have to reintegrate the later version spawnobject information into the earlier version desered objects if( hasnewobjectinfo && tmpSpawnListSize == SpawnListSize ) { for( int i = 0; i < SpawnListSize; ++i ) { SpawnObject so = (SpawnObject)m_SpawnObjects[i]; so.SubGroup = (int)tmpSubGroup[i]; so.SequentialResetTime = (double)tmpSequentialResetTime[i]; so.SequentialResetTo = (int)tmpSequentialResetTo[i]; so.KillsNeeded = (int)tmpKillsNeeded[i]; if( version > 19 ) so.RequireSurface = (bool)tmpRequireSurface[i]; bool restrictkills = false; bool clearadvance = true; double mind = -1; double maxd = -1; DateTime nextspawn = DateTime.MinValue; if( version > 23 ) { restrictkills = (bool)tmpRestrictKillsToSubgroup[i]; clearadvance = (bool)tmpClearOnAdvance[i]; mind = (double)tmpMinDelay[i]; maxd = (double)tmpMaxDelay[i]; nextspawn = (DateTime)tmpNextSpawn[i]; } so.RestrictKillsToSubgroup = restrictkills; so.ClearOnAdvance = clearadvance; so.MinDelay = mind; so.MaxDelay = maxd; so.NextSpawn = nextspawn; bool disablespawn = false; if( version > 26 ) { disablespawn = (bool)tmpDisableSpawn[i]; } so.Disabled = disablespawn; int packrange = -1; if( version > 27 ) { packrange = (int)tmpPackRange[i]; } so.PackRange = packrange; int spawnsper = 1; if( version > 28 ) { spawnsper = (int)tmpSpawnsPer[i]; } so.SpawnsPerTick = spawnsper; } } break; } } }
public XmlSimpleGump( object invoker, string gumptext, string gumptitle, int gumptype, BaseXmlSpawner.KeywordTag tag, Mobile from, XmlGumpCallback gumpcallback) : base( 0, 0 ) { string maintext = gumptext; int nselections = 0; int height = 400; int width = 369; Closable = false; Dragable = true; m_gumptype = gumptype; m_invoker = invoker; m_keywordtag = tag; m_gumpcallback = gumpcallback; AddPage( 0 ); // for the multiple selection gump, parse the gumptext for selections and responses if(gumptype == 4) { maintext = ParseGumpText(gumptext); nselections = gumpSelections.Count; height = height + nselections*40; } if(gumptype == 5) { maintext = ParseGumpText(gumptext); nselections = gumpSelections.Count; // the maintext in this case is a width,height specifier so parse it string [] args = maintext.Split(','); if(args != null && args.Length>1) { int.TryParse(args[0].Trim(), out width); int.TryParse(args[1].Trim(), out height); } } AddImageTiled( 54, 33, width, height, 2624 ); AddAlphaRegion( 54, 33, width, height ); AddImageTiled( width + 47, 39, 44, height-11, 203 ); AddImageTiled( 58, 39, 29, height - 10, 10460 ); // left hand border AddImageTiled( width + 43, 37, 31, height - 11, 10460 ); // right hand border AddImageTiled( 40, 38, 17, height - 9, 9263 ); // leftmost border //AddImageTiled( 94, 25, width - 27, 15, 10304 ); // top border AddImageTiled( 40, 25, width + 48, 15, 10304 ); // top border AddImageTiled( 40, height + 27, width + 46, 16, 10304 ); // bottom border if(gumptype != 5) { AddImage( width + 61, 9, 10441); // dragon borders AddImage( 6, 25, 10421 ); AddImage( 34, 12, 10420 ); AddImage( -10, height - 86, 10402 ); AddImage( 56, 150, 10411 ); AddImage( 136, 84, 96 ); // divider AddImage( width + 3, 57, 1417); // quest icons AddImage( width + 12, 66, 5576); AddButton( width - 31, height - 8, 2130, 2129, 3, GumpButtonType.Reply, 0 ); // Okay button } else { AddButton( width + 70, 25, 0x138b, 0x138b, 0, GumpButtonType.Reply, 0 ); // closegump button } if(gumptitle != null && gumptitle.Length > 0 && gumptype != 5) { // display the title if it is there AddImage( 156, 126, 2103 ); // bullet LocalAddHtml(gumptitle, 174, 121, 200, 40, 0x00FF42, false, false); } if(gumptype == 0) { // simple message gump LocalAddHtml(maintext, 105, 159, 299, 182, 0xEFEF5A, false, true); } else if(gumptype == 1) { // Yes/no type gump AddRadio( 101, height - 45, 9721, 9724, true, 1 ); // accept/yes radio AddRadio( 101, height - 11, 9721, 9724, false, 2 ); // decline/no radio AddHtmlLocalized(137, height - 41, 200, 30, 1049016, 0x7fff , false , false ); // Yes AddHtmlLocalized(137, height - 7, 200, 30, 1049017, 0x7fff , false , false ); // No LocalAddHtml(maintext, 105, 159, 299, 182, 0xEFEF5A, false, true); } else if(gumptype == 2) { // reply type gump AddImageTiled( 134, height - 7, 159, 23, 0x52 ); AddImageTiled( 135, height - 6, 157, 21, 0xBBC ); AddHtmlLocalized(105, height - 7, 200, 30, 3002006, 0x7fff , false , false ); // Say: AddTextEntry( 135, height - 7, 150, 21, 0, 99, (string)null ); LocalAddHtml(maintext, 105, 159, 299, 182, 0xEFEF5A, false, true); } else if(gumptype == 3) { // Quest type gump AddImage( 97, 49, 9005 ); // quest ribbon AddRadio( 101, height - 45, 9721, 9724, true, 1 ); // accept/yes radio AddRadio( 101, height - 11, 9721, 9724, false, 2 ); // decline/no radio AddHtmlLocalized( 139, 59, 200, 30, 1046013, 0x7fff, false , false ); // Quest Offer AddHtmlLocalized(137, height - 41, 200, 30, 1049011, 0x7fff , false , false ); // I accept! AddHtmlLocalized(137, height - 7, 200, 30, 1049012, 0x7fff , false , false ); // No thanks, I decline. LocalAddHtml(maintext, 105, 159, 299, 182, 0xEFEF5A, false, true); } else if(gumptype == 4) { // multiple selection type gump // parse the gump text to get the selections and responses for(int i=0;i < gumpSelections.Count; i++) { int y = 360 + i*40; AddRadio( 101, y, 9721, 9724, i==0 ? true: false, i ); // accept/yes radio AddHtml( 137, y+4, 250, 40, XmlSimpleGump.Color( gumpSelections[i].Selection, "FFFFFF" ), false, false ); } LocalAddHtml(maintext, 105, 159, 299, 182, 0xEFEF5A, false, true); } else if(gumptype == 5) { // parse the gump text to get the selections and responses for(int i=0;i < gumpSelections.Count; i++) { string selection = gumpSelections[i].Selection; string response = gumpSelections[i].Response; int gx = 0; int gy = 0; int gwidth = 0; int gheight = 0; string label = null; string [] args = null; int gumpid = 0; int color = 0; if(selection != null) { args = selection.Split(','); } // process the gumpitem specifications if(args.Length > 1) { for(int j=0;j<args.Length;j++) { args[j] = args[j].Trim(); } if(args[0].ToLower() == "button") { // syntax is button,gumpid,x,y if(args.Length > 3) { if(args[1].StartsWith("0x")) { int.TryParse(args[1].Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out gumpid); } else { int.TryParse(args[1], out gumpid); } int.TryParse(args[2], out gx); int.TryParse(args[3], out gy); int buttonid = 1000 + i; // add the button AddButton( gx, gy, gumpid, gumpid, buttonid, GumpButtonType.Reply, 0 ); } } else if(args[0].ToLower() == "label") { // syntax is label,x,y,label[,color] if(args.Length > 3) { int.TryParse(args[1], out gx); int.TryParse(args[2], out gy); label = args[3]; } // set the default label color color = 0x384; if(args.Length > 4) { int.TryParse(args[4], out color); } // add the label AddLabel( gx, gy, color, label ); } else if(args[0].ToLower() == "html") { // reparse the specification to allow for the possibility of commas in the html text args = selection.Split(new char[] {','},6); color = 0xEFEF5A; // syntax is html,x,y,width,height,text[,hue] * hue has to be in HEX format, ex: 0xFF00AA (lenght of 8 mandatory!) if(args.Length > 5) { int.TryParse(args[1].Trim(), out gx); int.TryParse(args[2].Trim(), out gy); int.TryParse(args[3].Trim(), out gwidth); int.TryParse(args[4].Trim(), out gheight); if(args.Length>6 && args[5].StartsWith("0x") && args[5].Trim().Length==8) { if(!int.TryParse(args[5].Trim().Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out color)) color=0xEFEF5A; label = args[6]; } else label = args[5]; } // add the html area //AddHtml( gx, gy, gwidth, gheight, label, false, true ); LocalAddHtml(label, gx, gy, gwidth, gheight, color, false, true); } else if(args[0].ToLower() == "textentry") { gumpSelections[i].GumpItemType = 1; // syntax is textentry,x,y,width,height[,textcolor][,text] if(args.Length > 4) { int.TryParse(args[1].Trim(), out gx); int.TryParse(args[2].Trim(), out gy); int.TryParse(args[3].Trim(), out gwidth); int.TryParse(args[4].Trim(), out gheight); } if(args.Length > 5) { label = args[5]; } // set the default textentry color color = 0x384; if(args.Length > 6) { int.TryParse(args[6], out color); } AddTextEntry( gx, gy, gwidth, gheight, color, i, label ); } else if(args[0].ToLower() == "radio") { int gumpid1 = 0; int gumpid2 = 0; // syntax is radio,gumpid1,gumpid2,x,y[,initialstate] if(args.Length > 4) { int.TryParse(args[1].Trim(), out gumpid1); int.TryParse(args[2].Trim(), out gumpid2); int.TryParse(args[3].Trim(), out gx); int.TryParse(args[4].Trim(), out gy); } bool initial = false; if(args.Length > 5) { bool.TryParse(args[5], out initial); } AddRadio( gx, gy, gumpid1, gumpid2, initial, i); } else if(args[0].ToLower() == "image") { // syntax is image,gumpid,x,y[,hue] if(args.Length > 3) { if(args[1].StartsWith("0x")) { int.TryParse(args[1].Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out gumpid); } else { int.TryParse(args[1], out gumpid); } int.TryParse(args[2], out gx); int.TryParse(args[3], out gy); if(args.Length > 4) { int.TryParse(args[4], out color); } // add the image AddImage( gx, gy, gumpid, color ); } } else if(args[0].ToLower() == "imagetiled") { // syntax is imagetiled,gumpid,x,y,width,height if(args.Length > 5) { if(args[1].StartsWith("0x")) { int.TryParse(args[1].Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out gumpid); } else { int.TryParse(args[1], out gumpid); } int.TryParse(args[2], out gx); int.TryParse(args[3], out gy); int.TryParse(args[4], out gwidth); int.TryParse(args[5], out gheight); // add the image AddImageTiled( gx, gy, gwidth, gheight, gumpid ); } } else if(args[0].ToLower() == "item") { // syntax is item,itemid,x,y[,hue] if(args.Length > 3) { if(args[1].StartsWith("0x")) { int.TryParse(args[1].Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out gumpid); } else { int.TryParse(args[1], out gumpid); } int.TryParse(args[2], out gx); int.TryParse(args[3], out gy); if(args.Length > 4) { int.TryParse(args[4], out color); } // add the image AddItem( gx, gy, gumpid, color ); } } } } } }