multiplayer!
parent
31eba8c1f6
commit
69f79d0761
|
|
@ -8,6 +8,7 @@
|
||||||
"@babel/core": "^7.14.8",
|
"@babel/core": "^7.14.8",
|
||||||
"@babel/preset-env": "^7.14.8",
|
"@babel/preset-env": "^7.14.8",
|
||||||
"@nodegui/nodegui": "^0.34.0",
|
"@nodegui/nodegui": "^0.34.0",
|
||||||
|
"@nodegui/packer": "^1.4.1",
|
||||||
"@rollup/plugin-alias": "^3.1.4",
|
"@rollup/plugin-alias": "^3.1.4",
|
||||||
"@rollup/plugin-babel": "^5.3.0",
|
"@rollup/plugin-babel": "^5.3.0",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,16 @@ const restoreLog = () => console.log = oldConsoleLog;
|
||||||
// const log = (...args: any[]) => console.log(chalk.cyan('[CLIENT]'), ...args);
|
// const log = (...args: any[]) => console.log(chalk.cyan('[CLIENT]'), ...args);
|
||||||
|
|
||||||
class ProcessManagerClass extends EventEmitter {
|
class ProcessManagerClass extends EventEmitter {
|
||||||
|
|
||||||
|
processLock = Promise.resolve();
|
||||||
|
// TODO replace this with an async sortof
|
||||||
|
// event emitter, to wait for all clean up
|
||||||
|
|
||||||
quit() {
|
quit() {
|
||||||
this.emit('shutdown');
|
this.emit('shutdown');
|
||||||
|
this.processLock.then(() => {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
restart() {
|
restart() {
|
||||||
|
|
@ -63,5 +70,19 @@ ipc.connectTo(name, () => {
|
||||||
process.on('SIGKILL', () => ProcessManager.quit());
|
process.on('SIGKILL', () => ProcessManager.quit());
|
||||||
process.on('SIGTERM', () => ProcessManager.quit());
|
process.on('SIGTERM', () => ProcessManager.quit());
|
||||||
process.on('SIGINT', () => ProcessManager.quit());
|
process.on('SIGINT', () => ProcessManager.quit());
|
||||||
|
// process.on('exit', () => ProcessManager.quit());
|
||||||
|
process.on('beforeExit', () => ProcessManager.quit());
|
||||||
|
|
||||||
|
// dumbass hack hahahah :)
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
var rl = require("readline").createInterface({
|
||||||
|
input: process.stdin,
|
||||||
|
output: process.stdout
|
||||||
|
});
|
||||||
|
|
||||||
|
rl.on("SIGINT", function () {
|
||||||
|
// @ts-ignore dont know why, dont fuckin care
|
||||||
|
process.emit("SIGINT");
|
||||||
|
});
|
||||||
|
}
|
||||||
///
|
///
|
||||||
|
|
@ -10,6 +10,11 @@ export class Player {
|
||||||
host: string;
|
host: string;
|
||||||
port: number;
|
port: number;
|
||||||
|
|
||||||
|
equals(player: Player) {
|
||||||
|
return this.host === player.host
|
||||||
|
&& this.port === player.port;
|
||||||
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import { Game } from '../Game.js';
|
||||||
import { Player } from './Player.js';
|
import { Player } from './Player.js';
|
||||||
import { injectTravelMemory } from '../Memories.js';
|
import { injectTravelMemory } from '../Memories.js';
|
||||||
import { MDNS_TYPE } from '../Constants.js';
|
import { MDNS_TYPE } from '../Constants.js';
|
||||||
|
import { ProcessManager } from '../ProcessManager.js';
|
||||||
|
|
||||||
const mdns = bonjour();
|
const mdns = bonjour();
|
||||||
const ID = uuid.v4();
|
const ID = uuid.v4();
|
||||||
|
|
@ -61,13 +62,30 @@ export async function ready(name: string) {
|
||||||
mdns.find({
|
mdns.find({
|
||||||
type: MDNS_TYPE
|
type: MDNS_TYPE
|
||||||
}, (service) => {
|
}, (service) => {
|
||||||
network.emit('change');
|
|
||||||
const p = new Player();
|
const p = new Player();
|
||||||
p.name = service.name;
|
p.name = service.name;
|
||||||
p.host = service.host;
|
p.host = service.host;
|
||||||
p.port = service.port;
|
p.port = service.port;
|
||||||
|
// console.log('')
|
||||||
devices.push(p);
|
devices.push(p);
|
||||||
|
network.emit('change');
|
||||||
}).on("down", (service) => {
|
}).on("down", (service) => {
|
||||||
|
const p = new Player();
|
||||||
|
p.name = service.name;
|
||||||
|
p.host = service.host;
|
||||||
|
p.port = service.port;
|
||||||
|
devices = devices.filter((player: Player) => {
|
||||||
|
return !player.equals(p);
|
||||||
|
});
|
||||||
network.emit('change');
|
network.emit('change');
|
||||||
// TODO remove player from MP
|
// TODO remove player from MP
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
|
ProcessManager.on('shutdown', () => {
|
||||||
|
ProcessManager.processLock = ProcessManager.processLock.then(() => new Promise(res => {
|
||||||
|
mdns.unpublishAll(() => {
|
||||||
|
res(void 0);
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
@ -128,6 +128,8 @@ abstract class ScrollPanel extends QScrollArea {
|
||||||
centralWidget: QWidget;
|
centralWidget: QWidget;
|
||||||
vLayout: QBoxLayout;
|
vLayout: QBoxLayout;
|
||||||
|
|
||||||
|
widgets: QWidget[] = [];
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.setInlineStyle(`
|
this.setInlineStyle(`
|
||||||
|
|
@ -147,23 +149,22 @@ abstract class ScrollPanel extends QScrollArea {
|
||||||
this.fill();
|
this.fill();
|
||||||
|
|
||||||
this.vLayout.addStretch(1);
|
this.vLayout.addStretch(1);
|
||||||
|
|
||||||
// for(let i = 0; i < 100; i ++) {
|
|
||||||
// const button = new QPushButton();
|
|
||||||
// button.setText('' + i);
|
|
||||||
// this.vLayout.addWidget(button);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
refill() {
|
refill() {
|
||||||
for(const a of this.nodeChildren) {
|
for(const component of this.widgets) {
|
||||||
console.log(a);
|
// component.hide();
|
||||||
|
component.close();
|
||||||
|
// component.nodeParent = null;
|
||||||
|
// this.vLayout.removeWidget(component);
|
||||||
}
|
}
|
||||||
|
this.widgets = [];
|
||||||
this.fill();
|
this.fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
addWidget(widget: QWidget) {
|
addWidget(widget: QWidget) {
|
||||||
this.vLayout.addWidget(widget);
|
this.widgets.push(widget);
|
||||||
|
this.vLayout.insertWidget(0, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract fill(): void;
|
abstract fill(): void;
|
||||||
|
|
|
||||||
50
yarn.lock
50
yarn.lock
|
|
@ -880,7 +880,7 @@
|
||||||
"@babel/helper-validator-identifier" "^7.14.8"
|
"@babel/helper-validator-identifier" "^7.14.8"
|
||||||
to-fast-properties "^2.0.0"
|
to-fast-properties "^2.0.0"
|
||||||
|
|
||||||
"@nodegui/artifact-installer@^1.1.0":
|
"@nodegui/artifact-installer@^1.0.0", "@nodegui/artifact-installer@^1.1.0":
|
||||||
version "1.1.0"
|
version "1.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/@nodegui/artifact-installer/-/artifact-installer-1.1.0.tgz#0888b02e114b0d81973f950426c2d4c43cfe3085"
|
resolved "https://registry.yarnpkg.com/@nodegui/artifact-installer/-/artifact-installer-1.1.0.tgz#0888b02e114b0d81973f950426c2d4c43cfe3085"
|
||||||
integrity sha512-x/rIewhjnLhf2b3lAy5ZIPSTS39LRpwMTKeEg6sn4RwvWwyNmreGzpvGi6Gkbl6FUpftn70nfOBOpaeO3hO8PQ==
|
integrity sha512-x/rIewhjnLhf2b3lAy5ZIPSTS39LRpwMTKeEg6sn4RwvWwyNmreGzpvGi6Gkbl6FUpftn70nfOBOpaeO3hO8PQ==
|
||||||
|
|
@ -906,6 +906,16 @@
|
||||||
node-addon-api "^3.1.0"
|
node-addon-api "^3.1.0"
|
||||||
postcss-nodegui-autoprefixer "0.0.7"
|
postcss-nodegui-autoprefixer "0.0.7"
|
||||||
|
|
||||||
|
"@nodegui/packer@^1.4.1":
|
||||||
|
version "1.4.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/@nodegui/packer/-/packer-1.4.1.tgz#a2b9398ae8c2e2b9bd72c4f8178225eb4c18537d"
|
||||||
|
integrity sha512-jmw2uuaiXZIW+Vxx4WpNFxkjzcqKRAT/VBf7jKbK4IIr1OW+G0ufYA4K5bGGlGG/4iE1oOLCLHbIRmSTYkfslw==
|
||||||
|
dependencies:
|
||||||
|
"@nodegui/artifact-installer" "^1.0.0"
|
||||||
|
commander "^4.0.1"
|
||||||
|
fs-extra "^8.1.0"
|
||||||
|
plist "^3.0.1"
|
||||||
|
|
||||||
"@nodegui/qode@^2.1.0":
|
"@nodegui/qode@^2.1.0":
|
||||||
version "2.1.1"
|
version "2.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/@nodegui/qode/-/qode-2.1.1.tgz#156144d51fba4b3fa0ef425620ff6ec3726f3b44"
|
resolved "https://registry.yarnpkg.com/@nodegui/qode/-/qode-2.1.1.tgz#156144d51fba4b3fa0ef425620ff6ec3726f3b44"
|
||||||
|
|
@ -1434,6 +1444,11 @@ balanced-match@^1.0.0:
|
||||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
|
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
|
||||||
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
|
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
|
||||||
|
|
||||||
|
base64-js@^1.5.1:
|
||||||
|
version "1.5.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
|
||||||
|
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
|
||||||
|
|
||||||
big-integer@^1.6.17:
|
big-integer@^1.6.17:
|
||||||
version "1.6.48"
|
version "1.6.48"
|
||||||
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.48.tgz#8fd88bd1632cba4a1c8c3e3d7159f08bb95b4b9e"
|
resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.48.tgz#8fd88bd1632cba4a1c8c3e3d7159f08bb95b4b9e"
|
||||||
|
|
@ -1806,6 +1821,11 @@ command-line-usage@^6.1.1:
|
||||||
table-layout "^1.0.1"
|
table-layout "^1.0.1"
|
||||||
typical "^5.2.0"
|
typical "^5.2.0"
|
||||||
|
|
||||||
|
commander@^4.0.1:
|
||||||
|
version "4.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068"
|
||||||
|
integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==
|
||||||
|
|
||||||
concat-map@0.0.1:
|
concat-map@0.0.1:
|
||||||
version "0.0.1"
|
version "0.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||||
|
|
@ -2284,6 +2304,15 @@ fs-extra@^5.0.0:
|
||||||
jsonfile "^4.0.0"
|
jsonfile "^4.0.0"
|
||||||
universalify "^0.1.0"
|
universalify "^0.1.0"
|
||||||
|
|
||||||
|
fs-extra@^8.1.0:
|
||||||
|
version "8.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0"
|
||||||
|
integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==
|
||||||
|
dependencies:
|
||||||
|
graceful-fs "^4.2.0"
|
||||||
|
jsonfile "^4.0.0"
|
||||||
|
universalify "^0.1.0"
|
||||||
|
|
||||||
fs-minipass@^1.2.5:
|
fs-minipass@^1.2.5:
|
||||||
version "1.2.7"
|
version "1.2.7"
|
||||||
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7"
|
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7"
|
||||||
|
|
@ -3437,6 +3466,15 @@ pkginfo@~0.3.0:
|
||||||
resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.3.1.tgz#5b29f6a81f70717142e09e765bbeab97b4f81e21"
|
resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.3.1.tgz#5b29f6a81f70717142e09e765bbeab97b4f81e21"
|
||||||
integrity sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=
|
integrity sha1-Wyn2qB9wcXFC4J52W76rl7T4HiE=
|
||||||
|
|
||||||
|
plist@^3.0.1:
|
||||||
|
version "3.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.2.tgz#74bbf011124b90421c22d15779cee60060ba95bc"
|
||||||
|
integrity sha512-MSrkwZBdQ6YapHy87/8hDU8MnIcyxBKjeF+McXnr5A9MtffPewTs7G3hlpodT5TacyfIyFTaJEhh3GGcmasTgQ==
|
||||||
|
dependencies:
|
||||||
|
base64-js "^1.5.1"
|
||||||
|
xmlbuilder "^9.0.7"
|
||||||
|
xmldom "^0.5.0"
|
||||||
|
|
||||||
portfinder@^1.0.28:
|
portfinder@^1.0.28:
|
||||||
version "1.0.28"
|
version "1.0.28"
|
||||||
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.28.tgz#67c4622852bd5374dd1dd900f779f53462fac778"
|
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.28.tgz#67c4622852bd5374dd1dd900f779f53462fac778"
|
||||||
|
|
@ -4399,6 +4437,16 @@ xdg-basedir@^4.0.0:
|
||||||
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-4.0.0.tgz#4bc8d9984403696225ef83a1573cbbcb4e79db13"
|
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-4.0.0.tgz#4bc8d9984403696225ef83a1573cbbcb4e79db13"
|
||||||
integrity sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==
|
integrity sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==
|
||||||
|
|
||||||
|
xmlbuilder@^9.0.7:
|
||||||
|
version "9.0.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d"
|
||||||
|
integrity sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=
|
||||||
|
|
||||||
|
xmldom@^0.5.0:
|
||||||
|
version "0.5.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.5.0.tgz#193cb96b84aa3486127ea6272c4596354cb4962e"
|
||||||
|
integrity sha512-Foaj5FXVzgn7xFzsKeNIde9g6aFBxTPi37iwsno8QvApmtg7KYrr+OPyRHcJF7dud2a5nGRBXK3n0dL62Gf7PA==
|
||||||
|
|
||||||
xtend@^4.0.0, xtend@~4.0.1:
|
xtend@^4.0.0, xtend@~4.0.1:
|
||||||
version "4.0.2"
|
version "4.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
|
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue