fix game launch

This commit is contained in:
cyber-dream 2022-10-25 13:41:03 +03:00
parent 5b960ed297
commit b2a2bbc363
2 changed files with 21 additions and 6 deletions

View File

@ -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)
}
}

View File

@ -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;
});
}
}
}