mirror of
https://github.com/mgerb/ps-launcher
synced 2026-01-11 19:02:50 +00:00
init
This commit is contained in:
3
app/pages/Home/Home.scss
Normal file
3
app/pages/Home/Home.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
.Home {
|
||||
padding: 10px;
|
||||
}
|
||||
68
app/pages/Home/Home.tsx
Normal file
68
app/pages/Home/Home.tsx
Normal file
@@ -0,0 +1,68 @@
|
||||
import * as _ from 'lodash';
|
||||
import fs from 'fs';
|
||||
import { exec } from 'child_process';
|
||||
import React from 'react';
|
||||
import { RouteComponentProps } from 'react-router-dom';
|
||||
|
||||
import './Home.scss';
|
||||
|
||||
interface Props extends RouteComponentProps<any> {}
|
||||
|
||||
interface State {
|
||||
path: string;
|
||||
}
|
||||
|
||||
export default class Home extends React.Component<Props, State> {
|
||||
constructor() {
|
||||
super();
|
||||
this.state = {
|
||||
path: '',
|
||||
};
|
||||
}
|
||||
|
||||
onFolderSelect(e: React.ChangeEvent<HTMLInputElement>) {
|
||||
const path: string = _.get(e, `target.files[0].path`);
|
||||
|
||||
if (path) {
|
||||
this.setState({ path });
|
||||
}
|
||||
}
|
||||
|
||||
async startGame() {
|
||||
const { path } = this.state;
|
||||
|
||||
// set the realm list
|
||||
await this.setRealmList();
|
||||
|
||||
// launch wow
|
||||
exec(`"${path}/WoW.exe"`, (err, output) => {
|
||||
console.log(err);
|
||||
console.log(output);
|
||||
});
|
||||
}
|
||||
|
||||
setRealmList(): Promise<any> {
|
||||
const { path } = this.state;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.writeFile(`${path}/realmlist.wtf`, 'set realmlist logon.elysium-project.org', err => {
|
||||
err ? reject(err) : resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { path } = this.state;
|
||||
|
||||
return (
|
||||
<div className="Home">
|
||||
<div>{path}</div>
|
||||
{/* hacky way of adding webkitdirectory to the input */}
|
||||
<input type="file" {...{ webkitdirectory: 'true' }} onChange={this.onFolderSelect.bind(this)} />
|
||||
<div>
|
||||
<button onClick={this.startGame.bind(this)}>Start</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
5
app/pages/NotFound/NotFound.scss
Normal file
5
app/pages/NotFound/NotFound.scss
Normal file
@@ -0,0 +1,5 @@
|
||||
.NotFound {
|
||||
font-size: 20px;
|
||||
text-align: center;
|
||||
padding-top: 200px;
|
||||
}
|
||||
18
app/pages/NotFound/NotFound.tsx
Normal file
18
app/pages/NotFound/NotFound.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import { RouteComponentProps } from 'react-router-dom';
|
||||
|
||||
import './NotFound.scss';
|
||||
|
||||
interface Props extends RouteComponentProps<any> {}
|
||||
|
||||
interface State {}
|
||||
|
||||
export default class NotFound extends React.Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
return <div className="NotFound">404 Not Found</div>;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user