proper import

git-svn-id: https://lsleditor.svn.sourceforge.net/svnroot/lsleditor@9 3f4676ac-adda-40fd-8265-58d1435b1672
This commit is contained in:
dimentox 2010-04-29 07:47:27 +00:00
parent 66730fd649
commit 3151e1e342
454 changed files with 57577 additions and 0 deletions

272
trunk/SecondLife/Float.cs Normal file
View file

@ -0,0 +1,272 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
using System.Text.RegularExpressions;
namespace LSLEditor
{
public partial class SecondLife
{
public struct Float
{
private object m_value;
private Double value
{
get
{
if (m_value == null)
m_value = (Double)0;
return (Double)m_value;
}
set
{
m_value = value;
}
}
public Float(Double a)
{
this.m_value = a;
}
#region public Float(string s)
public Float(string s)
{
Regex r = new Regex(@"\A[ ]*(?<sign>[+-]?)
(?:
(?:
0x
(?:
(?:
(?<int>[0-9a-f]*)
(?:
(?:\.
(?<frac>[0-9a-f]*)
)
|
)
)
(?:
(?:p
(?<exp>[-+]?[\d]*)
)
|
)
)
)
|
(?<dec>
[\d]*[.]?[\d]*
(?:
(?:
e[+-]?[\d]*
)
|
)
)
)", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
Match m = r.Match(s);
Double mantissa = 0.0;
if (r.Match(s).Groups["dec"].Value.Length > 0)
mantissa = Convert.ToDouble(r.Match(s).Groups["dec"].Value);
if (m.Groups["int"].Success)
{
if (m.Groups["int"].Value.Length > 0)
{
// System.Console.WriteLine("i:\t" + m.Groups["int"].Value);
mantissa = Convert.ToInt64(m.Groups["int"].Value, 16);
}
if (m.Groups["frac"].Value.Length > 0)
{
// System.Console.WriteLine("f:\t"+m.Groups["frac"].Value);
mantissa += Convert.ToInt64(m.Groups["frac"].Value, 16) / Math.Pow(16.0, m.Groups["frac"].Value.Length);
}
if (m.Groups["exp"].Value.Length > 0)
{
// System.Console.WriteLine("e:\t" + m.Groups["exp"].Value);
mantissa *= Math.Pow(2.0, Convert.ToInt64(m.Groups["exp"].Value, 10));
}
}
if (m.Groups["sign"].Value == "-")
this.m_value = -mantissa;
else
this.m_value = mantissa;
}
#endregion
public override int GetHashCode()
{
return (int)this.value % System.Int32.MaxValue;
}
public override string ToString()
{
return string.Format("{0:0.000000}",this.value);
}
public static explicit operator String(Float x)
{
return x.ToString();
}
public static implicit operator Double(Float x)
{
return x.value;
}
//public static implicit operator integer(Float x)
//{
// return (int)x.value;
//}
public static explicit operator Float(string s)
{
return new Float(s);
}
public static explicit operator Float(String s)
{
return new Float(s.ToString());
}
public static implicit operator Float(Int32 x)
{
return new Float((Double)x);
}
// 6 jan 2008 , does this work????
public static implicit operator Float(long x)
{
return new Float((int)(uint)x);
}
public static implicit operator Float(Double x)
{
return new Float(x);
}
public static implicit operator Float(integer x)
{
return new Float((Double)x);
}
public static Float operator *(Float a, Float b)
{
return new Float(a.value * b.value);
}
public static Float operator /(Float a, Float b)
{
return new Float(a.value / b.value);
}
public static Float operator ++(Float a)
{
return new Float(a.value + 1.0);
}
public static Float operator --(Float a)
{
return new Float(a.value - 1.0);
}
public static Float operator +(Float a, Float b)
{
return new Float(a.value + b.value);
}
public static Float operator -(Float a, Float b)
{
return new Float(a.value - b.value);
}
public static explicit operator bool(Float a)
{
return (Math.Abs(a.value) >= Double.Epsilon);
}
public static bool operator true(Float a)
{
return (Math.Abs(a.value) >= Double.Epsilon);
}
public static bool operator false(Float a)
{
return (Math.Abs(a.value) < Double.Epsilon);
}
public static bool operator ==(Float x, Float y)
{
return (Math.Abs(x.value - y.value) < Double.Epsilon);
}
public static bool operator !=(Float x, Float y)
{
return !(x == y);
}
public static int Compare(Float a, Float b)
{
if (a.value < b.value)
return -1;
if (a.value > b.value)
return 1;
return 0;
}
public override bool Equals(object o)
{
try
{
return (bool)(this == (Float)o);
}
catch
{
return false;
}
}
}
}
}

View file

@ -0,0 +1,948 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
using System.IO;
using System.Text;
using System.Threading;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms;
using LSLEditor.Helpers;
namespace LSLEditor
{
public class SecondLifeHostEventArgs : EventArgs
{
public string Message;
public SecondLifeHostEventArgs(string Message)
{
this.Message = Message;
}
}
public class SecondLifeHostMessageLinkedEventArgs : EventArgs
{
public SecondLife.integer linknum;
public SecondLife.integer num;
public SecondLife.String str;
public SecondLife.key id;
public SecondLifeHostMessageLinkedEventArgs(SecondLife.integer linknum, SecondLife.integer num, SecondLife.String str, SecondLife.key id)
{
this.linknum = linknum;
this.num = num;
this.str = str;
this.id = id;
}
}
public class SecondLifeHostChatEventArgs : EventArgs
{
public SecondLife.integer channel;
public SecondLife.String name;
public SecondLife.key id;
public SecondLife.String message;
public CommunicationType how;
public SecondLifeHostChatEventArgs(SecondLife.integer channel, SecondLife.String name, SecondLife.key id, SecondLife.String message, CommunicationType how)
{
this.channel = channel;
this.name = name;
this.id = id;
this.message = message;
this.how = how;
}
}
public class SecondLifeHost : IDisposable
{
private List<ListenFilter> ListenFilterList;
private List<Link> LinkList;
private SecondLife secondLife;
private TaskQueue taskQueue;
private AutoResetEvent StateChanged;
private Thread StateWatcher;
private LSLEditorForm mainForm;
private Assembly CompiledAssembly;
public string FullPath;
public Guid guid;
public delegate void SecondLifeHostMessageHandler(object sender, SecondLifeHostEventArgs e);
public event SecondLifeHostMessageHandler OnVerboseMessage;
public event SecondLifeHostMessageHandler OnStateChange;
public delegate void SecondLifeHostChatHandler(object sender, SecondLifeHostChatEventArgs e);
public event SecondLifeHostChatHandler OnChat;
public delegate void SecondLifeHostMessageLinkedHandler(object sender, SecondLifeHostMessageLinkedEventArgs e);
public event SecondLifeHostMessageLinkedHandler OnMessageLinked;
public event EventHandler OnDie;
public event EventHandler OnReset;
public event EventHandler OnListenChannelsChanged;
public System.Timers.Timer timer;
public System.Timers.Timer sensor_timer;
public string CurrentStateName;
private string NewStateName;
private string ObjectName;
private string ObjectDescription;
public SecondLifeHost(LSLEditorForm mainForm, Assembly CompiledAssembly, string FullPath, Guid guid)
{
this.ListenFilterList = null;
this.LinkList = null;
this.secondLife = null;
this.taskQueue = new TaskQueue();
this.StateChanged = new AutoResetEvent(false);
this.StateWatcher = new Thread(new ThreadStart(StateWatch));
this.StateWatcher.Name = "StateWatch";
this.StateWatcher.IsBackground = true;
this.StateWatcher.Start();
this.mainForm = mainForm;
this.CompiledAssembly = CompiledAssembly;
this.FullPath = FullPath;
this.guid = guid;
this.ObjectName = Path.GetFileNameWithoutExtension(this.FullPath);
this.ObjectDescription = "";
this.timer = new System.Timers.Timer();
this.timer.AutoReset = true;
this.timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
this.sensor_timer = new System.Timers.Timer();
this.sensor_timer.AutoReset = true;
this.sensor_timer.Elapsed += new System.Timers.ElapsedEventHandler(sensor_timer_Elapsed);
this.NewStateName = "default";
this.CurrentStateName = "";
}
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
ExecuteSecondLife("timer");
}
private void StateWatch()
{
while (true)
{
this.StateChanged.WaitOne();
this.taskQueue.Start(); // is implicit Stop() old Queue
if (this.CurrentStateName != this.NewStateName)
{
this.CurrentStateName = this.NewStateName;
ExecuteSecondLife("state_exit");
// Changing to CurrentStateName on this thread! (not ExecuteSecondLife)
this.taskQueue.Invoke(this, "SetState");
}
}
}
public void State(string strStateName, bool blnForce)
{
if (this.CompiledAssembly == null)
return;
if (blnForce)
this.CurrentStateName = "";
this.NewStateName = strStateName;
this.StateChanged.Set();
}
private void SetState()
{
if (CompiledAssembly == null)
return;
secondLife = CompiledAssembly.CreateInstance("LSLEditor.State_" + CurrentStateName) as SecondLife;
if (secondLife == null)
{
MessageBox.Show("State " + CurrentStateName+" does not exist!");
return;
}
ListenFilterList = new List<ListenFilter>();
LinkList = new List<Link>();
// Make friends
secondLife.host = this;
// Update runtime userinterface by calling event handler
if (OnStateChange != null)
OnStateChange(this, new SecondLifeHostEventArgs(CurrentStateName));
ExecuteSecondLife("state_entry");
}
public string GetArgumentsFromMethod(string strName)
{
if (this.secondLife == null)
return "";
MethodInfo mi = secondLife.GetType().GetMethod(strName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
if (mi == null)
return "";
int intI = 0;
string strArgs = "";
foreach (ParameterInfo pi in mi.GetParameters())
{
if (intI > 0)
strArgs += ",";
strArgs += pi.ParameterType.ToString() + " " + pi.Name;
intI++;
}
return strArgs;
}
public void VerboseEvent(string strEventName, object[] args)
{
StringBuilder sb = new StringBuilder();
sb.Append("*** ");
sb.Append(strEventName);
sb.Append('(');
for (int intI = 0; intI < args.Length; intI++)
{
if (intI > 0)
sb.Append(',');
sb.Append(args[intI].ToString());
}
sb.Append(")");
VerboseMessage(sb.ToString());
}
public void ExecuteSecondLife(string strName, params object[] args)
{
if (secondLife == null)
return;
VerboseEvent(strName, args);
this.taskQueue.Invoke(secondLife, strName, args);
}
public ArrayList GetEvents()
{
ArrayList ar = new ArrayList();
if (secondLife != null)
{
foreach (MethodInfo mi in secondLife.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
{
ar.Add(mi.Name);
}
}
ar.Sort();
return ar;
}
public void Reset()
{
if (OnReset != null)
OnReset(this, new EventArgs());
}
public void Die()
{
if (OnDie != null)
OnDie(this, new EventArgs());
if (secondLife != null)
{
// stop all timers
this.timer.Stop();
this.sensor_timer.Stop();
this.taskQueue.Stop();
this.taskQueue.Dispose();
this.taskQueue = null;
this.secondLife = null;
}
}
public void Dispose()
{
if (taskQueue != null)
{
this.taskQueue.Stop();
this.taskQueue.Dispose();
this.taskQueue = null;
}
if (listXmlRpc != null)
{
foreach (XMLRPC xmlRpc in listXmlRpc)
{
xmlRpc.CloseChannel();
}
}
if (secondLife != null)
{
this.timer.Stop();
this.sensor_timer.Stop();
this.mainForm = null;
this.secondLife = null;
}
}
#region Link functions
private struct Link
{
public int number;
public string name;
public SecondLife.key id;
public SecondLife.key target;
public Link(int number, string name, SecondLife.key id, SecondLife.key target)
{
this.number = number;
this.name = name;
this.id = id;
this.target = target;
}
}
public void llBreakAllLinks()
{
LinkList = new List<Link>();
}
public void llBreakLink(int linknum)
{
foreach (Link link in this.LinkList)
{
if (link.number == linknum)
{
this.LinkList.Remove(link);
break;
}
}
}
#endregion
#region Listen functions
public string[] GetListenChannels() // for GroupboxEvent
{
List<string> list = new List<string>();
foreach (ListenFilter lf in ListenFilterList)
{
list.Add(lf.channel.ToString());
}
return list.ToArray();
}
private struct ListenFilter
{
public int channel;
public string name;
public SecondLife.key id;
public string message;
public bool active;
public ListenFilter(int channel, string name, SecondLife.key id, string message)
{
this.channel = channel;
this.name = name;
this.id = id;
this.message = message;
this.active = true;
}
}
public void llListenControl(int number, int active)
{
for (int intI = 0; intI < ListenFilterList.Count; intI++)
{
ListenFilter lf = ListenFilterList[intI];
if (lf.GetHashCode() == number)
{
lf.active = (active == 1);
ListenFilterList[intI] = lf;
break;
}
}
}
public void llListenRemove(int intHandle)
{
for (int intI = 0; intI < ListenFilterList.Count; intI++)
{
ListenFilter lf = ListenFilterList[intI];
if (lf.GetHashCode() == intHandle)
{
ListenFilterList.RemoveAt(intI);
break;
}
}
}
public int llListen(int channel, string name, SecondLife.key id, string message)
{
if (ListenFilterList.Count >= 64)
{
Chat(this, 0, "LSLEditor", SecondLife.NULL_KEY, "Maximum of 64 listens!!!", CommunicationType.Shout);
return 0;
}
ListenFilter lf = new ListenFilter(channel, name, id, message);
ListenFilterList.Add(lf);
if (OnListenChannelsChanged != null)
OnListenChannelsChanged(this, null);
return lf.GetHashCode();
}
private bool CheckListenFilter(int channel, string name, SecondLife.key id, string message)
{
ListenFilter lfToCheck = new ListenFilter(channel, name, id, message);
foreach (ListenFilter lf in ListenFilterList)
{
if (!lf.active)
continue;
if (lf.channel != lfToCheck.channel)
continue;
if (lf.name != "" && lf.name != lfToCheck.name)
continue;
if (lf.id != Guid.Empty.ToString() && lf.id!="" && lf.id != lfToCheck.id)
continue;
if (lf.message != "" && lf.message != lfToCheck.message)
continue;
return true;
}
return false;
}
// sink listen
public void Listen(SecondLifeHostChatEventArgs e)
{
if (secondLife == null)
return;
if (CheckListenFilter(e.channel, e.name, e.id, e.message))
ExecuteSecondLife("listen", e.channel, e.name, e.id, e.message);
}
#endregion
// raise
public void Chat(object sender, int channel, string name, SecondLife.key id, string message, CommunicationType how)
{
if (OnChat != null)
OnChat(sender, new SecondLifeHostChatEventArgs(channel, name, id, message, how));
}
// raise
public void MessageLinked(SecondLife.integer linknum, SecondLife.integer num, SecondLife.String str, SecondLife.key id)
{
if (OnMessageLinked != null)
OnMessageLinked(this, new SecondLifeHostMessageLinkedEventArgs(linknum, num, str, id));
}
// sink
public void LinkMessage(SecondLifeHostMessageLinkedEventArgs e)
{
ExecuteSecondLife("link_message", e.linknum, e.num, e.str, e.id);
}
public SecondLife.key Http(string Url, SecondLife.list Parameters, string Body)
{
if (secondLife == null)
return SecondLife.NULL_KEY;
System.Net.WebProxy proxy = null;
if (Properties.Settings.Default.ProxyServer != "")
proxy = new System.Net.WebProxy(Properties.Settings.Default.ProxyServer.Replace("http://", ""));
if (Properties.Settings.Default.ProxyUserid != "" && proxy != null)
proxy.Credentials = new System.Net.NetworkCredential(Properties.Settings.Default.ProxyUserid, Properties.Settings.Default.ProxyPassword);
SecondLife.key Key = new SecondLife.key(Guid.NewGuid());
//WebRequestClass a = new WebRequestClass(proxy, secondLife, Url, Parameters, Body, Key);
try
{
HTTPRequest.Request(proxy, secondLife, Url, Parameters, Body, Key);
}
catch(Exception exception)
{
VerboseMessage(exception.Message);
}
return Key;
}
public void Email(string To, string Subject, string Body)
{
if (secondLife == null)
return;
SmtpClient client = new SmtpClient();
client.SmtpServer = Properties.Settings.Default.EmailServer;
string strName = GetObjectName();
string strObjectName = string.Format("Object-Name: {0}", strName);
SecondLife.vector RegionCorner = secondLife.llGetRegionCorner();
string strRegionName = secondLife.llGetRegionName();
string strRegion = string.Format("Region: {0} ({1},{2})", strRegionName, RegionCorner.x, RegionCorner.y);
SecondLife.vector pos = secondLife.llGetPos();
string strPosition = string.Format("Local-Position: ({0},{1},{2})", (int)pos.x, (int)pos.y, (int)pos.z);
string strPrefix = strObjectName + "\r\n";
strPrefix += strRegion + "\r\n";
strPrefix += strPosition + "\r\n\r\n";
MailMessage msg = new MailMessage();
msg.To = To;
msg.Subject = Subject;
msg.Body = strPrefix + Body;
msg.From = Properties.Settings.Default.EmailAddress;
msg.Headers.Add("Reply-to", msg.From);
//MailAttachment myAttachment = new MailAttachment(strAttachmentFile);
//msg.Attachments.Add(myAttachment);
VerboseMessage(client.Send(msg));
}
public void VerboseMessage(string Message)
{
if (OnVerboseMessage != null)
OnVerboseMessage(this, new SecondLifeHostEventArgs(Message));
}
delegate void ShowDialogDelegate(SecondLifeHost host,
SecondLife.String objectName,
SecondLife.key k,
SecondLife.String name,
SecondLife.String message,
SecondLife.list buttons,
SecondLife.integer channel);
private void Dialog(SecondLifeHost host,
SecondLife.String objectName,
SecondLife.key k,
SecondLife.String name,
SecondLife.String message,
SecondLife.list buttons,
SecondLife.integer channel)
{
llDialogForm DialogForm = new llDialogForm(host, objectName, k, name, message, buttons, channel);
DialogForm.Left = this.mainForm.Right - DialogForm.Width - 5;
DialogForm.Top = this.mainForm.Top + 30;
DialogForm.Show(this.mainForm);
this.mainForm.llDialogForms.Add(DialogForm);
}
public void llDialog(SecondLife.key avatar, SecondLife.String message, SecondLife.list buttons, SecondLife.integer channel)
{
if (message.ToString().Length >= 512)
{
VerboseMessage("llDialog: message too long, must be less than 512 characters");
return;
}
if (message.ToString().Length == 0)
{
VerboseMessage("llDialog: must supply a message");
return;
}
for (int intI = 0; intI < buttons.Count; intI++)
{
if (buttons[intI].ToString() == "")
{
VerboseMessage("llDialog: all buttons must have label strings");
return;
}
if (buttons[intI].ToString().Length > 24)
{
VerboseMessage("llDialog:Button Labels can not have more than 24 characters");
return;
}
}
if (buttons.Count == 0)
buttons = new SecondLife.list(new string[] { "OK" });
this.mainForm.Invoke(new ShowDialogDelegate(Dialog), this, (SecondLife.String)GetObjectName(), secondLife.llGetOwner(), (SecondLife.String)Properties.Settings.Default.AvatarName, message, buttons, channel);
}
public void SetPermissions(SecondLife.integer intPermissions)
{
ExecuteSecondLife("run_time_permissions", intPermissions);
}
delegate void RequestPermissionsDelegate(
SecondLifeHost host,
SecondLife.String objectName,
SecondLife.key k,
SecondLife.String name,
SecondLife.key agent,
SecondLife.integer intPermissions);
private void RequestPermissions(
SecondLifeHost host,
SecondLife.String objectName,
SecondLife.key k,
SecondLife.String name,
SecondLife.key agent,
SecondLife.integer intPermissions)
{
PermissionsForm PermissionForm = new PermissionsForm(this, GetObjectName(), secondLife.llGetOwner(), Properties.Settings.Default.AvatarName, agent, intPermissions);
PermissionForm.Left = this.mainForm.Right - PermissionForm.Width - 5;
PermissionForm.Top = this.mainForm.Top + 30;
PermissionForm.Show(this.mainForm);
this.mainForm.PermissionForms.Add(PermissionForm);
}
public void llRequestPermissions(SecondLife.key agent, SecondLife.integer intPermissions)
{
this.mainForm.Invoke(new RequestPermissionsDelegate(RequestPermissions),
this,
(SecondLife.String)GetObjectName(),
secondLife.llGetOwner(),
(SecondLife.String)Properties.Settings.Default.AvatarName,
agent,
intPermissions);
}
private int m_intControls = -1;
public void SendControl(Keys keys)
{
if (m_intControls < 0)
return;
if (this.secondLife == null)
return;
// check againt m_intControls TODO!!!!!
int held = 0;
int change = 0;
if ((keys & Keys.Up) == Keys.Up)
held |= SecondLife.CONTROL_UP;
if ((keys & Keys.Down) == Keys.Down)
held |= SecondLife.CONTROL_DOWN;
if ((keys & Keys.Left) == Keys.Left)
held |= SecondLife.CONTROL_LEFT;
if ((keys & Keys.Right) == Keys.Right)
held |= SecondLife.CONTROL_RIGHT;
ExecuteSecondLife("control", (SecondLife.key)Properties.Settings.Default.AvatarKey, (SecondLife.integer)held, (SecondLife.integer)change);
}
public void TakeControls(int intControls, int accept, int pass_on)
{
this.m_intControls = intControls;
}
public void ReleaseControls()
{
this.m_intControls = -1;
}
#region Notecards
private void GetNotecardLineWorker(SecondLife.key k, string strPath, int line)
{
StreamReader sr = new StreamReader(strPath);
int intI = 0;
string strData = SecondLife.EOF;
while (!sr.EndOfStream)
{
string strLine = sr.ReadLine();
if (intI == line)
{
strData = strLine;
break;
}
intI++;
}
sr.Close();
ExecuteSecondLife("dataserver", k, (SecondLife.String)strData);
}
public SecondLife.key GetNotecardLine(string name, int line)
{
string strPath = mainForm.SolutionExplorer.GetPath(this.guid, name);
if(strPath == string.Empty)
strPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name);
if (!File.Exists(strPath))
{
VerboseMessage("Notecard: " + strPath + " not found");
taskQueue.Invoke(secondLife, "llSay", (SecondLife.integer)0, (SecondLife.String)("Couldn't find notecard " + name));
return SecondLife.NULL_KEY;
}
SecondLife.key k = new SecondLife.key(Guid.NewGuid());
taskQueue.Invoke(this, "GetNotecardLineWorker", k, strPath, line);
return k;
}
private void GetNumberOfNotecardLinesWorker(SecondLife.key k, string strPath)
{
StreamReader sr = new StreamReader(strPath);
int intI = 0;
while (!sr.EndOfStream)
{
string strLine = sr.ReadLine();
intI++;
}
sr.Close();
ExecuteSecondLife("dataserver", k, (SecondLife.String)intI.ToString());
}
public SecondLife.key GetNumberOfNotecardLines(string name)
{
string strPath = mainForm.SolutionExplorer.GetPath(this.guid, name);
if (strPath == string.Empty)
strPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name);
if (!File.Exists(strPath))
{
VerboseMessage("Notecard: " + strPath + " not found");
taskQueue.Invoke(secondLife, "llSay", (SecondLife.integer)0, (SecondLife.String)("Couldn't find notecard " + name));
return SecondLife.NULL_KEY;
}
SecondLife.key k = new SecondLife.key(Guid.NewGuid());
taskQueue.Invoke(this, "GetNumberOfNotecardLinesWorker", k, strPath);
return k;
}
#endregion
#region XML-RPC
private List<XMLRPC> listXmlRpc;
public void llOpenRemoteDataChannel()
{
if (listXmlRpc == null)
listXmlRpc = new List<XMLRPC>();
XMLRPC xmlRpc = new XMLRPC();
xmlRpc.OnRequest += new XMLRPC.RequestEventHandler(xmlRpc_OnRequest);
xmlRpc.OpenChannel(listXmlRpc.Count);
listXmlRpc.Add(xmlRpc);
ExecuteSecondLife("remote_data",
SecondLife.REMOTE_DATA_CHANNEL,
xmlRpc.guid,
new SecondLife.key(Guid.NewGuid()),
(SecondLife.String)("LSLEditor"),
(SecondLife.integer)(0),
(SecondLife.String)("Listening on " + xmlRpc.Prefix));
}
void xmlRpc_OnRequest(object sender, XmlRpcRequestEventArgs e)
{
XMLRPC xmlRpc = sender as XMLRPC;
ExecuteSecondLife("remote_data",
SecondLife.REMOTE_DATA_REQUEST,
e.channel,
e.message_id,
e.sender,
e.iData,
e.sData);
}
public void llCloseRemoteDataChannel(SecondLife.key channel)
{
if (listXmlRpc == null)
return;
foreach (XMLRPC xmlRpc in listXmlRpc)
{
if (xmlRpc.guid == channel.guid)
{
xmlRpc.CloseChannel();
break;
}
}
}
public void llRemoteDataReply(SecondLife.key channel, SecondLife.key message_id, string sdata, int idata)
{
if (listXmlRpc == null)
return;
foreach (XMLRPC xmlRpc in listXmlRpc)
{
if (xmlRpc.guid == channel.guid)
{
xmlRpc.RemoteDataReply(channel.guid, message_id.guid, sdata, idata);
break;
}
}
}
// Wiki sais this is not working in InWorld
public SecondLife.key llSendRemoteData(SecondLife.key channel, string dest, int idata, string sdata)
{
XMLRPC xmlRpc = new XMLRPC();
xmlRpc.OnReply += new XMLRPC.RequestEventHandler(xmlRpc_OnReply);
SecondLife.key message_id = xmlRpc.SendRemoteData(channel, dest, idata, sdata);
return message_id;
}
// Wiki sais currently disabled
void xmlRpc_OnReply(object sender, XmlRpcRequestEventArgs e)
{
ExecuteSecondLife("remote_data",
SecondLife.REMOTE_DATA_REPLY,
e.channel,
e.message_id,
(SecondLife.String)"", // Wiki
e.iData,
e.sData);
}
#endregion
public string GetObjectName(Guid guid)
{
string strObjectName = mainForm.SolutionExplorer.GetObjectName(guid);
if (strObjectName != string.Empty)
return strObjectName;
else
return this.ObjectName;
}
public string GetObjectName()
{
return GetObjectName(this.guid);
}
public void SetObjectName(string name)
{
if (!mainForm.SolutionExplorer.SetObjectName(this.guid, name))
ObjectName = name;
}
public string GetObjectDescription(Guid guid)
{
string strObjectDescription = mainForm.SolutionExplorer.GetObjectDescription(guid);
if (strObjectDescription != string.Empty)
return strObjectDescription;
else
return this.ObjectDescription;
}
public string GetObjectDescription()
{
return GetObjectDescription(this.guid);
}
public void SetObjectDescription(string description)
{
if (!mainForm.SolutionExplorer.SetObjectDescription(this.guid, description))
this.ObjectDescription = description;
}
public string GetScriptName()
{
string strScriptName = mainForm.SolutionExplorer.GetScriptName(this.guid);
if (strScriptName == string.Empty)
strScriptName = this.FullPath;
if (Properties.Settings.Default.llGetScriptName)
strScriptName = Path.GetFileNameWithoutExtension(strScriptName);
else
strScriptName = Path.GetFileName(strScriptName);
return strScriptName;
}
public SecondLife.key GetKey()
{
string strGuid = mainForm.SolutionExplorer.GetKey(this.guid);
if (strGuid == string.Empty)
return new SecondLife.key(this.guid);
return new SecondLife.key(strGuid);
}
public SecondLife.String GetInventoryName(SecondLife.integer type, SecondLife.integer number)
{
string strInventoryName = mainForm.SolutionExplorer.GetInventoryName(this.guid, type, number);
if (strInventoryName == string.Empty)
return "**GetInventoryName only works in SolutionExplorer**";
return strInventoryName;
}
public SecondLife.key GetInventoryKey(SecondLife.String name)
{
string strInventoryKey = mainForm.SolutionExplorer.GetInventoryKey(this.guid, name);
if (strInventoryKey == string.Empty)
return new SecondLife.key(Guid.Empty);
return new SecondLife.key(strInventoryKey);
}
public SecondLife.integer GetInventoryNumber(SecondLife.integer type)
{
return mainForm.SolutionExplorer.GetInventoryNumber(this.guid, type);
}
public SecondLife.integer GetInventoryType(SecondLife.String name)
{
return mainForm.SolutionExplorer.GetInventoryType(this.guid, name);
}
public System.Media.SoundPlayer GetSoundPlayer(string sound)
{
string strPath = mainForm.SolutionExplorer.GetPath(this.guid, sound);
if (strPath == string.Empty)
strPath = sound;
return new System.Media.SoundPlayer(strPath);
}
private void sensor_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
SecondLife.integer total_number = 1;
ExecuteSecondLife("sensor", total_number);
}
}
}

File diff suppressed because it is too large Load diff

140
trunk/SecondLife/String.cs Normal file
View file

@ -0,0 +1,140 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
namespace LSLEditor
{
public partial class SecondLife
{
public struct String
{
private string value;
public String(string s)
{
this.value = s;
}
public static implicit operator String(string s)
{
return new String(s);
}
// 3 oct 2007
public static explicit operator String(bool a)
{
if (a)
return "1";
else
return "0";
}
// 24 augustus 2007
public static explicit operator String(int i)
{
return new String(i.ToString());
}
public static explicit operator String(long i)
{
return new String(((int)(uint)i).ToString());
}
public static explicit operator String(float i)
{
return new String(string.Format("{0:0.000000}",i));
}
public static implicit operator string(String s)
{
return s.ToString();
}
public static implicit operator bool(String s)
{
if (s.value == null)
return false;
else
return (s.value.Length != 0);
}
public static bool operator ==(String x, String y)
{
return (x.ToString() == y.ToString());
}
public static bool operator !=(String x, String y)
{
return !(x==y);
}
// Public overrides
public override bool Equals(object o)
{
try
{
return (bool)(this.value == o.ToString());
}
catch
{
return false;
}
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override string ToString()
{
if (this.value == null)
this.value = "";
return this.value;
}
}
}
}

294
trunk/SecondLife/integer.cs Normal file
View file

@ -0,0 +1,294 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
namespace LSLEditor
{
public partial class SecondLife
{
public struct integer
{
public static readonly integer FALSE = new integer(0);
public static readonly integer TRUE = new integer(1);
private object m_value;
private Int32 value
{
get
{
if (m_value == null)
m_value = (Int32)0;
return (Int32)m_value;
}
set
{
m_value = value;
}
}
// Constructor.
public integer(Int32 value)
{
this.m_value = value;
}
public integer(string s)
{
Float f = new Float(s);
this.m_value = (Int32)f;
}
// Implicit conversion from bool to integer. Maps true to
// integer.TRUE and false to integer.FALSE:
public static implicit operator integer(Boolean x)
{
return x ? TRUE : FALSE;
}
public static implicit operator integer(int x)
{
return new integer(x);
}
public static implicit operator integer(uint x)
{
return new integer((int)x);
}
// 3 oct 2007
public static implicit operator integer(long x)
{
return new integer((int)(uint)x);
}
// 15 aug 2007 made explicit
public static explicit operator integer(Double x)
{
return new integer((int)x);
}
// 15 aug 2007 made explicit
public static explicit operator integer(Float x)
{
return new integer((int)x);
}
public static explicit operator integer(String x)
{
return new integer(x.ToString());
}
// 6 jan 2008, BlandWanderer thingy
public static explicit operator integer(string x)
{
Float f = new Float(x);
return new integer((int)(uint)f);
}
// Explicit conversion from integer to bool.
// returns true when non zero else false
public static explicit operator bool(integer x)
{
return (x.value != 0);
}
// Logical negation (NOT) operator
public static integer operator !(integer x)
{
if (x.value == 0)
return TRUE;
else
return FALSE;
}
// Bitwise AND operator
public static integer operator &(integer x, integer y)
{
return new integer(x.value & y.value);
}
// Bitwise OR operator
public static integer operator |(integer x, integer y)
{
return new integer(x.value | y.value);
}
// Bitwise Not operator
public static integer operator ~(integer a)
{
return new integer(~a.value);
}
// Bitwise Xor operator
public static integer operator ^(integer a, integer b)
{
return new integer(a.value ^ b.value);
}
// Bitwise Shift right (b must be int)
public static integer operator >>(integer a, int b)
{
return new integer(a.value >> b);
}
// Bitwise Shift left (b must be int)
public static integer operator <<(integer a, int b)
{
return new integer(a.value << b);
}
public static integer operator %(integer a, integer b)
{
return new integer(a.value % b.value);
}
// Definitely true operator. Returns true if the operand is
// !=0, false otherwise:
public static bool operator true(integer x)
{
return (x.value != 0);
}
// Definitely false operator. Returns true if the operand is
// ==0, false otherwise:
public static bool operator false(integer x)
{
return (x.value == 0);
}
public static explicit operator String(integer x)
{
return x.value.ToString();
}
// this one is needed by the compiler
public static implicit operator Int32(integer x)
{
return x.value;
}
public static integer operator +(integer a, integer b)
{
return new integer(a.value + b.value);
}
public static integer operator -(integer a, integer b)
{
return new integer(a.value - b.value);
}
public static integer operator -(integer a, bool b)
{
return a - (integer)b;
}
public static integer operator +(integer a, bool b)
{
return a + (integer)b;
}
// 6 jan 2008
public static integer operator *(integer a, integer b)
{
return new integer(a.value * b.value);
}
// 23 feb 2008
public static integer operator *(integer a, Float b)
{
Float result = (Float)a.value * b;
return new integer((int)result);
}
// 6 jan 2008
public static bool operator ==(integer a, integer b)
{
return (a.value == b.value);
}
// 6 jan 2008
public static bool operator !=(integer a, integer b)
{
return (a.value != b.value);
}
public static int Compare(integer a, integer b)
{
if (a.value < b.value)
return -1;
if (a.value > b.value)
return 1;
return 0;
}
// Override the Object.Equals(object o) method:
public override bool Equals(object o)
{
try
{
return (bool)(this == (integer)o);
}
catch
{
return false;
}
}
// Override the Object.GetHashCode() method:
public override int GetHashCode()
{
return value;
}
// Override the ToString method to convert integer to a string:
public override string ToString()
{
return value.ToString();
}
}
}
}

170
trunk/SecondLife/key.cs Normal file
View file

@ -0,0 +1,170 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
namespace LSLEditor
{
public partial class SecondLife
{
public struct key
{
private string m_value;
public string guid
{
get
{
if (m_value == null)
m_value = "";
return m_value;
}
set
{
m_value = value;
}
}
public key(Guid guid)
{
this.m_value = guid.ToString();
}
public key(string strGuid)
{
this.m_value = strGuid;
}
public static readonly key NULL_KEY;
static key()
{
NULL_KEY = new key("00000000-0000-0000-0000-000000000000");
}
// This is the one-and-only implicit typecasting in SecondLife
public static implicit operator key(string strGuid)
{
if (strGuid == null)
return new key("");
else
return new key(strGuid);
}
public static implicit operator key(String _strGuid)
{
string strGuid = _strGuid;
if (strGuid == null)
return new key("");
else
return new key(strGuid);
}
public override string ToString()
{
if (this.guid == null)
this.guid = "";
return this.guid.ToString();
}
//public static explicit operator String(key k)
//{
// return k.ToString();
//}
// Check this!!!!
public static implicit operator String(key k)
{
return k.ToString();
}
public static bool operator ==(key key1, key key2)
{
return (key1.guid == key2.guid);
}
public static bool operator !=(key key1, key key2)
{
return !(key1.guid == key2.guid);
}
public static bool operator true(key k)
{
if ((object)k == null)
return false;
if (k.guid == NULL_KEY)
return false;
if (k.guid == "")
return false;
return true;
}
public static bool operator false(key k)
{
if ((object)k == null)
return true;
if (k.guid == NULL_KEY)
return true;
if (k.guid == "")
return true;
return false;
}
public override bool Equals(object obj)
{
try
{
return (this == (key)obj);
}
catch
{
return false;
}
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}
}

349
trunk/SecondLife/list.cs Normal file
View file

@ -0,0 +1,349 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
using System.Text;
using System.Collections;
namespace LSLEditor
{
public partial class SecondLife
{
public struct list
{
private System.Collections.ArrayList value;
public list(object[] args)
{
this.value = new ArrayList();
foreach (object objA in args)
this.Add(objA);
}
public list(list a)
{
this.value = new ArrayList();
this.value.AddRange(a.ToArray());
}
public int Count
{
get
{
if (this.value == null)
this.value = new ArrayList();
return this.value.Count;
}
}
public void AddRange(list c)
{
if(this.value == null)
this.value = new ArrayList();
this.value.AddRange(c.ToArray());
}
public void Add(object value)
{
if (this.value == null)
this.value = new ArrayList();
string strType = value.GetType().ToString();
if (value is string)
this.value.Add((String)value.ToString());
else if (value is int)
this.value.Add(new integer((int)value));
else if (value is uint)
this.value.Add(new integer((int)(uint)value));
else if (value is double)
this.value.Add(new Float((double)value));
else
this.value.Add(value);
}
public object this[int index]
{
get
{
if (this.value == null)
this.value = new ArrayList();
return this.value[index];
}
set
{
if (this.value == null)
this.value = new ArrayList();
this.value[index] = value;
}
}
public void Insert(int index, object value)
{
if (this.value == null)
this.value = new ArrayList();
if (this.value == null)
this.value = new ArrayList();
string strType = value.GetType().ToString();
if (value is string)
this.value.Insert(index, (String)value.ToString());
else if (value is int)
this.value.Insert(index, new integer((int)value));
else if (value is uint)
this.value.Insert(index, new integer((int)(uint)value));
else if (value is double)
this.value.Insert(index, new Float((double)value));
else
this.value.Insert(index, value);
}
public object[] ToArray()
{
if (this.value == null)
this.value = new ArrayList();
return this.value.ToArray();
}
public static list operator +(list a, list b)
{
list l = new list();
if((object)a != null)
l.AddRange(a);
if ((object)b != null)
l.AddRange(b);
return l;
}
public static list operator +(object b, list a)
{
list l = new list();
if ((object)a != null)
l.AddRange(a);
l.Insert(0, b);
return l;
}
public static list operator +(list a, object b)
{
list l = new list();
if ((object)a != null)
l.AddRange(a);
l.Add(b);
return l;
}
public static explicit operator list(string a)
{
list l = new list();
l.Add(a);
return l;
}
public static explicit operator list(String a)
{
list l = new list();
l.Add(a);
return l;
}
public static explicit operator list(integer a)
{
list l = new list();
l.Add(a);
return l;
}
public static explicit operator list(key a)
{
list l = new list();
l.Add(a);
return l;
}
public static explicit operator list(vector a)
{
list l = new list();
l.Add(a);
return l;
}
public static explicit operator list(rotation a)
{
list l = new list();
l.Add(a);
return l;
}
public static explicit operator list(uint a)
{
list l = new list();
l.Add(a);
return l;
}
public static explicit operator list(int a)
{
list l = new list();
l.Add(a);
return l;
}
public static explicit operator list(double a)
{
list l = new list();
l.Add(a);
return l;
}
public static integer operator ==(list l, list m)
{
if (l.Count != m.Count)
return FALSE;
for (int intI = 0; intI < l.Count; intI++)
if (!l[intI].Equals(m[intI]))
return FALSE;
return TRUE;
}
public static integer operator !=(list l, list m)
{
int intDifferent=0;
if (m.Count == 0) // shortcut
return l.Count;
for (int intI = 0; intI < l.Count; intI++)
{
bool blnFound = false;
for (int intJ = 0; intJ < m.Count; intJ++)
{
if (l[intI].Equals(m[intJ]))
{
blnFound = true;
break;
}
}
if(!blnFound)
intDifferent++;
}
return intDifferent;
}
public static bool operator true(list x)
{
if ((object)x == null)
return false;
return (x.value.Count != 0);
}
// Definitely false operator. Returns true if the operand is
// ==0, false otherwise:
public static bool operator false(list x)
{
if ((object)x == null)
return true;
return (x.value.Count == 0);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override bool Equals(object obj)
{
int intResult = (this == (list)obj);
return (intResult == 1);
}
public string ToVerboseString()
{
if (this.value == null)
this.value = new ArrayList();
StringBuilder sb = new StringBuilder();
sb.Append('[');
for (int intI = 0; intI < this.value.Count; intI++)
{
if(intI>0)
sb.Append(',');
if((this.value[intI] is string) && Properties.Settings.Default.QuotesListVerbose)
sb.Append("\""+this.value[intI].ToString()+"\"");
else
sb.Append(this.value[intI].ToString());
}
sb.Append(']');
return sb.ToString();
}
public override string ToString()
{
if (this.value == null)
this.value = new ArrayList();
StringBuilder sb = new StringBuilder();
for (int intI = 0; intI < this.value.Count; intI++)
{
if (this.value[intI] is vector)
{
vector v = (vector)this.value[intI];
sb.AppendFormat(new System.Globalization.CultureInfo("en-us"), "<{0:0.000000}, {1:0.000000}, {2:0.000000}>", (double)v.x, (double)v.y, (double)v.z);
}
else if (this.value[intI] is rotation)
{
rotation r = (rotation)this.value[intI];
sb.AppendFormat(new System.Globalization.CultureInfo("en-us"), "<{0:0.000000}, {1:0.000000}, {2:0.000000}, {3:0.000000}>", (double)r.x, (double)r.y, (double)r.z, (double)r.s);
}
else
sb.Append(this.value[intI].ToString());
}
return sb.ToString();
}
public static explicit operator String(list l)
{
if ((object)l == null)
return "";
else
return l.ToString();
}
}
}
}

View file

@ -0,0 +1,281 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
using System.Text.RegularExpressions;
namespace LSLEditor
{
public partial class SecondLife
{
public struct rotation
{
private object m_x, m_y, m_z, m_s;
public Float x
{
get
{
if (m_x == null)
m_x = (Float)0;
return (Float)m_x;
}
set
{
m_x = value;
}
}
public Float y
{
get
{
if (m_y == null)
m_y = (Float)0;
return (Float)m_y;
}
set
{
m_y = value;
}
}
public Float z
{
get
{
if (m_z == null)
m_z = (Float)0;
return (Float)m_z;
}
set
{
m_z = value;
}
}
public Float s
{
get
{
if (m_s == null)
m_s = (Float)0;
return (Float)m_s;
}
set
{
m_s = value;
}
}
public static readonly rotation ZERO_ROTATION;
public rotation(double x, double y, double z, double s)
{
this.m_x = (Float)x;
this.m_y = (Float)y;
this.m_z = (Float)z;
this.m_s = (Float)s;
}
public static explicit operator rotation(String s)
{
return new rotation(s.ToString());
}
public static explicit operator rotation(string s)
{
return new rotation(s);
}
public rotation(string a)
{
this.m_x = (Float)0;
this.m_y = (Float)0;
this.m_z = (Float)0;
this.m_s = (Float)0;
Regex regex = new Regex(
@"<(?<x>[^,]*),(?<y>[^,]*),(?<z>[^,]*),(?<s>[^,]*)>",
RegexOptions.IgnorePatternWhitespace |
RegexOptions.Compiled);
Match m = regex.Match(a);
if (m.Success)
{
this.m_x = new Float(m.Groups["x"].Value);
this.m_y = new Float(m.Groups["y"].Value);
this.m_z = new Float(m.Groups["z"].Value);
this.m_s = new Float(m.Groups["s"].Value);
}
}
static rotation()
{
ZERO_ROTATION = new rotation(0, 0, 0, 1);
}
public override string ToString()
{
return string.Format(new System.Globalization.CultureInfo("en-us"), "<{0:0.00000}, {1:0.00000}, {2:0.00000}, {3:0.00000}>", (double)this.x, (double)this.y, (double)this.z, (double)this.s);
}
public static explicit operator String(rotation rot)
{
if ((object)rot == null)
return ZERO_ROTATION.ToString();
else
return rot.ToString();
}
// 23 feb 2008
public static rotation operator -(rotation r)
{
return new rotation(-r.x, -r.y, -r.z, -r.s);
}
// 23 feb 2008
public static rotation operator +(rotation r)
{
return new rotation(r.x, r.y, r.z, r.s);
}
public static rotation operator *(rotation q, rotation r)
{
rotation rot = new rotation(
r.s * q.x - r.z * q.y + r.y * q.z + r.x * q.s,
r.s * q.y + r.z * q.x + r.y * q.s - r.x * q.z,
r.s * q.z + r.z * q.s - r.y * q.x + r.x * q.y,
r.s * q.s - r.z * q.z - r.y * q.y - r.x * q.x);
return rot;
}
public static rotation operator /(rotation q, rotation r)
{ // 23 feb 2008
rotation rot = new rotation(
r.s * q.x + r.z * q.y - r.y * q.z - r.x * q.s,
r.s * q.y - r.z * q.x - r.y * q.s + r.x * q.z,
r.s * q.z - r.z * q.s + r.y * q.x - r.x * q.y,
r.s * q.s + r.z * q.z + r.y * q.y + r.x * q.x);
return rot;
}
public static rotation operator +(rotation q, rotation r)
{
return new rotation(
q.x + r.x,
q.y + r.y,
q.z + r.z,
q.s + r.s
);
}
public static rotation operator -(rotation q, rotation r)
{
return new rotation(
q.x - r.x,
q.y - r.y,
q.z - r.z,
q.s - r.s
);
}
public const double EqualityTolerence = 1e-14; //Double.Epsilon;
public static bool operator ==(rotation r1, rotation r2)
{
if ((object)r1 == null)
r1 = ZERO_ROTATION;
if ((object)r2 == null)
r2 = ZERO_ROTATION;
if (Math.Abs(r1.x - r2.x) > EqualityTolerence)
return false;
if (Math.Abs(r1.y - r2.y) > EqualityTolerence)
return false;
if (Math.Abs(r1.z - r2.z) > EqualityTolerence)
return false;
if (Math.Abs(r1.s - r2.s) > EqualityTolerence)
return false;
return true;
}
public static bool operator !=(rotation r, rotation s)
{
return !(r == s);
}
public static bool operator true(rotation r)
{
if ((object)r == null)
return false;
if (r.x == 0 && r.y == 0 && r.z == 0 && r.s == 1)
return false;
return true;
}
public static bool operator false(rotation r)
{
if ((object)r == null)
return true;
if (r.x == 0 && r.y == 0 && r.z == 0 && r.s == 1)
return true;
return false;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override bool Equals(object obj)
{
try
{
return (this == (rotation)obj);
}
catch
{
return false;
}
}
}
}
}

292
trunk/SecondLife/vector.cs Normal file
View file

@ -0,0 +1,292 @@
// /**
// ********
// *
// * ORIGIONAL CODE BASE IS Copyright (C) 2006-2010 by Alphons van der Heijden
// * The code was donated on 4/28/2010 by Alphons van der Heijden
// * To Brandon'Dimentox Travanti' Husbands & Malcolm J. Kudra which in turn Liscense under the GPLv2.
// * In agreement to Alphons van der Heijden wishes.
// *
// * The community would like to thank Alphons for all of his hard work, blood sweat and tears.
// * Without his work the community would be stuck with crappy editors.
// *
// * The source code in this file ("Source Code") is provided by The LSLEditor Group
// * to you under the terms of the GNU General Public License, version 2.0
// * ("GPL"), unless you have obtained a separate licensing agreement
// * ("Other License"), formally executed by you and The LSLEditor Group. Terms of
// * the GPL can be found in the gplv2.txt document.
// *
// ********
// * GPLv2 Header
// ********
// * LSLEditor, a External editor for the LSL Language.
// * Copyright (C) 2010 The LSLEditor Group.
//
// * This program is free software; you can redistribute it and/or
// * modify it under the terms of the GNU General Public License
// * as published by the Free Software Foundation; either version 2
// * of the License, or (at your option) any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program; if not, write to the Free Software
// * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// ********
// *
// * The above copyright notice and this permission notice shall be included in all
// * copies or substantial portions of the Software.
// *
// ********
// */
using System;
using System.Text.RegularExpressions;
namespace LSLEditor
{
public partial class SecondLife
{
public struct vector
{
private object m_x, m_y, m_z;
public Float x
{
get
{
if (m_x == null)
m_x = (Float)0;
return (Float)m_x;
}
set
{
m_x = value;
}
}
public Float y
{
get
{
if (m_y == null)
m_y = (Float)0;
return (Float)m_y;
}
set
{
m_y = value;
}
}
public Float z
{
get
{
if (m_z == null)
m_z = (Float)0;
return (Float)m_z;
}
set
{
m_z = value;
}
}
public static readonly vector ZERO_VECTOR;
public vector(double x, double y, double z)
{
this.m_x = (Float)x;
this.m_y = (Float)y;
this.m_z = (Float)z;
}
public vector(string a)
{
this.m_x = (Float)0;
this.m_y = (Float)0;
this.m_z = (Float)0;
Regex regex = new Regex(
@"<(?<x>[^,]*),(?<y>[^,]*),(?<z>[^,]*)>",
RegexOptions.IgnorePatternWhitespace |
RegexOptions.Compiled);
Match m = regex.Match(a);
if (m.Success)
{
this.m_x = new Float(m.Groups["x"].Value);
this.m_y = new Float(m.Groups["y"].Value);
this.m_z = new Float(m.Groups["z"].Value);
}
}
static vector()
{
ZERO_VECTOR = new vector(0, 0, 0);
}
public static explicit operator vector(string s)
{
return new vector(s);
}
public static explicit operator vector(String s)
{
return new vector(s.ToString());
}
private double SumSqrs()
{
return x * x + y * y + z * z;
}
public static vector operator +(vector vector1, vector vector2)
{
return new vector(vector1.x + vector2.x, vector1.y + vector2.y, vector1.z + vector2.z);
}
public static vector operator -(vector vector1, vector vector2)
{
return new vector(vector1.x - vector2.x, vector1.y - vector2.y, vector1.z - vector2.z);
}
// 2 jun 2007
public static vector operator -(vector vector1)
{
return new vector(-vector1.x, -vector1.y, -vector1.z);
}
// 2 jun 2007
public static vector operator +(vector vector1)
{
return new vector(vector1.x, vector1.y, vector1.z);
}
public static double operator *(vector vector1, vector vector2)
{
return vector1.x * vector2.x + vector1.y * vector2.y + vector1.z * vector2.z;
}
public static vector operator /(vector v1, double dbl1)
{
return new vector(v1.x / dbl1, v1.y / dbl1, v1.z / dbl1);
}
public static vector operator *(vector v1, double dbl1)
{
return new vector(v1.x * dbl1, v1.y * dbl1, v1.z * dbl1);
}
public static vector operator *(double dbl1, vector v1)
{
return v1 * dbl1;
}
public static vector operator %(vector vector1, vector vector2)
{
return new vector(
vector1.y * vector2.z - vector1.z * vector2.y,
vector1.z * vector2.x - vector1.x * vector2.z,
vector1.x * vector2.y - vector1.y * vector2.x);
}
// checked 3 jun 2007
public static vector operator *(vector v, rotation r)
{
return new vector(
(r.s * r.s + r.x * r.x - r.y * r.y - r.z * r.z) * v.x + 2 * (r.x * r.y - r.s * r.z) * v.y + 2 * (r.s * r.y + r.x * r.z) * v.z,
2 * (r.s * r.z + r.x * r.y) * v.x + (r.s * r.s - r.x * r.x + r.y * r.y - r.z * r.z) * v.y + 2 * (r.y * r.z - r.s * r.x) * v.z,
2 * (r.x * r.z - r.s * r.y) * v.x + 2 * (r.s * r.x + r.y * r.z) * v.y + (r.s * r.s - r.x * r.x - r.y * r.y + r.z * r.z) * v.z
);
}
public static vector operator /(vector v, rotation r)
{
rotation inverseR = new rotation(-r.x,-r.y,-r.z,r.s);
return (v * inverseR);
}
// 2 jun 2007
public static bool operator <(vector v1, vector v2)
{
return v1.SumSqrs() < v2.SumSqrs();
}
// 2 jun 2007
public static bool operator <=(vector v1, vector v2)
{
return v1.SumSqrs() <= v2.SumSqrs();
}
// 2 jun 2007
public static bool operator >(vector v1, vector v2)
{
return v1.SumSqrs() > v2.SumSqrs();
}
public static bool operator >=(vector v1, vector v2)
{
return v1.SumSqrs() >= v2.SumSqrs();
}
public const double EqualityTolerence = 1e-14;
public static bool operator ==(vector v1, vector v2)
{
if ((object)v1 == null)
v1 = ZERO_VECTOR;
if ((object)v2 == null)
v2 = ZERO_VECTOR;
if (Math.Abs(v1.x - v2.x) > EqualityTolerence)
return false;
if (Math.Abs(v1.y - v2.y) > EqualityTolerence)
return false;
if (Math.Abs(v1.z - v2.z) > EqualityTolerence)
return false;
return true;
}
public static bool operator !=(vector v1, vector v2)
{
return !(v1 == v2);
}
public static bool operator true(vector v)
{
if ((object)v == null)
return false;
if (v.x == 0 && v.y == 0 && v.z == 0)
return false;
return true;
}
public static bool operator false(vector v)
{
if ((object)v == null)
return true;
if (v.x == 0 && v.y == 0 && v.z == 0)
return true;
return false;
}
public override string ToString()
{
return string.Format(new System.Globalization.CultureInfo("en-us"), "<{0:0.00000}, {1:0.00000}, {2:0.00000}>", (double)this.x, (double)this.y, (double)this.z);
}
public static explicit operator String(vector v)
{
if ((object)v == null)
return ZERO_VECTOR.ToString();
else
return v.ToString();
}
public override int GetHashCode()
{
return (int)((x + y + z) % Int32.MaxValue);
}
public override bool Equals(object obj)
{
try
{
return (this == (vector)obj);
}
catch
{
return false;
}
}
}
}
}