Commit 8de4a1f3 authored by nanahira's avatar nanahira

recursive load child ygopro data

parent e6319743
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Created by zh99998 on 16/9/2. * Created by zh99998 on 16/9/2.
*/ */
import {Component} from '@angular/core'; import {Component} from '@angular/core';
@Component({ @Component({
moduleId: module.id, moduleId: module.id,
selector: 'about', selector: 'about',
......
import {App} from './app'; import {App} from './app';
/** /**
* Created by zh99998 on 16/9/6. * Created by zh99998 on 16/9/6.
*/ */
......
import { AppLocal } from './app-local'; import {AppLocal} from './app-local';
import * as path from 'path'; import * as path from 'path';
import * as ini from 'ini'; import * as ini from 'ini';
import * as fs from 'fs'; import * as fs from 'fs';
......
...@@ -19,9 +19,8 @@ import {LoginService} from './login.service'; ...@@ -19,9 +19,8 @@ import {LoginService} from './login.service';
import {SettingsService} from './settings.sevices'; import {SettingsService} from './settings.sevices';
import {ComparableSet} from './shared/ComparableSet'; import {ComparableSet} from './shared/ComparableSet';
import {AppsJson} from './apps-json-type'; import {AppsJson} from './apps-json-type';
import Timer = NodeJS.Timer;
import ReadableStream = NodeJS.ReadableStream;
import * as os from 'os'; import * as os from 'os';
import Timer = NodeJS.Timer;
const Logger = { const Logger = {
info: (...message: any[]) => { info: (...message: any[]) => {
......
...@@ -23,7 +23,7 @@ $.fn.init = new Proxy($.fn.init, { ...@@ -23,7 +23,7 @@ $.fn.init = new Proxy($.fn.init, {
window['jQuery'] = $; window['jQuery'] = $;
import {Component, ViewEncapsulation, OnInit, Input, OnChanges, SimpleChanges, ElementRef} from '@angular/core'; import {Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges, ViewEncapsulation} from '@angular/core';
import {LoginService} from './login.service'; import {LoginService} from './login.service';
import {SettingsService} from './settings.sevices'; import {SettingsService} from './settings.sevices';
import {App} from './app'; import {App} from './app';
......
/** /**
* Created by weijian on 2016/10/26. * Created by weijian on 2016/10/26.
*/ */
import {Injectable, NgZone, EventEmitter} from '@angular/core'; import {EventEmitter, Injectable, NgZone} from '@angular/core';
import {Http} from '@angular/http'; import {Http} from '@angular/http';
// import {error} from 'util'; // import {error} from 'util';
// import Timer = NodeJS.Timer; // import Timer = NodeJS.Timer;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* Created by zh99998 on 2017/6/1. * Created by zh99998 on 2017/6/1.
*/ */
import * as Raven from 'raven-js'; import * as Raven from 'raven-js';
import { ErrorHandler } from '@angular/core'; import {ErrorHandler} from '@angular/core';
Raven Raven
.config('https://2c5fa0d0f13c43b5b96346f4eff2ea60@sentry.io/174769') .config('https://2c5fa0d0f13c43b5b96346f4eff2ea60@sentry.io/174769')
......
import {TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID} from '@angular/core'; import {LOCALE_ID, TRANSLATIONS, TRANSLATIONS_FORMAT} from '@angular/core';
import {remote} from 'electron'; import {remote} from 'electron';
export async function getTranslationProviders (): Promise<Object[]> { export async function getTranslationProviders (): Promise<Object[]> {
......
import {App} from './app'; import {App} from './app';
import * as path from 'path'; import * as path from 'path';
/** /**
* Created by weijian on 2016/10/24. * Created by weijian on 2016/10/24.
*/ */
......
/** /**
* Created by zh99998 on 16/9/2. * Created by zh99998 on 16/9/2.
*/ */
import { ChangeDetectorRef, Component, ElementRef, OnInit, ViewChild } from '@angular/core'; import {ChangeDetectorRef, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import { AppsService } from './apps.service'; import {AppsService} from './apps.service';
import { LoginService } from './login.service'; import {LoginService} from './login.service';
import { App, Category } from './app'; import {App, Category} from './app';
import { shell } from 'electron'; import {shell} from 'electron';
import { SettingsService } from './settings.sevices'; import {SettingsService} from './settings.sevices';
const ReconnectingWebSocket = require('reconnecting-websocket'); const ReconnectingWebSocket = require('reconnecting-websocket');
// import 'typeahead.js'; // import 'typeahead.js';
......
/** /**
* Created by zh99998 on 16/9/2. * Created by zh99998 on 16/9/2.
*/ */
import { Component } from '@angular/core'; import {Component} from '@angular/core';
import { LoginService } from './login.service'; import {LoginService} from './login.service';
import * as crypto from 'crypto'; import * as crypto from 'crypto';
import { shell } from 'electron'; import {shell} from 'electron';
@Component({ @Component({
moduleId: module.id, moduleId: module.id,
......
import { ChangeDetectorRef, Component, ElementRef, OnInit, Renderer, ViewChild } from '@angular/core'; import {ChangeDetectorRef, Component, ElementRef, OnInit, Renderer, ViewChild} from '@angular/core';
import 'bootstrap'; import 'bootstrap';
import { remote, shell } from 'electron'; import {remote, shell} from 'electron';
import * as $ from 'jquery'; import * as $ from 'jquery';
import * as Tether from 'tether'; import * as Tether from 'tether';
import { LoginService } from './login.service'; import {LoginService} from './login.service';
import { SettingsService } from './settings.sevices'; import {SettingsService} from './settings.sevices';
window['Tether'] = Tether; window['Tether'] = Tether;
const autoUpdater: Electron.AutoUpdater = remote.getGlobal('autoUpdater'); const autoUpdater: Electron.AutoUpdater = remote.getGlobal('autoUpdater');
......
import { ErrorHandler, LOCALE_ID, NgModule, NO_ERRORS_SCHEMA } from '@angular/core'; import {LOCALE_ID, NgModule, NO_ERRORS_SCHEMA} from '@angular/core';
import { BrowserModule } from '@angular/platform-browser'; import {BrowserModule} from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import { HttpModule } from '@angular/http'; import {HttpModule} from '@angular/http';
import { MyCardComponent } from './mycard.component'; import {MyCardComponent} from './mycard.component';
import { LoginComponent } from './login.component'; import {LoginComponent} from './login.component';
import { StoreComponent } from './store.component'; import {StoreComponent} from './store.component';
import { LobbyComponent } from './lobby.component'; import {LobbyComponent} from './lobby.component';
import { AppDetailComponent } from './app-detail.component'; import {AppDetailComponent} from './app-detail.component';
import { RosterComponent } from './roster.component'; import {RosterComponent} from './roster.component';
import { YGOProComponent } from './ygopro.component'; import {YGOProComponent} from './ygopro.component';
import { AppsService } from './apps.service'; import {AppsService} from './apps.service';
import { SettingsService } from './settings.sevices'; import {SettingsService} from './settings.sevices';
import { LoginService } from './login.service'; import {LoginService} from './login.service';
import { DownloadService } from './download.service'; import {DownloadService} from './download.service';
import { AboutComponent } from './about.component'; import {AboutComponent} from './about.component';
import { CandyComponent } from './candy.component'; import {CandyComponent} from './candy.component';
import { RavenErrorHandler } from './error-handler'; import {NetworkComponent} from './network.component';
import { NetworkComponent } from './network.component';
export function settingsService_getLocale(settingsService: SettingsService) { export function settingsService_getLocale(settingsService: SettingsService) {
return settingsService.getLocale(); return settingsService.getLocale();
......
import { ChangeDetectorRef, Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges, Injectable } from '@angular/core'; import {Component, Injectable, Input} from '@angular/core';
import { AppsService } from './apps.service'; import {AppsService} from './apps.service';
import {App} from './app'; import {App} from './app';
@Component({ @Component({
......
/** /**
* Created by zh99998 on 16/9/2. * Created by zh99998 on 16/9/2.
*/ */
import {Component, Input, EventEmitter, Output, OnInit, OnChanges} from '@angular/core'; import {Component, EventEmitter, Input, OnChanges, OnInit, Output} from '@angular/core';
@Component({ @Component({
moduleId: module.id, moduleId: module.id,
selector: 'roster', selector: 'roster',
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
* Created by zh99998 on 16/9/2. * Created by zh99998 on 16/9/2.
*/ */
import {Component} from '@angular/core'; import {Component} from '@angular/core';
@Component({ @Component({
moduleId: module.id, moduleId: module.id,
selector: 'store', selector: 'store',
......
...@@ -5,17 +5,17 @@ import {ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnDestroy ...@@ -5,17 +5,17 @@ import {ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnDestroy
import {Headers, Http} from '@angular/http'; import {Headers, Http} from '@angular/http';
import {clipboard, remote, shell} from 'electron'; import {clipboard, remote, shell} from 'electron';
import * as fs from 'fs-extra'; import * as fs from 'fs-extra';
import * as ini from 'ini';
import * as $ from 'jquery'; import * as $ from 'jquery';
import * as path from 'path'; import * as path from 'path';
import 'rxjs/Rx'; import 'rxjs/Rx';
import {ISubscription} from 'rxjs/Subscription'; import {ISubscription} from 'rxjs/Subscription';
import {App, AppStatus} from './app'; import {App} from './app';
import {AppsService} from './apps.service'; import {AppsService} from './apps.service';
import {LoginService} from './login.service'; import {LoginService} from './login.service';
import {SettingsService} from './settings.sevices'; import {SettingsService} from './settings.sevices';
import Timer = NodeJS.Timer; import Timer = NodeJS.Timer;
import WillNavigateEvent = Electron.WillNavigateEvent; import WillNavigateEvent = Electron.WillNavigateEvent;
import _ = require('lodash');
interface SystemConf { interface SystemConf {
use_d3d: string; use_d3d: string;
...@@ -278,8 +278,23 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -278,8 +278,23 @@ export class YGOProComponent implements OnInit, OnDestroy {
}); });
} }
getYGOProData(app: App) {
const ygoproData = <YGOProData>app.data;
for (const child of this.appsService.findChildren(app)) {
if (child.isYGOPro) {
const childData = this.getYGOProData(child);
_.mergeWith(ygoproData, childData, (objValue, srcValue) => {
if (_.isArray(objValue)) {
return objValue.concat(srcValue);
}
});
}
}
return ygoproData;
}
async ngOnInit() { async ngOnInit() {
const ygoproData = <YGOProData>this.app.data; const ygoproData = this.getYGOProData(this.app);
this.servers = ygoproData.servers; this.servers = ygoproData.servers;
this.selectableServers = this.servers.filter(s => !s.hidden); this.selectableServers = this.servers.filter(s => !s.hidden);
this.currentServer = this.selectableServers[0]; this.currentServer = this.selectableServers[0];
...@@ -293,11 +308,12 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -293,11 +308,12 @@ export class YGOProComponent implements OnInit, OnDestroy {
} }
if (ygoproData.ygopro.lastDeckFormat) { if (ygoproData.ygopro.lastDeckFormat) {
//console.log(`Deck format pattern: ${ygoproData.ygopro.lastDeckFormat}`) // console.log(`Deck format pattern: ${ygoproData.ygopro.lastDeckFormat}`)
this.lastDeckFormat = new RegExp(ygoproData.ygopro.lastDeckFormat); this.lastDeckFormat = new RegExp(ygoproData.ygopro.lastDeckFormat);
} }
this.system_conf = this.app.systemConfPath; this.system_conf = this.app.systemConfPath;
console.log(`Will load system conf file from ${this.system_conf}`);
await this.refresh(true); await this.refresh(true);
let modal = $('#game-list-modal'); let modal = $('#game-list-modal');
...@@ -549,6 +565,7 @@ export class YGOProComponent implements OnInit, OnDestroy { ...@@ -549,6 +565,7 @@ export class YGOProComponent implements OnInit, OnDestroy {
return null; return null;
} }
try { try {
// console.log(`Loading system conf from ${this.system_conf}`)
let data = await fs.readFile(this.system_conf, {encoding: 'utf-8'}); let data = await fs.readFile(this.system_conf, {encoding: 'utf-8'});
return data; return data;
} catch(e) { } catch(e) {
......
...@@ -71,6 +71,7 @@ System.config({ ...@@ -71,6 +71,7 @@ System.config({
"electron": "@node/electron", "electron": "@node/electron",
"ini": "@node/ini", "ini": "@node/ini",
"mustache": "@node/mustache", "mustache": "@node/mustache",
"lodash": "@node/lodash",
"mkdirp": "@node/mkdirp", "mkdirp": "@node/mkdirp",
"aria2": "@node/aria2", "aria2": "@node/aria2",
"electron-sudo": "@node/electron-sudo", "electron-sudo": "@node/electron-sudo",
......
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