Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1 from ampersoftware/feature/serverlist
Browse files Browse the repository at this point in the history
Server List
  • Loading branch information
rob5300 authored Aug 17, 2020
2 parents 206200c + d78bf1a commit d093c4d
Show file tree
Hide file tree
Showing 12 changed files with 568 additions and 147 deletions.
Binary file added images/icons/arrow-down-bold-box-outline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icons/arrow-down-bold-box.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icons/server.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 45 additions & 44 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
<html>
<head>
<meta charset="utf-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Creators.TF Launcher - Alpha Version</title>
<link rel="stylesheet" href="node_modules/@mdi/font/css/materialdesignicons.min.css">
<link rel="stylesheet" href="fonts/fonts.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="sidebar">
<div id="boxOfButtons">
<button id="settings-button" tooltip="Settings section. This is where you can change your folder directories and see other technical stuff."><i class="mdi mdi-cog"></i></button>
<button id="patchnotes-button" tooltip="Patch notes. Here we put all the changes that happened related to the launcher."><i class="mdi mdi-format-list-bulleted-square"></i></button>
<button id="update-button-updated" class="hidden" tooltip="Your launcher is up to date."><i class="mdi mdi-check-bold"></i></button>
<button id="update-button-download" class="hidden" tooltip="An update is available. Download now?"><i class="mdi mdi-download"></i></button>
<button id="update-button-downloading" class="hidden" tooltip="A new update is being downloaded."><i class="mdi mdi-loading"></i></button>
<button id="update-button-update" class="hidden" tooltip="An update is installed. Update now?"><i class="mdi mdi-sync-alert"></i></button>
</div>
</div>
<div id="contentdummy"></div>
<div id="content">
<div id="content-area">
<div id="title-image-holder">
<img id="title-image">
</div>
<p id="content-text"></p>
<div class="modInfoBox">
<div class="socialMedia" id="socialMediaGithub"></div>
<div class="socialMedia" id="socialMediaWebsite"></div>
<div class="socialMedia" id="socialMediaTwitter"></div>
<div class="socialMedia" id="socialMediaInstagram"></div>
<div class="socialMedia" id="socialMediaDiscord"></div>
</div>
<!-- <p id="version">🛠<span id="version-text"></span></p> -->
</div>
<div id="fadebehindbutton"></div>
<button id="install-play-update">Loading...</button>
<button id="remove-mod">Uninstall Mod</button>
</div>
<script src="./renderer.js"></script>
<script src="consolewarning.js"></script>
</body>
<head>
<meta charset="utf-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Creators.TF Launcher - Alpha Version</title>
<link rel="stylesheet" href="node_modules/@mdi/font/css/materialdesignicons.min.css">
<link rel="stylesheet" href="fonts/fonts.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="sidebar">
<div id="boxOfButtons">
<button id="settings-button" tooltip="Settings section. This is where you can change your folder directories and see other technical stuff."><i class="mdi mdi-cog"></i></button>
<button id="patchnotes-button" tooltip="Patch notes. Here we put all the changes that happened related to the launcher."><i class="mdi mdi-format-list-bulleted-square"></i></button>
<button id="update-button-updated" class="hidden" tooltip="Your launcher is up to date."><i class="mdi mdi-check-bold"></i></button>
<button id="update-button-download" class="hidden" tooltip="An update is available. Download now?"><i class="mdi mdi-download"></i></button>
<button id="update-button-downloading" class="hidden" tooltip="A new update is being downloaded."><i class="mdi mdi-loading"></i></button>
<button id="update-button-update" class="hidden" tooltip="An update is installed. Update now?"><i class="mdi mdi-sync-alert"></i></button>
</div>
</div>
<div id="contentdummy"></div>
<div id="content">
<div id="content-area">
<div id="boxOfModButtons">
<button id="serverlist"><i class="mdi mdi-server"></i></button>
<button id="remove-mod"><i class="mdi mdi-delete-forever"></i></button>
</div>
<div id="title-image-holder"><img id="title-image"></div>
<p id="content-text">Description Text goes here</p>
<div class="modInfoBox">
<div class="socialMedia" id="socialMediaGithub"></div>
<div class="socialMedia" id="socialMediaWebsite"></div>
<div class="socialMedia" id="socialMediaTwitter"></div>
<div class="socialMedia" id="socialMediaInstagram"></div>
<div class="socialMedia" id="socialMediaDiscord"></div>
</div>
<!-- <p id="version">🛠<span id="version-text"></span></p> -->
</div>
<div id="fadebehindbutton"></div>
<button id="install-play-update">Loading...</button>
</div>
<script src="renderer.js"></script>
<script src="consolewarning.js"></script>
</body>
</html>
21 changes: 10 additions & 11 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { app, BrowserWindow, ipcMain, shell, dialog } = require("electron");
const config = require("./modules/config");
const settingsPage = require("./settings-page/settingspage");
const patchnotesPage = require("./patchnotes-page/patchnotespage");
const serverlistPage = require("./serverlist-page/serverlistpage")
const mod_manager = require("./modules/mod_manager");
const { autoUpdater } = require("electron-updater");

Expand Down Expand Up @@ -48,9 +49,7 @@ function createWindow() {
global.mainWindow = mainWindow;
global.app = app;
mainWindow.removeMenu();

//mainWindow.loadFile(path.resolve(__dirname, 'loading.html'));

//Load copy of mods data for this process. The rendering process will load its own.

//Lets load the config file.
Expand Down Expand Up @@ -167,11 +166,15 @@ ipcMain.on("PatchNotesWindow", async (event, someArgument) => {
patchnotesPage.OpenWindow();
});

// ipcMain.on("app_version", (event) => {
// event.sender.send("app_version", {
// version: app.getVersion()
// });
// });
ipcMain.on("ServerListWindow", async (event, someArgument) => {
serverlistPage.OpenWindow();
});

//ipcMain.on("app_version", (event) => {
// event.sender.send("app_version", {
// version: app.getVersion()
// });
//});

ipcMain.on("GetConfig", async (event, someArgument) => {
event.reply("GetConfig-Reply", global.config);
Expand Down Expand Up @@ -214,10 +217,6 @@ ipcMain.on("GetCurrentModVersion", async(event, arg) => {
event.reply("GetCurrentModVersion-Reply", version);
});

// TODO -----------------------------
// MAKE THE UNINSTALL BUTTON APPEARS
// ONLY WHEN THE MOD IS INSTALLED
// ----------------------------------
ipcMain.on("Remove-Mod", async(event, arg) => {
if(mod_manager.currentModData != null && (mod_manager.currentModState == "INSTALLED" || mod_manager.currentModState == "UPDATE" )){
dialog.showMessageBox(global.mainWindow, {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"electron-log": "^4.2.2",
"electron-progressbar": "^1.2.0",
"electron-updater": "^4.3.4",
"flag-icon-css": "^3.5.0",
"jszip": "^3.5.0",
"marked": "^1.1.1"
}
Expand Down
7 changes: 4 additions & 3 deletions renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ updateButton_Update.onclick = (closeProgramAndUpdate) => {
global.log.info("The launcher was restarted to update" + closeProgramAndUpdate);
}

// this is disgusting
ipcRenderer.on("update_not_available", () => {
ipcRenderer.removeAllListeners("update_not_available");
updateButton_Updated.classList.remove("hidden");
Expand Down Expand Up @@ -109,6 +108,10 @@ document.getElementById("patchnotes-button").addEventListener("click", (a,b) =>
ipcRenderer.send("PatchNotesWindow", "");
});

document.getElementById("serverlist").addEventListener("click", (a, b) => {
ipcRenderer.send("ServerListWindow", "");
});

installButton.addEventListener("click", (e) => {
installButton.innerText = "STARTING...";
installButton.disabled = true;
Expand All @@ -128,7 +131,6 @@ ipcRenderer.on("InstallButtonName-Reply", (event, arg) => {

switch(arg) {
case "installed":
// installButton.style.backgroundColor = "#4CAF50";
installButton.style.background = "linear-gradient(to right, #009028 25%, #007520 75%)"; //Green (light-to-dark)
installButton.style.color = "white";
removeButton.style.display = "block";
Expand All @@ -140,7 +142,6 @@ ipcRenderer.on("InstallButtonName-Reply", (event, arg) => {
removeButton.style.display = "none";
break;
case "update":
// installButton.style.backgroundColor = "#0affa9";
installButton.style.background = "linear-gradient(to left, #1A96FF 25%, #1A70FF 75%)"; //Blue (dark-to-light)
installButton.style.color = "white";
removeButton.style.display = "block";
Expand Down
20 changes: 20 additions & 0 deletions serverlist-page/serverlist.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<html>
<head>
<meta charset="utf-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
<title>Server List</title>
<link rel="stylesheet" href="../node_modules/flag-icon-css/css/flag-icon.min.css">
<link rel="stylesheet" href="../node_modules/@mdi/font/css/materialdesignicons.min.css">
<link rel="stylesheet" href="../fonts/fonts.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1 id="modname">Creators.TF - Server List</h1>
<div id="loading"><h1>LOADING...</h1></div>
<div id="failMessage"></div>
<div id="server-container"></div>
<script src="../consolewarning.js"></script>
</body>
</html>
70 changes: 70 additions & 0 deletions serverlist-page/serverlistpage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const { BrowserWindow, ipcMain } = require("electron");
const path = global.path;

var serverlistWindow;
const apiEndpoint = "https://creators.tf/api/IServers/GServerList?provider=15";

module.exports.OpenWindow = OpenWindow;
function OpenWindow() {
global.log.info("Loading Server List window...");
serverlistWindow = new BrowserWindow({
parent: global.mainWindow,
webPreferences: {
preload: path.join(__dirname, "serverpage-preload.js"),
nodeIntegration: false
},
modal: true,
show: false,
center: true,
darkTheme: true,
maximizable: true,
resizable: true,
autoHideMenuBar: true,
minWidth: 700,
minHeight: 500,
width: 900,
height: 650
});
serverlistWindow.removeMenu();
serverlistWindow.loadFile(path.join(__dirname, "serverlist.html"));
serverlistWindow.once("ready-to-show", () => {
serverlistWindow.show();
});

}

ipcMain.on("GetServerList", async (event, arg) => {
GetServerList().then((result) => {event.reply("GetServerList-Reply", result)});
});

function GetServerList() {
return new Promise((resolve, reject) => {
var options = {
headers: {
'User-Agent': 'creators-tf-launcher'
}
};

var data = [];

let req = https.get(apiEndpoint, options, res => {
console.log(`statusCode: ${res.statusCode}`);
res.on('data', d => {
if (res.statusCode != 200) {
reject(`Failed accessing ${url}: ` + res.statusCode);
return;
}
data.push(d);
});
res.on("end", function() {
var buf = Buffer.concat(data);
let parsed = JSON.parse(buf.toString());
resolve(parsed);
});
});
req.on('error', error => {
reject(error.toString());
});
req.end();
});
}
Loading

0 comments on commit d093c4d

Please sign in to comment.