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