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 { Component, Input, OnInit } from '@angular/core';
import { Game } from 'src/app/interfaces/game.interface' import { Game } from 'src/app/interfaces/game.interface'
import { LauncherService } from 'src/app/services/launcher.service';
@Component({ @Component({
selector: 'skirda-game[game]', selector: 'skirda-game[game]',
@ -9,12 +10,14 @@ import { Game } from 'src/app/interfaces/game.interface'
export class GameComponent implements OnInit { export class GameComponent implements OnInit {
@Input() game!: Game @Input() game!: Game
constructor() { } constructor(private launcher: LauncherService) { }
ngOnInit(): void { ngOnInit(): void {
this.game.image = "assets/games/" + this.game.gameId + "/icon.png"
} }
run(game: Game) { 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 { Component, OnInit } from '@angular/core';
import { Game } from 'src/app/interfaces/game.interface' import { Game } from 'src/app/interfaces/game.interface'
import { GetGames } from 'src/app/services/go';
@Component({ @Component({
selector: 'app-menu-games', selector: 'app-menu-games',
@ -7,23 +8,34 @@ import { Game } from 'src/app/interfaces/game.interface'
styleUrls: ['./menu-games.component.scss'] styleUrls: ['./menu-games.component.scss']
}) })
export class MenuGamesComponent implements OnInit { export class MenuGamesComponent implements OnInit {
games: Game[] = [{ fakeGames: Game[] = [{
gameId: 'id:minecraft', gameId: 'minecraft',
title: 'Minecraft', title: 'Minecraft',
image: '/assets/games/minecraft/icon.png', image: '/assets/games/minecraft/icon.png',
}, { }, {
gameId: 'id:garrysmod', gameId: 'garrysmod',
title: 'Garry\'s mod', title: 'Garry\'s mod',
image: '/assets/games/garrysmod/icon.png', image: '/assets/games/garrysmod/icon.png',
}, { }, {
gameId: 'id:openarena', gameId: 'openarena',
title: 'OpenArena', title: 'OpenArena',
image: '/assets/games/openarena/icon.png', image: '/assets/games/openarena/icon.png',
}] }]
games: Game[] = []
constructor() { } constructor() { }
ngOnInit(): void { ngOnInit(): void {
if (GetGames == undefined){
this.games = this.fakeGames
}
else{
GetGames().then((value) => {
console.log(value);
this.games = value;
});
}
} }
} }