forked from MeloNX/MeloNX
Game update path fix
This commit is contained in:
parent
2a7cfa5650
commit
8c6dd455f2
@ -26,7 +26,7 @@ struct UpdateManagerSheet: View {
|
|||||||
Text(item.lastPathComponent)
|
Text(item.lastPathComponent)
|
||||||
.foregroundStyle(Color(uiColor: .label))
|
.foregroundStyle(Color(uiColor: .label))
|
||||||
Spacer()
|
Spacer()
|
||||||
if selectedItem == "\(game!.titleId)/\(item.lastPathComponent)" {
|
if selectedItem == "updates/\(game!.titleId)/\(item.lastPathComponent)" {
|
||||||
Image(systemName: "checkmark.circle.fill")
|
Image(systemName: "checkmark.circle.fill")
|
||||||
.foregroundStyle(Color.accentColor)
|
.foregroundStyle(Color.accentColor)
|
||||||
.font(.system(size: 24))
|
.font(.system(size: 24))
|
||||||
@ -86,7 +86,7 @@ struct UpdateManagerSheet: View {
|
|||||||
let destinationURL = romUpdatedDirectory.appendingPathComponent(url.lastPathComponent)
|
let destinationURL = romUpdatedDirectory.appendingPathComponent(url.lastPathComponent)
|
||||||
try? fileManager.copyItem(at: url, to: destinationURL)
|
try? fileManager.copyItem(at: url, to: destinationURL)
|
||||||
|
|
||||||
items.append(gameInfo.titleId + "/" + url.lastPathComponent)
|
items.append("updates/" + gameInfo.titleId + "/" + url.lastPathComponent)
|
||||||
selectItem(url.lastPathComponent)
|
selectItem(url.lastPathComponent)
|
||||||
Ryujinx.shared.games = Ryujinx.shared.loadGames()
|
Ryujinx.shared.games = Ryujinx.shared.loadGames()
|
||||||
loadJSON(jsonURL!)
|
loadJSON(jsonURL!)
|
||||||
@ -100,7 +100,7 @@ struct UpdateManagerSheet: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func removeUpdate(_ game: URL) {
|
func removeUpdate(_ game: URL) {
|
||||||
let gameString = "\(self.game!.titleId)/\(game.lastPathComponent)"
|
let gameString = "updates/\(self.game!.titleId)/\(game.lastPathComponent)"
|
||||||
paths.removeAll { $0 == game }
|
paths.removeAll { $0 == game }
|
||||||
items.removeAll { $0 == gameString }
|
items.removeAll { $0 == gameString }
|
||||||
|
|
||||||
@ -131,23 +131,25 @@ struct UpdateManagerSheet: View {
|
|||||||
|
|
||||||
func loadJSON(_ json: URL) {
|
func loadJSON(_ json: URL) {
|
||||||
self.jsonURL = json
|
self.jsonURL = json
|
||||||
print("Failed to read JSO")
|
|
||||||
|
|
||||||
guard let jsonURL = jsonURL else { return }
|
guard let jsonURL else { return }
|
||||||
print("Failed to read JSOK")
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let data = try Data(contentsOf: jsonURL)
|
let data = try Data(contentsOf: jsonURL)
|
||||||
if let jsonDict = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
|
if let jsonDict = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
|
||||||
let list = jsonDict["paths"] as? [String]
|
let list = jsonDict["paths"] as? [String]
|
||||||
{
|
{
|
||||||
var urls: [URL] = []
|
|
||||||
|
|
||||||
for path in list {
|
let filteredList = list.filter { relativePath in
|
||||||
urls.append(URL.documentsDirectory.appendingPathComponent("updates").appendingPathComponent(path))
|
let path = URL.documentsDirectory.appendingPathComponent(relativePath)
|
||||||
|
return FileManager.default.fileExists(atPath: path.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
items = list
|
let urls: [URL] = filteredList.map { relativePath in
|
||||||
|
URL.documentsDirectory.appendingPathComponent(relativePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
items = filteredList
|
||||||
paths = urls
|
paths = urls
|
||||||
selectedItem = jsonDict["selected"] as? String
|
selectedItem = jsonDict["selected"] as? String
|
||||||
}
|
}
|
||||||
@ -171,9 +173,9 @@ struct UpdateManagerSheet: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func selectItem(_ item: String) {
|
func selectItem(_ item: String) {
|
||||||
let newSelection = "\(game!.titleId)/\(item)"
|
let newSelection = "updates/\(game!.titleId)/\(item)"
|
||||||
|
|
||||||
guard let jsonURL = jsonURL else { return }
|
guard let jsonURL else { return }
|
||||||
|
|
||||||
do {
|
do {
|
||||||
let data = try Data(contentsOf: jsonURL)
|
let data = try Data(contentsOf: jsonURL)
|
||||||
@ -183,7 +185,7 @@ struct UpdateManagerSheet: View {
|
|||||||
jsonDict["selected"] = ""
|
jsonDict["selected"] = ""
|
||||||
selectedItem = ""
|
selectedItem = ""
|
||||||
} else {
|
} else {
|
||||||
jsonDict["selected"] = newSelection
|
jsonDict["selected"] = "\(newSelection)"
|
||||||
selectedItem = newSelection
|
selectedItem = newSelection
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,7 +752,7 @@ namespace Ryujinx.Headless.SDL2
|
|||||||
if (File.Exists(titleUpdateMetadataPath))
|
if (File.Exists(titleUpdateMetadataPath))
|
||||||
{
|
{
|
||||||
string updatePathRelative = JsonHelper.DeserializeFromFile(titleUpdateMetadataPath, _titleSerializerContext.TitleUpdateMetadata).Selected;
|
string updatePathRelative = JsonHelper.DeserializeFromFile(titleUpdateMetadataPath, _titleSerializerContext.TitleUpdateMetadata).Selected;
|
||||||
updatePath = Path.Combine(AppDataManager.BaseDirPath, "updates", updatePathRelative);
|
updatePath = Path.Combine(AppDataManager.BaseDirPath, updatePathRelative);
|
||||||
|
|
||||||
if (File.Exists(updatePath))
|
if (File.Exists(updatePath))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user