Commit e8b523b0 authored by nanahira's avatar nanahira

Merge branch 'v3-abstract-ygopro' into v3

parents 9372c2cd 8de4a1f3
......@@ -2,6 +2,7 @@
* Created by zh99998 on 16/9/2.
*/
import {Component} from '@angular/core';
@Component({
moduleId: module.id,
selector: 'about',
......
......@@ -35,7 +35,7 @@
</div>
<!--应用ready-->
<div *ngIf="currentApp.isReady() && (currentApp.id != 'ygopro')" class="i-b">
<div *ngIf="currentApp.isReady() && !currentApp.isYGOPro" class="i-b">
<button *ngIf="currentApp.runnable()" (click)="runApp(currentApp)" [disabled]="!appsService.allReady(currentApp)" type="button" class="btn btn-primary btn-sm">
<i class="fa fa-play" aria-hidden="true"></i> <span i18n>运行</span></button>
<button *ngIf="currentApp.actions.get('network')" [disabled]="!appsService.allReady(currentApp)" (click)="runApp(currentApp,'network')" type="button" class="btn btn-primary btn-sm">
......@@ -65,13 +65,13 @@
</div>
<!--<button (click)="log(appsService)">test</button>-->
<network *ngIf="(currentApp.id != 'ygopro') && currentApp && currentApp.network && currentApp.network.protocol == 'maotama'" [currentApp]="currentApp"></network>
<ygopro *ngIf="currentApp.isReady() && (currentApp.id == 'ygopro')" [app]="currentApp" [currentApp]="currentApp" (points)="onPoints($event)"></ygopro>
<network *ngIf="currentApp && !currentApp.isYGOPro && currentApp.network && currentApp.network.protocol == 'maotama'" [currentApp]="currentApp"></network>
<ygopro *ngIf="currentApp.isReady() && currentApp.isYGOPro" [app]="currentApp" [currentApp]="currentApp" (points)="onPoints($event)"></ygopro>
</div>
</div>
<div id="arena" class="panel panel-default" *ngIf="currentApp.id === 'ygopro' && points ">
<div id="arena" class="panel panel-default" *ngIf="currentApp.isYGOPro && points ">
<h2 i18n>排位成绩</h2>
<table class="table table-sm">
<tbody>
......
......@@ -55,13 +55,15 @@ export class AppDetailComponent implements OnInit, OnChanges {
'mysterious': '迷之物体',
'touhou': '东方 Project',
'touhou_pc98': '东方旧作',
'language': '语言包'
'language': '语言包',
'ygopro': 'YGOPro'
} : {
'recommend': 'Recommended',
'mysterious': 'Something',
'touhou': 'Touhou Project',
'touhou_pc98': 'Touhou old series',
'language': 'Language Pack'
'language': 'Language Pack',
'ygopro': 'YGOPro'
};
}
......
import {App} from './app';
/**
* Created by zh99998 on 16/9/6.
*/
......
import { AppLocal } from './app-local';
import {AppLocal} from './app-local';
import * as path from 'path';
import * as ini from 'ini';
import * as fs from 'fs';
import * as child_process from 'child_process';
import * as Mustache from 'mustache';
export enum Category {
game,
......@@ -62,6 +63,13 @@ export class AppStatus {
progressMessage: string;
}
export interface YGOProDistroData {
deckPath: string;
replayPath: string;
systemConf: string;
}
export class App {
id: string;
name: string; // i18n
......@@ -239,7 +247,7 @@ export class App {
return dependencies.every((dependency) => dependency.isReady());
}
async getSpawnAction(children: App[], action_name = 'main', referencedApp?: App, referencedAction?: Action, cwd?: string): Promise<SpawnAction> {
async getSpawnAction(children: App[], action_name = 'main', referencedApp?: App, referencedAction?: Action, cwd?: string, argsTemplate?: any): Promise<SpawnAction> {
const appCwd = (<AppLocal>this.local).path;
if(!cwd) {
cwd = appCwd;
......@@ -301,23 +309,31 @@ export class App {
if (action.open) {
const np2 = action.open;
const openAction = await np2.getSpawnAction([], 'main', this, action, cwd);
const openAction = await np2.getSpawnAction([], 'main', this, action, cwd, argsTemplate);
args = args.concat(openAction.args);
args.push(action.execute);
execute = openAction.execute;
cwd = openAction.cwd;
}
args = args.concat(action.args);
if (argsTemplate) {
for (let i = 0; i < args.length; ++i) {
if (typeof args[i] !== 'string') {
continue;
}
args[i] = Mustache.render(args[i], argsTemplate, null, { escape: (v) => v });
}
}
env = Object.assign(env, action.env);
return {
execute,
args,
env,
cwd
}
};
}
async spawnApp(children: App[], action_name = 'main') {
async spawnApp(children: App[], action_name = 'main', argsTemplate?: any) {
if (this.id === 'th123') {
let th105 = <App>this.references.get('th105');
......@@ -333,9 +349,44 @@ export class App {
}
const appCwd = (<AppLocal>this.local).path;
const {execute, args, env, cwd} = await this.getSpawnAction(children, action_name);
const {execute, args, env, cwd} = await this.getSpawnAction(children, action_name, null, null, null, argsTemplate);
console.log(execute, args, env, cwd, appCwd);
return child_process.spawn(execute, args, {env: env, cwd: cwd || appCwd});
}
get isYGOPro(): boolean {
return !!this.ygoproDistroData;
}
get ygoproDistroData(): YGOProDistroData {
if(!this.data) {
return null;
}
return this.data.ygopro || null;
}
get ygoproDeckPath(): string {
const distroData = this.ygoproDistroData;
if(!distroData) {
return null;
}
return path.join(this.local!.path, distroData.deckPath);
}
get ygoproReplayPath(): string {
const distroData = this.ygoproDistroData;
if(!distroData || !distroData.replayPath) {
return null;
}
return path.join(this.local!.path, distroData.replayPath);
}
get systemConfPath(): string {
const distroData = this.ygoproDistroData;
if(!distroData || !distroData.systemConf) {
return null;
}
return path.join(this.local!.path, distroData.systemConf);
}
}
......@@ -19,9 +19,8 @@ import {LoginService} from './login.service';
import {SettingsService} from './settings.sevices';
import {ComparableSet} from './shared/ComparableSet';
import {AppsJson} from './apps-json-type';
import Timer = NodeJS.Timer;
import ReadableStream = NodeJS.ReadableStream;
import * as os from 'os';
import Timer = NodeJS.Timer;
const Logger = {
info: (...message: any[]) => {
......
......@@ -23,7 +23,7 @@ $.fn.init = new Proxy($.fn.init, {
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 {SettingsService} from './settings.sevices';
import {App} from './app';
......
/**
* 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 {error} from 'util';
// import Timer = NodeJS.Timer;
......
......@@ -2,7 +2,7 @@
* Created by zh99998 on 2017/6/1.
*/
import * as Raven from 'raven-js';
import { ErrorHandler } from '@angular/core';
import {ErrorHandler} from '@angular/core';
Raven
.config('https://2c5fa0d0f13c43b5b96346f4eff2ea60@sentry.io/174769')
......@@ -12,4 +12,4 @@ export class RavenErrorHandler implements ErrorHandler {
handleError(err: any): void {
Raven.captureException(err.originalError || err);
}
}
\ No newline at end of file
}
import {TRANSLATIONS, TRANSLATIONS_FORMAT, LOCALE_ID} from '@angular/core';
import {LOCALE_ID, TRANSLATIONS, TRANSLATIONS_FORMAT} from '@angular/core';
import {remote} from 'electron';
export async function getTranslationProviders (): Promise<Object[]> {
......
import {App} from './app';
import * as path from 'path';
/**
* Created by weijian on 2016/10/24.
*/
......
......@@ -42,6 +42,15 @@
</a>
</li>
</ul>
<span i18n *ngIf="grouped_apps.ygopro">YGOPro 各发行版</span>
<ul *ngIf="grouped_apps.recommend" class="nav nav-pills flex-column">
<li *ngFor="let app of grouped_apps.ygopro" class="nav-item">
<a (click)="$event.preventDefault(); chooseApp(app)" [href]="'https://mycard.moe/' + app.id" class="nav-link" [class.active]="app===currentApp">
<img *ngIf="app.icon" class="icon" [src]="app.icon">
{{app.name}}
</a>
</li>
</ul>
<span i18n *ngIf="grouped_apps.mysterious">迷之物体</span>
<ul *ngIf="grouped_apps.mysterious" class="nav nav-pills flex-column">
<li *ngFor="let app of grouped_apps.mysterious" class="nav-item">
......@@ -95,4 +104,4 @@
</div>
</div>
<div id="right-shadow"></div>
\ No newline at end of file
<div id="right-shadow"></div>
/**
* Created by zh99998 on 16/9/2.
*/
import { ChangeDetectorRef, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { AppsService } from './apps.service';
import { LoginService } from './login.service';
import { App, Category } from './app';
import { shell } from 'electron';
import { SettingsService } from './settings.sevices';
import {ChangeDetectorRef, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
import {AppsService} from './apps.service';
import {LoginService} from './login.service';
import {App, Category} from './app';
import {shell} from 'electron';
import {SettingsService} from './settings.sevices';
const ReconnectingWebSocket = require('reconnecting-websocket');
// import 'typeahead.js';
......@@ -168,25 +169,27 @@ export class LobbyComponent implements OnInit {
let contains = ['game', 'music', 'book'].map((value) => Category[value]);
let result = {runtime: []};
for (let app of this.apps.values()) {
let tag: string;
let tags: string[];
if (contains.includes(app.category)) {
if (app.isInstalled()) {
tag = 'installed';
tags = ['installed'];
} else {
tag = app.tags ? app.tags[0] : 'test';
tags = app.tags || ['test'];
}
} else {
if (app.isInstalled()) {
tag = 'runtime_installed';
tags = ['runtime_installed'];
} else {
tag = 'runtime';
tags = ['runtime'];
}
}
if (!result[tag]) {
result[tag] = [];
for (const tag of tags) {
if (!result[tag]) {
result[tag] = [];
}
result[tag].push(app);
}
result[tag].push(app);
}
return result;
}
......
/**
* Created by zh99998 on 16/9/2.
*/
import { Component } from '@angular/core';
import { LoginService } from './login.service';
import {Component} from '@angular/core';
import {LoginService} from './login.service';
import * as crypto from 'crypto';
import { shell } from 'electron';
import {shell} from 'electron';
@Component({
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 { remote, shell } from 'electron';
import {remote, shell} from 'electron';
import * as $ from 'jquery';
import * as Tether from 'tether';
import { LoginService } from './login.service';
import { SettingsService } from './settings.sevices';
import {LoginService} from './login.service';
import {SettingsService} from './settings.sevices';
window['Tether'] = Tether;
const autoUpdater: Electron.AutoUpdater = remote.getGlobal('autoUpdater');
......
import { ErrorHandler, LOCALE_ID, NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { MyCardComponent } from './mycard.component';
import { LoginComponent } from './login.component';
import { StoreComponent } from './store.component';
import { LobbyComponent } from './lobby.component';
import { AppDetailComponent } from './app-detail.component';
import { RosterComponent } from './roster.component';
import { YGOProComponent } from './ygopro.component';
import { AppsService } from './apps.service';
import { SettingsService } from './settings.sevices';
import { LoginService } from './login.service';
import { DownloadService } from './download.service';
import { AboutComponent } from './about.component';
import { CandyComponent } from './candy.component';
import { RavenErrorHandler } from './error-handler';
import { NetworkComponent } from './network.component';
import {LOCALE_ID, NgModule, NO_ERRORS_SCHEMA} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {HttpModule} from '@angular/http';
import {MyCardComponent} from './mycard.component';
import {LoginComponent} from './login.component';
import {StoreComponent} from './store.component';
import {LobbyComponent} from './lobby.component';
import {AppDetailComponent} from './app-detail.component';
import {RosterComponent} from './roster.component';
import {YGOProComponent} from './ygopro.component';
import {AppsService} from './apps.service';
import {SettingsService} from './settings.sevices';
import {LoginService} from './login.service';
import {DownloadService} from './download.service';
import {AboutComponent} from './about.component';
import {CandyComponent} from './candy.component';
import {NetworkComponent} from './network.component';
export function settingsService_getLocale(settingsService: SettingsService) {
return settingsService.getLocale();
......
import { ChangeDetectorRef, Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges, Injectable } from '@angular/core';
import { AppsService } from './apps.service';
import {Component, Injectable, Input} from '@angular/core';
import {AppsService} from './apps.service';
import {App} from './app';
@Component({
......
/**
* 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({
moduleId: module.id,
selector: 'roster',
......
......@@ -2,6 +2,7 @@
* Created by zh99998 on 16/9/2.
*/
import {Component} from '@angular/core';
@Component({
moduleId: module.id,
selector: 'store',
......
This diff is collapsed.
{
"name": "mycard",
"version": "3.0.48",
"version": "3.0.51",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "3.0.48",
"version": "3.0.51",
"hasInstallScript": true,
"license": "UNLICENSED",
"dependencies": {
......@@ -35,6 +35,7 @@
"ini": "1.3.4",
"jquery": "2.2.4",
"marked": "0.3.6",
"mustache": "^4.2.0",
"raven-js": "3.16.1",
"raw-socket": "latest",
"reconnecting-websocket": "3.0.7",
......@@ -57,6 +58,7 @@
"@types/jquery": "^2.0.47",
"@types/lodash": "^4.14.172",
"@types/marked": "latest",
"@types/mustache": "^4.1.2",
"@types/node": "^14.0.1",
"@types/tether": "latest",
"@types/typeahead": "latest",
......@@ -564,6 +566,12 @@
"integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==",
"dev": true
},
"node_modules/@types/mustache": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/@types/mustache/-/mustache-4.1.2.tgz",
"integrity": "sha512-c4OVMMcyodKQ9dpwBwh3ofK9P6U9ZktKU9S+p33UqwMNN1vlv2P0zJZUScTshnx7OEoIIRcCFNQ904sYxZz8kg==",
"dev": true
},
"node_modules/@types/node": {
"version": "14.0.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.1.tgz",
......@@ -3539,6 +3547,14 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"node_modules/mustache": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz",
"integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==",
"bin": {
"mustache": "bin/mustache"
}
},
"node_modules/nan": {
"version": "2.14.2",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz",
......@@ -5904,6 +5920,12 @@
"integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==",
"dev": true
},
"@types/mustache": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/@types/mustache/-/mustache-4.1.2.tgz",
"integrity": "sha512-c4OVMMcyodKQ9dpwBwh3ofK9P6U9ZktKU9S+p33UqwMNN1vlv2P0zJZUScTshnx7OEoIIRcCFNQ904sYxZz8kg==",
"dev": true
},
"@types/node": {
"version": "14.0.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.1.tgz",
......@@ -8269,6 +8291,11 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"mustache": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz",
"integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ=="
},
"nan": {
"version": "2.14.2",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.2.tgz",
......
......@@ -70,6 +70,8 @@ System.config({
// other node.js libraries
"electron": "@node/electron",
"ini": "@node/ini",
"mustache": "@node/mustache",
"lodash": "@node/lodash",
"mkdirp": "@node/mkdirp",
"aria2": "@node/aria2",
"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