Commit dc57f592 authored by mercury233's avatar mercury233

add support for yrp3d

parent ea08a0c6
...@@ -341,6 +341,7 @@ ...@@ -341,6 +341,7 @@
</div> </div>
<div class="tab-pane" id="game-replay-local" role="tabpanel"> <div class="tab-pane" id="game-replay-local" role="tabpanel">
<div class="list-group"> <div class="list-group">
<a *ngFor="let replay of replays2" class="list-group-item list-group-item-action" (click)="watch_replay2(replay)">{{replay}}</a>
<a *ngFor="let replay of replays" class="list-group-item list-group-item-action" (click)="watch_replay(replay)">{{replay}}</a> <a *ngFor="let replay of replays" class="list-group-item list-group-item-action" (click)="watch_replay(replay)">{{replay}}</a>
</div> </div>
</div> </div>
......
...@@ -130,6 +130,7 @@ export class YGOProComponent implements OnInit, OnDestroy, OnChanges { ...@@ -130,6 +130,7 @@ export class YGOProComponent implements OnInit, OnDestroy, OnChanges {
points: EventEmitter<Points> = new EventEmitter(); points: EventEmitter<Points> = new EventEmitter();
decks: string[] = []; decks: string[] = [];
replays: string[] = []; replays: string[] = [];
replays2: string[] = [];
current_deck: string; current_deck: string;
system_conf: string; system_conf: string;
numfont: string[]; numfont: string[];
...@@ -503,6 +504,7 @@ export class YGOProComponent implements OnInit, OnDestroy, OnChanges { ...@@ -503,6 +504,7 @@ export class YGOProComponent implements OnInit, OnDestroy, OnChanges {
} }
this.replays = await this.get_replays(); this.replays = await this.get_replays();
this.replays2 = await this.get_replays2();
// https://mycard.moe/ygopro/api/user?username=ozxdno // https://mycard.moe/ygopro/api/user?username=ozxdno
try { try {
...@@ -561,6 +563,15 @@ export class YGOProComponent implements OnInit, OnDestroy, OnChanges { ...@@ -561,6 +563,15 @@ export class YGOProComponent implements OnInit, OnDestroy, OnChanges {
return []; return [];
} }
} }
async get_replays2(): Promise<string[]> {
try {
let files: string[] = await fs.readdir(this.app.ygoproReplayPath);
return files.filter(file => path.extname(file) === '.yrp3d').map(file => path.basename(file, '.yrp3d'));
} catch (error) {
console.error(`Load replay fail: ${error.toString()}`);
return [];
}
}
async get_font(files: string[]): Promise<string | undefined> { async get_font(files: string[]): Promise<string | undefined> {
for (let file of files) { for (let file of files) {
...@@ -645,6 +656,9 @@ export class YGOProComponent implements OnInit, OnDestroy, OnChanges { ...@@ -645,6 +656,9 @@ export class YGOProComponent implements OnInit, OnDestroy, OnChanges {
// return this.start_game(['-r', path.join('replay', replay + '.yrp')]); // return this.start_game(['-r', path.join('replay', replay + '.yrp')]);
return this.start_game('replay', { replay: path.join(this.app.ygoproReplayPath, `${replay}.yrp`) }); return this.start_game('replay', { replay: path.join(this.app.ygoproReplayPath, `${replay}.yrp`) });
} }
async watch_replay2(replay: string) {
return this.start_game('replay', { replay: path.join(this.app.ygoproReplayPath, `${replay}.yrp3d`) });
}
join_windbot(name?: string) { join_windbot(name?: string) {
if (!name) { if (!name) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment