From 2b9a2720bcd926e0653b479ca10c4c33901f6135 Mon Sep 17 00:00:00 2001 From: Walidoux Date: Thu, 4 May 2023 16:16:00 +0100 Subject: [PATCH] refactor(all-in-one): Organize DomainTypes into Flag objects and change type in handleConvertion - Refactored DomainTypes to a list of Flag objects for better organization - Changed the domain parameter type in handleConvertion from DomainTypes to string, to remove unnecessary coupling from code. --- .../design/AnimateView/AnimateView.tsx | 7 +-- src/components/design/index.ts | 1 + src/config/Domain.ts | 24 +++++----- src/controllers/FurniData.ts | 48 ------------------- src/controllers/index.ts | 4 -- src/tools/handleConvertion.ts | 3 +- src/types/Converters.d.ts | 14 +----- src/types/SubConverters.d.ts | 30 ------------ 8 files changed, 17 insertions(+), 114 deletions(-) delete mode 100644 src/controllers/FurniData.ts delete mode 100644 src/controllers/index.ts diff --git a/src/components/design/AnimateView/AnimateView.tsx b/src/components/design/AnimateView/AnimateView.tsx index af23c34..81c84ee 100644 --- a/src/components/design/AnimateView/AnimateView.tsx +++ b/src/components/design/AnimateView/AnimateView.tsx @@ -1,18 +1,15 @@ -import { Show, createEffect } from 'solid-js' +import { Show } from 'solid-js' import type { Component } from 'solid-js' import type { MotionComponentProps, Variant } from '@motionone/solid' import { Motion, Presence } from '@motionone/solid' export interface AnimateViewProps extends MotionComponentProps { - animation: Record + animation?: Record condition: boolean class?: string } export const AnimateView: Component = (props) => { - createEffect(() => { - console.log(props.condition) - }) return ( diff --git a/src/components/design/index.ts b/src/components/design/index.ts index 79ae0f4..73c659c 100644 --- a/src/components/design/index.ts +++ b/src/components/design/index.ts @@ -2,3 +2,4 @@ export * from './Loader' export * from './AnimateView' export * from './Image' export * from './Button' +export * from './Flag' diff --git a/src/config/Domain.ts b/src/config/Domain.ts index 8c9364c..ab84879 100644 --- a/src/config/Domain.ts +++ b/src/config/Domain.ts @@ -1,13 +1,13 @@ -export enum DomainTypes { - Portuguese = 'com.br', - Turkish = 'com.tr', - English = 'com', - German = 'de', - Spanish = 'es', - Finnish = 'fi', - French = 'fr', - Italian = 'it', - Dutch = 'nl' -} +// ISO 3166-1-alpha-2 Flags -export const SUPPORTED_LANGS = Object.keys(DomainTypes) +export const SUPPORTED_LANGS = [ + { name: 'Portuguese', code: 'br', domain: 'com.br' }, + { name: 'Turkish', code: 'tr', domain: 'com.tr' }, + { name: 'English', code: 'us', domain: 'com' }, + { name: 'German', code: 'de', domain: 'de' }, + { name: 'Spanish', code: 'es', domain: 'es' }, + { name: 'Finnish', code: 'fi', domain: 'fi' }, + { name: 'French', code: 'fr', domain: 'fr' }, + { name: 'Italian', code: 'it', domain: 'it' }, + { name: 'Dutch', code: 'nl', domain: 'nl' } +] diff --git a/src/controllers/FurniData.ts b/src/controllers/FurniData.ts deleted file mode 100644 index a9ca5ed..0000000 --- a/src/controllers/FurniData.ts +++ /dev/null @@ -1,48 +0,0 @@ -import type { IFurni, IFurniData, IXML, KeyValuePairs } from '../types' - -export class FurniData { - public data: IFurniData = { floorItems: [], wallItems: [] } - public fileName: string - - constructor(data: IXML, fileName: string) { - this.fileName = fileName - - this.parseRoomItemTypes(data.roomitemtypes.furnitype) - this.parseWallItemTypes(data.roomitemtypes.furnitype) - } - - private parseRoomItemTypes(roomItems: IFurni[]): void { - for (const roomItem of roomItems) { - this.data.floorItems.push(roomItem) - } - } - - private parseWallItemTypes(wallItems: IFurni[]): void { - for (const wallItem of wallItems) { - this.data.wallItems.push(wallItem) - } - } - - private getClassNameRevision(itemType: IFurni): { className: string; revision: number } { - const className = itemType.classname.split('*')[0] - const revision = itemType.revision - - return { className, revision } - } - - public get classNamesAndRevisions(): KeyValuePairs { - const entries: KeyValuePairs = {} - - for (const roomItem of this.data.floorItems) { - const { className, revision } = this.getClassNameRevision(roomItem) - entries[className] = String(revision) - } - - for (const wallItem of this.data.wallItems) { - const { className, revision } = this.getClassNameRevision(wallItem) - entries[className] = String(revision) - } - - return entries - } -} diff --git a/src/controllers/index.ts b/src/controllers/index.ts deleted file mode 100644 index b92fd54..0000000 --- a/src/controllers/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './EffectMap' -export * from './FigureMap' -export * from './FigureData' -export * from './FurniData' diff --git a/src/tools/handleConvertion.ts b/src/tools/handleConvertion.ts index cf2f8e3..47b941c 100644 --- a/src/tools/handleConvertion.ts +++ b/src/tools/handleConvertion.ts @@ -2,13 +2,12 @@ import { ResponseType } from '@tauri-apps/api/http' import { GAMEDATA_ENDPOINTS, client } from '../config/Endpoints' import type { ConvertionHandler } from '../types' -import type { DomainTypes } from '../config/Domain' import { parseData } from './parseData' import { Convertion } from '../config/Convertion' import { downloadGamedata } from './rusty' export const handleConvertion = async ( - domain: DomainTypes, + domain: string, callback: ConvertionHandler, assetsOption = false ): Promise => { diff --git a/src/types/Converters.d.ts b/src/types/Converters.d.ts index bafba24..908996b 100644 --- a/src/types/Converters.d.ts +++ b/src/types/Converters.d.ts @@ -1,11 +1,4 @@ -import type { - IFigureDataPalette, - IFigureDataSetType, - IFigureMapLibrary, - IFloorItem, - IFurni, - IProduct -} from './SubConverters' +import type { IFigureDataPalette, IFigureDataSetType, IFigureMapLibrary, IProduct } from './SubConverters' export interface IFigureData { palettes: IFigureDataPalette[] @@ -17,11 +10,6 @@ export interface IFigureMap { parts: Record> } -export interface IFurniData { - floorItems: IFloorItem[] - wallItems: IFurni[] -} - export type IEffectMap = Record> export interface IProductData { diff --git a/src/types/SubConverters.d.ts b/src/types/SubConverters.d.ts index 3c8d7a7..6f08efc 100644 --- a/src/types/SubConverters.d.ts +++ b/src/types/SubConverters.d.ts @@ -1,33 +1,3 @@ -export interface IFloorItemDimensions { - x: number - y: number - defaultDirection: number -} - -export interface IFloorItemPermissions { - canSitOn: boolean - canLayOn: boolean - canStandOn: boolean -} - -export interface IFloorItem extends IFurni { - dimensions: IFloorItemDimensions - permissions: IFloorItemPermissions -} - -export interface IFurni { - id: number - classname: string - description?: string - name?: string - furniLine?: string - customParams?: string - adurl?: string - offerID?: number - excludeDynamic: boolean - specialType: number -} - export type Club = 'idle' | 'HC' | 'VIP' export interface IFigureDataPaletteType {