mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-01-18 21:36:27 +01:00
Finish FurnitureBadgeDisplayView
This commit is contained in:
parent
0b568a089f
commit
02dfb4150c
@ -5,7 +5,7 @@ import { NitroLayoutTrophyViewProps } from './NitroLayoutTrophyView.types';
|
||||
|
||||
export const NitroLayoutTrophyView: FC<NitroLayoutTrophyViewProps> = props =>
|
||||
{
|
||||
const { color = '', message = '', date = '', senderName = '', onCloseClick = null } = props;
|
||||
const { color = '', message = '', date = '', senderName = '', customTitle = null, onCloseClick = null } = props;
|
||||
|
||||
return (
|
||||
<DraggableWindow handleSelector=".drag-handler">
|
||||
@ -17,6 +17,7 @@ export const NitroLayoutTrophyView: FC<NitroLayoutTrophyViewProps> = props =>
|
||||
</div>
|
||||
</div>
|
||||
<div className="trophy-content">
|
||||
{ customTitle && <div className="mb-2 fw-bold">{ customTitle }</div> }
|
||||
{ message }
|
||||
</div>
|
||||
<div className="trophy-footer d-flex justify-content-between fw-bold">
|
||||
|
@ -4,5 +4,6 @@ export interface NitroLayoutTrophyViewProps
|
||||
message: string;
|
||||
date: string;
|
||||
senderName: string;
|
||||
customTitle?: string;
|
||||
onCloseClick: () => void;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { FC } from 'react';
|
||||
import { FurnitureBackgroundColorView } from './background-color/FurnitureBackgroundColorView';
|
||||
import { FurnitureBadgeDisplayView } from './badge-display/FurnitureBadgeDisplayView';
|
||||
import { FurnitureContextMenuView } from './context-menu/FurnitureContextMenuView';
|
||||
import { FurnitureCustomStackHeightView } from './custom-stack-height/FurnitureCustomStackHeightView';
|
||||
import { FurnitureDimmerView } from './dimmer/FurnitureDimmerView';
|
||||
@ -29,6 +30,7 @@ export const FurnitureWidgetsView: FC<{}> = props =>
|
||||
<FurniturePresentView />
|
||||
<FurnitureStickieView />
|
||||
<FurnitureTrophyView />
|
||||
<FurnitureBadgeDisplayView />
|
||||
<FurnitureExternalImageView />
|
||||
</div>
|
||||
);
|
||||
|
@ -1,19 +1,23 @@
|
||||
import { NitroEvent, RoomEngineTriggerWidgetEvent, StringDataType } from '@nitrots/nitro-renderer';
|
||||
import { FC, useCallback } from 'react';
|
||||
import { GetRoomEngine, LocalizeBadgeDescription, LocalizeBadgeName } from '../../../../../api';
|
||||
import { FC, useCallback, useState } from 'react';
|
||||
import { GetRoomEngine, LocalizeBadgeDescription, LocalizeBadgeName, RoomWidgetRoomObjectUpdateEvent } from '../../../../../api';
|
||||
import { CreateEventDispatcherHook } from '../../../../../hooks';
|
||||
import { useRoomEngineEvent } from '../../../../../hooks/events/nitro/room/room-engine-event';
|
||||
import { NitroLayoutTrophyView } from '../../../../../layout';
|
||||
import { useRoomContext } from '../../../context/RoomContext';
|
||||
import { FurnitureTrophyData } from '../trophy/FurnitureTrophyData';
|
||||
|
||||
export const FurnitureBadgeDisplayView: FC<{}> = props =>
|
||||
{
|
||||
const { eventDispatcher = null, widgetHandler = null } = useRoomContext();
|
||||
const [ trophyData, setTrophyData ] = useState<FurnitureTrophyData>(null);
|
||||
|
||||
const onNitroEvent = useCallback((event: NitroEvent) =>
|
||||
{
|
||||
switch(event.type)
|
||||
{
|
||||
case RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING:
|
||||
case RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING: {
|
||||
case RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING:
|
||||
case RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING: {
|
||||
const widgetEvent = (event as RoomEngineTriggerWidgetEvent);
|
||||
|
||||
const roomObject = GetRoomEngine().getRoomObject(widgetEvent.roomId, widgetEvent.objectId, widgetEvent.category);
|
||||
@ -24,10 +28,23 @@ export const FurnitureBadgeDisplayView: FC<{}> = props =>
|
||||
|
||||
stringStuff.initializeFromRoomObjectModel(roomObject.model);
|
||||
|
||||
const bagdeName = LocalizeBadgeName(stringStuff.getValue(1));
|
||||
const badgeName = LocalizeBadgeName(stringStuff.getValue(1));
|
||||
const badgeDesc = LocalizeBadgeDescription(stringStuff.getValue(1));
|
||||
const date = stringStuff.getValue(2);
|
||||
const senderName = stringStuff.getValue(3);
|
||||
|
||||
setTrophyData(new FurnitureTrophyData(widgetEvent.objectId, widgetEvent.category, '1', senderName, date, badgeDesc, badgeName));
|
||||
return;
|
||||
}
|
||||
case RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED: {
|
||||
const widgetEvent = (event as RoomWidgetRoomObjectUpdateEvent);
|
||||
|
||||
setTrophyData(prevState =>
|
||||
{
|
||||
if(!prevState || (widgetEvent.id !== prevState.objectId) || (widgetEvent.category !== prevState.category)) return prevState;
|
||||
|
||||
return null;
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -35,20 +52,19 @@ export const FurnitureBadgeDisplayView: FC<{}> = props =>
|
||||
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_BADGE_DISPLAY_ENGRAVING, onNitroEvent);
|
||||
useRoomEngineEvent(RoomEngineTriggerWidgetEvent.REQUEST_ACHIEVEMENT_RESOLUTION_ENGRAVING, onNitroEvent);
|
||||
CreateEventDispatcherHook(RoomWidgetRoomObjectUpdateEvent.FURNI_REMOVED, widgetHandler.eventDispatcher, onNitroEvent);
|
||||
|
||||
const processAction = useCallback((type: string, value: string = null) =>
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case 'close':
|
||||
//setTrophyData(null);
|
||||
setTrophyData(null);
|
||||
return;
|
||||
}
|
||||
}, []);
|
||||
|
||||
return null;
|
||||
if(!trophyData) return null;
|
||||
|
||||
// if(!trophyData) return null;
|
||||
|
||||
// return <NitroLayoutTrophyView color={ trophyData.color } message={ trophyData.message } date={ trophyData.date } senderName={ trophyData.ownerName } onCloseClick={ () => processAction('close') } />;
|
||||
return <NitroLayoutTrophyView color={ trophyData.color } message={ trophyData.message } date={ trophyData.date } senderName={ trophyData.ownerName } customTitle={ trophyData.customTitle } onCloseClick={ () => processAction('close') } />;
|
||||
}
|
||||
|
@ -6,5 +6,6 @@ export class FurnitureTrophyData
|
||||
public color: string,
|
||||
public ownerName: string,
|
||||
public date: string,
|
||||
public message: string) {}
|
||||
public message: string,
|
||||
public customTitle?: string) {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user