summaryrefslogtreecommitdiff
path: root/src/renderer/gameserver
diff options
context:
space:
mode:
authorLawnCable <lawncable.tmw2@simonlaux.de>2018-05-20 16:21:58 -0400
committerLawnCable <lawncable.tmw2@simonlaux.de>2018-05-20 16:21:58 -0400
commit181e277b6cc4a085864d44f4e9b5a5322cf6ec4e (patch)
treee93c5fdf89ba88484c183b64dc05e012c50a4c69 /src/renderer/gameserver
parenta7f4fff0fdf72876281d7a2e78afaca625e0d6cb (diff)
downloadelectron-181e277b6cc4a085864d44f4e9b5a5322cf6ec4e.tar.gz
electron-181e277b6cc4a085864d44f4e9b5a5322cf6ec4e.tar.bz2
electron-181e277b6cc4a085864d44f4e9b5a5322cf6ec4e.tar.xz
electron-181e277b6cc4a085864d44f4e9b5a5322cf6ec4e.zip
pre-prototype
Diffstat (limited to 'src/renderer/gameserver')
-rw-r--r--src/renderer/gameserver/data.ts66
-rw-r--r--src/renderer/gameserver/profile.ts8
-rw-r--r--src/renderer/gameserver/server.ts117
3 files changed, 191 insertions, 0 deletions
diff --git a/src/renderer/gameserver/data.ts b/src/renderer/gameserver/data.ts
new file mode 100644
index 0000000..429e2bf
--- /dev/null
+++ b/src/renderer/gameserver/data.ts
@@ -0,0 +1,66 @@
+// This class returns Data over the gameservers until we find a better solution
+import {socialLink} from './server';
+import GameServer from './server';
+import GameServerProfile from './profile';
+
+
+const TMW2 = new GameServer(
+ new GameServerProfile(
+ "server.tmw2.org",
+ 6901,
+ "evol2",
+ "TMW2"
+ ),
+ "TMW2",
+ "TMW2: Monster Wars",
+ "What happens if you mix TMW with Evol and add many new Ideas",
+ "https://tmw2.org/feed.xml",
+ [{isVideo:false,file:"tmw2/background1.png"}],
+ "tmw2/icon.png",
+ [
+ new socialLink("fas fa-home","Website","https://tmw2.org"),
+ new socialLink("fab fa-discord","Discord","https://discord.gg/J4gcaqM"),
+ new socialLink("fas fa-users","Forum","https://tmw2.org/forums/"),
+ ]
+);
+
+const Evol = new GameServer(
+ new GameServerProfile(
+ "world.evolonline.org",
+ 6901,
+ "evol2"
+ ),
+ "Evol Online",
+ "Evol Online",
+ "[EvolDescription]",
+ undefined,// Insert feed.xml here if found
+ [],
+ "evol/icon.png",
+ [
+ new socialLink("fas fa-home","Website","https://evolonline.org/"),
+ ]
+);
+
+const TMW = new GameServer(
+ new GameServerProfile(
+ "server.themanaworld.org",
+ 6901,
+ "tmwAthena"
+ ),
+ "The Mana World",
+ "The Mana World",
+ "The clasic TMW experience. Join adventures with people from all over the world.",
+ undefined,// Insert feed.xml here if found
+ [],
+ "tmw/icon.png",
+ [
+ new socialLink("fas fa-home","Website","https://www.themanaworld.org/"),
+ new socialLink("fas fa-users","Forum","https://forums.themanaworld.org/"),
+ ]
+);
+
+export const GameServers = [
+ TMW2,
+ Evol,
+ TMW
+]
diff --git a/src/renderer/gameserver/profile.ts b/src/renderer/gameserver/profile.ts
new file mode 100644
index 0000000..4c99184
--- /dev/null
+++ b/src/renderer/gameserver/profile.ts
@@ -0,0 +1,8 @@
+export default class GameServerProfile {
+ constructor(
+ public address:string,
+ public port:number,
+ public engine:"tmwAthena"|"hercules"|"evol2",
+ public serverID:string = "DEFAULT", // To enable some server specific features
+ ){}
+}
diff --git a/src/renderer/gameserver/server.ts b/src/renderer/gameserver/server.ts
new file mode 100644
index 0000000..cc7a90f
--- /dev/null
+++ b/src/renderer/gameserver/server.ts
@@ -0,0 +1,117 @@
+import GameServerProfile from './profile';
+import { shell } from 'electron';
+import { switchPage } from '../CustomEvents';
+
+
+export default class GameServer {
+ constructor(
+ public profile:GameServerProfile,
+ public menuName:string,
+ public name:string,
+ public shortDescription:string,// the server in 1-2 sentences
+ public newsFeed:string,
+ public backgrounds:{isVideo:boolean,file:string}[],
+ public icon:string,
+ public socialLinks:socialLink[]
+ ){}
+
+ getMenuEntry():HTMLElement{
+ const sidebarItem = document.createElement('div');
+ sidebarItem.classList.add("sidebarItem");
+
+ //Title
+ const title = document.createElement('div');
+ title.classList.add("title");
+
+ const titleIMG = document.createElement('img');
+ titleIMG.src = `./media/server/${this.icon}`;
+
+ const titleText = document.createElement('div');
+ titleText.innerText = this.menuName;
+
+ title.appendChild(titleIMG);
+ title.appendChild(titleText);
+
+ title.addEventListener('click', ()=>{
+ switchPage("SERVER",this.name);
+ });
+
+ sidebarItem.appendChild(title);
+ //Collapsable
+ const container = document.createElement('div');
+ container.classList.add("colapse");
+
+ const info = document.createElement('div');
+ info.innerHTML = '<i class="fas fa-info fa-fw"></i>Information';
+ container.appendChild(info);
+
+ info.addEventListener('click', ()=>{
+ switchPage("SERVER",this.name);
+ });
+
+ const news = document.createElement('div');
+ news.innerHTML = '<i class="far fa-newspaper fa-fw"></i>News';
+ if(this.newsFeed && this.newsFeed!==null){
+ news.addEventListener('click', ()=>{
+ switchPage("SERVER",this.name,"NEWS");
+ });
+ } else {
+ news.hidden = true;
+ }
+
+ container.appendChild(news);
+
+ const preferences = document.createElement('div');
+ preferences.innerHTML = '<i class="fas fa-sliders-h fa-fw"></i>Preferences';
+ preferences.addEventListener('click', ()=>{
+ switchPage("SERVER",this.name,"PREF");
+ });
+ container.appendChild(preferences);
+
+ sidebarItem.appendChild(container);
+ //event Target / interactivity
+ const events = document.createElement('span');
+ events.classList.add("switch-page-event");
+ events.addEventListener("site-changed", (event:CustomEvent)=>{
+ sidebarItem.classList.remove("selected");
+ info.classList.remove("selected");
+ news.classList.remove("selected");
+ preferences.classList.remove("selected");
+ if(event.detail.sitetype === "SERVER" && event.detail.page === this.name){
+ sidebarItem.classList.add("selected");
+ if(event.detail.subPage === "NEWS") {
+ news.classList.add("selected");
+ } else if(event.detail.subPage === "PREF") {
+ preferences.classList.add("selected");
+ } else {
+ info.classList.add("selected");
+ }
+ }
+ });
+
+ sidebarItem.appendChild(events);
+ return sidebarItem;
+ }
+}
+
+export class socialLink {
+ constructor(
+ public icon:string,// has to be one from font awesome -https://fontawesome.com/icons
+ public tooltip:string,
+ public url:string
+ ){}
+
+ 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.innerHTML = `<i class="${this.icon}"></i>`;
+ element.title = this.tooltip;
+ return element;
+ }
+
+ open(){
+ if(this.url)
+ shell.openExternal(this.url.indexOf("://")!==-1?this.url:`https://${this.url}`);
+ }
+}