Archive update 0.53.1

This commit is contained in:
Tschrock
2019-09-02 11:37:22 -04:00
parent 715dfb8aeb
commit ac640dbe1a
32 changed files with 212 additions and 248 deletions
@@ -8,8 +8,8 @@ import {
import { StorageService } from '../../services/storageService';
import { cloneDeep } from '../../../common/utils';
import { PonyTownGame } from '../../../client/game';
import { updateRangeIndicator } from '../../../client/clientUtils';
import { faSlidersH, faCommentSlash, faGamepad, faImage } from '../../../client/icons';
import { updateRangeIndicator, readFileAsText } from '../../../client/clientUtils';
import { faSlidersH, faCommentSlash, faGamepad, faImage, faDownload, faUpload } from '../../../client/icons';
@Component({
selector: 'settings-modal',
@@ -24,6 +24,8 @@ export class SettingsModal implements OnInit, OnDestroy {
readonly filtersIcon = faCommentSlash;
readonly controlsIcon = faGamepad;
readonly graphicsIcon = faImage;
readonly exportIcon = faDownload;
readonly importIcon = faUpload;
@Output() close = new EventEmitter();
account: AccountSettings = {};
browser: BrowserSettings = {};
@@ -119,4 +121,19 @@ export class SettingsModal implements OnInit, OnDestroy {
this.account.filterWords = '';
}
}
export() {
const account = { ...this.account, actions: undefined };
const browser = this.browser;
const data = JSON.stringify({ account, browser });
saveAs(new Blob([data], { type: 'text/plain;charset=utf-8' }), `pony-town-settings.json`);
}
async import(file: File | undefined) {
if (file) {
const text = await readFileAsText(file);
const { account, browser } = JSON.parse(text);
const actions = this.account.actions;
Object.assign(this.account, { ...account, actions });
Object.assign(this.browser, browser);
}
}
}