1 import FileSaver from 'file-saver';
2 import PropTypes from 'prop-types';
3 import React from 'react';
4 import { Button, Col, Container, Row } from 'react-bootstrap';
5 import { withTranslation } from 'react-i18next';
6 import toastr from 'toastr';
8 import BaseRomButton from './BaseRomButton';
9 import { useAosBaseRom } from '../../helpers/AosBaseRomContext';
10 import BPS from '../../helpers/bps';
11 import i18n from '../../i18n';
13 const applyPatch = (rom, patch, filename) => {
15 const bps = new BPS();
18 const result = bps.applyPatch();
19 FileSaver.saveAs(new Blob([result], { type: 'application/octet-stream' }), filename);
21 toastr.error(i18n.t('aosSeeds.patchError', { msg: e.message }));
25 const Seed = ({ patch, seed }) => {
26 const { rom } = useAosBaseRom();
29 <h1>{i18n.t('aosSeeds.heading')}</h1>
31 <Col md={{ order: 2 }}>
35 onClick={() => applyPatch(
38 `${i18n.t('aosSeeds.filename', {
45 {i18n.t(patch ? 'aosSeeds.patch' : 'aosSeeds.fetchingPatch')}
51 <Col md={{ order: 1 }}>
53 {i18n.t('aosSeeds.preset')}:
55 <strong>{i18n.t(`aosSeeds.presets.${seed.preset}`)}</strong>
57 <p>{i18n.t(seed.race ? 'aosSeeds.race' : 'aosSeeds.noRace')}</p>
58 <p>{i18n.t(seed.mystery ? 'aosSeeds.mystery' : 'aosSeeds.noMystery')}</p>
61 <h2 className="mt-5">{i18n.t('aosSeeds.generator')}</h2>
62 <p>{i18n.t(`aosSeeds.generators.${seed.generator}`)}</p>
67 patch: PropTypes.instanceOf(ArrayBuffer),
68 seed: PropTypes.shape({
69 generator: PropTypes.string,
70 hash: PropTypes.string,
71 mystery: PropTypes.bool,
72 preset: PropTypes.string,
77 export default withTranslation()(Seed);