Skip to content

Commit

Permalink
Add ScummVM (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkashkin committed Nov 10, 2018
1 parent cd8105d commit 187c708
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ GameHub supports non-native games as well as native games for Linux.
It supports multiple [compatibility layers](https://github.com/tkashkin/GameHub/wiki/Compatibility-layers) for non-native games:
* Wine / Proton
* DOSBox
* ScummVM
* RetroArch

It also allows to add custom emulators.
Expand Down
1 change: 1 addition & 0 deletions data/icons/icons.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<file alias="scalable/actions/tool-wine-symbolic.svg">symbolic/tools/wine.svg</file>
<file alias="scalable/actions/tool-dosbox-symbolic.svg">symbolic/tools/dosbox.svg</file>
<file alias="scalable/actions/tool-scummvm-symbolic.svg">symbolic/tools/scummvm.svg</file>

<file alias="scalable/actions/tag.svg">normal/tags/tag.svg</file>

Expand Down
4 changes: 4 additions & 0 deletions data/icons/symbolic/tools/scummvm.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ src/data/compat/Innoextract.vala
src/data/compat/Proton.vala
src/data/compat/Wine.vala
src/data/compat/DOSBox.vala
src/data/compat/ScummVM.vala
src/data/compat/RetroArch.vala
src/data/compat/CustomEmulator.vala
src/ui/windows/MainWindow.vala
Expand Down
2 changes: 1 addition & 1 deletion src/app.vala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace GameHub

GameSources = { new Steam(), new GOG(), new Humble(), new Trove(), new User() };

CompatTool[] tools = { new Compat.CustomScript(), new Compat.CustomEmulator(), new Compat.Innoextract(), new Compat.DOSBox(), new Compat.RetroArch() };
CompatTool[] tools = { new Compat.CustomScript(), new Compat.CustomEmulator(), new Compat.Innoextract(), new Compat.DOSBox(), new Compat.ScummVM(), new Compat.RetroArch() };
foreach(var appid in Compat.Proton.APPIDS)
{
tools += new Compat.Proton(appid);
Expand Down
77 changes: 77 additions & 0 deletions src/data/compat/ScummVM.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
This file is part of GameHub.
Copyright (C) 2018 Anatoliy Kashkin
GameHub is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
GameHub is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GameHub. If not, see <https://www.gnu.org/licenses/>.
*/

using Gee;

using GameHub.Utils;

namespace GameHub.Data.Compat
{
public class ScummVM: CompatTool
{
private static string SCUMMVM_NO_GAMES_WARNING = "WARNING: ScummVM could not find any game";

public string binary { get; construct; default = "scummvm"; }

public ScummVM(string binary="scummvm")
{
Object(binary: binary);
}

construct
{
id = "scummvm";
name = "ScummVM";
icon = "tool-scummvm-symbolic";

executable = Utils.find_executable(binary);
installed = executable != null && executable.query_exists();
}

private bool scummvm_detect(File? dir)
{
if(dir != null && dir.query_exists())
{
var output = Utils.run({ executable.get_path(), "--detect" }, dir.get_path(), null, false, false);
return !(SCUMMVM_NO_GAMES_WARNING in output);
}
return false;
}

public override bool can_run(Runnable runnable)
{
return installed && runnable is Game && runnable.install_dir != null
&& (scummvm_detect(runnable.install_dir) || scummvm_detect(runnable.install_dir.get_child("data")));
}

public override async void run(Runnable runnable)
{
if(!can_run(runnable)) return;

var dir = runnable.install_dir;
var data_dir = runnable.install_dir.get_child("data");

if(!scummvm_detect(dir) && scummvm_detect(data_dir))
{
dir = data_dir;
}

yield Utils.run_thread({ executable.get_path(), "--auto-detect" }, dir.get_path());
}
}
}
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ sources = [
'data/compat/Proton.vala',
'data/compat/Wine.vala',
'data/compat/DOSBox.vala',
'data/compat/ScummVM.vala',
'data/compat/RetroArch.vala',
'data/compat/CustomEmulator.vala',

Expand Down

0 comments on commit 187c708

Please sign in to comment.