Skip to content

Commit

Permalink
USX editor no-longer pops out
Browse files Browse the repository at this point in the history
Changed:
- USX editor is no longer a separate window
-- Part of the Unix Bug Fix migration
  • Loading branch information
DavidCarbon committed Jun 4, 2024
1 parent d412e0a commit 6f58350
Show file tree
Hide file tree
Showing 14 changed files with 2,991 additions and 2,813 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public partial class Screen_Settings : Form
#pragma warning disable CS8618
public static Screen_Settings? Screen_Instance { get; set; }
#pragma warning restore CS8618
private int LastSelectedLanguage { get; set; }
public static bool RestartRequired { get; set; }
public static bool Insider_Settings_Lock { get; set; }
private string NewLauncherPath { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using SBRW.Launcher.App.UI_Forms.About_Screen;
using Flurl.Util;
using SBRW.Launcher.App.UI_Forms.About_Screen;
using SBRW.Launcher.App.UI_Forms.Main_Screen;
using SBRW.Launcher.App.UI_Forms.Parent_Screen;
using SBRW.Launcher.App.UI_Forms.Selection_CDN_Screen;
using SBRW.Launcher.App.UI_Forms.USXEditor_Screen;
using SBRW.Launcher.App.UI_Forms.User_Settings_Editor_Screen;
using SBRW.Launcher.App.UI_Forms.VerifyHash_Screen;
using SBRW.Launcher.Core.Cache;
using SBRW.Launcher.Core.Extension.Api_;
Expand Down Expand Up @@ -207,45 +208,6 @@ private async void SettingsSave_Click(object sender, EventArgs e)

if (TabControl_Shared_Hub.SelectedTab.Equals(TabPage_Settings))
{
/* TODO null check */
if (ComboBox_Language_List.SelectedItem != null && !string.IsNullOrWhiteSpace(((Json_List_Language)ComboBox_Language_List.SelectedItem).Value_Ini))
{
Save_Settings.Live_Data.Launcher_Language = ((Json_List_Language)ComboBox_Language_List.SelectedItem).Value_Ini;
XML_File.XML_Settings_Data.Language = ((Json_List_Language)ComboBox_Language_List.SelectedItem).Value_XML;

/* TODO: Inform player about custom languagepack used. */
if (((Json_List_Language)ComboBox_Language_List.SelectedItem).Category == "Custom")
{
MessageBox.Show(null, "Please Note: If a Server does not provide a Language Pack, it will fallback to English Language Pack instead.",
"GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Information);

if (!Directory.Exists(Save_Settings.Live_Data.Game_Path + "/scripts"))
{
try { Directory.CreateDirectory(Save_Settings.Live_Data.Game_Path + "/scripts"); }
catch { }
}

if (File.Exists(Save_Settings.Live_Data.Game_Path + "/scripts/LangPicker.ini"))
{
try { File.Delete(Save_Settings.Live_Data.Game_Path + "/scripts/LangPicker.ini"); }
catch { }
}

try
{
Ini_File LanguagePickerFile = new Ini_File(Save_Settings.Live_Data.Game_Path + "/scripts/LangPicker.ini");
LanguagePickerFile.Key_Write("Language", ((Json_List_Language)ComboBox_Language_List.SelectedItem).Value_Ini);
}
catch { }
}
/* Delete Custom Settings.ini for LangPicker.asi module */
else if (File.Exists(Save_Settings.Live_Data.Game_Path + "/scripts/LangPicker.ini"))
{
try { File.Delete(Save_Settings.Live_Data.Game_Path + "/scripts/LangPicker.ini"); }
catch { }
}
}

if (Save_Settings.Live_Data.Launcher_Proxy != (CheckBox_Proxy.Checked ? "1" : "0"))
{
Save_Settings.Live_Data.Launcher_Proxy = CheckBox_Proxy.Checked ? "1" : "0";
Expand Down Expand Up @@ -286,6 +248,24 @@ private async void SettingsSave_Click(object sender, EventArgs e)
RestartRequired = true;
}
*/
/* Proxy Logging */
if (ComboBox_Proxy_Logging.SelectedItem != default)
{
if (Save_Settings.Proxy_Log_Mode() != ((Json_List_Proxy_Logging)ComboBox_Proxy_Logging.SelectedItem).Mode)
{
Save_Settings.Live_Data.Launcher_Proxy_Log_Mode =
((int)((Json_List_Proxy_Logging)ComboBox_Proxy_Logging.SelectedItem).Mode).ToString();
}
}
/* Proxy GZip Version */
if (ComboBox_Proxy_GZip_Version.SelectedItem != default)
{
if (Save_Settings.Proxy_GZip_Version() != ((Json_List_Proxy_GZip_Version)ComboBox_Proxy_GZip_Version.SelectedItem).Version)
{
Save_Settings.Live_Data.Launcher_Proxy_GZip_Version =
((int)((Json_List_Proxy_GZip_Version)ComboBox_Proxy_GZip_Version.SelectedItem).Version).ToString();
}
}

if (Save_Settings.Live_Data.Launcher_Theme_Support != (CheckBox_Theme_Support.Checked ? "1" : "0"))
{
Expand Down Expand Up @@ -361,7 +341,6 @@ private async void SettingsSave_Click(object sender, EventArgs e)

/* Save Settings */
Save_Settings.Save();
XML_File.Save(1);

if (TabControl_Shared_Hub.SelectedTab.Equals(TabPage_Settings))
{
Expand Down Expand Up @@ -478,8 +457,45 @@ private void NumericUpDown_Range_Affinity_ValueChanged(object sender, EventArgs
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CheckBox_RPC_CheckedChanged(object sender, EventArgs e)
{
CheckBox_RPC.Text = $"Discord RPC {(CheckBox_RPC.Checked ? "(Enabled)" : "(Disabled)")}";
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CheckBox_JSON_Update_Cache_CheckedChanged(object sender, EventArgs e)
{
CheckBox_JSON_Update_Cache.Text = $"JSON Cache {(CheckBox_JSON_Update_Cache.Checked ? "(Enabled)" : "(Disabled)")}";
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CheckBox_Theme_Support_CheckedChanged(object sender, EventArgs e)
{
CheckBox_Theme_Support.Text = $"Custom Theme {(CheckBox_Theme_Support.Checked ? "(Enabled)" : "(Disabled)")}";
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CheckBox_Enable_ACM_CheckedChanged(object sender, EventArgs e)
{
CheckBox_Enable_ACM.Text = $"Account Manager {(CheckBox_Enable_ACM.Checked ? "(Enabled)" : "(Disabled)")}";
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void CheckBox_Enable_Affinity_Range_CheckedChanged(object sender, EventArgs e)
{
CheckBox_Enable_Affinity_Range.Text = $"Affinity Range {(CheckBox_Enable_Affinity_Range.Checked ? "(Enabled)" :"(Disabled)")}";
Enable_Affinity_Range(CheckBox_Enable_Affinity_Range.Checked);
}
/// <summary>
Expand All @@ -505,7 +521,19 @@ private void SettingsCancel_Click(object sender, EventArgs e)
/// <param name="e"></param>
private void SettingsUEditorButton_Click(object sender, EventArgs e)
{
Screen_User_Settings_Editor.OpenScreen();
try
{
Screen_User_Settings_Editor Custom_Instance_Settings = new Screen_User_Settings_Editor() { Dock = DockStyle.Fill, TopLevel = false, TopMost = true, FormBorderStyle = FormBorderStyle.None };
Panel_Form_Screens.Controls.Add(Custom_Instance_Settings);
Panel_Form_Screens.Visible = true;
Custom_Instance_Settings.Show();
Text = "Game Settings Editor - SBRW Launcher: " + Application.ProductVersion;
}
catch (Exception Error)
{
string ErrorMessage = "Game Settings Editor Screen Encountered an Error";
LogToFileAddons.OpenLog("GAME SETTINGS SCREEN", ErrorMessage, Error, "Exclamation", false);
}
}
/// <summary>
/// Settings Clear ModNet Cache
Expand Down Expand Up @@ -748,29 +776,6 @@ private void Console_Enter(object sender, EventArgs e)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ComboBox_Language_List_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
if (bool.TryParse(((Json_List_Language)ComboBox_Language_List.SelectedItem).IsSpecial.ToString(), out bool Result))
{
if (((Json_List_Language)ComboBox_Language_List.SelectedItem).IsSpecial)
{
ComboBox_Language_List.SelectedIndex = LastSelectedLanguage;
}
else
{
LastSelectedLanguage = ComboBox_Language_List.SelectedIndex;
}
}
}
catch { }
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ComboBox_Proxy_Logging_SelectedIndexChanged(object sender, EventArgs e)
{
if (Screen_Instance != default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,58 +118,37 @@ private void CheckGameFilesDirectoryPrevention()
}
#endregion
#region ComboxList Setup
/// <summary>
///
/// </summary>
private void RememberLastLanguage()
private void RememberLastProxySettings()
{
/* Last Selected CDN */
Log.Core("SETTINGS LANGLIST: Checking...");
Log.Core("SETTINGS LANGLIST: Setting first Language in list");
Log.Core("SETTINGS LANGLIST: Checking if Language is set on INI File");

try
{
if (!string.IsNullOrWhiteSpace(Save_Settings.Live_Data.Launcher_Language))
/* Proxy Logging */
if (!string.IsNullOrWhiteSpace(Save_Settings.Live_Data.Launcher_Proxy_Log_Mode))
{
string SavedLang = Save_Settings.Live_Data.Launcher_Language.Trim();

Log.Core("SETTINGS LANGLIST: Found something!");
Log.Core("SETTINGS LANGLIST: Checking if Language exists on our database");

if (LanguageListUpdater.CleanList.FindIndex(i => string.Equals(i.Value_Ini, SavedLang)) != 0)
{
Log.Core("SETTINGS LANGLIST: Language found! Checking its Value");
var index = LanguageListUpdater.CleanList.FindIndex(i => string.Equals(i.Value_Ini, SavedLang));

Log.Core("SETTINGS LANGLIST: ID is " + index);
if (index >= 0)
{
Log.Core("SETTINGS LANGLIST: ID set correctly");
ComboBox_Language_List.SelectedIndex = index;
}
else if (index < 0)
{
ComboBox_Language_List.SelectedIndex = 1;
}
}
else
{
Log.Warning("SETTINGS LANGLIST: Unable to find anything, assuming default");
ComboBox_Language_List.SelectedIndex = 1;
Log.Warning("SETTINGS LANGLIST: Unknown entry value is " + SavedLang);
}
Log.Core("SETTINGS LANGLIST: All done");
ComboBox_Proxy_Logging.SelectedIndex =
ProxySettingsListUpdater.Proxy_Logging.FindIndex(i => Equals(i.Mode, Save_Settings.Proxy_Log_Mode()));
}
else
{
ComboBox_Proxy_Logging.SelectedIndex = 1;
}
/* Proxy GZip Version */
if (!string.IsNullOrWhiteSpace(Save_Settings.Live_Data.Launcher_Proxy_GZip_Version))
{
ComboBox_Proxy_GZip_Version.SelectedIndex =
ProxySettingsListUpdater.Proxy_GZip_Version.FindIndex(i => Equals(i.Version, Save_Settings.Proxy_GZip_Version()));
}
else
{
Log.Warning("SETTINGS LANGLIST: Unable to find anything, assuming default");
ComboBox_Language_List.SelectedIndex = 1;
ComboBox_Proxy_GZip_Version.SelectedIndex = 1;
}
/* Manually Invoke Index Change to Set Selected Details Text */
ComboBox_Proxy_Logging_SelectedIndexChanged(default, default);
ComboBox_Proxy_GZip_Version_SelectedIndexChanged(default, default);
}
catch (Exception Error)
{
LogToFileAddons.OpenLog("SETTINGS LANGLIST", string.Empty, Error, string.Empty, true);
LogToFileAddons.OpenLog("SETTINGS ProxySettingsLIST", string.Empty, Error, string.Empty, true);
}
}
#endregion
Expand Down
Loading

0 comments on commit 6f58350

Please sign in to comment.