summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLawnCable <lawncable.tmw2@simonlaux.de>2018-05-20 20:51:35 -0400
committerLawnCable <lawncable.tmw2@simonlaux.de>2018-05-20 20:51:35 -0400
commit5f86ae2995cad6044c1c8fe3ebf98e5085658a90 (patch)
tree456cecdf6fb5338d1f74cbc09931d7ee7b077736
parentfb8104900abcc7b38e912a051ab046bc257167b9 (diff)
downloadelectron-5f86ae2995cad6044c1c8fe3ebf98e5085658a90.tar.gz
electron-5f86ae2995cad6044c1c8fe3ebf98e5085658a90.tar.bz2
electron-5f86ae2995cad6044c1c8fe3ebf98e5085658a90.tar.xz
electron-5f86ae2995cad6044c1c8fe3ebf98e5085658a90.zip
social buttons and debug btn
-rw-r--r--assets/index.css10
-rw-r--r--assets/index.html1
-rw-r--r--src/main.ts15
-rw-r--r--src/main/status.ts47
-rw-r--r--src/renderer/gameserver/server.ts12
-rw-r--r--src/renderer/index.ts10
-rw-r--r--src/renderer/serverView.ts8
7 files changed, 97 insertions, 6 deletions
diff --git a/assets/index.css b/assets/index.css
index ebe0e30..148f818 100644
--- a/assets/index.css
+++ b/assets/index.css
@@ -278,3 +278,13 @@ html, body {
#serverPage::-webkit-scrollbar-thumb:hover {
background-color: rgba(255,255,255,0.5);
}
+
+.socialContainer {
+ height:20pt;
+ margin-bottom: 4pt;
+}
+
+.socialContainer > button {
+ height:16pt;
+ margin-left: 3pt;
+}
diff --git a/assets/index.html b/assets/index.html
index a4e7972..2e75101 100644
--- a/assets/index.html
+++ b/assets/index.html
@@ -13,6 +13,7 @@
<div id="topbar">
<span>LawnCable's Mana Launcher</span>
<div class="topbar-btn-container">
+ <button id="debug"><i class="fas fa-terminal"></i></button>
<button id="minimize"><i class="fas fa-minus"></i></button>
<button id="quit"><i class="fas fa-times"></i></button>
</div>
diff --git a/src/main.ts b/src/main.ts
index dc2e47d..40e999f 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -2,7 +2,7 @@ import { app, BrowserWindow, ipcMain, remote } from 'electron';
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
-let mainWindow: BrowserWindow;
+export let mainWindow: BrowserWindow;
const isSecondInstance = app.makeSingleInstance(() => {
// Someone tried to run a second instance, we should focus our window.
if (mainWindow) {
@@ -30,8 +30,6 @@ const createWindow = () => {
// Open the DevTools.
mainWindow.webContents.openDevTools();
- //mainWindow.setProgressBar(0.5);
-
// Emitted when the window is closed.
mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
@@ -71,8 +69,19 @@ ipcMain.on('minimize', (event:any, arg:any)=> {
mainWindow.minimize();
});
+ipcMain.on('debug', (event:any, arg:any)=> {
+ if(mainWindow.webContents.isDevToolsOpened())
+ mainWindow.webContents.closeDevTools();
+ else
+ mainWindow.webContents.openDevTools();
+});
+
+import {Status} from './main/status';
ipcMain.on('play', (event:any, arg:any)=> {
console.log("play", arg);
+ Status.setPlaying(true);
+ Status.setProgress(500);
+ setTimeout(()=>{Status.setPlaying(false);Status.removeProgress();}, 10000);
});
diff --git a/src/main/status.ts b/src/main/status.ts
new file mode 100644
index 0000000..ffd6551
--- /dev/null
+++ b/src/main/status.ts
@@ -0,0 +1,47 @@
+import { mainWindow } from '../main';
+
+type STATUS = {
+ progress:number,
+ activity:string,
+ playing:boolean,
+}
+
+const status:STATUS = {
+ progress:null,
+ activity:null,
+ playing:false, //Is manaplus starting or started
+}
+
+export namespace Status {
+ export function setProgress(value: number){
+ status.progress=value;
+ updateStatus();
+ }
+ export function removeProgress(){
+ status.progress=null;
+ updateStatus();
+ }
+ export function setActivity(value: string){
+ status.activity=value;
+ updateStatus();
+ }
+ export function setPlaying(value: boolean){
+ status.playing=value;
+ updateStatus();
+ }
+ export function getStatus():STATUS{
+ return status;
+ }
+}
+
+function updateStatus(){
+
+ if(status.progress==null || status.progress<0)
+ mainWindow.setProgressBar(-1);
+ else if(status.progress>100)
+ mainWindow.setProgressBar(2);
+ else
+ mainWindow.setProgressBar(status.progress/100);
+
+ mainWindow.webContents.send('status-update', status);
+}
diff --git a/src/renderer/gameserver/server.ts b/src/renderer/gameserver/server.ts
index e18b43a..ca67553 100644
--- a/src/renderer/gameserver/server.ts
+++ b/src/renderer/gameserver/server.ts
@@ -115,6 +115,15 @@ export default class GameServer {
title.innerText = this.name;
content.appendChild(title);
+ const socialContainer = document.createElement('div');
+ socialContainer.classList.add("socialContainer");
+ setTimeout(()=>{
+ this.socialLinks.forEach((link)=>{
+ socialContainer.appendChild(link.getHTML());
+ });
+ }, 5);
+ content.appendChild(socialContainer);
+
const shrtDsrption = document.createElement('div');
shrtDsrption.classList.add("shortDescription");
shrtDsrption.innerText = this.shortDescription;
@@ -134,13 +143,14 @@ export class socialLink {
getHTML():HTMLElement{
//<button onclick="sv.openSocialLink(this)" socialLink="abc"><i class="fa fa-user"></i></button><br>
const element = document.createElement('button');
- element.onclick = this.open;
+ element.onclick = ()=>{this.open()};
element.innerHTML = `<i class="${this.icon}"></i>`;
element.title = this.tooltip;
return element;
}
open(){
+ console.log("A link was clicked!", this.url);
if(this.url)
shell.openExternal(this.url.indexOf("://")!==-1?this.url:`https://${this.url}`);
}
diff --git a/src/renderer/index.ts b/src/renderer/index.ts
index 7af2dea..944ee90 100644
--- a/src/renderer/index.ts
+++ b/src/renderer/index.ts
@@ -16,3 +16,13 @@ minimizeBtn.addEventListener('click', () => {
document.ondragover = document.ondrop = (event) => {
event.preventDefault();
};
+
+
+const debugBtn = document.getElementById('debug');
+
+//debugBtn.hidden = true;
+
+debugBtn.addEventListener('click', () => {
+ debugBtn.blur();
+ ipcRenderer.send('debug');
+});
diff --git a/src/renderer/serverView.ts b/src/renderer/serverView.ts
index 8176c42..48ce923 100644
--- a/src/renderer/serverView.ts
+++ b/src/renderer/serverView.ts
@@ -4,7 +4,7 @@ import { switchPage } from './CustomEvents';
let GameServerList:GameServer[] = null;
let SelectedGameserver:GameServer = null;
-const playBtn = document.getElementById('play');
+const playBtn:HTMLButtonElement = document.getElementById('play') as (HTMLButtonElement);
playBtn.addEventListener('click', () => {
ipcRenderer.send('play', SelectedGameserver.profile);
@@ -103,7 +103,11 @@ function setBackground(){
peviousSelectedGameserver = SelectedGameserver;
}
-
+ipcRenderer.on('status-update', (event:any, status:any) => {
+ const message = `Asynchronous message reply: ${status}`
+ console.log(message, status);
+ playBtn.disabled = status.playing;
+})