From 14a41159e782580521e5e510d91663bc93c9d2dc Mon Sep 17 00:00:00 2001 From: James Tanner Date: Thu, 28 Dec 2023 14:40:43 +0900 Subject: [PATCH] Support sim links for sharing specific categories of settings (gear, rotation, etc) --- ui/core/components/exporters.ts | 139 ++++++++++++++-- ui/core/components/importers.ts | 66 +++++++- ui/core/individual_sim_ui.ts | 204 ++++++++++++------------ ui/core/player.ts | 147 +++++++++++------ ui/core/sim.ts | 11 ++ ui/raid/import_export.ts | 2 +- ui/scss/core/components/_exporters.scss | 6 + 7 files changed, 412 insertions(+), 163 deletions(-) diff --git a/ui/core/components/exporters.ts b/ui/core/components/exporters.ts index 31a0229ca6..dacf15d7dc 100644 --- a/ui/core/components/exporters.ts +++ b/ui/core/components/exporters.ts @@ -9,18 +9,30 @@ import { IndividualSimSettings } from '../proto/ui'; import { classNames, raceNames } from '../proto_utils/names'; import { UnitStat } from '../proto_utils/stats'; import { specNames } from '../proto_utils/utils'; -import { downloadString, jsonStringifyWithFlattenedPaths } from '../utils'; +import { arrayEquals, downloadString, getEnumValues, jsonStringifyWithFlattenedPaths } from '../utils'; import { BaseModal } from './base_modal'; -import { IndividualWowheadGearPlannerImporter } from './importers'; +import { IndividualLinkImporter, IndividualWowheadGearPlannerImporter } from './importers'; import { RaidSimRequest } from '../proto/api'; +import { SimSettingCategories } from '../sim'; +import { EventID, TypedEvent } from '../typed_event'; +import { BooleanPicker } from './boolean_picker'; import * as Mechanics from '../constants/mechanics'; +declare var pako: any; + +interface ExporterOptions { + title: string, + header?: boolean, + allowDownload?: boolean, +} + export abstract class Exporter extends BaseModal { private readonly textElem: HTMLElement; + protected readonly changedEvent: TypedEvent = new TypedEvent(); - constructor(parent: HTMLElement, simUI: SimUI, title: string, allowDownload: boolean) { - super(parent, 'exporter', { title: title, footer: true }); + constructor(parent: HTMLElement, simUI: SimUI, options: ExporterOptions) { + super(parent, 'exporter', { title: options.title, header: options.header, footer: true }); this.body.innerHTML = ` @@ -30,7 +42,7 @@ export abstract class Exporter extends BaseModal { Copy to Clipboard - ${allowDownload ? ` + ${options.allowDownload ? `