From 4e17de2f2c33a6ddda4952265f7866d407965653 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 26 Oct 2016 23:43:32 -0400 Subject: use simpler crossplatform window management (#126) --- src/StardewModdingAPI/Program.cs | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) (limited to 'src/StardewModdingAPI/Program.cs') diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index f37f573d..f6c63851 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Globalization; using System.IO; using System.Linq; @@ -11,9 +10,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using StardewModdingAPI.Events; using StardewModdingAPI.Inheritance; -using StardewModdingAPI.Inheritance.Menus; using StardewValley; -using StardewValley.Menus; namespace StardewModdingAPI { @@ -32,7 +29,6 @@ namespace StardewModdingAPI public static Assembly StardewAssembly; public static Type StardewProgramType; public static FieldInfo StardewGameInfo; - public static Form StardewForm; public static Thread gameThread; public static Thread consoleInputThread; @@ -154,12 +150,9 @@ namespace StardewModdingAPI GameEvents.LoadContent += Events_LoadContent; Log.AsyncY("Applying Final SDV Tweaks..."); - StardewInvoke(() => - { - gamePtr.IsMouseVisible = false; - gamePtr.Window.Title = "Stardew Valley - Version " + Game1.version; - StardewForm.Resize += GraphicsEvents.InvokeResize; - }); + gamePtr.IsMouseVisible = false; + gamePtr.Window.Title = "Stardew Valley - Version " + Game1.version; + gamePtr.Window.ClientSizeChanged += GraphicsEvents.InvokeResize; } /// @@ -226,10 +219,8 @@ namespace StardewModdingAPI Game1.graphics.GraphicsProfile = GraphicsProfile.HiDef; LoadMods(); - StardewForm = Control.FromHandle(gamePtr.Window.Handle).FindForm(); - if (StardewForm != null) StardewForm.Closing += StardewForm_Closing; - ready = true; + gamePtr.Exiting += (sender, e) => ready = false; StardewGameInfo.SetValue(StardewProgramType, gamePtr); gamePtr.Run(); @@ -240,19 +231,6 @@ namespace StardewModdingAPI } } - private static void StardewForm_Closing(object sender, CancelEventArgs e) - { - e.Cancel = true; - - if (true || MessageBox.Show("Are you sure you would like to quit Stardew Valley?\nUnsaved progress will be lost!", "Confirm Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) - { - gamePtr.Exit(); - gamePtr.Dispose(); - StardewForm.Hide(); - ready = false; - } - } - public static void LoadMods() { Log.AsyncY("LOADING MODS"); @@ -374,11 +352,6 @@ namespace StardewModdingAPI { } - public static void StardewInvoke(Action a) - { - StardewForm.Invoke(a); - } - private static void help_CommandFired(object o, EventArgsCommand e) { if (e.Command.CalledArgs.Length > 0) -- cgit