From df13feeb774875aef33434f8be83399fc0e0ff29 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Sun, 16 Oct 2022 21:52:56 +0300 Subject: [PATCH] Start loading games list from launcher --- src/app/app.component.html | 6 +++ src/app/app.component.ts | 6 ++- src/app/app.module.ts | 15 +++++-- .../game-button/game-button.component.html | 17 ++++++++ .../game-button/game-button.component.scss | 0 .../game-button/game-button.component.spec.ts | 23 +++++++++++ .../game-button/game-button.component.ts | 15 +++++++ src/app/games-bar/games-bar.component.html | 5 +++ src/app/games-bar/games-bar.component.scss | 0 src/app/games-bar/games-bar.component.spec.ts | 23 +++++++++++ src/app/games-bar/games-bar.component.ts | 39 +++++++++++++++++++ src/app/services/go.ts | 6 +-- src/app/services/launcher.service.spec.ts | 16 ++++++++ src/app/services/launcher.service.ts | 19 +++++++++ src/app/services/oxana.service.spec.ts | 16 ++++++++ src/app/services/oxana.service.ts | 23 +++++++++++ 16 files changed, 222 insertions(+), 7 deletions(-) create mode 100644 src/app/games-bar/game-button/game-button.component.html create mode 100644 src/app/games-bar/game-button/game-button.component.scss create mode 100644 src/app/games-bar/game-button/game-button.component.spec.ts create mode 100644 src/app/games-bar/game-button/game-button.component.ts create mode 100644 src/app/games-bar/games-bar.component.html create mode 100644 src/app/games-bar/games-bar.component.scss create mode 100644 src/app/games-bar/games-bar.component.spec.ts create mode 100644 src/app/games-bar/games-bar.component.ts create mode 100644 src/app/services/launcher.service.spec.ts create mode 100644 src/app/services/launcher.service.ts create mode 100644 src/app/services/oxana.service.spec.ts create mode 100644 src/app/services/oxana.service.ts diff --git a/src/app/app.component.html b/src/app/app.component.html index d728138..3dee7cb 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,3 +1,9 @@ + Test (version: {{version}}) + + + + + \ No newline at end of file diff --git a/src/app/app.component.ts b/src/app/app.component.ts index ff7e327..6e1a918 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; -import { GetVersion, GetVersionCallbackDetail } from './services/go'; +import { GetVersion, GetVersionCallbackDetail, RunGame } from './services/go'; @Component({ selector: 'app-root', @@ -19,4 +19,8 @@ export class AppComponent { }); GetVersion(); } + + RunGame() { + RunGame(); + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index a7e6b55..5bdaea0 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,3 +1,7 @@ +import { NgDompurifySanitizer } from "@tinkoff/ng-dompurify"; +import { TuiRootModule, TuiDialogModule, TuiAlertModule, TUI_SANITIZER } from "@taiga-ui/core"; +import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; +import {TuiButtonModule} from '@taiga-ui/core'; import { APP_BASE_HREF, LocationStrategy, @@ -8,14 +12,19 @@ import { BrowserModule } from '@angular/platform-browser'; import { AppRoutingModule } from './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"; + @NgModule({ - declarations: [AppComponent], - imports: [BrowserModule, AppRoutingModule], + declarations: [AppComponent, GamesBarComponent, GameButtonComponent], + imports: [BrowserModule, AppRoutingModule, BrowserAnimationsModule, TuiRootModule, TuiDialogModule, TuiAlertModule, TuiButtonModule, TuiAvatarModule], providers: [ { provide: APP_BASE_HREF, useValue: '/' }, { provide: LocationStrategy, useClass: HashLocationStrategy }, - ], + {provide: TUI_SANITIZER, useClass: NgDompurifySanitizer} +], bootstrap: [AppComponent], }) export class AppModule {} diff --git a/src/app/games-bar/game-button/game-button.component.html b/src/app/games-bar/game-button/game-button.component.html new file mode 100644 index 0000000..a4a95c6 --- /dev/null +++ b/src/app/games-bar/game-button/game-button.component.html @@ -0,0 +1,17 @@ + + + + + diff --git a/src/app/games-bar/game-button/game-button.component.scss b/src/app/games-bar/game-button/game-button.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/games-bar/game-button/game-button.component.spec.ts b/src/app/games-bar/game-button/game-button.component.spec.ts new file mode 100644 index 0000000..85bf386 --- /dev/null +++ b/src/app/games-bar/game-button/game-button.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GameButtonComponent } from './game-button.component'; + +describe('GameButtonComponent', () => { + let component: GameButtonComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ GameButtonComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(GameButtonComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/games-bar/game-button/game-button.component.ts b/src/app/games-bar/game-button/game-button.component.ts new file mode 100644 index 0000000..2abb4e7 --- /dev/null +++ b/src/app/games-bar/game-button/game-button.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-game-button', + templateUrl: './game-button.component.html', + styleUrls: ['./game-button.component.scss'] +}) +export class GameButtonComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} diff --git a/src/app/games-bar/games-bar.component.html b/src/app/games-bar/games-bar.component.html new file mode 100644 index 0000000..d698516 --- /dev/null +++ b/src/app/games-bar/games-bar.component.html @@ -0,0 +1,5 @@ + + + name: {{item.name}} +
{{player}}
+
\ No newline at end of file diff --git a/src/app/games-bar/games-bar.component.scss b/src/app/games-bar/games-bar.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/games-bar/games-bar.component.spec.ts b/src/app/games-bar/games-bar.component.spec.ts new file mode 100644 index 0000000..5b7c125 --- /dev/null +++ b/src/app/games-bar/games-bar.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GamesBarComponent } from './games-bar.component'; + +describe('GamesBarComponent', () => { + let component: GamesBarComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ GamesBarComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(GamesBarComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/games-bar/games-bar.component.ts b/src/app/games-bar/games-bar.component.ts new file mode 100644 index 0000000..d7a3f2f --- /dev/null +++ b/src/app/games-bar/games-bar.component.ts @@ -0,0 +1,39 @@ +import { Component, OnInit } from '@angular/core'; +import { LauncherService } from '../services/launcher.service'; +import { Game } from '../services/oxana.service'; + +@Component({ + selector: 'app-games-bar', + templateUrl: './games-bar.component.html', + styleUrls: ['./games-bar.component.scss'] +}) + +export class GamesBarComponent implements OnInit { + constructor(private launcher: LauncherService) { } + + games!: Game[] + // games: Game[] = [{ + // name: 'str', + // players: ['1', '2'] + // }, + // { + // name: 'qwe', + // players: ['6', '4'] + // }] + + + ngOnInit(): void { + // let i = 0 + // setInterval(() => { + // this.games.push({name: `name-${++i}`, players: []}) + // }, 100) + this.games = this.launcher.GetGames() + console.log("asdasd") + console.log(this.games) + } + + // removePlayerZero (item: Game) { + // if (item.players.length == 0) return + // item.players.splice(0, 1) + // } +} diff --git a/src/app/services/go.ts b/src/app/services/go.ts index 585898d..596d44f 100644 --- a/src/app/services/go.ts +++ b/src/app/services/go.ts @@ -1,12 +1,13 @@ export interface Go extends Window { GetVersion: () => string; + RunGame: () => string; } export interface GoCallback extends Window { SetVersion: (value: string) => void; } -let { GetVersion } = window as unknown as Go; +let { GetVersion, RunGame} = window as unknown as Go; let { SetVersion } = window as unknown as GoCallback; export declare type GetVersionCallbackDetail = string; @@ -17,5 +18,4 @@ export declare type GetVersionCallbackDetail = string; }); document.dispatchEvent(event); }; - -export { GetVersion, SetVersion }; +export { GetVersion, SetVersion, RunGame}; diff --git a/src/app/services/launcher.service.spec.ts b/src/app/services/launcher.service.spec.ts new file mode 100644 index 0000000..794c9dd --- /dev/null +++ b/src/app/services/launcher.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { LauncherService } from './launcher.service'; + +describe('LauncherService', () => { + let service: LauncherService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(LauncherService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/launcher.service.ts b/src/app/services/launcher.service.ts new file mode 100644 index 0000000..1e83783 --- /dev/null +++ b/src/app/services/launcher.service.ts @@ -0,0 +1,19 @@ +import { Injectable } from '@angular/core'; +import { Game } from './oxana.service'; +@Injectable({ + providedIn: 'root' +}) +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 + } +} diff --git a/src/app/services/oxana.service.spec.ts b/src/app/services/oxana.service.spec.ts new file mode 100644 index 0000000..4fdbba0 --- /dev/null +++ b/src/app/services/oxana.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { OxanaService } from './oxana.service'; + +describe('OxanaService', () => { + let service: OxanaService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(OxanaService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/oxana.service.ts b/src/app/services/oxana.service.ts new file mode 100644 index 0000000..7395e0a --- /dev/null +++ b/src/app/services/oxana.service.ts @@ -0,0 +1,23 @@ +import { Injectable } from '@angular/core'; +import { LauncherService } from './launcher.service'; + +@Injectable({ + providedIn: 'root' +}) + + +export class OxanaService { + private games!: Game + constructor(private launcher: LauncherService) { } + + // public getGames():Game{ + // currentGames = launcher.GetGames() + // return currentGames + // } +} + +export interface Game { + name: string + icon: string + id: string +}