Skip to content

Commit 70fb2dd

Browse files
committed
Bug fixes, dummied out INI code
1 parent a69fad2 commit 70fb2dd

9 files changed

Lines changed: 610 additions & 114 deletions

File tree

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "tribeslauncher",
33
"productName": "tribeslauncher",
4-
"version": "0.2.0",
4+
"version": "0.3.0",
55
"description": "My Electron application description",
66
"main": "src/main/index.ts",
77
"scripts": {
@@ -57,6 +57,7 @@
5757
"@types/electron-devtools-installer": "^2.0.2",
5858
"@types/fs-extra": "^5.0.1",
5959
"@types/howler": "^2.0.5",
60+
"@types/ini": "^1.3.29",
6061
"@types/node": "^9.6.1",
6162
"@types/react": "^0.14.55",
6263
"@types/react-dom": "^0.14.20",
@@ -76,6 +77,7 @@
7677
"fs-extra": "^5.0.0",
7778
"fs-promise": "^2.0.3",
7879
"howler": "^2.0.9",
80+
"ini": "^1.3.5",
7981
"is-admin": "^2.1.1",
8082
"jsonschema": "^1.2.4",
8183
"node-dll-injector": "^0.1.1",

src/common/launcher-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const generateDefaultConfig = (userDataPath: string = '.'): LauncherConfi
8989
releaseChannel: 'stable',
9090
updateUrl: 'https://raw.githubusercontent.com/mcoot/tamodsupdate/release',
9191
autoInjectEnabled: false,
92-
autoInjectTimer: 20
92+
autoInjectTimer: 30
9393
};
9494
};
9595

src/common/launcher-news.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ export interface CommunityWeblink {
4545

4646
export type CommunityItem = CommunityDiscord | CommunityMumble | CommunityReddit | CommunityIframe | CommunityWeblink;
4747

48+
/////// INIs
49+
50+
export interface IniPreset {
51+
name: string;
52+
category: string;
53+
description: string;
54+
remotePath: string;
55+
}
56+
4857
/////// News
4958

5059
export interface NewsItem {
@@ -59,6 +68,7 @@ export interface LauncherNews {
5968
community: CommunityItem[];
6069
latestLauncherVersion: string;
6170
launcherUpdateLink: string;
71+
iniPresets: IniPreset[];
6272
}
6373

6474
/////// Functions
@@ -71,5 +81,6 @@ export const downloadLauncherNews = async (newsUrl: string): Promise<LauncherNew
7181
}
7282

7383
// Parse news to JSON - may throw exception if launcher news is invalid
74-
return JSON.parse(newsBuffer.toString('utf8'));
84+
const result = JSON.parse(newsBuffer.toString('utf8'));
85+
return result;
7586
};

src/main/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as commandLineArgs from 'command-line-args';
33
import { app, BrowserWindow, ipcMain } from 'electron';
44
import installExtension, { REACT_DEVELOPER_TOOLS } from 'electron-devtools-installer';
55
import { enableLiveReload } from 'electron-compile';
6+
import * as download from 'download';
67
import * as path from 'path';
78

89
import { InjectionResult, Injector } from '../common/injector';
@@ -116,6 +117,15 @@ const createWindow = async () => {
116117
event.sender.send('uninstall-finished-request');
117118
});
118119

120+
ipcMain.on('retrieve-ini-request', async (event: any, args: any) => {
121+
try {
122+
const result = await download(args[0]);
123+
event.sender.send('retrieve-ini-finished', [true, result]);
124+
} catch (err) {
125+
event.sender.send('retrieve-ini-finished', [false, err]);
126+
}
127+
});
128+
119129
ipcMain.on('news-request', async (event: any, newsUrl: string) => {
120130
let result;
121131
try {

src/renderer/components/app.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { ipcRenderer, remote } from 'electron';
1111
import { NewsDisplay } from './newsDisplay';
1212
import { CommunityDisplay } from './communityDisplay';
1313
import { InfoModal } from './infoModal';
14+
import { ConfigureModal } from './configureModal';
1415
import { SettingsModal } from './settingsModal';
1516
import { OnLaunchModal, OnLaunchModelStatus } from './onLaunchModal';
1617

@@ -64,7 +65,14 @@ export class App extends React.Component<AppProps, AppState> {
6465
window.addEventListener('beforeunload', this.componentCleanup);
6566
if (this.props.userDataPath) {
6667
// Load config
67-
const loadedConfig = await loadLauncherConfig(`${this.props.userDataPath}/launcherConfig.json`, this.props.userDataPath);
68+
let loadedConfig = generateDefaultConfig();
69+
try {
70+
loadedConfig = await loadLauncherConfig(`${this.props.userDataPath}/launcherConfig.json`, this.props.userDataPath);
71+
} catch (err) {
72+
remote.dialog.showErrorBox('Error loading configuration',
73+
`Unable to load launcher configuration; default configuration restored. Error: ${err.message || err}`);
74+
}
75+
6876
this.setState((s) => ({
6977
config: loadedConfig,
7078
launcherState: s.launcherState,
@@ -366,14 +374,20 @@ export class App extends React.Component<AppProps, AppState> {
366374
launcherVersion={LAUNCHER_VERSION}
367375
onModalButtonClick={(pth) => this.handleOnLaunchModelStateChange(null, null, pth)}
368376
/>
377+
<ConfigureModal
378+
config={this.state.config}
379+
news={this.state.news}
380+
userDataPath={this.props.userDataPath}
381+
userConfigPath={this.props.userConfigPath}
382+
onUninstallComplete={this.handleUninstallComplete}
383+
/>
369384
<SettingsModal
370385
initialConfig={this.state.config}
371386
onSettingsFormSave={this.onSettingsFormSave}
372387
userDataPath={this.props.userDataPath}
373388
userConfigPath={this.props.userConfigPath}
374-
onUninstallComplete={this.handleUninstallComplete}
375389
/>
376-
<InfoModal launcherVersion={LAUNCHER_VERSION} />
390+
<InfoModal launcherVersion={LAUNCHER_VERSION} news={this.state.news} />
377391
<Button compact size={'tiny'} icon onClick={this.onBtnMinimisePressed}>
378392
<Icon fitted name='window minimize' />
379393
</Button>

0 commit comments

Comments
 (0)