Add ability to set netplay server

This commit is contained in:
Ethan O'Brien 2023-07-15 15:10:56 -05:00
parent e3f71cd017
commit dfdbe55590
4 changed files with 15 additions and 4 deletions

3
a.html
View File

@ -19,8 +19,9 @@
volume: true,
}*/
EJS_volume = 1;
//EJS_startOnLoaded = true;
EJS_startOnLoaded = true;
//EJS_loadStateURL = "mega_mountain.state";
EJS_netplayServer = "http://127.0.0.1:3000";
</script>
<script src='data/loader.js'></script>
</body>

View File

@ -198,6 +198,9 @@
box-shadow: 0 0 0 5px rgba(var(--ejs-primary-color),0.5);
outline: 0;
}
.ejs_context_menu li:hover a {
color: #fff;
}
@ -1247,6 +1250,7 @@
height: 2rem;
display: block;
font-family: Arial;
border: 0px;
}
.ejs_netplay_name_heading {
margin-top: 0!important;

View File

@ -2803,7 +2803,7 @@ class EmulatorJS {
createNetplayMenu() {
const body = this.createPopup("Netplay", {
"Create a Room": () => {
console.log("aaaaaaaaaaaa");
this.netplay.openRoom();
},
"Close": () => {
this.netplayMenu.style.display = "none";
@ -2887,9 +2887,9 @@ class EmulatorJS {
}
}
defineNetplayFunctions() {
this.netplay.url = this.config.netplayUrl;
this.netplay.getOpenRooms = async () => {
//async because it will need to pull from server. This is for testing
return [{name:"Room 1", players:1, max:2},{name:"Room 2", players:2, max:2}];
return JSON.parse(await (await fetch(this.netplay.url+"/list?domain="+window.location.host+"&game_id=1")).text());
}
this.netplay.updateTableList = async () => {
const addToTable = (name, current, max) => {
@ -2920,9 +2920,14 @@ class EmulatorJS {
}
this.netplay.table.innerHTML = "";
const open = await this.netplay.getOpenRooms();
console.log(open);
for (let i=0; i<open.length; i++) {
addToTable(open[i].name, open[i].players, open[i].max);
}
}
this.netplay.openRoom = () => {
}
this.netplay.updateList = {

View File

@ -63,6 +63,7 @@
config.defaultOptions = window.EJS_defaultOptions;
config.gamePatchUrl = window.EJS_gamePatchUrl;
config.gameParentUrl = window.EJS_gameParentUrl;
config.netplayUrl = window.EJS_netplayServer;
if (typeof window.EJS_language === "string" && window.EJS_language !== "en-US") {
try {