Skip to content

Commit 224c14e

Browse files
committed
Redownload game data fix
1 parent bedf616 commit 224c14e

File tree

4 files changed

+62
-72
lines changed

4 files changed

+62
-72
lines changed

electron/settings/settings.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { checkSettings } from './settings-checker';
44
import { SettingsDefault } from './settings-default';
55
import * as macAddress from 'macaddress';
66
import { app, ipcMain } from 'electron';
7+
import * as del from 'del';
78

89
const settings = require('electron-settings');
910
const i18n = require('node-translate');
@@ -55,6 +56,10 @@ export class Settings {
5556
ipcMain.on('write-settings', (event, args) => {
5657
event.returnValue = settings.set(args[0], args[1]);
5758
});
59+
60+
ipcMain.on('reset-game', (event, args) => {
61+
this.resetGame();
62+
});
5863
};
5964

6065
public static resetSettings(): void {
@@ -98,4 +103,13 @@ export class Settings {
98103
};
99104
};
100105

106+
public static resetGame() {
107+
let destinationPath = app.getPath('userData') + '/game';
108+
109+
del([destinationPath + "/*"], {force: true}).then((paths) => {
110+
app.relaunch();
111+
app.quit();
112+
});
113+
}
114+
101115
}

package-lock.json

Lines changed: 45 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"decompress": "4.2.0",
4747
"decompress-targz": "4.1.1",
4848
"decompress-unzip": "4.0.1",
49+
"del": "3.0.0",
4950
"electron-localshortcut": "1.1.1",
5051
"electron-settings": "3.1.4",
5152
"enhanced-resolve": "3.3.0",
@@ -78,7 +79,6 @@
7879
"babel-core": "6.24.1",
7980
"babel-preset-es2015": "6.24.1",
8081
"babel-register": "6.24.1",
81-
"del": "3.0.0",
8282
"doctoc": "1.3.1",
8383
"electron": "1.8.2",
8484
"electron-builder": "19.55.3",

src/app/window/option/general/general.component.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { PromptService } from 'app/core/service/prompt.service';
66
import { SettingsService } from 'app/core/service/settings.service';
77
import { WindowService } from 'app/core/service/window.service';
88
import { OptionWindowService } from '../option.window';
9+
import { app, ipcMain } from 'electron';
910

1011
interface select {
1112
name: string;
@@ -93,10 +94,6 @@ export class GeneralComponent implements OnInit {
9394
}
9495

9596
public resetGameFile() {
96-
97-
this.settingsService.appVersion = null;
98-
this.settingsService.buildVersion = null;
99-
100-
electron.restart();
97+
this.ipcRendererService.send('reset-game');
10198
}
10299
}

0 commit comments

Comments
 (0)