Commit 07b9e520 authored by 神楽坂玲奈's avatar 神楽坂玲奈

news

parent 46a685a2
......@@ -20,3 +20,6 @@ progress {
margin-top: 2px;
}
.carousel-inner img {
width: 100%;
}
\ No newline at end of file
......@@ -4,7 +4,7 @@
<div *ngIf="!appsService.getDownloadInfo(routingService.app)">
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#install-modal">安装</button>
<button type="button" class="btn btn-secondary">导入</button>
<button type="button" class="btn btn-secondary">正版代购</button>
<!--<button type="button" class="btn btn-secondary">正版代购</button>-->
</div>
<div *ngIf="appsService.getDownloadInfo(routingService.app)">
<div *ngIf="appsService.getDownloadInfo(routingService.app).status === 'install'">正在安装...</div>
......@@ -18,23 +18,45 @@
<div *ngIf="isInstalled && (routingService.app != 'ygopro')">
<button (click)="startApp(routingService.app)" type="button" class="btn btn-primary">运行</button>
<button type="button" data-toggle="modal" data-target="#settings-modal" class="btn btn-secondary">设置</button>
<button (click)="appsService.browse(routingService.app)" type="button" class="btn btn-secondary">游览本地文件</button>
<!--<button (click)="appsService.browse(routingService.app)" type="button" class="btn btn-secondary">游览本地文件</button>-->
<button type="button" class="btn btn-secondary">联机</button>
</div>
<ygopro *ngIf="isInstalled && (routingService.app == 'ygopro')"></ygopro>
<br>
<h2>新闻</h2>
<h2 *ngIf="news">新闻</h2>
<p *ngIf="!news">没有新闻</p>
<div *ngIf="news">
<!--<div *ngIf="news">
<div class="list-group">
<a *ngFor="let item of news" href="{{item.url}}" class="list-group-item">{{item.title}}</a>
</div>
</div>-->
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li *ngFor="let item of news; let index = index;" data-target="#carousel-example-generic" [data-slide-to]="index" [class.active]="index == 0"></li>
</ol>
<div class="carousel-inner" role="listbox">
<div *ngFor="let item of news; let index = index;" class="carousel-item" [class.active]="index == 0">
<img [src]="item.image" [alt]="item.title">
<div class="carousel-caption">
<h3>{{item.title}}</h3>
<p>{{item.text}}</p>
</div>
</div>
</div>
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="icon-prev" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="icon-next" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<br>
<div *ngIf="friends">
......@@ -88,7 +110,12 @@
</table>
</div>
<button (click)="appsService.doTar()">DOTAR</button>
<div *ngIf="isInstalled">
<h2>本地文件</h2>
<button (click)="appsService.browse(routingService.app)" type="button" class="btn btn-secondary">浏览本地文件</button>
<button (click)="uninstall()" type="button" class="btn btn-secondary">{{'uninstall'|translate}}</button>
</div>
<div class="modal fade" id="settings-modal" tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
......@@ -187,10 +214,7 @@
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button id="submit" type="submit" [disabled]="!theForm.form.valid" class="btn btn-primary">安装</button>
</div>
<!--
-->
</form>
</div>
</div>
......
......@@ -229,6 +229,7 @@ export class AppsService {
deleteFile(path: string): Promise<string> {
return new Promise((resolve, reject)=> {
fs.lstat(path, (err, stats)=> {
if (err) return resolve(path);
if (stats.isDirectory()) {
fs.rmdir(path, (err)=> {
resolve(path);
......
......@@ -6,7 +6,7 @@
</select>
</div>
<button type="submit" class="btn btn-secondary" (click)="edit_deck(current_deck)">编辑</button>
<button type="submit" class="btn btn-secondary">删除</button>
<button type="submit" (click)="delete_deck(current_deck)" class="btn btn-secondary">删除</button>
<button type="submit" (click)="refresh()" class="btn btn-secondary">刷新</button>
</form>
......@@ -16,5 +16,165 @@
<button type="button" class="btn btn-secondary" data-toggle="modal" data-target="#game-create-modal">创建房间</button>
<button type="button" class="btn btn-secondary" data-toggle="modal" data-target="#game-list-modal">房间列表</button>
<button type="button" class="btn btn-secondary" data-toggle="modal" data-target="#game-create-windbot">单人模式</button>
<button (click)="appsService.browse(routingService.app)" type="button" class="btn btn-secondary">浏览本地文件</button>
<!--<button (click)="appsService.browse(routingService.app)" type="button" class="btn btn-secondary">浏览本地文件</button>-->
</div>
<div class="modal fade" id="game-create-windbot" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="myModalLabel1">单人模式</h4>
</div>
<div class="modal-body">
<label>选择对手</label>
<div id="windbot" class="list-group">
<a *ngFor="let name of windbot" href="#" class="list-group-item"
onclick="join_windbot(name)">{{name}}</a>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="game-create-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" id="myModalLabel">创建房间</h4>
</div>
<form id="game-create">
<div class="modal-body">
<div class="form-group row">
<label for="game-create-title" class="col-sm-2 form-control-label">游戏标题</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="game-create-title" name="title">
</div>
</div>
<div class="form-group row">
<label for="game-create-rule" class="col-sm-2 form-control-label">卡片允许</label>
<div class="col-sm-10">
<select class="form-control" id="game-create-rule" name="rule">
<option value="0" selected>OCG</option>
<option value="1">TCG</option>
<option value="2">OCG & TCG</option>
<option value="3">专有卡禁止</option>
</select>
</div>
</div>
<div class="form-group row">
<label for="game-create-mode" class="col-sm-2 form-control-label">决斗模式</label>
<div class="col-sm-10">
<select class="form-control" id="game-create-mode" name="mode">
<option value="0">单局模式</option>
<option value="1" selected>比赛模式</option>
<option value="2">TAG</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 form-control-label">额外选项</label>
<div class="col-sm-4">
<div class="row">
<label for="game-create-start-lp" class="col-sm-6 form-control-label">初始 LP</label>
<div class="col-sm-6">
<input name="start_lp" type="number" value="8000" min="1" max="65536"
class="form-control form-control-sm game-create-extra"
id="game-create-start-lp">
</div>
</div>
<div class="row">
<label for="game-create-start-hand" class="col-sm-6 form-control-label">初始手牌数</label>
<div class="col-sm-6">
<input name="start_hand" type="number" value="5" min="0" max="16"
class="form-control form-control-sm game-create-extra"
id="game-create-start-hand">
</div>
</div>
<div class="row">
<label for="game-create-draw-count" class="col-sm-6 form-control-label">每回合抽卡</label>
<div class="col-sm-6">
<input name="draw_count" type="number" value="1" min="0" max="16"
class="form-control form-control-sm game-create-extra"
id="game-create-draw-count">
</div>
</div>
</div>
<div class="col-sm-6">
<div class="checkbox">
<label>
<input name="enable_priority" type="checkbox">允许启动效果优先权
</label>
</div>
<div class="checkbox">
<label>
<input name="no_check_deck" type="checkbox">不检查卡组
</label>
</div>
<div class="checkbox">
<label>
<input name="no_shuffle_deck" type="checkbox">开局不洗卡组
</label>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2">私密房间</label>
<div class="col-sm-10">
<div class="checkbox">
<label>
<input name="private" type="checkbox">不在房间列表中显示 (约战功能还没做好,不要勾
</label>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary float-left" data-dismiss="modal" data-toggle="modal"
data-target="#game-list-modal">查看房间
</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<button type="submit" class="btn btn-primary">创建</button>
</div>
</form>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="game-list-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<table class="table table-striped table-hover">
<thead class="modal-header">
<tr>
<th class="title">游戏标题</th>
<th class="users">玩家</th>
<th class="mode">决斗模式</th>
<th class="extra">额外选项</th>
</tr>
</thead>
<tbody class="modal-body"></tbody>
</table>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
<div class="modal-footer">
<button type="button" class="btn btn-secondary float-left" data-dismiss="modal" data-toggle="modal"
data-target="#game-create-modal">创建房间
</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
</div>
</div>
</div>
</div>
\ No newline at end of file
......@@ -12,6 +12,7 @@ const path = System._nodeRequire('path');
const child_process = System._nodeRequire('child_process');
//const Promise = System._nodeRequire('bluebird');
const ini = System._nodeRequire('ini');
const electron = System._nodeRequire('electron');
@Component({
selector: 'ygopro',
......@@ -27,18 +28,22 @@ export class YGOProComponent {
numfont = {'darwin': ['/System/Library/Fonts/PingFang.ttc']};
textfont = {'darwin': ['/System/Library/Fonts/PingFang.ttc']};
windbot = ["琪露诺", "谜之剑士LV4", "复制植物", "尼亚"];
servers = [{address:"112.124.105.11", port: 7911}];
constructor(private appsService: AppsService, private routingService: RoutingService) {
this.refresh()
}
refresh() {
refresh = () => {
this.get_decks().then((decks)=> {
this.decks = decks;
if (!(this.current_deck in this.decks)) {
this.current_deck = decks[0];
}
})
}
};
get_decks(): Promise<[string]> {
return new Promise((resolve, reject)=> {
......@@ -77,6 +82,12 @@ export class YGOProComponent {
.catch(reason=>console.log(reason))
}
delete_deck(deck) {
return new Promise((resolve, reject) => {
fs.unlink(path.join(this.app.local.path, 'deck', deck + '.ydk'), resolve)
}).then(this.refresh)
}
fix_fonts = (data) => {
return this.get_font([data.numfont])
.catch(() => this.get_font(this.numfont[process.platform]).then(font => data['numfont'] = font))
......@@ -105,15 +116,39 @@ export class YGOProComponent {
})
};
join(name, server) {
this.load_system_conf()
.then(this.fix_fonts)
.then(data => {
data['lastdeck'] = this.current_deck;
data['lastip'] = server.address;
data['lastport'] = server.port;
data['roompass'] = name;
return data
})
.then(this.save_system_conf)
.then(()=>['-j'])
.then(this.start_game)
.catch(reason=>console.log(reason))
};
join_windbot(name) {
this.join(name, this.servers[0])
}
start_game = (args) => {
let win = electron.remote.getCurrentWindow();
win.minimize();
return new Promise((resolve, reject)=> {
let child = child_process.spawn(path.join(this.app.local.path, this.app.actions[process.platform]['main']['execute']), args, {cwd: this.app.local.path});
child.on('error', (error)=> {
reject(error)
reject(error);
win.restore()
});
child.on('exit', (code, signal)=> {
// error 触发之后还可能会触发exit,但是Promise只承认首次状态转移,因此这里无需重复判断是否已经error过。
resolve(code)
resolve(code);
win.restore()
})
})
};
......
This diff is collapsed.
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