aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.WinForms/Applications/Downloader.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-02-26 15:57:04 -0500
committerMichael <[email protected]>2017-02-26 15:57:09 -0500
commit82a5ca296bb6b4fe000b46af187fb41282e6bd62 (patch)
treeec53d13ae88a171d2e5e11e3bc2aece6481a3c3c /ShiftOS.WinForms/Applications/Downloader.cs
parentec61f5dfe9de92470cd91269c77713549e7d6159 (diff)
downloadshiftos_thereturn-82a5ca296bb6b4fe000b46af187fb41282e6bd62.tar.gz
shiftos_thereturn-82a5ca296bb6b4fe000b46af187fb41282e6bd62.tar.bz2
shiftos_thereturn-82a5ca296bb6b4fe000b46af187fb41282e6bd62.zip
Increase shiftletters payout (and shiftnet sub stuff)
Diffstat (limited to 'ShiftOS.WinForms/Applications/Downloader.cs')
-rw-r--r--ShiftOS.WinForms/Applications/Downloader.cs44
1 files changed, 42 insertions, 2 deletions
diff --git a/ShiftOS.WinForms/Applications/Downloader.cs b/ShiftOS.WinForms/Applications/Downloader.cs
index ec071d2..b1b7ed9 100644
--- a/ShiftOS.WinForms/Applications/Downloader.cs
+++ b/ShiftOS.WinForms/Applications/Downloader.cs
@@ -167,14 +167,33 @@ namespace ShiftOS.WinForms.Applications
}
}
+ /// <summary>
+ /// Gets a Shiftnet download speed in bytes based on the user's subscription.
+ /// </summary>
+ /// <returns>Download speed in bytes.</returns>
+ public static int GetDownloadSpeed()
+ {
+ switch (SaveSystem.CurrentSave.ShiftnetSubscription)
+ {
+ case 0:
+ return 256/*B*/;
+ case 1:
+ return 1024 * 1024/*KB*/;
+ case 2:
+ return 1024 * 10240/*KB*/;
+ case 3:
+ return 1024 * 1024 * 1024/*MB*/;
+ }
+ return 256;
+ }
+
public static void StartDownload(Download down)
{
var t = new Thread(() =>
{
- int byteWrite = 256;
_downloads.Add(down);
DownloadStarted?.Invoke(down);
- for (int i = 0; i < down.Bytes.Length; i += byteWrite)
+ for (int i = 0; i < down.Bytes.Length; i += GetDownloadSpeed())
{
Thread.Sleep(1000);
_downloads[_downloads.IndexOf(down)].Progress = (int)((float)(i / down.Bytes.Length) * 100);
@@ -197,4 +216,25 @@ namespace ShiftOS.WinForms.Applications
public byte[] Bytes { get; set; }
public int Progress { get; set; }
}
+
+ [Namespace("dev")]
+ public static class DownloaderDebugCommands
+ {
+ [Command("setsubscription", description ="Use to set the current shiftnet subscription.", usage ="{value:int32}")]
+ [RequiresArgument("value")]
+ public static bool SetShiftnetSubscription(Dictionary<string, object> args)
+ {
+ int val = 0;
+ if(int.TryParse(args["value"].ToString(), out val) == true)
+ {
+ SaveSystem.CurrentSave.ShiftnetSubscription = val;
+ SaveSystem.SaveGame();
+ }
+ else
+ {
+ Console.WriteLine("Not a valid 32-bit integer.");
+ }
+ return true;
+ }
+ }
}