@@ -9,120 +9,122 @@ import { isMac } from 'backend/constants/environment'
99import { LibraryManager } from 'common/types/game_manager'
1010
1111export default class SideloadLibraryManager implements LibraryManager {
12- init = ( ) => Promise . resolve ( )
13-
14- addNewApp ( {
15- app_name,
16- title,
17- install : { executable, platform } ,
18- art_cover,
19- art_square,
20- browserUrl,
21- is_installed = true ,
22- description,
23- customUserAgent,
24- launchFullScreen
25- } : GameInfo ) : void {
26- const game : GameInfo = {
27- runner : 'sideload' ,
12+ init = ( ) => Promise . resolve ( )
13+
14+ addNewApp ( {
2815 app_name,
2916 title,
30- install : {
31- executable,
32- platform,
33- is_dlc : false
34- } ,
35- folder_name : executable !== undefined ? dirname ( executable ) : undefined ,
17+ install : { executable, platform } ,
3618 art_cover,
37- is_installed : is_installed !== undefined ? is_installed : true ,
3819 art_square,
39- canRunOffline : ! browserUrl ,
4020 browserUrl,
21+ is_installed = true ,
4122 description,
4223 customUserAgent,
4324 launchFullScreen
25+ } : GameInfo ) : void {
26+ const game : GameInfo = {
27+ runner : 'sideload' ,
28+ app_name,
29+ title,
30+ install : {
31+ executable,
32+ platform,
33+ is_dlc : false
34+ } ,
35+ folder_name : executable !== undefined ? dirname ( executable ) : undefined ,
36+ art_cover,
37+ is_installed : is_installed !== undefined ? is_installed : true ,
38+ art_square,
39+ canRunOffline : ! browserUrl ,
40+ browserUrl,
41+ description,
42+ customUserAgent,
43+ launchFullScreen
44+ }
45+
46+ if ( isMac && executable ?. endsWith ( '.app' ) ) {
47+ const macAppExecutable = readdirSync (
48+ join ( executable , 'Contents' , 'MacOS' )
49+ ) [ 0 ]
50+ game . install . executable = join (
51+ executable ,
52+ 'Contents' ,
53+ 'MacOS' ,
54+ macAppExecutable
55+ )
56+ }
57+
58+ const current = libraryStore . get ( 'games' , [ ] )
59+
60+ const gameIndex = current . findIndex ( ( value ) => value . app_name === app_name )
61+
62+ // edit app in case it exists
63+ if ( gameIndex !== - 1 ) {
64+ current [ gameIndex ] = { ...current [ gameIndex ] , ...game }
65+ } else {
66+ current . push ( game )
67+ addShortcuts ( game )
68+ }
69+
70+ libraryStore . set ( 'games' , current )
71+
72+ sendFrontendMessage ( 'refreshLibrary' , 'sideload' )
73+
74+ return
4475 }
4576
46- if ( isMac && executable ?. endsWith ( '.app' ) ) {
47- const macAppExecutable = readdirSync (
48- join ( executable , 'Contents' , 'MacOS' )
49- ) [ 0 ]
50- game . install . executable = join (
51- executable ,
52- 'Contents' ,
53- 'MacOS' ,
54- macAppExecutable
55- )
77+ installState ( ) {
78+ logWarning ( `installState not implemented on Sideload Library Manager` )
5679 }
5780
58- const current = libraryStore . get ( 'games' , [ ] )
59-
60- const gameIndex = current . findIndex ( ( value ) => value . app_name === app_name )
61-
62- // edit app in case it exists
63- if ( gameIndex !== - 1 ) {
64- current [ gameIndex ] = { ...current [ gameIndex ] , ...game }
65- } else {
66- current . push ( game )
67- addShortcuts ( game )
81+ async refresh ( ) {
82+ logWarning ( `refresh not implemented on Sideload Library Manager` )
83+ return null
6884 }
6985
70- libraryStore . set ( 'games' , current )
71-
72- sendFrontendMessage ( 'refreshLibrary' , 'sideload' )
73-
74- return
75- }
76-
77- installState ( ) {
78- logWarning ( `installState not implemented on Sideload Library Manager` )
79- }
80-
81- async refresh ( ) {
82- logWarning ( `refresh not implemented on Sideload Library Manager` )
83- return null
84- }
85-
86- getGameInfo ( ) : GameInfo {
87- logWarning ( `getGameInfo not implemented on Sideload Library Manager` )
88- return {
89- app_name : '' ,
90- runner : 'sideload' ,
91- art_cover : '' ,
92- art_square : '' ,
93- install : { } ,
94- is_installed : false ,
95- title : '' ,
96- canRunOffline : false
86+ getGameInfo ( ) : GameInfo {
87+ logWarning ( `getGameInfo not implemented on Sideload Library Manager` )
88+ return {
89+ app_name : '' ,
90+ runner : 'sideload' ,
91+ art_cover : '' ,
92+ art_square : '' ,
93+ install : { } ,
94+ is_installed : false ,
95+ title : '' ,
96+ canRunOffline : false
97+ }
9798 }
98- }
9999
100- async listUpdateableGames ( ) : Promise < string [ ] > {
101- logWarning ( `listUpdateableGames not implemented on Sideload Library Manager` )
102- return [ ]
103- }
100+ async listUpdateableGames ( ) : Promise < string [ ] > {
101+ logWarning (
102+ `listUpdateableGames not implemented on Sideload Library Manager`
103+ )
104+ return [ ]
105+ }
104106
105- async runRunnerCommand ( ) : Promise < ExecResult > {
106- logWarning ( `runRunnerCommand not implemented on Sideload Library Manager` )
107- return { stdout : '' , stderr : '' }
108- }
107+ async runRunnerCommand ( ) : Promise < ExecResult > {
108+ logWarning ( `runRunnerCommand not implemented on Sideload Library Manager` )
109+ return { stdout : '' , stderr : '' }
110+ }
109111
110- async changeGameInstallPath ( ) : Promise < void > {
111- logWarning (
112- `changeGameInstallPath not implemented on Sideload Library Manager`
113- )
114- }
112+ async changeGameInstallPath ( ) : Promise < void > {
113+ logWarning (
114+ `changeGameInstallPath not implemented on Sideload Library Manager`
115+ )
116+ }
115117
116- async getInstallInfo ( ) : Promise < undefined > {
117- logWarning ( `getInstallInfo not implemented on Sideload Library Manager` )
118- return undefined
119- }
118+ async getInstallInfo ( ) : Promise < undefined > {
119+ logWarning ( `getInstallInfo not implemented on Sideload Library Manager` )
120+ return undefined
121+ }
120122
121- getLaunchOptions = ( ) => [ ]
123+ getLaunchOptions = ( ) => [ ]
122124
123- changeVersionPinnedStatus ( ) {
124- logWarning (
125- 'changeVersionPinnedStatus not implemented on Sideload Library Manager'
126- )
127- }
125+ changeVersionPinnedStatus ( ) {
126+ logWarning (
127+ 'changeVersionPinnedStatus not implemented on Sideload Library Manager'
128+ )
129+ }
128130}
0 commit comments