From b2a2bbc3637aba679eb2bcdd1c425cf020101b5c Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Tue, 25 Oct 2022 13:41:03 +0300 Subject: [PATCH] fix game launch --- projects/ui/src/lib/game/game.component.ts | 7 +++++-- .../menu-games/menu-games.component.ts | 20 +++++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/projects/ui/src/lib/game/game.component.ts b/projects/ui/src/lib/game/game.component.ts index 6042768..222385f 100644 --- a/projects/ui/src/lib/game/game.component.ts +++ b/projects/ui/src/lib/game/game.component.ts @@ -1,5 +1,6 @@ import { Component, Input, OnInit } from '@angular/core'; import { Game } from 'src/app/interfaces/game.interface' +import { LauncherService } from 'src/app/services/launcher.service'; @Component({ selector: 'skirda-game[game]', @@ -9,12 +10,14 @@ import { Game } from 'src/app/interfaces/game.interface' export class GameComponent implements OnInit { @Input() game!: Game - constructor() { } + constructor(private launcher: LauncherService) { } ngOnInit(): void { + this.game.image = "assets/games/" + this.game.gameId + "/icon.png" } run(game: Game) { - console.log('Game to run ' + game.title) + //console.log('Game to run ' + game.title) + this.launcher.RunGame(game) } } diff --git a/src/app/components/main/main-menu/menu-games/menu-games.component.ts b/src/app/components/main/main-menu/menu-games/menu-games.component.ts index 03cc9ab..37be063 100644 --- a/src/app/components/main/main-menu/menu-games/menu-games.component.ts +++ b/src/app/components/main/main-menu/menu-games/menu-games.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { Game } from 'src/app/interfaces/game.interface' +import { GetGames } from 'src/app/services/go'; @Component({ selector: 'app-menu-games', @@ -7,23 +8,34 @@ import { Game } from 'src/app/interfaces/game.interface' styleUrls: ['./menu-games.component.scss'] }) export class MenuGamesComponent implements OnInit { - games: Game[] = [{ - gameId: 'id:minecraft', + fakeGames: Game[] = [{ + gameId: 'minecraft', title: 'Minecraft', image: '/assets/games/minecraft/icon.png', }, { - gameId: 'id:garrysmod', + gameId: 'garrysmod', title: 'Garry\'s mod', image: '/assets/games/garrysmod/icon.png', }, { - gameId: 'id:openarena', + gameId: 'openarena', title: 'OpenArena', image: '/assets/games/openarena/icon.png', }] + games: Game[] = [] + constructor() { } ngOnInit(): void { + if (GetGames == undefined){ + this.games = this.fakeGames + } + else{ + GetGames().then((value) => { + console.log(value); + this.games = value; + }); + } } }