diff --git a/PCK-Studio/Features/CemuPanel.Designer.cs b/PCK-Studio/Features/CemuPanel.Designer.cs index d9860d21..b197f251 100644 --- a/PCK-Studio/Features/CemuPanel.Designer.cs +++ b/PCK-Studio/Features/CemuPanel.Designer.cs @@ -151,7 +151,7 @@ // this.GameDirectoryTextBox.CustomButton.Image = null; this.GameDirectoryTextBox.CustomButton.ImeMode = System.Windows.Forms.ImeMode.NoControl; - this.GameDirectoryTextBox.CustomButton.Location = new System.Drawing.Point(252, 1); + this.GameDirectoryTextBox.CustomButton.Location = new System.Drawing.Point(254, 1); this.GameDirectoryTextBox.CustomButton.Name = ""; this.GameDirectoryTextBox.CustomButton.Size = new System.Drawing.Size(25, 25); this.GameDirectoryTextBox.CustomButton.Style = MetroFramework.MetroColorStyle.Blue; @@ -160,6 +160,7 @@ this.GameDirectoryTextBox.CustomButton.UseSelectable = true; this.GameDirectoryTextBox.CustomButton.Visible = false; this.GameDirectoryTextBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.GameDirectoryTextBox.Enabled = false; this.GameDirectoryTextBox.Lines = new string[0]; this.GameDirectoryTextBox.Location = new System.Drawing.Point(3, 3); this.GameDirectoryTextBox.MaxLength = 32767; @@ -179,6 +180,7 @@ this.GameDirectoryTextBox.WaterMark = "Cemu Game Directory"; this.GameDirectoryTextBox.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109))))); this.GameDirectoryTextBox.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel); + this.GameDirectoryTextBox.TextChanged += new System.EventHandler(this.GameDirectoryTextBox_TextChanged); // // BrowseDirectoryBtn // diff --git a/PCK-Studio/Features/CemuPanel.cs b/PCK-Studio/Features/CemuPanel.cs index 0893f184..8d6757bd 100644 --- a/PCK-Studio/Features/CemuPanel.cs +++ b/PCK-Studio/Features/CemuPanel.cs @@ -1,4 +1,5 @@ using System; +using System.Xml; using System.IO; using System.Linq; using System.Windows.Forms; @@ -17,6 +18,61 @@ namespace PckStudio.Features public CemuPanel() { InitializeComponent(); + if (!TryApplyPermanentCemuConfig() && + MessageBox.Show("Failed to get Cemu perma settings\nDo you want to open your local settings.xml file?", + "Cemu mlc path not found", + MessageBoxButtons.YesNo, + MessageBoxIcon.Warning) == DialogResult.Yes + ) + { + + OpenFileDialog fileDialog = new OpenFileDialog() + { + Filter = "Cemu Settings|settings.xml", + }; + + if (fileDialog.ShowDialog(this) == DialogResult.OK) + { + TryApplyCemuConfig(fileDialog.FileName); + } + } + } + + private bool TryApplyCemuConfig(string settingsPath) + { + string cemuPath = Path.Combine(Path.GetDirectoryName(settingsPath), "Cemu.exe"); + if (File.Exists(cemuPath)) + { + var xml = new XmlDocument(); + xml.Load(settingsPath); + GameDirectoryTextBox.Text = xml.SelectSingleNode("content").SelectSingleNode("mlc_path").InnerText; + BrowseDirectoryBtn.Enabled = false; + } + return false; + } + + private bool TryApplyPermanentCemuConfig() + { + string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Cemu"); + string filepath = Path.Combine(path, "perm_setting.xml"); + if (Directory.Exists(path) && File.Exists(filepath)) + { + try + { + var xml = new XmlDocument(); + xml.Load(filepath); + var configNode = xml.SelectSingleNode("config"); + var mlcpathNode = configNode.SelectSingleNode("MlcPath"); + GameDirectoryTextBox.Text = mlcpathNode.InnerText; + BrowseDirectoryBtn.Enabled = false; + return true; + } + catch + { + return false; + } + } + return false; } private string GetSelectedRegionTitleId() @@ -51,12 +107,11 @@ namespace PckStudio.Features { OpenFolderDialog openFolderDialog = new OpenFolderDialog { - Title = "Select Cemu Game Directory" + Title = "Select Cemu mlc01 Directory" }; if (openFolderDialog.ShowDialog(Handle) == true && Directory.Exists(openFolderDialog.ResultPath)) { GameDirectoryTextBox.Text = openFolderDialog.ResultPath; - ListDLCs(); } } @@ -218,5 +273,10 @@ namespace PckStudio.Features { openSkinPackToolStripMenuItem_Click(sender, e); } + + private void GameDirectoryTextBox_TextChanged(object sender, EventArgs e) + { + ListDLCs(); + } } } diff --git a/PCK-Studio/Features/PckManager.cs b/PCK-Studio/Features/PckManager.cs index 774b1b88..a533ba84 100644 --- a/PCK-Studio/Features/PckManager.cs +++ b/PCK-Studio/Features/PckManager.cs @@ -44,6 +44,11 @@ namespace PckStudio.Features }); } + protected override void OnGotFocus(EventArgs e) + { + currentlyShowingControl?.Focus(); + } + private void supportedPlatformComboBox_SelectedIndexChanged(object sender, EventArgs e) { mainPanel.Controls.Remove(currentlyShowingControl);