protected override void OnExiting(object sender, EventArgs args)
        {
            if (Globals.Me != null && Globals.Me.CombatTimer > Globals.System?.GetTimeMs())
            {
                //Try to prevent SDL Window Close
                var exception = false;
                try
                {
                    var platform = GetType().GetField("Platform", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this);
                    var field    = platform.GetType().GetField("_isExiting", BindingFlags.NonPublic | BindingFlags.Instance);
                    field.SetValue(platform, 0);
                }
                catch
                {
                    //TODO: Should we log here? I really don't know if it's necessary.
                    exception = true;
                }

                if (!exception)
                {
                    //Show Message Getting Exit Confirmation From Player to Leave in Combat
                    var box = new InputBox(
                        Strings.Combat.warningtitle, Strings.Combat.warningcharacterselect, true, InputBox.InputType.YesNo,
                        ExitToDesktop, null, null
                        );

                    //Restart the MonoGame RunLoop
                    Run();
                    return;
                }
            }

            try
            {
                mUpdater?.Stop();
            }
            catch { }
            //Just close if we don't need to show a combat warning
            base.OnExiting(sender, args);
            Networking.Network.Close("quitting");
            base.Dispose();
        }
示例#2
0
 protected override void OnClosed(EventArgs e)
 {
     mUpdater.Stop();
     base.OnClosed(e);
     Application.Exit();
 }