diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx deleted file mode 100644 index 57d79ae..0000000 --- a/src/components/Button/Button.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import classNames from 'classnames' - -interface ButtonProps extends React.ComponentPropsWithoutRef<'button'> { - icon: JSX.Element - value: string - className?: string - handler?: () => void -} - -export const Button: React.FC = ({ - icon, - value, - className, - handler -}) => { - return ( - - ) -} diff --git a/src/components/Button/index.ts b/src/components/Button/index.ts deleted file mode 100644 index 8486fd6..0000000 --- a/src/components/Button/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Button' diff --git a/src/components/Downloader/Downloader.tsx b/src/components/Downloader/Downloader.tsx deleted file mode 100644 index 495ad70..0000000 --- a/src/components/Downloader/Downloader.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import classNames from 'classnames' -import { AnimatePresence, motion } from 'framer-motion' -import { useState } from 'react' - -export interface IDownloaderContent { - title: string - features: string[] -} - -interface DownloaderProps { - className?: string - children: React.ReactNode - content: IDownloaderContent -} - -export const Downloader: React.FC = ({ - className, - children, - content -}) => { - const [activeContent, setActiveContent] = useState(false) - - const handleActiveContent = (): void => { - return setActiveContent(!activeContent) - } - - return ( -
  • - {children} - - - {activeContent && ( - - - {content.title} - - - {content.features.map((feature) => { - return ( - - {feature} - - ) - })} - - )} - -
  • - ) -} diff --git a/src/components/Downloader/index.ts b/src/components/Downloader/index.ts deleted file mode 100644 index 8a00690..0000000 --- a/src/components/Downloader/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Downloader' diff --git a/src/components/Image/Image.tsx b/src/components/Image/Image.tsx deleted file mode 100644 index bb068a1..0000000 --- a/src/components/Image/Image.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import classNames from 'classnames' - -interface ImageProps extends React.ComponentPropsWithoutRef<'img'> { - size?: number - icon?: boolean -} - -export const Image: React.FC = ({ size, icon, ...rest }) => { - return ( - - ) -} diff --git a/src/components/Image/index.ts b/src/components/Image/index.ts deleted file mode 100644 index 072b161..0000000 --- a/src/components/Image/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Image' diff --git a/src/components/TitleBar/TitleBar.tsx b/src/components/TitleBar/TitleBar.tsx deleted file mode 100644 index cb76b73..0000000 --- a/src/components/TitleBar/TitleBar.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { Maximize, Minus, X } from 'react-feather' -import { appWindow } from '@tauri-apps/api/window' - -import { Image } from '../Image' - -export const TitleBar: React.FC = () => { - return ( - - ) -} diff --git a/src/components/TitleBar/index.ts b/src/components/TitleBar/index.ts deleted file mode 100644 index 259755c..0000000 --- a/src/components/TitleBar/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './TitleBar' diff --git a/src/components/Window/Window.tsx b/src/components/Window/Window.tsx deleted file mode 100644 index 446e450..0000000 --- a/src/components/Window/Window.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { Fragment } from 'react' - -import { TitleBar } from '../TitleBar/TitleBar' - -interface WindowProps { - children: React.ReactNode -} - -export const Window: React.FC = ({ children }) => { - return ( - - - -
    - {children} -
    -
    - ) -} diff --git a/src/components/Window/index.ts b/src/components/Window/index.ts deleted file mode 100644 index 4645aaa..0000000 --- a/src/components/Window/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Window' diff --git a/src/components/index.ts b/src/components/index.ts deleted file mode 100644 index 1bf9d29..0000000 --- a/src/components/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './Window' -export * from './Image' -export * from './Button' -export * from './Downloader' diff --git a/src/config/ENDPOINTS.ts b/src/config/ENDPOINTS.ts deleted file mode 100644 index 373d148..0000000 --- a/src/config/ENDPOINTS.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { getClient, ResponseType } from '@tauri-apps/api/http' - -import type { DomainTypes, GameEndPointsTypes } from '../types' - -const PROD_VERSION_REGEX = /(production-[^/]+)/im -const STABLE_PROD_VERSION = 'PRODUCTION-202303282207-162719871' - -export let PROD_VERSION: string | undefined - -const HABBO_URL = (domain: DomainTypes): string => { - return `https://www.habbo.${domain}` -} - -const HABBO_IMAGES = `https://images.habbo.com/gordon/${ - PROD_VERSION ?? STABLE_PROD_VERSION -}` - -export const client = await getClient() -await client - .get(`${HABBO_URL('com')}/gamedata/external_variables/0`, { - responseType: ResponseType.Text - }) - .then(({ data }) => { - return (PROD_VERSION = (data as string).match(PROD_VERSION_REGEX)?.[0]) - }) - -export const GAME_ENDPOINTS = (domain: DomainTypes): GameEndPointsTypes => { - return [ - { - src: `${HABBO_URL(domain)}/gamedata/figuredata/0`, - convert: 'XML', - fileName: 'FigureData' - }, - { - src: `${HABBO_IMAGES}/figuremap.xml`, - convert: 'XML', - fileName: 'FigureMap' - }, - { - src: `${HABBO_URL(domain)}/gamedata/furnidata_json/0`, - fileName: 'FurniData' - }, - { - src: `${HABBO_URL(domain)}/gamedata/productdata_json/0`, - fileName: 'ProductData' - }, - { - src: `${HABBO_IMAGES}/effectmap.xml`, - convert: 'XML', - fileName: 'EffectMap' - }, - { - src: `${HABBO_URL(domain)}/gamedata/external_flash_texts/0`, - convert: 'TXT', - fileName: 'ExternalTexts' - } - ] -} - -export const ASSETS_ENDPOINTS = (domain: DomainTypes): string[] => { - return [`${HABBO_URL(domain)}/`] -} diff --git a/src/mapping/convertTXT.ts b/src/mapping/convertTXT.ts deleted file mode 100644 index 692e868..0000000 --- a/src/mapping/convertTXT.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { parseData } from '../utils/parseData' - -interface IBadge { - code: string - name?: string - description?: string -} - -const badgePattern = /^badge_(?:name|desc)_([^=]+)/gim -const descriptionPattern = /^badge_desc_(\s*\w+)/ -const namePattern = /^badge_name_(\s*\w+)/ - -export const convertTXT = async (data: string): Promise => { - const badges: IBadge[] = [] - - const lines = data.split(/\r?\n/) - - for (const line of lines) { - const [key, value] = line.split('=') - const badge = key.match(badgePattern) - - if (badge != null) { - if (key.match(namePattern) != null) { - const badgeCode = key.match(namePattern)?.[1] as string - const existingBadge = badges.filter((badge) => { - return badge.code === badgeCode - })[0] - - if (Boolean(existingBadge)) { - const index = badges.indexOf(existingBadge) - badges[index].name = value - } else { - badges.push({ code: badgeCode, name: value }) - } - } else if (key.match(descriptionPattern) != null) { - const badgeCode = key.match(descriptionPattern)?.[1] as string - const existingBadge = badges.filter((badge) => { - return badge.code === badgeCode - })[0] - - if (Boolean(existingBadge)) { - const index = badges.indexOf(existingBadge) - badges[index].description = value - } else { - badges.push({ code: badgeCode, description: value }) - } - } - - lines.splice(lines.indexOf(line), 1) - } - } - - return await parseData('Badges', badges) -} diff --git a/src/mapping/convertXML.ts b/src/mapping/convertXML.ts deleted file mode 100644 index b736425..0000000 --- a/src/mapping/convertXML.ts +++ /dev/null @@ -1,194 +0,0 @@ -import type { - IEffectMap, - IEffectMapLibrary, - IFigureData, - IFigureDataColor, - IFigureDataHiddenLayer, - IFigureDataPalette, - IFigureDataPart, - IFigureDataSet, - IFigureDataSetType, - IFigureMap, - IFigureMapLibrary, - IFigureMapLibraryPart -} from '../types' - -export const convertXML = ( - XML: any, - url: string -): IFigureData | IFigureMap | IEffectMap => { - if (url.includes('figuredata')) { - const output: IFigureData = { palettes: [], setTypes: [] } - - for (const paletteXML of XML.figuredata.colors.palette) { - const palette: IFigureDataPalette = { id: 0, color: [] } - - if (paletteXML.id !== undefined) palette.id = paletteXML.id - - if (paletteXML.color !== undefined) { - for (const colorXML of paletteXML.color) { - const color: IFigureDataColor = { - id: 0, - index: 0, - club: 0, - selectable: false, - hexCode: '' - } - - const hexColor = String(colorXML['#text' as keyof IFigureDataColor]) - - if (colorXML.id !== undefined) color.id = colorXML.id - if (colorXML.index !== undefined) color.index = colorXML.index - if (colorXML.club !== undefined) color.club = colorXML.club - if (colorXML.selectable !== undefined) - color.selectable = colorXML.selectable === 0 ? true : false - if (hexColor !== undefined) color.hexCode = hexColor - - palette.color.push(color) - } - } - - output.palettes.push(palette) - } - - for (const setTypeXML of XML.figuredata.sets.settype) { - const settype: IFigureDataSetType = { - type: '', - paletteId: 0, - mandatoryF0: false, - mandatoryF1: false, - mandatoryM0: false, - mandatoryM1: false, - sets: [] - } - - if (setTypeXML.type !== undefined) settype.type = setTypeXML.type - if (setTypeXML.paletteId !== undefined) - settype.paletteId = setTypeXML.paletteId - if (setTypeXML.mandatoryF0 !== undefined) - settype.mandatoryF0 = setTypeXML.mandatoryF0 - if (setTypeXML.mandatoryF1 !== undefined) - settype.mandatoryF1 = setTypeXML.mandatoryF1 - if (setTypeXML.mandatoryM0 !== undefined) - settype.mandatoryM0 = setTypeXML.mandatoryM0 - if (setTypeXML.mandatoryM1 !== undefined) - settype.mandatoryM1 = setTypeXML.mandatoryM1 - - if (setTypeXML.sets !== undefined) { - for (const setXML of setTypeXML.sets) { - const setType: IFigureDataSet = { - id: 0, - gender: 'U', - club: 0, - colorable: false, - selectable: false, - preselectable: false, - sellable: false, - parts: [], - hiddenLayers: [] - } - - if (setXML.id !== undefined) setType.id = setXML.id - if (setXML.gender !== undefined) setType.gender = setXML.gender - if (setXML.club !== undefined) setType.club = setXML.club - if (setXML.colorable !== undefined) - setType.colorable = setXML.colorable === 0 ? true : false - if (setXML.selectable !== undefined) - setType.selectable = setXML.selectable - if (setXML.preselectable !== undefined) - setType.preselectable = setXML.preselectable - if (setXML.sellable !== undefined) setType.sellable = setXML.sellable - - if (setXML.parts !== undefined) { - for (const partXML of setXML.parts) { - const part: IFigureDataPart = { - id: 0, - type: '', - colorable: false, - index: 0, - colorindex: 0 - } - - if (partXML.id !== undefined) part.id = partXML.id - if (partXML.type !== undefined) part.type = partXML.type - if (partXML.colorable !== undefined) - part.colorable = partXML.colorable - if (partXML.index !== undefined) part.index = partXML.index - if (partXML.colorindex !== undefined) - part.colorindex = partXML.colorindex - - setType.parts.push(part) - } - } - - if (setXML.hiddenLayers !== undefined) { - for (const hiddenLayerXML of setXML.hiddenLayers) { - const hiddenLayer: IFigureDataHiddenLayer = { partType: '' } - - if (hiddenLayerXML.partType !== undefined) - hiddenLayer.partType = hiddenLayerXML.partType - - setType.hiddenLayers?.push(hiddenLayer) - } - } - - settype.sets.push(setType) - } - } - - output.setTypes.push(setTypeXML) - } - - return output - } else if (url.includes('figuremap')) { - const output: IFigureMap = { libraries: [] } - - for (const libraryXML of XML.map.lib as IFigureMapLibrary[]) { - const library: IFigureMapLibrary = { id: '', revision: 0, part: [] } - - if (libraryXML.id !== undefined) library.id = libraryXML.id - if (libraryXML.revision !== undefined) - library.revision = libraryXML.revision - - if (Array.isArray(libraryXML.part)) { - for (const libraryPart of libraryXML.part) { - const libraryPartXML: IFigureMapLibraryPart = { id: 0, type: '' } - - if (libraryPart.id !== undefined) libraryPartXML.id = libraryPart.id - if (libraryPart.type !== undefined) - libraryPartXML.type = libraryPart.type - - library.part.push(libraryPartXML) - } - } else { - const libraryPart = libraryXML.part as unknown as IFigureMapLibraryPart - library.part.push({ id: libraryPart.id, type: libraryPart.type }) - } - - output.libraries.push(library) - } - - return output - } else { - const output: IEffectMap = { effects: [] } - - for (const libraryXML of XML.map.effect as IEffectMapLibrary[]) { - const library: IEffectMapLibrary = { - id: 0, - lib: '', - type: '', - revision: 0 - } - - if (libraryXML.id !== undefined) library.id = libraryXML.id - if (libraryXML.lib !== undefined) library.lib = libraryXML.lib - if (libraryXML.type !== undefined) library.type = libraryXML.type - if (libraryXML.revision !== undefined) - library.revision = libraryXML.revision - - output.effects.push(library) - } - - return output - } -} diff --git a/src/mapping/index.ts b/src/mapping/index.ts deleted file mode 100644 index 13fe652..0000000 --- a/src/mapping/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './convertXML' -export * from './convertTXT' diff --git a/src/types/SubConverters.d.ts b/src/types/SubConverters.d.ts index 1e5e392..2ecd1f3 100644 --- a/src/types/SubConverters.d.ts +++ b/src/types/SubConverters.d.ts @@ -2,35 +2,35 @@ export interface IFurni { id: number classname: string revision: number - category: string + category?: string defaultdir: number xdim: number ydim: number - partcolors: { color: string[] } - name: string - description: string - adurl: string - offerid: number + partcolors?: { color: string[] } + name?: string + description?: string + adurl?: string + offerid?: number buyout: boolean rentofferid: number rentbuyout: boolean bc: boolean excludeddynamic: boolean - customparams: string + customparams?: string specialtype: number canstandon: boolean cansiton: boolean canlayon: boolean - furniline: string - environment: string + furniline?: string + environment?: string rare: boolean } export interface IFigureDataColor { id: number index: number - club: number // must be changed, either 0, 1, 2 - selectable: boolean + club: number // must be changed to something, either 0, 1, 2 + selectable: boolean // has been changed to boolean, can be either 1, 0 hexCode: string } @@ -41,35 +41,31 @@ export interface IFigureDataPalette { export interface IFigureDataPart { id: number - type: string // must be changed - colorable: boolean // must be changed + type: string // must be changed (i guess) + colorable: boolean // has been changed to boolean, can be either 1, 0 index: number colorindex: number } -export interface IFigureDataHiddenLayer { - partType: string // must be changed -} - export interface IFigureDataSet { id: number - gender: 'M' | 'F' | 'U' - club: number // 0, 1, 2 - colorable: boolean // must be changed - selectable: boolean // must be changed - preselectable: boolean // must be changed - sellable?: boolean // must be changed + gender: 'M' | 'F' | 'U' // has been changed + club: number // must be changed to something, either 0, 1, 2 + colorable: boolean // has been changed to boolean, can be either 1, 0 + selectable: boolean // has been changed to boolean, can be either 1, 0 + preselectable: boolean // has been changed to boolean, can be either 1, 0 + sellable?: boolean // has been changed to boolean, can be either 1, 0, null parts: IFigureDataPart[] - hiddenLayers?: IFigureDataHiddenLayer[] + hiddenLayers: Array<{ partType: string }> // !! can be empty } export interface IFigureDataSetType { - type: string // must be changed + type: string // must be changed (i guess) paletteId: number - mandatoryF0: boolean // 0, 1 - mandatoryF1: boolean // 0, 1 - mandatoryM0: boolean // 0, 1 - mandatoryM1: boolean // 0, 1 + mandatoryF0: boolean // has been changed to boolean, can be either 1, 0 + mandatoryF1: boolean // has been changed to boolean, can be either 1, 0 + mandatoryM0: boolean // has been changed to boolean, can be either 1, 0 + mandatoryM1: boolean // has been changed to boolean, can be either 1, 0 sets: IFigureDataSet[] } @@ -87,7 +83,7 @@ export interface IFigureMapLibrary { export interface IEffectMapLibrary { id: number lib: string - type: string + type: string // dance || fx revision: number } diff --git a/src/utils/fetchGameData.ts b/src/utils/fetchGameData.ts deleted file mode 100644 index 858ac9f..0000000 --- a/src/utils/fetchGameData.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { ResponseType } from '@tauri-apps/api/http' -import { XMLParser } from 'fast-xml-parser' - -import { GAME_ENDPOINTS, client } from '../config/ENDPOINTS' -import type { DomainTypes } from '../types/Domain' -import { convertTXT, convertXML } from '../mapping' -import { parseData } from './parseData' - -export const fetchGameData = async ( - domain: DomainTypes, - callback: (message: string, error: boolean) => void, - assetsOption = false -): Promise => { - if (!assetsOption) { - await Promise.all( - GAME_ENDPOINTS(domain).map(async (endpoint) => { - await client - .get(endpoint.src, { responseType: ResponseType.Text }) - .then(async ({ data }) => { - const currentData = data as string - - switch (endpoint.convert) { - case 'XML': - const convertedData = new XMLParser({ - ignoreAttributes: false, - attributeNamePrefix: '' - }).parse(currentData) - - const XML2JSON = convertXML(convertedData, endpoint.src) - - return await parseData(endpoint.fileName, XML2JSON) - case 'TXT': - return await convertTXT(currentData) - - default: - return await parseData(endpoint.fileName, currentData) - } - }) - .catch((error) => { - console.error(error) - return callback(error, true) - }) - }) - ) - } else { - /* ASSETS_ENDPOINTS(domain).map((endpoint) => { - client.get() - }) */ - } -} diff --git a/src/utils/parseData.ts b/src/utils/parseData.ts deleted file mode 100644 index 50311bd..0000000 --- a/src/utils/parseData.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { downloadDir } from '@tauri-apps/api/path' -import { createDir, exists, writeTextFile } from '@tauri-apps/api/fs' - -import { PROD_VERSION } from '../config/ENDPOINTS' - -export const parseData = async ( - fileName: string, - fileContent: string | object -): Promise => { - const outputDir = (await downloadDir()).concat(String(PROD_VERSION)) - const fileDir = outputDir.concat(`/${fileName}.json`) - - if (!(await exists(outputDir))) await createDir(outputDir) - - await writeTextFile( - fileDir, - typeof fileContent === 'object' ? JSON.stringify(fileContent) : fileContent - ) -}