support console
This commit is contained in:
parent
fd4137176c
commit
0a0061ca8c
|
@ -1,6 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="FinalSolution.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="FinalSolution.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
<userSettings>
|
||||
<FinalSolution.Properties.Settings>
|
||||
<setting name="AllocConsole" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
</FinalSolution.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
|
@ -46,14 +46,14 @@ namespace FinalSolution
|
|||
}
|
||||
};
|
||||
|
||||
File.WriteAllText(path, JsonConvert.SerializeObject(_instance));
|
||||
SaveConfig();
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public static void SaveConfig(string path = "config.json")
|
||||
private static void SaveConfig(string path = "config.json")
|
||||
{
|
||||
File.WriteAllText(path, JsonConvert.SerializeObject(_instance));
|
||||
File.WriteAllText(path, JsonConvert.SerializeObject(_instance, Formatting.Indented));
|
||||
}
|
||||
|
||||
private static string FindGameRunning()
|
||||
|
@ -87,5 +87,6 @@ namespace FinalSolution
|
|||
{
|
||||
public string Destiny2Path;
|
||||
public Dictionary<string, string> Hotkeys;
|
||||
public bool ShouldAllocConsole = false;
|
||||
}
|
||||
}
|
|
@ -107,7 +107,6 @@
|
|||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<None Include="sign_key.snk" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config"/>
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Gma.System.MouseKeyHook;
|
||||
|
@ -79,12 +78,26 @@ namespace FinalSolution
|
|||
|
||||
private void MainForm_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (positionWorker.IsBusy)
|
||||
{
|
||||
positionWorker.CancelAsync();
|
||||
}
|
||||
|
||||
if (timerWorker.IsBusy)
|
||||
{
|
||||
timerWorker.CancelAsync();
|
||||
}
|
||||
|
||||
_globalHook.Dispose();
|
||||
}
|
||||
|
||||
private void Reposition()
|
||||
{
|
||||
NativeUtils.GetWindowRect(NativeUtils.handle, out var rect);
|
||||
|
||||
// dont reposition if the game was not even started
|
||||
if (rect.left == 0 && rect.right == 0 && rect.top == 0 && rect.bottom == 0) return;
|
||||
|
||||
Size = new Size(rect.right - rect.left, rect.bottom - rect.top);
|
||||
|
||||
Left = rect.left;
|
||||
|
|
|
@ -54,5 +54,9 @@ namespace FinalSolution
|
|||
? fileNameBuilder.ToString()
|
||||
: null;
|
||||
}
|
||||
|
||||
[DllImport("kernel32", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool AllocConsole();
|
||||
}
|
||||
}
|
|
@ -16,6 +16,12 @@ namespace FinalSolution
|
|||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
if (Config.Instance.ShouldAllocConsole || Settings.Default.AllocConsole) // should open a console box
|
||||
{
|
||||
NativeUtils.AllocConsole();
|
||||
Console.WriteLine(@"Hello from the Children of Planet Earth!");
|
||||
}
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.ThreadException += (sender, args) =>
|
||||
|
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.2.0")]
|
||||
[assembly: AssemblyFileVersion("1.2.0")]
|
|
@ -1,26 +1,37 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace FinalSolution.Properties
|
||||
{
|
||||
namespace FinalSolution.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute(
|
||||
"Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
private static Settings defaultInstance =
|
||||
((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get { return defaultInstance; }
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool AllocConsole {
|
||||
get {
|
||||
return ((bool)(this["AllocConsole"]));
|
||||
}
|
||||
set {
|
||||
this["AllocConsole"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
<Settings>
|
||||
<Setting Name="AllocConsole" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue