Beispiel #1
0
        private void InterfaceTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                Text = string.Format("Total: {0}, Real: {1}", Envir.LastCount, Envir.LastRealCount);

                PlayersLabel.Text     = string.Format("Players: {0}", Envir.Players.Count);
                MonsterLabel.Text     = string.Format("Monsters: {0}", Envir.MonsterCount);
                ConnectionsLabel.Text = string.Format("Connections: {0}", Envir.Connections.Count);

                while (!MessageLog.IsEmpty)
                {
                    string message;

                    if (!MessageLog.TryDequeue(out message))
                    {
                        continue;
                    }

                    LogTextBox.AppendText(message);
                }

                while (!DebugLog.IsEmpty)
                {
                    string message;

                    if (!DebugLog.TryDequeue(out message))
                    {
                        continue;
                    }

                    DebugLogTextBox.AppendText(message);
                }

                while (!ChatLog.IsEmpty)
                {
                    string message;

                    if (!ChatLog.TryDequeue(out message))
                    {
                        continue;
                    }

                    ChatLogTextBox.AppendText(message);
                }

                ProcessPlayersOnlineTab();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #2
0
 private void LogWindow_Load(object sender, EventArgs e)
 {
     DebugLogsCheckBox.Checked = Properties.Settings.Default.MainWindowShowDebugLog;
     if (Properties.Settings.Default.MainWindowShowDebugLog)
     {
         DebugLogTextBox.Show();
         LogTextBox.Hide();
     }
     else
     {
         DebugLogTextBox.Hide();
         LogTextBox.Show();
     }
 }
Beispiel #3
0
 private void DebugLogsCheckBox_CheckedChanged(object sender, EventArgs e)
 {
     Properties.Settings.Default.MainWindowShowDebugLog = DebugLogsCheckBox.Checked;
     if (DebugLogsCheckBox.Checked)
     {
         DebugLogTextBox.Show();
         LogTextBox.Hide();
     }
     else
     {
         DebugLogTextBox.Hide();
         LogTextBox.Show();
     }
 }
Beispiel #4
0
 /// <summary>
 /// Clear log window contents
 /// </summary>
 public void Clear()
 {
     if (LogTextBox != null)
     {
         Utilities.CallActionSafelyAndWait(LogTextBox, new Action(() =>
         {
             LogTextBox.Clear();
             LogTextBox.ScrollToCaret();
         }));
     }
     if (DebugLogTextBox != null)
     {
         Utilities.CallActionSafelyAndWait(DebugLogTextBox, new Action(() =>
         {
             DebugLogTextBox.Clear();
             DebugLogTextBox.ScrollToCaret();
         }));
     }
 }
Beispiel #5
0
        private void InterfaceTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                Text = string.Format("Total: {0}, Real: {1}", Envir.LastCount, Envir.LastRealCount);
                PlayersLabel.Text     = string.Format("Players: {0}", Envir.Players.Count);
                MonsterLabel.Text     = string.Format("Monsters: {0}", Envir.MonsterCount);
                ConnectionsLabel.Text = string.Format("Connections: {0}", Envir.Connections.Count);

                if (Settings.Multithreaded && (Envir.MobThreads != null))
                {
                    CycleDelayLabel.Text = string.Format("CycleDelays: {0:0000}", Envir.LastRunTime);
                    for (int i = 0; i < Envir.MobThreads.Length; i++)
                    {
                        if (Envir.MobThreads[i] == null)
                        {
                            break;
                        }
                        CycleDelayLabel.Text = CycleDelayLabel.Text + string.Format("|{0:0000}", Envir.MobThreads[i].LastRunTime);
                    }
                }
                else
                {
                    CycleDelayLabel.Text = string.Format("CycleDelay: {0}", Envir.LastRunTime);
                }

                while (!MessageLog.IsEmpty)
                {
                    string message;

                    if (!MessageLog.TryDequeue(out message))
                    {
                        continue;
                    }

                    LogTextBox.AppendText(message);
                }

                while (!DebugLog.IsEmpty)
                {
                    string message;

                    if (!DebugLog.TryDequeue(out message))
                    {
                        continue;
                    }

                    DebugLogTextBox.AppendText(message);
                }

                while (!ChatLog.IsEmpty)
                {
                    string message;

                    if (!ChatLog.TryDequeue(out message))
                    {
                        continue;
                    }

                    ChatLogTextBox.AppendText(message);
                }

                ProcessPlayersOnlineTab();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #6
0
        private void InterfaceTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                Text = $"服务器刷新总数: {Envir.LastCount},实际总数: {Envir.LastRealCount}";
                PlayersLabel.Text     = $"玩家: {Envir.Players.Count}";
                MonsterLabel.Text     = $"怪物: {Envir.MonsterCount}";
                ConnectionsLabel.Text = $"连接: {Envir.Connections.Count}";

                if (Settings.Multithreaded && (Envir.MobThreads != null))
                {
                    CycleDelayLabel.Text = $"循环延迟: {Envir.LastRunTime:0000}";
                    for (int i = 0; i < Envir.MobThreads.Length; i++)
                    {
                        if (Envir.MobThreads[i] == null)
                        {
                            break;
                        }
                        CycleDelayLabel.Text = CycleDelayLabel.Text + $"|{Envir.MobThreads[i].LastRunTime:0000}";
                    }
                }
                else
                {
                    CycleDelayLabel.Text = $"循环延迟: {Envir.LastRunTime}";
                }

                while (!MessageQueue.MessageLog.IsEmpty)
                {
                    string message;

                    if (!MessageQueue.MessageLog.TryDequeue(out message))
                    {
                        continue;
                    }

                    LogTextBox.AppendText(message);
                }

                while (!MessageQueue.DebugLog.IsEmpty)
                {
                    string message;

                    if (!MessageQueue.DebugLog.TryDequeue(out message))
                    {
                        continue;
                    }

                    DebugLogTextBox.AppendText(message);
                }

                while (!MessageQueue.ChatLog.IsEmpty)
                {
                    string message;

                    if (!MessageQueue.ChatLog.TryDequeue(out message))
                    {
                        continue;
                    }

                    ChatLogTextBox.AppendText(message);
                }

                ProcessPlayersOnlineTab();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #7
0
        private void WriteLineSafe(LogType type, string format, params object[] arg)
        {
            string text = String.Format(format, arg);
            string zoneText = "";
            string frontText, backText;

            if (text[0] == '[' && text[3] == ']' && text[4] == ' ')
            {
                zoneText = text.Substring(0, 5);
                text     = text.Substring(5);
            }
            int index = text.IndexOf(':');

            if (index >= 0)
            {
                frontText = text.Substring(0, index + 1);
                backText  = text.Substring(index + 1) + "\r\n";
            }
            else
            {
                frontText = string.Empty;
                backText  = text + "\r\n";
            }
            Color textColor = Color.Black;

            switch (type)
            {
            case LogType.Player:
                textColor = Color.Blue;
                break;

            case LogType.Opponent:
                textColor = Color.Red;
                break;

            case LogType.Debug:
            case LogType.DebugVerbose:
                textColor = Color.Gray;
                break;

            default:
                break;
            }

            if (DebugLogTextBox != null)
            {
                Utilities.CallActionSafelyAndWait(DebugLogTextBox, new Action(() =>
                {
                    if (!string.IsNullOrEmpty(frontText))
                    {
                        DebugLogTextBox.AppendText(zoneText + frontText, textColor, true);
                    }
                    DebugLogTextBox.AppendText(backText, textColor, false);
                    DebugLogTextBox.ScrollToCaret();
                }));
            }

            if (LogTextBox != null && type != LogType.Debug)
            {
                Utilities.CallActionSafelyAndWait(LogTextBox, new Action(() =>
                {
                    if (!string.IsNullOrEmpty(frontText))
                    {
                        LogTextBox.AppendText(frontText, textColor, true);
                    }
                    LogTextBox.AppendText(backText, textColor, false);
                    LogTextBox.ScrollToCaret();
                }));
            }
        }
Beispiel #8
0
        private void InterfaceTimer_Tick(object sender, EventArgs e)
        {
            try
            {
                Text = string.Format("Total: {0}, Real: {1}", Envir.LastCount, Envir.LastRealCount);
                PlayersLabel.Text     = string.Format("Players: {0}", Envir.Players.Count);
                MonsterLabel.Text     = string.Format("Monsters: {0}", Envir.MonsterCount);
                ConnectionsLabel.Text = string.Format("Connections: {0}", Envir.Connections.Count);
                runningTimeLabel.Text = $"Running Time: {Envir.Stopwatch.ElapsedMilliseconds / 1000 / 60 / 60 / 24}d:{Envir.Stopwatch.ElapsedMilliseconds / 1000 / 60 / 60}h:{Envir.Stopwatch.ElapsedMilliseconds / 1000 / 60}m:{Envir.Stopwatch.ElapsedMilliseconds / 1000 % 60}s";

                if (Envir.LastRunTime > 200)
                {
                    CycleDelayLabel.ForeColor = Color.Red;
                }
                else
                {
                    CycleDelayLabel.ForeColor = Color.Black;
                }
                if (Settings.Multithreaded && (Envir.MobThreads != null))
                {
                    CycleDelayLabel.Text = string.Format("CycleDelays: {0:0000}", Envir.LastRunTime);
                    for (int i = 0; i < Envir.MobThreads.Length; i++)
                    {
                        if (Envir.MobThreads[i] == null)
                        {
                            break;
                        }
                        if (Envir.MobThreads[i].LastRunTime > 200 &&
                            CycleDelayLabel.ForeColor != Color.Red)
                        {
                            CycleDelayLabel.ForeColor = Color.Red;
                        }
                        if (CycleDelayLabel.ForeColor != Color.Red)
                        {
                            CycleDelayLabel.ForeColor = Color.Black;
                        }
                        CycleDelayLabel.Text = CycleDelayLabel.Text + string.Format("|{0:0000}", Envir.MobThreads[i].LastRunTime);
                    }
                }
                else
                {
                    CycleDelayLabel.Text = string.Format("CycleDelay: {0}", Envir.LastRunTime);
                }

                while (!MessageLog.IsEmpty)
                {
                    if (!MessageLog.TryDequeue(out string message))
                    {
                        continue;
                    }

                    LogTextBox.AppendText(message);
                }

                while (!DebugLog.IsEmpty)
                {
                    if (!DebugLog.TryDequeue(out string message))
                    {
                        continue;
                    }

                    DebugLogTextBox.AppendText(message);
                }

                while (!ChatLog.IsEmpty)
                {
                    if (!ChatLog.TryDequeue(out string message))
                    {
                        continue;
                    }

                    ChatLogTextBox.AppendText(message);
                }
                ProcessPlayersOnlineTab();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }