Normalization of OSSL function names.

Added the following replacement functions for compliance to the OSSL standards stated on the wiki:
osGetTerrainHeight
osSetTerrainHeight
osGetSunParam
osSetSunParam
osSetPenColor

The functions that do not comply to the standard give a warning when used but work normally otherwise.

The graphics primitive drawing command "PenColor" has also been added as well as dynamic texture parameter "bgcolor" as an alternative to "bgcolour".

The following two functions have been renamed because they are not enabled yet aynway:
osWindParamSet => osSetWindParam
osWindParamGet => osGetWindParam
viewer-2-initial-appearance
Marck 2010-12-10 22:13:05 +01:00
parent d8fd917076
commit b512ecd1dc
4 changed files with 115 additions and 31 deletions

View File

@ -165,7 +165,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
int width = 256; int width = 256;
int height = 256; int height = 256;
int alpha = 255; // 0 is transparent int alpha = 255; // 0 is transparent
Color bgColour = Color.White; // Default background color Color bgColor = Color.White; // Default background color
char altDataDelim = ';'; char altDataDelim = ';';
char[] paramDelimiter = { ',' }; char[] paramDelimiter = { ',' };
@ -253,15 +253,16 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
alpha = 256; alpha = 256;
} }
break; break;
case "bgcolor":
case "bgcolour": case "bgcolour":
int hex = 0; int hex = 0;
if (Int32.TryParse(value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out hex)) if (Int32.TryParse(value, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out hex))
{ {
bgColour = Color.FromArgb(hex); bgColor = Color.FromArgb(hex);
} }
else else
{ {
bgColour = Color.FromName(value); bgColor = Color.FromName(value);
} }
break; break;
case "altdatadelim": case "altdatadelim":
@ -315,7 +316,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
// background color in their scripts, only do when fully opaque // background color in their scripts, only do when fully opaque
if (alpha >= 255) if (alpha >= 255)
{ {
graph.FillRectangle(new SolidBrush(bgColour), 0, 0, width, height); graph.FillRectangle(new SolidBrush(bgColor), 0, 0, width, height);
} }
for (int w = 0; w < bitmap.Width; w++) for (int w = 0; w < bitmap.Width; w++)
@ -616,25 +617,25 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
} }
} }
} }
else if (nextLine.StartsWith("PenColour")) else if (nextLine.StartsWith("PenColour") || nextLine.StartsWith("PenColor"))
{ {
nextLine = nextLine.Remove(0, 9); nextLine = nextLine.Remove(0, 9);
nextLine = nextLine.Trim(); nextLine = nextLine.Trim();
int hex = 0; int hex = 0;
Color newColour; Color newColor;
if (Int32.TryParse(nextLine, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out hex)) if (Int32.TryParse(nextLine, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out hex))
{ {
newColour = Color.FromArgb(hex); newColor = Color.FromArgb(hex);
} }
else else
{ {
// this doesn't fail, it just returns black if nothing is found // this doesn't fail, it just returns black if nothing is found
newColour = Color.FromName(nextLine); newColor = Color.FromName(nextLine);
} }
myBrush.Color = newColour; myBrush.Color = newColor;
drawPen.Color = newColour; drawPen.Color = newColor;
} }
} }
} }

View File

@ -336,6 +336,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
internal void OSSLDeprecated(string function, string replacement)
{
OSSLShoutError(string.Format("Use of function {0} is deprecated. Use {1} instead.", function, replacement));
}
protected void ScriptSleep(int delay) protected void ScriptSleep(int delay)
{ {
delay = (int)((float)delay * m_ScriptDelayFactor); delay = (int)((float)delay * m_ScriptDelayFactor);
@ -347,13 +352,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// //
// OpenSim functions // OpenSim functions
// //
public LSL_Integer osSetTerrainHeight(int x, int y, double val)
{
CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight");
return SetTerrainHeight(x, y, val);
}
public LSL_Integer osTerrainSetHeight(int x, int y, double val) public LSL_Integer osTerrainSetHeight(int x, int y, double val)
{ {
CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight"); CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight");
OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight");
return SetTerrainHeight(x, y, val);
}
private LSL_Integer SetTerrainHeight(int x, int y, double val)
{
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0) if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0)
OSSLError("osTerrainSetHeight: Coordinate out of bounds"); OSSLError("osSetTerrainHeight: Coordinate out of bounds");
if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0))) if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0)))
{ {
@ -366,13 +380,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
public LSL_Float osGetTerrainHeight(int x, int y)
{
CheckThreatLevel(ThreatLevel.None, "osGetTerrainHeight");
return GetTerrainHeight(x, y);
}
public LSL_Float osTerrainGetHeight(int x, int y) public LSL_Float osTerrainGetHeight(int x, int y)
{ {
CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight"); CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight");
OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight");
return GetTerrainHeight(x, y);
}
private LSL_Float GetTerrainHeight(int x, int y)
{
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0) if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0)
OSSLError("osTerrainGetHeight: Coordinate out of bounds"); OSSLError("osGetTerrainHeight: Coordinate out of bounds");
return World.Heightmap[x, y]; return World.Heightmap[x, y];
} }
@ -1001,9 +1024,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return drawList; return drawList;
} }
public string osSetPenColor(string drawList, string color)
{
CheckThreatLevel(ThreatLevel.None, "osSetPenColor");
m_host.AddScriptLPS(1);
drawList += "PenColor " + color + "; ";
return drawList;
}
// Deprecated
public string osSetPenColour(string drawList, string colour) public string osSetPenColour(string drawList, string colour)
{ {
CheckThreatLevel(ThreatLevel.None, "osSetPenColour"); CheckThreatLevel(ThreatLevel.None, "osSetPenColour");
OSSLDeprecated("osSetPenColour", "osSetPenColor");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
drawList += "PenColour " + colour + "; "; drawList += "PenColour " + colour + "; ";
@ -1012,7 +1045,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public string osSetPenCap(string drawList, string direction, string type) public string osSetPenCap(string drawList, string direction, string type)
{ {
CheckThreatLevel(ThreatLevel.None, "osSetPenColour"); CheckThreatLevel(ThreatLevel.None, "osSetPenCap");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
drawList += "PenCap " + direction + "," + type + "; "; drawList += "PenCap " + direction + "," + type + "; ";
@ -1157,6 +1190,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public double osSunGetParam(string param) public double osSunGetParam(string param)
{ {
CheckThreatLevel(ThreatLevel.None, "osSunGetParam"); CheckThreatLevel(ThreatLevel.None, "osSunGetParam");
OSSLDeprecated("osSunGetParam", "osGetSunParam");
return GetSunParam(param);
}
public double osGetSunParam(string param)
{
CheckThreatLevel(ThreatLevel.None, "osGetSunParam");
return GetSunParam(param);
}
private double GetSunParam(string param)
{
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
double value = 0.0; double value = 0.0;
@ -1173,6 +1216,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void osSunSetParam(string param, double value) public void osSunSetParam(string param, double value)
{ {
CheckThreatLevel(ThreatLevel.None, "osSunSetParam"); CheckThreatLevel(ThreatLevel.None, "osSunSetParam");
OSSLDeprecated("osSunSetParam", "osSetSunParam");
SetSunParam(param, value);
}
public void osSetSunParam(string param, double value)
{
CheckThreatLevel(ThreatLevel.None, "osSetSunParam");
SetSunParam(param, value);
}
private void SetSunParam(string param, double value)
{
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
ISunModule module = World.RequestModuleInterface<ISunModule>(); ISunModule module = World.RequestModuleInterface<ISunModule>();
@ -1198,9 +1251,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return String.Empty; return String.Empty;
} }
public void osWindParamSet(string plugin, string param, float value) public void osSetWindParam(string plugin, string param, float value)
{ {
CheckThreatLevel(ThreatLevel.VeryLow, "osWindParamSet"); CheckThreatLevel(ThreatLevel.VeryLow, "osSetWindParam");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
IWindModule module = World.RequestModuleInterface<IWindModule>(); IWindModule module = World.RequestModuleInterface<IWindModule>();
@ -1214,9 +1267,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
public float osWindParamGet(string plugin, string param) public float osGetWindParam(string plugin, string param)
{ {
CheckThreatLevel(ThreatLevel.VeryLow, "osWindParamGet"); CheckThreatLevel(ThreatLevel.VeryLow, "osGetWindParam");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
IWindModule module = World.RequestModuleInterface<IWindModule>(); IWindModule module = World.RequestModuleInterface<IWindModule>();

View File

@ -67,8 +67,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams, string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams,
bool blend, int disp, int timer, int alpha, int face); bool blend, int disp, int timer, int alpha, int face);
LSL_Float osTerrainGetHeight(int x, int y); LSL_Float osGetTerrainHeight(int x, int y);
LSL_Integer osTerrainSetHeight(int x, int y, double val); LSL_Float osTerrainGetHeight(int x, int y); // Deprecated
LSL_Integer osSetTerrainHeight(int x, int y, double val);
LSL_Integer osTerrainSetHeight(int x, int y, double val); //Deprecated
void osTerrainFlush(); void osTerrainFlush();
int osRegionRestart(double seconds); int osRegionRestart(double seconds);
@ -107,7 +109,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
string osSetFontName(string drawList, string fontName); string osSetFontName(string drawList, string fontName);
string osSetFontSize(string drawList, int fontSize); string osSetFontSize(string drawList, int fontSize);
string osSetPenSize(string drawList, int penSize); string osSetPenSize(string drawList, int penSize);
string osSetPenColour(string drawList, string colour); string osSetPenColor(string drawList, string color);
string osSetPenColour(string drawList, string colour); // Deprecated
string osSetPenCap(string drawList, string direction, string type); string osSetPenCap(string drawList, string direction, string type);
string osDrawImage(string drawList, int width, int height, string imageUrl); string osDrawImage(string drawList, int width, int height, string imageUrl);
vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize); vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize);
@ -119,13 +122,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour); void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour);
void osSetEstateSunSettings(bool sunFixed, double sunHour); void osSetEstateSunSettings(bool sunFixed, double sunHour);
double osGetCurrentSunHour(); double osGetCurrentSunHour();
double osSunGetParam(string param); double osGetSunParam(string param);
void osSunSetParam(string param, double value); double osSunGetParam(string param); // Deprecated
void osSetSunParam(string param, double value);
void osSunSetParam(string param, double value); // Deprecated
// Wind Module Functions // Wind Module Functions
string osWindActiveModelPluginName(); string osWindActiveModelPluginName();
void osWindParamSet(string plugin, string param, float value); void osSetWindParam(string plugin, string param, float value);
float osWindParamGet(string plugin, string param); float osGetWindParam(string plugin, string param);
// Parcel commands // Parcel commands
void osParcelJoin(vector pos1, vector pos2); void osParcelJoin(vector pos1, vector pos2);

View File

@ -81,11 +81,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_OSSL_Functions.osGetCurrentSunHour(); return m_OSSL_Functions.osGetCurrentSunHour();
} }
public double osGetSunParam(string param)
{
return m_OSSL_Functions.osGetSunParam(param);
}
// Deprecated
public double osSunGetParam(string param) public double osSunGetParam(string param)
{ {
return m_OSSL_Functions.osSunGetParam(param); return m_OSSL_Functions.osSunGetParam(param);
} }
public void osSetSunParam(string param, double value)
{
m_OSSL_Functions.osSetSunParam(param, value);
}
// Deprecated
public void osSunSetParam(string param, double value) public void osSunSetParam(string param, double value)
{ {
m_OSSL_Functions.osSunSetParam(param, value); m_OSSL_Functions.osSunSetParam(param, value);
@ -97,14 +107,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
} }
// Not yet plugged in as available OSSL functions, so commented out // Not yet plugged in as available OSSL functions, so commented out
// void osWindParamSet(string plugin, string param, float value) // void osSetWindParam(string plugin, string param, float value)
// { // {
// m_OSSL_Functions.osWindParamSet(plugin, param, value); // m_OSSL_Functions.osSetWindParam(plugin, param, value);
// } // }
// //
// float osWindParamGet(string plugin, string param) // float osGetWindParam(string plugin, string param)
// { // {
// return m_OSSL_Functions.osWindParamGet(plugin, param); // return m_OSSL_Functions.osGetWindParam(plugin, param);
// } // }
public void osParcelJoin(vector pos1, vector pos2) public void osParcelJoin(vector pos1, vector pos2)
@ -165,11 +175,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
blend, disp, timer, alpha, face); blend, disp, timer, alpha, face);
} }
public LSL_Float osGetTerrainHeight(int x, int y)
{
return m_OSSL_Functions.osGetTerrainHeight(x, y);
}
// Deprecated
public LSL_Float osTerrainGetHeight(int x, int y) public LSL_Float osTerrainGetHeight(int x, int y)
{ {
return m_OSSL_Functions.osTerrainGetHeight(x, y); return m_OSSL_Functions.osTerrainGetHeight(x, y);
} }
public LSL_Integer osSetTerrainHeight(int x, int y, double val)
{
return m_OSSL_Functions.osSetTerrainHeight(x, y, val);
}
// Deprecated
public LSL_Integer osTerrainSetHeight(int x, int y, double val) public LSL_Integer osTerrainSetHeight(int x, int y, double val)
{ {
return m_OSSL_Functions.osTerrainSetHeight(x, y, val); return m_OSSL_Functions.osTerrainSetHeight(x, y, val);
@ -333,6 +353,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_OSSL_Functions.osSetPenCap(drawList, direction, type); return m_OSSL_Functions.osSetPenCap(drawList, direction, type);
} }
public string osSetPenColor(string drawList, string color)
{
return m_OSSL_Functions.osSetPenColor(drawList, color);
}
// Deprecated
public string osSetPenColour(string drawList, string colour) public string osSetPenColour(string drawList, string colour)
{ {
return m_OSSL_Functions.osSetPenColour(drawList, colour); return m_OSSL_Functions.osSetPenColour(drawList, colour);