mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
Merge branch 'Dev' into feat/wired-fixes-apr08
This commit is contained in:
@@ -1,9 +1,61 @@
|
||||
import { AvatarFigurePartType, AvatarScaleType, AvatarSetType, GetAssetManager, GetAvatarRenderManager, IFigurePart, IGraphicAsset, IPartColor, NitroAlphaFilter, NitroContainer, NitroRectangle, NitroSprite, TextureUtils } from '@nitrots/nitro-renderer';
|
||||
import { IAvatarEditorCategoryPartItem } from './IAvatarEditorCategoryPartItem';
|
||||
|
||||
const MAX_CACHE_BYTES = 200 * 1024 * 1024;
|
||||
|
||||
class LRUImageCache
|
||||
{
|
||||
private _cache: Map<string, string> = new Map();
|
||||
private _currentBytes: number = 0;
|
||||
|
||||
public get(key: string): string | undefined
|
||||
{
|
||||
const value = this._cache.get(key);
|
||||
|
||||
if(value !== undefined)
|
||||
{
|
||||
this._cache.delete(key);
|
||||
this._cache.set(key, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public set(key: string, value: string): void
|
||||
{
|
||||
if(this._cache.has(key))
|
||||
{
|
||||
const old = this._cache.get(key);
|
||||
|
||||
this._currentBytes -= (key.length + old.length) * 2;
|
||||
this._cache.delete(key);
|
||||
}
|
||||
|
||||
const entryBytes = (key.length + value.length) * 2;
|
||||
|
||||
while(this._currentBytes + entryBytes > MAX_CACHE_BYTES && this._cache.size > 0)
|
||||
{
|
||||
const firstKey = this._cache.keys().next().value;
|
||||
const firstValue = this._cache.get(firstKey);
|
||||
|
||||
this._currentBytes -= (firstKey.length + firstValue.length) * 2;
|
||||
this._cache.delete(firstKey);
|
||||
}
|
||||
|
||||
this._cache.set(key, value);
|
||||
this._currentBytes += entryBytes;
|
||||
}
|
||||
|
||||
public clear(): void
|
||||
{
|
||||
this._cache.clear();
|
||||
this._currentBytes = 0;
|
||||
}
|
||||
}
|
||||
|
||||
export class AvatarEditorThumbnailsHelper
|
||||
{
|
||||
private static THUMBNAIL_CACHE: Map<string, string> = new Map();
|
||||
private static THUMBNAIL_CACHE: LRUImageCache = new LRUImageCache();
|
||||
private static THUMB_DIRECTIONS: number[] = [ 2, 6, 0, 4, 3, 1 ];
|
||||
private static ALPHA_FILTER: NitroAlphaFilter = new NitroAlphaFilter({ alpha: 0.2 });
|
||||
private static DRAW_ORDER: string[] = [
|
||||
@@ -37,9 +89,18 @@ export class AvatarEditorThumbnailsHelper
|
||||
'ptr',
|
||||
];
|
||||
|
||||
private static getThumbnailKey(setType: string, part: IAvatarEditorCategoryPartItem): string
|
||||
private static getThumbnailKey(setType: string, part: IAvatarEditorCategoryPartItem, partColors?: IPartColor[], isDisabled?: boolean): string
|
||||
{
|
||||
return `${ setType }-${ part.partSet.id }`;
|
||||
let key = `${ setType }-${ part.partSet.id }`;
|
||||
|
||||
if(partColors?.length)
|
||||
{
|
||||
key += '-' + partColors.map(c => c?.rgb?.toString(16) ?? '0').join(',');
|
||||
}
|
||||
|
||||
if(isDisabled) key += '-d';
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
public static clearCache(): void
|
||||
@@ -51,7 +112,7 @@ export class AvatarEditorThumbnailsHelper
|
||||
{
|
||||
if(!setType || !setType.length || !part || !part.partSet || !part.partSet.parts || !part.partSet.parts.length) return null;
|
||||
|
||||
const thumbnailKey = this.getThumbnailKey(setType, part);
|
||||
const thumbnailKey = this.getThumbnailKey(setType, part, useColors ? partColors : null, isDisabled);
|
||||
const cached = this.THUMBNAIL_CACHE.get(thumbnailKey);
|
||||
|
||||
if(cached) return cached;
|
||||
@@ -145,7 +206,7 @@ export class AvatarEditorThumbnailsHelper
|
||||
{
|
||||
if(!figureString || !figureString.length) return null;
|
||||
|
||||
const thumbnailKey = figureString;
|
||||
const thumbnailKey = figureString + (isDisabled ? '-d' : '');
|
||||
const cached = this.THUMBNAIL_CACHE.get(thumbnailKey);
|
||||
|
||||
if(cached) return cached;
|
||||
|
||||
@@ -26,3 +26,4 @@ export * from './room/widgets';
|
||||
export * from './user';
|
||||
export * from './utils';
|
||||
export * from './wired';
|
||||
export * from './youtube';
|
||||
|
||||
@@ -9,8 +9,9 @@ export class NotificationBubbleItem
|
||||
private _notificationType: string;
|
||||
private _iconUrl: string;
|
||||
private _linkUrl: string;
|
||||
private _senderName: string;
|
||||
|
||||
constructor(message: string, notificationType: string = NotificationBubbleType.INFO, iconUrl: string = null, linkUrl: string = null)
|
||||
constructor(message: string, notificationType: string = NotificationBubbleType.INFO, iconUrl: string = null, linkUrl: string = null, senderName: string = '')
|
||||
{
|
||||
NotificationBubbleItem.ITEM_ID += 1;
|
||||
|
||||
@@ -19,6 +20,7 @@ export class NotificationBubbleItem
|
||||
this._notificationType = notificationType;
|
||||
this._iconUrl = iconUrl;
|
||||
this._linkUrl = linkUrl;
|
||||
this._senderName = senderName;
|
||||
}
|
||||
|
||||
public get id(): number
|
||||
@@ -45,4 +47,9 @@ export class NotificationBubbleItem
|
||||
{
|
||||
return this._linkUrl;
|
||||
}
|
||||
|
||||
public get senderName(): string
|
||||
{
|
||||
return this._senderName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { GetConfigurationValue } from '../nitro/GetConfigurationValue';
|
||||
import { LocalizeText } from './LocalizeText';
|
||||
|
||||
const allowedColours: Map<string, string> = new Map();
|
||||
@@ -47,16 +46,6 @@ export const RoomChatFormatter = (content: string) =>
|
||||
content = encodeHTML(content);
|
||||
//content = (joypixels.shortnameToUnicode(content) as string)
|
||||
|
||||
if(!GetConfigurationValue<boolean>('youtube.publish.disabled', false))
|
||||
{
|
||||
const labelShared = LocalizeText('widget.room.youtube.shared');
|
||||
const labelOpen = LocalizeText('widget.room.youtube.open_video');
|
||||
content = content.replace(
|
||||
/(?:http:\/\/|https:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?.*v=|shorts\/)?([a-zA-Z0-9_-]{11})/g,
|
||||
`<div style="margin:2px 0"><strong>📺 ${ labelShared }</strong></div><div><a href="https://youtu.be/$1" target="_blank" style="background-color:red;color:white;padding:3px 8px;border-radius:4px;text-decoration:none;font-size:12px">▶ ${ labelOpen }</a></div>`
|
||||
);
|
||||
}
|
||||
|
||||
if(content.startsWith('@') && content.indexOf('@', 1) > -1)
|
||||
{
|
||||
let match = null;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
let _youtubeEnabled = false;
|
||||
|
||||
export const getYoutubeRoomEnabled = () => _youtubeEnabled;
|
||||
export const setYoutubeRoomEnabled = (enabled: boolean) => { _youtubeEnabled = enabled; };
|
||||
@@ -0,0 +1 @@
|
||||
export * from './YouTubeRoomState';
|
||||
Reference in New Issue
Block a user