1
0
mirror of https://github.com/mgerb/ps-launcher synced 2026-01-10 02:22:49 +00:00

v0.0.2 - webview and other updates

This commit is contained in:
2017-10-25 23:16:55 -05:00
parent 96f9c4ca5d
commit f584a5a2f9
25 changed files with 418 additions and 51 deletions

View File

@@ -3,6 +3,7 @@ import fs from 'fs';
import { exec } from 'child_process';
import { inject, observer } from 'mobx-react';
import { AppState } from '../../state/AppState';
import { toast } from '../../util';
import './ServerList.scss';
@@ -32,14 +33,24 @@ export class ServerList extends React.Component<Props, any> {
private async play(): Promise<void> {
const { directory } = this.props.AppState.selectedExpansion;
// set the realm list
await this.setRealmList();
if (directory === '') {
toast.error('Please set your root WoW directory');
return;
}
// launch wow
exec(`"${directory}/WoW.exe"`, (err, output) => {
console.log(err);
console.log(output);
});
try {
// set the realm list
await this.setRealmList();
// launch wow
exec(`"${directory}/WoW.exe"`, err => {
if (err) {
toast.error('Unable to find WoW.exe in current directory');
}
});
} catch {
toast.error('Unable to find realmlist.wtf in current directory');
}
}
private setRealmList(): Promise<any> {
@@ -47,8 +58,16 @@ export class ServerList extends React.Component<Props, any> {
const { realmlist } = this.props.AppState.selectedServer;
return new Promise((resolve, reject) => {
fs.writeFile(`${directory}/realmlist.wtf`, `set realmlist ${realmlist}`, err => {
err ? reject(err) : resolve();
fs.stat(`${directory}/realmlist.wtf`, readErr => {
// return if we can't find realmlist.wtf
if (readErr) {
reject(readErr);
return;
}
fs.writeFile(`${directory}/realmlist.wtf`, `set realmlist ${realmlist}`, err => {
err ? reject(err) : resolve();
});
});
});
}
@@ -60,7 +79,7 @@ export class ServerList extends React.Component<Props, any> {
<div className="server-list">
<div className="server-list-heading">
<div>Servers</div>
<i className="fa fa-plus"/>
<i className="fa fa-plus" />
</div>
<div className="item-container">{this.renderItems()}</div>
<div className="start-button-container">