public VoteGump(PlayerMobile from, Election election) : base(50, 50) { m_From = from; m_Election = election; bool canVote = election.CanVote(from); AddPage(0); AddBackground(0, 0, 420, 350, 5054); AddBackground(10, 10, 400, 330, 3000); AddHtmlText(20, 20, 380, 20, election.Faction.Definition.Header, false, false); if (canVote) { AddHtmlLocalized(20, 60, 380, 20, 1011428, false, false); // VOTE FOR LEADERSHIP } else { AddHtmlLocalized(20, 60, 380, 20, 1038032, false, false); // You have already voted in this election. } for (int i = 0; i < election.Candidates.Count; ++i) { Candidate cd = election.Candidates[i]; if (canVote) { AddButton(20, 100 + (i * 20), 4005, 4007, i + 1, GumpButtonType.Reply, 0); } AddLabel(55, 100 + (i * 20), 0, cd.Mobile.Name); AddLabel(300, 100 + (i * 20), 0, cd.Votes.ToString()); } AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Reply, 0); AddHtmlLocalized(55, 310, 100, 20, 1011012, false, false); // CANCEL }
public ElectionManagementGump(Election election, Candidate candidate, int page) : base(40, 40) { m_Election = election; m_Candidate = candidate; m_Page = page; AddPage(0); if (candidate != null) { AddBackground(0, 0, 448, 354, 9270); AddAlphaRegion(10, 10, 428, 334); AddHtml(10, 10, 428, 20, Color(Center("Candidate Management"), LabelColor), false, false); AddHtml(45, 35, 100, 20, Color("Player Name:", LabelColor), false, false); AddHtml(145, 35, 100, 20, Color(candidate.Mobile == null ? "null" : candidate.Mobile.Name, LabelColor), false, false); AddHtml(45, 55, 100, 20, Color("Vote Count:", LabelColor), false, false); AddHtml(145, 55, 100, 20, Color(candidate.Votes.ToString(), LabelColor), false, false); AddButton(12, 73, 4005, 4007, 1, GumpButtonType.Reply, 0); AddHtml(45, 75, 100, 20, Color("Drop Candidate", LabelColor), false, false); AddImageTiled(13, 99, 422, 242, 9264); AddImageTiled(14, 100, 420, 240, 9274); AddAlphaRegion(14, 100, 420, 240); AddHtml(14, 100, 420, 20, Color(Center("Voters"), LabelColor), false, false); if (page > 0) { AddButton(397, 104, 0x15E3, 0x15E7, 2, GumpButtonType.Reply, 0); } else { AddImage(397, 104, 0x25EA); } if ((page + 1) * 10 < candidate.Voters.Count) { AddButton(414, 104, 0x15E1, 0x15E5, 3, GumpButtonType.Reply, 0); } else { AddImage(414, 104, 0x25E6); } AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor), false, false); AddHtml(47, 120, 150, 20, Color("Name", LabelColor), false, false); AddHtml(195, 120, 100, 20, Color(Center("Address"), LabelColor), false, false); AddHtml(295, 120, 80, 20, Color(Center("Time"), LabelColor), false, false); AddHtml(355, 120, 60, 20, Color(Center("Legit"), LabelColor), false, false); int idx = 0; for (int i = page * 10; i >= 0 && i < candidate.Voters.Count && i < (page + 1) * 10; ++i, ++idx) { Voter voter = (Voter)candidate.Voters[i]; AddButton(13, 138 + (idx * 20), 4002, 4004, 4 + i, GumpButtonType.Reply, 0); object[] fields = voter.AcquireFields(); int x = 45; for (int j = 0; j < fields.Length; ++j) { object obj = fields[j]; if (obj is Mobile) { AddHtml(x + 2, 140 + (idx * 20), 150, 20, Color(((Mobile)obj).Name, LabelColor), false, false); x += 150; } else if (obj is System.Net.IPAddress) { AddHtml(x, 140 + (idx * 20), 100, 20, Color(Center(obj.ToString()), LabelColor), false, false); x += 100; } else if (obj is DateTime) { AddHtml(x, 140 + (idx * 20), 80, 20, Color(Center(FormatTimeSpan(((DateTime)obj) - election.LastStateTime)), LabelColor), false, false); x += 80; } else if (obj is int) { AddHtml(x, 140 + (idx * 20), 60, 20, Color(Center((int)obj + "%"), LabelColor), false, false); x += 60; } } } } else { AddBackground(0, 0, 288, 334, 9270); AddAlphaRegion(10, 10, 268, 314); AddHtml(10, 10, 268, 20, Color(Center("Election Management"), LabelColor), false, false); AddHtml(45, 35, 100, 20, Color("Current State:", LabelColor), false, false); AddHtml(145, 35, 100, 20, Color(election.State.ToString(), LabelColor), false, false); AddButton(12, 53, 4005, 4007, 1, GumpButtonType.Reply, 0); AddHtml(45, 55, 100, 20, Color("Transition Time:", LabelColor), false, false); AddHtml(145, 55, 100, 20, Color(FormatTimeSpan(election.NextStateTime), LabelColor), false, false); AddImageTiled(13, 79, 262, 242, 9264); AddImageTiled(14, 80, 260, 240, 9274); AddAlphaRegion(14, 80, 260, 240); AddHtml(14, 80, 260, 20, Color(Center("Candidates"), LabelColor), false, false); AddHtml(14, 100, 30, 20, Color(Center("-->"), LabelColor), false, false); AddHtml(47, 100, 150, 20, Color("Name", LabelColor), false, false); AddHtml(195, 100, 80, 20, Color(Center("Votes"), LabelColor), false, false); for (int i = 0; i < election.Candidates.Count; ++i) { Candidate cd = election.Candidates[i]; Mobile mob = cd.Mobile; if (mob == null) { continue; } AddButton(13, 118 + (i * 20), 4005, 4007, 2 + i, GumpButtonType.Reply, 0); AddHtml(47, 120 + (i * 20), 150, 20, Color(mob.Name, LabelColor), false, false); AddHtml(195, 120 + (i * 20), 80, 20, Color(Center(cd.Votes.ToString()), LabelColor), false, false); } } }
public ElectionManagementGump(Election election) : this(election, null, 0) { }
public ElectionGump(PlayerMobile from, Election election) : base(50, 50) { m_From = from; m_Election = election; AddPage(0); AddBackground(0, 0, 420, 180, 5054); AddBackground(10, 10, 400, 160, 3000); AddHtmlText(20, 20, 380, 20, election.Faction.Definition.Header, false, false); // NOTE: Gump not entirely OSI-accurate, intentionally so switch (election.State) { case ElectionState.Pending: { TimeSpan toGo = (election.LastStateTime + Election.PendingPeriod) - DateTime.UtcNow; int days = (int)(toGo.TotalDays + 0.5); AddHtmlLocalized(20, 40, 380, 20, 1038034, false, false); // A new election campaign is pending if (days > 0) { AddHtmlLocalized(20, 60, 280, 20, 1018062, false, false); // Days until next election : AddLabel(300, 60, 0, days.ToString()); } else { AddHtmlLocalized(20, 60, 280, 20, 1018059, false, false); // Election campaigning begins tonight. } break; } case ElectionState.Campaign: { TimeSpan toGo = (election.LastStateTime + Election.CampaignPeriod) - DateTime.UtcNow; int days = (int)(toGo.TotalDays + 0.5); AddHtmlLocalized(20, 40, 380, 20, 1018058, false, false); // There is an election campaign in progress. if (days > 0) { AddHtmlLocalized(20, 60, 280, 20, 1038033, false, false); // Days to go: AddLabel(300, 60, 0, days.ToString()); } else { AddHtmlLocalized(20, 60, 280, 20, 1018061, false, false); // Campaign in progress. Voting begins tonight. } if (m_Election.CanBeCandidate(m_From)) { AddButton(20, 110, 4005, 4007, 2, GumpButtonType.Reply, 0); AddHtmlLocalized(55, 110, 350, 20, 1011427, false, false); // CAMPAIGN FOR LEADERSHIP } else { PlayerState pl = PlayerState.Find(m_From); if (pl == null || pl.Rank.Rank < Election.CandidateRank) { AddHtmlLocalized(20, 100, 380, 20, 1010118, false, false); // You must have a higher rank to run for office } } break; } case ElectionState.Election: { TimeSpan toGo = (election.LastStateTime + Election.VotingPeriod) - DateTime.UtcNow; int days = (int)Math.Ceiling(toGo.TotalDays); AddHtmlLocalized(20, 40, 380, 20, 1018060, false, false); // There is an election vote in progress. AddHtmlLocalized(20, 60, 280, 20, 1038033, false, false); AddLabel(300, 60, 0, days.ToString()); AddHtmlLocalized(55, 100, 380, 20, 1011428, false, false); // VOTE FOR LEADERSHIP AddButton(20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0); break; } } AddButton(20, 140, 4005, 4007, 0, GumpButtonType.Reply, 0); AddHtmlLocalized(55, 140, 350, 20, 1011012, false, false); // CANCEL }
public FactionState(GenericReader reader) { int version = reader.ReadEncodedInt(); switch (version) { case 5: { m_LastAtrophy = reader.ReadDateTime(); goto case 4; } case 4: { int count = reader.ReadEncodedInt(); for (int i = 0; i < count; ++i) { DateTime time = reader.ReadDateTime(); if (i < m_LastBroadcasts.Length) { m_LastBroadcasts[i] = time; } } goto case 3; } case 3: case 2: case 1: { m_Election = new Election(reader); goto case 0; } case 0: { m_Faction = Faction.ReadReference(reader); m_Commander = reader.ReadMobile(); if (version < 5) { m_LastAtrophy = DateTime.UtcNow; } if (version < 4) { DateTime time = reader.ReadDateTime(); if (m_LastBroadcasts.Length > 0) { m_LastBroadcasts[0] = time; } } m_Tithe = reader.ReadEncodedInt(); m_Silver = reader.ReadEncodedInt(); int memberCount = reader.ReadEncodedInt(); m_Members = new List <PlayerState>(); for (int i = 0; i < memberCount; ++i) { PlayerState pl = new PlayerState(reader, m_Faction, m_Members); if (pl.Mobile != null) { m_Members.Add(pl); } } m_Faction.State = this; m_Faction.ZeroRankOffset = m_Members.Count; m_Members.Sort(); for (int i = m_Members.Count - 1; i >= 0; i--) { PlayerState player = m_Members[i]; if (player.KillPoints <= 0) { m_Faction.ZeroRankOffset = i; } else { player.RankIndex = i; } } m_FactionItems = new List <FactionItem>(); if (version >= 2) { int factionItemCount = reader.ReadEncodedInt(); for (int i = 0; i < factionItemCount; ++i) { FactionItem factionItem = new FactionItem(reader, m_Faction); Timer.DelayCall(TimeSpan.Zero, new TimerCallback(factionItem.CheckAttach)); // sandbox attachment } } m_FactionTraps = new List <BaseFactionTrap>(); if (version >= 3) { int factionTrapCount = reader.ReadEncodedInt(); for (int i = 0; i < factionTrapCount; ++i) { BaseFactionTrap trap = reader.ReadItem() as BaseFactionTrap; if (trap != null && !trap.CheckDecay()) { m_FactionTraps.Add(trap); } } } break; } } if (version < 1) { m_Election = new Election(m_Faction); } }