mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 23:46:19 +00:00
🆙 Init V3
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { FC } from 'react';
|
||||
import { LocalizeText } from '../../../../../api';
|
||||
import { Button, Column, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../../common';
|
||||
import { useRoom } from '../../../../../hooks';
|
||||
|
||||
interface EffectBoxConfirmViewProps
|
||||
{
|
||||
objectId: number;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export const EffectBoxConfirmView: FC<EffectBoxConfirmViewProps> = props =>
|
||||
{
|
||||
const { objectId = -1, onClose = null } = props;
|
||||
const { roomSession = null } = useRoom();
|
||||
|
||||
const useProduct = () =>
|
||||
{
|
||||
roomSession.useMultistateItem(objectId);
|
||||
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<NitroCardView className="nitro-use-product-confirmation">
|
||||
<NitroCardHeaderView headerText={ LocalizeText('effectbox.header.title') } onCloseClick={ onClose } />
|
||||
<NitroCardContentView center>
|
||||
<div className="flex gap-2">
|
||||
<Column justifyContent="between">
|
||||
<Text>{ LocalizeText('effectbox.header.description') }</Text>
|
||||
<div className="flex items-center justify-between">
|
||||
<Button variant="danger" onClick={ onClose }>{ LocalizeText('generic.cancel') }</Button>
|
||||
<Button variant="success" onClick={ useProduct }>{ LocalizeText('generic.ok') }</Button>
|
||||
</div>
|
||||
</Column>
|
||||
</div>
|
||||
</NitroCardContentView>
|
||||
</NitroCardView>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,130 @@
|
||||
import { ContextMenuEnum, CustomUserNotificationMessageEvent, GetSessionDataManager, RoomObjectCategory } from '@nitrots/nitro-renderer';
|
||||
import { FC } from 'react';
|
||||
import { GetGroupInformation, LocalizeText } from '../../../../../api';
|
||||
import { EFFECTBOX_OPEN, GROUP_FURNITURE, MONSTERPLANT_SEED_CONFIRMATION, MYSTERYTROPHY_OPEN_DIALOG, PURCHASABLE_CLOTHING_CONFIRMATION, useFurnitureContextMenuWidget, useMessageEvent, useNotification } from '../../../../../hooks';
|
||||
import { ContextMenuHeaderView } from '../../context-menu/ContextMenuHeaderView';
|
||||
import { ContextMenuListItemView } from '../../context-menu/ContextMenuListItemView';
|
||||
import { ContextMenuView } from '../../context-menu/ContextMenuView';
|
||||
import { FurnitureMysteryBoxOpenDialogView } from '../FurnitureMysteryBoxOpenDialogView';
|
||||
import { FurnitureMysteryTrophyOpenDialogView } from '../FurnitureMysteryTrophyOpenDialogView';
|
||||
import { EffectBoxConfirmView } from './EffectBoxConfirmView';
|
||||
import { MonsterPlantSeedConfirmView } from './MonsterPlantSeedConfirmView';
|
||||
import { PurchasableClothingConfirmView } from './PurchasableClothingConfirmView';
|
||||
|
||||
export const FurnitureContextMenuView: FC<{}> = props =>
|
||||
{
|
||||
const { closeConfirm = null, processAction = null, onClose = null, objectId = -1, mode = null, confirmMode = null, confirmingObjectId = -1, groupData = null, isGroupMember = false, objectOwnerId = -1 } = useFurnitureContextMenuWidget();
|
||||
const { simpleAlert = null } = useNotification();
|
||||
|
||||
useMessageEvent<CustomUserNotificationMessageEvent>(CustomUserNotificationMessageEvent, event =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
if(!parser) return;
|
||||
|
||||
// HOPPER_NO_COSTUME = 1; HOPPER_NO_HC = 2; GATE_NO_HC = 3; STARS_NOT_CANDIDATE = 4 (not coded in Emulator); STARS_NOT_ENOUGH_USERS = 5 (not coded in Emulator);
|
||||
|
||||
switch(parser.count)
|
||||
{
|
||||
case 1:
|
||||
simpleAlert(LocalizeText('costumehopper.costumerequired.bodytext'), null, 'catalog/open/temporary_effects' , LocalizeText('costumehopper.costumerequired.buy'), LocalizeText('costumehopper.costumerequired.header'), null);
|
||||
break;
|
||||
case 2:
|
||||
simpleAlert(LocalizeText('viphopper.viprequired.bodytext'), null, 'catalog/open/habbo_club' , LocalizeText('viprequired.buy.vip'), LocalizeText('viprequired.header'), null);
|
||||
break;
|
||||
case 3:
|
||||
simpleAlert(LocalizeText('gate.viprequired.bodytext'), null, 'catalog/open/habbo_club' , LocalizeText('viprequired.buy.vip'), LocalizeText('gate.viprequired.title'), null);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
const isOwner = GetSessionDataManager().userId === objectOwnerId;
|
||||
|
||||
return (
|
||||
<>
|
||||
{ (confirmMode === MONSTERPLANT_SEED_CONFIRMATION) &&
|
||||
<MonsterPlantSeedConfirmView objectId={ confirmingObjectId } onClose={ closeConfirm } /> }
|
||||
{ (confirmMode === PURCHASABLE_CLOTHING_CONFIRMATION) &&
|
||||
<PurchasableClothingConfirmView objectId={ confirmingObjectId } onClose={ closeConfirm } /> }
|
||||
{ (confirmMode === EFFECTBOX_OPEN) &&
|
||||
<EffectBoxConfirmView objectId={ confirmingObjectId } onClose={ closeConfirm } /> }
|
||||
{ (confirmMode === MYSTERYTROPHY_OPEN_DIALOG) &&
|
||||
<FurnitureMysteryTrophyOpenDialogView objectId={ confirmingObjectId } onClose={ closeConfirm } /> }
|
||||
<FurnitureMysteryBoxOpenDialogView ownerId={ objectOwnerId } />
|
||||
{ (objectId >= 0) && mode &&
|
||||
<ContextMenuView category={ RoomObjectCategory.FLOOR } fades={ true } objectId={ objectId } onClose={ onClose }>
|
||||
{ (mode === ContextMenuEnum.FRIEND_FURNITURE) &&
|
||||
<>
|
||||
<ContextMenuHeaderView>
|
||||
{ LocalizeText('friendfurni.context.title') }
|
||||
</ContextMenuHeaderView>
|
||||
<ContextMenuListItemView onClick={ event => processAction('use_friend_furni') }>
|
||||
{ LocalizeText('friendfurni.context.use') }
|
||||
</ContextMenuListItemView>
|
||||
</> }
|
||||
{ (mode === ContextMenuEnum.MONSTERPLANT_SEED) &&
|
||||
<>
|
||||
<ContextMenuHeaderView>
|
||||
{ LocalizeText('furni.mnstr_seed.name') }
|
||||
</ContextMenuHeaderView>
|
||||
<ContextMenuListItemView onClick={ event => processAction('use_monsterplant_seed') }>
|
||||
{ LocalizeText('widget.monsterplant_seed.button.use') }
|
||||
</ContextMenuListItemView>
|
||||
</> }
|
||||
{ (mode === ContextMenuEnum.RANDOM_TELEPORT) &&
|
||||
<>
|
||||
<ContextMenuHeaderView>
|
||||
{ LocalizeText('furni.random_teleport.name') }
|
||||
</ContextMenuHeaderView>
|
||||
<ContextMenuListItemView onClick={ event => processAction('use_random_teleport') }>
|
||||
{ LocalizeText('widget.random_teleport.button.use') }
|
||||
</ContextMenuListItemView>
|
||||
</> }
|
||||
{ (mode === ContextMenuEnum.PURCHASABLE_CLOTHING) &&
|
||||
<>
|
||||
<ContextMenuHeaderView>
|
||||
{ LocalizeText('furni.generic_usable.name') }
|
||||
</ContextMenuHeaderView>
|
||||
<ContextMenuListItemView onClick={ event => processAction('use_purchaseable_clothing') }>
|
||||
{ LocalizeText('widget.generic_usable.button.use') }
|
||||
</ContextMenuListItemView>
|
||||
</> }
|
||||
{ (mode === ContextMenuEnum.MYSTERY_BOX) &&
|
||||
<>
|
||||
<ContextMenuHeaderView>
|
||||
{ LocalizeText('mysterybox.context.title') }
|
||||
</ContextMenuHeaderView>
|
||||
<ContextMenuListItemView onClick={ event => processAction('use_mystery_box') }>
|
||||
{ LocalizeText('mysterybox.context.' + ((isOwner) ? 'owner' : 'other') + '.use') }
|
||||
</ContextMenuListItemView>
|
||||
</> }
|
||||
{ (mode === ContextMenuEnum.MYSTERY_TROPHY) &&
|
||||
<>
|
||||
<ContextMenuHeaderView>
|
||||
{ LocalizeText('mysterytrophy.header.title') }
|
||||
</ContextMenuHeaderView>
|
||||
<ContextMenuListItemView onClick={ event => processAction('use_mystery_trophy') }>
|
||||
{ LocalizeText('friendfurni.context.use') }
|
||||
</ContextMenuListItemView>
|
||||
</> }
|
||||
{ (mode === GROUP_FURNITURE) && groupData &&
|
||||
<>
|
||||
<ContextMenuHeaderView className="cursor-pointer text-truncate" onClick={ () => GetGroupInformation(groupData.guildId) }>
|
||||
{ groupData.guildName }
|
||||
</ContextMenuHeaderView>
|
||||
{ !isGroupMember &&
|
||||
<ContextMenuListItemView onClick={ event => processAction('join_group') }>
|
||||
{ LocalizeText('widget.furniture.button.join.group') }
|
||||
</ContextMenuListItemView> }
|
||||
<ContextMenuListItemView onClick={ event => processAction('go_to_group_homeroom') }>
|
||||
{ LocalizeText('widget.furniture.button.go.to.group.home.room') }
|
||||
</ContextMenuListItemView>
|
||||
{ groupData.guildHasReadableForum &&
|
||||
<ContextMenuListItemView onClick={ event => processAction('open_forum') }>
|
||||
{ LocalizeText('widget.furniture.button.open_group_forum') }
|
||||
</ContextMenuListItemView> }
|
||||
</> }
|
||||
</ContextMenuView> }
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,85 @@
|
||||
import { IFurnitureData, RoomObjectCategory } from '@nitrots/nitro-renderer';
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { FurniCategory, GetFurnitureDataForRoomObject, LocalizeText } from '../../../../../api';
|
||||
import { Button, Column, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../../common';
|
||||
import { useRoom } from '../../../../../hooks';
|
||||
|
||||
interface MonsterPlantSeedConfirmViewProps
|
||||
{
|
||||
objectId: number;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
const MODE_DEFAULT: number = -1;
|
||||
const MODE_MONSTERPLANT_SEED: number = 0;
|
||||
|
||||
export const MonsterPlantSeedConfirmView: FC<MonsterPlantSeedConfirmViewProps> = props =>
|
||||
{
|
||||
const { objectId = -1, onClose = null } = props;
|
||||
const [ furniData, setFurniData ] = useState<IFurnitureData>(null);
|
||||
const [ mode, setMode ] = useState(MODE_DEFAULT);
|
||||
const { roomSession = null } = useRoom();
|
||||
|
||||
const useProduct = () =>
|
||||
{
|
||||
roomSession.useMultistateItem(objectId);
|
||||
|
||||
onClose();
|
||||
};
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
if(!roomSession || (objectId === -1)) return;
|
||||
|
||||
const furniData = GetFurnitureDataForRoomObject(roomSession.roomId, objectId, RoomObjectCategory.FLOOR);
|
||||
|
||||
if(!furniData) return;
|
||||
|
||||
setFurniData(furniData);
|
||||
|
||||
let mode = MODE_DEFAULT;
|
||||
|
||||
switch(furniData.specialType)
|
||||
{
|
||||
case FurniCategory.MONSTERPLANT_SEED:
|
||||
mode = MODE_MONSTERPLANT_SEED;
|
||||
break;
|
||||
}
|
||||
|
||||
if(mode === MODE_DEFAULT)
|
||||
{
|
||||
onClose();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
setMode(mode);
|
||||
}, [ roomSession, objectId, onClose ]);
|
||||
|
||||
if(mode === MODE_DEFAULT) return null;
|
||||
|
||||
return (
|
||||
<NitroCardView className="nitro-use-product-confirmation">
|
||||
<NitroCardHeaderView headerText={ LocalizeText('useproduct.widget.title.plant_seed', [ 'name' ], [ furniData.name ]) } onCloseClick={ onClose } />
|
||||
<NitroCardContentView center>
|
||||
<div className="flex gap-2 overflow-hidden">
|
||||
<div className="flex flex-col">
|
||||
<div className="product-preview">
|
||||
<div className="monsterplant-image" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col justify-between overflow-auto">
|
||||
<Column gap={ 2 }>
|
||||
<Text>{ LocalizeText('useproduct.widget.text.plant_seed', [ 'productName' ], [ furniData.name ]) }</Text>
|
||||
<Text>{ LocalizeText('useproduct.widget.info.plant_seed') }</Text>
|
||||
</Column>
|
||||
<div className="flex items-center justify-between">
|
||||
<Button variant="danger" onClick={ onClose }>{ LocalizeText('useproduct.widget.cancel') }</Button>
|
||||
<Button variant="success" onClick={ useProduct }>{ LocalizeText('widget.monsterplant_seed.button.use') }</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</NitroCardContentView>
|
||||
</NitroCardView>
|
||||
);
|
||||
};
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
import { AvatarFigurePartType, GetAvatarRenderManager, GetSessionDataManager, RedeemItemClothingComposer, RoomObjectCategory, UserFigureComposer } from '@nitrots/nitro-renderer';
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { FurniCategory, GetFurnitureDataForRoomObject, LocalizeText, SendMessageComposer } from '../../../../../api';
|
||||
import { Button, Column, LayoutAvatarImageView, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../../common';
|
||||
import { useRoom } from '../../../../../hooks';
|
||||
|
||||
interface PurchasableClothingConfirmViewProps
|
||||
{
|
||||
objectId: number;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
const MODE_DEFAULT: number = -1;
|
||||
const MODE_PURCHASABLE_CLOTHING: number = 0;
|
||||
|
||||
export const PurchasableClothingConfirmView: FC<PurchasableClothingConfirmViewProps> = props =>
|
||||
{
|
||||
const { objectId = -1, onClose = null } = props;
|
||||
const [ mode, setMode ] = useState(MODE_DEFAULT);
|
||||
const [ gender, setGender ] = useState<string>(AvatarFigurePartType.MALE);
|
||||
const [ newFigure, setNewFigure ] = useState<string>(null);
|
||||
const { roomSession = null } = useRoom();
|
||||
|
||||
const useProduct = () =>
|
||||
{
|
||||
SendMessageComposer(new RedeemItemClothingComposer(objectId));
|
||||
SendMessageComposer(new UserFigureComposer(gender, newFigure));
|
||||
|
||||
onClose();
|
||||
};
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
let mode = MODE_DEFAULT;
|
||||
|
||||
const figure = GetSessionDataManager().figure;
|
||||
const gender = GetSessionDataManager().gender;
|
||||
const validSets: number[] = [];
|
||||
|
||||
if(roomSession && (objectId >= 0))
|
||||
{
|
||||
const furniData = GetFurnitureDataForRoomObject(roomSession.roomId, objectId, RoomObjectCategory.FLOOR);
|
||||
|
||||
if(furniData)
|
||||
{
|
||||
switch(furniData.specialType)
|
||||
{
|
||||
case FurniCategory.FIGURE_PURCHASABLE_SET:
|
||||
mode = MODE_PURCHASABLE_CLOTHING;
|
||||
|
||||
const setIds = furniData.customParams.split(',').map(part => parseInt(part));
|
||||
|
||||
for(const setId of setIds)
|
||||
{
|
||||
if(GetAvatarRenderManager().isValidFigureSetForGender(setId, gender)) validSets.push(setId);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(mode === MODE_DEFAULT)
|
||||
{
|
||||
onClose();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
setGender(gender);
|
||||
setNewFigure(GetAvatarRenderManager().getFigureStringWithFigureIds(figure, gender, validSets));
|
||||
|
||||
// if owns clothing, change to it
|
||||
|
||||
setMode(mode);
|
||||
}, [ roomSession, objectId, onClose ]);
|
||||
|
||||
if(mode === MODE_DEFAULT) return null;
|
||||
|
||||
return (
|
||||
<NitroCardView className="nitro-use-product-confirmation">
|
||||
<NitroCardHeaderView headerText={ LocalizeText('useproduct.widget.title.bind_clothing') } onCloseClick={ onClose } />
|
||||
<NitroCardContentView center>
|
||||
<div className="flex overflow-hidden gap-2">
|
||||
<div className="flex flex-col">
|
||||
<div className="mannequin-preview">
|
||||
<LayoutAvatarImageView direction={ 2 } figure={ newFigure } />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col justify-between overflow-auto">
|
||||
<Column gap={ 2 }>
|
||||
<Text>{ LocalizeText('useproduct.widget.text.bind_clothing') }</Text>
|
||||
<Text>{ LocalizeText('useproduct.widget.info.bind_clothing') }</Text>
|
||||
</Column>
|
||||
<div className="flex items-center justify-between">
|
||||
<Button variant="danger" onClick={ onClose }>{ LocalizeText('useproduct.widget.cancel') }</Button>
|
||||
<Button variant="success" onClick={ useProduct }>{ LocalizeText('useproduct.widget.bind_clothing') }</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</NitroCardContentView>
|
||||
</NitroCardView>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user