create games info with launch buttons
This commit is contained in:
parent
299b87d9ec
commit
e9a1dcdb50
@ -1,5 +1,4 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { GetVersion, GetVersionCallbackDetail, RunGame } from './services/go';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@ -17,10 +16,10 @@ export class AppComponent {
|
|||||||
if (!(event instanceof CustomEvent<string>)) return;
|
if (!(event instanceof CustomEvent<string>)) return;
|
||||||
this.version = event.detail;
|
this.version = event.detail;
|
||||||
});
|
});
|
||||||
GetVersion();
|
//GetVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
RunGame() {
|
RunGame() {
|
||||||
RunGame();
|
//RunGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,15 @@ import {
|
|||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './modules/app-routing.module';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { GamesBarComponent } from './games-bar/games-bar.component';
|
|
||||||
import { GameButtonComponent } from './games-bar/game-button/game-button.component';
|
|
||||||
import { TuiAvatarModule } from "@taiga-ui/kit";
|
import { TuiAvatarModule } from "@taiga-ui/kit";
|
||||||
|
import { GamesBarModule } from "./components/games-bar/games-bar.module";
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [AppComponent, GamesBarComponent, GameButtonComponent],
|
declarations: [AppComponent],
|
||||||
imports: [BrowserModule, AppRoutingModule, BrowserAnimationsModule, TuiRootModule, TuiDialogModule, TuiAlertModule, TuiButtonModule, TuiAvatarModule],
|
imports: [BrowserModule, AppRoutingModule, BrowserAnimationsModule, TuiRootModule, TuiDialogModule, TuiAlertModule, TuiButtonModule, TuiAvatarModule, GamesBarModule],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: APP_BASE_HREF, useValue: '/' },
|
{ provide: APP_BASE_HREF, useValue: '/' },
|
||||||
{ provide: LocationStrategy, useClass: HashLocationStrategy },
|
{ provide: LocationStrategy, useClass: HashLocationStrategy },
|
||||||
|
@ -1,2 +1,20 @@
|
|||||||
<h1>{{game.title}}</h1>
|
<h1>{{game.title}}</h1>
|
||||||
<p>{{game.description}}</p>
|
<p>{{game.description}}</p>
|
||||||
|
<ng-template #icon>
|
||||||
|
<tui-avatar
|
||||||
|
size="xs"
|
||||||
|
[rounded]="true"
|
||||||
|
[avatarUrl]="'http://jpg.jpg'"
|
||||||
|
></tui-avatar>
|
||||||
|
</ng-template>
|
||||||
|
|
||||||
|
<button
|
||||||
|
tuiButton
|
||||||
|
type="button"
|
||||||
|
appearance="primary"
|
||||||
|
[icon]="icon"
|
||||||
|
class="tui-space_right-3 tui-space_bottom-3"
|
||||||
|
(click)= "runGame()"
|
||||||
|
>
|
||||||
|
<ng-content></ng-content>
|
||||||
|
</button>
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
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 {TuiButtonModule} from '@taiga-ui/core';
|
||||||
|
import { LauncherService } from 'src/app/services/launcher.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-game-info[game]',
|
selector: 'app-game-info[game]',
|
||||||
@ -9,7 +11,12 @@ import { Game } from 'src/app/interfaces/game.interface';
|
|||||||
export class GameInfoComponent implements OnInit {
|
export class GameInfoComponent implements OnInit {
|
||||||
@Input() game!: Game;
|
@Input() game!: Game;
|
||||||
|
|
||||||
constructor() {}
|
constructor(private launcher: LauncherService) {}
|
||||||
|
|
||||||
ngOnInit(): void {}
|
ngOnInit(): void {}
|
||||||
|
|
||||||
|
runGame(){
|
||||||
|
//console.log("hello")
|
||||||
|
this.launcher.RunGame(this.game)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,9 @@ export class GamesBarComponent implements OnInit {
|
|||||||
GetGames().then((value) => {
|
GetGames().then((value) => {
|
||||||
console.log(value);
|
console.log(value);
|
||||||
this.games = value;
|
this.games = value;
|
||||||
|
if (this.games.length > 0){
|
||||||
|
this.activeGame = 0
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,12 @@ import { CommonModule } from '@angular/common';
|
|||||||
import { GamesBarComponent } from './games-bar.component';
|
import { GamesBarComponent } from './games-bar.component';
|
||||||
import { GameItemComponent } from './game-item/game-item.component';
|
import { GameItemComponent } from './game-item/game-item.component';
|
||||||
import { GameInfoComponent } from './game-info/game-info.component';
|
import { GameInfoComponent } from './game-info/game-info.component';
|
||||||
|
import {TuiButtonModule} from '@taiga-ui/core';
|
||||||
|
import { TuiAvatarComponent, TuiAvatarModule } from '@taiga-ui/kit';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [GamesBarComponent, GameItemComponent, GameInfoComponent],
|
declarations: [GamesBarComponent, GameItemComponent, GameInfoComponent],
|
||||||
imports: [CommonModule],
|
imports: [CommonModule,TuiButtonModule, TuiAvatarModule],
|
||||||
exports: [GamesBarComponent, GameItemComponent, GameInfoComponent],
|
exports: [GamesBarComponent, GameItemComponent, GameInfoComponent],
|
||||||
})
|
})
|
||||||
export class GamesBarModule {}
|
export class GamesBarModule {}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
export interface Game {
|
export interface Game {
|
||||||
id: number;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
image: string;
|
image: string;
|
||||||
description: string;
|
description: string;
|
||||||
}
|
}
|
||||||
|
|
@ -2,13 +2,14 @@ import { Game } from '../interfaces/game.interface';
|
|||||||
|
|
||||||
export interface Go extends Window {
|
export interface Go extends Window {
|
||||||
GetGames: () => Promise<Game[]>;
|
GetGames: () => Promise<Game[]>;
|
||||||
|
GoRunGame: (gameId: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GoCallback extends Window {
|
export interface GoCallback extends Window {
|
||||||
SetVersion: (value: string) => void;
|
SetVersion: (value: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { GetGames } = window as unknown as Go;
|
let { GetGames, GoRunGame } = window as unknown as Go;
|
||||||
let { SetVersion } = window as unknown as GoCallback;
|
let { SetVersion } = window as unknown as GoCallback;
|
||||||
|
|
||||||
let w = window as unknown as GoCallback;
|
let w = window as unknown as GoCallback;
|
||||||
@ -29,4 +30,4 @@ let w = window as unknown as GoCallback;
|
|||||||
// document.dispatchEvent(event);
|
// document.dispatchEvent(event);
|
||||||
// };
|
// };
|
||||||
|
|
||||||
export { GetGames, SetVersion };
|
export { GetGames, SetVersion, GoRunGame };
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Game } from './oxana.service';
|
import { Game } from '../interfaces/game.interface';
|
||||||
|
import { GoRunGame } from './go';
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
@ -7,13 +8,13 @@ export class LauncherService {
|
|||||||
|
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
public GetGames(): Game[]{
|
// public GetGames(): Game[]{
|
||||||
var currentGames :Game[] = [
|
// var currentGames :Game[]
|
||||||
{ name: "ad", icon: "string", id: "string"},
|
// return currentGames
|
||||||
{ name: "qwet", icon: "string", id: "string"},
|
// }
|
||||||
{ name: "1233", icon: "string", id: "string"},
|
|
||||||
{ name: "ghjghj", icon: "string", id: "string"}
|
public RunGame(game: Game){
|
||||||
]
|
//console.log(game)
|
||||||
return currentGames
|
GoRunGame(game.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { LauncherService } from './launcher.service';
|
import { LauncherService } from './launcher.service';
|
||||||
|
import { Game } from '../interfaces/game.interface';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -16,8 +17,3 @@ export class OxanaService {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Game {
|
|
||||||
name: string
|
|
||||||
icon: string
|
|
||||||
id: string
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user