mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-12-24 23:51:49 +01:00
Attempt to allow language preference to work across instances
Related to issue #205.
This commit is contained in:
parent
15de9307c3
commit
4fe6fc6660
@ -10,6 +10,7 @@ using System.Drawing;
|
|||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Globalization;
|
||||||
|
|
||||||
namespace DS4Windows
|
namespace DS4Windows
|
||||||
{
|
{
|
||||||
@ -226,8 +227,13 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
protected static BackingStore m_Config = new BackingStore();
|
protected static BackingStore m_Config = new BackingStore();
|
||||||
protected static Int32 m_IdleTimeout = 600000;
|
protected static Int32 m_IdleTimeout = 600000;
|
||||||
static string exepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
|
public static string exepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
|
||||||
public static string appdatapath;
|
public static string appdatapath;
|
||||||
|
public static bool firstRun = false;
|
||||||
|
public static bool multisavespots = false;
|
||||||
|
public static bool oldappdatafail = false;
|
||||||
|
public static string appDataPpath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Windows";
|
||||||
|
public static string oldappdatapath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool";
|
||||||
public static bool runHotPlug = false;
|
public static bool runHotPlug = false;
|
||||||
public const int XINPUT_UNPLUG_SETTLE_TIME = 250; // Inhibit races that occur with the asynchronous teardown of ScpVBus -> X360 driver instance.
|
public const int XINPUT_UNPLUG_SETTLE_TIME = 250; // Inhibit races that occur with the asynchronous teardown of ScpVBus -> X360 driver instance.
|
||||||
public static string[] tempprofilename = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty };
|
public static string[] tempprofilename = new string[5] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty };
|
||||||
@ -324,6 +330,52 @@ namespace DS4Windows
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void FindConfigLocation()
|
||||||
|
{
|
||||||
|
if (File.Exists(exepath + "\\Auto Profiles.xml")
|
||||||
|
&& File.Exists(appDataPpath + "\\Auto Profiles.xml"))
|
||||||
|
{
|
||||||
|
Global.firstRun = true;
|
||||||
|
Global.multisavespots = true;
|
||||||
|
}
|
||||||
|
else if (File.Exists(exepath + "\\Auto Profiles.xml"))
|
||||||
|
SaveWhere(exepath);
|
||||||
|
else if (File.Exists(appDataPpath + "\\Auto Profiles.xml"))
|
||||||
|
SaveWhere(appDataPpath);
|
||||||
|
else if (File.Exists(oldappdatapath + "\\Auto Profiles.xml"))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Directory.Exists(appDataPpath))
|
||||||
|
Directory.Move(appDataPpath, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Windows Old");
|
||||||
|
Directory.Move(oldappdatapath, appDataPpath);
|
||||||
|
SaveWhere(appDataPpath);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Global.oldappdatafail = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!File.Exists(exepath + "\\Auto Profiles.xml")
|
||||||
|
&& !File.Exists(appDataPpath + "\\Auto Profiles.xml"))
|
||||||
|
{
|
||||||
|
Global.firstRun = true;
|
||||||
|
Global.multisavespots = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetCulture(string culture)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture);
|
||||||
|
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo(culture);
|
||||||
|
}
|
||||||
|
catch { /* Skip setting culture that we cannot set */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static event EventHandler<EventArgs> ControllerStatusChange; // called when a controller is added/removed/battery or touchpad mode changes/etc.
|
public static event EventHandler<EventArgs> ControllerStatusChange; // called when a controller is added/removed/battery or touchpad mode changes/etc.
|
||||||
public static void ControllerStatusChanged(object sender)
|
public static void ControllerStatusChanged(object sender)
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,6 @@ using Microsoft.Win32;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Globalization;
|
|
||||||
using Microsoft.Win32.TaskScheduler;
|
using Microsoft.Win32.TaskScheduler;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -38,9 +37,6 @@ namespace DS4Windows
|
|||||||
WebClient wc = new WebClient();
|
WebClient wc = new WebClient();
|
||||||
NonFormTimer hotkeysTimer = new NonFormTimer();
|
NonFormTimer hotkeysTimer = new NonFormTimer();
|
||||||
NonFormTimer autoProfilesTimer = new NonFormTimer();
|
NonFormTimer autoProfilesTimer = new NonFormTimer();
|
||||||
string exepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
|
|
||||||
string appDataPpath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Windows";
|
|
||||||
string oldappdatapath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool";
|
|
||||||
string tempProfileProgram = string.Empty;
|
string tempProfileProgram = string.Empty;
|
||||||
double dpix, dpiy;
|
double dpix, dpiy;
|
||||||
List<string> profilenames = new List<string>();
|
List<string> profilenames = new List<string>();
|
||||||
@ -87,44 +83,22 @@ namespace DS4Windows
|
|||||||
|
|
||||||
public DS4Form(string[] args)
|
public DS4Form(string[] args)
|
||||||
{
|
{
|
||||||
bool firstrun = false;
|
Global.FindConfigLocation();
|
||||||
|
|
||||||
if (File.Exists(exepath + "\\Auto Profiles.xml")
|
if (Global.firstRun)
|
||||||
&& File.Exists(appDataPpath + "\\Auto Profiles.xml"))
|
|
||||||
{
|
{
|
||||||
firstrun = true;
|
new SaveWhere(Global.multisavespots).ShowDialog();
|
||||||
new SaveWhere(true).ShowDialog();
|
|
||||||
}
|
}
|
||||||
else if (File.Exists(exepath + "\\Auto Profiles.xml"))
|
else if (Global.oldappdatafail)
|
||||||
SaveWhere(exepath);
|
|
||||||
else if (File.Exists(appDataPpath + "\\Auto Profiles.xml"))
|
|
||||||
SaveWhere(appDataPpath);
|
|
||||||
else if (File.Exists(oldappdatapath + "\\Auto Profiles.xml"))
|
|
||||||
{
|
{
|
||||||
try
|
MessageBox.Show(Properties.Resources.CannotMoveFiles, "DS4Windows");
|
||||||
{
|
Process.Start("explorer.exe", @"/select, " + appDataPpath);
|
||||||
if (Directory.Exists(appDataPpath))
|
Close();
|
||||||
Directory.Move(appDataPpath, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Windows Old");
|
return;
|
||||||
Directory.Move(oldappdatapath, appDataPpath);
|
|
||||||
SaveWhere(appDataPpath);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
MessageBox.Show(Properties.Resources.CannotMoveFiles, "DS4Windows");
|
|
||||||
Process.Start("explorer.exe", @"/select, " + appDataPpath);
|
|
||||||
Close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!File.Exists(exepath + "\\Auto Profiles.xml")
|
|
||||||
&& !File.Exists(appDataPpath + "\\Auto Profiles.xml"))
|
|
||||||
{
|
|
||||||
firstrun = true;
|
|
||||||
new SaveWhere(false).ShowDialog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.Load();
|
Global.Load();
|
||||||
this.setCulture(UseLang);
|
Global.SetCulture(UseLang);
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
ThemeUtil.SetTheme(lvDebug);
|
ThemeUtil.SetTheme(lvDebug);
|
||||||
@ -434,16 +408,6 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCulture(string culture)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture);
|
|
||||||
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo(culture);
|
|
||||||
}
|
|
||||||
catch { /* Skip setting culture that we cannot set */ }
|
|
||||||
}
|
|
||||||
|
|
||||||
private void populateHoverTextDict()
|
private void populateHoverTextDict()
|
||||||
{
|
{
|
||||||
hoverTextDict.Clear();
|
hoverTextDict.Clear();
|
||||||
|
@ -1,30 +1,29 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
using NonFormTimer = System.Threading.Timer;
|
||||||
using System.Security.Principal;
|
using System.Threading.Tasks;
|
||||||
using System.Security.Permissions;
|
using static DS4Windows.Global;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace DS4Windows
|
namespace DS4Windows
|
||||||
{
|
{
|
||||||
public partial class WelcomeDialog : Form
|
public partial class WelcomeDialog : Form
|
||||||
{
|
{
|
||||||
public WelcomeDialog()
|
public WelcomeDialog(bool loadConfig=false)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Icon = Properties.Resources.DS4;
|
Icon = Properties.Resources.DS4;
|
||||||
|
if (loadConfig)
|
||||||
|
{
|
||||||
|
Global.FindConfigLocation();
|
||||||
|
Global.Load();
|
||||||
|
Global.SetCulture(Global.UseLang);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bnFinish_Click(object sender, EventArgs e)
|
private void bnFinish_Click(object sender, EventArgs e)
|
||||||
@ -54,7 +53,6 @@ namespace DS4Windows
|
|||||||
bnStep1.Text = Properties.Resources.Downloading.Replace("*number*", e.ProgressPercentage.ToString());
|
bnStep1.Text = Properties.Resources.Downloading.Replace("*number*", e.ProgressPercentage.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
string exepath = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;
|
|
||||||
private void wb_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
|
private void wb_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
|
||||||
{
|
{
|
||||||
bnStep1.Text = Properties.Resources.OpeningInstaller;
|
bnStep1.Text = Properties.Resources.OpeningInstaller;
|
||||||
|
@ -39,7 +39,7 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new WelcomeDialog());
|
Application.Run(new WelcomeDialog(true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (s == "re-enabledevice" || s == "-re-enabledevice")
|
else if (s == "re-enabledevice" || s == "-re-enabledevice")
|
||||||
|
Loading…
Reference in New Issue
Block a user