mirror of
https://github.com/duckietm/Nitro-V3.git
synced 2026-06-19 15:06:20 +00:00
Merge pull request #211 from simoleo89/fix/furni-editor-wall-items
fix(infostand): show Edit Furni button for wall items
This commit is contained in:
@@ -18,6 +18,56 @@ const PICKUP_MODE_NONE: number = 0;
|
|||||||
const PICKUP_MODE_EJECT: number = 1;
|
const PICKUP_MODE_EJECT: number = 1;
|
||||||
const PICKUP_MODE_FULL: number = 2;
|
const PICKUP_MODE_FULL: number = 2;
|
||||||
|
|
||||||
|
function getValidRoomObjectDirection(roomObject: any, isPositive: boolean)
|
||||||
|
{
|
||||||
|
if(!roomObject || !roomObject.model) return 0;
|
||||||
|
|
||||||
|
let allowedDirections: number[] = [];
|
||||||
|
|
||||||
|
if(roomObject.type === 'monster_plant')
|
||||||
|
{
|
||||||
|
allowedDirections = roomObject.model.getValue('pet_allowed_directions');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
allowedDirections = roomObject.model.getValue('furniture_allowed_directions');
|
||||||
|
}
|
||||||
|
|
||||||
|
let direction = roomObject.getDirection().x;
|
||||||
|
|
||||||
|
if(allowedDirections && allowedDirections.length)
|
||||||
|
{
|
||||||
|
let index = allowedDirections.indexOf(direction);
|
||||||
|
|
||||||
|
if(index < 0)
|
||||||
|
{
|
||||||
|
index = 0;
|
||||||
|
|
||||||
|
for(let i = 0; i < allowedDirections.length; i++)
|
||||||
|
{
|
||||||
|
if(direction <= allowedDirections[i]) break;
|
||||||
|
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
index = index % allowedDirections.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isPositive)
|
||||||
|
{
|
||||||
|
index = (index + 1) % allowedDirections.length;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
index = (index - 1 + allowedDirections.length) % allowedDirections.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
direction = allowedDirections[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
return direction;
|
||||||
|
}
|
||||||
|
|
||||||
export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props =>
|
export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props =>
|
||||||
{
|
{
|
||||||
const { avatarInfo = null, onClose = null } = props;
|
const { avatarInfo = null, onClose = null } = props;
|
||||||
@@ -78,56 +128,6 @@ export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props
|
|||||||
SendMessageComposer(new UpdateFurniturePositionComposer(avatarInfo.id, newX, newY, Math.round(newZ * 10000), newDirection));
|
SendMessageComposer(new UpdateFurniturePositionComposer(avatarInfo.id, newX, newY, Math.round(newZ * 10000), newDirection));
|
||||||
}, [ avatarInfo ]);
|
}, [ avatarInfo ]);
|
||||||
|
|
||||||
function getValidRoomObjectDirection(roomObject: any, isPositive: boolean)
|
|
||||||
{
|
|
||||||
if(!roomObject || !roomObject.model) return 0;
|
|
||||||
|
|
||||||
let allowedDirections: number[] = [];
|
|
||||||
|
|
||||||
if(roomObject.type === 'monster_plant')
|
|
||||||
{
|
|
||||||
allowedDirections = roomObject.model.getValue('pet_allowed_directions');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
allowedDirections = roomObject.model.getValue('furniture_allowed_directions');
|
|
||||||
}
|
|
||||||
|
|
||||||
let direction = roomObject.getDirection().x;
|
|
||||||
|
|
||||||
if(allowedDirections && allowedDirections.length)
|
|
||||||
{
|
|
||||||
let index = allowedDirections.indexOf(direction);
|
|
||||||
|
|
||||||
if(index < 0)
|
|
||||||
{
|
|
||||||
index = 0;
|
|
||||||
|
|
||||||
for(let i = 0; i < allowedDirections.length; i++)
|
|
||||||
{
|
|
||||||
if(direction <= allowedDirections[i]) break;
|
|
||||||
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
index = index % allowedDirections.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isPositive)
|
|
||||||
{
|
|
||||||
index = (index + 1) % allowedDirections.length;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
index = (index - 1 + allowedDirections.length) % allowedDirections.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
direction = allowedDirections[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
return direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleHeightChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) =>
|
const handleHeightChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) =>
|
||||||
{
|
{
|
||||||
let newZ = parseFloat(event.target.value);
|
let newZ = parseFloat(event.target.value);
|
||||||
@@ -421,7 +421,11 @@ export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props
|
|||||||
if(key === 'offsetX') value = String(x);
|
if(key === 'offsetX') value = String(x);
|
||||||
else if(key === 'offsetY') value = String(y);
|
else if(key === 'offsetY') value = String(y);
|
||||||
else if(key === 'offsetZ') value = String(z);
|
else if(key === 'offsetZ') value = String(z);
|
||||||
else if(key === 'scale') { value = String(scale); hasScale = true; }
|
else if(key === 'scale')
|
||||||
|
{
|
||||||
|
value = String(scale);
|
||||||
|
hasScale = true;
|
||||||
|
}
|
||||||
|
|
||||||
clone[i] = value;
|
clone[i] = value;
|
||||||
map.set(key, value);
|
map.set(key, value);
|
||||||
@@ -638,13 +642,6 @@ export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props
|
|||||||
})() }</Text>
|
})() }</Text>
|
||||||
</div>
|
</div>
|
||||||
</div> }
|
</div> }
|
||||||
{ (!avatarInfo.isWallItem && canMove) &&
|
|
||||||
<>
|
|
||||||
<button
|
|
||||||
className="w-full text-white text-xs bg-[#2a2a3a] hover:bg-[#3a3a4a] border border-[#ffffff33] rounded px-2 py-1 cursor-pointer transition-colors"
|
|
||||||
onClick={ () => setDropdownOpen(!dropdownOpen) }>
|
|
||||||
{ dropdownOpen ? `${LocalizeText('widget.furni.present.close')} Buildtools` : `${LocalizeText('navigator.roomsettings.doormode.open')} Buildtools` }
|
|
||||||
</button>
|
|
||||||
{ isModerator &&
|
{ isModerator &&
|
||||||
<button
|
<button
|
||||||
className="w-full text-white text-xs bg-[#1e7295] hover:bg-[#1a617f] border border-[#ffffff33] rounded px-2 py-1 cursor-pointer transition-colors"
|
className="w-full text-white text-xs bg-[#1e7295] hover:bg-[#1a617f] border border-[#ffffff33] rounded px-2 py-1 cursor-pointer transition-colors"
|
||||||
@@ -659,6 +656,13 @@ export const InfoStandWidgetFurniView: FC<InfoStandWidgetFurniViewProps> = props
|
|||||||
} }>
|
} }>
|
||||||
Edit Furni
|
Edit Furni
|
||||||
</button> }
|
</button> }
|
||||||
|
{ (!avatarInfo.isWallItem && canMove) &&
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
className="w-full text-white text-xs bg-[#2a2a3a] hover:bg-[#3a3a4a] border border-[#ffffff33] rounded px-2 py-1 cursor-pointer transition-colors"
|
||||||
|
onClick={ () => setDropdownOpen(!dropdownOpen) }>
|
||||||
|
{ dropdownOpen ? `${LocalizeText('widget.furni.present.close')} Buildtools` : `${LocalizeText('navigator.roomsettings.doormode.open')} Buildtools` }
|
||||||
|
</button>
|
||||||
{ dropdownOpen &&
|
{ dropdownOpen &&
|
||||||
<div className="flex gap-[4px] w-full">
|
<div className="flex gap-[4px] w-full">
|
||||||
{ /* Left panel: position + rotation */ }
|
{ /* Left panel: position + rotation */ }
|
||||||
|
|||||||
Reference in New Issue
Block a user