Skip to content

Commit

Permalink
Merge pull request #132 from Kapiainen/galaxy-arguments
Browse files Browse the repository at this point in the history
Updated GOG Galaxy support
  • Loading branch information
Kapiainen authored May 30, 2018
2 parents 25d191e + 24bb316 commit d9160e8
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 23 deletions.
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
**Version 3.0.3 - 2018/05/30:**
- Updated GOG Galaxy support to include arguments in the paths of games.

**Version 3.0.2 - 2018/05/30:**
- Updated to support the latest version of GOG Galaxy.

Expand Down
7 changes: 2 additions & 5 deletions dist/@Resources/game/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -398,12 +398,9 @@ createProperties = function(game, platform)
end,
update = f
}))
local path = game:getPath()
local action = nil
if path:startsWith('"') and path:endsWith('"') then
path = path:sub(2, -2)
end
if io.fileExists(path, false) then
local path = game:getPath():match('"(.-)"')
if path ~= nil and io.fileExists(path, false) then
local head, tail = io.splitPath(path)
if head ~= nil then
action = function(self, index)
Expand Down
36 changes: 28 additions & 8 deletions dist/@Resources/main/platforms/gog_galaxy/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,31 @@ do
getExePath = function(self, info)
assert(type(info) == 'table', 'main.platforms.gog_galaxy.init.GOGGalaxy.getExePath')
if type(info.playTasks) ~= 'table' then
return nil
return nil, nil
end
if type(info.playTasks[1]) ~= 'table' then
return nil
local task = nil
local _list_0 = info.playTasks
for _index_0 = 1, #_list_0 do
local t = _list_0[_index_0]
if t.isPrimary == true then
task = t
break
end
end
if type(info.playTasks[1].path) ~= 'string' then
return nil
if task == nil then
if type(info.playTasks[1]) ~= 'table' then
return nil, nil
end
if type(info.playTasks[1].path) ~= 'string' then
return nil, nil
end
task = info.playTasks[1]
end
local path = (task.path:gsub('//', '\\'))
if task.arguments ~= nil then
return path, task.arguments
end
return (info.playTasks[1].path:gsub('//', '\\'))
return path, nil
end,
generateGames = function(self, indexOutput, galaxyOutput)
assert(type(indexOutput) == 'string', 'main.platforms.gog_galaxy.init.GOGGalaxy.generateGames')
Expand All @@ -129,7 +145,7 @@ do
_continue_0 = true
break
end
local exePath = self:getExePath(info)
local exePath, arguments = self:getExePath(info)
if type(exePath) ~= 'string' then
log('Skipping GOG Galaxy game', productID, 'because the path to the executable could not be found')
_continue_0 = true
Expand All @@ -144,7 +160,11 @@ do
if not (io.fileExists(fullPath, false)) then
path = nil
else
path = ('"%s"'):format(fullPath)
if arguments == nil then
path = ('"%s"'):format(fullPath)
else
path = ('"%s" "%s"'):format(fullPath, arguments)
end
end
end
local title = titles[productID]
Expand Down
6 changes: 2 additions & 4 deletions src/game/init.moon
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,9 @@ createProperties = (game, platform) ->
})
)
-- Path
path = game\getPath()
action = nil
if path\startsWith('"') and path\endsWith('"')
path = path\sub(2, -2)
if io.fileExists(path, false)
path = game\getPath()\match('"(.-)"')
if path ~= nil and io.fileExists(path, false)
head, tail = io.splitPath(path)
if head ~= nil
action = (index) =>
Expand Down
25 changes: 19 additions & 6 deletions src/main/platforms/gog_galaxy/init.moon
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,20 @@ class GOGGalaxy extends Platform

getExePath: (info) =>
assert(type(info) == 'table', 'main.platforms.gog_galaxy.init.GOGGalaxy.getExePath')
return nil if type(info.playTasks) ~= 'table'
return nil if type(info.playTasks[1]) ~= 'table'
return nil if type(info.playTasks[1].path) ~= 'string'
return (info.playTasks[1].path\gsub('//', '\\'))
return nil, nil if type(info.playTasks) ~= 'table'
task = nil
for t in *info.playTasks
if t.isPrimary == true
task = t
break
if task == nil
return nil, nil if type(info.playTasks[1]) ~= 'table'
return nil, nil if type(info.playTasks[1].path) ~= 'string'
task = info.playTasks[1]
path = (task.path\gsub('//', '\\'))
if task.arguments ~= nil
return path, task.arguments
return path, nil

-- TODO: Refactor to allow for tests
generateGames: (indexOutput, galaxyOutput) =>
Expand All @@ -127,7 +137,7 @@ class GOGGalaxy extends Platform
if type(info) ~= 'table'
log('Skipping GOG Galaxy game', productID, 'because the info file could not be found')
continue
exePath = @getExePath(info)
exePath, arguments = @getExePath(info)
if type(exePath) ~= 'string'
log('Skipping GOG Galaxy game', productID, 'because the path to the executable could not be found')
continue
Expand All @@ -139,7 +149,10 @@ class GOGGalaxy extends Platform
unless io.fileExists(fullPath, false)
nil
else
('"%s"')\format(fullPath)
if arguments == nil
('"%s"')\format(fullPath)
else
('"%s" "%s"')\format(fullPath, arguments)
title = titles[productID]
if title == nil
log('Skipping GOG Galaxy game', productID, 'because title could not be found')
Expand Down

0 comments on commit d9160e8

Please sign in to comment.