Commit 71c3dbff authored by Andrei Lisita's avatar Andrei Lisita 🎮

runner: Add preview_savestate()

parent 993a000e
......@@ -59,6 +59,9 @@ public class Games.CommandRunner : Object, Runner {
public void preview_current_state () {
}
public void preview_savestate (Savestate savestate) {
}
public void start () throws Error {
string? working_directory = null;
string[]? envp = null;
......
......@@ -21,6 +21,7 @@ public interface Games.Runner : Object {
public abstract void capture_current_state_pixbuf ();
public abstract void preview_current_state ();
public abstract void preview_savestate (Savestate savestate);
public abstract bool try_create_savestate (bool is_automatic);
public abstract void load_savestate (Savestate savestate) throws Error;
......
......@@ -46,6 +46,9 @@ private class Games.DummyRunner : Object, Runner {
public void preview_current_state () {
}
public void preview_savestate (Savestate savestate) {
}
public void start () throws Error {
}
......
......@@ -45,9 +45,11 @@ public class Games.RetroRunner : Object, Runner {
private InputCapabilities input_capabilities;
private Settings settings;
private Title game_title;
private Savestate[] game_savestates;
private Savestate latest_savestate;
private Savestate tmp_live_savestate;
private Savestate previewed_savestate;
private Gdk.Pixbuf current_state_pixbuf;
......@@ -158,6 +160,24 @@ public class Games.RetroRunner : Object, Runner {
view.set_pixbuf (current_state_pixbuf);
}
public void preview_savestate (Savestate savestate) {
previewed_savestate = savestate;
var screenshot_path = savestate.get_screenshot_path ();
Gdk.Pixbuf pixbuf = null;
// Treat errors locally because loading the savestate screenshot is not
// a critical operation
try {
pixbuf = new Gdk.Pixbuf.from_file (screenshot_path);
}
catch (Error e) {
warning ("Couldn't load %s: %s", screenshot_path, e.message);
}
view.set_pixbuf (pixbuf);
}
public virtual Gtk.Widget? get_extra_widget () {
return null;
}
......
Markdown is supported
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