diff --git a/src/core/utils/proxy/NitroAlphaFilter.ts b/src/core/utils/proxy/NitroAlphaFilter.ts new file mode 100644 index 00000000..26eba360 --- /dev/null +++ b/src/core/utils/proxy/NitroAlphaFilter.ts @@ -0,0 +1,4 @@ +import { AlphaFilter } from '@pixi/filter-alpha'; + +export class NitroAlphaFilter extends AlphaFilter +{} diff --git a/src/core/utils/proxy/index.ts b/src/core/utils/proxy/index.ts index 95551ec3..e1fc28b5 100644 --- a/src/core/utils/proxy/index.ts +++ b/src/core/utils/proxy/index.ts @@ -1,5 +1,6 @@ export * from './INitroPoint'; export * from './NitroAdjustmentFilter'; +export * from './NitroAlphaFilter'; export * from './NitroContainer'; export * from './NitroFilter'; export * from './NitroPoint'; diff --git a/src/nitro/avatar/AvatarRenderManager.ts b/src/nitro/avatar/AvatarRenderManager.ts index 5675bec1..391abd02 100644 --- a/src/nitro/avatar/AvatarRenderManager.ts +++ b/src/nitro/avatar/AvatarRenderManager.ts @@ -352,7 +352,7 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa return !(isValid); } - public getFigureClubLevel(container: IAvatarFigureContainer, gender: string, searchParts: string[]): number + public getFigureClubLevel(container: IAvatarFigureContainer, gender: string, searchParts: string[] = null): number { if(!this._structure) return 0; @@ -363,7 +363,10 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa for(const part of parts) { - const set = figureData.getSetType(part); + const set = figureData.getSetType(part); + + if(!set) continue; + const setId = container.getPartSetId(part); const partSet = set.getPartSet(setId); @@ -378,6 +381,8 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa { const color = palette.getColor(colorId); + if(!color) continue; + clubLevel = Math.max(color.clubLevel, clubLevel); } } @@ -389,6 +394,8 @@ export class AvatarRenderManager extends NitroManager implements IAvatarRenderMa { const set = figureData.getSetType(part); + if(!set) continue; + if(parts.indexOf(part) === -1) clubLevel = Math.max(set.optionalFromClubLevel(gender), clubLevel); } diff --git a/src/nitro/avatar/IAvatarRenderManager.ts b/src/nitro/avatar/IAvatarRenderManager.ts index 3bee9b2b..5b380022 100644 --- a/src/nitro/avatar/IAvatarRenderManager.ts +++ b/src/nitro/avatar/IAvatarRenderManager.ts @@ -15,7 +15,7 @@ export interface IAvatarRenderManager extends INitroManager isFigureContainerReady(container: IAvatarFigureContainer): boolean; createAvatarImage(figure: string, size: string, gender: string, listener?: IAvatarImageListener, effectListener?: IAvatarEffectListener): IAvatarImage; downloadAvatarFigure(container: IAvatarFigureContainer, listener: IAvatarImageListener): void; - getFigureClubLevel(container: IAvatarFigureContainer, gender: string, searchParts: string[]): number; + getFigureClubLevel(container: IAvatarFigureContainer, gender: string, searchParts?: string[]): number; isValidFigureSetForGender(setId: number, gender: string): boolean; getFigureStringWithFigureIds(k: string, _arg_2: string, _arg_3: number[]): string; getMandatoryAvatarPartSetIds(k: string, _arg_2: number): string[]; diff --git a/src/nitro/avatar/structure/figure/PartColor.ts b/src/nitro/avatar/structure/figure/PartColor.ts index 06e558b5..0bd79036 100644 --- a/src/nitro/avatar/structure/figure/PartColor.ts +++ b/src/nitro/avatar/structure/figure/PartColor.ts @@ -13,11 +13,11 @@ export class PartColor implements IPartColor { if(!data) throw new Error('invalid_data'); - this._id = data.id; - this._index = data.index; - this._clubLevel = data.club; - this._isSelectable = data.selectable; - this._rgb = parseInt('0x' + data.hexCode, 16); + this._id = data.id; + this._index = data.index; + this._clubLevel = (data.club || 0); + this._isSelectable = data.selectable; + this._rgb = parseInt('0x' + data.hexCode, 16); } public get id(): number diff --git a/src/nitro/communication/NitroMessages.ts b/src/nitro/communication/NitroMessages.ts index d18910ad..3fdf2e18 100644 --- a/src/nitro/communication/NitroMessages.ts +++ b/src/nitro/communication/NitroMessages.ts @@ -1,5 +1,5 @@ import { IMessageConfiguration } from '../../core/communication/messages/IMessageConfiguration'; -import { AchievementNotificationMessageEvent, ActivityPointNotificationMessageEvent, AddJukeboxDiskComposer, ApproveNameMessageComposer, ApproveNameMessageEvent, AvailabilityTimeMessageEvent, BadgeReceivedEvent, BonusRareInfoMessageEvent, BuildersClubFurniCountMessageEvent, BuildersClubSubscriptionStatusMessageEvent, BundleDiscountRulesetMessageEvent, ChangeUserNameMessageComposer, ChangeUserNameResultMessageEvent, CheckUserNameMessageComposer, CheckUserNameResultMessageEvent, ClubGiftNotificationEvent, DirectSMSClubBuyAvailableMessageEvent, FigureUpdateEvent, FurnitureGuildInfoComposer, GetBonusRareInfoMessageComposer, GetCatalogPageExpirationComposer, GetCatalogPageWithEarliestExpiryComposer, GetDirectClubBuyAvailableComposer, GetHabboBasicMembershipExtendOfferComposer, GetHabboClubExtendOfferMessageComposer, GetInterstitialMessageComposer, GetJukeboxPlayListMessageComposer, GetLimitedOfferAppearingNextComposer, GetNextTargetedOfferComposer, GetNowPlayingMessageComposer, GetOfficialSongIdMessageComposer, GetRoomAdPurchaseInfoComposer, GetSeasonalCalendarDailyOfferComposer, GetSongInfoMessageComposer, GetSoundMachinePlayListMessageComposer, GetUserSongDisksMessageComposer, HabboClubExtendOfferMessageEvent, HotelClosedAndOpensEvent, HotelClosesAndWillOpenAtEvent, HotelWillCloseInMinutesEvent, InfoFeedEnableMessageEvent, InterstitialMessageEvent, InterstitialShownMessageComposer, IsOfferGiftableMessageEvent, JukeboxPlayListFullMessageEvent, JukeboxSongDisksMessageEvent, LimitedOfferAppearingNextMessageEvent, MaintenanceStatusMessageEvent, MarkCatalogNewAdditionsPageOpenedComposer, MarketplaceBuyOfferComposer, MarketplaceRedeemCreditsComposer, MarketplaceRequesstItemStatsComposer, MarketplaceRequestComposer, MarketplaceRequestOffersComposer, MarketplaceRequestOwnItemsComposer, MarketplaceTakeItemBackComposer, MysteryBoxKeysEvent, NotEnoughBalanceMessageEvent, NowPlayingMessageEvent, OfficialSongIdMessageEvent, OpenCampaignCalendarDoorAsStaffComposer, OpenCampaignCalendarDoorComposer, PetExperienceEvent, PetMountComposer, PetSupplementComposer, PlayListMessageEvent, PlayListSongAddedMessageEvent, PurchaseBasicMembershipExtensionComposer, PurchaseRoomAdMessageComposer, PurchaseTargetedOfferComposer, PurchaseVipMembershipExtensionComposer, RemoveAllRightsMessageComposer, RemoveJukeboxDiskComposer, RemoveOwnRoomRightsRoomMessageComposer, RemovePetSaddleComposer, RoomAdErrorEvent, RoomAdPurchaseInfoEvent, RoomUnitGiveHandItemPetComposer, SeasonalCalendarDailyOfferMessageEvent, SellablePetPalettesMessageEvent, SetTargetedOfferStateComposer, ShopTargetedOfferViewedComposer, TargetedOfferEvent, TargetedOfferNotFoundEvent, TogglePetBreedingComposer, TogglePetRidingComposer, TraxSongInfoMessageEvent, UnseenResetCategoryComposer, UnseenResetItemsComposer, UsePetProductComposer, UserSongDisksInventoryMessageEvent, WardrobeMessageEvent } from './messages'; +import { AchievementNotificationMessageEvent, ActivityPointNotificationMessageEvent, AddJukeboxDiskComposer, ApproveNameMessageComposer, ApproveNameMessageEvent, AvailabilityTimeMessageEvent, BadgeReceivedEvent, BonusRareInfoMessageEvent, BuildersClubFurniCountMessageEvent, BuildersClubSubscriptionStatusMessageEvent, BundleDiscountRulesetMessageEvent, ChangeUserNameMessageComposer, ChangeUserNameResultMessageEvent, CheckUserNameMessageComposer, CheckUserNameResultMessageEvent, ClubGiftNotificationEvent, DirectSMSClubBuyAvailableMessageEvent, FigureUpdateEvent, FurnitureGroupInfoComposer, GetBonusRareInfoMessageComposer, GetCatalogPageExpirationComposer, GetCatalogPageWithEarliestExpiryComposer, GetDirectClubBuyAvailableComposer, GetHabboBasicMembershipExtendOfferComposer, GetHabboClubExtendOfferMessageComposer, GetInterstitialMessageComposer, GetJukeboxPlayListMessageComposer, GetLimitedOfferAppearingNextComposer, GetNextTargetedOfferComposer, GetNowPlayingMessageComposer, GetOfficialSongIdMessageComposer, GetRoomAdPurchaseInfoComposer, GetSeasonalCalendarDailyOfferComposer, GetSongInfoMessageComposer, GetSoundMachinePlayListMessageComposer, GetUserSongDisksMessageComposer, HabboClubExtendOfferMessageEvent, HotelClosedAndOpensEvent, HotelClosesAndWillOpenAtEvent, HotelWillCloseInMinutesEvent, InfoFeedEnableMessageEvent, InterstitialMessageEvent, InterstitialShownMessageComposer, IsOfferGiftableMessageEvent, JukeboxPlayListFullMessageEvent, JukeboxSongDisksMessageEvent, LimitedOfferAppearingNextMessageEvent, MaintenanceStatusMessageEvent, MarkCatalogNewAdditionsPageOpenedComposer, MarketplaceBuyOfferComposer, MarketplaceRedeemCreditsComposer, MarketplaceRequesstItemStatsComposer, MarketplaceRequestComposer, MarketplaceRequestOffersComposer, MarketplaceRequestOwnItemsComposer, MarketplaceTakeItemBackComposer, MysteryBoxKeysEvent, NotEnoughBalanceMessageEvent, NowPlayingMessageEvent, OfficialSongIdMessageEvent, OpenCampaignCalendarDoorAsStaffComposer, OpenCampaignCalendarDoorComposer, PetExperienceEvent, PetMountComposer, PetSupplementComposer, PlayListMessageEvent, PlayListSongAddedMessageEvent, PurchaseBasicMembershipExtensionComposer, PurchaseRoomAdMessageComposer, PurchaseTargetedOfferComposer, PurchaseVipMembershipExtensionComposer, RemoveAllRightsMessageComposer, RemoveJukeboxDiskComposer, RemoveOwnRoomRightsRoomMessageComposer, RemovePetSaddleComposer, RoomAdErrorEvent, RoomAdPurchaseInfoEvent, RoomUnitGiveHandItemPetComposer, SeasonalCalendarDailyOfferMessageEvent, SellablePetPalettesMessageEvent, SetTargetedOfferStateComposer, ShopTargetedOfferViewedComposer, TargetedOfferEvent, TargetedOfferNotFoundEvent, TogglePetBreedingComposer, TogglePetRidingComposer, TraxSongInfoMessageEvent, UnseenResetCategoryComposer, UnseenResetItemsComposer, UsePetProductComposer, UserSongDisksInventoryMessageEvent, WardrobeMessageEvent } from './messages'; import { AvailabilityStatusMessageEvent } from './messages/incoming/availability/AvailabilityStatusMessageEvent'; import { CfhSanctionMessageEvent, CfhTopicsInitEvent, SanctionStatusEvent } from './messages/incoming/callforhelp'; import { CameraPublishStatusMessageEvent } from './messages/incoming/camera/CameraPublishStatusMessageEvent'; @@ -158,6 +158,7 @@ import { FurnitureItemDataEvent } from './messages/incoming/room/furniture/Furni import { FurnitureStackHeightEvent } from './messages/incoming/room/furniture/FurnitureStackHeightEvent'; import { FurnitureState2Event } from './messages/incoming/room/furniture/FurnitureState2Event'; import { FurnitureStateEvent } from './messages/incoming/room/furniture/FurnitureStateEvent'; +import { GroupFurniContextMenuInfoMessageEvent } from './messages/incoming/room/furniture/GroupFurniContextMenuInfoMessageEvent'; import { LoveLockFurniFinishedEvent } from './messages/incoming/room/furniture/LoveLockFurniFinishedEvent'; import { LoveLockFurniFriendConfirmedEvent } from './messages/incoming/room/furniture/LoveLockFurniFriendConfirmedEvent'; import { LoveLockFurniStartEvent } from './messages/incoming/room/furniture/LoveLockFurniStartEvent'; @@ -701,6 +702,7 @@ export class NitroMessages implements IMessageConfiguration this._events.set(IncomingHeader.LOVELOCK_FURNI_FRIEND_COMFIRMED, LoveLockFurniFriendConfirmedEvent); this._events.set(IncomingHeader.LOVELOCK_FURNI_START, LoveLockFurniStartEvent); this._events.set(IncomingHeader.OBJECTS_DATA_UPDATE, ObjectsDataUpdateEvent); + this._events.set(IncomingHeader.FURNITURE_GROUP_CONTEXT_MENU_INFO, GroupFurniContextMenuInfoMessageEvent); // FLOOR this._events.set(IncomingHeader.FURNITURE_FLOOR_ADD, FurnitureFloorAddEvent); @@ -1078,7 +1080,7 @@ export class NitroMessages implements IMessageConfiguration // FURNITURE this._composers.set(OutgoingHeader.FURNITURE_ALIASES, FurnitureAliasesComposer); - this._composers.set(OutgoingHeader.FURNITURE_GUILD_INFO, FurnitureGuildInfoComposer); + this._composers.set(OutgoingHeader.FURNITURE_GROUP_INFO, FurnitureGroupInfoComposer); this._composers.set(OutgoingHeader.FURNITURE_PICKUP, FurniturePickupComposer); this._composers.set(OutgoingHeader.FURNITURE_PLACE, FurniturePlaceComposer); this._composers.set(OutgoingHeader.ITEM_PAINT, FurniturePlacePaintComposer); diff --git a/src/nitro/communication/messages/incoming/IncomingHeader.ts b/src/nitro/communication/messages/incoming/IncomingHeader.ts index b8d24cbf..711e88d8 100644 --- a/src/nitro/communication/messages/incoming/IncomingHeader.ts +++ b/src/nitro/communication/messages/incoming/IncomingHeader.ts @@ -30,6 +30,7 @@ export class IncomingHeader public static FURNITURE_FLOOR_UPDATE = 3776; public static FURNITURE_ITEMDATA = 2202; public static FURNITURE_STATE = 2376; + public static FURNITURE_GROUP_CONTEXT_MENU_INFO= 3293; public static GAME_CENTER_ACHIEVEMENTS = 2265; public static GAME_CENTER_GAME_LIST = 222; public static GAME_CENTER_STATUS = 2893; diff --git a/src/nitro/communication/messages/incoming/room/furniture/GroupFurniContextMenuInfoMessageEvent.ts b/src/nitro/communication/messages/incoming/room/furniture/GroupFurniContextMenuInfoMessageEvent.ts new file mode 100644 index 00000000..6dd79a19 --- /dev/null +++ b/src/nitro/communication/messages/incoming/room/furniture/GroupFurniContextMenuInfoMessageEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '../../../../../../core/communication/messages/IMessageEvent'; +import { MessageEvent } from '../../../../../../core/communication/messages/MessageEvent'; +import { GroupFurniContextMenuInfoMessageParser } from '../../../parser/room/furniture/GroupFurniContextMenuInfoMessageParser'; + +export class GroupFurniContextMenuInfoMessageEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, GroupFurniContextMenuInfoMessageParser); + } + + public getParser(): GroupFurniContextMenuInfoMessageParser + { + return this.parser as GroupFurniContextMenuInfoMessageParser; + } +} diff --git a/src/nitro/communication/messages/incoming/room/furniture/index.ts b/src/nitro/communication/messages/incoming/room/furniture/index.ts index 27e8ec63..6f6d34fe 100644 --- a/src/nitro/communication/messages/incoming/room/furniture/index.ts +++ b/src/nitro/communication/messages/incoming/room/furniture/index.ts @@ -5,6 +5,7 @@ export * from './FurnitureItemDataEvent'; export * from './FurnitureStackHeightEvent'; export * from './FurnitureState2Event'; export * from './FurnitureStateEvent'; +export * from './GroupFurniContextMenuInfoMessageEvent'; export * from './LoveLockFurniFinishedEvent'; export * from './LoveLockFurniFriendConfirmedEvent'; export * from './LoveLockFurniStartEvent'; diff --git a/src/nitro/communication/messages/outgoing/OutgoingHeader.ts b/src/nitro/communication/messages/outgoing/OutgoingHeader.ts index 85dcb7fd..43ce08c0 100644 --- a/src/nitro/communication/messages/outgoing/OutgoingHeader.ts +++ b/src/nitro/communication/messages/outgoing/OutgoingHeader.ts @@ -231,7 +231,7 @@ export class OutgoingHeader public static UNIT_GIVE_HANDITEM_PET = 2768; public static PET_MOUNT = 1036; public static PET_SUPPLEMENT = 749; - public static FURNITURE_GUILD_INFO = 2651; + public static FURNITURE_GROUP_INFO = 2651; public static ACHIEVEMENT_RESOLUTION_OPEN = 359; public static USE_PET_PRODUCT = 1328; public static REMOVE_PET_SADDLE = 186; diff --git a/src/nitro/communication/messages/outgoing/room/furniture/FurnitureGuildInfoComposer.ts b/src/nitro/communication/messages/outgoing/room/furniture/FurnitureGroupInfoComposer.ts similarity index 64% rename from src/nitro/communication/messages/outgoing/room/furniture/FurnitureGuildInfoComposer.ts rename to src/nitro/communication/messages/outgoing/room/furniture/FurnitureGroupInfoComposer.ts index c14028ef..59c36316 100644 --- a/src/nitro/communication/messages/outgoing/room/furniture/FurnitureGuildInfoComposer.ts +++ b/src/nitro/communication/messages/outgoing/room/furniture/FurnitureGroupInfoComposer.ts @@ -1,8 +1,8 @@ import { IMessageComposer } from '../../../../../../core/communication/messages/IMessageComposer'; -export class FurnitureGuildInfoComposer implements IMessageComposer> +export class FurnitureGroupInfoComposer implements IMessageComposer> { - private _data: ConstructorParameters; + private _data: ConstructorParameters; constructor(objectId: number, guildId: number) { diff --git a/src/nitro/communication/messages/outgoing/room/furniture/index.ts b/src/nitro/communication/messages/outgoing/room/furniture/index.ts index 613f7303..c3ec36cf 100644 --- a/src/nitro/communication/messages/outgoing/room/furniture/index.ts +++ b/src/nitro/communication/messages/outgoing/room/furniture/index.ts @@ -1,7 +1,7 @@ export * from './dimmer'; export * from './floor'; export * from './FurnitureAliasesComposer'; -export * from './FurnitureGuildInfoComposer'; +export * from './FurnitureGroupInfoComposer'; export * from './FurniturePickupComposer'; export * from './FurniturePlaceComposer'; export * from './FurniturePlacePaintComposer'; diff --git a/src/nitro/communication/messages/parser/room/furniture/GroupFurniContextMenuInfoMessageParser.ts b/src/nitro/communication/messages/parser/room/furniture/GroupFurniContextMenuInfoMessageParser.ts new file mode 100644 index 00000000..da3e8320 --- /dev/null +++ b/src/nitro/communication/messages/parser/room/furniture/GroupFurniContextMenuInfoMessageParser.ts @@ -0,0 +1,67 @@ +import { IMessageDataWrapper, IMessageParser } from '../../../../../../core'; + +export class GroupFurniContextMenuInfoMessageParser implements IMessageParser +{ + private _objectId: number; + private _guildId: number; + private _guildName: string; + private _guildHomeRoomId: number; + private _userIsMember: boolean; + private _guildHasReadableForum: boolean; + + public flush(): boolean + { + this._objectId = 0; + this._guildId = 0; + this._guildName = null; + this._guildHomeRoomId = 0; + this._userIsMember = false; + this._guildHasReadableForum = false; + + return true; + } + + public parse(wrapper: IMessageDataWrapper): boolean + { + if(!wrapper) return false; + + this._objectId = wrapper.readInt(); + this._guildId = wrapper.readInt(); + this._guildName = wrapper.readString(); + this._guildHomeRoomId = wrapper.readInt(); + this._userIsMember = wrapper.readBoolean(); + this._guildHasReadableForum = wrapper.readBoolean(); + + return true; + } + + public get objectId(): number + { + return this._objectId; + } + + public get guildId(): number + { + return this._guildId; + } + + public get guildName(): string + { + return this._guildName; + } + + public get guildHomeRoomId(): number + { + return this._guildHomeRoomId; + } + + public get userIsMember(): boolean + { + return this._userIsMember; + } + + public get guildHasReadableForum(): boolean + { + return this._guildHasReadableForum; + } +} diff --git a/src/nitro/communication/messages/parser/room/furniture/index.ts b/src/nitro/communication/messages/parser/room/furniture/index.ts index c4d77185..4e2216d4 100644 --- a/src/nitro/communication/messages/parser/room/furniture/index.ts +++ b/src/nitro/communication/messages/parser/room/furniture/index.ts @@ -5,6 +5,7 @@ export * from './FurnitureItemDataParser'; export * from './FurnitureStackHeightParser'; export * from './FurnitureState2Parser'; export * from './FurnitureStateParser'; +export * from './GroupFurniContextMenuInfoMessageParser'; export * from './LoveLockFurniFinishedParser'; export * from './LoveLockFurniFriendConfirmedParser'; export * from './LoveLockFurniStartParser'; diff --git a/src/nitro/communication/messages/parser/user/HabboGroupEntryData.ts b/src/nitro/communication/messages/parser/user/HabboGroupEntryData.ts index d8cb006c..c238e115 100644 --- a/src/nitro/communication/messages/parser/user/HabboGroupEntryData.ts +++ b/src/nitro/communication/messages/parser/user/HabboGroupEntryData.ts @@ -5,22 +5,22 @@ export class HabboGroupEntryData private _groupId: number; private _groupName: string; private _badgeCode: string; - private _Str_6751: string; - private _Str_6979: string; + private _colorA: string; + private _colorB: string; private _favourite: boolean; private _ownerId: number; - private _Str_19808: boolean; + private _hasForum: boolean; constructor(wrapper: IMessageDataWrapper) { this._groupId = wrapper.readInt(); this._groupName = wrapper.readString(); this._badgeCode = wrapper.readString(); - this._Str_6751 = wrapper.readString(); - this._Str_6979 = wrapper.readString(); + this._colorA = wrapper.readString(); + this._colorB = wrapper.readString(); this._favourite = wrapper.readBoolean(); this._ownerId = wrapper.readInt(); - this._Str_19808 = wrapper.readBoolean(); + this._hasForum = wrapper.readBoolean(); } public get groupId(): number @@ -38,14 +38,14 @@ export class HabboGroupEntryData return this._badgeCode; } - public get _Str_5845(): string + public get colorA(): string { - return this._Str_6751; + return this._colorA; } - public get _Str_6659(): string + public get colorB(): string { - return this._Str_6979; + return this._colorB; } public get favourite(): boolean @@ -58,8 +58,8 @@ export class HabboGroupEntryData return this._ownerId; } - public get _Str_21674(): boolean + public get hasForum(): boolean { - return this._Str_19808; + return this._hasForum; } } diff --git a/src/nitro/room/RoomObjectEventHandler.ts b/src/nitro/room/RoomObjectEventHandler.ts index a9ea903e..57a93491 100644 --- a/src/nitro/room/RoomObjectEventHandler.ts +++ b/src/nitro/room/RoomObjectEventHandler.ts @@ -11,7 +11,7 @@ import { IRoomGeometry } from '../../room/utils/IRoomGeometry'; import { IVector3D } from '../../room/utils/IVector3D'; import { RoomEnterEffect } from '../../room/utils/RoomEnterEffect'; import { Vector3d } from '../../room/utils/Vector3d'; -import { FurnitureGuildInfoComposer, SetObjectDataMessageComposer } from '../communication'; +import { FurnitureGroupInfoComposer, SetObjectDataMessageComposer } from '../communication'; import { BotPlaceComposer } from '../communication/messages/outgoing/room/engine/BotPlaceComposer'; import { GetItemDataComposer } from '../communication/messages/outgoing/room/engine/GetItemDataComposer'; import { PetMoveComposer } from '../communication/messages/outgoing/room/engine/PetMoveComposer'; @@ -814,7 +814,7 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou eventDispatcher.dispatchEvent(new RoomEngineUseProductEvent(RoomEngineUseProductEvent.USE_PRODUCT_FROM_ROOM, roomId, objectId, objectCategory)); return; case RoomObjectWidgetRequestEvent.GUILD_FURNI_CONTEXT_MENU: - this._roomEngine.connection.send(new FurnitureGuildInfoComposer(event.objectId, event.object.model.getValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_GUILD_ID))); + this._roomEngine.connection.send(new FurnitureGroupInfoComposer(event.objectId, event.object.model.getValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_GUILD_ID))); return; case RoomObjectWidgetRequestEvent.MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG: eventDispatcher.dispatchEvent(new RoomEngineTriggerWidgetEvent(RoomEngineTriggerWidgetEvent.REQUEST_MONSTERPLANT_SEED_PLANT_CONFIRMATION_DIALOG, roomId, objectId, objectCategory)); diff --git a/src/nitro/room/object/RoomObjectVariable.ts b/src/nitro/room/object/RoomObjectVariable.ts index be68b29a..db3c790d 100644 --- a/src/nitro/room/object/RoomObjectVariable.ts +++ b/src/nitro/room/object/RoomObjectVariable.ts @@ -50,7 +50,7 @@ export class RoomObjectVariable public static FURNITURE_COLOR: string = 'furniture_color'; public static FURNITURE_LIFT_AMOUNT: string = 'furniure_lift_amount'; public static FURNITURE_GUILD_CUSTOMIZED_GUILD_ID: string = 'furniture_guild_customized_guild_id'; - public static FURNITURE_GUILD_CUSTOMIZED_BADGE: string = 'furniture_guild_customized_badge'; + public static FURNITURE_GUILD_CUSTOMIZED_ASSET_NAME: string = 'furniture_guild_customized_asset_name'; public static FURNITURE_GUILD_CUSTOMIZED_COLOR_1: string = 'furniture_guild_customized_color_1'; public static FURNITURE_GUILD_CUSTOMIZED_COLOR_2: string = 'furniture_guild_customized_color_2'; public static FURNITURE_STATE_UPDATE_TIME: string = 'furniture_state_update_time'; diff --git a/src/nitro/room/object/logic/furniture/FurnitureGuildCustomizedLogic.ts b/src/nitro/room/object/logic/furniture/FurnitureGuildCustomizedLogic.ts index f8fdd361..ff2ff8f6 100644 --- a/src/nitro/room/object/logic/furniture/FurnitureGuildCustomizedLogic.ts +++ b/src/nitro/room/object/logic/furniture/FurnitureGuildCustomizedLogic.ts @@ -1,4 +1,9 @@ +import { IRoomGeometry, RoomSpriteMouseEvent } from '../../../../../room'; import { RoomObjectUpdateMessage } from '../../../../../room/messages/RoomObjectUpdateMessage'; +import { Nitro } from '../../../../Nitro'; +import { MouseEventType } from '../../../../ui'; +import { RoomObjectBadgeAssetEvent, RoomObjectWidgetRequestEvent } from '../../../events'; +import { ObjectGroupBadgeUpdateMessage, ObjectSelectedMessage } from '../../../messages'; import { ObjectDataUpdateMessage } from '../../../messages/ObjectDataUpdateMessage'; import { StringDataType } from '../../data/type/StringDataType'; import { RoomObjectVariable } from '../../RoomObjectVariable'; @@ -11,6 +16,17 @@ export class FurnitureGuildCustomizedLogic extends FurnitureMultiStateLogic public static COLOR1_KEY: number = 3; public static COLOR2_KEY: number = 4; + public getEventTypes(): string[] + { + const types = [ + RoomObjectBadgeAssetEvent.LOAD_BADGE, + RoomObjectWidgetRequestEvent.GUILD_FURNI_CONTEXT_MENU, + RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU + ]; + + return this.mergeTypes(super.getEventTypes(), types); + } + public processUpdateMessage(message: RoomObjectUpdateMessage): void { super.processUpdateMessage(message); @@ -26,6 +42,24 @@ export class FurnitureGuildCustomizedLogic extends FurnitureMultiStateLogic this.updateColors(data.getValue(FurnitureGuildCustomizedLogic.COLOR1_KEY), data.getValue(FurnitureGuildCustomizedLogic.COLOR2_KEY)); } } + + else if(message instanceof ObjectGroupBadgeUpdateMessage) + { + if(message.assetName !== 'loading_icon') + { + this.object.model.setValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_ASSET_NAME, message.assetName); + + this.update(Nitro.instance.time); + } + } + + else if(message instanceof ObjectSelectedMessage) + { + if(!message.selected) + { + this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.CLOSE_FURNI_CONTEXT_MENU, this.object)); + } + } } protected updateGroupId(id: string): void @@ -35,7 +69,7 @@ export class FurnitureGuildCustomizedLogic extends FurnitureMultiStateLogic private updateBadge(badge: string): void { - this.object.model.setValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_BADGE, badge); + this.eventDispatcher.dispatchEvent(new RoomObjectBadgeAssetEvent(RoomObjectBadgeAssetEvent.LOAD_BADGE, this.object, badge, true)); } public updateColors(color1: string, color2: string): void @@ -43,4 +77,22 @@ export class FurnitureGuildCustomizedLogic extends FurnitureMultiStateLogic this.object.model.setValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_COLOR_1, parseInt(color1, 16)); this.object.model.setValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_COLOR_2, parseInt(color2, 16)); } + + public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void + { + if(!event || !geometry || !this.object) return; + + switch(event.type) + { + case MouseEventType.MOUSE_CLICK: + this.openContextMenu(); + } + + super.mouseEvent(event, geometry); + } + + private openContextMenu(): void + { + this.eventDispatcher.dispatchEvent(new RoomObjectWidgetRequestEvent(RoomObjectWidgetRequestEvent.GUILD_FURNI_CONTEXT_MENU, this.object)); + } } diff --git a/src/nitro/room/object/visualization/furniture/FurnitureGuildCustomizedVisualization.ts b/src/nitro/room/object/visualization/furniture/FurnitureGuildCustomizedVisualization.ts index 9a9a0b47..d71ed348 100644 --- a/src/nitro/room/object/visualization/furniture/FurnitureGuildCustomizedVisualization.ts +++ b/src/nitro/room/object/visualization/furniture/FurnitureGuildCustomizedVisualization.ts @@ -1,27 +1,44 @@ +import { IGraphicAsset, IRoomObjectSprite } from '../../../../../room'; import { RoomObjectVariable } from '../../RoomObjectVariable'; import { FurnitureAnimatedVisualization } from './FurnitureAnimatedVisualization'; export class FurnitureGuildCustomizedVisualization extends FurnitureAnimatedVisualization { - public static DEFAULT_COLOR_1: number = 0xEEEEEE; - public static DEFAULT_COLOR_2: number = 0x4B4B4B; + public static PRIMARY_COLOUR_SPRITE_TAG: string = 'COLOR1'; + public static SECONDARY_COLOUR_SPRITE_TAG: string = 'COLOR2'; + public static BADGE: string = 'BADGE'; + public static DEFAULT_COLOR_1: number = 0xEEEEEE; + public static DEFAULT_COLOR_2: number = 0x4B4B4B; private _color1: number; private _color2: number; + private _badgeAssetNameNormalScale: string; + private _badgeAssetNameSmallScale: string; constructor() { super(); - this._color1 = FurnitureGuildCustomizedVisualization.DEFAULT_COLOR_1; - this._color2 = FurnitureGuildCustomizedVisualization.DEFAULT_COLOR_2; + this._color1 = FurnitureGuildCustomizedVisualization.DEFAULT_COLOR_1; + this._color2 = FurnitureGuildCustomizedVisualization.DEFAULT_COLOR_2; + this._badgeAssetNameNormalScale = ''; + this._badgeAssetNameSmallScale = ''; } protected updateModel(scale: number): boolean { const flag = super.updateModel(scale); - if(!flag) return false; + if(this._badgeAssetNameNormalScale === '') + { + const assetName = this.object.model.getValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_ASSET_NAME); + + if(assetName) + { + this._badgeAssetNameNormalScale = assetName; + this._badgeAssetNameSmallScale = (this._badgeAssetNameNormalScale + '_32'); + } + } this._color1 = this.object.model.getValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_COLOR_1); this._color2 = this.object.model.getValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_COLOR_2); @@ -35,10 +52,34 @@ export class FurnitureGuildCustomizedVisualization extends FurnitureAnimatedVisu switch(tag) { - case 'COLOR1': return this._color1; - case 'COLOR2': return this._color2; + case FurnitureGuildCustomizedVisualization.PRIMARY_COLOUR_SPRITE_TAG: return this._color1; + case FurnitureGuildCustomizedVisualization.SECONDARY_COLOUR_SPRITE_TAG: return this._color2; } return super.getLayerColor(scale, layerId, colorId); } -} \ No newline at end of file + + public getSpriteAssetName(scale: number, layerId: number): string + { + const tag = this.getLayerTag(scale, this._direction, layerId); + + if(tag === FurnitureGuildCustomizedVisualization.BADGE) + { + if(scale === 32) return this._badgeAssetNameSmallScale; + + return this._badgeAssetNameNormalScale; + } + + return super.getSpriteAssetName(scale, layerId); + } + + protected getLibraryAssetNameForSprite(asset: IGraphicAsset, sprite: IRoomObjectSprite): string + { + if(sprite.tag === FurnitureGuildCustomizedVisualization.BADGE) + { + return '%group.badge.url%' + sprite.libraryAssetName.replace('badge_', ''); + } + + return super.getLibraryAssetNameForSprite(asset, sprite); + } +}