mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-26 15:40:51 +01:00
Add max wardrobe slots to config
This commit is contained in:
parent
a84a641ba7
commit
268509a107
@ -8,6 +8,7 @@
|
|||||||
"habbopages.url": "https://website.com/habbopages/",
|
"habbopages.url": "https://website.com/habbopages/",
|
||||||
"chat.viewer.height.percentage": 0.40,
|
"chat.viewer.height.percentage": 0.40,
|
||||||
"widget.dimmer.colorwheel": false,
|
"widget.dimmer.colorwheel": false,
|
||||||
|
"avatar.wardrobe.max.slots": 10,
|
||||||
"hotelview": {
|
"hotelview": {
|
||||||
"widgets": {
|
"widgets": {
|
||||||
"slot.1.widget": "promoarticle",
|
"slot.1.widget": "promoarticle",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
import { AvatarEditorFigureCategory, FigureSetIdsMessageEvent, GetWardrobeMessageComposer, IAvatarFigureContainer, UserFigureComposer, UserWardrobePageEvent } from '@nitrots/nitro-renderer';
|
import { AvatarEditorFigureCategory, FigureSetIdsMessageEvent, GetWardrobeMessageComposer, IAvatarFigureContainer, UserFigureComposer, UserWardrobePageEvent } from '@nitrots/nitro-renderer';
|
||||||
import { FC, useCallback, useEffect, useState } from 'react';
|
import { FC, useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { GetAvatarRenderManager, GetClubMemberLevel, GetSessionDataManager, LocalizeText } from '../../api';
|
import { GetAvatarRenderManager, GetClubMemberLevel, GetConfiguration, GetSessionDataManager, LocalizeText } from '../../api';
|
||||||
import { Button } from '../../common/Button';
|
import { Button } from '../../common/Button';
|
||||||
import { ButtonGroup } from '../../common/ButtonGroup';
|
import { ButtonGroup } from '../../common/ButtonGroup';
|
||||||
import { Column } from '../../common/Column';
|
import { Column } from '../../common/Column';
|
||||||
@ -25,7 +25,6 @@ import { AvatarEditorWardrobeView } from './views/wardrobe/AvatarEditorWardrobeV
|
|||||||
|
|
||||||
const DEFAULT_MALE_FIGURE: string = 'hr-100.hd-180-7.ch-215-66.lg-270-79.sh-305-62.ha-1002-70.wa-2007';
|
const DEFAULT_MALE_FIGURE: string = 'hr-100.hd-180-7.ch-215-66.lg-270-79.sh-305-62.ha-1002-70.wa-2007';
|
||||||
const DEFAULT_FEMALE_FIGURE: string = 'hr-515-33.hd-600-1.ch-635-70.lg-716-66-62.sh-735-68';
|
const DEFAULT_FEMALE_FIGURE: string = 'hr-515-33.hd-600-1.ch-635-70.lg-716-66-62.sh-735-68';
|
||||||
const MAX_SAVED_FIGURES: number = 10;
|
|
||||||
|
|
||||||
export const AvatarEditorView: FC<{}> = props =>
|
export const AvatarEditorView: FC<{}> = props =>
|
||||||
{
|
{
|
||||||
@ -36,13 +35,15 @@ export const AvatarEditorView: FC<{}> = props =>
|
|||||||
const [ activeCategory, setActiveCategory ] = useState<IAvatarEditorCategoryModel>(null);
|
const [ activeCategory, setActiveCategory ] = useState<IAvatarEditorCategoryModel>(null);
|
||||||
const [ figureSetIds, setFigureSetIds ] = useState<number[]>([]);
|
const [ figureSetIds, setFigureSetIds ] = useState<number[]>([]);
|
||||||
const [ boundFurnitureNames, setBoundFurnitureNames ] = useState<string[]>([]);
|
const [ boundFurnitureNames, setBoundFurnitureNames ] = useState<string[]>([]);
|
||||||
const [ savedFigures, setSavedFigures ] = useState<[ IAvatarFigureContainer, string ][]>(new Array(MAX_SAVED_FIGURES));
|
const [ savedFigures, setSavedFigures ] = useState<[ IAvatarFigureContainer, string ][]>([]);
|
||||||
const [ isWardrobeVisible, setIsWardrobeVisible ] = useState(false);
|
const [ isWardrobeVisible, setIsWardrobeVisible ] = useState(false);
|
||||||
const [ lastFigure, setLastFigure ] = useState<string>(null);
|
const [ lastFigure, setLastFigure ] = useState<string>(null);
|
||||||
const [ lastGender, setLastGender ] = useState<string>(null);
|
const [ lastGender, setLastGender ] = useState<string>(null);
|
||||||
const [ needsReset, setNeedsReset ] = useState(false);
|
const [ needsReset, setNeedsReset ] = useState(false);
|
||||||
const [ isInitalized, setIsInitalized ] = useState(false);
|
const [ isInitalized, setIsInitalized ] = useState(false);
|
||||||
|
|
||||||
|
const maxWardrobeSlots = useMemo(() => GetConfiguration<number>('avatar.wardrobe.max.slots', 10), []);
|
||||||
|
|
||||||
const onAvatarEditorEvent = useCallback((event: AvatarEditorEvent) =>
|
const onAvatarEditorEvent = useCallback((event: AvatarEditorEvent) =>
|
||||||
{
|
{
|
||||||
switch(event.type)
|
switch(event.type)
|
||||||
@ -88,7 +89,7 @@ export const AvatarEditorView: FC<{}> = props =>
|
|||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
while(i < MAX_SAVED_FIGURES)
|
while(i < maxWardrobeSlots)
|
||||||
{
|
{
|
||||||
savedFigures.push([ null, null ]);
|
savedFigures.push([ null, null ]);
|
||||||
|
|
||||||
@ -103,7 +104,7 @@ export const AvatarEditorView: FC<{}> = props =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
setSavedFigures(savedFigures)
|
setSavedFigures(savedFigures)
|
||||||
}, []);
|
}, [ maxWardrobeSlots ]);
|
||||||
|
|
||||||
CreateMessageHook(UserWardrobePageEvent, onUserWardrobePageEvent);
|
CreateMessageHook(UserWardrobePageEvent, onUserWardrobePageEvent);
|
||||||
|
|
||||||
@ -194,6 +195,11 @@ export const AvatarEditorView: FC<{}> = props =>
|
|||||||
setFigureData(figures.get(gender));
|
setFigureData(figures.get(gender));
|
||||||
}, [ figures ]);
|
}, [ figures ]);
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
setSavedFigures(new Array(maxWardrobeSlots));
|
||||||
|
}, [ maxWardrobeSlots ]);
|
||||||
|
|
||||||
useEffect(() =>
|
useEffect(() =>
|
||||||
{
|
{
|
||||||
if(!isWardrobeVisible) return;
|
if(!isWardrobeVisible) return;
|
||||||
|
Loading…
Reference in New Issue
Block a user