@@ -7,7 +7,7 @@ const { getAllModsMetadata,
77 getRequiredModsVersionInfo,
88 patchMods,
99 getGameDirectorySync,
10- // waitForGameLaunch,
10+ // waitForGameLaunch,
1111 killGameProcess,
1212 openIsaacSocketUtility } = require ( "./env" ) ;
1313
@@ -63,11 +63,47 @@ const isPortTaken = (port) => {
6363 }
6464 initServer ( PORT ) ;
6565 win = createMainWindow ( ) ;
66+
67+ let gameDir ;
68+ try {
69+ gameDir = await getGameDirectorySync ( ) ;
70+ }
71+ catch ( e ) {
72+ dialog . showMessageBoxSync ( {
73+ title : "错误" ,
74+ message : `无法获取游戏目录,请检查IsaacBoxUtility.exe是否被杀毒软件删除或限制访问` ,
75+ type : "error"
76+ } )
77+ return ;
78+ }
79+
80+ let mods ;
81+ try {
82+ mods = await getAllModsMetadata ( gameDir ) ;
83+ } catch ( e ) {
84+ dialog . showMessageBoxSync ( {
85+ title : "错误" ,
86+ message : `无法获取MOD信息` ,
87+ type : "error"
88+ } )
89+ return ;
90+ }
91+
92+ let requiredMods ;
93+ try {
94+ requiredMods = await getRequiredModsVersionInfo ( mods ) ;
95+ } catch ( e ) {
96+ dialog . showMessageBoxSync ( {
97+ title : "错误" ,
98+ message : `无法获取所需MOD信息` ,
99+ type : "error"
100+ } )
101+ return ;
102+ }
103+
104+ let isPatched ;
66105 try {
67- const gameDir = await getGameDirectorySync ( ) ;
68- const mods = await getAllModsMetadata ( gameDir ) ;
69- const requiredMods = await getRequiredModsVersionInfo ( mods ) ;
70- const isPatched = await patchMods ( gameDir , requiredMods )
106+ isPatched = await patchMods ( gameDir , requiredMods )
71107 if ( isPatched ) {
72108 await killGameProcess ( ) ;
73109 dialog . showMessageBox ( {
@@ -76,9 +112,25 @@ const isPortTaken = (port) => {
76112 message : "所需MOD已经为您安装完成,请您手动重新启动游戏"
77113 } )
78114 }
79- openIsaacSocketUtility ( ) ;
80- } catch ( error ) {
81- console . log ( error ) ;
115+ } catch ( e ) {
116+ dialog . showMessageBoxSync ( {
117+ title : "错误" ,
118+ message : `无法安装所需MOD` ,
119+ type : "error"
120+ } )
121+ return ;
122+ }
123+
124+ try {
125+ await openIsaacSocketUtility ( ) ;
126+ }
127+ catch ( e ) {
128+ dialog . showMessageBoxSync ( {
129+ title : "错误" ,
130+ message : `无法打开IsaacSocket连接工具,请检查.NET环境是否安装,IsaacSocketUtility.exe是否被杀毒软件删除或限制访问,IsaacBoxUtility.exe,或者请以管理员权限打开。` ,
131+ type : "error"
132+ } )
133+ return ;
82134 }
83135} ) ( ) ;
84136
0 commit comments