Beispiel #1
0
        public void QueuePoll(ShardPoller poller)
        {
            if (m_Polls == null)
            {
                m_Polls = new Queue <ShardPoller>(4);
            }

            m_Polls.Enqueue(poller);
        }
Beispiel #2
0
        private static void EventSink_Login_Callback(object state)
        {
            Mobile   from = (Mobile)state;
            NetState ns   = from.NetState;

            if (ns == null)
            {
                return;
            }

            ShardPollGump spg = null;

            for (int i = 0; i < m_ActivePollers.Count; ++i)
            {
                ShardPoller poller = m_ActivePollers[i];

                if (poller.Deleted || !poller.Active)
                {
                    continue;
                }

                if (poller.TimeRemaining > TimeSpan.Zero)
                {
                    if (poller.HasAlreadyVoted(ns))
                    {
                        continue;
                    }

                    if (spg == null)
                    {
                        spg = new ShardPollGump(from, poller, false, null);
                        from.SendGump(spg);
                    }
                    else
                    {
                        spg.QueuePoll(poller);
                    }
                }
                else
                {
                    poller.Active = false;
                }
            }
        }
Beispiel #3
0
		public ShardPollPrompt( ShardPoller poller, ShardPollOption opt )
		{
			m_Poller = poller;
			m_Option = opt;
		}
Beispiel #4
0
		public ShardPollGump( Mobile from, ShardPoller poller, bool editing, Queue polls ) : base( 50, 50 )
		{
			m_From = from;
			m_Poller = poller;
			m_Editing = editing;
			m_Polls = polls;

			Closable = false;

			AddPage( 0 );

			int totalVotes = 0;
			int totalOptionHeight = 0;

			for ( int i = 0; i < poller.Options.Length; ++i )
			{
				totalVotes += poller.Options[i].Votes;
				totalOptionHeight += poller.Options[i].ComputeHeight() + 5;
			}

			bool isViewingResults = editing && poller.Active;
			bool isCompleted = totalVotes > 0 && !poller.Active;

			if ( editing && !isViewingResults )
				totalOptionHeight += 35;

			int height = 115 + totalOptionHeight;

			AddBackground( 1, 1, 398, height - 2, 3600 );
			AddAlphaRegion( 16, 15, 369, height - 31 );

			AddItem( 308, 30, 0x1E5E );

			string title;

			if ( editing )
				title = ( isCompleted ? "Poll Completed" : "Poll Editor" );
			else
				title = "Shard Poll";

			AddHtml( 22, 22, 294, 20, Color( Center( title ), LabelColor32 ), false, false );

			if ( editing )
			{
				AddHtml( 22, 22, 294, 20, Color( String.Format( "{0} total", totalVotes ), LabelColor32 ), false, false );
				AddButton( 287, 23, 0x2622, 0x2623, 2, GumpButtonType.Reply, 0 );
			}

			AddHtml( 22, 50, 294, 40, Color( poller.Title, 0x99CC66 ), false, false );

			AddImageTiled( 32, 88, 264, 1, 9107 );
			AddImageTiled( 42, 90, 264, 1, 9157 );

			int y = 100;

			for ( int i = 0; i < poller.Options.Length; ++i )
			{
				ShardPollOption option = poller.Options[i];
				string text = option.Title;

				if ( editing && totalVotes > 0 )
				{
					double perc = option.Votes / (double)totalVotes;

					text = String.Format( "[{1}: {2}%] {0}", text, option.Votes, (int)(perc*100) );
				}

				int optHeight = option.ComputeHeight();

				y += optHeight/2;

				if ( isViewingResults )
					AddImage( 24, y - 15, 0x25FE );
				else
					AddRadio( 24, y - 15, 0x25F9, 0x25FC, false, 1 + i );

				AddHtml( 60, y - (9 * option.LineBreaks), 250, 18 * option.LineBreaks, Color( text, LabelColor32 ), false, false );

				y += optHeight/2;
				y += 5;
			}

			if ( editing && !isViewingResults )
			{
				AddRadio( 24, y + 15 - 15, 0x25F9, 0x25FC, false, 1 + poller.Options.Length );
				AddHtml( 60, y + 15 - 9, 250, 18, Color( "Create new option.", 0x99CC66 ), false, false );
			}

			AddButton( 314, height - 73, 247, 248, 1, GumpButtonType.Reply, 0 );
			AddButton( 314, height - 47, 242, 241, 0, GumpButtonType.Reply, 0 );
		}
Beispiel #5
0
		public void QueuePoll( ShardPoller poller )
		{
			if ( m_Polls == null )
				m_Polls = new Queue( 4 );

			m_Polls.Enqueue( poller );
		}
Beispiel #6
0
        public void QueuePoll(ShardPoller poller)
        {
            if (this.m_Polls == null)
                this.m_Polls = new Queue<ShardPoller>(4);

            this.m_Polls.Enqueue(poller);
        }
Beispiel #7
0
 public ShardPollPrompt(ShardPoller poller, ShardPollOption opt)
 {
     m_Poller = poller;
     m_Option = opt;
 }
Beispiel #8
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Polls != null && m_Polls.Count > 0)
            {
                ShardPoller poller = m_Polls.Dequeue();

                if (poller != null)
                {
                    Timer.DelayCall <object[]>(TimeSpan.FromSeconds(1.0), new TimerStateCallback <object[]>(poller.SendQueuedPoll_Callback), new object[] { m_From, m_Polls });
                }
            }

            if (info.ButtonID == 1)
            {
                int[] switches = info.Switches;

                if (switches.Length == 0)
                {
                    return;
                }

                int             switched = switches[0] - 1;
                ShardPollOption opt      = null;

                if (switched >= 0 && switched < m_Poller.Options.Length)
                {
                    opt = m_Poller.Options[switched];
                }

                if (opt == null && !m_Editing)
                {
                    return;
                }

                if (m_Editing)
                {
                    if (!m_Poller.Active)
                    {
                        m_From.SendMessage("Enter a title for the option. Escape to cancel.{0}", opt == null ? "" : " Use \"DEL\" to delete.");
                        m_From.Prompt = new ShardPollPrompt(m_Poller, opt);
                    }
                    else
                    {
                        m_From.SendMessage("You may not edit an active poll. Deactivate it first.");
                        m_From.SendGump(new ShardPollGump(m_From, m_Poller, m_Editing, m_Polls));
                    }
                }
                else
                {
                    if (!m_Poller.Active)
                    {
                        m_From.SendMessage("The poll has been deactivated.");
                    }
                    else if (m_Poller.HasAlreadyVoted(sender))
                    {
                        m_From.SendMessage("You have already voted on this poll.");
                    }
                    else
                    {
                        m_Poller.AddVote(sender, opt);
                    }
                }
            }
            else if (info.ButtonID == 2 && m_Editing)
            {
                m_From.SendGump(new ShardPollGump(m_From, m_Poller, m_Editing, m_Polls));
                m_From.SendGump(new PropertiesGump(m_From, m_Poller));
            }
        }
Beispiel #9
0
        public ShardPollGump(Mobile from, ShardPoller poller, bool editing, Queue <ShardPoller> polls) : base(50, 50)
        {
            m_From    = from;
            m_Poller  = poller;
            m_Editing = editing;
            m_Polls   = polls;

            Closable = false;

            AddPage(0);

            int totalVotes        = 0;
            int totalOptionHeight = 0;

            for (int i = 0; i < poller.Options.Length; ++i)
            {
                totalVotes        += poller.Options[i].Votes;
                totalOptionHeight += poller.Options[i].ComputeHeight() + 5;
            }

            bool isViewingResults = editing && poller.Active;
            bool isCompleted      = totalVotes > 0 && !poller.Active;

            if (editing && !isViewingResults)
            {
                totalOptionHeight += 35;
            }

            int height = 115 + totalOptionHeight;

            AddBackground(1, 1, 398, height - 2, 3600);
            AddAlphaRegion(16, 15, 369, height - 31);

            AddItem(308, 30, 0x1E5E);

            string title;

            if (editing)
            {
                title = (isCompleted ? "Poll Completed" : "Poll Editor");
            }
            else
            {
                title = "Shard Poll";
            }

            AddHtml(22, 22, 294, 20, Color(Center(title), LabelColor32), false, false);

            if (editing)
            {
                AddHtml(22, 22, 294, 20, Color(String.Format("{0} total", totalVotes), LabelColor32), false, false);
                AddButton(287, 23, 0x2622, 0x2623, 2, GumpButtonType.Reply, 0);
            }

            AddHtml(22, 50, 294, 40, Color(poller.Title, 0x99CC66), false, false);

            AddImageTiled(32, 88, 264, 1, 9107);
            AddImageTiled(42, 90, 264, 1, 9157);

            int y = 100;

            for (int i = 0; i < poller.Options.Length; ++i)
            {
                ShardPollOption option = poller.Options[i];
                string          text   = option.Title;

                if (editing && totalVotes > 0)
                {
                    double perc = option.Votes / (double)totalVotes;

                    text = String.Format("[{1}: {2}%] {0}", text, option.Votes, (int)(perc * 100));
                }

                int optHeight = option.ComputeHeight();

                y += optHeight / 2;

                if (isViewingResults)
                {
                    AddImage(24, y - 15, 0x25FE);
                }
                else
                {
                    AddRadio(24, y - 15, 0x25F9, 0x25FC, false, 1 + i);
                }

                AddHtml(60, y - (9 * option.LineBreaks), 250, 18 * option.LineBreaks, Color(text, LabelColor32), false, false);

                y += optHeight / 2;
                y += 5;
            }

            if (editing && !isViewingResults)
            {
                AddRadio(24, y + 15 - 15, 0x25F9, 0x25FC, false, 1 + poller.Options.Length);
                AddHtml(60, y + 15 - 9, 250, 18, Color("Create new option.", 0x99CC66), false, false);
            }

            AddButton(314, height - 73, 247, 248, 1, GumpButtonType.Reply, 0);
            AddButton(314, height - 47, 242, 241, 0, GumpButtonType.Reply, 0);
        }