Commit 4fb67164 authored by Adrien Plazas's avatar Adrien Plazas
Browse files

playstation-portable: Use thumbnails as covers

parent 7074e3f5
Pipeline #300656 failed with stage
in 33 minutes and 54 seconds
......@@ -111,6 +111,7 @@ vala_sources = [
'platforms/playstation/playstation-header.vala',
'platforms/playstation/playstation-parser.vala',
'platforms/playstation-portable/playstation-portable-cover.vala',
'platforms/playstation-portable/playstation-portable-error.vala',
'platforms/playstation-portable/playstation-portable-header.vala',
'platforms/playstation-portable/playstation-portable-parser.vala',
......
// This file is part of Highscore. License: GPL-3.0+.
public class Highscore.PlayStationPortableCover : Object, Cover {
private const string THUMBNAIL_PATH = "psp_game/icon0.png";
private Uri uri;
private string uid;
private File? file;
private string cover_path;
public PlayStationPortableCover (Uri uri, string uid) {
this.uri = uri;
this.uid = uid;
}
public File? get_cover () {
if (file != null)
return file;
try {
load_cover ();
}
catch (Error e) {
warning (e.message);
return file;
}
if (file != null)
return file;
var uri_file = uri.to_file ();
try {
file = Iso.read_iso_file (uri_file.get_path (), THUMBNAIL_PATH, cover_path);
}
catch (Error e) {
warning (e.message);
}
return file;
}
private string get_cover_path () throws Error {
if (cover_path != null)
return cover_path;
var dir = Application.get_covers_dir ();
cover_path = @"$dir/$uid.thumbnail";
return cover_path;
}
private void load_cover () throws Error {
var cover_path = get_cover_path ();
if (!FileUtils.test (cover_path, FileTest.EXISTS))
return;
file = File.new_for_path (cover_path);
changed ();
}
public Gdk.RGBA get_background_color () {
return { 0.0f, 0.0f, 0.0f, 1.0f };
}
}
......@@ -2,6 +2,7 @@
public class Highscore.PlayStationPortableParser : GameParser {
private string uid;
private Cover cover;
public PlayStationPortableParser (Platform platform, Uri uri) {
base (platform, uri);
......@@ -16,9 +17,15 @@ public class Highscore.PlayStationPortableParser : GameParser {
var product_number = header.get_product_number ();
uid = @"$prefix-$product_number".down ();
cover = new PlayStationPortableCover (uri, uid);
}
public override string get_uid () {
return uid;
}
public override Cover? get_cover () {
return cover;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment