Skip to content

Commit 337ecb5

Browse files
committed
Add Installation and exe for windows
1 parent 230656e commit 337ecb5

File tree

5 files changed

+23
-12
lines changed

5 files changed

+23
-12
lines changed

assets/js/script.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ document.addEventListener('keydown', ev => {
450450
}
451451
})
452452

453-
const host = 'ws://0.0.0.0:8009/websockets.php'
453+
const host = 'ws://127.0.0.1:8009/websockets.php'
454454
const socket = new WebSocket(host)
455455

456456
// Event handler bindings

dmplayer.bat

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
@echo off
2+
:: echo Starting local Dungeon Master Player server...
23
:: start servers
3-
start /B php -S localhost:8008 -q
4-
start /B php websockets.php -q
4+
start /B "" php -S localhost:8008 -c php.ini -q >NUL 2>&1
5+
start /B "" php -f ./websockets.php -c php.ini -q >NUL 2>&1
6+
57

68
:: Open default browser
79
start http://localhost:8008
@@ -11,8 +13,7 @@ start http://localhost:8008
1113
timeout /T 1 >nul
1214
if exist "stopserver" (
1315
del stopserver
14-
taskkill /F /IM "php websockets.php -q"
15-
taskkill /F /IM "php -S localhost:8008 -q"
16+
taskkill /F /IM php.exe >nul 2>&1
1617
exit /B
1718
)
1819
goto loop

install-php.bat

+14-4
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,31 @@ set "phpDownloadUrl=https://windows.php.net/downloads/releases/latest/php-8.2-nt
66
set "phpZipFile=php.zip"
77
set "phpExtractDir=php"
88

9+
REM Check if PHP folder exists and delete it
10+
if exist "%phpExtractDir%" (
11+
echo Deleting existing PHP folder...
12+
rmdir /S /Q "%phpExtractDir%"
13+
)
14+
15+
REM Get the current script directory
16+
for %%I in ("%~dp0") do set "scriptDir=%%~fI"
17+
918
REM Download PHP
1019
echo Downloading PHP...
11-
powershell -Command "(New-Object System.Net.WebClient).DownloadFile('%phpDownloadUrl%', '%phpZipFile%')"
20+
powershell -Command "Invoke-WebRequest -Uri '%phpDownloadUrl%' -OutFile '%scriptDir%\%phpZipFile%'"
1221

1322
REM Extract PHP
1423
echo Extracting PHP...
15-
powershell -Command "Expand-Archive -Path '%phpZipFile%' -DestinationPath '%phpExtractDir%' -Force"
24+
powershell -Command "Expand-Archive -Path '%scriptDir%\%phpZipFile%' -DestinationPath '%scriptDir%\%phpExtractDir%' -Force"
1625

1726
REM Add PHP directory to PATH
1827
echo Adding PHP directory to PATH...
19-
setx PATH "%cd%\%phpExtractDir%\;%PATH%" /M
28+
set "phpPath=%scriptDir%%phpExtractDir%"
29+
setx PATH "%phpPath%;%PATH%" /M
2030

2131
REM Cleanup
2232
echo Cleanup...
23-
del "%phpZipFile%"
33+
del "%scriptDir%\%phpZipFile%"
2434

2535
echo PHP installation completed.
2636

readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ On Windows, use dmplayer.bat (coming soon)<br>
2323
On Linux and MacOS, use dmplayer.sh
2424

2525
### Install PHP (windows):
26-
Running install-php.bat will take care of it. (coming soon)
26+
Running install-php.bat will take care of it. Right click and "Run as administrator".
2727

28-
If you're more technically inclined, you can instead do this:
28+
If you'd rather do it manually:
2929
- Download the most recent <a href="https://windows.php.net/download">php</a> zip-file
3030
- Unzip anywhere, but remember the directory
3131
- <a href="https://www.computerhope.com/issues/ch000549.htm">Add that directory to PATH</a>

websockets.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$address = '0.0.0.0';
3+
$address = '127.0.0.1';
44
$port = 8009;
55

66
// Create WebSocket.

0 commit comments

Comments
 (0)