diff --git a/src/app/games/game/game.component.ts b/src/app/games/game/game.component.ts index df51648..8cb1f55 100644 --- a/src/app/games/game/game.component.ts +++ b/src/app/games/game/game.component.ts @@ -1,10 +1,11 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnChanges, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; +import { forkJoin } from 'rxjs'; import { GamesService } from '../games.service'; -import { IGame } from '../games.service.interface'; +import { IChart, IGame } from '../games.service.interface'; /** - * Container component for the tabs and relevant content. + * Container component for relevant content on a game. */ @Component({ selector: 'game', @@ -18,8 +19,13 @@ export class GameComponent implements OnInit { /** * The summary to use to display basic game info. */ - game: IGame; + game: IGame; + /** + * Data obtained from the CSV files. + */ + csvData: string[]; + // Get the CSVs if the navigated slug is correct, otherwise navigate to 404 ngOnInit(): void { this.route.params.subscribe( res => { @@ -27,12 +33,19 @@ export class GameComponent implements OnInit { this.gamesService.getGames().subscribe( res => { // redirect if an unknown slug is provided - const index = res.findIndex((game) => game.slug === slug) - if (index !== -1) { - this.game = res[index]; + const index = res.findIndex((game) => game.slug === slug); + if (index === -1) { + this.router.navigateByUrl("/404", { skipLocationChange: true }); } else { - this.router.navigateByUrl("/404", { skipLocationChange: true }); + this.game = res[index]; + forkJoin([ + this.gamesService.getGameCSV(this.game.csvs.nonmatching), + this.gamesService.getGameCSV(this.game.csvs.matching) + ]).subscribe( + res => this.csvData = res, + err => console.error(err) + ); } }, err => { @@ -43,5 +56,4 @@ export class GameComponent implements OnInit { } ); } - -} +} \ No newline at end of file diff --git a/src/app/games/games.service.interface.ts b/src/app/games/games.service.interface.ts index 72d3154..06dd5a8 100644 --- a/src/app/games/games.service.interface.ts +++ b/src/app/games/games.service.interface.ts @@ -20,22 +20,18 @@ export interface IGame { * Links to display as an icon. The key defines the icon, and the value is the link href. */ links: {[type: string]: string}; - // /** - // * The name of the "matching" CSV to read. - // */ - // matching: string; - // /** - // * The name of the "nonmatching" CSV to read. - // */ - // nonmatching: string; /** - * Information on which csvs to use and what to call them. + * Struct with names of CSVs to use */ - csv_info: ICSVInfo[]; + csvs: ICSVs; /** - * The charts to display for this game. + * Data from CSVs */ - charts: IChart[]; + csvData: string[]; + /** + * The charts and data for each game. + */ + progressMeta: IChart[]; } /** @@ -83,35 +79,35 @@ export interface IChart { /** * The index to start counting pairs from. If none provided, will assume 5. */ - index?: number; - /** - * The series to have for each chart. - */ - series: ISeries[]; + index: number; /** * Names to use for the lines */ - line_names: string[]; + series: string[]; + /** + * The series to have for each chart. + */ + subdivisions: ISubdivision[]; } /** * Describes a csv of chart data and its name. */ -export interface ICSVInfo { +export interface ICSVs { /** - * The name of the csv type to display with the line. + * CSV file to get the matching data from. */ - name?: string; + matching: string; /** - * CSV file to get the data from. + * CSV file to get the nonmatching data from. */ - data: string; + nonmatching: string; } /** * Describes a singles series within a chart. */ -export interface ISeries { +export interface ISubdivision { /** * The name of the metric to display at the top. */ diff --git a/src/assets/csv/progress-mm-matching.csv b/src/assets/csv/progress-mm-matching.csv index f137ce1..5a154c4 100644 --- a/src/assets/csv/progress-mm-matching.csv +++ b/src/assets/csv/progress-mm-matching.csv @@ -1,4 +1,3 @@ -csv_version,timestamp,git_hash,src,total,boot,boot_total,code,code_total,ovl,ovl_total,asm,nonMatchingFunctions,assets,assets_total,archive,archive_total,audio,audio_total,interface,interface_total,misc,misc total,objects,objects_total,scenes,scenes_total,text,text_total 2,1615435438,e788bfecbfb10afd4182332db99bb562ea75b1de,103860,4747680,31572,86160,58624,1065936,13664,3595584,4597948,49,0,40817824,0,434608,0,6029280,0,749728,0,3953872,0,13518320,0,15695712,0,436304 2,1615511099,72f2b6aa4d154514008f61cc35025875a0528e02,103860,4747680,31572,86160,58624,1065936,13664,3595584,4597948,49,0,40817824,0,434608,0,6029280,0,749728,0,3953872,0,13518320,0,15695712,0,436304 2,1615512459,a983d14081b0e0daee4428769e7968071a1e9401,103860,4747680,31572,86160,58624,1065936,13664,3595584,4597948,49,0,40817824,0,434608,0,6029280,0,749728,0,3953872,0,13518320,0,15695712,0,436304 diff --git a/src/assets/csv/progress-mm-nonmatching.csv b/src/assets/csv/progress-mm-nonmatching.csv index 7bc6c3c..6f4240c 100644 --- a/src/assets/csv/progress-mm-nonmatching.csv +++ b/src/assets/csv/progress-mm-nonmatching.csv @@ -1,4 +1,3 @@ -csv_version,timestamp,git_hash,src,total,boot,boot_total,code,code_total,ovl,ovl_total,asm,nonMatchingFunctions,assets,assets_total,archive,archive_total,audio,audio_total,interface,interface_total,misc,misc total,objects,objects_total,scenes,scenes_total,text,text_total 2,1615435438,e788bfecbfb10afd4182332db99bb562ea75b1de,120152,4747680,36352,86160,70136,1065936,13664,3595584,4582152,0,0,40817824,0,434608,0,6029280,0,749728,0,3953872,0,13518320,0,15695712,0,436304 2,1615511099,72f2b6aa4d154514008f61cc35025875a0528e02,120152,4747680,36352,86160,70136,1065936,13664,3595584,4582152,0,0,40817824,0,434608,0,6029280,0,749728,0,3953872,0,13518320,0,15695712,0,436304 2,1615512459,a983d14081b0e0daee4428769e7968071a1e9401,120152,4747680,36352,86160,70136,1065936,13664,3595584,4582152,0,0,40817824,0,434608,0,6029280,0,749728,0,3953872,0,13518320,0,15695712,0,436304 diff --git a/src/assets/json/games.json b/src/assets/json/games.json index ef6eadf..6ca455f 100644 --- a/src/assets/json/games.json +++ b/src/assets/json/games.json @@ -6,23 +6,21 @@ "github": "https://www.github.com/zeldaret/oot" }, "faq": "oot_faq", - "csv_info": [ - { - "name": "nonmatching", - "data": "progress-oot-nonmatching" - }, - { - "name": "matching", - "data": "progress-oot-matching" - } - ], - "charts": [ + "csvs": { + "matching": "progress-oot-matching", + "nonmatching": "progress-oot-nonmatching" + }, + "progressMeta": [ { + "type": "code", "title": "Ocarina of Time MQ Debug Rom", "subtitle": "Code decompilation progress", "index": 3, - "line_names": ["Nonmatching", "Matching"], "series": [ + "Nonmatching", + "Matching" + ], + "subdivisions": [ { "metric": "Code", "description": "{0} / {1} bytes of all code decompiled ({2}%)" @@ -50,34 +48,32 @@ "github": "https://www.github.com/zeldaret/mm" }, "faq": "mm_faq", - "csv_info": [ - { - "name": "nonmatching", - "data": "progress-mm-nonmatching" - }, - { - "name": "matching", - "data": "progress-mm-matching" - } - ], - "charts": [ + "csvs": { + "matching": "progress-mm-matching", + "nonmatching": "progress-mm-nonmatching" + }, + "progressMeta": [ { + "type": "code", "title": "Majora's Mask", "subtitle": "Code decompilation progress", - "line_names": ["Nonmatching", "Matching"], - "index": 3, "series": [ + "Nonmatching", + "Matching" + ], + "index": 3, + "subdivisions": [ { "metric": "Code", "description": "{0} / {1} bytes of all code decompiled ({2}%)" }, { - "metric": "boot", - "description": "{0} / {1} bytes of boot decompiled ({2}%)" + "metric": "Code", + "description": "{0} / {1} bytes of code decompiled ({2}%)" }, { - "metric": "code", - "description": "{0} / {1} bytes of code decompiled ({2}%)" + "metric": "Boot", + "description": "{0} / {1} bytes of boot decompiled ({2}%)" }, { "metric": "Overlays", @@ -86,11 +82,15 @@ ] }, { + "type": "assets", "title": "Majora's Mask", - "subtitle": "Asset decompilation progress", - "line_names": ["Debinarised", "Identified"], - "index": 13, + "subtitle": "Asset analysis progress", "series": [ + "Debinarised", + "Identified" + ], + "index": 13, + "subdivisions": [ { "metric": "Assets", "description": "{0} / {1} bytes of all assets decompiled ({2}%)" @@ -127,4 +127,4 @@ } ] } -] +] \ No newline at end of file