summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Program.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-10-26 23:43:32 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-10-26 23:43:32 -0400
commit4e17de2f2c33a6ddda4952265f7866d407965653 (patch)
treeaacc7cc50ae783adf8beb105945bab4eba7f35ef /src/StardewModdingAPI/Program.cs
parent9436920d91fddd36d5c208299c3fa24b29a909be (diff)
downloadSMAPI-4e17de2f2c33a6ddda4952265f7866d407965653.tar.gz
SMAPI-4e17de2f2c33a6ddda4952265f7866d407965653.tar.bz2
SMAPI-4e17de2f2c33a6ddda4952265f7866d407965653.zip
use simpler crossplatform window management (#126)
Diffstat (limited to 'src/StardewModdingAPI/Program.cs')
-rw-r--r--src/StardewModdingAPI/Program.cs35
1 files changed, 4 insertions, 31 deletions
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;
}
/// <summary>
@@ -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)