mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-20 15:36:18 +00:00
Merge pull request #173 from medievalshell/Dev
feat: branding furni image position editor (move + scale) + fix(navigator): ignore search events while disabled + invalidate on FlatCreated + Restyle Catalog with two ui
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
"avatar.asset.effect.url": "${asset.url}/effect/%libname%.nitro",
|
"avatar.asset.effect.url": "${asset.url}/effect/%libname%.nitro",
|
||||||
"furni.asset.url": "${asset.url}/furniture/%libname%.nitro",
|
"furni.asset.url": "${asset.url}/furniture/%libname%.nitro",
|
||||||
"furni.asset.icon.url": "${hof.furni.url}/icons/%libname%%param%_icon.png",
|
"furni.asset.icon.url": "${hof.furni.url}/icons/%libname%%param%_icon.png",
|
||||||
"pet.asset.url": "${asset.url}/pets/%libname%.nitro",
|
"pet.asset.url": "${asset.url}/pet/%libname%.nitro",
|
||||||
"generic.asset.url": "${asset.url}/generic/%libname%.nitro",
|
"generic.asset.url": "${asset.url}/generic/%libname%.nitro",
|
||||||
"badge.asset.url": "${image.library.url}album1584/%badgename%.gif",
|
"badge.asset.url": "${image.library.url}album1584/%badgename%.gif",
|
||||||
"radio.url": "${gamedata.url}/radio-stations.json5?t=%timestamp%",
|
"radio.url": "${gamedata.url}/radio-stations.json5?t=%timestamp%",
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
"housekeeping.enabled": true,
|
"housekeeping.enabled": true,
|
||||||
"toolbar.hide.quests": true,
|
"toolbar.hide.quests": true,
|
||||||
"show.google.ads": false,
|
"show.google.ads": false,
|
||||||
|
"catalog.classic.style": false,
|
||||||
"loginview": {
|
"loginview": {
|
||||||
"images": {
|
"images": {
|
||||||
"background": "${asset.url}/c_images/reception/stretch_blue.png",
|
"background": "${asset.url}/c_images/reception/stretch_blue.png",
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ const preloadUrl = async (url: string): Promise<void> =>
|
|||||||
{
|
{
|
||||||
if(!url) return;
|
if(!url) return;
|
||||||
|
|
||||||
|
// Split gamedata URLs are directories (end with '/'); fetching them as a
|
||||||
|
// file just 404s and wastes a connection at startup. The real split loader
|
||||||
|
// handles those — only warm up actual file URLs here.
|
||||||
|
if(url.split('?')[0].split('#')[0].endsWith('/')) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const response = await fetch(url, { cache: 'force-cache' });
|
const response = await fetch(url, { cache: 'force-cache' });
|
||||||
|
|||||||
@@ -27,8 +27,16 @@ export class PageLocalization implements IPageLocalization
|
|||||||
|
|
||||||
if(!imageName || !imageName.length) return null;
|
if(!imageName || !imageName.length) return null;
|
||||||
|
|
||||||
|
// Already a full URL (any extension) -> use it directly.
|
||||||
|
if(/^https?:\/\//i.test(imageName)) return imageName;
|
||||||
|
|
||||||
let assetUrl = GetConfigurationValue<string>('catalog.asset.image.url');
|
let assetUrl = GetConfigurationValue<string>('catalog.asset.image.url');
|
||||||
|
|
||||||
|
// The template forces ".gif" (.../%name%.gif). If the image name
|
||||||
|
// already carries its own extension (png/jpg/webp/gif), don't append
|
||||||
|
// the forced .gif so non-gif catalog images work too.
|
||||||
|
if(/\.[a-z0-9]+$/i.test(imageName)) assetUrl = assetUrl.replace(/\.gif(?=$|\?)/i, '');
|
||||||
|
|
||||||
assetUrl = assetUrl.replace('%name%', imageName);
|
assetUrl = assetUrl.replace('%name%', imageName);
|
||||||
|
|
||||||
return assetUrl;
|
return assetUrl;
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ export class LocalStorageKeys
|
|||||||
public static CATALOG_SKIP_PURCHASE_CONFIRMATION: string = 'catalogSkipPurchaseConfirmation';
|
public static CATALOG_SKIP_PURCHASE_CONFIRMATION: string = 'catalogSkipPurchaseConfirmation';
|
||||||
public static CHAT_WINDOW_ENABLED: string = 'chatWindowEnabled';
|
public static CHAT_WINDOW_ENABLED: string = 'chatWindowEnabled';
|
||||||
public static CHAT_TRANSLATION_SETTINGS: string = 'chatTranslationSettings';
|
public static CHAT_TRANSLATION_SETTINGS: string = 'chatTranslationSettings';
|
||||||
|
public static CATALOG_CLASSIC_STYLE: string = 'catalogClassicStyle';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -252,7 +252,8 @@ const CatalogClassicViewInner: FC<{}> = () =>
|
|||||||
<div className="nitro-catalog-classic-layout-header-shell">
|
<div className="nitro-catalog-classic-layout-header-shell">
|
||||||
<CatalogBreadcrumbView />
|
<CatalogBreadcrumbView />
|
||||||
<div className="nitro-catalog-classic-layout-hero">
|
<div className="nitro-catalog-classic-layout-hero">
|
||||||
{ !!currentPage?.localization?.getImage(0) && <img src={ currentPage.localization.getImage(0) } /> }
|
{ /* info_duckets renders its own logo in the body (BcInfoView) — don't duplicate it in the hero */ }
|
||||||
|
{ (currentPage?.layoutCode !== 'info_duckets') && !!currentPage?.localization?.getImage(0) && <img src={ currentPage.localization.getImage(0) } /> }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="nitro-catalog-classic-layout-container">
|
<div className="nitro-catalog-classic-layout-container">
|
||||||
|
|||||||
@@ -0,0 +1,335 @@
|
|||||||
|
import { AddLinkEventTracker, ILinkEventTracker, RemoveLinkEventTracker } from '@nitrots/nitro-renderer';
|
||||||
|
import { FC, useEffect, useState } from 'react';
|
||||||
|
import { FaCog, FaEdit, FaEye, FaEyeSlash, FaHeart, FaPlus, FaStar, FaTrash } from 'react-icons/fa';
|
||||||
|
import { CatalogType, LocalizeText } from '../../api';
|
||||||
|
import { NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../common';
|
||||||
|
import { useCatalogActions, useCatalogData, useCatalogFavorites, useCatalogUiState, useHasPermission } from '../../hooks';
|
||||||
|
import { CatalogAdminProvider, useCatalogAdmin } from './CatalogAdminContext';
|
||||||
|
import { CatalogAdminOfferEditView } from './views/admin/CatalogAdminOfferEditView';
|
||||||
|
import { CatalogAdminPageEditView } from './views/admin/CatalogAdminPageEditView';
|
||||||
|
import { CatalogBuildersClubStatusView } from './views/catalog-header/CatalogBuildersClubStatusView';
|
||||||
|
import { CatalogIconView } from './views/catalog-icon/CatalogIconView';
|
||||||
|
import { CatalogFavoritesView } from './views/favorites/CatalogFavoritesView';
|
||||||
|
import { CatalogGiftView } from './views/gift/CatalogGiftView';
|
||||||
|
import { CatalogNavigationView } from './views/navigation/CatalogNavigationView';
|
||||||
|
import { CatalogSearchView } from './views/page/common/CatalogSearchView';
|
||||||
|
import { GetCatalogLayout } from './views/page/layout/GetCatalogLayout';
|
||||||
|
import { MarketplacePostOfferView } from './views/page/layout/marketplace/MarketplacePostOfferView';
|
||||||
|
|
||||||
|
const CatalogModernViewInner: FC<{}> = () =>
|
||||||
|
{
|
||||||
|
const { rootNode = null, currentPage = null, searchResult = null } = useCatalogData();
|
||||||
|
const { isVisible = false, setIsVisible = null, navigationHidden = false, setNavigationHidden = null, activeNodes = [], setSearchResult = null, currentType = CatalogType.NORMAL } = useCatalogUiState();
|
||||||
|
const { openPageByName = null, openPageByOfferId = null, activateNode = null, openCatalogByType = null, toggleCatalogByType = null } = useCatalogActions();
|
||||||
|
const catalogAdmin = useCatalogAdmin();
|
||||||
|
const adminMode = catalogAdmin?.adminMode ?? false;
|
||||||
|
const setAdminMode = catalogAdmin?.setAdminMode ?? (() =>
|
||||||
|
{});
|
||||||
|
const hasPendingChanges = catalogAdmin?.hasPendingChanges ?? false;
|
||||||
|
const publishCatalog = catalogAdmin?.publishCatalog ?? (() =>
|
||||||
|
{});
|
||||||
|
const loading = catalogAdmin?.loading ?? false;
|
||||||
|
const { favoriteOfferIds, favoritePageIds } = useCatalogFavorites();
|
||||||
|
const [ showFavorites, setShowFavorites ] = useState(false);
|
||||||
|
|
||||||
|
const isMod = useHasPermission('acc_catalogfurni');
|
||||||
|
const totalFavs = favoriteOfferIds.length + favoritePageIds.length;
|
||||||
|
const buildersClubHeaderStyle = (currentType === CatalogType.BUILDER)
|
||||||
|
? { borderColor: '#d79d2e', borderBottomColor: '#000', background: 'linear-gradient(180deg, #d89f2d 0%, #c68515 100%)' }
|
||||||
|
: undefined;
|
||||||
|
// Desktop = fixed 780x520. On mobile the window clamps below the viewport so
|
||||||
|
// it reads as a dialog (with margins) instead of filling the whole phone
|
||||||
|
// screen — applies to both the normal catalog and the Builders Club.
|
||||||
|
const catalogCardSize = 'w-[780px] h-[520px] max-w-[96vw] max-h-[72vh] sm:max-w-[100vw] sm:max-h-[92vh]';
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
const getCatalogTypeFromLink = (type?: string) =>
|
||||||
|
{
|
||||||
|
switch((type || '').toLowerCase())
|
||||||
|
{
|
||||||
|
case 'bc':
|
||||||
|
case 'builder':
|
||||||
|
case 'buildersclub':
|
||||||
|
case 'builders_club':
|
||||||
|
return CatalogType.BUILDER;
|
||||||
|
default:
|
||||||
|
return CatalogType.NORMAL;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const linkTracker: ILinkEventTracker = {
|
||||||
|
linkReceived: (url: string) =>
|
||||||
|
{
|
||||||
|
const parts = url.split('/');
|
||||||
|
|
||||||
|
if(parts.length < 2) return;
|
||||||
|
|
||||||
|
switch(parts[1])
|
||||||
|
{
|
||||||
|
case 'show':
|
||||||
|
if(parts.length > 2)
|
||||||
|
{
|
||||||
|
openCatalogByType(getCatalogTypeFromLink(parts[2]));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsVisible(true);
|
||||||
|
return;
|
||||||
|
case 'hide':
|
||||||
|
setIsVisible(false);
|
||||||
|
return;
|
||||||
|
case 'toggle':
|
||||||
|
if(parts.length > 2)
|
||||||
|
{
|
||||||
|
toggleCatalogByType(getCatalogTypeFromLink(parts[2]));
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsVisible(prevValue => !prevValue);
|
||||||
|
return;
|
||||||
|
case 'open':
|
||||||
|
if(parts.length > 2)
|
||||||
|
{
|
||||||
|
if(parts.length === 4)
|
||||||
|
{
|
||||||
|
switch(parts[2])
|
||||||
|
{
|
||||||
|
case 'offerId':
|
||||||
|
openPageByOfferId(parseInt(parts[3]));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
openPageByName(parts[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setIsVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
eventUrlPrefix: 'catalog/'
|
||||||
|
};
|
||||||
|
|
||||||
|
AddLinkEventTracker(linkTracker);
|
||||||
|
|
||||||
|
return () => RemoveLinkEventTracker(linkTracker);
|
||||||
|
}, [ setIsVisible, openPageByOfferId, openPageByName, openCatalogByType, toggleCatalogByType ]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{ isVisible &&
|
||||||
|
<NitroCardView className={ `nitro-catalog ${ catalogCardSize }` } uniqueKey="catalog">
|
||||||
|
<NitroCardHeaderView className={ currentType === CatalogType.BUILDER ? 'builders-club-card-header' : '' } headerText={ LocalizeText('catalog.title') } onCloseClick={ () => setIsVisible(false) } style={ buildersClubHeaderStyle } />
|
||||||
|
<NitroCardContentView classNames={ [ 'p-0!', 'overflow-hidden!' ] }>
|
||||||
|
{ /* Admin banner */ }
|
||||||
|
{ adminMode &&
|
||||||
|
<div className="flex items-center justify-between bg-warning text-dark text-[10px] font-bold px-3 py-0.5 uppercase tracking-wider" style={ { textShadow: '0 1px 0 rgba(255,255,255,0.3)' } }>
|
||||||
|
<span>⚙ Admin Mode</span>
|
||||||
|
<button
|
||||||
|
className={ `px-3 py-0.5 rounded text-[10px] font-bold uppercase cursor-pointer transition-all ${ hasPendingChanges ? 'bg-success text-white animate-pulse shadow-md' : 'bg-white/50 text-dark hover:bg-success hover:text-white' }` }
|
||||||
|
disabled={ loading }
|
||||||
|
onClick={ () => publishCatalog() }
|
||||||
|
>
|
||||||
|
{ loading ? '...' : hasPendingChanges ? '⬆ Publish' : '⬆ Publish' }
|
||||||
|
</button>
|
||||||
|
</div> }
|
||||||
|
|
||||||
|
<CatalogBuildersClubStatusView />
|
||||||
|
<div className="flex min-h-0 flex-1">
|
||||||
|
{ /* === LEFT SIDEBAR === */ }
|
||||||
|
<div className="group/rail flex flex-col w-[52px] sm:hover:w-[175px] min-w-[52px] bg-card-grid-item border-r-2 border-card-grid-item-border py-1.5 gap-px overflow-y-auto overflow-x-hidden transition-[width] duration-200 ease-in-out [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
||||||
|
|
||||||
|
{ /* Favorites toggle */ }
|
||||||
|
<div
|
||||||
|
className={ `flex items-center gap-2 mx-1 px-1.5 py-1.5 rounded cursor-pointer transition-all duration-150 ${ showFavorites ? 'bg-primary text-white' : 'hover:bg-card-grid-item-active' }` }
|
||||||
|
onClick={ () => setShowFavorites(!showFavorites) }
|
||||||
|
>
|
||||||
|
<div className="w-7 h-6 flex items-center justify-center shrink-0 relative">
|
||||||
|
<FaHeart className={ `text-xs ${ showFavorites ? 'text-white' : totalFavs > 0 ? 'text-danger' : 'text-muted' }` } />
|
||||||
|
{ totalFavs > 0 &&
|
||||||
|
<span className="absolute -top-1 -right-1 min-w-[14px] h-[14px] bg-danger text-white text-[8px] font-bold rounded-full flex items-center justify-center px-0.5 leading-none">
|
||||||
|
{ totalFavs }
|
||||||
|
</span> }
|
||||||
|
</div>
|
||||||
|
<span className={ `text-[11px] font-bold whitespace-nowrap opacity-0 group-hover/rail:opacity-100 transition-opacity duration-200 ${ showFavorites ? 'text-white' : '' }` }>{ LocalizeText('catalog.favorites') }</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="border-b border-card-grid-item-border mx-2 my-0.5" />
|
||||||
|
|
||||||
|
{ /* Admin: root page actions */ }
|
||||||
|
{ adminMode && rootNode &&
|
||||||
|
<div className="flex items-center gap-1 mx-1 px-1.5 py-1 opacity-0 group-hover/rail:opacity-100 transition-opacity">
|
||||||
|
<button
|
||||||
|
className="flex items-center gap-1 text-[9px] text-success hover:text-green-800 cursor-pointer transition-colors"
|
||||||
|
title={ LocalizeText('catalog.admin.new.root.category') }
|
||||||
|
onClick={ () => catalogAdmin.createPage({ caption: 'New Category', captionSave: 'New Category', catalogMode: currentType, pageLayout: 'default_3x3', iconImage: 0, minRank: 1, visible: '1', enabled: '1', orderNum: 99, parentId: rootNode.pageId }) }
|
||||||
|
>
|
||||||
|
<FaPlus className="text-[8px]" />
|
||||||
|
<span className="whitespace-nowrap">{ LocalizeText('catalog.admin.new') }</span>
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="flex items-center gap-1 text-[9px] text-primary hover:text-dark cursor-pointer transition-colors"
|
||||||
|
title={ LocalizeText('catalog.admin.edit.root') }
|
||||||
|
onClick={ () =>
|
||||||
|
{
|
||||||
|
catalogAdmin.setEditingPageNode(null); catalogAdmin.setEditingRootPage(true); catalogAdmin.setEditingPageData(true);
|
||||||
|
} }
|
||||||
|
>
|
||||||
|
<FaEdit className="text-[8px]" />
|
||||||
|
<span className="whitespace-nowrap">{ LocalizeText('catalog.admin.root') }</span>
|
||||||
|
</button>
|
||||||
|
</div> }
|
||||||
|
|
||||||
|
{ /* Category icons */ }
|
||||||
|
{ rootNode && rootNode.children.length > 0 && rootNode.children.map((child, index) =>
|
||||||
|
{
|
||||||
|
if(!adminMode && !child.isVisible) return null;
|
||||||
|
|
||||||
|
const isHidden = !child.isVisible;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={ `${ child.pageId }-${ index }` }
|
||||||
|
className={ `group/cat flex items-center gap-2 mx-1 px-1.5 py-1 rounded cursor-pointer transition-all duration-150 ${ isHidden ? 'opacity-40' : '' } ${ child.isActive ? 'bg-card-grid-item-active border border-card-grid-item-border-active shadow-inner1px' : 'border border-transparent hover:bg-card-grid-item-active' }` }
|
||||||
|
title={ adminMode ? `${ child.localization } [ID: ${ child.pageId }]${ isHidden ? ` (${ LocalizeText('catalog.admin.hidden') })` : '' }` : child.localization }
|
||||||
|
onClick={ () =>
|
||||||
|
{
|
||||||
|
if(searchResult) setSearchResult(null);
|
||||||
|
if(showFavorites) setShowFavorites(false);
|
||||||
|
activateNode(child);
|
||||||
|
} }
|
||||||
|
>
|
||||||
|
<div className="w-7 h-6 flex items-center justify-center shrink-0 relative">
|
||||||
|
<CatalogIconView icon={ child.iconId } />
|
||||||
|
{ isHidden && <FaEyeSlash className="absolute -bottom-0.5 -right-0.5 text-[7px] text-danger" /> }
|
||||||
|
</div>
|
||||||
|
<span className={ `text-[11px] whitespace-nowrap overflow-hidden truncate opacity-0 group-hover/rail:opacity-100 transition-opacity duration-200 flex-1 ${ child.isActive ? 'font-bold text-dark' : 'text-gray-700' }` }>
|
||||||
|
{ child.localization }
|
||||||
|
</span>
|
||||||
|
{ /* Admin actions on each root category */ }
|
||||||
|
{ adminMode &&
|
||||||
|
<div className="flex items-center gap-1 opacity-0 group-hover/rail:opacity-100 transition-opacity shrink-0">
|
||||||
|
<div
|
||||||
|
className="w-[18px] h-[18px] rounded flex items-center justify-center hover:bg-primary/20 cursor-pointer transition-colors"
|
||||||
|
title={ `${ LocalizeText('catalog.admin.edit.title') } "${ child.localization }"` }
|
||||||
|
onClick={ e =>
|
||||||
|
{
|
||||||
|
e.stopPropagation();
|
||||||
|
catalogAdmin.setEditingPageNode(child);
|
||||||
|
catalogAdmin.setEditingRootPage(false);
|
||||||
|
catalogAdmin.setEditingPageData(true);
|
||||||
|
} }
|
||||||
|
>
|
||||||
|
<FaEdit className="text-[9px] text-primary" />
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="w-[18px] h-[18px] rounded flex items-center justify-center hover:bg-warning/20 cursor-pointer transition-colors"
|
||||||
|
title={ isHidden ? LocalizeText('catalog.admin.show') : LocalizeText('catalog.admin.hide') }
|
||||||
|
onClick={ e =>
|
||||||
|
{
|
||||||
|
e.stopPropagation();
|
||||||
|
catalogAdmin.togglePageVisible(child.pageId);
|
||||||
|
} }
|
||||||
|
>
|
||||||
|
{ isHidden
|
||||||
|
? <FaEye className="text-[9px] text-success" />
|
||||||
|
: <FaEyeSlash className="text-[9px] text-muted" /> }
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="w-[18px] h-[18px] rounded flex items-center justify-center hover:bg-danger/20 cursor-pointer transition-colors"
|
||||||
|
title={ `${ LocalizeText('catalog.admin.delete.title') } "${ child.localization }"` }
|
||||||
|
onClick={ e =>
|
||||||
|
{
|
||||||
|
e.stopPropagation();
|
||||||
|
if(confirm(LocalizeText('catalog.admin.delete.category.confirm', [ 'name' ], [ child.localization ])))
|
||||||
|
{
|
||||||
|
catalogAdmin.deletePage(child.pageId);
|
||||||
|
}
|
||||||
|
} }
|
||||||
|
>
|
||||||
|
<FaTrash className="text-[9px] text-danger" />
|
||||||
|
</div>
|
||||||
|
</div> }
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}) }
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{ /* === MAIN AREA === */ }
|
||||||
|
<div className="flex flex-col flex-1 overflow-hidden bg-light">
|
||||||
|
{ /* Toolbar: search + admin */ }
|
||||||
|
<div className="flex items-center gap-2 px-2 py-1.5 bg-card-tab-item border-b border-card-grid-item-border">
|
||||||
|
{ /* Breadcrumb */ }
|
||||||
|
<div className="flex items-center gap-1 text-[11px] text-gray-600 min-w-0 flex-1">
|
||||||
|
<FaStar className="text-[9px] text-primary shrink-0" />
|
||||||
|
{ activeNodes && activeNodes.length > 0
|
||||||
|
? activeNodes.map((node, i) => (
|
||||||
|
<span key={ `${ node.pageId }-${ i }` } className="flex items-center gap-1 min-w-0">
|
||||||
|
{ i > 0 && <span className="text-[8px] opacity-30">›</span> }
|
||||||
|
<span className={ `truncate ${ i === activeNodes.length - 1 ? 'font-bold text-dark' : 'cursor-pointer hover:text-primary' }` }
|
||||||
|
onClick={ i < activeNodes.length - 1 ? () => activateNode(node) : undefined }>
|
||||||
|
{ node.localization }
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
))
|
||||||
|
: <span className="text-muted">{ LocalizeText('catalog.title') }</span> }
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="w-[110px] sm:w-[180px] shrink-0">
|
||||||
|
<CatalogSearchView />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{ isMod &&
|
||||||
|
<button
|
||||||
|
className={ `flex items-center gap-1 px-2 py-1 rounded text-[10px] font-bold cursor-pointer transition-all border ${ adminMode ? 'bg-warning text-dark border-warning shadow-inner1px' : 'bg-card-grid-item text-gray-600 border-card-grid-item-border hover:bg-primary hover:text-white hover:border-primary' }` }
|
||||||
|
onClick={ () => setAdminMode(!adminMode) }
|
||||||
|
>
|
||||||
|
<FaCog className={ `${ adminMode ? 'animate-spin' : '' }` } style={ adminMode ? { animationDuration: '3s' } : {} } />
|
||||||
|
{ LocalizeText('catalog.admin') }
|
||||||
|
</button> }
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{ /* Content area */ }
|
||||||
|
<div className="flex flex-1 overflow-hidden">
|
||||||
|
{ showFavorites
|
||||||
|
? <div className="flex-1 overflow-auto nitro-card-content-shell">
|
||||||
|
<CatalogFavoritesView onClose={ () => setShowFavorites(false) } />
|
||||||
|
</div>
|
||||||
|
: <>
|
||||||
|
{ !navigationHidden && activeNodes && activeNodes.length > 0 &&
|
||||||
|
<div className="w-[120px] min-w-[120px] sm:w-[170px] sm:min-w-[170px] border-r-2 border-card-grid-item-border bg-card-grid-item overflow-y-auto py-1">
|
||||||
|
<CatalogNavigationView node={ activeNodes[0] } />
|
||||||
|
</div> }
|
||||||
|
<div className="flex-1 overflow-auto p-2 nitro-card-content-shell">
|
||||||
|
{ adminMode && <CatalogAdminPageEditView /> }
|
||||||
|
{ GetCatalogLayout(currentPage, () => setNavigationHidden(true)) }
|
||||||
|
</div>
|
||||||
|
</> }
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</NitroCardContentView>
|
||||||
|
</NitroCardView> }
|
||||||
|
<CatalogAdminOfferEditView />
|
||||||
|
<CatalogGiftView />
|
||||||
|
<MarketplacePostOfferView />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CatalogModernView: FC<{}> = () =>
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
<CatalogAdminProvider>
|
||||||
|
<CatalogModernViewInner />
|
||||||
|
</CatalogAdminProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,10 +1,23 @@
|
|||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
import { useCatalogData } from '../../hooks';
|
import { useCatalogClassicStyle, useCatalogData } from '../../hooks';
|
||||||
import { CatalogClassicView } from './CatalogClassicView';
|
import { CatalogClassicView } from './CatalogClassicView';
|
||||||
|
import { CatalogModernView } from './CatalogModernView';
|
||||||
|
|
||||||
export const CatalogView: FC<{}> = () =>
|
export const CatalogView: FC<{}> = () =>
|
||||||
{
|
{
|
||||||
const { catalogLocalizationVersion = 0 } = useCatalogData();
|
const { catalogLocalizationVersion = 0 } = useCatalogData();
|
||||||
|
const [ catalogClassicStyle ] = useCatalogClassicStyle();
|
||||||
|
|
||||||
|
// Default = upstream rebuilt catalog (CatalogClassicView, latest release theme).
|
||||||
|
// The "stile classico" toggle (or global catalog.classic.style flag) switches
|
||||||
|
// to the Hippiehotel.nl catalog (CatalogModernView, self-contained tailwind).
|
||||||
|
// Both the normal catalog and the Builders Club follow this toggle.
|
||||||
|
if(catalogClassicStyle) return (
|
||||||
|
<>
|
||||||
|
<div className="hidden" data-catalog-localization-version={ catalogLocalizationVersion } />
|
||||||
|
<CatalogModernView />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -67,8 +67,14 @@ export const CatalogAdminPageEditView: FC<{}> = () =>
|
|||||||
{
|
{
|
||||||
if(!editingPageData || !targetNode) return;
|
if(!editingPageData || !targetNode) return;
|
||||||
|
|
||||||
setCaption(targetNode.localization || '');
|
// The server appends " (pageId)" to the caption for mods/admins (see
|
||||||
setCaptionSave(targetNode.pageName || targetNode.localization || '');
|
// CatalogPagesListComposer). Strip that exact suffix before seeding the
|
||||||
|
// edit field, otherwise saving folds the id back into the stored
|
||||||
|
// caption and it multiplies on every edit ("Wired (1114) (1114) ...").
|
||||||
|
const rawCaption = (targetNode.localization || '').replace(new RegExp(`\\s*\\(${ targetNode.pageId }\\)\\s*$`), '');
|
||||||
|
|
||||||
|
setCaption(rawCaption);
|
||||||
|
setCaptionSave(targetNode.pageName || rawCaption);
|
||||||
setCatalogMode(currentType === CatalogType.BUILDER ? 'BUILDER' : 'NORMAL');
|
setCatalogMode(currentType === CatalogType.BUILDER ? 'BUILDER' : 'NORMAL');
|
||||||
setPageLayout(currentPage?.layoutCode || 'default_3x3');
|
setPageLayout(currentPage?.layoutCode || 'default_3x3');
|
||||||
setIconImage(targetNode.iconId ?? 0);
|
setIconImage(targetNode.iconId ?? 0);
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { FC, useEffect } from 'react';
|
||||||
|
import { SanitizeHtml } from '../../../../../api';
|
||||||
|
import { CatalogLayoutProps } from './CatalogLayout.types';
|
||||||
|
|
||||||
|
// Info/landing layout: a logo box on top (image scaled to fit the available
|
||||||
|
// space, no crop) and a smaller box below with the page text in black.
|
||||||
|
// Logo = page headline image (getImage(0)), text = page text 1 (getText(0)),
|
||||||
|
// set from catalog admin (Gestione -> Modifica pagina). Hides the (empty)
|
||||||
|
// navigation sidebar so the content uses the full width.
|
||||||
|
export const CatalogLayoutBcInfoView: FC<CatalogLayoutProps> = props =>
|
||||||
|
{
|
||||||
|
const { page = null, hideNavigation = null } = props;
|
||||||
|
|
||||||
|
const logo = page?.localization?.getImage(0) || '';
|
||||||
|
const text = page?.localization?.getText(0) || '';
|
||||||
|
|
||||||
|
useEffect(() =>
|
||||||
|
{
|
||||||
|
hideNavigation?.();
|
||||||
|
}, [ page, hideNavigation ]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col h-full gap-2">
|
||||||
|
<div className="flex-1 min-h-0 bg-white rounded border border-card-grid-item-border overflow-hidden flex items-center justify-center">
|
||||||
|
{ logo
|
||||||
|
? <img alt="" className="max-w-full max-h-full object-contain" src={ logo } />
|
||||||
|
: <span className="text-muted text-[11px]">Logo — imposta l'immagine headline da Gestione</span> }
|
||||||
|
</div>
|
||||||
|
<div className="shrink-0 max-h-[32%] bg-white rounded border border-card-grid-item-border p-3 overflow-auto">
|
||||||
|
<div
|
||||||
|
className="text-black text-[12px] leading-snug"
|
||||||
|
dangerouslySetInnerHTML={ { __html: SanitizeHtml(text) } } />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ICatalogPage } from '../../../../../api';
|
import { ICatalogPage } from '../../../../../api';
|
||||||
import { CatalogLayoutProps } from './CatalogLayout.types';
|
import { CatalogLayoutProps } from './CatalogLayout.types';
|
||||||
import { CatalogLayoutBadgeDisplayView } from './CatalogLayoutBadgeDisplayView';
|
import { CatalogLayoutBadgeDisplayView } from './CatalogLayoutBadgeDisplayView';
|
||||||
|
import { CatalogLayoutBcInfoView } from './CatalogLayoutBcInfoView';
|
||||||
import { CatalogLayoutBuildersClubBuyView } from './CatalogLayoutBuildersClubBuyView';
|
import { CatalogLayoutBuildersClubBuyView } from './CatalogLayoutBuildersClubBuyView';
|
||||||
import { CatalogLayoutColorGroupingView } from './CatalogLayoutColorGroupingView';
|
import { CatalogLayoutColorGroupingView } from './CatalogLayoutColorGroupingView';
|
||||||
import { CatalogLayoutCustomPrefixView } from './CatalogLayoutCustomPrefixView';
|
import { CatalogLayoutCustomPrefixView } from './CatalogLayoutCustomPrefixView';
|
||||||
@@ -34,6 +35,8 @@ export const GetCatalogLayout = (page: ICatalogPage, hideNavigation: () => void)
|
|||||||
{
|
{
|
||||||
case 'frontpage_featured':
|
case 'frontpage_featured':
|
||||||
return null;
|
return null;
|
||||||
|
case 'info_duckets':
|
||||||
|
return <CatalogLayoutBcInfoView { ...layoutProps } />;
|
||||||
case 'frontpage4':
|
case 'frontpage4':
|
||||||
return <CatalogLayoutFrontpage4View { ...layoutProps } />;
|
return <CatalogLayoutFrontpage4View { ...layoutProps } />;
|
||||||
case 'pets':
|
case 'pets':
|
||||||
|
|||||||
@@ -19,6 +19,13 @@ const TAB_PETS: string = 'inventory.furni.tab.pets';
|
|||||||
const TAB_BADGES: string = 'inventory.badges';
|
const TAB_BADGES: string = 'inventory.badges';
|
||||||
const TAB_PREFIXES: string = 'inventory.prefixes';
|
const TAB_PREFIXES: string = 'inventory.prefixes';
|
||||||
const TABS = [ TAB_FURNITURE, TAB_PETS, TAB_BADGES, TAB_PREFIXES, TAB_BOTS ];
|
const TABS = [ TAB_FURNITURE, TAB_PETS, TAB_BADGES, TAB_PREFIXES, TAB_BOTS ];
|
||||||
|
// Maps an optional link code (inventory/show/<code>) to a tab so other views
|
||||||
|
// (e.g. the profile "Change Badges" button) can deep-link to a specific tab.
|
||||||
|
const TAB_BY_CODE: Record<string, string> = {
|
||||||
|
furni: TAB_FURNITURE, furniture: TAB_FURNITURE,
|
||||||
|
pets: TAB_PETS, badges: TAB_BADGES,
|
||||||
|
prefixes: TAB_PREFIXES, bots: TAB_BOTS
|
||||||
|
};
|
||||||
const UNSEEN_CATEGORIES = [ UnseenItemCategory.FURNI, UnseenItemCategory.PET, UnseenItemCategory.BADGE, UnseenItemCategory.PREFIX, UnseenItemCategory.BOT ];
|
const UNSEEN_CATEGORIES = [ UnseenItemCategory.FURNI, UnseenItemCategory.PET, UnseenItemCategory.BADGE, UnseenItemCategory.PREFIX, UnseenItemCategory.BOT ];
|
||||||
const TAB_ICONS: Record<string, ReactNode> = {
|
const TAB_ICONS: Record<string, ReactNode> = {
|
||||||
[TAB_FURNITURE]: <FaCouch />,
|
[TAB_FURNITURE]: <FaCouch />,
|
||||||
@@ -94,12 +101,14 @@ export const InventoryView: FC<{}> = props =>
|
|||||||
{
|
{
|
||||||
case 'show':
|
case 'show':
|
||||||
setIsVisible(true);
|
setIsVisible(true);
|
||||||
|
if(parts[2] && TAB_BY_CODE[parts[2]]) setCurrentTab(TAB_BY_CODE[parts[2]]);
|
||||||
return;
|
return;
|
||||||
case 'hide':
|
case 'hide':
|
||||||
setIsVisible(false);
|
setIsVisible(false);
|
||||||
return;
|
return;
|
||||||
case 'toggle':
|
case 'toggle':
|
||||||
setIsVisible(prevValue => !prevValue);
|
setIsVisible(prevValue => !prevValue);
|
||||||
|
if(parts[2] && TAB_BY_CODE[parts[2]]) setCurrentTab(TAB_BY_CODE[parts[2]]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export const NavigatorView: FC<{}> = props =>
|
|||||||
{
|
{
|
||||||
const { topLevelContext, topLevelContexts, navigatorData, navigatorSearches } = useNavigatorData();
|
const { topLevelContext, topLevelContexts, navigatorData, navigatorSearches } = useNavigatorData();
|
||||||
const { searchResult, isFetching } = useNavigatorSearch();
|
const { searchResult, isFetching } = useNavigatorSearch();
|
||||||
const { isVisible, isCreatorOpen, isRoomInfoOpen, isRoomLinkOpen, isOpenSavesSearches, needsInit } = useNavigatorUiState();
|
const { isVisible, isCreatorOpen, isRoomInfoOpen, isRoomLinkOpen, isOpenSavesSearches, needsInit, currentTabCode } = useNavigatorUiState();
|
||||||
const elementRef = useRef<HTMLDivElement>(null);
|
const elementRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useNitroEvent<RoomSessionEvent>(RoomSessionEvent.CREATED, event =>
|
useNitroEvent<RoomSessionEvent>(RoomSessionEvent.CREATED, event =>
|
||||||
@@ -122,7 +122,7 @@ export const NavigatorView: FC<{}> = props =>
|
|||||||
{ topLevelContexts && topLevelContexts.length > 0 && topLevelContexts.map((context, index) =>
|
{ topLevelContexts && topLevelContexts.length > 0 && topLevelContexts.map((context, index) =>
|
||||||
<NitroCard.TabItem
|
<NitroCard.TabItem
|
||||||
key={ index }
|
key={ index }
|
||||||
isActive={ topLevelContext === context && !isCreatorOpen }
|
isActive={ (currentTabCode ? currentTabCode === context.code : topLevelContext === context) && !isCreatorOpen }
|
||||||
onClick={ () => useNavigatorUiStore.getState().setTab(context.code) }>
|
onClick={ () => useNavigatorUiStore.getState().setTab(context.code) }>
|
||||||
{ LocalizeText('navigator.toplevelview.' + context.code) }
|
{ LocalizeText('navigator.toplevelview.' + context.code) }
|
||||||
</NitroCard.TabItem>) }
|
</NitroCard.TabItem>) }
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export const RadioView: FC<{}> = () =>
|
|||||||
<div className="mt-0.5 flex items-center gap-1.5">
|
<div className="mt-0.5 flex items-center gap-1.5">
|
||||||
{ selectedPlaying &&
|
{ selectedPlaying &&
|
||||||
<span className="flex items-center gap-1 text-[9px] font-bold uppercase tracking-wide text-sky-400">
|
<span className="flex items-center gap-1 text-[9px] font-bold uppercase tracking-wide text-sky-400">
|
||||||
<span className="h-1.5 w-1.5 rounded-full bg-sky-400" /> Live
|
<span className="h-1.5 w-1.5 rounded-full bg-sky-400" /> { LocalizeText('radio.live') }
|
||||||
</span> }
|
</span> }
|
||||||
{ selected?.genre &&
|
{ selected?.genre &&
|
||||||
<span className="truncate text-[10px] text-white/45">{ selected.genre }</span> }
|
<span className="truncate text-[10px] text-white/45">{ selected.genre }</span> }
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
import { GetRoomEngine, RoomObjectCategory, RoomObjectVariable } from '@nitrots/nitro-renderer';
|
||||||
|
import { FC, PointerEvent as ReactPointerEvent, useCallback, useEffect, useRef, useState } from 'react';
|
||||||
|
import { LocalizeText } from '../../../../../api';
|
||||||
|
import { Button, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../../common';
|
||||||
|
|
||||||
|
const PAD_W = 230;
|
||||||
|
const PAD_H = 150;
|
||||||
|
// How many offset units one pixel of drag represents.
|
||||||
|
const UNITS_PER_PX = 1.5;
|
||||||
|
|
||||||
|
interface Props
|
||||||
|
{
|
||||||
|
roomId: number;
|
||||||
|
objectId: number;
|
||||||
|
isWallItem: boolean;
|
||||||
|
initialX: number;
|
||||||
|
initialY: number;
|
||||||
|
initialZ: number;
|
||||||
|
initialScale: number;
|
||||||
|
onClose: () => void;
|
||||||
|
onSave: (x: number, y: number, z: number, scale: number) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ImagePositionEditorView: FC<Props> = props =>
|
||||||
|
{
|
||||||
|
const { roomId, objectId, isWallItem, initialX, initialY, initialZ, initialScale, onClose, onSave } = props;
|
||||||
|
const [ x, setX ] = useState(initialX);
|
||||||
|
const [ y, setY ] = useState(initialY);
|
||||||
|
const [ z, setZ ] = useState(initialZ);
|
||||||
|
const [ scale, setScale ] = useState(initialScale || 100);
|
||||||
|
const padRef = useRef<HTMLDivElement>(null);
|
||||||
|
const draggingRef = useRef(false);
|
||||||
|
|
||||||
|
const category = isWallItem ? RoomObjectCategory.WALL : RoomObjectCategory.FLOOR;
|
||||||
|
|
||||||
|
// Local-only live preview: set the branding model values directly. The model
|
||||||
|
// bumps its update counter so the visualization re-renders next frame.
|
||||||
|
// Nothing is sent to the server until Save.
|
||||||
|
const applyLive = useCallback((nx: number, ny: number, nz: number, nScale: number) =>
|
||||||
|
{
|
||||||
|
const roomObject = GetRoomEngine().getRoomObject(roomId, objectId, category);
|
||||||
|
if(!roomObject?.model) return;
|
||||||
|
|
||||||
|
roomObject.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_OFFSET_X, nx);
|
||||||
|
roomObject.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_OFFSET_Y, ny);
|
||||||
|
roomObject.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_OFFSET_Z, nz);
|
||||||
|
roomObject.model.setValue(RoomObjectVariable.FURNITURE_BRANDING_SCALE, nScale);
|
||||||
|
}, [ roomId, objectId, category ]);
|
||||||
|
|
||||||
|
useEffect(() => { applyLive(x, y, z, scale); }, [ x, y, z, scale, applyLive ]);
|
||||||
|
|
||||||
|
const setFromPointer = useCallback((clientX: number, clientY: number) =>
|
||||||
|
{
|
||||||
|
const rect = padRef.current?.getBoundingClientRect();
|
||||||
|
if(!rect) return;
|
||||||
|
|
||||||
|
const cx = rect.left + (rect.width / 2);
|
||||||
|
const cy = rect.top + (rect.height / 2);
|
||||||
|
|
||||||
|
setX(Math.round((clientX - cx) * UNITS_PER_PX));
|
||||||
|
setY(Math.round((clientY - cy) * UNITS_PER_PX));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const onPointerDown = (event: ReactPointerEvent<HTMLDivElement>) =>
|
||||||
|
{
|
||||||
|
draggingRef.current = true;
|
||||||
|
padRef.current?.setPointerCapture(event.pointerId);
|
||||||
|
setFromPointer(event.clientX, event.clientY);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onPointerMove = (event: ReactPointerEvent<HTMLDivElement>) =>
|
||||||
|
{
|
||||||
|
if(draggingRef.current) setFromPointer(event.clientX, event.clientY);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onPointerUp = (event: ReactPointerEvent<HTMLDivElement>) =>
|
||||||
|
{
|
||||||
|
draggingRef.current = false;
|
||||||
|
padRef.current?.releasePointerCapture?.(event.pointerId);
|
||||||
|
};
|
||||||
|
|
||||||
|
const cancel = () =>
|
||||||
|
{
|
||||||
|
applyLive(initialX, initialY, initialZ, initialScale || 100);
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
const save = () =>
|
||||||
|
{
|
||||||
|
onSave(x, y, z, scale);
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
const dotLeft = (PAD_W / 2) + (x / UNITS_PER_PX);
|
||||||
|
const dotTop = (PAD_H / 2) + (y / UNITS_PER_PX);
|
||||||
|
const clampedLeft = Math.max(0, Math.min(PAD_W, dotLeft));
|
||||||
|
const clampedTop = Math.max(0, Math.min(PAD_H, dotTop));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<NitroCardView className="no-resize" uniqueKey="image-position-editor" theme="primary-slim">
|
||||||
|
<NitroCardHeaderView headerText={ LocalizeText('image.position.editor.title') } onCloseClick={ cancel } />
|
||||||
|
<NitroCardContentView>
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<span className="text-[11px] text-black/60">{ LocalizeText('image.position.editor.hint') }</span>
|
||||||
|
<div
|
||||||
|
ref={ padRef }
|
||||||
|
onPointerDown={ onPointerDown }
|
||||||
|
onPointerMove={ onPointerMove }
|
||||||
|
onPointerUp={ onPointerUp }
|
||||||
|
className="relative cursor-crosshair self-center rounded border border-black/30 bg-[#1b2733]"
|
||||||
|
style={ { width: PAD_W, height: PAD_H } }>
|
||||||
|
{ /* center crosshair */ }
|
||||||
|
<div className="pointer-events-none absolute left-1/2 top-0 h-full w-px -translate-x-1/2 bg-white/10" />
|
||||||
|
<div className="pointer-events-none absolute left-0 top-1/2 h-px w-full -translate-y-1/2 bg-white/10" />
|
||||||
|
{ /* draggable dot */ }
|
||||||
|
<div
|
||||||
|
className="pointer-events-none absolute h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full bg-sky-400 shadow-[0_0_6px_rgba(56,189,248,0.8)] ring-2 ring-white/70"
|
||||||
|
style={ { left: clampedLeft, top: clampedTop } } />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span className="w-12 text-[11px] text-black/70">{ LocalizeText('image.position.editor.scale') }</span>
|
||||||
|
<input type="range" min={ 10 } max={ 500 } step={ 1 } value={ scale } onChange={ e => setScale(e.target.valueAsNumber || 100) } className="grow" />
|
||||||
|
<span className="w-12 text-right text-[11px] tabular-nums text-black/70">{ (scale / 100).toFixed(2) }x</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-3 gap-2">
|
||||||
|
<label className="flex flex-col gap-0.5 text-[11px] text-black/70">{ LocalizeText('image.position.editor.offsetx') }
|
||||||
|
<input type="number" value={ x } onChange={ e => setX(e.target.valueAsNumber || 0) } className="form-control form-control-sm" />
|
||||||
|
</label>
|
||||||
|
<label className="flex flex-col gap-0.5 text-[11px] text-black/70">{ LocalizeText('image.position.editor.offsety') }
|
||||||
|
<input type="number" value={ y } onChange={ e => setY(e.target.valueAsNumber || 0) } className="form-control form-control-sm" />
|
||||||
|
</label>
|
||||||
|
<label className="flex flex-col gap-0.5 text-[11px] text-black/70">{ LocalizeText('image.position.editor.offsetz') }
|
||||||
|
<input type="number" value={ z } onChange={ e => setZ(e.target.valueAsNumber || 0) } className="form-control form-control-sm" />
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex justify-end gap-2">
|
||||||
|
<Button variant="secondary" onClick={ cancel }>{ LocalizeText('image.position.editor.cancel') }</Button>
|
||||||
|
<Button variant="success" onClick={ save }>{ LocalizeText('save') }</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</NitroCardContentView>
|
||||||
|
</NitroCardView>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -6,6 +6,7 @@ import { AvatarInfoFurni, GetGroupInformation, LocalizeText, SendMessageComposer
|
|||||||
import { Button, Column, Flex, LayoutBadgeImageView, LayoutCurrencyIcon, LayoutLimitedEditionCompactPlateView, LayoutRarityLevelView, LayoutRoomObjectImageView, Text, UserProfileIconView } from '../../../../../common';
|
import { Button, Column, Flex, LayoutBadgeImageView, LayoutCurrencyIcon, LayoutLimitedEditionCompactPlateView, LayoutRarityLevelView, LayoutRoomObjectImageView, Text, UserProfileIconView } from '../../../../../common';
|
||||||
import { useHasPermission, useMessageEvent, useNitroEvent, useRareValues, useRoom, useWiredTools } from '../../../../../hooks';
|
import { useHasPermission, useMessageEvent, useNitroEvent, useRareValues, useRoom, useWiredTools } from '../../../../../hooks';
|
||||||
import { NitroInput } from '../../../../../layout';
|
import { NitroInput } from '../../../../../layout';
|
||||||
|
import { ImagePositionEditorView } from './ImagePositionEditorView';
|
||||||
|
|
||||||
interface InfoStandWidgetFurniViewProps
|
interface InfoStandWidgetFurniViewProps
|
||||||
{
|
{
|
||||||
@@ -43,6 +44,7 @@ export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props
|
|||||||
const [ isJukeBox, setIsJukeBox ] = useState<boolean>(false);
|
const [ isJukeBox, setIsJukeBox ] = useState<boolean>(false);
|
||||||
const [ isSongDisk, setIsSongDisk ] = useState<boolean>(false);
|
const [ isSongDisk, setIsSongDisk ] = useState<boolean>(false);
|
||||||
const [ isBranded, setIsBranded ] = useState<boolean>(false);
|
const [ isBranded, setIsBranded ] = useState<boolean>(false);
|
||||||
|
const [ showPositionEditor, setShowPositionEditor ] = useState<boolean>(false);
|
||||||
const [ songId, setSongId ] = useState<number>(-1);
|
const [ songId, setSongId ] = useState<number>(-1);
|
||||||
const [ songName, setSongName ] = useState<string>('');
|
const [ songName, setSongName ] = useState<string>('');
|
||||||
const [ songCreator, setSongCreator ] = useState<string>('');
|
const [ songCreator, setSongCreator ] = useState<string>('');
|
||||||
@@ -393,6 +395,45 @@ export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props
|
|||||||
return data;
|
return data;
|
||||||
}, [ furniKeys, furniValues ]);
|
}, [ furniKeys, furniValues ]);
|
||||||
|
|
||||||
|
const getBrandingOffset = useCallback((key: string): number =>
|
||||||
|
{
|
||||||
|
const index = furniKeys.indexOf(key);
|
||||||
|
if(index < 0) return 0;
|
||||||
|
const value = parseInt(furniValues[index]);
|
||||||
|
return isNaN(value) ? 0 : value;
|
||||||
|
}, [ furniKeys, furniValues ]);
|
||||||
|
|
||||||
|
const hasBrandingOffsets = isBranded && (furniKeys.indexOf('offsetX') >= 0);
|
||||||
|
|
||||||
|
// Persist the position from the editor: rebuild the branding map with the
|
||||||
|
// new offsets and send it (same path as Save), then reflect it in the fields.
|
||||||
|
const savePositionEditor = useCallback((x: number, y: number, z: number, scale: number) =>
|
||||||
|
{
|
||||||
|
const map = new Map<string, string>();
|
||||||
|
const clone = Array.from(furniValues);
|
||||||
|
let hasScale = false;
|
||||||
|
|
||||||
|
for(let i = 0; i < furniKeys.length; i++)
|
||||||
|
{
|
||||||
|
const key = furniKeys[i];
|
||||||
|
let value = furniValues[i];
|
||||||
|
|
||||||
|
if(key === 'offsetX') value = String(x);
|
||||||
|
else if(key === 'offsetY') value = String(y);
|
||||||
|
else if(key === 'offsetZ') value = String(z);
|
||||||
|
else if(key === 'scale') { value = String(scale); hasScale = true; }
|
||||||
|
|
||||||
|
clone[i] = value;
|
||||||
|
map.set(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// older branding furni may not carry a scale key yet — always send it
|
||||||
|
if(!hasScale) map.set('scale', String(scale));
|
||||||
|
|
||||||
|
GetRoomEngine().modifyRoomObjectDataWithMap(avatarInfo.id, avatarInfo.category, RoomObjectOperationType.OBJECT_SAVE_STUFF_DATA, map);
|
||||||
|
setFurniValues(clone);
|
||||||
|
}, [ avatarInfo, furniKeys, furniValues ]);
|
||||||
|
|
||||||
const processButtonAction = useCallback((action: string) =>
|
const processButtonAction = useCallback((action: string) =>
|
||||||
{
|
{
|
||||||
if(!action || (action === '')) return;
|
if(!action || (action === '')) return;
|
||||||
@@ -749,6 +790,10 @@ export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props
|
|||||||
<Button variant="dark" onClick={ event => processButtonAction('use') }>
|
<Button variant="dark" onClick={ event => processButtonAction('use') }>
|
||||||
{ LocalizeText('infostand.button.use') }
|
{ LocalizeText('infostand.button.use') }
|
||||||
</Button> }
|
</Button> }
|
||||||
|
{ hasBrandingOffsets &&
|
||||||
|
<Button variant="dark" onClick={ () => setShowPositionEditor(true) }>
|
||||||
|
{ LocalizeText('image.position.editor.button') }
|
||||||
|
</Button> }
|
||||||
{ ((furniKeys.length > 0 && furniValues.length > 0) && (furniKeys.length === furniValues.length)) &&
|
{ ((furniKeys.length > 0 && furniValues.length > 0) && (furniKeys.length === furniValues.length)) &&
|
||||||
<Button variant="dark" onClick={ () => processButtonAction('save_branding_configuration') }>
|
<Button variant="dark" onClick={ () => processButtonAction('save_branding_configuration') }>
|
||||||
{ LocalizeText('save') }
|
{ LocalizeText('save') }
|
||||||
@@ -758,6 +803,17 @@ export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props
|
|||||||
{ LocalizeText('save') }
|
{ LocalizeText('save') }
|
||||||
</Button> }
|
</Button> }
|
||||||
</Flex>
|
</Flex>
|
||||||
|
{ showPositionEditor &&
|
||||||
|
<ImagePositionEditorView
|
||||||
|
roomId={ roomSession.roomId }
|
||||||
|
objectId={ avatarInfo.id }
|
||||||
|
isWallItem={ avatarInfo.isWallItem }
|
||||||
|
initialX={ getBrandingOffset('offsetX') }
|
||||||
|
initialY={ getBrandingOffset('offsetY') }
|
||||||
|
initialZ={ getBrandingOffset('offsetZ') }
|
||||||
|
initialScale={ getBrandingOffset('scale') || 100 }
|
||||||
|
onClose={ () => setShowPositionEditor(false) }
|
||||||
|
onSave={ savePositionEditor } /> }
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { RelationshipStatusEnum, RelationshipStatusInfoMessageParser } from '@nitrots/nitro-renderer';
|
import { RelationshipStatusEnum, RelationshipStatusInfoMessageParser } from '@nitrots/nitro-renderer';
|
||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
import { GetUserProfile, LocalizeText } from '../../api';
|
import { CreateLinkEvent, GetUserProfile, LocalizeText } from '../../api';
|
||||||
import { Flex, LayoutAvatarImageView } from '../../common';
|
import { Flex, LayoutAvatarImageView } from '../../common';
|
||||||
|
|
||||||
interface RelationshipsContainerViewProps
|
interface RelationshipsContainerViewProps
|
||||||
@@ -29,7 +29,7 @@ export const RelationshipsContainerView: FC<RelationshipsContainerViewProps> = p
|
|||||||
</Flex>
|
</Flex>
|
||||||
<div className="nitro-extended-profile__relationship-copy">
|
<div className="nitro-extended-profile__relationship-copy">
|
||||||
<div className="nitro-extended-profile__relationship-box">
|
<div className="nitro-extended-profile__relationship-box">
|
||||||
<p className="nitro-extended-profile__relationship-name" onClick={ event => (relationshipInfo && (relationshipInfo.randomFriendId >= 1) && GetUserProfile(relationshipInfo.randomFriendId)) }>
|
<p className="nitro-extended-profile__relationship-name" onClick={ event => ((relationshipInfo && (relationshipInfo.randomFriendId >= 1)) ? GetUserProfile(relationshipInfo.randomFriendId) : CreateLinkEvent('friends/toggle')) }>
|
||||||
{ (!relationshipInfo || (relationshipInfo.friendCount === 0)) &&
|
{ (!relationshipInfo || (relationshipInfo.friendCount === 0)) &&
|
||||||
LocalizeText('extendedprofile.add.friends') }
|
LocalizeText('extendedprofile.add.friends') }
|
||||||
{ (relationshipInfo && (relationshipInfo.friendCount >= 1)) &&
|
{ (relationshipInfo && (relationshipInfo.friendCount >= 1)) &&
|
||||||
@@ -37,7 +37,7 @@ export const RelationshipsContainerView: FC<RelationshipsContainerViewProps> = p
|
|||||||
</p>
|
</p>
|
||||||
{ (relationshipInfo && (relationshipInfo.friendCount >= 1)) &&
|
{ (relationshipInfo && (relationshipInfo.friendCount >= 1)) &&
|
||||||
<div className="nitro-extended-profile__relationship-head">
|
<div className="nitro-extended-profile__relationship-head">
|
||||||
<LayoutAvatarImageView direction={ 4 } figure={ relationshipInfo.randomFriendFigure } headOnly={ true } classNames={ [ '!w-auto', '!h-auto', '!left-0' ] } />
|
<LayoutAvatarImageView direction={ 2 } figure={ relationshipInfo.randomFriendFigure } headOnly={ true } />
|
||||||
</div> }
|
</div> }
|
||||||
</div>
|
</div>
|
||||||
<p className="nitro-extended-profile__relationship-subcopy">
|
<p className="nitro-extended-profile__relationship-subcopy">
|
||||||
|
|||||||
@@ -60,18 +60,12 @@ export const UserContainerView: FC<UserContainerViewProps> = props =>
|
|||||||
prefixText={ userProfile.prefixText }
|
prefixText={ userProfile.prefixText }
|
||||||
username={ userProfile.username } />
|
username={ userProfile.username } />
|
||||||
<p className="nitro-extended-profile__motto">{ userProfile.motto || '\u00A0' }</p>
|
<p className="nitro-extended-profile__motto">{ userProfile.motto || '\u00A0' }</p>
|
||||||
<p
|
<p className="nitro-extended-profile__meta">
|
||||||
className="nitro-extended-profile__meta"
|
<b>{ LocalizeText('extendedprofile.created').replace(/%\w+%/g, '').trim() }</b> { userProfile.registration }
|
||||||
dangerouslySetInnerHTML={ {
|
</p>
|
||||||
__html: LocalizeText('extendedprofile.created', [ 'created' ], [ userProfile.registration ])
|
<p className="nitro-extended-profile__meta">
|
||||||
} }
|
<b>{ LocalizeText('extendedprofile.last.login').replace(/%\w+%/g, '').trim() }</b> { FriendlyTime.format(userProfile.secondsSinceLastVisit, '.ago', 2) }
|
||||||
/>
|
</p>
|
||||||
<p
|
|
||||||
className="nitro-extended-profile__meta"
|
|
||||||
dangerouslySetInnerHTML={ {
|
|
||||||
__html: LocalizeText('extendedprofile.last.login', [ 'lastlogin' ], [ FriendlyTime.format(userProfile.secondsSinceLastVisit, '.ago', 2) ])
|
|
||||||
} }
|
|
||||||
/>
|
|
||||||
<p className="nitro-extended-profile__meta nitro-extended-profile__meta--strong">
|
<p className="nitro-extended-profile__meta nitro-extended-profile__meta--strong">
|
||||||
<b>{ LocalizeText('extendedprofile.achievementscore') }</b> { userProfile.achievementPoints }
|
<b>{ LocalizeText('extendedprofile.achievementscore') }</b> { userProfile.achievementPoints }
|
||||||
</p>
|
</p>
|
||||||
@@ -100,10 +94,10 @@ export const UserContainerView: FC<UserContainerViewProps> = props =>
|
|||||||
|
|
||||||
{ isOwnProfile &&
|
{ isOwnProfile &&
|
||||||
<div className="nitro-extended-profile__actions">
|
<div className="nitro-extended-profile__actions">
|
||||||
<button className="nitro-extended-profile__link" type="button">
|
<button className="nitro-extended-profile__link" type="button" onClick={ () => CreateLinkEvent('avatar-editor/show') }>
|
||||||
{ LocalizeText('extended.profile.change.looks') }
|
{ LocalizeText('extended.profile.change.looks') }
|
||||||
</button>
|
</button>
|
||||||
<button className="nitro-extended-profile__link" type="button" onClick={ () => CreateLinkEvent('inventory/open/badges') }>
|
<button className="nitro-extended-profile__link" type="button" onClick={ () => CreateLinkEvent('inventory/show/badges') }>
|
||||||
{ LocalizeText('extended.profile.change.badges') }
|
{ LocalizeText('extended.profile.change.badges') }
|
||||||
</button>
|
</button>
|
||||||
</div> }
|
</div> }
|
||||||
@@ -148,11 +142,11 @@ export const UserContainerView: FC<UserContainerViewProps> = props =>
|
|||||||
<span className="nitro-extended-profile__summary-label">{ LocalizeText('inventory.badges') }</span>
|
<span className="nitro-extended-profile__summary-label">{ LocalizeText('inventory.badges') }</span>
|
||||||
<span className="nitro-extended-profile__summary-value">{ totalBadges }</span>
|
<span className="nitro-extended-profile__summary-value">{ totalBadges }</span>
|
||||||
</button>
|
</button>
|
||||||
<div className="nitro-extended-profile__summary-button">
|
<button className="nitro-extended-profile__summary-button nitro-extended-profile__summary-button--center" type="button" onClick={ () => CreateLinkEvent('achievements/toggle') }>
|
||||||
<img className="nitro-extended-profile__summary-icon" src={ profileLevelIcon } alt="" />
|
<img className="nitro-extended-profile__summary-icon" src={ profileLevelIcon } alt="" />
|
||||||
<span className="nitro-extended-profile__summary-label">{ LocalizeText('extendedprofile.achievementscore') }</span>
|
<span className="nitro-extended-profile__summary-label">{ LocalizeText('extendedprofile.achievementscore') }</span>
|
||||||
<span className="nitro-extended-profile__summary-value">{ userProfile.achievementPoints }</span>
|
<span className="nitro-extended-profile__summary-value">{ userProfile.achievementPoints }</span>
|
||||||
</div>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ExtendedProfileChangedMessageEvent, GetSessionDataManager, NavigatorSearchComposer, RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, RoomEngineObjectEvent, RoomObjectCategory, RoomObjectType, UserCurrentBadgesComposer, UserCurrentBadgesEvent, UserProfileEvent, UserProfileParser, UserRelationshipsComposer } from '@nitrots/nitro-renderer';
|
import { ExtendedProfileChangedMessageEvent, GetSessionDataManager, RelationshipStatusInfoEvent, RelationshipStatusInfoMessageParser, RoomEngineObjectEvent, RoomObjectCategory, RoomObjectType, UserCurrentBadgesComposer, UserCurrentBadgesEvent, UserProfileEvent, UserProfileParser, UserRelationshipsComposer } from '@nitrots/nitro-renderer';
|
||||||
import { FC, useState } from 'react';
|
import { FC, useState } from 'react';
|
||||||
import { GetRoomSession, GetUserProfile, LocalizeText, SendMessageComposer } from '../../api';
|
import { CreateLinkEvent, GetRoomSession, GetUserProfile, LocalizeText, SendMessageComposer } from '../../api';
|
||||||
import { useMessageEvent, useNitroEvent } from '../../hooks';
|
import { useMessageEvent, useNitroEvent } from '../../hooks';
|
||||||
import { NitroCard } from '../../layout';
|
import { NitroCard } from '../../layout';
|
||||||
import { GroupsContainerView } from './GroupsContainerView';
|
import { GroupsContainerView } from './GroupsContainerView';
|
||||||
@@ -28,10 +28,11 @@ export const UserProfileView: FC<{}> = () =>
|
|||||||
|
|
||||||
const onOpenRooms = () =>
|
const onOpenRooms = () =>
|
||||||
{
|
{
|
||||||
if(userProfile)
|
if(!userProfile) return;
|
||||||
{
|
|
||||||
SendMessageComposer(new NavigatorSearchComposer('hotel_view', `owner:${ userProfile.username }`));
|
// Open the navigator AND run the owner search (the composer alone never
|
||||||
}
|
// showed the navigator window, so the button looked dead).
|
||||||
|
CreateLinkEvent(`navigator/search/hotel_view/owner:${ userProfile.username }`);
|
||||||
};
|
};
|
||||||
|
|
||||||
useMessageEvent<UserCurrentBadgesEvent>(UserCurrentBadgesEvent, event =>
|
useMessageEvent<UserCurrentBadgesEvent>(UserCurrentBadgesEvent, event =>
|
||||||
@@ -100,7 +101,7 @@ export const UserProfileView: FC<{}> = () =>
|
|||||||
if(!userProfile) return null;
|
if(!userProfile) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NitroCard className="nitro-extended-profile-window w-[521px] h-[537px]" uniqueKey="nitro-user-profile">
|
<NitroCard className="nitro-extended-profile-window w-[600px] h-[600px] max-w-[96vw] max-h-[92vh]" uniqueKey="nitro-user-profile">
|
||||||
<NitroCard.Header
|
<NitroCard.Header
|
||||||
headerText={ LocalizeText('extendedprofile.caption') }
|
headerText={ LocalizeText('extendedprofile.caption') }
|
||||||
onCloseClick={ onClose } />
|
onCloseClick={ onClose } />
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { FC, useEffect, useState } from 'react';
|
|||||||
import { FaUserCog, FaVolumeDown, FaVolumeMute, FaVolumeUp } from 'react-icons/fa';
|
import { FaUserCog, FaVolumeDown, FaVolumeMute, FaVolumeUp } from 'react-icons/fa';
|
||||||
import { DispatchMainEvent, DispatchUiEvent, LocalizeText, SendMessageComposer } from '../../api';
|
import { DispatchMainEvent, DispatchUiEvent, LocalizeText, SendMessageComposer } from '../../api';
|
||||||
import { NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common';
|
import { NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../common';
|
||||||
import { useCatalogPlaceMultipleItems, useCatalogSkipPurchaseConfirmation, useChatWindow, useMessageEvent } from '../../hooks';
|
import { useCatalogClassicStyle, useCatalogPlaceMultipleItems, useCatalogSkipPurchaseConfirmation, useChatWindow, useMessageEvent } from '../../hooks';
|
||||||
import { classNames } from '../../layout';
|
import { classNames } from '../../layout';
|
||||||
|
|
||||||
export const UserSettingsView: FC<{}> = props =>
|
export const UserSettingsView: FC<{}> = props =>
|
||||||
@@ -13,6 +13,7 @@ export const UserSettingsView: FC<{}> = props =>
|
|||||||
const [ catalogPlaceMultipleObjects, setCatalogPlaceMultipleObjects ] = useCatalogPlaceMultipleItems();
|
const [ catalogPlaceMultipleObjects, setCatalogPlaceMultipleObjects ] = useCatalogPlaceMultipleItems();
|
||||||
const [ catalogSkipPurchaseConfirmation, setCatalogSkipPurchaseConfirmation ] = useCatalogSkipPurchaseConfirmation();
|
const [ catalogSkipPurchaseConfirmation, setCatalogSkipPurchaseConfirmation ] = useCatalogSkipPurchaseConfirmation();
|
||||||
const [ chatWindowEnabled, setChatWindowEnabled ] = useChatWindow();
|
const [ chatWindowEnabled, setChatWindowEnabled ] = useChatWindow();
|
||||||
|
const [ catalogClassicStyle, setCatalogClassicStyle ] = useCatalogClassicStyle();
|
||||||
|
|
||||||
const processAction = (type: string, value?: boolean | number | string) =>
|
const processAction = (type: string, value?: boolean | number | string) =>
|
||||||
{
|
{
|
||||||
@@ -156,6 +157,10 @@ export const UserSettingsView: FC<{}> = props =>
|
|||||||
<input checked={ chatWindowEnabled } className="form-check-input" type="checkbox" onChange={ event => setChatWindowEnabled(event.target.checked) } />
|
<input checked={ chatWindowEnabled } className="form-check-input" type="checkbox" onChange={ event => setChatWindowEnabled(event.target.checked) } />
|
||||||
<Text>Enable chat window</Text>
|
<Text>Enable chat window</Text>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<input checked={ catalogClassicStyle } className="form-check-input" type="checkbox" onChange={ event => setCatalogClassicStyle(event.target.checked) } />
|
||||||
|
<Text>Catalogo: stile classico</Text>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<Text bold>{ LocalizeText('widget.memenu.settings.volume') }</Text>
|
<Text bold>{ LocalizeText('widget.memenu.settings.volume') }</Text>
|
||||||
|
|||||||
@@ -1,147 +0,0 @@
|
|||||||
import { IWheelAdminPrize, IWheelAdminPrizeEdit } from '@nitrots/nitro-renderer';
|
|
||||||
import { FC, useEffect, useState } from 'react';
|
|
||||||
import { LocalizeText } from '../../api';
|
|
||||||
import { Column, Flex, Text } from '../../common';
|
|
||||||
import { useFortuneWheel } from '../../hooks';
|
|
||||||
import { NitroCard } from '../../layout';
|
|
||||||
|
|
||||||
interface EditRow
|
|
||||||
{
|
|
||||||
id: number;
|
|
||||||
category: string;
|
|
||||||
num: number;
|
|
||||||
weight: number;
|
|
||||||
label: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CategoryDef
|
|
||||||
{
|
|
||||||
key: string;
|
|
||||||
labelKey: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CATEGORIES: CategoryDef[] = [
|
|
||||||
{ key: 'item', labelKey: 'rarevalues.editor.cat.item' },
|
|
||||||
{ key: 'diamanti', labelKey: 'achievements.activitypoint.5' },
|
|
||||||
{ key: 'duckets', labelKey: 'achievements.activitypoint.0' },
|
|
||||||
{ key: 'crediti', labelKey: 'credits' },
|
|
||||||
{ key: 'giri', labelKey: 'rarevalues.editor.cat.spin' },
|
|
||||||
{ key: 'nulla', labelKey: 'rarevalues.editor.cat.nothing' }
|
|
||||||
];
|
|
||||||
|
|
||||||
const prizeToCategory = (prize: IWheelAdminPrize): string =>
|
|
||||||
{
|
|
||||||
switch(prize.type)
|
|
||||||
{
|
|
||||||
case 'item': return 'item';
|
|
||||||
case 'points': return (prize.pointsType === 5) ? 'diamanti' : 'duckets';
|
|
||||||
case 'credits': return 'crediti';
|
|
||||||
case 'spin': return 'giri';
|
|
||||||
default: return 'nulla';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const prizeToNum = (prize: IWheelAdminPrize): number =>
|
|
||||||
(prize.type === 'item') ? (parseInt(prize.value) || 0) : prize.amount;
|
|
||||||
|
|
||||||
const rowToEdit = (row: EditRow): IWheelAdminPrizeEdit =>
|
|
||||||
{
|
|
||||||
const base = { id: row.id, weight: row.weight, label: row.label };
|
|
||||||
|
|
||||||
switch(row.category)
|
|
||||||
{
|
|
||||||
case 'item': return { ...base, type: 'item', value: String(row.num), amount: 1, pointsType: 0 };
|
|
||||||
case 'diamanti': return { ...base, type: 'points', value: '', amount: row.num, pointsType: 5 };
|
|
||||||
case 'duckets': return { ...base, type: 'points', value: '', amount: row.num, pointsType: 0 };
|
|
||||||
case 'crediti': return { ...base, type: 'credits', value: '', amount: row.num, pointsType: 0 };
|
|
||||||
case 'giri': return { ...base, type: 'spin', value: '', amount: row.num, pointsType: 0 };
|
|
||||||
default: return { ...base, type: 'nothing', value: '', amount: 0, pointsType: 0 };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
interface FortuneWheelSettingsViewProps
|
|
||||||
{
|
|
||||||
onClose: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const FortuneWheelSettingsView: FC<FortuneWheelSettingsViewProps> = ({ onClose }) =>
|
|
||||||
{
|
|
||||||
const { adminPrizes = [], loadAdminPrizes = null, saveAdminPrizes = null } = useFortuneWheel();
|
|
||||||
const [ editRows, setEditRows ] = useState<EditRow[]>([]);
|
|
||||||
|
|
||||||
useEffect(() =>
|
|
||||||
{
|
|
||||||
if(loadAdminPrizes) loadAdminPrizes();
|
|
||||||
}, [ loadAdminPrizes ]);
|
|
||||||
|
|
||||||
useEffect(() =>
|
|
||||||
{
|
|
||||||
setEditRows(adminPrizes.map(prize => ({
|
|
||||||
id: prize.id,
|
|
||||||
category: prizeToCategory(prize),
|
|
||||||
num: prizeToNum(prize),
|
|
||||||
weight: prize.weight,
|
|
||||||
label: prize.label
|
|
||||||
})));
|
|
||||||
}, [ adminPrizes ]);
|
|
||||||
|
|
||||||
const updateRow = (id: number, patch: Partial<EditRow>) =>
|
|
||||||
setEditRows(prev => prev.map(row => (row.id === id) ? { ...row, ...patch } : row));
|
|
||||||
|
|
||||||
return (
|
|
||||||
<NitroCard className="w-[480px] h-[520px]" uniqueKey="fortune-wheel-settings">
|
|
||||||
<NitroCard.Header
|
|
||||||
headerText={ LocalizeText('wheel.settings.title') }
|
|
||||||
onCloseClick={ onClose } />
|
|
||||||
<NitroCard.Content>
|
|
||||||
<Column gap={ 1 } className="h-full p-1">
|
|
||||||
<Flex gap={ 1 } className="px-1 text-[11px] font-bold text-black/60">
|
|
||||||
<span className="w-28">{ LocalizeText('rarevalues.editor.type') }</span>
|
|
||||||
<span className="w-16">{ LocalizeText('rarevalues.editor.value') }</span>
|
|
||||||
<span className="w-12">{ LocalizeText('rarevalues.editor.weight') }</span>
|
|
||||||
<span className="grow">{ LocalizeText('rarevalues.editor.label') }</span>
|
|
||||||
</Flex>
|
|
||||||
<Column gap={ 1 } overflow="auto" className="grow">
|
|
||||||
{ editRows.map(row => (
|
|
||||||
<Flex key={ row.id } alignItems="center" gap={ 1 } className="border-b border-black/10 pb-1">
|
|
||||||
<select
|
|
||||||
value={ row.category }
|
|
||||||
onChange={ event => updateRow(row.id, { category: event.target.value }) }
|
|
||||||
className="w-28 rounded border border-black/20 bg-white px-1 py-0.5 text-sm text-[#1f2d34]">
|
|
||||||
{ CATEGORIES.map(cat => (
|
|
||||||
<option key={ cat.key } value={ cat.key }>{ LocalizeText(cat.labelKey) }</option>
|
|
||||||
)) }
|
|
||||||
</select>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
value={ row.num }
|
|
||||||
disabled={ row.category === 'nulla' }
|
|
||||||
onChange={ event => updateRow(row.id, { num: parseInt(event.target.value) || 0 }) }
|
|
||||||
className="w-16 rounded border border-black/20 bg-white px-1 py-0.5 text-sm text-[#1f2d34] disabled:opacity-40" />
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
value={ row.weight }
|
|
||||||
onChange={ event => updateRow(row.id, { weight: parseInt(event.target.value) || 0 }) }
|
|
||||||
className="w-12 rounded border border-black/20 bg-white px-1 py-0.5 text-sm text-[#1f2d34]" />
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={ row.label }
|
|
||||||
onChange={ event => updateRow(row.id, { label: event.target.value }) }
|
|
||||||
className="min-w-0 grow rounded border border-black/20 bg-white px-1 py-0.5 text-sm text-[#1f2d34]" />
|
|
||||||
</Flex>
|
|
||||||
)) }
|
|
||||||
{ !editRows.length &&
|
|
||||||
<Text small className="text-black/50">{ LocalizeText('wheel.settings.empty') }</Text> }
|
|
||||||
</Column>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
disabled={ !editRows.length }
|
|
||||||
onClick={ () => saveAdminPrizes?.(editRows.map(rowToEdit)) }
|
|
||||||
className="cursor-pointer rounded bg-[#3a7bb5] px-4 py-2 font-bold text-white hover:bg-[#336ea3] disabled:cursor-default disabled:opacity-40">
|
|
||||||
{ LocalizeText('rarevalues.editor.save') }
|
|
||||||
</button>
|
|
||||||
</Column>
|
|
||||||
</NitroCard.Content>
|
|
||||||
</NitroCard>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
import { AddLinkEventTracker, GetRoomEngine, ILinkEventTracker, IWheelPrize, RemoveLinkEventTracker } from '@nitrots/nitro-renderer';
|
|
||||||
import { FC, useEffect, useMemo, useRef, useState } from 'react';
|
|
||||||
import { LocalizeText } from '../../api';
|
|
||||||
import { Column, Flex, LayoutAvatarImageView, LayoutBadgeImageView, LayoutCurrencyIcon, LayoutImage, Text } from '../../common';
|
|
||||||
import { useFortuneWheel, useHasPermission } from '../../hooks';
|
|
||||||
import { NitroCard } from '../../layout';
|
|
||||||
import { FortuneWheelSettingsView } from './FortuneWheelSettingsView';
|
|
||||||
|
|
||||||
// Stock UI palette (white / light-blue / grey / black).
|
|
||||||
const SLICE_COLORS = [ '#eef2f5', '#c3dcec' ];
|
|
||||||
const RIM = '#4c606c';
|
|
||||||
const WHEEL_SIZE = 420;
|
|
||||||
const ICON_RADIUS = 150;
|
|
||||||
const FULL_TURNS = 5;
|
|
||||||
|
|
||||||
const renderPrizeIcon = (prize: IWheelPrize) =>
|
|
||||||
{
|
|
||||||
switch(prize.type)
|
|
||||||
{
|
|
||||||
case 'item':
|
|
||||||
return <LayoutImage imageUrl={ GetRoomEngine().getFurnitureFloorIconUrl(prize.spriteId) } className="h-9 w-9 bg-contain bg-center bg-no-repeat" />;
|
|
||||||
case 'badge':
|
|
||||||
return <LayoutBadgeImageView badgeCode={ prize.badgeCode } />;
|
|
||||||
case 'credits':
|
|
||||||
return (
|
|
||||||
<Column alignItems="center" gap={ 0 }>
|
|
||||||
<LayoutCurrencyIcon type={ -1 } />
|
|
||||||
<span className="text-[10px] font-bold text-[#2a3a42]">{ prize.amount }</span>
|
|
||||||
</Column>);
|
|
||||||
case 'points':
|
|
||||||
return (
|
|
||||||
<Column alignItems="center" gap={ 0 }>
|
|
||||||
<LayoutCurrencyIcon type={ prize.pointsType } />
|
|
||||||
<span className="text-[10px] font-bold text-[#2a3a42]">{ prize.amount }</span>
|
|
||||||
</Column>);
|
|
||||||
case 'spin':
|
|
||||||
return <span className="text-xs font-bold text-[#2a3a42]">+{ prize.amount }</span>;
|
|
||||||
default:
|
|
||||||
return <span className="text-xs font-bold text-[#2a3a42]/60">—</span>;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const FortuneWheelView: FC<{}> = () =>
|
|
||||||
{
|
|
||||||
const [ isVisible, setIsVisible ] = useState(false);
|
|
||||||
const [ isSettingsOpen, setIsSettingsOpen ] = useState(false);
|
|
||||||
const { freeSpins, extraSpins, spinCost, spinCostType, prizes, recentWins, pendingPrizeId, isSpinning, open, spin, buySpin, finishSpin } = useFortuneWheel();
|
|
||||||
const canManage = useHasPermission('acc_wheeladmin');
|
|
||||||
const [ rotation, setRotation ] = useState(0);
|
|
||||||
const rotationRef = useRef(0);
|
|
||||||
const prizesRef = useRef<IWheelPrize[]>([]);
|
|
||||||
prizesRef.current = prizes;
|
|
||||||
|
|
||||||
useEffect(() =>
|
|
||||||
{
|
|
||||||
const linkTracker: ILinkEventTracker = {
|
|
||||||
linkReceived: (url: string) =>
|
|
||||||
{
|
|
||||||
const parts = url.split('/');
|
|
||||||
if(parts.length < 2) return;
|
|
||||||
|
|
||||||
switch(parts[1])
|
|
||||||
{
|
|
||||||
case 'show': setIsVisible(true); return;
|
|
||||||
case 'hide': setIsVisible(false); return;
|
|
||||||
case 'toggle': setIsVisible(prev => !prev); return;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
eventUrlPrefix: 'fortune-wheel/',
|
|
||||||
};
|
|
||||||
|
|
||||||
AddLinkEventTracker(linkTracker);
|
|
||||||
|
|
||||||
return () => RemoveLinkEventTracker(linkTracker);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() =>
|
|
||||||
{
|
|
||||||
if(isVisible) open();
|
|
||||||
}, [ isVisible, open ]);
|
|
||||||
|
|
||||||
// Drive the spin animation when the server reports the winning slice.
|
|
||||||
useEffect(() =>
|
|
||||||
{
|
|
||||||
if(pendingPrizeId < 0) return;
|
|
||||||
|
|
||||||
const list = prizesRef.current;
|
|
||||||
const idx = list.findIndex(prize => prize.id === pendingPrizeId);
|
|
||||||
|
|
||||||
if(!list.length || (idx < 0))
|
|
||||||
{
|
|
||||||
finishSpin();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const sliceAngle = 360 / list.length;
|
|
||||||
const centerAngle = ((idx + 0.5) * sliceAngle);
|
|
||||||
const current = rotationRef.current;
|
|
||||||
const target = (current - (current % 360)) + (FULL_TURNS * 360) + (360 - centerAngle);
|
|
||||||
|
|
||||||
rotationRef.current = target;
|
|
||||||
setRotation(target);
|
|
||||||
}, [ pendingPrizeId, finishSpin ]);
|
|
||||||
|
|
||||||
const sliceAngle = prizes.length ? (360 / prizes.length) : 0;
|
|
||||||
|
|
||||||
const background = useMemo(() =>
|
|
||||||
{
|
|
||||||
if(!prizes.length) return SLICE_COLORS[0];
|
|
||||||
|
|
||||||
const stops = prizes.map((_, i) => `${ SLICE_COLORS[i % 2] } ${ i * sliceAngle }deg ${ (i + 1) * sliceAngle }deg`).join(', ');
|
|
||||||
return `conic-gradient(${ stops })`;
|
|
||||||
}, [ prizes, sliceAngle ]);
|
|
||||||
|
|
||||||
if(!isVisible) return null;
|
|
||||||
|
|
||||||
const canSpin = ((freeSpins + extraSpins) > 0) && !isSpinning && (prizes.length > 0);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<NitroCard className="w-[800px] max-w-[96vw]" uniqueKey="fortune-wheel">
|
|
||||||
<NitroCard.Header headerText={ LocalizeText('wheel.title') } onCloseClick={ () => setIsVisible(false) } />
|
|
||||||
<NitroCard.Content>
|
|
||||||
<Flex gap={ 3 }>
|
|
||||||
<Column alignItems="center" gap={ 2 } className="shrink-0">
|
|
||||||
<div className="relative" style={ { width: WHEEL_SIZE, height: WHEEL_SIZE } }>
|
|
||||||
<div
|
|
||||||
className="absolute left-1/2 -top-2 z-20 -translate-x-1/2 drop-shadow-[0_2px_2px_rgba(0,0,0,0.25)]"
|
|
||||||
style={ { width: 0, height: 0, borderLeft: '14px solid transparent', borderRight: '14px solid transparent', borderTop: `28px solid ${ RIM }` } } />
|
|
||||||
<div
|
|
||||||
className="absolute inset-0 rounded-full shadow-[0_0_0_4px_rgba(0,0,0,0.12),inset_0_0_18px_rgba(0,0,0,0.1)]"
|
|
||||||
style={ { background, border: `8px solid ${ RIM }`, transform: `rotate(${ rotation }deg)`, transition: isSpinning ? 'transform 4.5s cubic-bezier(0.15,0.85,0.25,1)' : 'none' } }
|
|
||||||
onTransitionEnd={ () => { if(isSpinning) finishSpin(); } }>
|
|
||||||
{ prizes.map((_, i) => (
|
|
||||||
<div
|
|
||||||
key={ `divider-${ i }` }
|
|
||||||
className="absolute bottom-1/2 left-1/2 origin-bottom"
|
|
||||||
style={ { width: '2px', height: `${ WHEEL_SIZE / 2 }px`, transform: `translateX(-1px) rotate(${ i * sliceAngle }deg)`, background: 'rgba(76,96,108,0.3)' } } />
|
|
||||||
)) }
|
|
||||||
{ prizes.map((prize, i) =>
|
|
||||||
{
|
|
||||||
const centerAngle = ((i + 0.5) * sliceAngle);
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={ prize.id }
|
|
||||||
className="absolute left-1/2 top-1/2"
|
|
||||||
style={ { transform: `rotate(${ centerAngle }deg) translateY(-${ ICON_RADIUS }px) rotate(-${ centerAngle }deg)` } }>
|
|
||||||
<div className="-translate-x-1/2 -translate-y-1/2">
|
|
||||||
{ renderPrizeIcon(prize) }
|
|
||||||
</div>
|
|
||||||
</div>);
|
|
||||||
}) }
|
|
||||||
</div>
|
|
||||||
<div className="absolute left-1/2 top-1/2 z-10 h-14 w-14 -translate-x-1/2 -translate-y-1/2 rounded-full bg-[#eef2f5] shadow-[0_0_8px_rgba(0,0,0,0.25)]" style={ { border: `4px solid ${ RIM }` } } />
|
|
||||||
</div>
|
|
||||||
<Text bold className="text-[#2f6f95]">{ LocalizeText('wheel.free.today', [ 'count' ], [ freeSpins.toString() ]) }</Text>
|
|
||||||
<Text small className="text-[#33424c]">{ LocalizeText('wheel.extra', [ 'count' ], [ extraSpins.toString() ]) }</Text>
|
|
||||||
<Flex gap={ 2 } alignItems="center">
|
|
||||||
<button
|
|
||||||
disabled={ !canSpin }
|
|
||||||
onClick={ () => spin() }
|
|
||||||
className="cursor-pointer rounded bg-[#3a7bb5] px-4 py-2 font-bold text-white hover:bg-[#336ea3] disabled:cursor-default disabled:opacity-40">
|
|
||||||
{ LocalizeText('wheel.spin') }
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={ () => buySpin() }
|
|
||||||
className="flex cursor-pointer items-center gap-1 rounded bg-[#6b7884] px-3 py-2 text-white hover:bg-[#5e6a75]">
|
|
||||||
{ LocalizeText('wheel.buy') } { spinCost }
|
|
||||||
<LayoutCurrencyIcon type={ spinCostType } />
|
|
||||||
</button>
|
|
||||||
{ canManage &&
|
|
||||||
<button
|
|
||||||
onClick={ () => setIsSettingsOpen(true) }
|
|
||||||
className="cursor-pointer rounded bg-[#8a6b3a] px-3 py-2 font-bold text-white hover:bg-[#735730]">
|
|
||||||
{ LocalizeText('wheel.settings') }
|
|
||||||
</button> }
|
|
||||||
</Flex>
|
|
||||||
</Column>
|
|
||||||
<Column gap={ 2 } className="min-w-[300px] grow rounded-lg border border-black/10 bg-black/5 p-3">
|
|
||||||
<Text bold className="text-base text-[#33424c]">{ LocalizeText('wheel.winners') }</Text>
|
|
||||||
<Column gap={ 1 } overflow="auto" className="h-[440px]">
|
|
||||||
{ recentWins.map((win, i) => (
|
|
||||||
<Flex key={ i } alignItems="center" gap={ 2 } className="rounded border-b border-black/10 py-1.5 hover:bg-black/5">
|
|
||||||
<div className="relative h-11 w-11 shrink-0 overflow-hidden rounded bg-black/5">
|
|
||||||
<LayoutAvatarImageView figure={ win.look } headOnly direction={ 2 } style={ { backgroundSize: 'auto', backgroundPosition: '-22px -32px' } } />
|
|
||||||
</div>
|
|
||||||
<Column gap={ 0 } className="min-w-0">
|
|
||||||
<Text bold truncate className="text-[#1f2d34]">{ win.username }</Text>
|
|
||||||
<Text small truncate className="text-[#2f6f95]">{ win.prizeLabel }</Text>
|
|
||||||
</Column>
|
|
||||||
</Flex>
|
|
||||||
)) }
|
|
||||||
{ !recentWins.length &&
|
|
||||||
<Text small className="text-black/50">{ LocalizeText('wheel.winners.empty') }</Text> }
|
|
||||||
</Column>
|
|
||||||
</Column>
|
|
||||||
</Flex>
|
|
||||||
</NitroCard.Content>
|
|
||||||
{ canManage && isSettingsOpen &&
|
|
||||||
<FortuneWheelSettingsView onClose={ () => setIsSettingsOpen(false) } /> }
|
|
||||||
</NitroCard>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
import { AddLinkEventTracker, GetRoomEngine, GetSessionDataManager, ILinkEventTracker, IRareValue, RemoveLinkEventTracker } from '@nitrots/nitro-renderer';
|
|
||||||
import { FC, useEffect, useMemo, useState } from 'react';
|
|
||||||
import { LocalizeFormattedNumber, LocalizeText } from '../../api';
|
|
||||||
import { Column, Flex, LayoutCurrencyIcon, LayoutImage, Text } from '../../common';
|
|
||||||
import { useRareValues } from '../../hooks';
|
|
||||||
import { NitroCard, NitroInput } from '../../layout';
|
|
||||||
|
|
||||||
interface RareValueRow
|
|
||||||
{
|
|
||||||
spriteId: number;
|
|
||||||
name: string;
|
|
||||||
iconUrl: string;
|
|
||||||
value: IRareValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const RareValuesView: FC<{}> = () =>
|
|
||||||
{
|
|
||||||
const [ isVisible, setIsVisible ] = useState(false);
|
|
||||||
const [ searchValue, setSearchValue ] = useState('');
|
|
||||||
const { values = null, loaded = false } = useRareValues();
|
|
||||||
|
|
||||||
useEffect(() =>
|
|
||||||
{
|
|
||||||
const linkTracker: ILinkEventTracker = {
|
|
||||||
linkReceived: (url: string) =>
|
|
||||||
{
|
|
||||||
const parts = url.split('/');
|
|
||||||
if(parts.length < 2) return;
|
|
||||||
|
|
||||||
switch(parts[1])
|
|
||||||
{
|
|
||||||
case 'show': setIsVisible(true); return;
|
|
||||||
case 'hide': setIsVisible(false); return;
|
|
||||||
case 'toggle': setIsVisible(prev => !prev); return;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
eventUrlPrefix: 'rare-values/',
|
|
||||||
};
|
|
||||||
|
|
||||||
AddLinkEventTracker(linkTracker);
|
|
||||||
|
|
||||||
return () => RemoveLinkEventTracker(linkTracker);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const rows = useMemo<RareValueRow[]>(() =>
|
|
||||||
{
|
|
||||||
if(!values) return [];
|
|
||||||
|
|
||||||
const list: RareValueRow[] = [];
|
|
||||||
|
|
||||||
values.forEach((value, spriteId) =>
|
|
||||||
{
|
|
||||||
if(value.points <= 0) return;
|
|
||||||
|
|
||||||
const floorData = GetSessionDataManager().getFloorItemData(spriteId);
|
|
||||||
const wallData = floorData ? null : GetSessionDataManager().getWallItemData(spriteId);
|
|
||||||
const data = (floorData ?? wallData);
|
|
||||||
|
|
||||||
if(!data) return;
|
|
||||||
|
|
||||||
const iconUrl = (floorData
|
|
||||||
? GetRoomEngine().getFurnitureFloorIconUrl(spriteId)
|
|
||||||
: GetRoomEngine().getFurnitureWallIconUrl(spriteId));
|
|
||||||
|
|
||||||
list.push({ spriteId, name: (data.name || data.className || `#${ spriteId }`), iconUrl, value });
|
|
||||||
});
|
|
||||||
|
|
||||||
list.sort((a, b) => (b.value.points - a.value.points));
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}, [ values ]);
|
|
||||||
|
|
||||||
const filtered = useMemo<RareValueRow[]>(() =>
|
|
||||||
{
|
|
||||||
const query = searchValue.trim().toLocaleLowerCase();
|
|
||||||
|
|
||||||
if(!query) return rows;
|
|
||||||
|
|
||||||
return rows.filter(row => row.name.toLocaleLowerCase().includes(query));
|
|
||||||
}, [ rows, searchValue ]);
|
|
||||||
|
|
||||||
if(!isVisible) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<NitroCard className="w-[420px] h-[480px]" uniqueKey="rare-values">
|
|
||||||
<NitroCard.Header
|
|
||||||
headerText={ LocalizeText('rarevalues.title') }
|
|
||||||
onCloseClick={ () => setIsVisible(false) } />
|
|
||||||
<NitroCard.Content>
|
|
||||||
<Column gap={ 2 } className="h-full p-1">
|
|
||||||
<NitroInput
|
|
||||||
placeholder={ LocalizeText('generic.search') }
|
|
||||||
value={ searchValue }
|
|
||||||
onChange={ event => setSearchValue(event.target.value) } />
|
|
||||||
<Column gap={ 0 } overflow="auto" className="grow">
|
|
||||||
{ !loaded &&
|
|
||||||
<Text center className="mt-2 text-black/60">{ LocalizeText('rarevalues.loading') }</Text> }
|
|
||||||
{ (loaded && !filtered.length) &&
|
|
||||||
<Text center className="mt-2 text-black/60">{ LocalizeText('rarevalues.empty') }</Text> }
|
|
||||||
{ filtered.map(row => (
|
|
||||||
<Flex key={ row.spriteId } alignItems="center" gap={ 2 } className="border-b border-black/10 py-1.5 hover:bg-black/5">
|
|
||||||
<LayoutImage imageUrl={ row.iconUrl } className="h-10 w-10 shrink-0 bg-contain bg-center bg-no-repeat" />
|
|
||||||
<Text truncate className="grow text-[#1f2d34]">{ row.name }</Text>
|
|
||||||
<Flex alignItems="center" gap={ 1 } className="shrink-0">
|
|
||||||
<Text bold textEnd className="text-[#2f6f95]">{ LocalizeFormattedNumber(row.value.points) }</Text>
|
|
||||||
<LayoutCurrencyIcon type={ row.value.pointsType } />
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
)) }
|
|
||||||
</Column>
|
|
||||||
</Column>
|
|
||||||
</NitroCard.Content>
|
|
||||||
</NitroCard>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -176,9 +176,15 @@
|
|||||||
border: 0 !important;
|
border: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
& .nitro-card-accordion-set-header span {
|
/* The header title is rendered by the shared <Text> component, which is a
|
||||||
font-size: 12px;
|
<div> (not a <span>) — so target the div too, otherwise it keeps the app
|
||||||
|
default size and shows as oversized "testoni". */
|
||||||
|
& .nitro-card-accordion-set-header span,
|
||||||
|
& .nitro-card-accordion-set-header > div {
|
||||||
|
font-size: 12px !important;
|
||||||
|
font-weight: 700;
|
||||||
color: #111 !important;
|
color: #111 !important;
|
||||||
|
line-height: 1.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
& .nitro-card-accordion-set-header .fa-icon {
|
& .nitro-card-accordion-set-header .fa-icon {
|
||||||
@@ -800,3 +806,43 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------ *
|
||||||
|
* Flat (non-nested) overrides. The rules above live inside a nested
|
||||||
|
* `.nitro-friends { & ... }` block; these are written flat so they
|
||||||
|
* apply reliably and win by source order. They fix two things the
|
||||||
|
* nested rules didn't: the oversized/overflowing friend-list heads and
|
||||||
|
* the oversized accordion section titles ("testoni").
|
||||||
|
* ------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
/* Friend-list avatar: clip a small box and centre the head, same proven
|
||||||
|
recipe as the messenger head. `inset: auto` cancels the component's
|
||||||
|
`inset-0`, otherwise the 130px head fills the row and overflows. */
|
||||||
|
.nitro-friends .friends-list-avatar {
|
||||||
|
position: relative !important;
|
||||||
|
width: 34px;
|
||||||
|
height: 36px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nitro-friends .friends-list-avatar .avatar-image {
|
||||||
|
position: absolute !important;
|
||||||
|
inset: auto !important;
|
||||||
|
left: 50% !important;
|
||||||
|
top: 56% !important;
|
||||||
|
width: 54px !important;
|
||||||
|
height: 54px !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
background-position: center center !important;
|
||||||
|
transform: translate(-50%, -50%) scale(.95) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Accordion section titles are rendered by <Text> (a <div>, not a <span>),
|
||||||
|
so size the div too — otherwise they show oversized. */
|
||||||
|
.nitro-friends .nitro-card-accordion-set-header > div,
|
||||||
|
.nitro-friends .nitro-card-accordion-set-header span {
|
||||||
|
font-size: 12px !important;
|
||||||
|
font-weight: 700 !important;
|
||||||
|
line-height: 1.15 !important;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
.nitro-extended-profile-window {
|
|
||||||
border-radius: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nitro-extended-profile-window .nitro-card-header-shell {
|
.nitro-extended-profile-window .nitro-card-header-shell {
|
||||||
min-height: 34px;
|
min-height: 34px;
|
||||||
max-height: 34px;
|
max-height: 34px;
|
||||||
@@ -46,32 +42,31 @@
|
|||||||
|
|
||||||
.nitro-extended-profile__identity {
|
.nitro-extended-profile__identity {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 56px minmax(0, 1fr);
|
grid-template-columns: 68px minmax(0, 1fr);
|
||||||
gap: 8px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Mirror the room infostand exactly: a 68x135 flex column (= profile-background)
|
||||||
|
that centres the avatar horizontally and clips it; the stand/overlay sit on
|
||||||
|
top as absolute layers. The avatar keeps its component default classes
|
||||||
|
(relative w-[90px] h-[130px] left-[-2px]) so it lines up with bg + stand and
|
||||||
|
isn't crooked. Do NOT absolutely position or force width/height on it. */
|
||||||
.nitro-extended-profile__avatar-shell {
|
.nitro-extended-profile__avatar-shell {
|
||||||
width: 56px;
|
width: 68px;
|
||||||
height: 113px;
|
height: 135px;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background-size: cover;
|
border-radius: 3px;
|
||||||
background-position: center;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nitro-extended-profile__avatar-stand,
|
.nitro-extended-profile__avatar-stand,
|
||||||
.nitro-extended-profile__avatar-overlay {
|
.nitro-extended-profile__avatar-overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
top: 0;
|
||||||
}
|
left: 0;
|
||||||
|
|
||||||
.nitro-extended-profile__avatar-image {
|
|
||||||
position: absolute !important;
|
|
||||||
left: 50% !important;
|
|
||||||
bottom: -4px;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
width: auto !important;
|
|
||||||
height: auto !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.nitro-extended-profile__identity-copy {
|
.nitro-extended-profile__identity-copy {
|
||||||
@@ -253,14 +248,27 @@
|
|||||||
|
|
||||||
.nitro-extended-profile__relationship-head {
|
.nitro-extended-profile__relationship-head {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: -2px;
|
right: 3px;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
width: 34px;
|
width: 30px;
|
||||||
height: 34px;
|
height: 32px;
|
||||||
transform: translateY(-50%);
|
transform: translateY(-50%);
|
||||||
display: flex;
|
overflow: hidden;
|
||||||
align-items: center;
|
}
|
||||||
justify-content: center;
|
|
||||||
|
/* Same proven recipe as the messenger head: clip a small box and centre a
|
||||||
|
54x54 avatar in it. `inset: auto` cancels the component's `inset-0` so the
|
||||||
|
width/position take effect (otherwise the head overflows huge). */
|
||||||
|
.nitro-extended-profile__relationship-head .avatar-image {
|
||||||
|
position: absolute !important;
|
||||||
|
inset: auto !important;
|
||||||
|
left: 50% !important;
|
||||||
|
top: 54% !important;
|
||||||
|
width: 50px !important;
|
||||||
|
height: 50px !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
background-position: center center !important;
|
||||||
|
transform: translate(-50%, -50%) scale(.95) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nitro-extended-profile__relationship-subcopy {
|
.nitro-extended-profile__relationship-subcopy {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export * from './useCatalog';
|
export * from './useCatalog';
|
||||||
|
export * from './useCatalogClassicStyle';
|
||||||
export * from './useCatalogFavorites';
|
export * from './useCatalogFavorites';
|
||||||
export * from './useCatalogPlaceMultipleItems';
|
export * from './useCatalogPlaceMultipleItems';
|
||||||
export * from './useCatalogSkipPurchaseConfirmation';
|
export * from './useCatalogSkipPurchaseConfirmation';
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { useBetween } from 'use-between';
|
||||||
|
import { GetConfigurationValue, LocalStorageKeys } from '../../api';
|
||||||
|
import { useLocalStorage } from '../useLocalStorage';
|
||||||
|
|
||||||
|
// Per-user toggle for the catalog visual style.
|
||||||
|
// - true => classic (old) catalog look
|
||||||
|
// - false => modern (rebuilt) catalog look
|
||||||
|
// The default for users who never touched the toggle comes from the global
|
||||||
|
// `catalog.classic.style` flag in ui-config.json, so an admin can flip the
|
||||||
|
// default for everyone (true = classic for all, false = modern for all)
|
||||||
|
// while still letting each user override it from the settings panel.
|
||||||
|
const useCatalogClassicStyleState = () => useLocalStorage<boolean>(LocalStorageKeys.CATALOG_CLASSIC_STYLE, GetConfigurationValue<boolean>('catalog.classic.style', false));
|
||||||
|
|
||||||
|
export const useCatalogClassicStyle = () => useBetween(useCatalogClassicStyleState);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { NavigatorSearchComposer, NavigatorSearchEvent,
|
import { FlatCreatedEvent, NavigatorSearchComposer, NavigatorSearchEvent, NavigatorSearchResultSet } from '@nitrots/nitro-renderer';
|
||||||
NavigatorSearchResultSet } from '@nitrots/nitro-renderer';
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { SendMessageComposer } from '../../api';
|
import { SendMessageComposer } from '../../api';
|
||||||
import { useMessageEvent } from '../events';
|
import { useMessageEvent } from '../events';
|
||||||
@@ -23,6 +23,7 @@ export const useNavigatorSearch = () =>
|
|||||||
{
|
{
|
||||||
const tabCode = useNavigatorUiStore(s => s.currentTabCode);
|
const tabCode = useNavigatorUiStore(s => s.currentTabCode);
|
||||||
const filter = useNavigatorUiStore(s => s.currentFilter);
|
const filter = useNavigatorUiStore(s => s.currentFilter);
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const [ searchResult, setSearchResult ] = useState<NavigatorSearchResultSet | null>(null);
|
const [ searchResult, setSearchResult ] = useState<NavigatorSearchResultSet | null>(null);
|
||||||
const [ isFetching, setIsFetching ] = useState(false);
|
const [ isFetching, setIsFetching ] = useState(false);
|
||||||
@@ -40,15 +41,25 @@ export const useNavigatorSearch = () =>
|
|||||||
const result = event.getParser()?.result;
|
const result = event.getParser()?.result;
|
||||||
if(!result) return;
|
if(!result) return;
|
||||||
|
|
||||||
// Accept any incoming result for the currently active tab. Server
|
// No active tab → the search query is disabled, ignore any event.
|
||||||
// can push extra results unprompted (e.g. after a room is
|
// Otherwise only accept the event whose code matches the active tab.
|
||||||
// created); accepting them keeps the panel in sync.
|
if(!tabCode || (result.code !== tabCode)) return;
|
||||||
if(tabCode && result.code !== tabCode) return;
|
|
||||||
|
|
||||||
setSearchResult(result);
|
setSearchResult(result);
|
||||||
setIsFetching(false);
|
setIsFetching(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// A newly created room invalidates the current search so it refetches.
|
||||||
|
useMessageEvent<FlatCreatedEvent>(FlatCreatedEvent, () =>
|
||||||
|
{
|
||||||
|
queryClient.invalidateQueries({ queryKey: [ 'navigator', 'search' ] });
|
||||||
|
|
||||||
|
if(!tabCode) return;
|
||||||
|
|
||||||
|
setIsFetching(true);
|
||||||
|
SendMessageComposer(new NavigatorSearchComposer(tabCode, filter));
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
searchResult,
|
searchResult,
|
||||||
isFetching,
|
isFetching,
|
||||||
|
|||||||
Reference in New Issue
Block a user