Remove old unused widget handlers

This commit is contained in:
Bill 2022-04-17 20:41:40 -04:00
parent c7a4c1b04b
commit 61022c16ef
25 changed files with 46 additions and 982 deletions

View File

@ -21,6 +21,7 @@ export * from './nitro/room/widgets/messages';
export * from './nitro/session';
export * from './notification';
export * from './purse';
export * from './room';
export * from './user';
export * from './utils';
export * from './wired';

View File

@ -1,22 +0,0 @@
import { RoomObjectItem } from './RoomObjectItem';
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetChooserContentEvent extends RoomWidgetUpdateEvent
{
public static USER_CHOOSER_CONTENT: string = 'RWCCE_USER_CHOOSER_CONTENT';
public static FURNI_CHOOSER_CONTENT: string = 'RWCCE_FURNI_CHOOSER_CONTENT';
private _items: RoomObjectItem[];
constructor(type: string, items: RoomObjectItem[])
{
super(type);
this._items = items;
}
public get items(): RoomObjectItem[]
{
return this._items;
}
}

View File

@ -1,27 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateCustomStackHeightEvent extends RoomWidgetUpdateEvent
{
public static UPDATE_CUSTOM_STACK_HEIGHT: string = 'RWUCSHE_UPDATE_CUSTOM_STACK_HEIGHT';
private _objectId: number;
private _height: number;
constructor(objectId: number, height: number = 0)
{
super(RoomWidgetUpdateCustomStackHeightEvent.UPDATE_CUSTOM_STACK_HEIGHT);
this._objectId = objectId;
this._height = height;
}
public get objectId(): number
{
return this._objectId;
}
public get height(): number
{
return this._height;
}
}

View File

@ -1,28 +0,0 @@
import { IPhotoData } from './IPhotoData';
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateExternalImageEvent extends RoomWidgetUpdateEvent
{
public static UPDATE_EXTERNAL_IMAGE: string = 'RWUEIE_UPDATE_EXTERNAL_IMAGE';
private _objectId: number;
private _photoData: IPhotoData;
constructor(objectId: number, photoData: IPhotoData = null)
{
super(RoomWidgetUpdateExternalImageEvent.UPDATE_EXTERNAL_IMAGE);
this._objectId = objectId;
this._photoData = photoData;
}
public get objectId(): number
{
return this._objectId;
}
public get photoData(): IPhotoData
{
return this._photoData;
}
}

View File

@ -1,41 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdateMannequinEvent extends RoomWidgetUpdateEvent
{
public static MANNEQUIN_UPDATE: string = 'RWUME_MANNEQUIN_UPDATE';
private _objectId: number;
private _figure: string;
private _gender: string;
private _name: string;
constructor(type: string, objectId: number, figure: string, gender: string, name: string)
{
super(type);
this._objectId = objectId;
this._figure = figure;
this._gender = gender;
this._name = name;
}
public get objectId(): number
{
return this._objectId;
}
public get figure(): string
{
return this._figure;
}
public get gender(): string
{
return this._gender;
}
public get name(): string
{
return this._name;
}
}

View File

@ -1,116 +0,0 @@
import { RoomWidgetUpdateEvent } from './RoomWidgetUpdateEvent';
export class RoomWidgetUpdatePresentDataEvent extends RoomWidgetUpdateEvent
{
public static PACKAGEINFO: string = 'RWUPDE_PACKAGEINFO';
public static CONTENTS: string = 'RWUPDE_CONTENTS';
public static CONTENTS_CLUB: string = 'RWUPDE_CONTENTS_CLUB';
public static CONTENTS_FLOOR: string = 'RWUPDE_CONTENTS_FLOOR';
public static CONTENTS_LANDSCAPE: string = 'RWUPDE_CONTENTS_LANDSCAPE';
public static CONTENTS_WALLPAPER: string = 'RWUPDE_CONTENTS_WALLPAPER';
public static CONTENTS_IMAGE: string = 'RWUPDE_CONTENTS_IMAGE';
private _objectId: number = -1;
private _classId: number = 0;
private _itemType: string = '';
private _giftMessage: string = '';
private _imageUrl: string = null;
private _isController: boolean;
private _purchaserName: string;
private _purchaserFigure: string;
private _placedItemId: number = -1;
private _placedItemType: string = '';
private _placedInRoom: boolean;
constructor(type: string, objectId: number, giftMessage: string, isOwnerOfFurniture: boolean = false, imageUrl: string = null, purchaserName: string = null, purchaserFigure: string = null)
{
super(type);
this._objectId = objectId;
this._giftMessage = giftMessage;
this._imageUrl = imageUrl;
this._isController = isOwnerOfFurniture;
this._purchaserName = purchaserName;
this._purchaserFigure = purchaserFigure;
}
public get objectId(): number
{
return this._objectId;
}
public get classId(): number
{
return this._classId;
}
public set classId(classId: number)
{
this._classId = classId;
}
public get itemType(): string
{
return this._itemType;
}
public set itemType(type: string)
{
this._itemType = type;
}
public get giftMessage(): string
{
return this._giftMessage;
}
public get imageUrl(): string
{
return this._imageUrl;
}
public get isController(): boolean
{
return this._isController;
}
public get purchaserName(): string
{
return this._purchaserName;
}
public get purchaserFigure(): string
{
return this._purchaserFigure;
}
public get placedItemId(): number
{
return this._placedItemId;
}
public set placedItemId(itemId: number)
{
this._placedItemId = itemId;
}
public get placedInRoom(): boolean
{
return this._placedInRoom;
}
public set placedInRoom(flag: boolean)
{
this._placedInRoom = flag;
}
public get placedItemType(): string
{
return this._placedItemType;
}
public set placedItemType(type: string)
{
this._placedItemType = type;
}
}

View File

@ -2,7 +2,6 @@ export * from './IPhotoData';
export * from './RoomDimmerPreset';
export * from './RoomObjectItem';
export * from './RoomWidgetAvatarInfoEvent';
export * from './RoomWidgetChooserContentEvent';
export * from './RoomWidgetFloodControlEvent';
export * from './RoomWidgetObjectNameEvent';
export * from './RoomWidgetPollUpdateEvent';
@ -10,20 +9,16 @@ export * from './RoomWidgetUpdateBackgroundColorPreviewEvent';
export * from './RoomWidgetUpdateChatEvent';
export * from './RoomWidgetUpdateChatInputContentEvent';
export * from './RoomWidgetUpdateCreditFurniEvent';
export * from './RoomWidgetUpdateCustomStackHeightEvent';
export * from './RoomWidgetUpdateDanceStatusEvent';
export * from './RoomWidgetUpdateDecorateModeEvent';
export * from './RoomWidgetUpdateDimmerEvent';
export * from './RoomWidgetUpdateDimmerStateEvent';
export * from './RoomWidgetUpdateEvent';
export * from './RoomWidgetUpdateExternalImageEvent';
export * from './RoomWidgetUpdateInfostandEvent';
export * from './RoomWidgetUpdateInfostandFurniEvent';
export * from './RoomWidgetUpdateInfostandPetEvent';
export * from './RoomWidgetUpdateInfostandRentableBotEvent';
export * from './RoomWidgetUpdateInfostandUserEvent';
export * from './RoomWidgetUpdateMannequinEvent';
export * from './RoomWidgetUpdatePresentDataEvent';
export * from './RoomWidgetUpdateRentableBotChatEvent';
export * from './RoomWidgetUpdateRoomEngineEvent';
export * from './RoomWidgetUpdateRoomObjectEvent';

View File

@ -1,102 +0,0 @@
import { NitroEvent, RoomObjectCategory, RoomObjectVariable, RoomWidgetEnum } from '@nitrots/nitro-renderer';
import { GetRoomEngine, GetSessionDataManager } from '../../../..';
import { LocalizeText } from '../../../../utils';
import { RoomObjectItem, RoomWidgetChooserContentEvent, RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetMessage, RoomWidgetRequestWidgetMessage, RoomWidgetRoomObjectMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class FurniChooserWidgetHandler extends RoomWidgetHandler
{
public processEvent(event: NitroEvent): void
{
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
if(!message) return null;
switch(message.type)
{
case RoomWidgetRequestWidgetMessage.FURNI_CHOOSER:
this.processChooser();
break;
case RoomWidgetRoomObjectMessage.SELECT_OBJECT:
this.selectRoomObject((message as RoomWidgetRoomObjectMessage));
break;
}
return null;
}
private processChooser(): void
{
const roomId = this.container.roomSession.roomId;
const items: RoomObjectItem[] = [];
const wallItems = GetRoomEngine().getRoomObjects(roomId, RoomObjectCategory.WALL);
const floorItems = GetRoomEngine().getRoomObjects(roomId, RoomObjectCategory.FLOOR);
wallItems.forEach(roomObject =>
{
let name = roomObject.type;
if(name.startsWith('poster'))
{
name = LocalizeText(`poster_${ name.replace('poster', '') }_name`);
}
else
{
const typeId = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_TYPE_ID);
const furniData = GetSessionDataManager().getWallItemData(typeId);
if(furniData && furniData.name.length) name = furniData.name;
}
items.push(new RoomObjectItem(roomObject.id, RoomObjectCategory.WALL, name));
});
floorItems.forEach(roomObject =>
{
let name = roomObject.type;
const typeId = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_TYPE_ID);
const furniData = GetSessionDataManager().getFloorItemData(typeId);
if(furniData && furniData.name.length) name = furniData.name;
items.push(new RoomObjectItem(roomObject.id, RoomObjectCategory.FLOOR, name));
});
items.sort((a, b) =>
{
return (a.name < b.name) ? -1 : 1;
});
this.container.eventDispatcher.dispatchEvent(new RoomWidgetChooserContentEvent(RoomWidgetChooserContentEvent.FURNI_CHOOSER_CONTENT, items));
}
private selectRoomObject(message: RoomWidgetRoomObjectMessage): void
{
if((message.category !== RoomObjectCategory.WALL) && (message.category !== RoomObjectCategory.FLOOR)) return;
GetRoomEngine().selectRoomObject(this.container.roomSession.roomId, message.id, message.category);
}
public get type(): string
{
return RoomWidgetEnum.FURNI_CHOOSER;
}
public get eventTypes(): string[]
{
return [];
}
public get messageTypes(): string[]
{
return [
RoomWidgetRequestWidgetMessage.FURNI_CHOOSER,
RoomWidgetRoomObjectMessage.SELECT_OBJECT
];
}
}

View File

@ -1,59 +0,0 @@
import { FurnitureExchangeComposer, NitroEvent, RoomObjectVariable, RoomWidgetEnum } from '@nitrots/nitro-renderer';
import { RoomWidgetCreditFurniRedeemMessage, RoomWidgetUpdateCreditFurniEvent, RoomWidgetUpdateEvent } from '..';
import { GetRoomEngine } from '../..';
import { IsOwnerOfFurniture } from '../../..';
import { RoomWidgetFurniToWidgetMessage, RoomWidgetMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class FurnitureCreditWidgetHandler extends RoomWidgetHandler
{
public processEvent(event: NitroEvent): void
{
return;
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
switch(message.type)
{
case RoomWidgetFurniToWidgetMessage.REQUEST_CREDITFURNI: {
const creditMessage = (message as RoomWidgetFurniToWidgetMessage);
const roomObject = GetRoomEngine().getRoomObject(creditMessage.roomId, creditMessage.objectId, creditMessage.category);
if(!roomObject || !IsOwnerOfFurniture(roomObject)) return;
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateCreditFurniEvent(RoomWidgetUpdateCreditFurniEvent.CREDIT_FURNI_UPDATE, creditMessage.objectId, roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_CREDIT_VALUE), (roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_TYPE_ID) + '_' + creditMessage.type + '_' + creditMessage.objectId)));
break;
}
case RoomWidgetCreditFurniRedeemMessage.REDEEM: {
const redeemMessage = (message as RoomWidgetCreditFurniRedeemMessage);
this.container.roomSession.connection.send(new FurnitureExchangeComposer(redeemMessage.objectId));
break;
}
}
return null;
}
public get type(): string
{
return RoomWidgetEnum.FURNI_CREDIT_WIDGET;
}
public get eventTypes(): string[]
{
return [];
}
public get messageTypes(): string[]
{
return [
RoomWidgetFurniToWidgetMessage.REQUEST_CREDITFURNI,
RoomWidgetCreditFurniRedeemMessage.REDEEM
];
}
}

View File

@ -1,61 +0,0 @@
import { NitroEvent, RoomEngineTriggerWidgetEvent, RoomWidgetEnum } from '@nitrots/nitro-renderer';
import { GetRoomEngine } from '../../../..';
import { RoomWidgetUpdateCustomStackHeightEvent, RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class FurnitureCustomStackHeightWidgetHandler extends RoomWidgetHandler
{
private _lastFurniId: number = -1;
public processEvent(event: NitroEvent): void
{
switch(event.type)
{
case RoomEngineTriggerWidgetEvent.OPEN_WIDGET: {
const widgetEvent = (event as RoomEngineTriggerWidgetEvent);
const roomObject = GetRoomEngine().getRoomObject(widgetEvent.roomId, widgetEvent.objectId, widgetEvent.category);
if(!roomObject) return;
this._lastFurniId = widgetEvent.objectId;
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateCustomStackHeightEvent(this._lastFurniId, roomObject.getLocation().z));
return;
}
case RoomEngineTriggerWidgetEvent.CLOSE_WIDGET: {
const widgetEvent = (event as RoomEngineTriggerWidgetEvent);
if(widgetEvent.objectId !== this._lastFurniId) return;
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateCustomStackHeightEvent(-1));
return;
}
}
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
switch(message.type)
{
}
return null;
}
public get type(): string
{
return RoomWidgetEnum.CUSTOM_STACK_HEIGHT;
}
public get eventTypes(): string[]
{
return [];
}
public get messageTypes(): string[]
{
return [];
}
}

View File

@ -1,64 +0,0 @@
import { NitroEvent, RoomEngineTriggerWidgetEvent, RoomObjectVariable, RoomWidgetEnum } from '@nitrots/nitro-renderer';
import { GetRoomEngine } from '../../../..';
import { IPhotoData, RoomWidgetUpdateEvent, RoomWidgetUpdateExternalImageEvent } from '../events';
import { RoomWidgetMessage } from '../messages/RoomWidgetMessage';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class FurnitureExternalImageWidgetHandler extends RoomWidgetHandler
{
private _lastFurniId: number = -1;
public processEvent(event: NitroEvent): void
{
switch(event.type)
{
case RoomEngineTriggerWidgetEvent.OPEN_WIDGET: {
const widgetEvent = (event as RoomEngineTriggerWidgetEvent);
const roomObject = GetRoomEngine().getRoomObject(widgetEvent.roomId, widgetEvent.objectId, widgetEvent.category);
if(!roomObject) return;
this._lastFurniId = widgetEvent.objectId;
const data = roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_DATA);
const photoData = (JSON.parse(data) as IPhotoData);
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateExternalImageEvent(roomObject.id, photoData));
return;
}
case RoomEngineTriggerWidgetEvent.CLOSE_WIDGET: {
const widgetEvent = (event as RoomEngineTriggerWidgetEvent);
if(widgetEvent.objectId !== this._lastFurniId) return;
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateExternalImageEvent(-1));
return;
}
}
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
switch(message.type)
{
}
return null;
}
public get type(): string
{
return RoomWidgetEnum.EXTERNAL_IMAGE;
}
public get eventTypes(): string[]
{
return [];
}
public get messageTypes(): string[]
{
return [];
}
}

View File

@ -1,54 +0,0 @@
import { NitroEvent, RoomEngineTriggerWidgetEvent, RoomObjectVariable, RoomWidgetEnum } from '@nitrots/nitro-renderer';
import { RoomWidgetUpdateMannequinEvent } from '..';
import { GetRoomEngine } from '../../GetRoomEngine';
import { RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class FurnitureMannequinWidgetHandler extends RoomWidgetHandler
{
public processEvent(event: NitroEvent): void
{
switch(event.type)
{
case RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN: {
const widgetEvent = (event as RoomEngineTriggerWidgetEvent);
const roomObject = GetRoomEngine().getRoomObject(widgetEvent.roomId, widgetEvent.objectId, widgetEvent.category);
if(!roomObject) return;
const model = roomObject.model;
const figure = model.getValue<string>(RoomObjectVariable.FURNITURE_MANNEQUIN_FIGURE);
const gender = model.getValue<string>(RoomObjectVariable.FURNITURE_MANNEQUIN_GENDER);
const name = model.getValue<string>(RoomObjectVariable.FURNITURE_MANNEQUIN_NAME);
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdateMannequinEvent(RoomWidgetUpdateMannequinEvent.MANNEQUIN_UPDATE, roomObject.id, figure, gender, name));
return;
}
}
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
switch(message.type)
{
}
return null;
}
public get type(): string
{
return RoomWidgetEnum.MANNEQUIN;
}
public get eventTypes(): string[]
{
return [ RoomEngineTriggerWidgetEvent.REQUEST_MANNEQUIN ];
}
public get messageTypes(): string[]
{
return [];
}
}

View File

@ -1,223 +0,0 @@
import { IFurnitureData, IGetImageListener, NitroEvent, NitroRenderTexture, PetFigureData, RoomObjectCategory, RoomObjectVariable, RoomSessionPresentEvent, RoomWidgetEnum, TextureUtils, Vector3d } from '@nitrots/nitro-renderer';
import { GetSessionDataManager, IsOwnerOfFurniture } from '../../..';
import { GetRoomEngine, LocalizeText } from '../../../..';
import { ProductTypeEnum } from '../../../../catalog';
import { RoomWidgetUpdateEvent, RoomWidgetUpdatePresentDataEvent } from '../events';
import { RoomWidgetFurniToWidgetMessage, RoomWidgetPresentOpenMessage } from '../messages';
import { RoomWidgetMessage } from '../messages/RoomWidgetMessage';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class FurniturePresentWidgetHandler extends RoomWidgetHandler implements IGetImageListener
{
private static FLOOR: string = 'floor';
private static WALLPAPER: string = 'wallpaper';
private static LANDSCAPE: string = 'landscape';
private static POSTER: string = 'poster';
private _lastFurniId: number = -1;
private _name: string = null;
public processEvent(event: NitroEvent): void
{
switch(event.type)
{
case RoomSessionPresentEvent.RSPE_PRESENT_OPENED: {
const presentEvent = (event as RoomSessionPresentEvent);
let furniData: IFurnitureData = null;
if(presentEvent.itemType === ProductTypeEnum.FLOOR)
{
furniData = GetSessionDataManager().getFloorItemData(presentEvent.classId);
}
else if(presentEvent.itemType === ProductTypeEnum.WALL)
{
furniData = GetSessionDataManager().getWallItemData(presentEvent.classId);
}
let isOwnerOfFurni = false;
if(presentEvent.placedInRoom)
{
const roomObject = GetRoomEngine().getRoomObject(this.container.roomSession.roomId, presentEvent.placedItemId, RoomObjectCategory.FLOOR);
if(roomObject) isOwnerOfFurni = IsOwnerOfFurniture(roomObject);
}
let giftImage: string = null;
let dataUpdateEvent: RoomWidgetUpdatePresentDataEvent = null;
switch(presentEvent.itemType)
{
case ProductTypeEnum.WALL: {
if(furniData)
{
switch(furniData.className)
{
case FurniturePresentWidgetHandler.FLOOR:
dataUpdateEvent = new RoomWidgetUpdatePresentDataEvent(RoomWidgetUpdatePresentDataEvent.CONTENTS_FLOOR, 0, LocalizeText('inventory.furni.item.floor.name'), isOwnerOfFurni);
break;
case FurniturePresentWidgetHandler.LANDSCAPE:
dataUpdateEvent = new RoomWidgetUpdatePresentDataEvent(RoomWidgetUpdatePresentDataEvent.CONTENTS_LANDSCAPE, 0, LocalizeText('inventory.furni.item.landscape.name'), isOwnerOfFurni);
break;
case FurniturePresentWidgetHandler.WALLPAPER:
dataUpdateEvent = new RoomWidgetUpdatePresentDataEvent(RoomWidgetUpdatePresentDataEvent.CONTENTS_WALLPAPER, 0, LocalizeText('inventory.furni.item.wallpaper.name'), isOwnerOfFurni);
break;
case FurniturePresentWidgetHandler.POSTER: {
const productCode = presentEvent.productCode;
let extras: string = null;
if(productCode.indexOf('poster') === 0) extras = productCode.replace('poster', '');
giftImage = GetRoomEngine().getFurnitureWallIconUrl(presentEvent.classId, extras);
const productData = GetSessionDataManager().getProductData(productCode);
if(productData) this._name = productData.name;
else if(furniData) this._name = furniData.name;
dataUpdateEvent = new RoomWidgetUpdatePresentDataEvent(RoomWidgetUpdatePresentDataEvent.CONTENTS, 0, this._name, isOwnerOfFurni, giftImage);
break;
}
default: {
giftImage = GetRoomEngine().getFurnitureWallIconUrl(presentEvent.classId);
if(furniData) this._name = furniData.name;
dataUpdateEvent = new RoomWidgetUpdatePresentDataEvent(RoomWidgetUpdatePresentDataEvent.CONTENTS, 0, this._name, isOwnerOfFurni, giftImage);
break;
}
}
}
break;
}
case ProductTypeEnum.HABBO_CLUB:
dataUpdateEvent = new RoomWidgetUpdatePresentDataEvent(RoomWidgetUpdatePresentDataEvent.CONTENTS_CLUB, 0, LocalizeText('widget.furni.present.hc'), false);
break;
default: {
if(presentEvent.placedItemType === ProductTypeEnum.PET)
{
const petfigureString = presentEvent.petFigureString;
if(petfigureString && petfigureString.length)
{
const petFigureData = new PetFigureData(petfigureString);
const petImage = GetRoomEngine().getRoomObjectPetImage(petFigureData.typeId, petFigureData.paletteId, petFigureData.color, new Vector3d(90), 64, this, true, 0, petFigureData.customParts);
if(petImage) giftImage = petImage.getImage().src;
}
}
if(!giftImage)
{
const furniImage = GetRoomEngine().getFurnitureFloorImage(presentEvent.classId, new Vector3d(90), 64, this);
if(furniImage) giftImage = furniImage.getImage().src;
}
const productData = GetSessionDataManager().getProductData(presentEvent.productCode);
if(productData) this._name = productData.name;
else this._name = furniData.name;
if(giftImage) dataUpdateEvent = new RoomWidgetUpdatePresentDataEvent(RoomWidgetUpdatePresentDataEvent.CONTENTS, 0, this._name, isOwnerOfFurni, giftImage);
break;
}
}
if(dataUpdateEvent)
{
dataUpdateEvent.classId = presentEvent.classId;
dataUpdateEvent.itemType = presentEvent.itemType;
dataUpdateEvent.placedItemId = presentEvent.placedItemId;
dataUpdateEvent.placedInRoom = presentEvent.placedInRoom;
dataUpdateEvent.placedItemType = presentEvent.placedItemType;
this.container.eventDispatcher.dispatchEvent(dataUpdateEvent);
}
return;
}
}
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
switch(message.type)
{
case RoomWidgetFurniToWidgetMessage.REQUEST_PRESENT: {
const widgetMessage = (message as RoomWidgetFurniToWidgetMessage);
const roomObject = GetRoomEngine().getRoomObject(widgetMessage.roomId, widgetMessage.objectId, widgetMessage.category);
if(!roomObject) return null;
this._lastFurniId = widgetMessage.objectId;
const giftMessage = (roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_DATA) || '');
const purchaserName = roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_PURCHASER_NAME);
const purchaserFigure = roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_PURCHASER_FIGURE);
const typeId = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_TYPE_ID);
const extras = roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_EXTRAS);
const giftImage = GetRoomEngine().getFurnitureFloorImage(typeId, new Vector3d(180), 64, null, 0, extras);
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdatePresentDataEvent(RoomWidgetUpdatePresentDataEvent.PACKAGEINFO, widgetMessage.objectId, giftMessage, IsOwnerOfFurniture(roomObject), giftImage.getImage().src, purchaserName, purchaserFigure));
break;
}
case RoomWidgetPresentOpenMessage.OPEN_PRESENT: {
const openMessage = (message as RoomWidgetPresentOpenMessage);
if(openMessage.objectId !== this._lastFurniId) return null;
this.container.roomSession.openGift(openMessage.objectId);
GetRoomEngine().changeObjectModelData(GetRoomEngine().activeRoomId, openMessage.objectId, RoomObjectCategory.FLOOR, RoomObjectVariable.FURNITURE_DISABLE_PICKING_ANIMATION, 1);
break;
}
}
return null;
}
public imageReady(id: number, texture: NitroRenderTexture, image: HTMLImageElement = null): void
{
let imageUrl: string = null;
if(image) imageUrl = image.src;
else if(texture) imageUrl = TextureUtils.generateImageUrl(texture);
this.container.eventDispatcher.dispatchEvent(new RoomWidgetUpdatePresentDataEvent(RoomWidgetUpdatePresentDataEvent.CONTENTS_IMAGE, 0, this._name, false, imageUrl));
}
public imageFailed(id: number): void
{
}
public get type(): string
{
return RoomWidgetEnum.FURNI_PRESENT_WIDGET;
}
public get eventTypes(): string[]
{
return [
RoomSessionPresentEvent.RSPE_PRESENT_OPENED
];
}
public get messageTypes(): string[]
{
return [
RoomWidgetFurniToWidgetMessage.REQUEST_PRESENT,
RoomWidgetPresentOpenMessage.OPEN_PRESENT
];
}
}

View File

@ -1,61 +0,0 @@
import { NitroEvent, RoomObjectVariable, RoomWidgetEnum } from '@nitrots/nitro-renderer';
import { RoomWidgetUpdateEvent } from '..';
import { GetRoomEngine } from '../..';
import { RoomWidgetFurniToWidgetMessage, RoomWidgetMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class FurnitureTrophyWidgetHandler extends RoomWidgetHandler
{
public processEvent(event: NitroEvent): void
{
return;
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
switch(message.type)
{
case RoomWidgetFurniToWidgetMessage.REQUEST_TROPHY: {
const widgetMessage = (message as RoomWidgetFurniToWidgetMessage);
const roomObject = GetRoomEngine().getRoomObject(widgetMessage.roomId, widgetMessage.objectId, widgetMessage.category);
if(!roomObject) return;
const color = roomObject.model.getValue<number>(RoomObjectVariable.FURNITURE_COLOR);
const extra = parseInt(roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_EXTRAS));
let data = roomObject.model.getValue<string>(RoomObjectVariable.FURNITURE_DATA);
const ownerName = data.substring(0, data.indexOf('\t'));
data = data.substring((ownerName.length + 1), data.length);
const date = data.substring(0, data.indexOf('\t'));
const text = data.substr((date.length + 1), data.length);
break;
}
}
return null;
}
public get type(): string
{
return RoomWidgetEnum.FURNI_TROPHY_WIDGET;
}
public get eventTypes(): string[]
{
return [];
}
public get messageTypes(): string[]
{
return [
RoomWidgetFurniToWidgetMessage.REQUEST_TROPHY
];
}
}

View File

@ -3,7 +3,7 @@ import { GetClubMemberLevel, GetConfiguration, GetNitroInstance, SendMessageComp
import { GetRoomEngine, GetSessionDataManager, LocalizeText, NotificationUtilities } from '../../../..';
import { CreateLinkEvent } from '../../../CreateLinkEvent';
import { RoomWidgetFloodControlEvent, RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetChatMessage, RoomWidgetChatSelectAvatarMessage, RoomWidgetChatTypingMessage, RoomWidgetMessage, RoomWidgetRequestWidgetMessage } from '../messages';
import { RoomWidgetChatMessage, RoomWidgetChatSelectAvatarMessage, RoomWidgetChatTypingMessage, RoomWidgetMessage } from '../messages';
import { RoomWidgetHandler } from './RoomWidgetHandler';
export class RoomWidgetChatInputHandler extends RoomWidgetHandler
@ -148,12 +148,10 @@ export class RoomWidgetChatInputHandler extends RoomWidgetHandler
return null;
case ':furni':
this.container.processWidgetMessage(new RoomWidgetRequestWidgetMessage(RoomWidgetRequestWidgetMessage.FURNI_CHOOSER));
CreateLinkEvent('furni-chooser/');
return null;
case ':chooser':
this.container.processWidgetMessage(new RoomWidgetRequestWidgetMessage(RoomWidgetRequestWidgetMessage.USER_CHOOSER));
CreateLinkEvent('user-chooser/');
return null;
case ':floor':
case ':bcfloor':

View File

@ -1,78 +0,0 @@
import { NitroEvent, RoomObjectCategory, RoomWidgetEnum } from '@nitrots/nitro-renderer';
import { RoomWidgetHandler } from '.';
import { GetRoomEngine } from '../../../..';
import { RoomObjectItem, RoomWidgetChooserContentEvent, RoomWidgetUpdateEvent } from '../events';
import { RoomWidgetMessage, RoomWidgetRequestWidgetMessage, RoomWidgetRoomObjectMessage } from '../messages';
export class UserChooserWidgetHandler extends RoomWidgetHandler
{
public processEvent(event: NitroEvent): void
{
}
public processWidgetMessage(message: RoomWidgetMessage): RoomWidgetUpdateEvent
{
if(!message) return null;
switch(message.type)
{
case RoomWidgetRequestWidgetMessage.USER_CHOOSER:
this.processChooser();
break;
case RoomWidgetRoomObjectMessage.SELECT_OBJECT:
this.selectRoomObject((message as RoomWidgetRoomObjectMessage));
break;
}
return null;
}
private processChooser(): void
{
const roomId = this.container.roomSession.roomId;
const items: RoomObjectItem[] = [];
const userItems = GetRoomEngine().getRoomObjects(roomId, RoomObjectCategory.UNIT);
userItems.forEach(roomObject =>
{
const userData = this.container.roomSession.userDataManager.getUserDataByIndex(roomObject.id);
if(!userData) return;
items.push(new RoomObjectItem(userData.roomIndex, RoomObjectCategory.UNIT, userData.name));
});
items.sort((a, b) =>
{
return (a.name < b.name) ? -1 : 1;
});
this.container.eventDispatcher.dispatchEvent(new RoomWidgetChooserContentEvent(RoomWidgetChooserContentEvent.USER_CHOOSER_CONTENT, items));
}
private selectRoomObject(message: RoomWidgetRoomObjectMessage): void
{
if(message.category !== RoomObjectCategory.UNIT) return;
GetRoomEngine().selectRoomObject(this.container.roomSession.roomId, message.id, message.category);
}
public get type(): string
{
return RoomWidgetEnum.USER_CHOOSER;
}
public get eventTypes(): string[]
{
return [];
}
public get messageTypes(): string[]
{
return [
RoomWidgetRequestWidgetMessage.USER_CHOOSER,
RoomWidgetRoomObjectMessage.SELECT_OBJECT
];
}
}

View File

@ -1,14 +1,7 @@
export * from './FurniChooserWidgetHandler';
export * from './FurnitureContextMenuWidgetHandler';
export * from './FurnitureCreditWidgetHandler';
export * from './FurnitureCustomStackHeightWidgetHandler';
export * from './FurnitureDimmerWidgetHandler';
export * from './FurnitureExternalImageWidgetHandler';
export * from './FurnitureInternalLinkHandler';
export * from './FurnitureMannequinWidgetHandler';
export * from './FurniturePresentWidgetHandler';
export * from './FurnitureRoomLinkHandler';
export * from './FurnitureTrophyWidgetHandler';
export * from './FurnitureYoutubeDisplayWidgetHandler';
export * from './IRoomWidgetHandler';
export * from './IRoomWidgetHandlerManager';
@ -19,5 +12,4 @@ export * from './RoomWidgetChatInputHandler';
export * from './RoomWidgetHandler';
export * from './RoomWidgetHandlerManager';
export * from './RoomWidgetInfostandHandler';
export * from './UserChooserWidgetHandler';
export * from './WordQuizWidgetHandler';

View File

@ -2,10 +2,6 @@ import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetFurniToWidgetMessage extends RoomWidgetMessage
{
public static REQUEST_CREDITFURNI: string = 'RWFWM_MESSAGE_REQUEST_CREDITFURNI';
public static REQUEST_STICKIE: string = 'RWFWM_MESSAGE_REQUEST_STICKIE';
public static REQUEST_PRESENT: string = 'RWFWM_MESSAGE_REQUEST_PRESENT';
public static REQUEST_TROPHY: string = 'RWFWM_MESSAGE_REQUEST_TROPHY';
public static REQUEST_TEASER: string = 'RWFWM_MESSAGE_REQUEST_TEASER';
public static REQUEST_ECOTRONBOX: string = 'RWFWM_MESSAGE_REQUEST_ECOTRONBOX';
public static REQUEST_DIMMER: string = 'RWFWM_MESSAGE_REQUEST_DIMMER';

View File

@ -1,20 +0,0 @@
import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetPresentOpenMessage extends RoomWidgetMessage
{
public static OPEN_PRESENT: string = 'RWPOM_OPEN_PRESENT';
private _objectId: number;
constructor(type: string, objectId: number)
{
super(type);
this._objectId = objectId;
}
public get objectId(): number
{
return this._objectId;
}
}

View File

@ -2,8 +2,6 @@ import { RoomWidgetMessage } from './RoomWidgetMessage';
export class RoomWidgetRequestWidgetMessage extends RoomWidgetMessage
{
public static USER_CHOOSER: string = 'RWRWM_USER_CHOOSER';
public static FURNI_CHOOSER: string = 'RWRWM_FURNI_CHOOSER';
public static ME_MENU: string = 'RWRWM_ME_MENU';
public static EFFECTS: string = 'RWRWM_EFFECTS';
public static FLOOR_EDITOR: string = 'RWRWM_FLOOR_EDITOR';

View File

@ -13,7 +13,6 @@ export * from './RoomWidgetFurniActionMessage';
export * from './RoomWidgetFurniToWidgetMessage';
export * from './RoomWidgetMessage';
export * from './RoomWidgetPollMessage';
export * from './RoomWidgetPresentOpenMessage';
export * from './RoomWidgetRequestWidgetMessage';
export * from './RoomWidgetRoomObjectMessage';
export * from './RoomWidgetUseProductMessage';

View File

@ -7,5 +7,5 @@ export function CanManipulateFurniture(roomSession: IRoomSession, objectId: numb
{
if(!roomSession) return false;
return ((roomSession.controllerLevel >= RoomControllerLevel.GUEST) || GetSessionDataManager().isModerator || IsOwnerOfFurniture(GetRoomEngine().getRoomObject(roomSession.roomId, objectId, category)));
return (roomSession.isRoomOwner || (roomSession.controllerLevel >= RoomControllerLevel.GUEST) || GetSessionDataManager().isModerator || IsOwnerOfFurniture(GetRoomEngine().getRoomObject(roomSession.roomId, objectId, category)));
}

1
src/api/room/index.ts Normal file
View File

@ -0,0 +1 @@
export * from './widgets';

View File

@ -0,0 +1,39 @@
import { AvatarFigurePartType, IAvatarFigureContainer } from '@nitrots/nitro-renderer';
import { GetAvatarRenderManager } from '../../nitro';
const MANNEQUIN_FIGURE = [ 'hd', 99999, [ 99998 ] ];
const MANNEQUIN_CLOTHING_PART_TYPES = [
AvatarFigurePartType.CHEST_ACCESSORY,
AvatarFigurePartType.COAT_CHEST,
AvatarFigurePartType.CHEST,
AvatarFigurePartType.LEGS,
AvatarFigurePartType.SHOES,
AvatarFigurePartType.WAIST_ACCESSORY
];
export const GetMergedMannequinFigureContainer = (figure: string, targetFigure: string) =>
{
const figureContainer = GetAvatarRenderManager().createFigureContainer(figure);
const targetFigureContainer = GetAvatarRenderManager().createFigureContainer(targetFigure);
for(const part of MANNEQUIN_CLOTHING_PART_TYPES) figureContainer.removePart(part);
for(const part of targetFigureContainer.getPartTypeIds())
{
figureContainer.updatePart(part, targetFigureContainer.getPartSetId(part), targetFigureContainer.getPartColorIds(part));
}
return figureContainer;
}
export const TransformAsMannequinFigure = (figureContainer: IAvatarFigureContainer) =>
{
for(const part of figureContainer.getPartTypeIds())
{
if(MANNEQUIN_CLOTHING_PART_TYPES.indexOf(part) >= 0) continue;
figureContainer.removePart(part);
}
figureContainer.updatePart((MANNEQUIN_FIGURE[0] as string), (MANNEQUIN_FIGURE[1] as number), (MANNEQUIN_FIGURE[2] as number[]));
};

View File

@ -0,0 +1 @@
export * from './MannequinUtilities';