aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs48
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs19
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs43
5 files changed, 98 insertions, 18 deletions
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index 2640f08..d7f39b0 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -469,13 +469,19 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
469 startPoint.X += endPoint.X; 469 startPoint.X += endPoint.X;
470 startPoint.Y += endPoint.Y; 470 startPoint.Y += endPoint.Y;
471 } 471 }
472 else if (nextLine.StartsWith("FillPolygon"))
473 {
474 PointF[] points = null;
475 GetParams(partsDelimiter, ref nextLine, 11, ref points);
476 graph.FillPolygon(myBrush, points);
477 }
472 else if (nextLine.StartsWith("Ellipse")) 478 else if (nextLine.StartsWith("Ellipse"))
473 { 479 {
474 float x = 0; 480 float x = 0;
475 float y = 0; 481 float y = 0;
476 GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y); 482 GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y);
477 endPoint.X = (int) x; 483 endPoint.X = (int)x;
478 endPoint.Y = (int) y; 484 endPoint.Y = (int)y;
479 graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); 485 graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
480 startPoint.X += endPoint.X; 486 startPoint.X += endPoint.X;
481 startPoint.Y += endPoint.Y; 487 startPoint.Y += endPoint.Y;
@@ -492,30 +498,31 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
492 nextLine = nextLine.Remove(0, 8); 498 nextLine = nextLine.Remove(0, 8);
493 nextLine = nextLine.Trim(); 499 nextLine = nextLine.Trim();
494 500
495 string [] fprops = nextLine.Split(partsDelimiter); 501 string[] fprops = nextLine.Split(partsDelimiter);
496 foreach (string prop in fprops) { 502 foreach (string prop in fprops)
497 503 {
504
498 switch (prop) 505 switch (prop)
499 { 506 {
500 case "B": 507 case "B":
501 if (!(myFont.Bold)) 508 if (!(myFont.Bold))
502 myFont = new Font(myFont, myFont.Style | FontStyle.Bold); 509 myFont = new Font(myFont, myFont.Style | FontStyle.Bold);
503 break; 510 break;
504 case "I": 511 case "I":
505 if (!(myFont.Italic)) 512 if (!(myFont.Italic))
506 myFont = new Font(myFont, myFont.Style | FontStyle.Italic); 513 myFont = new Font(myFont, myFont.Style | FontStyle.Italic);
507 break; 514 break;
508 case "U": 515 case "U":
509 if (!(myFont.Underline)) 516 if (!(myFont.Underline))
510 myFont = new Font(myFont, myFont.Style | FontStyle.Underline); 517 myFont = new Font(myFont, myFont.Style | FontStyle.Underline);
511 break; 518 break;
512 case "S": 519 case "S":
513 if (!(myFont.Strikeout)) 520 if (!(myFont.Strikeout))
514 myFont = new Font(myFont, myFont.Style | FontStyle.Strikeout); 521 myFont = new Font(myFont, myFont.Style | FontStyle.Strikeout);
515 break; 522 break;
516 case "R": 523 case "R":
517 myFont = new Font(myFont, FontStyle.Regular); 524 myFont = new Font(myFont, FontStyle.Regular);
518 break; 525 break;
519 } 526 }
520 } 527 }
521 } 528 }
@@ -542,7 +549,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
542 if (Int32.TryParse(nextLine, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out hex)) 549 if (Int32.TryParse(nextLine, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out hex))
543 { 550 {
544 newColour = Color.FromArgb(hex); 551 newColour = Color.FromArgb(hex);
545 } 552 }
546 else 553 else
547 { 554 {
548 // this doesn't fail, it just returns black if nothing is found 555 // this doesn't fail, it just returns black if nothing is found
@@ -582,6 +589,25 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
582 } 589 }
583 } 590 }
584 591
592 private static void GetParams(char[] partsDelimiter, ref string line, int startLength, ref PointF[] points)
593 {
594 line = line.Remove(0, startLength);
595 string[] parts = line.Split(partsDelimiter);
596 if (parts.Length > 1 && parts.Length % 2 == 0)
597 {
598 points = new PointF[parts.Length / 2];
599 for (int i = 0; i < parts.Length; i = i + 2)
600 {
601 string xVal = parts[i].Trim();
602 string yVal = parts[i+1].Trim();
603 float x = Convert.ToSingle(xVal, CultureInfo.InvariantCulture);
604 float y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture);
605 PointF point = new PointF(x, y);
606 points[i / 2] = point;
607 }
608 }
609 }
610
585 private Bitmap ImageHttpRequest(string url) 611 private Bitmap ImageHttpRequest(string url)
586 { 612 {
587 WebRequest request = HttpWebRequest.Create(url); 613 WebRequest request = HttpWebRequest.Create(url);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 6190349..b40e441 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -833,6 +833,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
833 return drawList; 833 return drawList;
834 } 834 }
835 835
836 public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y)
837 {
838 CheckThreatLevel(ThreatLevel.None, "osDrawFilledPolygon");
839
840 m_host.AddScriptLPS(1);
841
842 if (x.Length != y.Length || x.Length < 3)
843 {
844 return "";
845 }
846 drawList += "FillPolygon " + x.GetLSLStringItem(0) + "," + y.GetLSLStringItem(0);
847 for (int i = 1; i < x.Length; i++)
848 {
849 drawList += "," + x.GetLSLStringItem(i) + "," + y.GetLSLStringItem(i);
850 }
851 drawList += "; ";
852 return drawList;
853 }
854
836 public string osSetFontSize(string drawList, int fontSize) 855 public string osSetFontSize(string drawList, int fontSize)
837 { 856 {
838 CheckThreatLevel(ThreatLevel.None, "osSetFontSize"); 857 CheckThreatLevel(ThreatLevel.None, "osSetFontSize");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index c24dae8..202bf41 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -97,6 +97,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
97 string osDrawEllipse(string drawList, int width, int height); 97 string osDrawEllipse(string drawList, int width, int height);
98 string osDrawRectangle(string drawList, int width, int height); 98 string osDrawRectangle(string drawList, int width, int height);
99 string osDrawFilledRectangle(string drawList, int width, int height); 99 string osDrawFilledRectangle(string drawList, int width, int height);
100 string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y);
100 string osSetFontSize(string drawList, int fontSize); 101 string osSetFontSize(string drawList, int fontSize);
101 string osSetPenSize(string drawList, int penSize); 102 string osSetPenSize(string drawList, int penSize);
102 string osSetPenColour(string drawList, string colour); 103 string osSetPenColour(string drawList, string colour);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 605f67b..b6bfb43 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -267,6 +267,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
267 return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height); 267 return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height);
268 } 268 }
269 269
270 public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y)
271 {
272 return m_OSSL_Functions.osDrawFilledPolygon(drawList, x, y);
273 }
274
270 public string osSetFontSize(string drawList, int fontSize) 275 public string osSetFontSize(string drawList, int fontSize)
271 { 276 {
272 return m_OSSL_Functions.osSetFontSize(drawList, fontSize); 277 return m_OSSL_Functions.osSetFontSize(drawList, fontSize);
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index bdacf8b..2842f6b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -439,6 +439,13 @@ namespace OpenSim.Region.ScriptEngine.Shared
439 439
440 set {m_data = value; } 440 set {m_data = value; }
441 } 441 }
442 // Function to obtain LSL type from an index. This is needed
443 // because LSL lists allow for multiple types, and safely
444 // iterating in them requires a type check.
445 public Type GetLSLListItemType(int itemIndex)
446 {
447 return m_data[itemIndex].GetType();
448 }
442 449
443 // Member functions to obtain item as specific types. 450 // Member functions to obtain item as specific types.
444 // For cases where implicit conversions would apply if items 451 // For cases where implicit conversions would apply if items
@@ -465,6 +472,10 @@ namespace OpenSim.Region.ScriptEngine.Shared
465 { 472 {
466 return new LSL_Types.LSLFloat((Double)m_data[itemIndex]); 473 return new LSL_Types.LSLFloat((Double)m_data[itemIndex]);
467 } 474 }
475 else if (m_data[itemIndex] is LSL_Types.LSLString)
476 {
477 return new LSL_Types.LSLFloat(m_data[itemIndex].ToString());
478 }
468 else 479 else
469 { 480 {
470 return (LSL_Types.LSLFloat)m_data[itemIndex]; 481 return (LSL_Types.LSLFloat)m_data[itemIndex];
@@ -481,20 +492,32 @@ namespace OpenSim.Region.ScriptEngine.Shared
481 { 492 {
482 return new LSL_Types.LSLString((string)m_data[itemIndex]); 493 return new LSL_Types.LSLString((string)m_data[itemIndex]);
483 } 494 }
495 else if (m_data[itemIndex] is LSL_Types.LSLFloat)
496 {
497 return new LSL_Types.LSLString((LSLFloat)m_data[itemIndex]);
498 }
499 else if (m_data[itemIndex] is LSL_Types.LSLInteger)
500 {
501 return new LSL_Types.LSLString((LSLInteger)m_data[itemIndex]);
502 }
484 else 503 else
485 { 504 {
486 return (LSL_Types.LSLString)m_data[itemIndex]; 505 return (LSL_Types.LSLString)m_data[itemIndex];
487 } 506 }
488 } 507 }
489 508
490 public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex) 509 public LSL_Types.LSLInteger GetLSLIntegerItem(int itemIndex)
491 { 510 {
492 if (m_data[itemIndex] is LSL_Types.LSLInteger) 511 if (m_data[itemIndex] is LSL_Types.LSLInteger)
493 return (LSL_Types.LSLInteger)m_data[itemIndex]; 512 return (LSL_Types.LSLInteger)m_data[itemIndex];
494 else if (m_data[itemIndex] is Int32) 513 if (m_data[itemIndex] is LSL_Types.LSLFloat)
495 return new LSLInteger((int)m_data[itemIndex]); 514 return new LSLInteger((int)m_data[itemIndex]);
496 else 515 else if (m_data[itemIndex] is Int32)
497 throw new InvalidCastException(); 516 return new LSLInteger((int)m_data[itemIndex]);
517 else if (m_data[itemIndex] is LSL_Types.LSLString)
518 return new LSLInteger((string)m_data[itemIndex]);
519 else
520 throw new InvalidCastException();
498 } 521 }
499 522
500 public LSL_Types.Vector3 GetVector3Item(int itemIndex) 523 public LSL_Types.Vector3 GetVector3Item(int itemIndex)
@@ -1331,6 +1354,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
1331 m_string=s; 1354 m_string=s;
1332 } 1355 }
1333 1356
1357 public LSLString(LSLInteger i)
1358 {
1359 string s = String.Format("{0}", i);
1360 m_string = s;
1361 }
1362
1334 #endregion 1363 #endregion
1335 1364
1336 #region Operators 1365 #region Operators