pixeltris / YgoMaster

Offline Yu-Gi-Oh! Master Duel
MIT License
839 stars 122 forks source link

Convenience issue: Two exe files must be run to start the offline client. #24

Closed RndUser0 closed 2 years ago

RndUser0 commented 2 years ago

It would be more convenient if YgoMasterClient.exe would start YgoMaster.exe automatically if it's not already running.

I wrote this batch script for that:

@echo off

C:
cd\Program Files (x86)\Steam\SteamApps\common\Yu-Gi-Oh!  Master Duel\Build

tasklist /fi "imagename eq YgoMaster.exe" |find ":" > nul
if not errorlevel 1 start "YGO Master" /B YgoMaster.exe

tasklist /fi "imagename eq YgoMasterClient.exe" |find ":" > nul
if not errorlevel 1 start "YGO Master Client" /B YgoMasterClient.exe
pixeltris commented 2 years ago

I could add something similar before this line of code to check for the YgoMaster.exe process and launch it if it doesn't exist. I'll look at doing that for the next update.

https://github.com/pixeltris/YgoMaster/blob/7b5e3ecb1a1afd9d7d2cd8a31a747816f87a32d7/YgoMasterClient/Program.cs#L54

RndUser0 commented 2 years ago

OK, thanks :)

justAFleetingTumbleweed commented 2 years ago

It would be more convenient if YgoMasterClient.exe would start YgoMaster.exe automatically if it's not already running.

I wrote this batch script for that:

@echo off

C:
cd\Program Files (x86)\Steam\SteamApps\common\Yu-Gi-Oh!  Master Duel\Build

tasklist /fi "imagename eq YgoMaster.exe" |find ":" > nul
if not errorlevel 1 start "YGO Master" /B YgoMaster.exe

tasklist /fi "imagename eq YgoMasterClient.exe" |find ":" > nul
if not errorlevel 1 start "YGO Master Client" /B YgoMasterClient.exe

Same scenario, my friends and I struggling of opening 2 executables to run the Offline YGO, I wrote also mine 2 weeks ago that can launch both executables, and when closed the other one will close also. because my friends are just asking me since they lack of knowledge in this kind of topic, we will gladly appreciate for implementing it on your next update

@echo off
mode con: cols=97 lines=21

echo Offline Yu-Gi-Oh! Master Duel Game Launcher
timeout 3 >nul
cls
echo Checks if the Offline Server Console is already running.
tasklist /nh /fi "imagename eq YgoMaster.exe" | find /i "YgoMaster.exe" >nul
if not errorlevel 1 cls && echo It seems that the Offline Yu-Gi-Oh! Master Duel is improperly closed in it's last session. && timeout 2 >nul && cls && echo The Offline Server Console is running! && timeout 2 >nul && goto RestartIt
timeout 1 >nul
cls
echo Checks if the Offline Server Console is already running..
tasklist /nh /fi "imagename eq YgoMaster.exe" | find /i "YgoMaster.exe" >nul
if not errorlevel 1 cls && echo It seems that the Offline Yu-Gi-Oh! Master Duel is improperly closed in it's last session. && timeout 2 >nul && cls && echo The Offline Server Console is running! && timeout 2 >nul && goto RestartIt
timeout 1 >nul
cls
goto ItsNotRunning

:ItsNotRunning
cls
echo Nope!
timeout 2 >nul
cls
goto LaunchIt

:LaunchIt
cls
echo The Offline Yu-Gi-Oh! Master Duel is gonna start.
timeout 1 >nul
cls
echo The Offline Yu-Gi-Oh! Master Duel is gonna start..
timeout 1 >nul
cls
echo Launching the Offline Server Console.
start /min YgoMaster.exe
timeout 1 >nul
cls
echo Launching Offline Yu-Gi-Oh! Master Duel.
start YgoMasterClient.exe
timeout 1 >nul
cls
goto Waiting

:Waiting
cls
echo Gonna wait for Offline Yu-Gi-Oh! Master Duel to be launched properly before monitoring it.
timeout 1 >nul
tasklist /nh /fi "imagename eq masterduel.exe" | find /i "masterduel.exe" >nul
if not errorlevel 1 goto WatchIt
cls
echo Gonna wait for Offline Yu-Gi-Oh! Master Duel to be launched properly before monitoring it..
timeout 1 >nul
tasklist /nh /fi "imagename eq masterduel.exe" | find /i "masterduel.exe" >nul
if not errorlevel 1 goto WatchIt
cls
echo Gonna wait for Offline Yu-Gi-Oh! Master Duel to be launched properly before monitoring it...
timeout 1 >nul
tasklist /nh /fi "imagename eq masterduel.exe" | find /i "masterduel.exe" >nul
if not errorlevel 1 goto WatchIt
cls
goto Waiting

:WatchIt
cls
echo Monitoring Offline Yu-Gi-Oh! Master Duel if it's being closed by the user.
tasklist /nh /fi "imagename eq masterduel.exe" | find /i "masterduel.exe" >nul
if errorlevel 1 cls && echo It seems that Offline Yu-Gi-Oh! Master Duel is being closed by the user && timeout 2 >nul && goto KillIt
timeout 1 >nul
cls
echo Monitoring Offline Yu-Gi-Oh! Master Duel if it's being closed by the user..
tasklist /nh /fi "imagename eq masterduel.exe" | find /i "masterduel.exe" >nul
if errorlevel 1 cls && echo It seems that Offline Yu-Gi-Oh! Master Duel is being closed by the user && timeout 2 >nul && goto KillIt
timeout 1 >nul
cls
echo Monitoring Offline Yu-Gi-Oh! Master Duel if it's being closed by the user...
tasklist /nh /fi "imagename eq masterduel.exe" | find /i "masterduel.exe" >nul
if errorlevel 1 cls && echo It seems that Offline Yu-Gi-Oh! Master Duel is being closed by the user && timeout 2 >nul && goto KillIt
timeout 1 >nul
cls
if not errorlevel 1 goto WatchIt

:KillIt
cls
echo Terminating the Offline Server Console.
timeout 1 >nul
cls
echo Terminating the Offline Server Console..
timeout 1 >nul
taskkill /im YgoMaster.exe /f >nul

tasklist /nh /fi "imagename eq YgoMaster.exe" | find /i "YgoMaster.exe" >nul
cls
if errorlevel 1 echo The Offline Server Console is properly terminated! && timeout 2 >nul && goto Termination
if not errorlevel 1 echo The Offline Server Console is still running! && timeout 2 >nul && goto KillIt

:RestartIt
cls
echo Restarting the Offline Server Console.
timeout 1 >nul
cls
echo Restarting the Offline Server Console..
timeout 1 >nul
cls
taskkill /im YgoMaster.exe /f >nul

tasklist /nh /fi "imagename eq YgoMaster.exe" | find /i "YgoMaster.exe" >nul
cls
if errorlevel 1 echo The Offline Server Console is properly restarted! && timeout 2 >nul && cls && echo Restarting the Launcher. && timeout 1 >nul && cls && echo Restarting the Launcher.. && timeout 1 >nul && cls && goto LaunchIt
if not errorlevel 1 echo The Offline Server Console is still running! && timeout 2 >nul && goto RestartIt

:Termination
cls
echo The Game Launcher is going to end.
timeout 1 >nul
cls
echo The Game Launcher is going to end..
timeout 1 >nul
cls
exit
pixeltris commented 2 years ago

Added in v1.5 (commit https://github.com/pixeltris/YgoMaster/commit/fe9aa117fd3ea0318d189afbd9a3b7160b4549d6). It will auto run YgoMaster.exe when you run YgoMasterClient.exe. Currently this isn't done as a sub process so YgoMaster wont auto close when YgoMasterClient closes. I might eventually change this logic, but for now it stays as is.