diff --git a/src/layout/card/grid/NitroCardGridView.scss b/src/layout/card/grid/NitroCardGridView.scss index e424066a..a924d2ce 100644 --- a/src/layout/card/grid/NitroCardGridView.scss +++ b/src/layout/card/grid/NitroCardGridView.scss @@ -1,4 +1,5 @@ .nitro-card-grid { + width: 100%; .row-cols-3 { diff --git a/src/layout/card/grid/item/NitroCardGridItemView.tsx b/src/layout/card/grid/item/NitroCardGridItemView.tsx index 445851e1..a1e4b253 100644 --- a/src/layout/card/grid/item/NitroCardGridItemView.tsx +++ b/src/layout/card/grid/item/NitroCardGridItemView.tsx @@ -6,13 +6,13 @@ import { NitroCardGridItemViewProps } from './NitroCardGridItemView.types'; export const NitroCardGridItemView: FC = props => { - const { itemImage = undefined, itemColor = undefined, itemActive = false, itemCount = 1, itemUnique = false, itemUniqueNumber = 0, itemUnseen = false, className = '', style = {}, children = null, ...rest } = props; + const { itemImage = undefined, itemColor = undefined, itemActive = false, itemCount = 1, itemUnique = false, itemUniqueNumber = 0, itemUnseen = false, columns = undefined, className = '', style = {}, children = null, ...rest } = props; const { theme = NitroCardGridThemes.THEME_DEFAULT } = useNitroCardGridContext(); const imageUrl = `url(${ itemImage })`; return ( -
+
{ (itemCount > 1) && { itemCount } } diff --git a/src/layout/card/grid/item/NitroCardGridItemView.types.ts b/src/layout/card/grid/item/NitroCardGridItemView.types.ts index 52e0242c..bf005811 100644 --- a/src/layout/card/grid/item/NitroCardGridItemView.types.ts +++ b/src/layout/card/grid/item/NitroCardGridItemView.types.ts @@ -9,4 +9,5 @@ export interface NitroCardGridItemViewProps extends DetailsHTMLAttributes = props => { @@ -29,6 +31,8 @@ export const AvatarEditorView: FC = props => const [ activeCategory, setActiveCategory ] = useState(null); const [ figureSetIds, setFigureSetIds ] = useState([]); const [ boundFurnitureNames, setBoundFurnitureNames ] = useState([]); + const [ savedFigures, setSavedFigures ] = useState<[ string, string ][]>(new Array(MAX_SAVED_FIGURES)); + const [ isWardrobeVisible, setIsWardrobeVisible ] = useState(false); const [ lastFigure, setLastFigure ] = useState(null); const [ lastGender, setLastGender ] = useState(null); const [ needsReset, setNeedsReset ] = useState(false); @@ -62,6 +66,32 @@ export const AvatarEditorView: FC = props => useUiEvent(AvatarEditorEvent.HIDE_EDITOR, onAvatarEditorEvent); useUiEvent(AvatarEditorEvent.TOGGLE_EDITOR, onAvatarEditorEvent); + const onFigureSetIdsMessageEvent = useCallback((event: FigureSetIdsMessageEvent) => + { + const parser = event.getParser(); + + setFigureSetIds(parser.figureSetIds); + setBoundFurnitureNames(parser.boundsFurnitureNames); + }, []); + + CreateMessageHook(FigureSetIdsMessageEvent, onFigureSetIdsMessageEvent); + + const onUserWardrobePageEvent = useCallback((event: UserWardrobePageEvent) => + { + const parser = event.getParser(); + + const savedFigures: [ string, string ][] = new Array(MAX_SAVED_FIGURES); + + for(const value of parser.looks.values()) + { + console.log(value); + } + + setSavedFigures(savedFigures) + }, []); + + CreateMessageHook(UserWardrobePageEvent, onUserWardrobePageEvent); + const selectCategory = useCallback((name: string) => { if(!categories) return; @@ -157,17 +187,20 @@ export const AvatarEditorView: FC = props => setFigureData(figures.get(gender)); }, [ figures ]); - const onFigureSetIdsMessageEvent = useCallback((event: FigureSetIdsMessageEvent) => + useEffect(() => { - const parser = event.getParser(); + if(!isWardrobeVisible) return; - setFigureSetIds(parser.figureSetIds); - setBoundFurnitureNames(parser.boundsFurnitureNames); + setActiveCategory(null); + SendMessageHook(new UserWardrobePageComposer()); + }, [ isWardrobeVisible ]); - resetCategories(); - }, [ resetCategories ]); + useEffect(() => + { + if(!activeCategory) return; - CreateMessageHook(FigureSetIdsMessageEvent, onFigureSetIdsMessageEvent); + setIsWardrobeVisible(false); + }, [ activeCategory ]); useEffect(() => { @@ -192,12 +225,14 @@ export const AvatarEditorView: FC = props => AvatarEditorUtilities.FIGURE_SET_IDS = figureSetIds; AvatarEditorUtilities.BOUND_FURNITURE_NAMES = boundFurnitureNames; + resetCategories(); + return () => { AvatarEditorUtilities.FIGURE_SET_IDS = null; AvatarEditorUtilities.BOUND_FURNITURE_NAMES = null; } - }, [ figureSetIds, boundFurnitureNames ]); + }, [ figureSetIds, boundFurnitureNames, resetCategories ]); useEffect(() => { @@ -227,19 +262,25 @@ export const AvatarEditorView: FC = props => setIsVisible(false) } /> - { categories && (categories.size > 0) && activeCategory && Array.from(categories.keys()).map(category => + { categories && (categories.size > 0) && Array.from(categories.keys()).map(category => { + const isActive = (activeCategory && (activeCategory.name === category)); + return ( - selectCategory(category) }> + selectCategory(category) }> { LocalizeText(`avatareditor.category.${ category }`) } ); })} + setIsWardrobeVisible(true) }> + { LocalizeText(`avatareditor.category.wardrobe`) } +
- { activeCategory && } + { (activeCategory && !isWardrobeVisible) && } + { isWardrobeVisible && }
diff --git a/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx b/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx new file mode 100644 index 00000000..31a45db8 --- /dev/null +++ b/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.tsx @@ -0,0 +1,56 @@ +import { FC, useMemo } from 'react'; +import { NitroCardGridItemView } from '../../../../layout/card/grid/item/NitroCardGridItemView'; +import { NitroCardGridView } from '../../../../layout/card/grid/NitroCardGridView'; +import { NitroCardGridThemes } from '../../../../layout/card/grid/NitroCardGridView.types'; +import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; +import { AvatarEditorWardrobeViewProps } from './AvatarEditorWardrobeView.types'; + +export const AvatarEditorWardrobeView: FC = props => +{ + const { figures = [] } = props; + + const savedFigures = useMemo(() => + { + if(!figures) return []; + + let i = 0; + + const items: JSX.Element[] = []; + + while(i < figures.length) + { + const figure = figures[i]; + + let figureString = null; + let gender = null; + + if(figure) + { + figureString = (figure[0] || null); + gender = (figure[1] || null); + } + + items.push( + + + + ); + + i++ + } + + return items; + }, [ figures ]); + + console.log(figures.length); + + return ( +
+
+ + { savedFigures } + +
+
+ ); +} diff --git a/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.types.ts b/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.types.ts new file mode 100644 index 00000000..a6d5c978 --- /dev/null +++ b/src/views/avatar-editor/views/wardrobe/AvatarEditorWardrobeView.types.ts @@ -0,0 +1,4 @@ +export interface AvatarEditorWardrobeViewProps +{ + figures: [ string, string ][]; +}