Skip to content

Commit

Permalink
Migrate Loader file for new path + refresh code and patches after a l…
Browse files Browse the repository at this point in the history
…oader update
  • Loading branch information
Sora-yx committed Feb 17, 2025
1 parent ea7e74f commit d0e4db5
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions SA-Mod-Manager/UI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public partial class MainWindow : Window
string codexmlpath = string.Empty;
string codedatpath = string.Empty;
string patchdatpath = string.Empty;
private static bool gameMissingFlag = false;

// Shared Variables
CodeList mainCodes = null;
Expand Down Expand Up @@ -109,7 +108,7 @@ private async void MainWindowManager_Loaded(object sender, RoutedEventArgs e)
new SplashScreenDialog().ShowDialog();
}


Load();
SetBindings(); //theme is set here

Expand Down Expand Up @@ -152,6 +151,7 @@ private async void MainWindowManager_Loaded(object sender, RoutedEventArgs e)
{
UpdateManagerStatusText(Lang.GetString("UpdateStatus.ChkUpdate"));
await App.PerformUpdateLoaderCheck();
Refresh();
}

if (App.CurrentGame.id == GameEntry.GameType.SADX)
Expand Down Expand Up @@ -198,7 +198,7 @@ private void SaveAndPlayButton_Click(object sender, RoutedEventArgs e)
Save();
Refresh();


if (App.CurrentGame.id == GameEntry.GameType.Unsupported || ModDependency.CheckDependencies(EnabledMods, mods))
return;

Expand Down Expand Up @@ -1102,7 +1102,7 @@ private async Task<bool> ResultPickGame(string path)
UIHelper.ToggleButton(ref btnOpenGameDir, true);
suppressEvent = true;


if (DoGameSwap((Game)game, path))
{
ComboGameSelection.SelectedValue = App.CurrentGame;
Expand Down Expand Up @@ -1188,6 +1188,7 @@ private async void btnInstallLoader_Click(object sender, RoutedEventArgs e)
await HandleLoaderInstall();
UpdateButtonsState();
btnBrowseGameDir.IsEnabled = true;
Refresh();
Save();
}

Expand Down Expand Up @@ -1310,7 +1311,7 @@ private void comboProfile_SelectionChanged(object sender, SelectionChangedEventA
{
LoadGameSettings();
SetBindings();
SetGameUI();
SetGameUI();
Refresh();
Save();
}
Expand Down Expand Up @@ -1478,6 +1479,7 @@ private void UpdateManagerInfo()
}

App.CurrentGame.loader.installed = File.Exists(App.CurrentGame.loader.dataDllOriginPath) && File.Exists(App.CurrentGame.loader.loaderdllpath);
MigrateLoaderDLL();
UpdateButtonsState();
}

Expand Down Expand Up @@ -2035,7 +2037,7 @@ private void LoadModList()
}

LoadCodes();
// DataContext = ViewModel;
// DataContext = ViewModel;
ConfigureModBtn_UpdateState();
}

Expand Down Expand Up @@ -2430,7 +2432,7 @@ public void Refresh()
ComboGameSelection.SelectedValue = App.GamesList.FirstOrDefault();
return;
}


InitCodes();
LoadModList();
Expand Down Expand Up @@ -2610,6 +2612,25 @@ private void UpdateDLLData()
}
}

//todo delete next update
private void MigrateLoaderDLL()
{
try
{
string oldLoaderPath = Path.Combine(App.CurrentGame.modDirectory, App.CurrentGame.loader.name + ".dll");
if (App.CurrentGame.loader.installed == false && File.Exists(App.CurrentGame.loader.dataDllOriginPath) && File.Exists(oldLoaderPath))
{
if (!File.Exists(App.CurrentGame.loader.loaderdllpath))
{
//this will fire the mod loader update and it will download the rest
File.Copy(oldLoaderPath, App.CurrentGame.loader.loaderdllpath);
}

}
}
catch { }
}

private async Task InstallLoader()
{
bool dataDllOrigExist = File.Exists(App.CurrentGame.loader.dataDllOriginPath);
Expand Down Expand Up @@ -2723,6 +2744,7 @@ private async Task HandleLoaderInstall()
App.CurrentGame.loader.installed = !App.CurrentGame.loader.installed;
UIHelper.EnableButton(ref btnInstallLoader);
UpdateBtnInstallLoader_State();

}

#endregion
Expand Down Expand Up @@ -2890,7 +2912,7 @@ private async void ComboGameSelection_SelectionChanged(object sender, SelectionC
suppressEvent = false;
return;
}

Game entry = ComboGameSelection.SelectedItem as Game;

if (entry == GamesInstall.AddGame)
Expand Down

0 comments on commit d0e4db5

Please sign in to comment.