Skip to content

Commit

Permalink
Fixes for thcrap out of the box + dependency order.
Browse files Browse the repository at this point in the history
Changed: Dependencies will now appear only above the patches that depend on them.
Changed: Required thcrap directories will now be created automatically if they do not exist.
  • Loading branch information
David-JonesDVN committed Mar 25, 2020
1 parent 66970dd commit b3230f7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Changed: The profile editor will now fill in missing game profiles with paths th
Changed: You can now set arbitrary names for game profile IDs as long as they don't start with "th".
Changed: Enlarged the custom games list.
Changed: Upgraded to Visual Studio 2017 from 2012. Hopefully shouldn't change anything.
Changed: Dependencies will now appear only above the patches that depend on them.
Changed: Required thcrap directories will now be created automatically if they do not exist.
Fixed: The tray icon's Main Games menu not working (no idea when that broke).
Fixed: thcrap's encoding for patches not using UTF-8.
Fixed: Error if patch directory does not exist.
Expand Down
10 changes: 5 additions & 5 deletions Touhou Launcher/ConfigForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public void Refreshcrap()
}
}
}
foreach (string file in Directory.GetFiles(MainForm.curCfg.crapDir + "\\config", "*.js").Where(n => !n.Contains("games.js") && !n.Contains("config.js")))
foreach (FileInfo file in new DirectoryInfo(MainForm.curCfg.crapDir).CreateSubdirectory("config").GetFiles("*.js").Where(n => n.Name != "games.js" && n.Name != "config.js"))
{
crapCfg.Items.Add(Path.GetFileName(file));
crapCfg.Items.Add(file.Name);
}
}
if (MainForm.curCfg.crapDir != "")
Expand Down Expand Up @@ -373,12 +373,12 @@ private void openAppdata_Click(object sender, EventArgs e)
private void openReplays_Click(object sender, EventArgs e)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.DoNotVerify) + "\\ShanghaiAlice\\th";
if (Directory.Exists(path + (MainForm.idToNumber[game]).ToString("00") + "\\replay"))
if (Directory.Exists(path + MainForm.idToNumber[game].ToString("00") + "\\replay"))
{
Process.Start(path + (MainForm.idToNumber[game]).ToString("00") + "\\replay");
Process.Start(path + MainForm.idToNumber[game].ToString("00") + "\\replay");
return;
}
else if (Directory.Exists(path + (MainForm.idToNumber[game]).ToString("00") + "tr\\replay"))
else if (Directory.Exists(path + MainForm.idToNumber[game].ToString("00") + "tr\\replay"))
{
Process.Start(path + MainForm.idToNumber[game].ToString("00") + "tr\\replay");
return;
Expand Down
6 changes: 4 additions & 2 deletions Touhou Launcher/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ private void LoadSettings()
minimizeToTray.Checked = curCfg.minimizeToTray;
showTray.Checked = curCfg.showTray;
np2Dir.Text = curCfg.np2Dir;
crapDir.Text = curCfg.crapDir + "\\bin\\thcrap_loader.exe";
if (curCfg.crapDir != "")
crapDir.Text = curCfg.crapDir + "\\bin\\thcrap_loader.exe";
crapStartingRepo.Text = curCfg.StartingRepo;
foreach (CheckBox chk in GetAll(randomSettings, typeof(CheckBox)))
{
Expand Down Expand Up @@ -995,7 +996,8 @@ private void Dir_LostFocus(object sender, EventArgs e)
{
((TextBox)sender).BackColor = SystemColors.Window;
curCfg.np2Dir = np2Dir.Text;
curCfg.crapDir = Path.GetDirectoryName(crapDir.Text).TrimEnd("\\bin".ToCharArray());
string crapPath = Path.GetDirectoryName(crapDir.Text);
curCfg.crapDir = Directory.Exists(crapPath + "\\bin") ? crapPath : crapPath.TrimEnd("\\bin".ToCharArray());
curCfg.StartingRepo = crapStartingRepo.Text;
}
else
Expand Down
12 changes: 7 additions & 5 deletions Touhou Launcher/thcrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ private void thcrap_Load(object sender, EventArgs e)
patchStates.Add(patch["archive"].Substring(6));
}
}
foreach (string localRepo in Directory.GetFiles(MainForm.curCfg.crapDir + "\\repos", "repo.js", SearchOption.AllDirectories))
foreach (FileInfo localRepo in new DirectoryInfo(MainForm.curCfg.crapDir).CreateSubdirectory("repos").GetFiles("repo.js", SearchOption.AllDirectories))
{
addRepo(File.ReadAllText(localRepo), true);
addRepo(File.ReadAllText(localRepo.FullName), true);
}
searchRepo(MainForm.curCfg.StartingRepo);
games = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(MainForm.curCfg.crapDir + "\\config\\games.js"));
Expand Down Expand Up @@ -211,16 +211,18 @@ private void onPatchGet(object sender, DownloadStringCompletedEventArgs e)
}
else
repository = dependencySet[0];
addPatch(repository, dependencySet[dependencySet.Length - 1], true);
addPatch(repository, dependencySet[dependencySet.Length - 1], (string)e.UserState + "/" + patch.id + "/");
}
}
}

private void addPatch(string repo, string patch, bool dependency = false)
private void addPatch(string repo, string patch, string dependent = "")
{
if (!patchStates.Contains(repo + "/" + patch + "/"))
{
patchStates.Insert(dependency ? 0 : patchStates.Count, repo + "/" + patch + "/");
int depIndex = patchStates.IndexOf(dependent);
depIndex = depIndex == -1 || dependent == "" ? patchStates.Count : depIndex;
patchStates.Insert(depIndex, repo + "/" + patch + "/");
repoList_SelectedIndexChanged(this, new EventArgs());
}
WebClient wc = new WebClient();
Expand Down

0 comments on commit b3230f7

Please sign in to comment.