public static void Process() { if (_client == null || !_client.Connected) { if (Connected) { while (_receiveList != null && !_receiveList.IsEmpty) { Packet p; if (!_receiveList.TryDequeue(out p) || p == null) { continue; } if (!(p is ServerPackets.Disconnect) && !(p is ServerPackets.ClientVersion)) { continue; } MirScene.ActiveScene.ProcessPacket(p); _receiveList = null; return; } MirMessageBox.Show("Lost connection with the server.", true); Disconnect(); return; } return; } if (!Connected && TimeConnected > 0 && CMain.Time > TimeConnected + 5000) { Disconnect(); Connect(); return; } while (_receiveList != null && !_receiveList.IsEmpty) { Packet p; if (!_receiveList.TryDequeue(out p) || p == null) { continue; } MirScene.ActiveScene.ProcessPacket(p); } if (CMain.Time > TimeOutTime && _sendList != null && _sendList.IsEmpty) { _sendList.Enqueue(new C.KeepAlive()); } if (_sendList == null || _sendList.IsEmpty) { return; } TimeOutTime = CMain.Time + Settings.TimeOut; List <byte> data = new List <byte>(); while (!_sendList.IsEmpty) { Packet p; if (!_sendList.TryDequeue(out p)) { continue; } data.AddRange(p.GetPacketBytes()); } CMain.BytesSent += data.Count; BeginSend(data); }
public KeyboardLayoutDialog() { Index = 119; Library = Libraries.Title; Movable = true; Sort = true; Location = Center; TitleLabel = new MirImageControl { //Index = 7, Library = Libraries.Title, Location = new Point(18, 4), Parent = this }; PageLabel = new MirLabel { Text = "Keyboard Settings", Font = new Font(Settings.FontName, Settings.FontSize + 2, FontStyle.Bold), DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter, Parent = this, Size = new System.Drawing.Size(242, 30), Location = new Point(135, 34) }; CloseButton = new MirButton { HoverIndex = 361, Index = 360, Location = new Point(489, 3), Library = Libraries.Prguse2, Parent = this, PressedIndex = 362, Sound = SoundList.ButtonA, }; CloseButton.Click += (o, e) => Hide(); ScrollUpButton = new MirButton { Index = 197, HoverIndex = 198, PressedIndex = 199, Library = Libraries.Prguse2, Parent = this, Size = new Size(16, 14), Location = new Point(491, 88), Sound = SoundList.ButtonA, Visible = true }; ScrollUpButton.Click += (o, e) => { if (TopLine <= 0) { return; } TopLine--; UpdateText(); UpdatePositionBar(); }; ScrollDownButton = new MirButton { Index = 207, HoverIndex = 208, Library = Libraries.Prguse2, PressedIndex = 209, Parent = this, Size = new Size(16, 14), Location = new Point(491, 363), Sound = SoundList.ButtonA, Visible = true }; ScrollDownButton.Click += (o, e) => { if (TopLine + LineCount >= CMain.InputKeys.Keylist.Count + CMain.InputKeys.Keylist.GroupBy(x => x.Group).Select(y => y.First()).Count()) { return; } TopLine++; UpdateText(); UpdatePositionBar(); }; PositionBar = new MirButton { Index = 205, HoverIndex = 206, PressedIndex = 206, Library = Libraries.Prguse2, Location = new Point(491, 101), Parent = this, Movable = true, Sound = SoundList.None, Visible = true }; PositionBar.OnMoving += PositionBar_OnMoving; ResetButton = new MirButton { Index = 120, HoverIndex = 121, PressedIndex = 122, Library = Libraries.Title, Size = new Size(72, 25), Location = new Point(30, 400), Parent = this, Visible = true, }; ResetButton.Click += (o, e) => { for (int i = 0; i < CMain.InputKeys.Keylist.Count; i++) { KeyBind bind = CMain.InputKeys.Keylist[i]; KeyBind defaultBind = CMain.InputKeys.DefaultKeylist[i]; if (bind.Key != defaultBind.Key || bind.RequireAlt != defaultBind.RequireAlt || bind.RequireCtrl != defaultBind.RequireCtrl || bind.RequireShift != defaultBind.RequireShift || bind.RequireTilde != defaultBind.RequireTilde) { CMain.InputKeys.Keylist[i].Key = defaultBind.Key; CMain.InputKeys.Keylist[i].RequireAlt = defaultBind.RequireAlt; CMain.InputKeys.Keylist[i].RequireCtrl = defaultBind.RequireCtrl; CMain.InputKeys.Keylist[i].RequireShift = defaultBind.RequireShift; CMain.InputKeys.Keylist[i].RequireTilde = defaultBind.RequireTilde; //CMain.Profile.InputKeys.Save(CMain.Profile.InputKeys.Keylist[i]); } } UpdateText(); MirMessageBox messageBox = new MirMessageBox("Keyboard settings have been reset back to default.", MirMessageBoxButtons.OK); messageBox.Show(); }; EnforceButton = new MirButton { Visible = true, Index = 1346, Library = Libraries.Prguse, Sound = SoundList.ButtonA, Parent = this, Location = new Point(105, 406) }; EnforceButton.Click += EnforceButton_Click; EnforceButtonChecked = new MirImageControl() { Visible = Enforce, Index = 1347, Library = Libraries.Prguse, Parent = this, NotControl = true, Location = new Point(105, 406) }; EnforceButtonLabel = new MirLabel { Visible = true, NotControl = true, Parent = this, Location = new Point(120, 404), AutoSize = true, Text = "Assign Rule: Strict" }; UpdateText(); }
public MentorDialog() { Index = 170; Library = Libraries.Prguse; Movable = true; Sort = true; Location = Center; TitleLabel = new MirImageControl { Index = 51, Library = Libraries.Title, Location = new Point(18, 8), Parent = this }; CloseButton = new MirButton { HoverIndex = 361, Index = 360, Location = new Point(219, 3), Library = Libraries.Prguse2, Parent = this, PressedIndex = 362, Sound = SoundList.ButtonA, }; CloseButton.Click += (o, e) => Hide(); AllowButton = new MirButton { HoverIndex = 115, Index = 114, Location = new Point(30, 178), Library = Libraries.Prguse, Parent = this, PressedIndex = 116, Sound = SoundList.ButtonA, Hint = GameLanguage.MentorRequests }; AllowButton.Click += (o, e) => { if (AllowButton.Index == 116) { AllowButton.Index = 117; AllowButton.HoverIndex = 118; AllowButton.PressedIndex = 119; } else { AllowButton.Index = 114; AllowButton.HoverIndex = 115; AllowButton.PressedIndex = 116; } Network.Enqueue(new C.AllowMentor()); }; AddButton = new MirButton { HoverIndex = 214, Index = 213, Location = new Point(60, 178), Library = Libraries.Title, Parent = this, PressedIndex = 215, Sound = SoundList.ButtonA, Hint = GameLanguage.AddMentor }; AddButton.Click += (o, e) => { if (MentorLevel != 0) { GameScene.Scene.ChatDialog.ReceiveChat("你已经有一个师傅了.", ChatType.System); return; } string message = GameLanguage.MentorEnterName; MirInputBox inputBox = new MirInputBox(message); inputBox.OKButton.Click += (o1, e1) => { Network.Enqueue(new C.AddMentor { Name = inputBox.InputTextBox.Text }); inputBox.Dispose(); }; inputBox.Show(); }; RemoveButton = new MirButton { HoverIndex = 217, Index = 216, Location = new Point(135, 178), Library = Libraries.Title, Parent = this, PressedIndex = 218, Sound = SoundList.ButtonA, Hint = GameLanguage.RemoveMentorMentee }; RemoveButton.Click += (o, e) => { if (MentorName == "") { GameScene.Scene.ChatDialog.ReceiveChat(GameLanguage.NoMentorship, ChatType.System); return; } MirMessageBox messageBox = new MirMessageBox(string.Format("移除师徒关系将会有冷却,你确定?"), MirMessageBoxButtons.YesNo); messageBox.YesButton.Click += (oo, ee) => Network.Enqueue(new C.CancelMentor { }); messageBox.NoButton.Click += (oo, ee) => { messageBox.Dispose(); }; messageBox.Show(); }; MentorNameLabel = new MirLabel { Location = new Point(20, 58), Size = new Size(200, 30), BackColour = Color.Empty, ForeColour = Color.LightGray, DrawFormat = TextFormatFlags.VerticalCenter, Parent = this, NotControl = true, Font = new Font(Settings.FontName, 10F), }; MentorLevelLabel = new MirLabel { Location = new Point(170, 58), Size = new Size(200, 30), BackColour = Color.Empty, ForeColour = Color.LightGray, DrawFormat = TextFormatFlags.VerticalCenter, Parent = this, NotControl = true, Font = new Font(Settings.FontName, 10F), }; MentorOnlineLabel = new MirLabel { Location = new Point(125, 58), Size = new Size(200, 30), BackColour = Color.Empty, ForeColour = Color.Green, DrawFormat = TextFormatFlags.VerticalCenter, Parent = this, NotControl = true, Font = new Font(Settings.FontName, 7F), Visible = false, Text = "在线", }; StudentNameLabel = new MirLabel { Location = new Point(20, 112), Size = new Size(200, 30), BackColour = Color.Empty, ForeColour = Color.LightGray, DrawFormat = TextFormatFlags.VerticalCenter, Parent = this, NotControl = true, Font = new Font(Settings.FontName, 10F), }; StudentLevelLabel = new MirLabel { Location = new Point(170, 111), Size = new Size(200, 30), BackColour = Color.Empty, ForeColour = Color.LightGray, DrawFormat = TextFormatFlags.VerticalCenter, Parent = this, NotControl = true, Font = new Font(Settings.FontName, 10F), }; StudentOnlineLabel = new MirLabel { Location = new Point(125, 112), Size = new Size(200, 30), BackColour = Color.Empty, ForeColour = Color.Green, DrawFormat = TextFormatFlags.VerticalCenter, Parent = this, NotControl = true, Font = new Font(Settings.FontName, 7F), Visible = false, Text = "在线", }; MentorLabel = new MirLabel { Location = new Point(15, 41), Size = new Size(200, 30), BackColour = Color.Empty, ForeColour = Color.DimGray, DrawFormat = TextFormatFlags.VerticalCenter, Parent = this, NotControl = true, Font = new Font(Settings.FontName, 7F), Text = "师傅", }; StudentLabel = new MirLabel { Location = new Point(15, 94), Size = new Size(200, 30), BackColour = Color.Empty, ForeColour = Color.DimGray, DrawFormat = TextFormatFlags.VerticalCenter, Parent = this, NotControl = true, Font = new Font(Settings.FontName, 7F), Text = "徒弟", }; MenteeEXPLabel = new MirLabel { Location = new Point(15, 147), Size = new Size(200, 30), BackColour = Color.Empty, ForeColour = Color.DimGray, DrawFormat = TextFormatFlags.VerticalCenter, Parent = this, NotControl = true, Font = new Font(Settings.FontName, 7F), }; }
static void Scene_MouseDown(object sender, EventArgs e) { MouseEventArgs ME = e as MouseEventArgs; if (ME == null) { return; } if (ME.Button == MouseButtons.Left) { if (MirItemCell.SelectedCell != null) { if (MirItemCell.SelectedCell.GridType == MirGridType.Equipment || MirItemCell.SelectedCell.GridType == MirGridType.Trade) { MirItemCell.SelectedCell = null; return; } MirMessageBox MMBox = new MirMessageBox( string.Format("Are you sure you want to drop {0}?", MirItemCell.SelectedCell.Item.Info.ItemName), MessageBoxButtons.YesNo); MirItemCell Cell = MirItemCell.SelectedCell; MMBox.YesButton.Click += (O, A) => { OutBound.DropItem(Cell.GridType, Cell.Item.UniqueID); Cell.Item = null; MapObject.User.CalculateWeight(); }; MMBox.Show(); MirItemCell.SelectedCell = null; return; } else if (MirItemCell.PickedUpGold) { MirInputBox MIBox = new MirInputBox("How much do you want to drop?"); MIBox.OKButton.Click += (O, A) => { int Amount; if (int.TryParse(MIBox.InputTextBox.Text, out Amount) && Amount > 0 && Amount <= MapObject.User.Gold) { OutBound.DropGold(Amount); MapObject.User.Gold -= Amount; } MIBox.Dispose(); }; MIBox.Show(); MirItemCell.PickedUpGold = false; return; } } MouseB |= ME.Button; if (ME.Button == MouseButtons.Left) { if (MapObject.MouseObject != MapObject.User && MapObject.MouseObject != null && !MapObject.MouseObject.Dead) { MapObject.TargetObject = MapObject.MouseObject; } else { MapObject.TargetObject = null; } } }
public MailListDialog() { Index = 670; Library = Libraries.Title; Size = new Size(312, 444); Movable = true; Sort = true; Location = new Point((Settings.ScreenWidth - Size.Width) - 150, 5); CloseButton = new MirButton { HoverIndex = 361, Index = 360, Location = new Point(Size.Width - 27, 3), Library = Libraries.Prguse2, Parent = this, PressedIndex = 362, Sound = SoundList.ButtonA, }; CloseButton.Click += (o, e) => Hide(); HelpButton = new MirButton { Index = 257, HoverIndex = 258, PressedIndex = 259, Library = Libraries.Prguse2, Parent = this, Location = new Point(Size.Width - 50, 3), Sound = SoundList.ButtonA, }; HelpButton.Click += (o, e) => GameScene.Scene.HelpDialog.DisplayPage(""); PreviousButton = new MirButton { Index = 240, HoverIndex = 241, PressedIndex = 242, Library = Libraries.Prguse2, Parent = this, Location = new Point(102, Size.Height - 55), Sound = SoundList.ButtonA, }; PreviousButton.Click += (o, e) => { if (CurrentPage <= 1) { return; } SelectedMail = null; CurrentPage--; StartIndex -= 10; UpdateInterface(); }; PageLabel = new MirLabel { Text = "", Parent = this, Location = new Point(120, Size.Height - 55), Size = new Size(67, 15), DrawFormat = TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter, }; NextButton = new MirButton { Index = 243, HoverIndex = 244, PressedIndex = 245, Library = Libraries.Prguse2, Parent = this, Location = new Point(192, Size.Height - 55), Sound = SoundList.ButtonA, }; NextButton.Click += (o, e) => { if (CurrentPage >= PageCount) { return; } SelectedMail = null; CurrentPage++; StartIndex += 10; UpdateInterface(); }; #region Action Buttons SendButton = new MirButton { Index = 563, HoverIndex = 564, PressedIndex = 565, Library = Libraries.Prguse, Parent = this, Location = new Point(75, 414), Sound = SoundList.ButtonA, Hint = "Send" }; SendButton.Click += (o, e) => { MirInputBox inputBox = new MirInputBox("Please enter the name of the person you would like to mail."); inputBox.OKButton.Click += (o1, e1) => { //open letter dialog, pass in name GameScene.Scene.MailComposeLetterDialog.ComposeMail(inputBox.InputTextBox.Text); inputBox.Dispose(); }; inputBox.Show(); }; ReplyButton = new MirButton { Index = 569, HoverIndex = 570, PressedIndex = 571, Library = Libraries.Prguse, Parent = this, Location = new Point(102, 414), Sound = SoundList.ButtonA, Hint = "Reply" }; ReplyButton.Click += (o, e) => { if (SelectedMail == null) { return; } GameScene.Scene.MailComposeLetterDialog.ComposeMail(SelectedMail.SenderName); }; ReadButton = new MirButton { Index = 572, HoverIndex = 573, PressedIndex = 574, Library = Libraries.Prguse, Parent = this, Location = new Point(129, 414), Sound = SoundList.ButtonA, Hint = "Read" }; ReadButton.Click += (o, e) => { if (SelectedMail == null) { return; } if (SelectedMail.Gold > 0 || SelectedMail.Items.Count > 0) { GameScene.Scene.MailReadParcelDialog.ReadMail(SelectedMail); } else { GameScene.Scene.MailReadLetterDialog.ReadMail(SelectedMail); } }; DeleteButton = new MirButton { Index = 557, HoverIndex = 558, PressedIndex = 559, Library = Libraries.Prguse, Parent = this, Location = new Point(156, 414), Sound = SoundList.ButtonA, Hint = "Delete" }; DeleteButton.Click += (o, e) => { if (SelectedMail == null || SelectedMail.Locked) { return; } if (SelectedMail.Items.Count > 0 || SelectedMail.Gold > 0) { MirMessageBox messageBox = new MirMessageBox("This parcel contains items or gold. Are you sure you want to delete it?", MirMessageBoxButtons.YesNo); messageBox.YesButton.Click += (o1, e1) => { Network.Enqueue(new C.DeleteMail { MailID = SelectedMail.MailID }); SelectedMail = null; }; messageBox.Show(); } else { Network.Enqueue(new C.DeleteMail { MailID = SelectedMail.MailID }); SelectedMail = null; } }; BlockListButton = new MirButton { Index = 520, HoverIndex = 521, PressedIndex = 522, Library = Libraries.Prguse, Parent = this, Location = new Point(183, 414), Sound = SoundList.ButtonA, Hint = "Block List" }; BugReportButton = new MirButton { Index = 523, HoverIndex = 524, PressedIndex = 525, Library = Libraries.Prguse, Parent = this, Location = new Point(210, 414), Sound = SoundList.ButtonA, Hint = "Report Bug" }; #endregion }