protected override void ResetState() { post = null; }
void ICommitGumpEntity.Create() { if (GuardPost.Owner == null) { return; } m_Gump.AddPage(0); m_Gump.AddImage(486, 28, 2623); m_Gump.AddImage(36, 1, 10861); m_Gump.AddImage(6, 33, 2623); m_Gump.AddImage(6, 242, 2623); m_Gump.AddImage(6, 15, 2620); m_Gump.AddImage(219, 14, 2621); m_Gump.AddImage(140, 33, 2623); m_Gump.AddImage(139, 242, 2623); m_Gump.AddImage(6, 452, 2626); m_Gump.AddImage(213, 462, 2621); m_Gump.AddImage(469, 451, 2628); m_Gump.AddImage(470, 14, 2622); m_Gump.AddImage(486, 41, 2623); m_Gump.AddImage(485, 243, 2623); m_Gump.AddImage(26, 14, 2621); m_Gump.AddImage(23, 462, 2621); m_Gump.AddAlphaRegion(493, 14, 22, 463); m_Gump.AddBackground(16, 25, 470, 440, 9270); m_Gump.AddAlphaRegion(8, 473, 499, 8); m_Gump.AddButton(401, 417, 247, 248, (int)Buttons.btnMenuMainOK, GumpButtonType.Reply, 0); m_Gump.AddHtml(45, 46, 412, 19, @"<basefont color=#FFCC00><center>Guard Post Customisation</basefont></center>", (bool)false, (bool)false); m_Gump.AddHtml(60, 76, 205, 314, "<basefont color=white><center>Guard Type</center></basefont>", (bool)false, (bool)false); m_Gump.AddHtml(286, 76, 199, 314, "<basefont color=white><center>Hire Rate</center></basefont>", (bool)false, (bool)false); //For the guards we could just use the enum directly but in this case i want to sort the guards by their cost type first. //And also possibly exclude guard types from this particular Kin. m_Types = KinSystem.GetEligibleGuardTypes(GuardPost.Owner.IOBRealAlignment); m_Types.Sort(delegate(KinFactionGuardTypes x, KinFactionGuardTypes y) //Sort by cost type so they are grouped { int costA = (int)KinSystem.GetGuardCostType(x); int costB = (int)KinSystem.GetGuardCostType(y); if (costA < costB) { return(1); } else if (costA == costB) { return(0); } else { return(-1); } } ); List <string> guardTypeStrings = new List <string>(); foreach (KinFactionGuardTypes t in m_Types) { guardTypeStrings.Add(KinSystem.GetEnumTypeDescription <KinFactionGuardTypes>(t)); } //Add complete button set of possible guards, in two columns. Hook response methods up. m_GuardTypeButtons = new ButtonSet ( m_Gump, guardTypeStrings, 2, 135, 25, 1153, 1150, 41, 115, 1000, //Anon methods GO! delegate(int id) { return(m_State.GetValue <KinFactionGuardTypes>("Type").Equals(m_Types[id])); }, //Get Status delegate(int id) { SetGuardType(m_Types[id]); }, //Click delegate(int id) { return(GetGuardTextColour(m_Types[id])); } //Get label colour ); m_Gump.AddHtml(75, 310, 230, 314, string.Format(m_MAINT, GetNextMaintTimeMinutes()), (bool)false, (bool)false); m_Gump.AddHtml(75, 335, 230, 314, string.Format(m_SLOTS, GetSlotTextColour(), m_State.GetValue <int>("Slots")), (bool)false, (bool)false); m_Gump.AddHtml(75, 360, 230, 314, string.Format(m_SILVER, GetSilverTextColour(), GuardPost.Silver), (bool)false, (bool)false); //Defrag creatures and show next hire time if there is no guard currently spawned. GuardPost.Defrag(); if (GuardPost.Creatures.Count == 0) { m_Gump.AddHtml(75, 385, 230, 314, string.Format(m_HIRE, GetNextHireTimeMinutes()), (bool)false, (bool)false); } //Add button set for the FightMode subset we are interested in. m_SpeedButtons = new ButtonSet ( m_Gump, typeof(KinGuardPost.HireSpeeds), 1, 0, 25, 1153, 1150, 340, 115, 2000, //Anon methods GO! delegate(int id) { return(((int)m_State.GetValue <KinGuardPost.HireSpeeds>("Speed")).Equals(id)); }, delegate(int id) { m_State.SetValue("Speed", (KinGuardPost.HireSpeeds)id); }, delegate(int id) { return(1359); } ); m_Gump.AddHtml(286, 200, 199, 314, "<basefont color=white><center>Target Priority</center></basefont>", (bool)false, (bool)false); //Add button set for the FightMode subset we are interested in. m_TargetButtons = new ButtonSet ( m_Gump, typeof(FightModeButtons), 1, 0, 25, 1153, 1150, 340, 230, 3000, //note: these are flags so we give them the highest offset //Anon methods GO! delegate(int id) { return((((int)m_State.GetValue <FightMode>("Target")) & id) != 0); }, delegate(int id) { SetTarget((FightMode)id); }, delegate(int id) { return(1359); } ); /* * m_Gump.AddHtml(286, 310, 199, 314, "<basefont color=white><center>Fight Style</center></basefont>", (bool)false, (bool)false); * * spacer = 315; * * m_Gump.AddLabel(380, spacer += 25, 1359, @"Melee"); * m_Gump.AddButton(340, spacer, 1150, 1153, (int)Buttons.btnStyleMelee, GumpButtonType.Reply, 0); * m_Gump.AddLabel(380, spacer += 25, 1359, @"Magic"); * m_Gump.AddButton(340, spacer, 1150, 1153, (int)Buttons.btnStyleMagic, GumpButtonType.Reply, 0); */ if (m_State.IsValueDirty <KinFactionGuardTypes>("Type") || m_State.IsValueDirty <int>("Slots") || m_State.IsValueDirty <KinGuardPost.HireSpeeds>("Speed") || m_State.IsValueDirty <FightMode>("Target")) { m_Gump.AddHtml(10, 415, 412, 136, m_OK, (bool)false, (bool)false); } }
protected override void LoadState() { post = new(ParsedFileLines(GuardPostRecord.Parse)); }
/// <summary> /// Commit any outstanding changes /// </summary> /// <param name="sender"></param> void ICommitGumpEntity.CommitChanges() { if (!((ICommitGumpEntity)this).Validate()) { m_Gump.From.SendMessage("The guard post has been changed since you were modifying it. Please make the changes again."); return; } if (m_State.IsValueDirty <KinFactionGuardTypes>("Type")) { //set guard type //TODO: - check some delay? GuardPost.GuardType = (KinFactionGuardTypes)m_State.GetValue <KinFactionGuardTypes>("Type"); m_Gump.From.SendMessage("Guard type changed to {0}.", KinSystem.GetEnumTypeDescription <KinFactionGuardTypes>((KinFactionGuardTypes)m_State.GetValue <KinFactionGuardTypes>("Type"))); } if (m_State.IsValueDirty <KinGuardPost.HireSpeeds>("Speed")) { GuardPost.HireSpeed = (KinGuardPost.HireSpeeds)m_State.GetValue <KinGuardPost.HireSpeeds>("Speed"); m_Gump.From.SendMessage("Hire rate successfully changed to {0}", KinSystem.GetEnumTypeDescription <KinGuardPost.HireSpeeds>((KinGuardPost.HireSpeeds)m_State.GetValue <KinGuardPost.HireSpeeds>("Speed"))); GuardPost.RefreshNextSpawnTime(); } if (m_State.IsValueDirty <int>("Slots")) { KinFactionGuardTypes currentType = (KinFactionGuardTypes)m_State.GetOriginalValue <KinFactionGuardTypes>("Type"); KinFactionGuardTypes type = (KinFactionGuardTypes)m_State.GetValue <KinFactionGuardTypes>("Type"); int cost = KinSystem.GetGuardCostType(type); int currentCost = KinSystem.GetGuardCostType(currentType); int slots = 0; slots += (currentCost - cost); KinCityData data = KinCityManager.GetCityData(GuardPost.City); if (data == null) { return; } KinCityData.BeneficiaryData bd = data.GetBeneficiary(GuardPost.Owner); if (bd == null) { return; } bd.ModifyGuardSlots(slots); m_Gump.From.SendMessage("Unassigned guard slots modified by {0}.", slots); } /* * if (m_State.StyleChanged) * { * //Assign new style * GuardPost.FightStyle = m_State.Style; * } */ if (m_State.IsValueDirty <FightMode>("Target")) { //Dont overwrite this one // 0 the strongest, weakest, closest //NAND out the options so these bits are all 0 GuardPost.FightMode &= ~FightMode.Strongest; GuardPost.FightMode &= ~FightMode.Weakest; GuardPost.FightMode &= ~FightMode.Closest; //write new version GuardPost.FightMode |= (FightMode)m_State.GetValue <FightMode>("Target"); m_Gump.From.SendMessage("Guard target priority successfully changed."); GuardPost.UpdateExisitngGuards(); } }