コード例 #1
0
		public SpeechLogGump( Mobile player, List<SpeechLogEntry> log, int page )
			: base( 500, 30 )
		{
			m_Player = player;
			m_Log = log;
			m_Page = page;

			AddImageTiled( 0, 0, 300, 425, 0xA40 );
			AddAlphaRegion( 1, 1, 298, 423 );

			string playerName = player.Name;
			string playerAccount = player.Account is Account ? player.Account.Username : "******";

			AddHtml( 10, 10, 280, 20, String.Format( "<basefont color=#A0A0FF><center>SPEECH LOG - {0} (<i>{1}</i>)</center></basefont>", playerName, Utility.FixHtml( playerAccount ) ), false, false );

			int lastPage = ( log.Count - 1 ) / MaxEntriesPerPage;

			string sLog;

			if ( page < 0 || page > lastPage )
			{
				sLog = "";
			}
			else
			{
				int max = log.Count - ( lastPage - page ) * MaxEntriesPerPage;
				int min = Math.Max( max - MaxEntriesPerPage, 0 );

				StringBuilder builder = new StringBuilder();

				for ( int i = min; i < max; i++ )
				{
					SpeechLogEntry entry = log[i];

					Mobile m = entry.From;

					string name = m.Name;
					string account = m.Account is Account ? m.Account.Username : "******";
					string speech = entry.Speech;

					if ( i != min )
						builder.Append( "<br>" );

					builder.AppendFormat( "<u>{0}</u> (<i>{1}</i>): {2}", name, Utility.FixHtml( account ), Utility.FixHtml( speech ) );
				}

				sLog = builder.ToString();
			}

			AddHtml( 10, 40, 280, 350, sLog, false, true );

			if ( page > 0 )
				AddButton( 10, 395, 0xFAE, 0xFB0, 1, GumpButtonType.Reply, 0 ); // Previous page

			AddLabel( 45, 395, 0x481, String.Format( "Current page: {0}/{1}", page + 1, lastPage + 1 ) );

			if ( page < lastPage )
				AddButton( 261, 395, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0 ); // Next page
		}
コード例 #2
0
        public void Add( SpeechLogEntry entry )
        {
            if ( MaxLength > 0 && m_Queue.Count >= MaxLength )
                m_Queue.Dequeue();

            Clean();

            m_Queue.Enqueue( entry );
        }
コード例 #3
0
        public void Add(SpeechLogEntry entry)
        {
            if (MaxLength > 0 && m_Queue.Count >= MaxLength)
            {
                m_Queue.Dequeue();
            }

            Clean();

            m_Queue.Enqueue(entry);
        }
コード例 #4
0
        public void Clean()
        {
            while (m_Queue.Count > 0)
            {
                SpeechLogEntry entry = (SpeechLogEntry)m_Queue.Peek();

                if (DateTime.Now - entry.Created > EntryDuration)
                {
                    m_Queue.Dequeue();
                }
                else
                {
                    break;
                }
            }
        }
コード例 #5
0
ファイル: Logging.cs プロジェクト: jicomub/Temrael
        public static void WriteLine(Mobile from, SpeechLogEntry e)
        {
            try
            {
                string path = Directories.AppendPath(Directories.logs, "Speechlogs");

                Account acct = from.Account as Account;

                string name = (acct == null ? from.Name : acct.Username);

                path = Directories.AppendPath(path, from.AccessLevel.ToString());
                path = Directories.AppendPath(path, name);
                string today = Directories.FormatDay(e.Created);
                path = Path.Combine(path, String.Format("{0} {1}.log", from.Name, today));

                using (StreamWriter sw = new StreamWriter(path, true))
                    sw.WriteLine("[{0}] {1}: {2}", e.Created, SpeechlogLogging.Format(e.From), e.Speech);
            }
            catch
            {
            }
        }