use simpler crossplatform window management (#126)
This commit is contained in:
parent
9436920d91
commit
4e17de2f2c
|
@ -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)
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Weavers>
|
||||
|
||||
</Weavers>
|
|
@ -50,9 +50,6 @@ namespace TrainerMod
|
|||
{
|
||||
Command.RegisterCommand("types", "Lists all value types | types").CommandFired += types_CommandFired;
|
||||
|
||||
Command.RegisterCommand("hide", "Hides the game form | hide").CommandFired += hide_CommandFired;
|
||||
Command.RegisterCommand("show", "Shows the game form | show").CommandFired += show_CommandFired;
|
||||
|
||||
Command.RegisterCommand("save", "Saves the game? Doesn't seem to work. | save").CommandFired += save_CommandFired;
|
||||
Command.RegisterCommand("load", "Shows the load screen | load").CommandFired += load_CommandFired;
|
||||
|
||||
|
@ -94,16 +91,6 @@ namespace TrainerMod
|
|||
Log.AsyncY($"[Int32: {int.MinValue} - {int.MaxValue}], [Int64: {long.MinValue} - {long.MaxValue}], [String: \"raw text\"], [Colour: r,g,b (EG: 128, 32, 255)]");
|
||||
}
|
||||
|
||||
private static void hide_CommandFired(object sender, EventArgsCommand e)
|
||||
{
|
||||
Program.StardewInvoke(() => { Program.StardewForm.Hide(); });
|
||||
}
|
||||
|
||||
private static void show_CommandFired(object sender, EventArgsCommand e)
|
||||
{
|
||||
Program.StardewInvoke(() => { Program.StardewForm.Show(); });
|
||||
}
|
||||
|
||||
private static void save_CommandFired(object sender, EventArgsCommand e)
|
||||
{
|
||||
SaveGame.Save();
|
||||
|
|
|
@ -95,9 +95,7 @@
|
|||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
|
@ -119,9 +117,6 @@
|
|||
</None>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="FodyWeavers.xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
|
|
Loading…
Reference in New Issue