Skip to content
This repository was archived by the owner on Apr 30, 2020. It is now read-only.

Commit b73e147

Browse files
committed
Version 6
1 parent 0b0825c commit b73e147

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

CFW2OFW Helper/Program.cs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static class G
2727
static public readonly string makeNpdata = currentDir + "\\make_npdata.exe";
2828
static public readonly string patchPath = currentDir + "\\patch";
2929
static public readonly string DECPath = patchPath + "\\decrypted.data";
30-
static public readonly string version = "5";
30+
static public readonly string version = "6";
3131
static public readonly WebClient wc = new WebClient();
3232
static public void Exit(string msg)
3333
{
@@ -390,7 +390,7 @@ public ProcessArgs(bool exitAfterPatch, string input)
390390
psnID.Append(regionID);
391391
psnID.Append(lowID == "BL" ? "B" : "A");
392392
newID = psnID.ToString() + highID;
393-
Console.Write("Game identified: ");
393+
Console.Write("\nGame identified: ");
394394
Program.Cyan(ID + "\n");
395395
if (!exitAfterPatch)
396396
{
@@ -549,7 +549,7 @@ static void Updates(string ID)
549549
{
550550
try
551551
{
552-
G.xmlDoc.LoadXml(G.wc.DownloadString(new Uri("https://a0.ww.np.dl.playstation.net/tpl/np/" + ID + "/" + ID + "-ver.xml")));
552+
G.xmlDoc.LoadXml(G.wc.DownloadString("https://a0.ww.np.dl.playstation.net/tpl/np/" + ID + "/" + ID + "-ver.xml"));
553553
}
554554
catch (WebException e)
555555
{
@@ -599,13 +599,19 @@ static void GetPatch(KeyValuePair<string, string> entry, string part)
599599
fname = url.Substring(url.LastIndexOf("/", StringComparison.Ordinal) + 1),
600600
path = G.patchPath + "\\" + fname;
601601
bool exists = File.Exists(path);
602-
Console.Write(fname + " ...");
603-
string message = " local";
602+
Console.Write(fname + " ... ");
603+
string message = "local";
604604
if ((exists && GetSHA1(path) != entry.Value) || !exists)
605605
{
606606
if (exists) File.Delete(path);
607-
G.wc.DownloadFile(url, part);
608-
message = " done";
607+
G.wc.DownloadProgressChanged += Wc_DownloadProgressChanged;
608+
G.wc.DownloadFileAsync(new Uri(url), part);
609+
while (G.wc.IsBusy)
610+
{
611+
new System.Threading.ManualResetEvent(false).WaitOne(200);
612+
}
613+
G.wc.DownloadProgressChanged -= Wc_DownloadProgressChanged;
614+
message = "done";
609615
}
610616
if (File.Exists(part)) File.Move(part, path);
611617
G.patchFNames.Enqueue(fname);
@@ -642,6 +648,13 @@ static void GetPatches(string gameName, uint size)
642648
G.Exit("Not all patches were downloaded, please try again");
643649
}
644650

651+
private static void Wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
652+
{
653+
int p = e.ProgressPercentage;
654+
p = p < 100 ? p : 99;
655+
Console.Write("{0:00}%\b\b\b", p);
656+
}
657+
645658
static void ProcessPatches(string outputDir, string ID)
646659
{
647660
string d = " done", f = " failed\n";
@@ -959,6 +972,11 @@ static public void Cyan(string msg)
959972

960973
static void Help()
961974
{
975+
Console.WriteLine("Credits:");
976+
Cyan("mathieulh");
977+
Console.Write(" - PKG code\n");
978+
Cyan("Hykem");
979+
Console.WriteLine(" - make-mpdata\n");
962980
Console.Write("To convert a game, please place the ");
963981
Green("PS3_GAME");
964982
Console.Write(" folder next to this program and run it with no arguments.\n\n" +
@@ -1002,9 +1020,10 @@ static void Main(string[] args)
10021020
WebRequest.DefaultWebProxy = null;
10031021
G.wc.Proxy = null;
10041022
CheckUpdate();
1005-
KeyValuePair<int, int> catOffset, verOffset = new KeyValuePair<int, int>();
1023+
var catOffset = new KeyValuePair<int, int>();
1024+
var verOffset = new KeyValuePair<int, int>();
10061025

1007-
Console.WriteLine($" --- CFW2OFW Helper v{G.version} ---\nThanks to mathieulh for PKG related code!\n");
1026+
Console.WriteLine($" --- CFW2OFW Helper v{G.version} ---");
10081027
switch (args.Length)
10091028
{
10101029
case 0:

0 commit comments

Comments
 (0)