Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ ssh_host_key.pub
tmp-gomud.exe
__debug*
.claude/


cmd/app/dist/*
cmd/app/node_modules/*
cmd/app/build_cache/*
cmd/app/steam/output/*
12 changes: 10 additions & 2 deletions _datafiles/html/public/static/js/webclient-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,10 @@ const Client = (() => {

function reconnectWithToken(token) {
debugLog('Reconnecting with copyover token');
const wsUrl = (location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host + '/ws';
var wsUrl = (location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host + '/ws';
if (typeof WS_URL_OVERRIDE != "undefined" && WS_URL_OVERRIDE != "") {
wsUrl = WS_URL_OVERRIDE;
}
socket = new WebSocket(wsUrl);
attachSocketHandlers('Reconnected after server reboot.', false);
const origOnOpen = socket.onopen;
Expand Down Expand Up @@ -2100,7 +2103,12 @@ const Client = (() => {
socket.close();
return;
}
const wsUrl = (location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host + '/ws';

var wsUrl = (location.protocol === 'https:' ? 'wss://' : 'ws://') + location.host + '/ws';
if (typeof WS_URL_OVERRIDE != "undefined" && WS_URL_OVERRIDE != "") {
wsUrl = WS_URL_OVERRIDE;
}

debugLog('Connecting to: ' + wsUrl);
socket = new WebSocket(wsUrl);
attachSocketHandlers('Connected to the server!', true);
Expand Down
24 changes: 21 additions & 3 deletions _datafiles/html/public/webclient-pure.html
Original file line number Diff line number Diff line change
Expand Up @@ -1165,11 +1165,29 @@

<link rel="stylesheet" href="{{ .ASSET_BASE_URL }}/static/css/xterm.css" />
<link rel="stylesheet" href="{{ .ASSET_BASE_URL }}/static/css/windows.css" />

<script type="text/javascript">
const WS_URL_OVERRIDE = ""; // ws://gomud.net/ws
</script>
<script src="{{ .ASSET_BASE_URL }}/static/js/xterm/xterm.4.19.0.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/xterm/xterm-addon-fit.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/_all.js?mp3.js,fx.js,vwin.js,webclient-core.js,triggers.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/_all.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/mp3.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/fx.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/vwin.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/webclient-core.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/triggers.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/window-character.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/window-comm.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/window-gametime.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/window-gear.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/window-killstats.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/window-map.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/window-modal.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/window-online.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/window-party.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/window-pet.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/window-room.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/window-status.js"></script>
<script src="{{ .ASSET_BASE_URL }}/static/js/windows/window-vitals.js"></script>

</head>
<body onload="init()">
Expand Down
62 changes: 62 additions & 0 deletions cmd/app/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.PHONY: install start build-mac build-win build-linux build clean vendor-gomud-files clean-gomud-vendored build-steam-mac build-steam-win build-steam-linux build-steam steam-upload

HOST ?= gomud.net
WS_URL ?= wss://$(HOST)/ws

install: vendor-gomud
npm install

start: vendor-gomud
npm start

build-mac: install
npm run build:mac

build-win: install
npm run build:win

build-linux: install
npm run build:linux

build: install
npm run build:mac
npm run build:win
npm run build:linux

clean: clean-gomud-vendored
@echo "Clearing dist/ and node_modules/ ..."
@rm -rf dist node_modules

clean-gomud-vendored:
@echo "Clearing build_cache..."
@rm -rf build_cache/*

build-steam-mac: install
npm run build:steam-mac

build-steam-win: install
npm run build:steam-win

build-steam-linux: install
npm run build:steam-linux

build-steam: install
npm run build:steam-win
npm run build:steam-mac
npm run build:steam-linux

steam-upload:
steamcmd +login $(STEAM_USERNAME) +run_app_build $(CURDIR)/steam/app_build.vdf +quit

vendor-gomud: clean-gomud-vendored
@echo "Vendoring files from GoMud html..."
@cp -rp ../../_datafiles/html/public/webclient-pure.html build_cache/
@mkdir -p build_cache/static
@cp -rp ../../_datafiles/html/public/static/js build_cache/static/
@cp -rp ../../_datafiles/html/public/static/css build_cache/static/
@echo "Replacing template vars with new values..."
@sed -i '' 's/{{ .ASSET_BASE_URL }}//g' build_cache/webclient-pure.html
@sed -i '' 's/{{ .CONFIG.Server.MudName }}//g' build_cache/webclient-pure.html
@sed -i '' 's|="/static/|="static/|g' build_cache/webclient-pure.html
@sed -i '' 's|src="/static/|src="static/|g' build_cache/webclient-pure.html
@sed -i '' 's|WS_URL_OVERRIDE = "";|WS_URL_OVERRIDE = "$(WS_URL)";|g' build_cache/webclient-pure.html
80 changes: 80 additions & 0 deletions cmd/app/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
const { app, BrowserWindow, Menu } = require('electron');
const path = require('path');

// Required for Steam overlay compatibility with Chromium
app.commandLine.appendSwitch('in-process-gpu');

// Initialize Steam SDK (graceful fallback for non-Steam launches)
let steamClient = null;
try {
const steamworks = require('steamworks.js');
steamClient = steamworks.init(YOUR_APP_ID); // Replace YOUR_APP_ID with your numeric Steam App ID
} catch (err) {
console.warn('Steam SDK not available:', err.message);
}

function createWindow() {
const win = new BrowserWindow({
width: 1920,
height: 1080,
fullscreen: true,
title: 'GoMud Client',
webPreferences: {
contextIsolation: true,
nodeIntegration: false,
},
});

win.loadFile(path.join(__dirname, 'build_cache', 'webclient-pure.html'));

if (process.argv.includes('--dev')) {
win.webContents.openDevTools();
}
}

function buildMenu() {
const template = [
...(process.platform === 'darwin' ? [{
label: app.name,
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'quit' },
],
}] : []),
{
label: 'View',
submenu: [
{ role: 'togglefullscreen' },
{ role: 'resetZoom' },
{ role: 'zoomIn' },
{ role: 'zoomOut' },
],
},
{
label: 'Edit',
submenu: [
{ role: 'copy' },
{ role: 'paste' },
{ role: 'selectAll' },
],
},
];

Menu.setApplicationMenu(Menu.buildFromTemplate(template));
}

app.whenReady().then(() => {
buildMenu();
createWindow();
});

app.on('window-all-closed', () => {
app.quit();
});

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
Loading
Loading