mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 22:26:09 +08:00
a few changes
This commit is contained in:
@@ -5436,6 +5436,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
if (item is LSL_Integer LSL_Integeritem)
|
||||
return LSL_Integeritem;
|
||||
if (item is int LSL_Intitem)
|
||||
return new LSL_Integer(LSL_Intitem);
|
||||
if (item is LSL_Float LSL_Floatitem)
|
||||
return new LSL_Integer(LSL_Floatitem.value);
|
||||
return new LSL_Integer(item.ToString());
|
||||
@@ -5461,11 +5463,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return 0;
|
||||
|
||||
// valid keys seem to get parsed as integers then converted to floats
|
||||
if (item is LSL_Key)
|
||||
if (item is LSL_Key lslk)
|
||||
{
|
||||
string s = item.ToString();
|
||||
if(UUID.TryParse(s, out UUID _))
|
||||
return Convert.ToDouble(new LSL_Integer(s).value);
|
||||
if(UUID.TryParse(lslk.m_string, out UUID _))
|
||||
return Convert.ToDouble(new LSL_Integer(lslk.m_string).value);
|
||||
// we can't do this because a string is also a LSL_Key for now :(
|
||||
//else
|
||||
// return 0;
|
||||
@@ -5473,10 +5474,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
try
|
||||
{
|
||||
if (item is LSL_Integer intitem)
|
||||
return new LSL_Float(intitem.value);
|
||||
if (item is LSL_Float floatitem)
|
||||
return floatitem;
|
||||
if (item is LSL_Integer intitem)
|
||||
return new LSL_Float(intitem.value);
|
||||
if (item is int LSL_Intitem)
|
||||
return new LSL_Float(LSL_Intitem);
|
||||
if (item is LSL_String lstringitem)
|
||||
{
|
||||
Match m = Regex.Match(lstringitem.m_string, "^\\s*(-?\\+?[,0-9]+\\.?[0-9]*)");
|
||||
|
||||
@@ -1417,25 +1417,48 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
CheckThreatLevel();
|
||||
|
||||
return osSetPenColor(drawList, color, (LSL_Float)1.0);
|
||||
byte argbR = Utils.FloatZeroOneToByte((float)color.x);
|
||||
byte argbG = Utils.FloatZeroOneToByte((float)color.y);
|
||||
byte argbB = Utils.FloatZeroOneToByte((float)color.z);
|
||||
|
||||
StringBuilder sb = new(19);
|
||||
sb.Append("PenColor FF");
|
||||
sb.Append(Utils.charHighNibbleToHexChar(argbR));
|
||||
sb.Append(Utils.charLowNibbleToHexChar(argbR));
|
||||
sb.Append(Utils.charHighNibbleToHexChar(argbG));
|
||||
sb.Append(Utils.charLowNibbleToHexChar(argbG));
|
||||
sb.Append(Utils.charHighNibbleToHexChar(argbB));
|
||||
sb.Append(Utils.charLowNibbleToHexChar(argbB));
|
||||
sb.Append("; ");
|
||||
|
||||
drawList += sb.ToString();
|
||||
return drawList;
|
||||
}
|
||||
|
||||
public string osSetPenColor(string drawList, LSL_Types.Vector3 color, LSL_Float alpha)
|
||||
{
|
||||
CheckThreatLevel() ;
|
||||
CheckThreatLevel();
|
||||
|
||||
int argbA = (int) (Util.Clamp ((float)alpha, 0f, 1f) * 255f);
|
||||
int argbR = (int) (Util.Clamp ((float)color.x, 0f, 1f) * 255f);
|
||||
int argbG = (int) (Util.Clamp ((float)color.y, 0f, 1f) * 255f);
|
||||
int argbB = (int) (Util.Clamp ((float)color.z, 0f, 1f) * 255f);
|
||||
|
||||
StringBuilder hexColorBuilder = new StringBuilder();
|
||||
hexColorBuilder.Append(argbA.ToString("X2"));
|
||||
hexColorBuilder.Append(argbR.ToString("X2"));
|
||||
hexColorBuilder.Append(argbG.ToString("X2"));
|
||||
hexColorBuilder.Append(argbB.ToString("X2"));
|
||||
byte argbA = Utils.FloatZeroOneToByte((float)alpha);
|
||||
byte argbR = Utils.FloatZeroOneToByte((float)color.x);
|
||||
byte argbG = Utils.FloatZeroOneToByte((float)color.y);
|
||||
byte argbB = Utils.FloatZeroOneToByte((float)color.z);
|
||||
|
||||
return osSetPenColor(drawList, hexColorBuilder.ToString());
|
||||
StringBuilder sb = new(19);
|
||||
sb.Append("PenColor ");
|
||||
sb.Append(Utils.charHighNibbleToHexChar(argbA));
|
||||
sb.Append(Utils.charLowNibbleToHexChar(argbA));
|
||||
sb.Append(Utils.charHighNibbleToHexChar(argbR));
|
||||
sb.Append(Utils.charLowNibbleToHexChar(argbR));
|
||||
sb.Append(Utils.charHighNibbleToHexChar(argbG));
|
||||
sb.Append(Utils.charLowNibbleToHexChar(argbG));
|
||||
sb.Append(Utils.charHighNibbleToHexChar(argbB));
|
||||
sb.Append(Utils.charLowNibbleToHexChar(argbB));
|
||||
sb.Append(';');
|
||||
sb.Append(' ');
|
||||
|
||||
drawList += sb.ToString();
|
||||
return drawList;
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
|
||||
Reference in New Issue
Block a user