diff --git a/src/assets/styles/bootstrap/_variables.scss b/src/assets/styles/bootstrap/_variables.scss index 1d1de900..b2592966 100644 --- a/src/assets/styles/bootstrap/_variables.scss +++ b/src/assets/styles/bootstrap/_variables.scss @@ -80,7 +80,8 @@ $cello-light: #21516e !default; $cello-dark: #1e465e !default; $pale-sky: #677181 !default; $oslo-gray: #8F9297 !default; - +$ghost: #c8cad0 !default; +$gray-chateau: #a3a7b1 !default; $success: $green !default; $info: $cyan !default; $warning: $yellow !default; diff --git a/src/layout/card/grid/item/NitroCardGridItemView.scss b/src/layout/card/grid/item/NitroCardGridItemView.scss index 69de83c1..b2959864 100644 --- a/src/layout/card/grid/item/NitroCardGridItemView.scss +++ b/src/layout/card/grid/item/NitroCardGridItemView.scss @@ -64,11 +64,9 @@ } .avatar-image { - width: 100% !important; - height: 100% !important; background-position: center; background-repeat: no-repeat; - background-position-y: -32px !important; + background-position-y: 12px !important; } .trade-button { diff --git a/src/views/avatar-editor/AvatarEditorView.scss b/src/views/avatar-editor/AvatarEditorView.scss index c17999bb..8c2f6b0d 100644 --- a/src/views/avatar-editor/AvatarEditorView.scss +++ b/src/views/avatar-editor/AvatarEditorView.scss @@ -83,8 +83,36 @@ .wardrobe-grid { .grid-item-container { - height: 100% !important; - max-height: 100% !important; + height: 142px !important; + max-height: 142px !important; + + .grid-item { + background-color: $ghost; + + .avatar-image { + position: absolute; + bottom: 0; + background-position-y: -23px !important; + z-index: 3; + } + + .figure-button-container { + background-color: $gray-chateau; + z-index: 2; + } + + &:after { + position: absolute; + content: ''; + height: 50%; + bottom: 0; + left: 0; + right: 0; + background-color: $gray-chateau; + box-shadow: 0 0 8px 2px rgba($white,.6); + z-index: 1; + } + } } } } diff --git a/src/views/avatar-editor/AvatarEditorView.tsx b/src/views/avatar-editor/AvatarEditorView.tsx index 378d53e4..1caa8729 100644 --- a/src/views/avatar-editor/AvatarEditorView.tsx +++ b/src/views/avatar-editor/AvatarEditorView.tsx @@ -79,14 +79,25 @@ export const AvatarEditorView: FC = props => const onUserWardrobePageEvent = useCallback((event: UserWardrobePageEvent) => { const parser = event.getParser(); + const savedFigures: [ string, string ][] = []; - const savedFigures: [ string, string ][] = new Array(MAX_SAVED_FIGURES); + let i = 0; - for(const value of parser.looks.values()) + while(i < MAX_SAVED_FIGURES) { - console.log(value); + savedFigures.push([ null, null ]); + + i++; } + for(let [ index, value ] of parser.looks.entries()) + { + console.log(index, value); + savedFigures[(index - 1)] = [ value[0], value[1] ]; + } + + console.log(savedFigures); + setSavedFigures(savedFigures) }, []); @@ -280,7 +291,7 @@ export const AvatarEditorView: FC = props =>
{ (activeCategory && !isWardrobeVisible) && } - { isWardrobeVisible && } + { isWardrobeVisible && }
diff --git a/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx b/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx index 31a45db8..d33a9d2e 100644 --- a/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx +++ b/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx @@ -1,4 +1,7 @@ -import { FC, useMemo } from 'react'; +import { UserWardrobeSaveComposer } from 'nitro-renderer'; +import { FC, useCallback, useMemo } from 'react'; +import { Button } from 'react-bootstrap'; +import { SendMessageHook } from '../../../../hooks'; import { NitroCardGridItemView } from '../../../../layout/card/grid/item/NitroCardGridItemView'; import { NitroCardGridView } from '../../../../layout/card/grid/NitroCardGridView'; import { NitroCardGridThemes } from '../../../../layout/card/grid/NitroCardGridView.types'; @@ -7,48 +10,68 @@ import { AvatarEditorWardrobeViewProps } from './AvatarEditorWardrobeView.types' export const AvatarEditorWardrobeView: FC = props => { - const { figures = [] } = props; + const { figureData = null, savedFigures = [], setSavedFigures = null, loadAvatarInEditor = null } = props; - const savedFigures = useMemo(() => + const wearFigureAtIndex = useCallback((index: number) => { - if(!figures) return []; + if((index >= savedFigures.length) || (index < 0)) return; - let i = 0; + const [ figure, gender ] = savedFigures[index]; + + loadAvatarInEditor(figure, gender); + }, [ savedFigures, loadAvatarInEditor ]); + + const saveFigureAtWardrobeIndex = useCallback((index: number) => + { + if(!figureData || (index >= savedFigures.length) || (index < 0)) return; + + const newFigures = [ ...savedFigures ]; + + const figure = figureData.getFigureString(); + const gender = figureData.gender; + + newFigures[index] = [ figure, gender ]; + + setSavedFigures(newFigures); + SendMessageHook(new UserWardrobeSaveComposer((index + 1), figure, gender)); + }, [ figureData, savedFigures, setSavedFigures ]); + + const figures = useMemo(() => + { + if(!savedFigures) return []; const items: JSX.Element[] = []; - while(i < figures.length) - { - const figure = figures[i]; - - let figureString = null; - let gender = null; - - if(figure) + savedFigures.forEach((figure, index) => { - figureString = (figure[0] || null); - gender = (figure[1] || null); - } + let figureString = null; + let gender = null; - items.push( - - - - ); - - i++ - } + if(figure) + { + figureString = (figure[0] || null); + gender = (figure[1] || null); + } + + items.push( + + { figureString && } +
+ + { figureString && } +
+
+ ); + }); return items; - }, [ figures ]); - - console.log(figures.length); + }, [ savedFigures, saveFigureAtWardrobeIndex, wearFigureAtIndex ]); return (
- - { savedFigures } + + { figures }
diff --git a/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.types.ts b/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.types.ts index a6d5c978..2311c58e 100644 --- a/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.types.ts +++ b/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.types.ts @@ -1,4 +1,10 @@ +import { Dispatch, SetStateAction } from 'react'; +import { FigureData } from '../../common/FigureData'; + export interface AvatarEditorWardrobeViewProps { - figures: [ string, string ][]; + figureData: FigureData; + savedFigures: [ string, string ][]; + setSavedFigures: Dispatch>; + loadAvatarInEditor: (figure: string, gender: string, reset?: boolean) => void; }