diff --git a/Config/.gitignore b/Config/.gitignore deleted file mode 100644 index d344ba6..0000000 --- a/Config/.gitignore +++ /dev/null @@ -1 +0,0 @@ -config.json diff --git a/Config/config.json.template b/Config/config.json.template deleted file mode 100644 index 43d31e9..0000000 --- a/Config/config.json.template +++ /dev/null @@ -1,4 +0,0 @@ -{ - "pathToLolExe": "", - "pathToLolFolder": "" -} diff --git a/package.json b/package.json index 111d84c..0fe201e 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "bundle": "./node_modules/.bin/webpack --bail", "clean": "rm -r built src/built", "package:osx": "./node_modules/.bin/electron-packager . LobbyClient --out=built --platform=darwin --arch=x64 --version=0.37.5 --ignore='(node_modules|src/ui/components|src/ui/directives|src/ui/css|src/ui/services)'", - "package:win": "./node_modules/.bin/electron-packager . LobbyClient --out=built --platform=win32 --arch=x64 --version=0.37.5 --ignore='(node_modules|src/ui/components|src/ui/directives|src/ui/css|src/ui/services)'", + "package:win": "./node_modules/.bin/electron-packager . LobbyClient --out=built --platform=win32 --arch=x64 --version=0.37.5 --ignore='node_modules' --ignore='src/ui/components' --ignore='src/ui/directives' --ignore='src/ui/css' --ignore='src/ui/services'", "test": "npm run bundle" }, "keywords": [ @@ -48,8 +48,8 @@ "dependencies": { "babel-polyfill": "^6.7.4", "bluebird": "^3.3.4", - "font-awesome": "^4.5.0", - "socket.io-client": "^1.4.5", + "font-awesome": "^4.7.0", + "socket.io-client": "^2.0.0", "vue": "^1.0.24", "vue-router": "^0.7.13" } diff --git a/src/ui/components/loading/loadingComponent.ts b/src/ui/components/loading/loadingComponent.ts deleted file mode 100644 index da7b792..0000000 --- a/src/ui/components/loading/loadingComponent.ts +++ /dev/null @@ -1,38 +0,0 @@ -/// -'use strict'; - -import Component from "vue-class-component"; -const Vue = require("vue"); - -import "../../css/loading.less"; - -import CDNService from "../../services/cdnService.ts"; -import StaticService from "../../services/staticService.ts"; -import NetworkService from "../../services/networkService.ts"; -import SettingService from "../../services/settingService.ts"; - -@Component({ - template: require("./loadingView.html") -}) -export default class LoadingComponent extends Vue { - private state: string; - - data() { - return { - state: "Loading assets..." - }; - } - - ready() { - CDNService.load().then(() => { - this.state = "Populating data..."; - return StaticService.populate(); - }).then(() => { - this.state = "Connecting to server..."; - return NetworkService.connectToCentral("http://localhost:9090"); - }).then(() => { - this.state = "Done!"; - this.$router.go("/login"); - }); - } -} \ No newline at end of file diff --git a/src/ui/components/loading/loadingView.html b/src/ui/components/loading/loadingView.html deleted file mode 100644 index 40b7dbc..0000000 --- a/src/ui/components/loading/loadingView.html +++ /dev/null @@ -1,14 +0,0 @@ -
- {{ state }} -
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file diff --git a/src/ui/components/lobby/lobbyComponent.ts b/src/ui/components/lobby/lobbyComponent.ts index 633697c..d3651d9 100644 --- a/src/ui/components/lobby/lobbyComponent.ts +++ b/src/ui/components/lobby/lobbyComponent.ts @@ -28,77 +28,101 @@ Vue.partial("lobby-player-list", require("./partials/playerList.html")); export default class LobbyComponent extends Vue { private message: string; private messages: ChatMessages[]; - + private settings: SettingService; private lobby: lobby.Lobby; - - data() { - return { - message: "", - messages: [], - lobby: NetworkServiceStatic.currentLobby, - - // The settings property is not needed, but - // adding it forces Vue to observe it. This - // way we get notified of changes and update. - settings: SettingServiceStatic, - }; - } - - created() { + private isHost: boolean; + + ready() { // Mainly for debugging. Redirects if there's no connection. if (!NetworkServiceStatic.currentConnection) { - this.$router.go("/loading"); + this.$router.go("/login"); } - + + NetworkServiceStatic.on("host", isHost => { + this.isHost = isHost; + }); + + NetworkServiceStatic.on("start-championselect", () => { + this.$router.go("/championSelect"); + }); NetworkServiceStatic.on("chat", (timestamp, sender, message) => { if (this.messages.length && this.messages[this.messages.length - 1].sender === sender) { this.messages[this.messages.length - 1].messages.push(message); } else { this.messages.push({ timestamp, sender, messages: [message] }); } - + // Scroll down on the next tick if we aren't scrolled yet. // We scroll down next tick because by then the contents of the // chat will have been updated with the newly added message. const el = document.getElementById("chat-container"); const isAttached = el.scrollTop + el.clientHeight + 1 >= el.scrollHeight; - + this.$nextTick(() => { // If we were attached before the element got bigger, scroll down. // This effectively reattaches the scroll. if (isAttached) { el.scrollTop = el.scrollHeight; } - }); + }); }); + + NetworkServiceStatic.currentLobbyConnection.emit("host"); + } + data() { + return { + message: "", + messages: [], + lobby: NetworkServiceStatic.currentLobby, + network: NetworkService, + isHost: this.isHost, + + // The settings property is not needed, but + // adding it forces Vue to observe it. This + // way we get notified of changes and update. + settings: SettingServiceStatic, + }; } - + + created() { + } + playersInTeam(team: lobby.Team) { return this.lobby.players.filter(x => x.team === team); } - + getOrNone(url = CDNService.getPath("assets/storeImages/layout/g-background_generic.jpg")) { return url; } - + sendChat() { NetworkServiceStatic.sendMessage(this.message); this.message = ""; } - + joinTeam(team: lobby.Team) { NetworkServiceStatic.joinTeam(team); } - startGame(){ - NetworkServiceStatic.startGame(); + + startChampionSelect() { + NetworkServiceStatic.startChampionSelect(); } - - get playerSettings() { - return this.settings.playerSettings; + + leave() { + NetworkServiceStatic.leaveLobby(); + this.$router.go("/lobbies"); } - + + iconByUser(user: { idServer: number}) { + return StaticService.iconById(NetworkServiceStatic.userById(user.idServer).iconId).iconURL; + } + get hostSettings() { return this.settings.hostSettings; } -} \ No newline at end of file + + openLobbySettings() { + ModalComponent.present("lobby-settings", this.settings); + } +} diff --git a/src/ui/components/lobby/lobbyView.html b/src/ui/components/lobby/lobbyView.html index 5ccd8ee..c077e0f 100644 --- a/src/ui/components/lobby/lobbyView.html +++ b/src/ui/components/lobby/lobbyView.html @@ -1,10 +1,20 @@ -
-
-
-
-
+
+
+ {{ lobby.name }} +
+
+ {{ lobby.gamemodeName }} Map name 5v5 Blind pick +
+
-
+ + +
\ No newline at end of file diff --git a/src/ui/components/lobby/partials/chat.html b/src/ui/components/lobby/partials/chat.html index e9d3ff4..30b953b 100644 --- a/src/ui/components/lobby/partials/chat.html +++ b/src/ui/components/lobby/partials/chat.html @@ -1,13 +1,14 @@ -
-
- {{ group.timestamp | formatTime }} - {{ group.sender }} -
- {{ message }} -
+
+
+ + {{ group.timestamp | formatTime }} {{ group.sender }}: +
+
{{ message }}
+
+
-
-
- +
+ +
\ No newline at end of file diff --git a/src/ui/components/lobby/partials/playerList.html b/src/ui/components/lobby/partials/playerList.html index ce20b0e..ad7f90f 100644 --- a/src/ui/components/lobby/partials/playerList.html +++ b/src/ui/components/lobby/partials/playerList.html @@ -1,18 +1,19 @@ -
- {{ team.name }} - -
- {{ player.name }} - - +
+
+
+
{{ team.name }}
+ +
+
+ + {{ player.username }} {{ player.id }} {{ player.idServer }} {{ player.isHost }} +
+
+
+ + +
- -
- JOIN -
-
-
- START
diff --git a/src/ui/components/lobby/partials/settings.html b/src/ui/components/lobby/partials/settings.html index a53dd7b..527adcc 100644 --- a/src/ui/components/lobby/partials/settings.html +++ b/src/ui/components/lobby/partials/settings.html @@ -1,15 +1,4 @@ - -
- Lobby - - Configure -
- -
-
- -
- +
diff --git a/src/ui/components/lobbyList/lobbyListComponent.ts b/src/ui/components/lobbyList/lobbyListComponent.ts index a1e13a9..e899613 100644 --- a/src/ui/components/lobbyList/lobbyListComponent.ts +++ b/src/ui/components/lobbyList/lobbyListComponent.ts @@ -6,29 +6,38 @@ const Vue = require("vue"); import "../../css/lobby-list.less"; import NetworkService from "../../services/networkService.ts"; +import StaticService from "../../services/staticService.ts"; @Component({ template: require("./lobbyListView.html") }) export default class LobbyListComponent extends Vue { - private username: string; + private lobbySelected: lobby.LobbyListItem; + private canCreateLobby: boolean; created() { // Mainly for debugging. Redirects if theres no connection. if (!NetworkService.currentConnection) { - this.$router.go("/loading"); + this.$router.go("/login"); } } data() { + this.canCreateLobby = true; return { - username: "Player", - network: NetworkService + network: NetworkService, + staticService: StaticService, + lobbySelected: undefined, + canCreateLobby: this.canCreateLobby }; } + select(lobby: lobby.LobbyListItem) { + this.lobbySelected = lobby; + } + join(lobby: lobby.LobbyListItem) { - NetworkService.joinLobby(lobby, this.username).then(() => { + NetworkService.joinLobby(lobby).then(() => { console.log("Connected to lobby."); this.$router.go("/lobby"); }, err => { @@ -36,4 +45,18 @@ export default class LobbyListComponent extends Vue { console.log(err.stack); }); } + + //TODO: limit lobby creation when clicked + create() { + if (!this.canCreateLobby) return; + + this.canCreateLobby = false; + NetworkService.createLobby().then(() => { + console.log("Created lobby."); + this.$router.go("/lobby"); + }, err => { + console.log("Couldn't create a lobby."); + console.log(err.stack); + }); + } } \ No newline at end of file diff --git a/src/ui/components/lobbyList/lobbyListView.html b/src/ui/components/lobbyList/lobbyListView.html index 883617b..3c7ccdb 100644 --- a/src/ui/components/lobbyList/lobbyListView.html +++ b/src/ui/components/lobbyList/lobbyListView.html @@ -1,9 +1,41 @@ - - -
-
- {{ lobby.name }} - {{ lobby.creator }}
- {{ lobby.playerCount }}/{{ lobby.playerLimit }}
- {{ lobby.address }}:{{ lobby.port }} +
+
+
+ + + + + + + + + + + + +
Lobby nameOwnerGamemodeUsers
+
+
+ + +
+
+
+
+ +
\ No newline at end of file diff --git a/src/ui/components/lobbySettings/lobbySettingsComponent.ts b/src/ui/components/lobbySettings/lobbySettingsComponent.ts new file mode 100644 index 0000000..c054019 --- /dev/null +++ b/src/ui/components/lobbySettings/lobbySettingsComponent.ts @@ -0,0 +1,46 @@ +/// +'use strict'; + +import "../../css/lobby-settings.less"; +import ModalComponent from "../modal/modalComponent.ts"; +import StaticService from "../../services/staticService.ts"; +import SettingServiceStatic, { SettingService } from "../../services/settingService.ts"; + +import Component from "vue-class-component"; +const Vue = require("vue"); + +@Component({ + template: require("./lobbySettingsVue.html") +}) +export default class LobbySettingsComponent extends Vue { + + private listenerFun: (evt: KeyboardEvent) => void; + private selectedIcon: user.Icon; + private settings: SettingService; + + ready() { + // Attach ESC listener. Is removed in finish() call. + this.listenerFun = (evnt: KeyboardEvent) => { + if (evnt.keyCode !== 27) return; + this.finish(ModalComponent.params[0]); + }; + document.addEventListener("keyup", this.listenerFun); + } + + data() { + return { + staticService: StaticService, + selectedIcon: ModalComponent.params[0], + settings: SettingServiceStatic, + }; + } + + get hostSettings() { + return this.settings.hostSettings; + } + + finish(arg) { + ModalComponent.finish(arg); + document.removeEventListener("keyup", this.listenerFun); + } +} \ No newline at end of file diff --git a/src/ui/components/lobbySettings/lobbySettingsVue.html b/src/ui/components/lobbySettings/lobbySettingsVue.html new file mode 100644 index 0000000..ab6258e --- /dev/null +++ b/src/ui/components/lobbySettings/lobbySettingsVue.html @@ -0,0 +1,6 @@ +
Settings
+
+
+ +
+
\ No newline at end of file diff --git a/src/ui/components/login/loginComponent.ts b/src/ui/components/login/loginComponent.ts index 40298df..040e917 100644 --- a/src/ui/components/login/loginComponent.ts +++ b/src/ui/components/login/loginComponent.ts @@ -6,32 +6,84 @@ const Vue = require("vue"); import "../../css/login.less"; +import CDNService from "../../services/cdnService.ts"; +import StaticService from "../../services/staticService.ts"; +import NetworkService from "../../services/networkService.ts"; +import SettingService from "../../services/settingService.ts"; +import ModalComponent from "../modal/modalComponent.ts"; + @Component({ template: require("./loginView.html") }) export default class LoginComponent extends Vue { private isLoading: boolean; private previousInvalid: boolean; - + private username: string; - private password: string; - + private host: string; + private path: string; + private port: string; + private state: string; + private icon: any; + data() { + if (localStorage.getItem("path") != undefined && localStorage.getItem("path") != "") { + this.path = localStorage.getItem("path"); + } else { + this.path = "Path to LoL 4.20"; + } + if (localStorage.getItem("host") != undefined && localStorage.getItem("host") != "") { + this.host = localStorage.getItem("host"); + } + if (localStorage.getItem("port") != undefined && localStorage.getItem("port") != "") { + this.port = localStorage.getItem("port"); + } + if (localStorage.getItem("name") != undefined && localStorage.getItem("name") != "") { + this.username = localStorage.getItem("name"); + } + var iconId = 0; + if (localStorage.getItem("icon") != undefined && localStorage.getItem("icon") != "") { + iconId = parseInt(localStorage.getItem("icon")); + } + CDNService.load().then(() => { + return StaticService.populate(); + }).then(() => { + this.icon = StaticService.icons[iconId]; + }); return { isLoading: false, previousInvalid: false, - username: "", - password: "" + username: this.username, + host: this.host, + path: this.path, + port: this.port, + icon: this.icon }; } - + login() { - if (!this.username || !this.password) return; - + if (!this.username || !this.host || this.isLoading) return; + + localStorage.setItem("host", this.host); + localStorage.setItem("path", this.path); + localStorage.setItem("name", this.username); + localStorage.setItem("port", this.port); + localStorage.setItem("icon", this.indexByiconId(this.icon.id).toString()); + this.isLoading = true; this.previousInvalid = false; - setTimeout(() => { + NetworkService.connectToCentral("http://" + this.host + ":" + this.port, this.username, this.icon.id).then(() => { this.$router.go("/lobbies"); - }, 1000); + }); + } + + openIconPicker() { + ModalComponent.present("select-icon", this.icon).then(c => { + this.icon = c; + }); + } + + indexByiconId(id: number): number { + return StaticService.icons.indexOf(StaticService.icons.filter(x => x.id === id)[0]); } -} \ No newline at end of file +} diff --git a/src/ui/components/login/loginView.html b/src/ui/components/login/loginView.html index 00d0e37..6ade7e7 100644 --- a/src/ui/components/login/loginView.html +++ b/src/ui/components/login/loginView.html @@ -1,27 +1,13 @@ -