-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9853589
commit b896625
Showing
24 changed files
with
120 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ZenovaLauncher | ||
{ | ||
public class ProfileManager : ObservableCollection<Profile> | ||
{ | ||
public static ProfileManager instance; | ||
|
||
public ProfileManager() | ||
{ | ||
Add(new Profile("Latest release", new MinecraftVersion("1.14.30.2", "uuid"))); | ||
Add(new Profile("Latest beta", new MinecraftVersion("1.16.0.55", "uuid", isBeta: true))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ZenovaLauncher | ||
{ | ||
class VersionManager : ObservableCollection<MinecraftVersion> | ||
{ | ||
public static VersionManager instance; | ||
|
||
private readonly string _cacheFile = "versions.json"; | ||
private readonly HttpClient _client = new HttpClient(); | ||
|
||
public VersionManager() | ||
{ | ||
|
||
} | ||
|
||
private void ParseList(JArray data) | ||
{ | ||
Clear(); | ||
// ([name, uuid, isBeta])[] | ||
foreach (JArray o in data.AsEnumerable().Reverse()) | ||
{ | ||
Add(new MinecraftVersion(o[0].Value<string>(), o[1].Value<string>(), o[2].Value<int>() == 1)); | ||
} | ||
} | ||
|
||
public async Task LoadFromCache() | ||
{ | ||
try | ||
{ | ||
using (var reader = File.OpenText(_cacheFile)) | ||
{ | ||
var data = await reader.ReadToEndAsync(); | ||
ParseList(JArray.Parse(data)); | ||
} | ||
} | ||
catch (FileNotFoundException) | ||
{ // ignore | ||
} | ||
} | ||
|
||
public async Task DownloadList() | ||
{ | ||
var resp = await _client.GetAsync("https://mrarm.io/r/w10-vdb"); | ||
resp.EnsureSuccessStatusCode(); | ||
var data = await resp.Content.ReadAsStringAsync(); | ||
File.WriteAllText(_cacheFile, data); | ||
ParseList(JArray.Parse(data)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters