From e9a1dcdb50d6925dda8c55332f99afb2edafb17e Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Mon, 17 Oct 2022 21:48:28 +0300 Subject: [PATCH] create games info with launch buttons --- .../game-button/game-button.component.html | 0 .../game-button/game-button.component.scss | 0 .../game-button/game-button.component.spec.ts | 0 .../game-button/game-button.component.ts | 0 .../games-bar/games-bar.component.html | 0 .../games-bar/games-bar.component.scss | 0 .../games-bar/games-bar.component.spec.ts | 0 .../games-bar/games-bar.component.ts | 0 src/app/app.component.ts | 5 ++--- src/app/app.module.ts | 9 ++++----- .../game-info/game-info.component.html | 18 ++++++++++++++++++ .../game-info/game-info.component.ts | 9 ++++++++- .../games-bar/games-bar.component.ts | 3 +++ .../components/games-bar/games-bar.module.ts | 4 +++- src/app/interfaces/game.interface.ts | 11 ++++++----- src/app/services/go.ts | 5 +++-- src/app/services/launcher.service.ts | 19 ++++++++++--------- src/app/services/oxana.service.ts | 6 +----- 18 files changed, 58 insertions(+), 31 deletions(-) rename {src/app => .obsolete}/games-bar/game-button/game-button.component.html (100%) rename {src/app => .obsolete}/games-bar/game-button/game-button.component.scss (100%) rename {src/app => .obsolete}/games-bar/game-button/game-button.component.spec.ts (100%) rename {src/app => .obsolete}/games-bar/game-button/game-button.component.ts (100%) rename {src/app => .obsolete}/games-bar/games-bar.component.html (100%) rename {src/app => .obsolete}/games-bar/games-bar.component.scss (100%) rename {src/app => .obsolete}/games-bar/games-bar.component.spec.ts (100%) rename {src/app => .obsolete}/games-bar/games-bar.component.ts (100%) diff --git a/src/app/games-bar/game-button/game-button.component.html b/.obsolete/games-bar/game-button/game-button.component.html similarity index 100% rename from src/app/games-bar/game-button/game-button.component.html rename to .obsolete/games-bar/game-button/game-button.component.html diff --git a/src/app/games-bar/game-button/game-button.component.scss b/.obsolete/games-bar/game-button/game-button.component.scss similarity index 100% rename from src/app/games-bar/game-button/game-button.component.scss rename to .obsolete/games-bar/game-button/game-button.component.scss diff --git a/src/app/games-bar/game-button/game-button.component.spec.ts b/.obsolete/games-bar/game-button/game-button.component.spec.ts similarity index 100% rename from src/app/games-bar/game-button/game-button.component.spec.ts rename to .obsolete/games-bar/game-button/game-button.component.spec.ts diff --git a/src/app/games-bar/game-button/game-button.component.ts b/.obsolete/games-bar/game-button/game-button.component.ts similarity index 100% rename from src/app/games-bar/game-button/game-button.component.ts rename to .obsolete/games-bar/game-button/game-button.component.ts diff --git a/src/app/games-bar/games-bar.component.html b/.obsolete/games-bar/games-bar.component.html similarity index 100% rename from src/app/games-bar/games-bar.component.html rename to .obsolete/games-bar/games-bar.component.html diff --git a/src/app/games-bar/games-bar.component.scss b/.obsolete/games-bar/games-bar.component.scss similarity index 100% rename from src/app/games-bar/games-bar.component.scss rename to .obsolete/games-bar/games-bar.component.scss diff --git a/src/app/games-bar/games-bar.component.spec.ts b/.obsolete/games-bar/games-bar.component.spec.ts similarity index 100% rename from src/app/games-bar/games-bar.component.spec.ts rename to .obsolete/games-bar/games-bar.component.spec.ts diff --git a/src/app/games-bar/games-bar.component.ts b/.obsolete/games-bar/games-bar.component.ts similarity index 100% rename from src/app/games-bar/games-bar.component.ts rename to .obsolete/games-bar/games-bar.component.ts diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 6e1a918..4d63a84 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,4 @@ import { Component } from '@angular/core'; -import { GetVersion, GetVersionCallbackDetail, RunGame } from './services/go'; @Component({ selector: 'app-root', @@ -17,10 +16,10 @@ export class AppComponent { if (!(event instanceof CustomEvent)) return; this.version = event.detail; }); - GetVersion(); + //GetVersion(); } RunGame() { - RunGame(); + //RunGame(); } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5bdaea0..6ce5b79 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -10,16 +10,15 @@ import { import { NgModule } from '@angular/core'; 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 { GamesBarComponent } from './games-bar/games-bar.component'; -import { GameButtonComponent } from './games-bar/game-button/game-button.component'; import { TuiAvatarModule } from "@taiga-ui/kit"; +import { GamesBarModule } from "./components/games-bar/games-bar.module"; @NgModule({ - declarations: [AppComponent, GamesBarComponent, GameButtonComponent], - imports: [BrowserModule, AppRoutingModule, BrowserAnimationsModule, TuiRootModule, TuiDialogModule, TuiAlertModule, TuiButtonModule, TuiAvatarModule], + declarations: [AppComponent], + imports: [BrowserModule, AppRoutingModule, BrowserAnimationsModule, TuiRootModule, TuiDialogModule, TuiAlertModule, TuiButtonModule, TuiAvatarModule, GamesBarModule], providers: [ { provide: APP_BASE_HREF, useValue: '/' }, { provide: LocationStrategy, useClass: HashLocationStrategy }, diff --git a/src/app/components/games-bar/game-info/game-info.component.html b/src/app/components/games-bar/game-info/game-info.component.html index 75f0a56..5e9bba3 100644 --- a/src/app/components/games-bar/game-info/game-info.component.html +++ b/src/app/components/games-bar/game-info/game-info.component.html @@ -1,2 +1,20 @@

{{game.title}}

{{game.description}}

+ + + + + diff --git a/src/app/components/games-bar/game-info/game-info.component.ts b/src/app/components/games-bar/game-info/game-info.component.ts index e9fbb6c..238583e 100644 --- a/src/app/components/games-bar/game-info/game-info.component.ts +++ b/src/app/components/games-bar/game-info/game-info.component.ts @@ -1,5 +1,7 @@ import { Component, Input, OnInit } from '@angular/core'; import { Game } from 'src/app/interfaces/game.interface'; +import {TuiButtonModule} from '@taiga-ui/core'; +import { LauncherService } from 'src/app/services/launcher.service'; @Component({ selector: 'app-game-info[game]', @@ -9,7 +11,12 @@ import { Game } from 'src/app/interfaces/game.interface'; export class GameInfoComponent implements OnInit { @Input() game!: Game; - constructor() {} + constructor(private launcher: LauncherService) {} ngOnInit(): void {} + + runGame(){ + //console.log("hello") + this.launcher.RunGame(this.game) + } } diff --git a/src/app/components/games-bar/games-bar.component.ts b/src/app/components/games-bar/games-bar.component.ts index c8cc169..8a5c22f 100644 --- a/src/app/components/games-bar/games-bar.component.ts +++ b/src/app/components/games-bar/games-bar.component.ts @@ -21,6 +21,9 @@ export class GamesBarComponent implements OnInit { GetGames().then((value) => { console.log(value); this.games = value; + if (this.games.length > 0){ + this.activeGame = 0 + } }); } } diff --git a/src/app/components/games-bar/games-bar.module.ts b/src/app/components/games-bar/games-bar.module.ts index 772a10d..9b09d18 100644 --- a/src/app/components/games-bar/games-bar.module.ts +++ b/src/app/components/games-bar/games-bar.module.ts @@ -3,10 +3,12 @@ import { CommonModule } from '@angular/common'; import { GamesBarComponent } from './games-bar.component'; import { GameItemComponent } from './game-item/game-item.component'; import { GameInfoComponent } from './game-info/game-info.component'; +import {TuiButtonModule} from '@taiga-ui/core'; +import { TuiAvatarComponent, TuiAvatarModule } from '@taiga-ui/kit'; @NgModule({ declarations: [GamesBarComponent, GameItemComponent, GameInfoComponent], - imports: [CommonModule], + imports: [CommonModule,TuiButtonModule, TuiAvatarModule], exports: [GamesBarComponent, GameItemComponent, GameInfoComponent], }) export class GamesBarModule {} diff --git a/src/app/interfaces/game.interface.ts b/src/app/interfaces/game.interface.ts index 9f31050..37f5170 100644 --- a/src/app/interfaces/game.interface.ts +++ b/src/app/interfaces/game.interface.ts @@ -1,6 +1,7 @@ export interface Game { - id: number; - title: string; - image: string; - description: string; -} + id: number; + title: string; + image: string; + description: string; + } + \ No newline at end of file diff --git a/src/app/services/go.ts b/src/app/services/go.ts index 5ec794f..acc0fd5 100644 --- a/src/app/services/go.ts +++ b/src/app/services/go.ts @@ -2,13 +2,14 @@ import { Game } from '../interfaces/game.interface'; export interface Go extends Window { GetGames: () => Promise; + GoRunGame: (gameId: number) => void; } export interface GoCallback extends Window { 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 w = window as unknown as GoCallback; @@ -29,4 +30,4 @@ let w = window as unknown as GoCallback; // document.dispatchEvent(event); // }; -export { GetGames, SetVersion }; +export { GetGames, SetVersion, GoRunGame }; diff --git a/src/app/services/launcher.service.ts b/src/app/services/launcher.service.ts index 1e83783..a8ce8ae 100644 --- a/src/app/services/launcher.service.ts +++ b/src/app/services/launcher.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; -import { Game } from './oxana.service'; +import { Game } from '../interfaces/game.interface'; +import { GoRunGame } from './go'; @Injectable({ providedIn: 'root' }) @@ -7,13 +8,13 @@ export class LauncherService { constructor() { } - public GetGames(): Game[]{ - var currentGames :Game[] = [ - { name: "ad", icon: "string", id: "string"}, - { name: "qwet", icon: "string", id: "string"}, - { name: "1233", icon: "string", id: "string"}, - { name: "ghjghj", icon: "string", id: "string"} - ] - return currentGames + // public GetGames(): Game[]{ + // var currentGames :Game[] + // return currentGames + // } + + public RunGame(game: Game){ + //console.log(game) + GoRunGame(game.id) } } diff --git a/src/app/services/oxana.service.ts b/src/app/services/oxana.service.ts index 7395e0a..20fea91 100644 --- a/src/app/services/oxana.service.ts +++ b/src/app/services/oxana.service.ts @@ -1,5 +1,6 @@ import { Injectable } from '@angular/core'; import { LauncherService } from './launcher.service'; +import { Game } from '../interfaces/game.interface'; @Injectable({ providedIn: 'root' @@ -16,8 +17,3 @@ export class OxanaService { // } } -export interface Game { - name: string - icon: string - id: string -}