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 #12 from ampersoftware/enhancement/serverlist
Browse files Browse the repository at this point in the history
Enhancement/serverlist
  • Loading branch information
rob5300 authored Aug 22, 2020
2 parents f9c2265 + bea6b31 commit c9f10f4
Show file tree
Hide file tree
Showing 20 changed files with 405 additions and 177 deletions.
15 changes: 14 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## Version 0.0.5 (ALPHA)
## Version 0.1.0 - (ALPHA)
### 22/08/2020 - 19:33 (GMT)
- [WINDOWS INSTALLER USERS ONLY]
- Fixed a rare case where the launcher wouldn't return update status. (Launcher update, not mod-related).
- Updated Electron to v9.2.1.
- Added server list page.
- Fixed a bug causing the TF2 directory to not be found (thanks brucelay!).
- Fixed various bugs related to path finding on Linux.
- Implemented better patch notes system for the launcher.
- Added warning for non auto-update users so they can know when a new version is available.
- Small layout changes.


## Version 0.0.5 - (ALPHA)
### 08/08/2020 - 00:28 (GMT)
- Released launcher's alpha version
Binary file added images/backgrounds/servers.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/icons/arrow-down-bold-box-outline.png
Binary file not shown.
Binary file removed images/icons/arrow-down-bold-box.png
Binary file not shown.
Binary file removed images/icons/server.png
Binary file not shown.
Binary file removed images/thatarrowfromthetfblog.png
Binary file not shown.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<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="Content-Security-Policy" content="default-src 'self' https://api.github.com/; 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">
Expand All @@ -19,6 +19,7 @@
<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 id="launcherversion">Checking for updates...</div>
</div>
<div id="contentdummy"></div>
<div id="content">
Expand Down
5 changes: 1 addition & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function createWindow() {
height: 600,
webPreferences: {
preload: path.join(__dirname, "preload.js"),
nodeIntegration: true
nodeIntegration: false
},
center: true,
maximizable: true,
Expand Down Expand Up @@ -99,7 +99,6 @@ function createWindow() {
}
}

// app.whenReady().then(createWindow);
app.on("ready", () => {
createWindow();
autoUpdater.checkForUpdatesAndNotify();
Expand Down Expand Up @@ -166,11 +165,9 @@ ipcMain.on("restart_app", () => {
ipcMain.on("SettingsWindow", async (event, someArgument) => {
settingsPage.OpenWindow();
});

ipcMain.on("PatchNotesWindow", async (event, someArgument) => {
patchnotesPage.OpenWindow();
});

ipcMain.on("ServerListWindow", async (event, someArgument) => {
serverlistPage.OpenWindow();
});
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "creators-tf-launcher",
"version": "0.0.5",
"version": "0.1.0",
"description": "An easier way to install, update and play TF2 content.",
"main": "main.js",
"scripts": {
Expand All @@ -25,7 +25,7 @@
},
"license": "MIT",
"devDependencies": {
"electron": "^8.5.0",
"electron": "^9.2.1",
"electron-builder": "^22.8.0"
},
"dependencies": {
Expand Down
16 changes: 0 additions & 16 deletions patchnotes-page/patch.js

This file was deleted.

2 changes: 1 addition & 1 deletion patchnotes-page/patchnotespage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function OpenWindow() {
parent: global.mainWindow,
webPreferences: {
preload: path.join(__dirname, "preload.js"),
nodeIntegration: true
nodeIntegration: false
},
modal: true,
show: false,
Expand Down
19 changes: 19 additions & 0 deletions patchnotes-page/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const marked = require("marked");
marked.setOptions({
breaks: true,
gfm: true,
headerIds: false
});

window.addEventListener("DOMContentLoaded", () => {
var request = new XMLHttpRequest();
request.open("GET", "https://raw.githubusercontent.com/ampersoftware/Creators.TF-Community-Launcher/master/changelog.md");
request.send();
request.onload = () => {
if (request.status === 200) {
document.getElementById("patchnotes").innerHTML = marked(request.responseText);
} else {
document.getElementById("patchnotes").innerHTML = marked("## If you are reading this, there are two options:\n- Github is down (You can check their status page at `githubstatus.com`)\n- Your internet is down");
}
}
});
34 changes: 27 additions & 7 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ const path = require("path");
const moddata = JSON.parse(fs.readFileSync(path.resolve(__dirname, "internal", "mods.json")));
const { ipcRenderer } = require("electron");

global.log = require("electron-log");
global.log.transports.console.format = "[{d}-{m}-{y}] [{h}:{i}:{s}T{z}] -- [{processType}] -- [{level}] -- {text}";
global.log.transports.file.format = "[{d}-{m}-{y}] [{h}:{i}:{s}T{z}] -- [{processType}] -- [{level}] -- {text}";
global.log.transports.file.fileName = "renderer.log";
global.log.transports.file.maxSize = 10485760; //why 10mb? idk.
global.log.transports.file.getFile();
global.log.silly("Testing log - PRELOAD OF MAIN WINDOW");
window.ipcRenderer = ipcRenderer;

window.log = require("electron-log");
window.log.transports.console.format = "[{d}-{m}-{y}] [{h}:{i}:{s}T{z}] -- [{processType}] -- [{level}] -- {text}";
window.log.transports.file.format = "[{d}-{m}-{y}] [{h}:{i}:{s}T{z}] -- [{processType}] -- [{level}] -- {text}";
window.log.transports.file.fileName = "renderer.log";
window.log.transports.file.maxSize = 10485760; //why 10mb? idk.
window.log.transports.file.getFile();
window.log.silly("Testing log - PRELOAD OF MAIN WINDOW");

window.addEventListener("DOMContentLoaded", () => {
sidebar = document.getElementById("sidebar");
Expand Down Expand Up @@ -38,4 +40,22 @@ window.addEventListener("DOMContentLoaded", () => {

div.addEventListener("click", function(e){OnClick_Mod(modentry)}, false);
});

var launcherversionBox = document.getElementById("launcherversion");
const config = require("./package.json");
const currentClientVersion = config.version;
let request = new XMLHttpRequest();
request.open("GET", "https://api.github.com/repos/ampersoftware/Creators.TF-Community-Launcher/releases/latest");
request.send();
request.onload = () => {
if (request.status === 200) {
var answer = JSON.parse(request.response);
var version = answer.name;
if (currentClientVersion === version) {
launcherversionBox.remove();
} else {
launcherversionBox.innerText = "A new update is available for the launcher.\nCheck the website to download the new version.\nIf you are using the auto-updater version,\ndownload it automatically by clicking the yellow\nbutton!";
}
}
}
});
16 changes: 8 additions & 8 deletions renderer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { ipcRenderer } = require("electron");
ipcRenderer = window.ipcRenderer;

var content = document.getElementById("content");
var contentDummy = document.getElementById("contentdummy");
Expand Down Expand Up @@ -31,7 +31,7 @@ document.onload = () => {
};

function OnClick_Mod(data) {
global.log.info("Mod entry clicked");
window.log.info("Mod entry clicked");

content.style.backgroundImage = `url("${"./" + data.backgroundimage}")`;
titleImage.src = data.titleimage;
Expand Down Expand Up @@ -62,12 +62,12 @@ function OnClick_Mod(data) {

updateButton_Download.onclick = (downloadUpdate) => {
ipcRenderer.send("download_update");
global.log.info("User chose to download the update. Downloading it." + downloadUpdate);
window.log.info("User chose to download the update. Downloading it." + downloadUpdate);
}

updateButton_Update.onclick = (closeProgramAndUpdate) => {
ipcRenderer.send("restart_app");
global.log.info("The launcher was restarted to update" + closeProgramAndUpdate);
window.log.info("The launcher was restarted to update" + closeProgramAndUpdate);
}

ipcRenderer.on("update_not_available", () => {
Expand All @@ -76,28 +76,28 @@ ipcRenderer.on("update_not_available", () => {
updateButton_Download.remove();
updateButton_Downloading.remove();
updateButton_Update.remove();
global.log.info("No update available... Sad!");
window.log.info("No update available... Sad!");
});

ipcRenderer.on("update_available", () => {
ipcRenderer.removeAllListeners("update_available");
updateButton_Updated.remove();
updateButton_Download.classList.remove("hidden");
global.log.info("An update is available. Waiting for user's input to actually download it.");
window.log.info("An update is available. Waiting for user's input to actually download it.");
});

ipcRenderer.on("update_downloading", () => {
ipcRenderer.removeAllListeners("update_downloading");
updateButton_Download.remove();
updateButton_Downloading.classList.remove("hidden");
global.log.info("Downloading update");
window.log.info("Downloading update");
});

ipcRenderer.on("update_downloaded", () => {
ipcRenderer.removeAllListeners("update_downloaded");
updateButton_Download.remove();
updateButton_Update.classList.remove("hidden");
global.log.info("The update was downloaded and will be installed on restart. Waiting for user's input.");
window.log.info("The update was downloaded and will be installed on restart. Waiting for user's input.");
});

document.getElementById("settings-button").addEventListener("click", (a,b) => {
Expand Down
7 changes: 4 additions & 3 deletions serverlist-page/serverlist.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<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="Content-Security-Policy" content="default-src 'self' https://creators.tf/; 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">
Expand All @@ -12,9 +12,10 @@
</head>
<body>
<h1 id="modname">Creators.TF - Server List</h1>
<div id="loading"><h1>LOADING...</h1></div>
<div id="failMessage"></div>
<div id="refreshHolder"><button id="refreshButton"><i class="mdi mdi-refresh-circle blue"></i></button></div>
<div id="server-container"></div>
<div id="loading">LOADING...</div>
<div id="failMessage"></div>
<script src="../consolewarning.js"></script>
</body>
</html>
20 changes: 12 additions & 8 deletions serverlist-page/serverlistpage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { BrowserWindow, ipcMain } = require("electron");
const path = global.path;
const path = require("path");

var serverlistWindow;
const apiEndpoint = "https://creators.tf/api/IServers/GServerList?provider=15";
Expand All @@ -20,24 +20,28 @@ function OpenWindow() {
maximizable: true,
resizable: true,
autoHideMenuBar: true,
minWidth: 700,
minHeight: 500,
width: 900,
height: 650
minWidth: 850,
minHeight: 550,
width: 950,
height: 700
});
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)});
try{
event.reply("GetServerList-Reply", await GetServerList());
}
catch (error) {
event.reply("GetServerList-Reply", null);
}
});

function GetServerList() {
async function GetServerList() {
return new Promise((resolve, reject) => {
var options = {
headers: {
Expand Down
Loading

0 comments on commit c9f10f4

Please sign in to comment.