expose the option to save HUDs into notecard on the API

master
UbitUmarov 2020-06-01 21:05:57 +01:00
parent 873b3b0af6
commit 9bd5310fe8
3 changed files with 95 additions and 51 deletions

View File

@ -3023,7 +3023,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// <param name="avatar"></param>
/// <param name="notecard">The name of the notecard to which to save the appearance.</param>
/// <returns>The asset ID of the notecard saved.</returns>
public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard)
public LSL_Key osNpcSaveAppearance(LSL_Key npc, LSL_String notecard)
{
return NpcSaveAppearance(npc, notecard, true);
}
public LSL_Key osNpcSaveAppearance(LSL_Key npc, LSL_String notecard, LSL_Integer includeHuds)
{
return NpcSaveAppearance(npc, notecard, includeHuds == 0);
}
protected LSL_Key NpcSaveAppearance(LSL_Key npc, string notecard, bool NoHUds)
{
CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance");
@ -3031,14 +3042,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (npcModule != null)
{
UUID npcId;
if (!UUID.TryParse(npc.m_string, out npcId))
if (!UUID.TryParse(npc.m_string, out UUID npcId))
return new LSL_Key(UUID.Zero.ToString());
if (!npcModule.CheckPermissions(npcId, m_host.OwnerID))
return new LSL_Key(UUID.Zero.ToString());
return SaveAppearanceToNotecard(npcId, notecard);
return SaveAppearanceToNotecard(npcId, notecard, NoHUds);
}
return new LSL_Key(UUID.Zero.ToString());
@ -3522,32 +3532,57 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// </summary>
/// <param name="notecard">The name of the notecard to which to save the appearance.</param>
/// <returns>The asset ID of the notecard saved.</returns>
public LSL_Key osOwnerSaveAppearance(string notecard)
public LSL_Key osOwnerSaveAppearance(LSL_String notecard)
{
CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance");
return SaveAppearanceToNotecard(m_host.OwnerID, notecard);
return SaveAppearanceToNotecard(m_host.OwnerID, notecard, false);
}
public LSL_Key osAgentSaveAppearance(LSL_Key avatarKey, string notecard)
public LSL_Key osOwnerSaveAppearance(LSL_String notecard, LSL_Integer includeHuds)
{
CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance");
return SaveAppearanceToNotecard(m_host.OwnerID, notecard, includeHuds == 0);
}
public LSL_Key osAgentSaveAppearance(LSL_Key avatarKey, LSL_String notecard)
{
CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance");
UUID avatarId;
if (!UUID.TryParse(avatarKey, out avatarId))
if (!UUID.TryParse(avatarKey, out UUID avatarId))
return new LSL_Key(UUID.Zero.ToString());
return SaveAppearanceToNotecard(avatarId, notecard);
return SaveAppearanceToNotecard(avatarId, notecard, false);
}
protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecard)
public LSL_Key osAgentSaveAppearance(LSL_Key avatarKey, LSL_String notecard, LSL_Integer includeHuds)
{
CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance");
if (!UUID.TryParse(avatarKey, out UUID avatarId))
return new LSL_Key(UUID.Zero.ToString());
return SaveAppearanceToNotecard(avatarId, notecard, includeHuds == 0);
}
protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecard, bool NoHuds)
{
ScenePresence sp = World.GetScenePresence(avatarId);
if (sp == null || sp.IsChildAgent)
return new LSL_Key(UUID.Zero.ToString());
return SaveAppearanceToNotecard(sp, notecard, NoHuds);
}
protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecard, bool NoHuds)
{
IAvatarFactoryModule appearanceModule = World.RequestModuleInterface<IAvatarFactoryModule>();
if (appearanceModule != null)
{
appearanceModule.SaveBakedTextures(sp.UUID);
OSDMap appearancePacked = sp.Appearance.PackForNotecard();
OSDMap appearancePacked = sp.Appearance.PackForNotecard(NoHuds);
TaskInventoryItem item
= SaveNotecard(notecard, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);
@ -3560,16 +3595,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecard)
{
ScenePresence sp = World.GetScenePresence(avatarId);
if (sp == null || sp.IsChildAgent)
return new LSL_Key(UUID.Zero.ToString());
return SaveAppearanceToNotecard(sp, notecard);
}
/// <summary>
/// Get the gender as specified in avatar appearance for a given avatar key
/// </summary>

View File

@ -337,13 +337,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
/// <returns>TRUE if the key belongs to an npc in the scene. FALSE otherwise.</returns>
LSL_Integer osIsNpc(LSL_Key npc);
key osNpcCreate(string user, string name, vector position, string notecard);
key osNpcCreate(string user, string name, vector position, string notecard, int options);
LSL_Key osNpcSaveAppearance(key npc, string notecard);
void osNpcLoadAppearance(key npc, string notecard);
vector osNpcGetPos(key npc);
void osNpcMoveTo(key npc, vector position);
void osNpcMoveToTarget(key npc, vector target, int options);
key osNpcCreate(string user, string name, vector position, string notecard);
key osNpcCreate(string user, string name, vector position, string notecard, int options);
LSL_Key osNpcSaveAppearance(key npc, LSL_String notecard);
LSL_Key osNpcSaveAppearance(key npc, LSL_String notecard, LSL_Integer includeHuds);
void osNpcLoadAppearance(key npc, string notecard);
vector osNpcGetPos(key npc);
void osNpcMoveTo(key npc, vector position);
void osNpcMoveToTarget(key npc, vector target, int options);
/// <summary>
/// Get the owner of the NPC
@ -352,27 +353,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
/// <returns>
/// The owner of the NPC for an owned NPC. The NPC's agent id for an unowned NPC. UUID.Zero if the key is not an npc.
/// </returns>
LSL_Key osNpcGetOwner(key npc);
LSL_Key osNpcGetOwner(key npc);
rotation osNpcGetRot(key npc);
void osNpcSetRot(LSL_Key npc, rotation rot);
void osNpcStopMoveToTarget(LSL_Key npc);
void osNpcSetProfileAbout(LSL_Key npc, string about);
void osNpcSetProfileImage(LSL_Key npc, string image);
void osNpcSay(key npc, string message);
void osNpcSay(key npc, int channel, string message);
void osNpcSayTo(LSL_Key npc, LSL_Key target, int channel, string msg);
void osNpcShout(key npc, int channel, string message);
void osNpcSit(key npc, key target, int options);
void osNpcStand(LSL_Key npc);
void osNpcRemove(key npc);
void osNpcPlayAnimation(LSL_Key npc, string animation);
void osNpcStopAnimation(LSL_Key npc, string animation);
void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num);
void osNpcWhisper(key npc, int channel, string message);
rotation osNpcGetRot(key npc);
LSL_Key osOwnerSaveAppearance(string notecard);
LSL_Key osAgentSaveAppearance(key agentId, string notecard);
void osNpcSetRot(LSL_Key npc, rotation rot);
void osNpcStopMoveToTarget(LSL_Key npc);
void osNpcSetProfileAbout(LSL_Key npc, string about);
void osNpcSetProfileImage(LSL_Key npc, string image);
void osNpcSay(key npc, string message);
void osNpcSay(key npc, int channel, string message);
void osNpcSayTo(LSL_Key npc, LSL_Key target, int channel, string msg);
void osNpcShout(key npc, int channel, string message);
void osNpcSit(key npc, key target, int options);
void osNpcStand(LSL_Key npc);
void osNpcRemove(key npc);
void osNpcPlayAnimation(LSL_Key npc, string animation);
void osNpcStopAnimation(LSL_Key npc, string animation);
void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num);
void osNpcWhisper(key npc, int channel, string message);
LSL_Key osOwnerSaveAppearance(LSL_String notecard);
LSL_Key osOwnerSaveAppearance(LSL_String notecard, LSL_Integer includeHuds);
LSL_Key osAgentSaveAppearance(key agentId, LSL_String notecard);
LSL_Key osAgentSaveAppearance(key agentId, LSL_String notecard, LSL_Integer includeHuds);
key osGetGender(LSL_Key rawAvatarId);
key osGetMapTexture();

View File

@ -628,11 +628,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom, options);
}
public key osNpcSaveAppearance(key npc, string notecard)
public key osNpcSaveAppearance(key npc, LSL_String notecard)
{
return m_OSSL_Functions.osNpcSaveAppearance(npc, notecard);
}
public key osNpcSaveAppearance(key npc, LSL_String notecard, LSL_Integer includeHuds)
{
return m_OSSL_Functions.osNpcSaveAppearance(npc, notecard, includeHuds);
}
public void osNpcLoadAppearance(key npc, string notecard)
{
m_OSSL_Functions.osNpcLoadAppearance(npc, notecard);
@ -738,16 +743,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osNpcTouch(npcLSL_Key, object_key, link_num);
}
public LSL_Key osOwnerSaveAppearance(string notecard)
public LSL_Key osOwnerSaveAppearance(LSL_String notecard)
{
return m_OSSL_Functions.osOwnerSaveAppearance(notecard);
}
public LSL_Key osAgentSaveAppearance(LSL_Key agentId, string notecard)
public LSL_Key osOwnerSaveAppearance(LSL_String notecard, LSL_Integer includeHuds)
{
return m_OSSL_Functions.osOwnerSaveAppearance(notecard, includeHuds);
}
public LSL_Key osAgentSaveAppearance(LSL_Key agentId, LSL_String notecard)
{
return m_OSSL_Functions.osAgentSaveAppearance(agentId, notecard);
}
public LSL_Key osAgentSaveAppearance(LSL_Key agentId, LSL_String notecard, LSL_Integer includeHuds)
{
return m_OSSL_Functions.osAgentSaveAppearance(agentId, notecard, includeHuds);
}
public OSSLPrim Prim;
[Serializable]