Commit 41497011 authored by 神楽坂玲奈's avatar 神楽坂玲奈

not work

parent 6b71d41a
......@@ -55,7 +55,6 @@
"lodash-es": "^4.17.21",
"mousetrap": "^1.6.5",
"mustache": "^4.2.0",
"reconnecting-websocket": "^4.4.0",
"rxjs": "^7.3.0",
"strophe.js": "^1.4.2",
"strophejs-plugin-caps": "^1.1.3",
......@@ -15709,12 +15708,6 @@
"node": ">=8.10.0"
}
},
"node_modules/reconnecting-websocket": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/reconnecting-websocket/-/reconnecting-websocket-4.4.0.tgz",
"integrity": "sha512-D2E33ceRPga0NvTDhJmphEgJ7FUYF0v4lr1ki0csq06OdlxKfugGzN0dSkxM/NfqCxYELK4KcaTOUOjTV6Dcng==",
"dev": true
},
"node_modules/reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
......@@ -31677,12 +31670,6 @@
"picomatch": "^2.2.1"
}
},
"reconnecting-websocket": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/reconnecting-websocket/-/reconnecting-websocket-4.4.0.tgz",
"integrity": "sha512-D2E33ceRPga0NvTDhJmphEgJ7FUYF0v4lr1ki0csq06OdlxKfugGzN0dSkxM/NfqCxYELK4KcaTOUOjTV6Dcng==",
"dev": true
},
"reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
......@@ -7,11 +7,7 @@ import { LoginService } from '../login/login.service';
import { App, Category } from '../shared/app';
import { shell } from 'electron';
import { SettingsService } from '../settings.service';
const ReconnectingWebSocket = require('reconnecting-websocket');
// import 'typeahead.js';
// import Options = Twitter.Typeahead.Options;
import $ from 'jquery';
@Component({
selector: 'lobby',
......
......@@ -61,7 +61,7 @@
</div>
</div>
<div class="modal fade" id="game-list-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal fade" #gameListModal id="game-list-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content flex-row">
......@@ -218,7 +218,7 @@
</div>
<div class="modal fade" id="game-replay-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal fade" #gameReplayModal id="game-replay-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<!--<div class="modal-header">-->
......@@ -261,29 +261,29 @@
<div class="dropdown-menu">
<h6 i18n class="dropdown-header">匹配</h6>
<label class="form-check dropdown-item">
<input type="checkbox" class="form-check-input" [(ngModel)]="replay_rooms_filter.athletic">
<input type="checkbox" class="form-check-input" [(ngModel)]="replay_rooms_filter.athletic" (change)='refresh_replay_rooms()'>
<ng-container i18n>竞技匹配</ng-container>
</label>
<label class="form-check dropdown-item">
<input type="checkbox" class="form-check-input" [(ngModel)]="replay_rooms_filter.entertain">
<input type="checkbox" class="form-check-input" [(ngModel)]="replay_rooms_filter.entertain" (change)='refresh_replay_rooms()'>
<ng-container i18n>娱乐匹配</ng-container>
</label>
<h6 i18n class="dropdown-header">自定义游戏</h6>
<label class="form-check dropdown-item">
<input type="checkbox" class="form-check-input" [(ngModel)]="replay_rooms_filter.single">
<input type="checkbox" class="form-check-input" [(ngModel)]="replay_rooms_filter.single" (change)='refresh_replay_rooms()'>
<ng-container i18n>单局模式</ng-container>
</label>
<label class="form-check dropdown-item">
<input type="checkbox" class="form-check-input" [(ngModel)]="replay_rooms_filter.match">
<input type="checkbox" class="form-check-input" [(ngModel)]="replay_rooms_filter.match" (change)='refresh_replay_rooms()'>
<ng-container i18n>比赛模式</ng-container>
</label>
<label class="form-check dropdown-item">
<input type="checkbox" class="form-check-input" [(ngModel)]="replay_rooms_filter.tag">
<input type="checkbox" class="form-check-input" [(ngModel)]="replay_rooms_filter.tag" (change)='refresh_replay_rooms()'>
<ng-container i18n>TAG</ng-container>
</label>
<h6 i18n class="dropdown-header">单人模式</h6>
<label class="form-check dropdown-item">
<input type="checkbox" class="form-check-input" [(ngModel)]="replay_rooms_filter.windbot">
<input type="checkbox" class="form-check-input" [(ngModel)]="replay_rooms_filter.windbot" (change)='refresh_replay_rooms()'>
<ng-container i18n>单人模式</ng-container>
</label>
</div>
......
......@@ -2,6 +2,7 @@
* Created by zh99998 on 16/9/2.
*/
import {
AfterViewInit,
ChangeDetectorRef,
Component,
ElementRef,
......@@ -17,7 +18,7 @@ import {
import { clipboard, shell } from 'electron';
import * as remote from '@electron/remote';
import fs from 'fs-extra';
import $ from 'jquery';
// import $ from 'jquery';
import path from 'path';
import { App } from '../shared/app';
import { AppsService } from '../apps.service';
......@@ -128,7 +129,7 @@ let match_started_at: Date;
templateUrl: 'ygopro.component.html',
styleUrls: ['ygopro.component.css'],
})
export class YGOProComponent implements OnInit, OnDestroy {
export class YGOProComponent implements OnInit, OnDestroy, AfterViewInit {
@Input()
app: App;
@Input()
......@@ -198,6 +199,12 @@ export class YGOProComponent implements OnInit, OnDestroy {
match_interval: Timer | undefined;
join_password: string;
host_password = (this.loginService.user.external_id ^ 0x54321).toString();
@ViewChild('gameListModal')
gameListModal: ElementRef<HTMLElement>;
@ViewChild('gameReplayModal')
gameReplayModal: ElementRef<HTMLElement>;
@ViewChild('watchFilter')
watchFilter: ElementRef<HTMLElement>;
constructor(
private http: HttpClient,
......@@ -319,13 +326,18 @@ export class YGOProComponent implements OnInit, OnDestroy {
this.lastDeckFormat = new RegExp(ygoproData.ygopro.lastDeckFormat);
}
remote.ipcMain.on('YGOPro', (e: any, type: string) => {
console.log('rrrrr');
this.request_match(type);
});
this.system_conf = this.app.systemConfPath;
console.log(`Will load system conf file from ${this.system_conf}`);
await this.refresh(true);
}
let modal = $('#game-list-modal');
modal.on('show.bs.modal', () => {
ngAfterViewInit() {
this.gameListModal.nativeElement.addEventListener('show.bs.modal', () => {
this.rooms_loading = true;
this.connections = this.servers
.filter((server) => server.custom)
......@@ -373,17 +385,14 @@ export class YGOProComponent implements OnInit, OnDestroy {
});
});
modal.on('hide.bs.modal', () => {
this.gameListModal.nativeElement.addEventListener('hide.bs.modal', () => {
for (let connection of this.connections) {
connection.close();
}
this.connections = [];
});
// TODO: 跟上面的逻辑合并
let replay_modal = $('#game-replay-modal');
replay_modal.on('show.bs.modal', () => {
this.gameReplayModal.nativeElement.addEventListener('show.bs.modal', () => {
this.replay_connections = this.servers
.filter((server) => server.replay)
.map((server) => {
......@@ -436,13 +445,14 @@ export class YGOProComponent implements OnInit, OnDestroy {
});
});
replay_modal.on('hide.bs.modal', () => {
this.gameReplayModal.nativeElement.addEventListener('hide.bs.modal', () => {
for (let connection of this.replay_connections) {
connection.close();
}
this.replay_connections = [];
});
this.watchFilter.nativeElement
let watchDropdownMenu = $('#watch-filter');
watchDropdownMenu.on('change', "input[type='checkbox']", (event) => {
......@@ -450,25 +460,25 @@ export class YGOProComponent implements OnInit, OnDestroy {
this.refresh_replay_rooms();
});
replay_modal.on('click', (event) => {
if (!watchDropdownMenu.is(event.target) && !watchDropdownMenu.has(event.target).length) {
watchDropdownMenu.removeClass('show');
}
});
// replay_modal.on('click', (event) => {
// if (!watchDropdownMenu.is(event.target) && !watchDropdownMenu.has(event.target).length) {
// watchDropdownMenu.removeClass('show');
// }
// });
// $('#watchDropdownMenuButton').on('click', () => {
// watchDropdownMenu.toggleClass('show');
// });
$('#watchDropdownMenuButton').on('click', () => {
watchDropdownMenu.toggleClass('show');
});
remote.ipcMain.on('YGOPro', (e: any, type: string) => {
console.log('rrrrr');
this.request_match(type);
});
}
async refresh(init?: boolean) {
this.decks = await this.get_decks();
this.decks_grouped = _.mapValues(_.groupBy(this.decks, (p) => path.dirname(p)), (g) => g.map((p) => path.basename(p, '.ydk')))
this.decks_grouped = _.mapValues(
_.groupBy(this.decks, (p) => path.dirname(p)),
(g) => g.map((p) => path.basename(p, '.ydk'))
);
if (this.lastDeckFormat) {
const systemConfString = await this.load_system_conf();
......@@ -493,7 +503,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
this.current_deck = this.decks[0];
}
console.log(this.current_deck)
console.log(this.current_deck);
}
this.replays = await this.get_replays();
......@@ -515,7 +525,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
async get_decks(): Promise<string[]> {
try {
return (await fg('**/*.ydk', { cwd: this.app.ygoproDeckPath })).map(d => d.slice(0, -4));
return (await fg('**/*.ydk', { cwd: this.app.ygoproDeckPath })).map((d) => d.slice(0, -4));
} catch (error) {
console.error(`Load deck fail: ${error.toString()}`);
return [];
......
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