Group fixes

This commit is contained in:
Bill 2021-08-31 01:17:28 -04:00
parent ff95658be4
commit 8b6b9c0d78
4 changed files with 100 additions and 14 deletions

View File

@ -50,7 +50,7 @@ export class RoomObjectVariable
public static FURNITURE_COLOR: string = 'furniture_color'; public static FURNITURE_COLOR: string = 'furniture_color';
public static FURNITURE_LIFT_AMOUNT: string = 'furniure_lift_amount'; 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_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_1: string = 'furniture_guild_customized_color_1';
public static FURNITURE_GUILD_CUSTOMIZED_COLOR_2: string = 'furniture_guild_customized_color_2'; public static FURNITURE_GUILD_CUSTOMIZED_COLOR_2: string = 'furniture_guild_customized_color_2';
public static FURNITURE_STATE_UPDATE_TIME: string = 'furniture_state_update_time'; public static FURNITURE_STATE_UPDATE_TIME: string = 'furniture_state_update_time';

View File

@ -1,5 +1,9 @@
import { IRoomGeometry, RoomSpriteMouseEvent } from '../../../../../room';
import { RoomObjectUpdateMessage } from '../../../../../room/messages/RoomObjectUpdateMessage'; import { RoomObjectUpdateMessage } from '../../../../../room/messages/RoomObjectUpdateMessage';
import { ContextMenuEnum } from '../../../../ui/widget/enums/ContextMenuEnum'; import { Nitro } from '../../../../Nitro';
import { MouseEventType } from '../../../../ui';
import { RoomObjectBadgeAssetEvent, RoomObjectWidgetRequestEvent } from '../../../events';
import { ObjectGroupBadgeUpdateMessage, ObjectSelectedMessage } from '../../../messages';
import { ObjectDataUpdateMessage } from '../../../messages/ObjectDataUpdateMessage'; import { ObjectDataUpdateMessage } from '../../../messages/ObjectDataUpdateMessage';
import { StringDataType } from '../../data/type/StringDataType'; import { StringDataType } from '../../data/type/StringDataType';
import { RoomObjectVariable } from '../../RoomObjectVariable'; import { RoomObjectVariable } from '../../RoomObjectVariable';
@ -12,6 +16,17 @@ export class FurnitureGuildCustomizedLogic extends FurnitureMultiStateLogic
public static COLOR1_KEY: number = 3; public static COLOR1_KEY: number = 3;
public static COLOR2_KEY: number = 4; 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 public processUpdateMessage(message: RoomObjectUpdateMessage): void
{ {
super.processUpdateMessage(message); super.processUpdateMessage(message);
@ -27,6 +42,24 @@ export class FurnitureGuildCustomizedLogic extends FurnitureMultiStateLogic
this.updateColors(data.getValue(FurnitureGuildCustomizedLogic.COLOR1_KEY), data.getValue(FurnitureGuildCustomizedLogic.COLOR2_KEY)); 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 protected updateGroupId(id: string): void
@ -36,7 +69,7 @@ export class FurnitureGuildCustomizedLogic extends FurnitureMultiStateLogic
private updateBadge(badge: string): void 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 public updateColors(color1: string, color2: string): void
@ -45,8 +78,21 @@ export class FurnitureGuildCustomizedLogic extends FurnitureMultiStateLogic
this.object.model.setValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_COLOR_2, parseInt(color2, 16)); this.object.model.setValue(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_COLOR_2, parseInt(color2, 16));
} }
public get contextMenu(): string public mouseEvent(event: RoomSpriteMouseEvent, geometry: IRoomGeometry): void
{ {
return ContextMenuEnum.GROUP_FURNITURE; 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));
} }
} }

View File

@ -1,27 +1,44 @@
import { IGraphicAsset, IRoomObjectSprite } from '../../../../../room';
import { RoomObjectVariable } from '../../RoomObjectVariable'; import { RoomObjectVariable } from '../../RoomObjectVariable';
import { FurnitureAnimatedVisualization } from './FurnitureAnimatedVisualization'; import { FurnitureAnimatedVisualization } from './FurnitureAnimatedVisualization';
export class FurnitureGuildCustomizedVisualization extends FurnitureAnimatedVisualization export class FurnitureGuildCustomizedVisualization extends FurnitureAnimatedVisualization
{ {
public static DEFAULT_COLOR_1: number = 0xEEEEEE; public static PRIMARY_COLOUR_SPRITE_TAG: string = 'COLOR1';
public static DEFAULT_COLOR_2: number = 0x4B4B4B; 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 _color1: number;
private _color2: number; private _color2: number;
private _badgeAssetNameNormalScale: string;
private _badgeAssetNameSmallScale: string;
constructor() constructor()
{ {
super(); super();
this._color1 = FurnitureGuildCustomizedVisualization.DEFAULT_COLOR_1; this._color1 = FurnitureGuildCustomizedVisualization.DEFAULT_COLOR_1;
this._color2 = FurnitureGuildCustomizedVisualization.DEFAULT_COLOR_2; this._color2 = FurnitureGuildCustomizedVisualization.DEFAULT_COLOR_2;
this._badgeAssetNameNormalScale = '';
this._badgeAssetNameSmallScale = '';
} }
protected updateModel(scale: number): boolean protected updateModel(scale: number): boolean
{ {
const flag = super.updateModel(scale); const flag = super.updateModel(scale);
if(!flag) return false; if(this._badgeAssetNameNormalScale === '')
{
const assetName = this.object.model.getValue<string>(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_ASSET_NAME);
if(assetName)
{
this._badgeAssetNameNormalScale = assetName;
this._badgeAssetNameSmallScale = (this._badgeAssetNameNormalScale + '_32');
}
}
this._color1 = this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_COLOR_1); this._color1 = this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_COLOR_1);
this._color2 = this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_COLOR_2); this._color2 = this.object.model.getValue<number>(RoomObjectVariable.FURNITURE_GUILD_CUSTOMIZED_COLOR_2);
@ -35,10 +52,34 @@ export class FurnitureGuildCustomizedVisualization extends FurnitureAnimatedVisu
switch(tag) switch(tag)
{ {
case 'COLOR1': return this._color1; case FurnitureGuildCustomizedVisualization.PRIMARY_COLOUR_SPRITE_TAG: return this._color1;
case 'COLOR2': return this._color2; case FurnitureGuildCustomizedVisualization.SECONDARY_COLOUR_SPRITE_TAG: return this._color2;
} }
return super.getLayerColor(scale, layerId, colorId); return super.getLayerColor(scale, layerId, colorId);
} }
}
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);
}
}

View File

@ -8,6 +8,5 @@ export class ContextMenuEnum
public static MYSTERY_TROPHY: string = 'MYSTERY_TROPHY'; public static MYSTERY_TROPHY: string = 'MYSTERY_TROPHY';
public static RANDOM_TELEPORT: string = 'RANDOM_TELEPORT'; public static RANDOM_TELEPORT: string = 'RANDOM_TELEPORT';
public static PURCHASABLE_CLOTHING: string = 'PURCHASABLE_CLOTHING'; public static PURCHASABLE_CLOTHING: string = 'PURCHASABLE_CLOTHING';
public static GROUP_FURNITURE: string = 'GROUP_FURNITURE';
public static GENERIC_USABLE: string = 'GENERIC_USABLE'; public static GENERIC_USABLE: string = 'GENERIC_USABLE';
} }