Skip to content

Commit

Permalink
Natural Launcher v1.0.3 now ask at first launch if you want to keep c…
Browse files Browse the repository at this point in the history
…ustom files. Editable in the settings !
  • Loading branch information
MaelElseware committed Dec 18, 2018
1 parent 3428a69 commit e874e9a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 5 deletions.
9 changes: 7 additions & 2 deletions NaturalLauncher/Launcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Launcher

public static bool keepLauncherAlive = true;
public static bool restartSteam = false; // used at the end of the verify process
public static bool keepCustomFiles = false; // keep files customized by the player when existing (sound, sprites ...)

public static DateTime LAUNCHTIME = System.DateTime.UtcNow;
public static string discordCustomStatus = "Currently In The Launcher";
Expand Down Expand Up @@ -170,14 +171,15 @@ public static void CheckInstallDirectory()
{
string IndicatedFolder = "";
bool isXP = false;
XmlBuilder.ReadConfigXml(out IndicatedFolder, out isXP, out string discordStatus, out bool keepAlive);
XmlBuilder.ReadConfigXml(out IndicatedFolder, out isXP, out string discordStatus, out bool keepAlive, out bool keepcustoms);

if (IndicatedFolder.Length >0)
{
HLFolder = IndicatedFolder;
isExperimental = isXP;
discordCustomStatus = discordStatus;
keepLauncherAlive = keepAlive;
keepCustomFiles = keepcustoms;
}
else
NeedDirectory = true;
Expand Down Expand Up @@ -215,6 +217,9 @@ public static void CheckInstallDirectory()
{
Environment.Exit(0); //stop the process
}

// Because it's first launch, ask if we want to keep custom files
Util.AskForCustomFiles();
}

NSFolder = HLFolder + Path.DirectorySeparatorChar + "ns";
Expand All @@ -227,7 +232,7 @@ public static bool IsNLPack()
if (File.Exists(curDir + Path.DirectorySeparatorChar + configName))
{
string IndicatedFolder = "";
XmlBuilder.ReadConfigXml(out IndicatedFolder, out Result, out string plop, out bool noob);
XmlBuilder.ReadConfigXml(out IndicatedFolder, out Result, out string plop, out bool noob,out bool lolilol);
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions NaturalLauncher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@ public void UpdateGame_Worker(object sender, DoWorkEventArgs e)
UpdateLog.WriteLine(Util.GetShortTimeString() + gameFilePath + " not existing, needs downloading");
ShouldDownload = true;
}
if (File.Exists(gameFilePath) && Launcher.keepCustomFiles && ( kv.Key.EndsWith(".wav") || kv.Key.EndsWith(".mp3") || kv.Key.EndsWith(".spr") || kv.Key.EndsWith(".tga") ) )
{
UpdateLog.WriteLine(Util.GetShortTimeString() + gameFilePath + " Keeping custom files");
ShouldDownload = false;
}
if (File.Exists(gameFilePath) && IgnoreManifest.Files.ContainsKey(kv.Key) && IgnoreValue == "1") // ignore everything
{
UpdateLog.WriteLine(Util.GetShortTimeString() + gameFilePath + " Is Ignored for update, not checking");
Expand Down
3 changes: 2 additions & 1 deletion NaturalLauncher/Settings.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
<Label Content="Custom discord status :" Canvas.Left="38" Canvas.Top="128" Height="27" Width="145" Foreground="#FF5ACAFF" FontWeight="Bold" HorizontalContentAlignment="Center"/>
<TextBox x:Name="DiscordTxtbox" Height="27" Canvas.Left="212" TextWrapping="Wrap" Text="status" Canvas.Top="127" Width="261" Foreground="#FF2B2F30" FontWeight="Bold" Background="#BFFFFFFF" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
<Button x:Name="ChangeDiscordButton" Content="Change" Canvas.Left="479" Canvas.Top="127" Width="49" Height="27" Background="#19000000" BorderBrush="#FF5ACAFF" Foreground="#FF5ACAFF" Click="ChangeDiscord_Click"/>
<CheckBox x:Name="isExperimental" Content="Use Experimental Build" Canvas.Left="196" Canvas.Top="265" FontWeight="Bold" Foreground="#FFFF685A" Width="175" HorizontalContentAlignment="Center" Click="isExperimental_Click"/>
<CheckBox x:Name="isExperimental" Content="Use Experimental Build" Canvas.Left="306" Canvas.Top="265" FontWeight="Bold" Foreground="#FFFF685A" Width="175" HorizontalContentAlignment="Center" Click="isExperimental_Click"/>
<CheckBox x:Name="isKeepingCustoms" Content="Keep Custom Files" Canvas.Left="102" Canvas.Top="265" FontWeight="Bold" Foreground="#FFFF965A" Width="175" HorizontalContentAlignment="Center" Click="KeepCustom_Click"/>
</Canvas>
</Grid>
</Window>
10 changes: 9 additions & 1 deletion NaturalLauncher/Settings.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ public Settings()

try
{
XmlBuilder.ReadConfigXml(out string uno, out bool isXP, out string discordStatus, out bool keepAlive);
XmlBuilder.ReadConfigXml(out string uno, out bool isXP, out string discordStatus, out bool keepAlive, out bool keepCustoms);
Launcher.keepLauncherAlive = keepAlive;
DiscordTxtbox.Text = discordStatus;
KeepAliveChecker.IsChecked = keepAlive;
isExperimental.IsChecked = isXP;
isKeepingCustoms.IsChecked = keepCustoms;
windowfullyopen = true;
}
catch(Exception exception)
Expand Down Expand Up @@ -291,5 +292,12 @@ private void ChangeDiscord_Click(object sender, RoutedEventArgs e)
Launcher.UpdateDiscord(false);
XmlBuilder.CreateConfigXml();
}

private void KeepCustom_Click(object sender, RoutedEventArgs e)
{
Launcher.keepCustomFiles = isKeepingCustoms.IsChecked.Value;

XmlBuilder.CreateConfigXml();
}
}
}
25 changes: 25 additions & 0 deletions NaturalLauncher/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -665,5 +665,30 @@ public static void PlaySoundFX(string Type) //now only play when error because w


}

public static void AskForCustomFiles()
{
string sMessageBoxText = "Do you want to preserve your custom files?" + Environment.NewLine + "(can be changed in the settings)";
string sCaption = "Keep Custom Files";

MessageBoxButton btnMessageBox = MessageBoxButton.YesNo;
MessageBoxImage icnMessageBox = MessageBoxImage.Warning;

MessageBoxResult rsltMessageBox = System.Windows.MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox);

switch (rsltMessageBox)
{
case MessageBoxResult.Yes:
Launcher.keepCustomFiles = true;
break;

case MessageBoxResult.No:
Launcher.keepCustomFiles = false;
break;
}

XmlBuilder.CreateConfigXml();
}

}
}
11 changes: 10 additions & 1 deletion NaturalLauncher/XmlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static XElement CreateSubdirectoryXML(DirectoryInfo dir)
return xmlInfo;
}

public static bool ReadConfigXml(out string HLFolder, out bool isXP, out string customDiscordStatus, out bool keepLauncherAlive)
public static bool ReadConfigXml(out string HLFolder, out bool isXP, out string customDiscordStatus, out bool keepLauncherAlive, out bool keepCustomFiles)
{
XmlDocument doc = new XmlDocument();
try
Expand Down Expand Up @@ -125,6 +125,14 @@ public static bool ReadConfigXml(out string HLFolder, out bool isXP, out string
{
keepLauncherAlive = true;
}
try
{
keepCustomFiles = doc.SelectSingleNode("//keepCustomFiles").InnerText == "True";
}
catch
{
keepCustomFiles = false;
}

return true;

Expand All @@ -137,6 +145,7 @@ public static bool CreateConfigXml()
xmlInfo.Add(new XElement("isXP", Launcher.isExperimental.ToString()));
xmlInfo.Add(new XElement("DiscordStatus", Launcher.discordCustomStatus));
xmlInfo.Add(new XElement("keeplauncherAlive", Launcher.keepLauncherAlive.ToString()));
xmlInfo.Add(new XElement("keepCustomFiles", Launcher.keepCustomFiles.ToString()));

var doc = new XDocument(new XDeclaration("1.0", "UTF-8", "yes"), xmlInfo);

Expand Down

0 comments on commit e874e9a

Please sign in to comment.