Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
FelisDiligens committed Jul 11, 2020
2 parents 6c99aad + f3b33b8 commit 7f15818
Show file tree
Hide file tree
Showing 28 changed files with 711 additions and 262 deletions.
11 changes: 11 additions & 0 deletions Fo76ini/Fo76ini.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@
</ItemGroup>
<ItemGroup>
<Content Include="icon.ico" />
<None Include="Resources\question_mark.png" />
<None Include="Resources\bethesda-launcher-pts.png" />
<None Include="Resources\bethesda-launcher.png" />
<None Include="Resources\bethesdanet.png" />
<None Include="Resources\bethesda_24px.png" />
<None Include="Resources\xbox_24px.png" />
<None Include="Resources\steam_24px.png" />
<None Include="Resources\msstore_24px.png" />
<None Include="Resources\msstore.png" />
<None Include="Resources\xbox.png" />
<None Include="Resources\steam.png" />
<None Include="icons\defrost.png" />
<None Include="icons\frozen-plus.png" />
</ItemGroup>
Expand Down
243 changes: 183 additions & 60 deletions Fo76ini/Form1.Designer.cs

Large diffs are not rendered by default.

42 changes: 3 additions & 39 deletions Fo76ini/Form1.Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ private int SerializeControlText(XElement element, ToolTip toolTip, Control cont
subControl.Name != "labelTranslationAuthor" &&
subControl.Name != "groupBoxWIP" &&
subControl.Name != "labelNewVersion" &&
subControl.Name != "labelModsDeploy")
subControl.Name != "labelModsDeploy" &&
subControl.Name != "labelGameEdition")
{
// Get XElement name:
String type = "Element";
Expand Down Expand Up @@ -313,7 +314,7 @@ private void SerializeXMLFile(String name = null, String iso = null, String auth
if (iso == null)
iso = this.languageISOs[index];
if (author == null)
author = this.labelAuthorName.Text.Trim();
author = this.labelTranslationAuthor.Text.Trim();
if (fileName == null)
fileName = iso + ".template.xml";

Expand Down Expand Up @@ -366,43 +367,6 @@ private void SerializeXMLFile(String name = null, String iso = null, String auth
private void GenerateEnglishXMLFile()
{
SerializeXMLFile("English (USA)", "en-US", "", "en-US.xml");
/*// Create document and root:
XDocument xmlDoc = new XDocument();
XElement xmlRoot = new XElement("Language");
xmlRoot.Add(new XAttribute("name", "English (USA)"));
xmlRoot.Add(new XAttribute("iso", "en-US"));
xmlDoc.AddFirst(new XComment("\n This file is auto-generated on program start.\n Therefore any changes made to this file will be overriden.\n You can use this as a template for your own translation, though.\n"));
xmlDoc.Add(xmlRoot);
// Serialize miscellaneous strings:
XElement xmlStrings = new XElement("Strings");
foreach (KeyValuePair<String, String> pair in Translation.localizedStrings)
xmlStrings.Add(new XElement("String",
new XAttribute("text", pair.Value),
new XAttribute("id", pair.Key)));
xmlRoot.Add(xmlStrings);
// Create dropdowns:
XElement xmlDropDowns = new XElement("Dropdowns");
foreach (KeyValuePair<String, ComboBoxContainer> pair in this.comboBoxes)
SerializeDropDownOptions(xmlDropDowns, pair.Key, pair.Value.Items);
xmlRoot.Add(xmlDropDowns);
// Create messageboxes:
xmlRoot.Add(MsgBox.Serialize());
// Serialize all control elements:
XElement xmlForm1 = new XElement("Form1", new XAttribute("title", this.Text));
XElement xmlFormMods = new XElement("FormMods", new XAttribute("title", this.formMods.Text));
SerializeControlText(xmlForm1, this.toolTip, this);
SerializeControlText(xmlFormMods, this.formMods.toolTip, this.formMods);
xmlRoot.Add(xmlForm1);
xmlRoot.Add(xmlFormMods);
// Save it:
xmlDoc.Save(Path.Combine(languageFolder, "en-US.xml"));
//using (XmlTextWriter writer = new XmlTextWriter(Path.Combine(languageFolder, "en-US.xml"), new UTF8Encoding(false)))
// xmlDoc.Save(writer); */
}

private void ChangeLanguage(string langFile)
Expand Down
155 changes: 133 additions & 22 deletions Fo76ini/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Fo76ini
{
public partial class Form1 : Form
{
public const String VERSION = "1.6.3";
public const String VERSION = "1.7.0";

protected System.Globalization.CultureInfo enUS = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");

Expand Down Expand Up @@ -161,7 +161,9 @@ private void Form1_Load(object sender, EventArgs e)
// Load *.ini files:
try
{
IniFiles.Instance.GameEdition = (GameEdition)IniFiles.Instance.GetInt(IniFile.Config, "Preferences", "uGameEdition", 0);
IniFiles.Instance.LoadGameInis();
IniFiles.Instance.Set(IniFile.Config, "Preferences", "uGameEdition", (int)IniFiles.Instance.GameEdition);
}
catch (IniParser.Exceptions.ParsingException exc)
{
Expand All @@ -171,7 +173,7 @@ private void Form1_Load(object sender, EventArgs e)
}
catch (FileNotFoundException exc)
{
MsgBox.Get("runGameToGenerateINI").Show(MessageBoxButtons.OK, MessageBoxIcon.Error);
MsgBox.Get("runGameToGenerateINI").FormatTitle(IniFiles.Instance.GetIniName(IniFile.F76), IniFiles.Instance.GetIniName(IniFile.F76Prefs)).Show(MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
return;
}
Expand Down Expand Up @@ -300,8 +302,8 @@ private void AddAllEventHandler()

// Game Edition
uiLoader.LinkList(
new RadioButton[] { this.radioButtonEditionBethesdaNet, this.radioButtonEditionSteam, this.radioButtonEditionBethesdaNetPTS },
new String[] { "1", "2", "3" },
new RadioButton[] { this.radioButtonEditionBethesdaNet, this.radioButtonEditionSteam, this.radioButtonEditionBethesdaNetPTS, this.radioButtonEditionMSStore },
new String[] { "1", "2", "3", "4" },
IniFile.Config, "Preferences", "uGameEdition",
"0"
);
Expand Down Expand Up @@ -831,6 +833,9 @@ private void buttonLaunchGame_Click(object sender, EventArgs e)
case (uint)GameEdition.BethesdaNetPTS:
process = "bethesdanet://run/57";
break;
case (uint)GameEdition.MSStore:
process = "ms-windows-store://pdp/?ProductId=9nkgnmnk3k3z";
break;
default:
MsgBox.Get("chooseGameEdition").Show(MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
Expand All @@ -843,15 +848,26 @@ private void buttonLaunchGame_Click(object sender, EventArgs e)
MsgBox.Get("modsGamePathNotSet").Show(MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
process = Path.GetFullPath(Path.Combine(ManagedMods.Instance.GamePath, "Fallout76.exe"));
process = Path.GetFullPath(Path.Combine(ManagedMods.Instance.GamePath, ManagedMods.Instance.GameEdition == GameEdition.MSStore ? "Project76_GamePass.exe" : "Fallout76.exe"));
}
if (process != null)
{
if (IniFiles.Instance.GetBool(IniFile.Config, "Preferences", "bAutoApply", false))
ApplyChanges();
System.Diagnostics.Process.Start(process);
if (IniFiles.Instance.GetBool(IniFile.Config, "Preferences", "bQuitOnLaunch", false))
this.Close();
try
{
System.Diagnostics.Process.Start(process);
if (IniFiles.Instance.GetBool(IniFile.Config, "Preferences", "bQuitOnLaunch", false))
this.Close();
}
catch (Exception ex)
{
if (ManagedMods.Instance.GameEdition == GameEdition.MSStore)
{
MsgBox.Get("msstoreRunExecutableFailed").FormatTitle(ex.Message).Show(MessageBoxIcon.Error);
return;
}
}
}
}

Expand Down Expand Up @@ -924,31 +940,102 @@ private void buttonFixIssuesEarlierVersion_Click(object sender, EventArgs e)
* Game edition
*/

private void radioButtonEditionSteam_CheckedChanged(object sender, EventArgs e)
private void ChangeGameEdition(GameEdition edition)
{
if (this.radioButtonEditionSteam.Checked)
bool restartRequired = ManagedMods.Instance.GameEdition != GameEdition.Unknown && ((ManagedMods.Instance.GameEdition == GameEdition.MSStore && edition != GameEdition.MSStore) || (ManagedMods.Instance.GameEdition != GameEdition.MSStore && edition == GameEdition.MSStore));

if (restartRequired && MsgBox.Get("msstoreRestartRequired").Show(MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
switch (ManagedMods.Instance.GameEdition)
{
case GameEdition.Steam:
this.radioButtonEditionSteam.Checked = true;
break;
case GameEdition.BethesdaNet:
this.radioButtonEditionBethesdaNet.Checked = true;
break;
case GameEdition.BethesdaNetPTS:
this.radioButtonEditionBethesdaNetPTS.Checked = true;
break;
case GameEdition.MSStore:
this.radioButtonEditionMSStore.Checked = true;
break;
}
return;
}

// Change image
switch (edition)
{
case GameEdition.Steam:
this.pictureBoxGameEdition.Image = Properties.Resources.steam;
this.labelGameEdition.Text = "Steam";
break;
case GameEdition.BethesdaNet:
this.pictureBoxGameEdition.Image = Properties.Resources.bethesda;
this.labelGameEdition.Text = "Bethesda";
break;
case GameEdition.BethesdaNetPTS:
this.pictureBoxGameEdition.Image = Properties.Resources.bethesda_pts;
this.labelGameEdition.Text = "Bethesda\n(PTS)";
break;
case GameEdition.MSStore:
this.pictureBoxGameEdition.Image = Properties.Resources.msstore;
this.labelGameEdition.Text = "Microsoft\nStore";
break;
default:
this.pictureBoxGameEdition.Image = Properties.Resources.question_mark;
this.labelGameEdition.Text = "Unknown";
break;
}

// Currently, no way to launch game executable, if installed via MS Store:
/*if (edition == GameEdition.MSStore)
{
IniFiles.Instance.Set(IniFile.Config, "Preferences", "uLaunchOption", 1);
this.radioButtonLaunchViaExecutable.Checked = false;
this.radioButtonLaunchViaExecutable.Enabled = false;
this.radioButtonLaunchViaLink.Checked = true;
}
else
{
this.radioButtonLaunchViaExecutable.Enabled = true;
}*/

IniFiles.Instance.ChangeGameEdition(edition);
this.formMods.ChangeGameEdition(edition);
this.textBoxGamePath.Text = ManagedMods.Instance.GamePath;

if (restartRequired)
{
this.formMods.ChangeGameEdition(GameEdition.Steam);
this.textBoxGamePath.Text = ManagedMods.Instance.GamePath;
IniFiles.Instance.SaveWindowState("Form1", this);
Application.Restart();
}
}

private void radioButtonEditionSteam_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButtonEditionSteam.Checked)
ChangeGameEdition(GameEdition.Steam);
}

private void radioButtonEditionBethesdaNet_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButtonEditionBethesdaNet.Checked)
{
this.formMods.ChangeGameEdition(GameEdition.BethesdaNet);
this.textBoxGamePath.Text = ManagedMods.Instance.GamePath;
}
ChangeGameEdition(GameEdition.BethesdaNet);
}

private void radioButtonEditionBethesdaNetPTS_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButtonEditionBethesdaNetPTS.Checked)
{
this.formMods.ChangeGameEdition(GameEdition.BethesdaNetPTS);
this.textBoxGamePath.Text = ManagedMods.Instance.GamePath;
}
ChangeGameEdition(GameEdition.BethesdaNetPTS);
}

private void radioButtonEditionMSStore_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButtonEditionMSStore.Checked)
ChangeGameEdition(GameEdition.MSStore);
}

// Nuclear Winter mode
Expand All @@ -959,13 +1046,30 @@ private void checkBoxNWMode_CheckedChanged(object sender, EventArgs e)
{
if (MsgBox.ShowID("nwModeEnabledButModsAreDeployed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
ManagedMods.Instance.nuclearWinterMode = IniFiles.Instance.nuclearWinterMode;
// Disable mods:
ManagedMods.Instance.nuclearWinterMode = true;
this.formMods.OpenUI();
this.formMods.Deploy();
}
}
else if (!IniFiles.Instance.nuclearWinterMode && ManagedMods.Instance.nuclearWinterMode && ManagedMods.Instance.Mods.Count() > 0)
{
if (MsgBox.ShowID("nwModeDisabledAndModsAreStillDisabled", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
// Enable mods:
ManagedMods.Instance.nuclearWinterMode = false;
this.formMods.OpenUI();
this.formMods.Deploy();
}
}
}

private void pictureBoxGameEdition_Click(object sender, EventArgs e)
{
this.tabControl1.SelectTab(this.tabPageSettings);
this.groupBoxGameEdition.Focus();
}

private void checkBoxShowPassword_CheckedChanged(object sender, EventArgs e)
{
// https://stackoverflow.com/questions/8185747/how-can-i-unmask-password-text-box-and-mask-it-back-to-password
Expand Down Expand Up @@ -1131,7 +1235,14 @@ private void textBoxGamePath_TextChanged(object sender, EventArgs e)

private void radioButtonLaunchViaExecutable_CheckedChanged(object sender, EventArgs e)
{
this.labelLaunchOptionTip.Visible = this.radioButtonLaunchViaExecutable.Checked;
this.labelLaunchOptionTip.Visible = false;
this.labelLaunchOptionMSStoreNotice.Visible = false;

if (ManagedMods.Instance.GameEdition == GameEdition.BethesdaNet || ManagedMods.Instance.GameEdition == GameEdition.BethesdaNetPTS)
this.labelLaunchOptionTip.Visible = this.radioButtonLaunchViaExecutable.Checked;

else if (ManagedMods.Instance.GameEdition == GameEdition.MSStore)
this.labelLaunchOptionMSStoreNotice.Visible = this.radioButtonLaunchViaExecutable.Checked;
}
}
}
7 changes: 3 additions & 4 deletions Fo76ini/FormMods.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Fo76ini/FormMods.resx
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,6 @@
h+r6rFy4sEMHYIfq+sTbnbmhCbFDdX1mX7AoymZRlM0fKDLmARhb1lLZqDWmAAAAAElFTkSuQmCC
</value>
</data>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>132, 17</value>
</metadata>
<metadata name="openFileDialogMod.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>327, 17</value>
</metadata>
Expand Down
Loading

0 comments on commit 7f15818

Please sign in to comment.