Fixing whitespace/formatting style.

This commit is contained in:
Ima Mechanique 2013-07-13 11:42:48 +01:00
parent 3bc95288c5
commit 8661094ddd
12 changed files with 3822 additions and 3900 deletions

View file

@ -58,9 +58,9 @@ namespace LSLEditor
private string m_FullPathName; private string m_FullPathName;
private Guid m_Guid; private Guid m_Guid;
// private bool sOutline = true; // private bool sOutline = true;
public LSLEditorForm parent; public LSLEditorForm parent;
public Encoding encodedAs = null; public Encoding encodedAs = null;
private const int WM_NCACTIVATE = 0x0086; private const int WM_NCACTIVATE = 0x0086;
protected override void WndProc(ref Message m) protected override void WndProc(ref Message m)
@ -141,7 +141,7 @@ namespace LSLEditor
this.Icon = lslEditorForm.Icon; this.Icon = lslEditorForm.Icon;
this.parent = lslEditorForm; this.parent = lslEditorForm;
this.numberedTextBoxUC1.TextBox.setEditform(this); this.numberedTextBoxUC1.TextBox.setEditform(this);
this.numberedTextBoxUC1.TextBox.Init(this.parent, this.parent.ConfLSL); this.numberedTextBoxUC1.TextBox.Init(this.parent, this.parent.ConfLSL);
this.numberedTextBoxUC1.TextBox.OnDirtyChanged += new IsDirtyHandler(TextBox_OnDirtyChanged); this.numberedTextBoxUC1.TextBox.OnDirtyChanged += new IsDirtyHandler(TextBox_OnDirtyChanged);
@ -149,25 +149,25 @@ namespace LSLEditor
this.Resize += new EventHandler(EditForm_Position); this.Resize += new EventHandler(EditForm_Position);
this.Layout += new LayoutEventHandler(EditForm_Layout); this.Layout += new LayoutEventHandler(EditForm_Layout);
ImageList imageList = new ImageList(); ImageList imageList = new ImageList();
imageList.Images.Add(new Bitmap(this.GetType(), "Images.Unknown.gif")); imageList.Images.Add(new Bitmap(this.GetType(), "Images.Unknown.gif"));
imageList.Images.Add(new Bitmap(this.GetType(), "Images.Functions.gif")); imageList.Images.Add(new Bitmap(this.GetType(), "Images.Functions.gif"));
imageList.Images.Add(new Bitmap(this.GetType(), "Images.Events.gif")); imageList.Images.Add(new Bitmap(this.GetType(), "Images.Events.gif"));
imageList.Images.Add(new Bitmap(this.GetType(), "Images.Constants.gif")); imageList.Images.Add(new Bitmap(this.GetType(), "Images.Constants.gif"));
imageList.Images.Add(new Bitmap(this.GetType(), "Images.Class.gif")); imageList.Images.Add(new Bitmap(this.GetType(), "Images.Class.gif"));
imageList.Images.Add(new Bitmap(this.GetType(), "Images.Vars.gif")); imageList.Images.Add(new Bitmap(this.GetType(), "Images.Vars.gif"));
imageList.Images.Add(new Bitmap(this.GetType(), "Images.Properties.gif")); imageList.Images.Add(new Bitmap(this.GetType(), "Images.Properties.gif"));
imageList.Images.Add(new Bitmap(this.GetType(), "Images.States.gif")); imageList.Images.Add(new Bitmap(this.GetType(), "Images.States.gif"));
this.tvOutline.ImageList = imageList; this.tvOutline.ImageList = imageList;
if (lslEditorForm.outlineToolStripMenuItem.Checked) if (lslEditorForm.outlineToolStripMenuItem.Checked)
{ {
splitContainer1.Panel2Collapsed = false; splitContainer1.Panel2Collapsed = false;
} }
else else
{ {
splitContainer1.Panel2Collapsed = true; splitContainer1.Panel2Collapsed = true;
} }
SetFont(); SetFont();
} }
@ -199,7 +199,7 @@ namespace LSLEditor
tabPage.Text = this.Text; tabPage.Text = this.Text;
this.parent.OnDirtyChanged(this.numberedTextBoxUC1.TextBox.Dirty); this.parent.OnDirtyChanged(this.numberedTextBoxUC1.TextBox.Dirty);
} }
private void exitToolStripMenuItem_Click(object sender, EventArgs e) private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{ {
@ -319,32 +319,32 @@ namespace LSLEditor
public void SaveCurrentFile(string strPath) public void SaveCurrentFile(string strPath)
{ {
this.FullPathName = strPath; this.FullPathName = strPath;
Encoding encodeAs = this.encodedAs; Encoding encodeAs = this.encodedAs;
if (this.IsScript && encodeAs == null) if (this.IsScript && encodeAs == null)
{ {
switch (Properties.Settings.Default.OutputFormat) switch (Properties.Settings.Default.OutputFormat)
{ {
case "UTF8": case "UTF8":
encodeAs = Encoding.UTF8; encodeAs = Encoding.UTF8;
break; break;
case "Unicode": case "Unicode":
encodeAs = Encoding.Unicode; encodeAs = Encoding.Unicode;
break; break;
case "BigEndianUnicode": case "BigEndianUnicode":
encodeAs = Encoding.BigEndianUnicode; encodeAs = Encoding.BigEndianUnicode;
break; break;
default: default:
encodeAs = Encoding.Default; encodeAs = Encoding.Default;
break; break;
} }
} }
else if (encodeAs == null) else if (encodeAs == null)
{ {
encodeAs = Encoding.UTF8; encodeAs = Encoding.UTF8;
} }
this.numberedTextBoxUC1.TextBox.SaveCurrentFile(strPath, encodeAs); this.numberedTextBoxUC1.TextBox.SaveCurrentFile(strPath, encodeAs);
this.encodedAs = encodeAs; this.encodedAs = encodeAs;
} }
public void SaveCurrentFile() public void SaveCurrentFile()
@ -492,44 +492,44 @@ namespace LSLEditor
//this.disableCompilesyntaxCheckToolStripMenuItem.Checked = !this.disableCompilesyntaxCheckToolStripMenuItem.Checked; //this.disableCompilesyntaxCheckToolStripMenuItem.Checked = !this.disableCompilesyntaxCheckToolStripMenuItem.Checked;
} }
private void tvOutline_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) private void tvOutline_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{ {
this.parent.BeginInvoke(new TreeNodeMouseClickEventHandler( this.parent.BeginInvoke(new TreeNodeMouseClickEventHandler(
delegate(object sender2, TreeNodeMouseClickEventArgs e2) delegate(object sender2, TreeNodeMouseClickEventArgs e2)
{ {
if (e.Node.Tag is Helpers.OutlineHelper) if (e.Node.Tag is Helpers.OutlineHelper)
{ {
Helpers.OutlineHelper ohOutline = (Helpers.OutlineHelper)e.Node.Tag; Helpers.OutlineHelper ohOutline = (Helpers.OutlineHelper)e.Node.Tag;
if (ohOutline.line < this.TextBox.Lines.Length) if (ohOutline.line < this.TextBox.Lines.Length)
{ {
//editForm.Focus(); //editForm.Focus();
//editForm.TextBox.Select(); //editForm.TextBox.Select();
//editForm.TextBox.Goto(ohOutline.line + 1); //editForm.TextBox.Goto(ohOutline.line + 1);
//TextBox.Focus(); //TextBox.Focus();
this.TextBox.Select(); this.TextBox.Select();
this.TextBox.SelectionStart = this.TextBox.GetFirstCharIndexFromLine(ohOutline.line); this.TextBox.SelectionStart = this.TextBox.GetFirstCharIndexFromLine(ohOutline.line);
} }
} }
}), sender, e); }), sender, e);
} }
private void tvOutline_AfterSelect(object sender, TreeViewEventArgs e) private void tvOutline_AfterSelect(object sender, TreeViewEventArgs e)
{ {
//this.TextBox.Select //this.TextBox.Select
} }
private void splitContainer1_Click(object sender, EventArgs e) private void splitContainer1_Click(object sender, EventArgs e)
{ {
} }
private void tvOutline_VisibleChanged(object sender, EventArgs e) private void tvOutline_VisibleChanged(object sender, EventArgs e)
{ {
this.tvOutline.ExpandAll(); this.tvOutline.ExpandAll();
} }
} }
} }

View file

@ -66,17 +66,17 @@ namespace LSLEditor
public class SecondLifeHostMessageLinkedEventArgs : EventArgs public class SecondLifeHostMessageLinkedEventArgs : EventArgs
{ {
public SecondLife.integer linknum; public SecondLife.integer iLinkIndex;
public SecondLife.integer num; public SecondLife.integer iNumber;
public SecondLife.String str; public SecondLife.String sText;
public SecondLife.key id; public SecondLife.key kID;
public SecondLifeHostMessageLinkedEventArgs(SecondLife.integer linknum, SecondLife.integer num, SecondLife.String str, SecondLife.key id) public SecondLifeHostMessageLinkedEventArgs(SecondLife.integer iLinkIndex, SecondLife.integer iNumber, SecondLife.String sText, SecondLife.key kID)
{ {
this.linknum = linknum; this.iLinkIndex = iLinkIndex;
this.num = num; this.iNumber = iNumber;
this.str = str; this.sText = sText;
this.id = id; this.kID = kID;
} }
} }
@ -179,12 +179,10 @@ namespace LSLEditor
private void StateWatch() private void StateWatch()
{ {
while (true) while (true) {
{
this.StateChanged.WaitOne(); this.StateChanged.WaitOne();
this.taskQueue.Start(); // is implicit Stop() old Queue this.taskQueue.Start(); // is implicit Stop() old Queue
if (this.CurrentStateName != this.NewStateName) if (this.CurrentStateName != this.NewStateName) {
{
this.CurrentStateName = this.NewStateName; this.CurrentStateName = this.NewStateName;
ExecuteSecondLife("state_exit"); ExecuteSecondLife("state_exit");
@ -196,56 +194,55 @@ namespace LSLEditor
public void State(string strStateName, bool blnForce) public void State(string strStateName, bool blnForce)
{ {
if (this.CompiledAssembly == null) if (this.CompiledAssembly != null) {
return; if (blnForce) {
if (blnForce) this.CurrentStateName = "";
this.CurrentStateName = ""; }
this.NewStateName = strStateName; this.NewStateName = strStateName;
this.StateChanged.Set(); this.StateChanged.Set();
}
} }
private void SetState() private void SetState()
{ {
if (CompiledAssembly == null) if (CompiledAssembly != null) {
return; secondLife = CompiledAssembly.CreateInstance("LSLEditor.State_" + CurrentStateName) as SecondLife;
secondLife = CompiledAssembly.CreateInstance("LSLEditor.State_" + CurrentStateName) as SecondLife;
if (secondLife == null) if (secondLife == null) {
{ MessageBox.Show("State " + CurrentStateName + " does not exist!");
MessageBox.Show("State " + CurrentStateName+" does not exist!"); return;
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");
} }
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) 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 = ""; string strArgs = "";
foreach (ParameterInfo pi in mi.GetParameters()) if (this.secondLife != null) {
{ MethodInfo mi = secondLife.GetType().GetMethod(strName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
if (intI > 0) if (mi != null) {
strArgs += ","; int intI = 0;
strArgs += pi.ParameterType.ToString() + " " + pi.Name; foreach (ParameterInfo pi in mi.GetParameters()) {
intI++; if (intI > 0)
strArgs += ",";
strArgs += pi.ParameterType.ToString() + " " + pi.Name;
intI++;
}
}
} }
return strArgs; return strArgs;
} }
@ -256,10 +253,8 @@ namespace LSLEditor
sb.Append("*** "); sb.Append("*** ");
sb.Append(strEventName); sb.Append(strEventName);
sb.Append('('); sb.Append('(');
for (int intI = 0; intI < args.Length; intI++) for (int intI = 0; intI < args.Length; intI++) {
{ if (intI > 0) sb.Append(',');
if (intI > 0)
sb.Append(',');
sb.Append(args[intI].ToString()); sb.Append(args[intI].ToString());
} }
sb.Append(")"); sb.Append(")");
@ -268,21 +263,18 @@ namespace LSLEditor
public void ExecuteSecondLife(string strName, params object[] args) public void ExecuteSecondLife(string strName, params object[] args)
{ {
if (secondLife == null) if (secondLife != null) {
return; VerboseEvent(strName, args);
VerboseEvent(strName, args); this.taskQueue.Invoke(secondLife, strName, args);
}
this.taskQueue.Invoke(secondLife, strName, args);
} }
public ArrayList GetEvents() public ArrayList GetEvents()
{ {
ArrayList ar = new ArrayList(); ArrayList ar = new ArrayList();
if (secondLife != null) if (secondLife != null) {
{ foreach (MethodInfo mi in secondLife.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) {
foreach (MethodInfo mi in secondLife.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
{
ar.Add(mi.Name); ar.Add(mi.Name);
} }
} }
@ -292,17 +284,18 @@ namespace LSLEditor
public void Reset() public void Reset()
{ {
if (OnReset != null) if (OnReset != null) {
OnReset(this, new EventArgs()); OnReset(this, new EventArgs());
}
} }
public void Die() public void Die()
{ {
if (OnDie != null) if (OnDie != null) {
OnDie(this, new EventArgs()); OnDie(this, new EventArgs());
}
if (secondLife != null) if (secondLife != null) {
{
// stop all timers // stop all timers
this.timer.Stop(); this.timer.Stop();
this.sensor_timer.Stop(); this.sensor_timer.Stop();
@ -313,26 +306,21 @@ namespace LSLEditor
this.secondLife = null; this.secondLife = null;
} }
} }
public void Dispose() public void Dispose()
{ {
if (taskQueue != null) if (taskQueue != null) {
{
this.taskQueue.Stop(); this.taskQueue.Stop();
this.taskQueue.Dispose(); this.taskQueue.Dispose();
this.taskQueue = null; this.taskQueue = null;
} }
if (listXmlRpc != null) if (listXmlRpc != null) {
{ foreach (XMLRPC xmlRpc in listXmlRpc) {
foreach (XMLRPC xmlRpc in listXmlRpc)
{
xmlRpc.CloseChannel(); xmlRpc.CloseChannel();
} }
} }
if (secondLife != null) if (secondLife != null) {
{
this.timer.Stop(); this.timer.Stop();
this.sensor_timer.Stop(); this.sensor_timer.Stop();
this.mainForm = null; this.mainForm = null;
@ -364,10 +352,8 @@ namespace LSLEditor
public void llBreakLink(int linknum) public void llBreakLink(int linknum)
{ {
foreach (Link link in this.LinkList) foreach (Link link in this.LinkList) {
{ if (link.number == linknum) {
if (link.number == linknum)
{
this.LinkList.Remove(link); this.LinkList.Remove(link);
break; break;
} }
@ -381,8 +367,7 @@ namespace LSLEditor
public string[] GetListenChannels() // for GroupboxEvent public string[] GetListenChannels() // for GroupboxEvent
{ {
List<string> list = new List<string>(); List<string> list = new List<string>();
foreach (ListenFilter lf in ListenFilterList) foreach (ListenFilter lf in ListenFilterList) {
{
list.Add(lf.channel.ToString()); list.Add(lf.channel.ToString());
} }
return list.ToArray(); return list.ToArray();
@ -407,11 +392,9 @@ namespace LSLEditor
public void llListenControl(int number, int active) public void llListenControl(int number, int active)
{ {
for (int intI = 0; intI < ListenFilterList.Count; intI++) for (int intI = 0; intI < ListenFilterList.Count; intI++) {
{
ListenFilter lf = ListenFilterList[intI]; ListenFilter lf = ListenFilterList[intI];
if (lf.GetHashCode() == number) if (lf.GetHashCode() == number) {
{
lf.active = (active == 1); lf.active = (active == 1);
ListenFilterList[intI] = lf; ListenFilterList[intI] = lf;
break; break;
@ -421,11 +404,9 @@ namespace LSLEditor
public void llListenRemove(int intHandle) public void llListenRemove(int intHandle)
{ {
for (int intI = 0; intI < ListenFilterList.Count; intI++) for (int intI = 0; intI < ListenFilterList.Count; intI++) {
{
ListenFilter lf = ListenFilterList[intI]; ListenFilter lf = ListenFilterList[intI];
if (lf.GetHashCode() == intHandle) if (lf.GetHashCode() == intHandle) {
{
ListenFilterList.RemoveAt(intI); ListenFilterList.RemoveAt(intI);
break; break;
} }
@ -450,18 +431,12 @@ namespace LSLEditor
{ {
ListenFilter lfToCheck = new ListenFilter(channel, name, id, message); ListenFilter lfToCheck = new ListenFilter(channel, name, id, message);
foreach (ListenFilter lf in ListenFilterList) foreach (ListenFilter lf in ListenFilterList) {
{ if (!lf.active) continue;
if (!lf.active) if (lf.channel != lfToCheck.channel) continue;
continue; if (lf.name != "" && lf.name != lfToCheck.name) continue;
if (lf.channel != lfToCheck.channel) if (lf.id != Guid.Empty.ToString() && lf.id != "" && lf.id != lfToCheck.id) continue;
continue; if (lf.message != "" && lf.message != lfToCheck.message) 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 true;
} }
return false; return false;
@ -470,10 +445,11 @@ namespace LSLEditor
// sink listen // sink listen
public void Listen(SecondLifeHostChatEventArgs e) public void Listen(SecondLifeHostChatEventArgs e)
{ {
if (secondLife == null) if (secondLife != null) {
return; if (CheckListenFilter(e.channel, e.name, e.id, e.message)) {
if (CheckListenFilter(e.channel, e.name, e.id, e.message)) ExecuteSecondLife("listen", e.channel, e.name, e.id, e.message);
ExecuteSecondLife("listen", e.channel, e.name, e.id, e.message); }
}
} }
#endregion #endregion
@ -481,98 +457,99 @@ namespace LSLEditor
// raise // raise
public void Chat(object sender, int channel, string name, SecondLife.key id, string message, CommunicationType how) public void Chat(object sender, int channel, string name, SecondLife.key id, string message, CommunicationType how)
{ {
if (OnChat != null) if (OnChat != null) {
OnChat(sender, new SecondLifeHostChatEventArgs(channel, name, id, message, how)); OnChat(sender, new SecondLifeHostChatEventArgs(channel, name, id, message, how));
}
} }
// raise // raise
public void MessageLinked(SecondLife.integer linknum, SecondLife.integer num, SecondLife.String str, SecondLife.key id) public void MessageLinked(SecondLife.integer iLlinkIndex, SecondLife.integer iNumber, SecondLife.String sText, SecondLife.key kID)
{ {
if (OnMessageLinked != null) if (OnMessageLinked != null) {
OnMessageLinked(this, new SecondLifeHostMessageLinkedEventArgs(linknum, num, str, id)); OnMessageLinked(this, new SecondLifeHostMessageLinkedEventArgs(iLlinkIndex, iNumber, sText, kID));
}
} }
// sink // sink
public void LinkMessage(SecondLifeHostMessageLinkedEventArgs e) public void LinkMessage(SecondLifeHostMessageLinkedEventArgs e)
{ {
ExecuteSecondLife("link_message", e.linknum, e.num, e.str, e.id); ExecuteSecondLife("link_message", e.iLinkIndex, e.iNumber, e.sText, e.kID);
} }
public SecondLife.key Http(string Url, SecondLife.list Parameters, string Body) public SecondLife.key Http(string Url, SecondLife.list Parameters, string Body)
{ {
if (secondLife == null) SecondLife.key Key = SecondLife.NULL_KEY;
return SecondLife.NULL_KEY; if (secondLife != null) {
System.Net.WebProxy proxy = null;
if (Properties.Settings.Default.ProxyServer != "") {
proxy = new System.Net.WebProxy(Properties.Settings.Default.ProxyServer.Replace("http://", ""));
}
System.Net.WebProxy proxy = null; if (Properties.Settings.Default.ProxyUserid != "" && proxy != null) {
if (Properties.Settings.Default.ProxyServer != "") proxy.Credentials = new System.Net.NetworkCredential(Properties.Settings.Default.ProxyUserid, Properties.Settings.Default.ProxyPassword);
proxy = new System.Net.WebProxy(Properties.Settings.Default.ProxyServer.Replace("http://", "")); }
if (Properties.Settings.Default.ProxyUserid != "" && proxy != null) Key = new SecondLife.key(Guid.NewGuid());
proxy.Credentials = new System.Net.NetworkCredential(Properties.Settings.Default.ProxyUserid, Properties.Settings.Default.ProxyPassword); //WebRequestClass a = new WebRequestClass(proxy, secondLife, Url, Parameters, Body, Key);
try {
SecondLife.key Key = new SecondLife.key(Guid.NewGuid()); HTTPRequest.Request(proxy, secondLife, Url, Parameters, Body, Key);
//WebRequestClass a = new WebRequestClass(proxy, secondLife, Url, Parameters, Body, Key); } catch (Exception exception) {
try VerboseMessage(exception.Message);
{ }
HTTPRequest.Request(proxy, secondLife, Url, Parameters, Body, Key);
}
catch(Exception exception)
{
VerboseMessage(exception.Message);
} }
return Key; return Key;
} }
public void Email(string To, string Subject, string Body) public void Email(string To, string Subject, string Body)
{ {
if (secondLife == null) if (secondLife != null) {
return; SmtpClient client = new SmtpClient();
client.SmtpServer = Properties.Settings.Default.EmailServer;
SmtpClient client = new SmtpClient(); string strName = GetObjectName();
client.SmtpServer = Properties.Settings.Default.EmailServer; string strObjectName = string.Format("Object-Name: {0}", strName);
string strName = GetObjectName(); SecondLife.vector RegionCorner = secondLife.llGetRegionCorner();
string strObjectName = string.Format("Object-Name: {0}", strName); string strRegionName = secondLife.llGetRegionName();
string strRegion = string.Format("Region: {0} ({1},{2})", strRegionName, RegionCorner.x, RegionCorner.y);
SecondLife.vector RegionCorner = secondLife.llGetRegionCorner(); SecondLife.vector pos = secondLife.llGetPos();
string strRegionName = secondLife.llGetRegionName(); string strPosition = string.Format("Local-Position: ({0},{1},{2})", (int)pos.x, (int)pos.y, (int)pos.z);
string strRegion = string.Format("Region: {0} ({1},{2})", strRegionName, RegionCorner.x, RegionCorner.y);
SecondLife.vector pos = secondLife.llGetPos(); string strPrefix = strObjectName + "\r\n";
string strPosition = string.Format("Local-Position: ({0},{1},{2})", (int)pos.x, (int)pos.y, (int)pos.z); strPrefix += strRegion + "\r\n";
strPrefix += strPosition + "\r\n\r\n";
string strPrefix = strObjectName + "\r\n"; MailMessage msg = new MailMessage();
strPrefix += strRegion + "\r\n"; msg.To = To;
strPrefix += strPosition + "\r\n\r\n"; msg.Subject = Subject;
msg.Body = strPrefix + Body;
msg.From = Properties.Settings.Default.EmailAddress;
msg.Headers.Add("Reply-to", msg.From);
MailMessage msg = new MailMessage(); //MailAttachment myAttachment = new MailAttachment(strAttachmentFile);
msg.To = To; //msg.Attachments.Add(myAttachment);
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); VerboseMessage(client.Send(msg));
//msg.Attachments.Add(myAttachment); }
VerboseMessage(client.Send(msg));
} }
public void VerboseMessage(string Message) public void VerboseMessage(string Message)
{ {
if (OnVerboseMessage != null) if (OnVerboseMessage != null) {
OnVerboseMessage(this, new SecondLifeHostEventArgs(Message)); OnVerboseMessage(this, new SecondLifeHostEventArgs(Message));
}
} }
delegate void ShowDialogDelegate(SecondLifeHost host, delegate void ShowDialogDelegate(SecondLifeHost host,
SecondLife.String objectName, SecondLife.String objectName,
SecondLife.key k, SecondLife.key k,
SecondLife.String name, SecondLife.String name,
SecondLife.String message, SecondLife.String message,
SecondLife.list buttons, SecondLife.list buttons,
SecondLife.integer channel); SecondLife.integer channel);
private void Dialog(SecondLifeHost host, private void Dialog(SecondLifeHost host,
SecondLife.String objectName, SecondLife.String objectName,
SecondLife.key k, SecondLife.key k,
SecondLife.String name, SecondLife.String name,
@ -589,68 +566,62 @@ namespace LSLEditor
public void llDialog(SecondLife.key avatar, SecondLife.String message, SecondLife.list buttons, SecondLife.integer channel) public void llDialog(SecondLife.key avatar, SecondLife.String message, SecondLife.list buttons, SecondLife.integer channel)
{ {
if (message.ToString().Length >= 512) if (message.ToString().Length >= 512) {
{
VerboseMessage("llDialog: message too long, must be less than 512 characters"); VerboseMessage("llDialog: message too long, must be less than 512 characters");
return; return;
} }
if (message.ToString().Length == 0) if (message.ToString().Length == 0) {
{
VerboseMessage("llDialog: must supply a message"); VerboseMessage("llDialog: must supply a message");
return; return;
} }
for (int intI = 0; intI < buttons.Count; intI++) for (int intI = 0; intI < buttons.Count; intI++) {
{ if (buttons[intI].ToString() == "") {
if (buttons[intI].ToString() == "")
{
VerboseMessage("llDialog: all buttons must have label strings"); VerboseMessage("llDialog: all buttons must have label strings");
return; return;
} }
if (buttons[intI].ToString().Length > 24) if (buttons[intI].ToString().Length > 24) {
{
VerboseMessage("llDialog:Button Labels can not have more than 24 characters"); VerboseMessage("llDialog:Button Labels can not have more than 24 characters");
return; return;
} }
} }
if (buttons.Count == 0) if (buttons.Count == 0) {
buttons = new SecondLife.list(new string[] { "OK" }); 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); this.mainForm.Invoke(new ShowDialogDelegate(Dialog), this, (SecondLife.String)GetObjectName(), secondLife.llGetOwner(), (SecondLife.String)Properties.Settings.Default.AvatarName, message, buttons, channel);
} }
delegate void ShowTextBoxDelegate(SecondLifeHost host, delegate void ShowTextBoxDelegate(SecondLifeHost host,
SecondLife.String objectName, SecondLife.String objectName,
SecondLife.key k, SecondLife.key k,
SecondLife.String name, SecondLife.String name,
SecondLife.String message, SecondLife.String message,
SecondLife.integer channel); SecondLife.integer channel);
private void TextBox(SecondLifeHost host, private void TextBox(SecondLifeHost host,
SecondLife.String objectName, SecondLife.String objectName,
SecondLife.key k, SecondLife.key k,
SecondLife.String name, SecondLife.String name,
SecondLife.String message, SecondLife.String message,
SecondLife.integer channel) SecondLife.integer channel)
{ {
llTextBoxForm TextBoxForm = new llTextBoxForm(host, objectName, k, name, message, channel); llTextBoxForm TextBoxForm = new llTextBoxForm(host, objectName, k, name, message, channel);
TextBoxForm.Left = this.mainForm.Left + this.mainForm.Width / 2 - TextBoxForm.Width / 2; TextBoxForm.Left = this.mainForm.Left + this.mainForm.Width / 2 - TextBoxForm.Width / 2;
TextBoxForm.Top = this.mainForm.Top + this.mainForm.Height / 2 - TextBoxForm.Height / 2; TextBoxForm.Top = this.mainForm.Top + this.mainForm.Height / 2 - TextBoxForm.Height / 2;
TextBoxForm.Show(this.mainForm); TextBoxForm.Show(this.mainForm);
this.mainForm.llTextBoxForms.Add(TextBoxForm); this.mainForm.llTextBoxForms.Add(TextBoxForm);
} }
public void llTextBox(SecondLife.key avatar, SecondLife.String message, SecondLife.integer channel) public void llTextBox(SecondLife.key avatar, SecondLife.String message, SecondLife.integer channel)
{ {
if (message.ToString().Length >= 512) if (message.ToString().Length >= 512) {
{ VerboseMessage("llTextBox: message too long, must be less than 512 characters");
VerboseMessage("llTextBox: message too long, must be less than 512 characters"); return;
return; }
} if (message.ToString().Length == 0) {
if (message.ToString().Length == 0) VerboseMessage("llTextBos: must supply a message");
{ return;
VerboseMessage("llTextBos: must supply a message"); }
return; this.mainForm.Invoke(new ShowTextBoxDelegate(TextBox), this, (SecondLife.String)GetObjectName(), secondLife.llGetOwner(), (SecondLife.String)Properties.Settings.Default.AvatarName, message, channel);
} }
this.mainForm.Invoke(new ShowTextBoxDelegate(TextBox), this, (SecondLife.String)GetObjectName(), secondLife.llGetOwner(), (SecondLife.String)Properties.Settings.Default.AvatarName, message, channel);
}
public void SetPermissions(SecondLife.integer intPermissions) public void SetPermissions(SecondLife.integer intPermissions)
{ {
@ -681,12 +652,12 @@ namespace LSLEditor
public void llRequestPermissions(SecondLife.key agent, SecondLife.integer intPermissions) public void llRequestPermissions(SecondLife.key agent, SecondLife.integer intPermissions)
{ {
this.mainForm.Invoke(new RequestPermissionsDelegate(RequestPermissions), this.mainForm.Invoke(new RequestPermissionsDelegate(RequestPermissions),
this, this,
(SecondLife.String)GetObjectName(), (SecondLife.String)GetObjectName(),
secondLife.llGetOwner(), secondLife.llGetOwner(),
(SecondLife.String)Properties.Settings.Default.AvatarName, (SecondLife.String)Properties.Settings.Default.AvatarName,
agent, agent,
intPermissions); intPermissions);
} }
@ -694,26 +665,22 @@ namespace LSLEditor
public void SendControl(Keys keys) public void SendControl(Keys keys)
{ {
if (m_intControls < 0) if (m_intControls >= 0 || this.secondLife != null) {
return; // check againt m_intControls TODO!!!!!
if (this.secondLife == null) int held = 0;
return; int change = 0;
// check againt m_intControls TODO!!!!! 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;
int held = 0; ExecuteSecondLife("control", (SecondLife.key)Properties.Settings.Default.AvatarKey, (SecondLife.integer)held, (SecondLife.integer)change);
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) public void TakeControls(int intControls, int accept, int pass_on)
@ -732,11 +699,9 @@ namespace LSLEditor
StreamReader sr = new StreamReader(strPath); StreamReader sr = new StreamReader(strPath);
int intI = 0; int intI = 0;
string strData = SecondLife.EOF; string strData = SecondLife.EOF;
while (!sr.EndOfStream) while (!sr.EndOfStream) {
{
string strLine = sr.ReadLine(); string strLine = sr.ReadLine();
if (intI == line) if (intI == line) {
{
strData = strLine; strData = strLine;
break; break;
} }
@ -749,10 +714,10 @@ namespace LSLEditor
public SecondLife.key GetNotecardLine(string name, int line) public SecondLife.key GetNotecardLine(string name, int line)
{ {
string strPath = mainForm.SolutionExplorer.GetPath(this.guid, name); string strPath = mainForm.SolutionExplorer.GetPath(this.guid, name);
if(strPath == string.Empty) if (strPath == string.Empty) {
strPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name); strPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name);
if (!File.Exists(strPath)) }
{ if (!File.Exists(strPath)) {
VerboseMessage("Notecard: " + strPath + " not found"); VerboseMessage("Notecard: " + strPath + " not found");
taskQueue.Invoke(secondLife, "llSay", (SecondLife.integer)0, (SecondLife.String)("Couldn't find notecard " + name)); taskQueue.Invoke(secondLife, "llSay", (SecondLife.integer)0, (SecondLife.String)("Couldn't find notecard " + name));
return SecondLife.NULL_KEY; return SecondLife.NULL_KEY;
@ -767,8 +732,7 @@ namespace LSLEditor
{ {
StreamReader sr = new StreamReader(strPath); StreamReader sr = new StreamReader(strPath);
int intI = 0; int intI = 0;
while (!sr.EndOfStream) while (!sr.EndOfStream) {
{
string strLine = sr.ReadLine(); string strLine = sr.ReadLine();
intI++; intI++;
} }
@ -780,11 +744,11 @@ namespace LSLEditor
public SecondLife.key GetNumberOfNotecardLines(string name) public SecondLife.key GetNumberOfNotecardLines(string name)
{ {
string strPath = mainForm.SolutionExplorer.GetPath(this.guid, name); string strPath = mainForm.SolutionExplorer.GetPath(this.guid, name);
if (strPath == string.Empty) if (strPath == string.Empty) {
strPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name); strPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name);
}
if (!File.Exists(strPath)) if (!File.Exists(strPath)) {
{
VerboseMessage("Notecard: " + strPath + " not found"); VerboseMessage("Notecard: " + strPath + " not found");
taskQueue.Invoke(secondLife, "llSay", (SecondLife.integer)0, (SecondLife.String)("Couldn't find notecard " + name)); taskQueue.Invoke(secondLife, "llSay", (SecondLife.integer)0, (SecondLife.String)("Couldn't find notecard " + name));
return SecondLife.NULL_KEY; return SecondLife.NULL_KEY;
@ -800,8 +764,9 @@ namespace LSLEditor
private List<XMLRPC> listXmlRpc; private List<XMLRPC> listXmlRpc;
public void llOpenRemoteDataChannel() public void llOpenRemoteDataChannel()
{ {
if (listXmlRpc == null) if (listXmlRpc == null) {
listXmlRpc = new List<XMLRPC>(); listXmlRpc = new List<XMLRPC>();
}
XMLRPC xmlRpc = new XMLRPC(); XMLRPC xmlRpc = new XMLRPC();
xmlRpc.OnRequest += new XMLRPC.RequestEventHandler(xmlRpc_OnRequest); xmlRpc.OnRequest += new XMLRPC.RequestEventHandler(xmlRpc_OnRequest);
xmlRpc.OpenChannel(listXmlRpc.Count); xmlRpc.OpenChannel(listXmlRpc.Count);
@ -830,27 +795,23 @@ namespace LSLEditor
public void llCloseRemoteDataChannel(SecondLife.key channel) public void llCloseRemoteDataChannel(SecondLife.key channel)
{ {
if (listXmlRpc == null) if (listXmlRpc != null) {
return; foreach (XMLRPC xmlRpc in listXmlRpc) {
foreach (XMLRPC xmlRpc in listXmlRpc) if (xmlRpc.guid == channel.guid) {
{ xmlRpc.CloseChannel();
if (xmlRpc.guid == channel.guid) break;
{ }
xmlRpc.CloseChannel();
break;
} }
} }
} }
public void llRemoteDataReply(SecondLife.key channel, SecondLife.key message_id, string sdata, int idata) public void llRemoteDataReply(SecondLife.key channel, SecondLife.key message_id, string sdata, int idata)
{ {
if (listXmlRpc == null) if (listXmlRpc != null) {
return; foreach (XMLRPC xmlRpc in listXmlRpc) {
foreach (XMLRPC xmlRpc in listXmlRpc) if (xmlRpc.guid == channel.guid) {
{ xmlRpc.RemoteDataReply(channel.guid, message_id.guid, sdata, idata);
if (xmlRpc.guid == channel.guid) break;
{ }
xmlRpc.RemoteDataReply(channel.guid, message_id.guid, sdata, idata);
break;
} }
} }
} }
@ -880,10 +841,7 @@ namespace LSLEditor
public string GetObjectName(Guid guid) public string GetObjectName(Guid guid)
{ {
string strObjectName = mainForm.SolutionExplorer.GetObjectName(guid); string strObjectName = mainForm.SolutionExplorer.GetObjectName(guid);
if (strObjectName != string.Empty) return strObjectName != string.Empty ? strObjectName : this.ObjectName;
return strObjectName;
else
return this.ObjectName;
} }
public string GetObjectName() public string GetObjectName()
@ -893,17 +851,19 @@ namespace LSLEditor
public void SetObjectName(string name) public void SetObjectName(string name)
{ {
if (!mainForm.SolutionExplorer.SetObjectName(this.guid, name)) if (!mainForm.SolutionExplorer.SetObjectName(this.guid, name)) {
ObjectName = name; ObjectName = name;
}
} }
public string GetObjectDescription(Guid guid) public string GetObjectDescription(Guid guid)
{ {
string strObjectDescription = mainForm.SolutionExplorer.GetObjectDescription(guid); string strObjectDescription = mainForm.SolutionExplorer.GetObjectDescription(guid);
if (strObjectDescription != string.Empty) if (strObjectDescription != string.Empty) {
return strObjectDescription; return strObjectDescription;
else } else {
return this.ObjectDescription; return this.ObjectDescription;
}
} }
public string GetObjectDescription() public string GetObjectDescription()
@ -913,43 +873,49 @@ namespace LSLEditor
public void SetObjectDescription(string description) public void SetObjectDescription(string description)
{ {
if (!mainForm.SolutionExplorer.SetObjectDescription(this.guid, description)) if (!mainForm.SolutionExplorer.SetObjectDescription(this.guid, description)) {
this.ObjectDescription = description; this.ObjectDescription = description;
}
} }
public string GetScriptName() public string GetScriptName()
{ {
string strScriptName = mainForm.SolutionExplorer.GetScriptName(this.guid); string strScriptName = mainForm.SolutionExplorer.GetScriptName(this.guid);
if (strScriptName == string.Empty) if (strScriptName == string.Empty) {
strScriptName = this.FullPath; strScriptName = this.FullPath;
if (Properties.Settings.Default.llGetScriptName) }
if (Properties.Settings.Default.llGetScriptName) {
strScriptName = Path.GetFileNameWithoutExtension(strScriptName); strScriptName = Path.GetFileNameWithoutExtension(strScriptName);
else } else {
strScriptName = Path.GetFileName(strScriptName); strScriptName = Path.GetFileName(strScriptName);
}
return strScriptName; return strScriptName;
} }
public SecondLife.key GetKey() public SecondLife.key GetKey()
{ {
string strGuid = mainForm.SolutionExplorer.GetKey(this.guid); string strGuid = mainForm.SolutionExplorer.GetKey(this.guid);
if (strGuid == string.Empty) if (strGuid == string.Empty) {
return new SecondLife.key(this.guid); return new SecondLife.key(this.guid);
}
return new SecondLife.key(strGuid); return new SecondLife.key(strGuid);
} }
public SecondLife.String GetInventoryName(SecondLife.integer type, SecondLife.integer number) public SecondLife.String GetInventoryName(SecondLife.integer type, SecondLife.integer number)
{ {
string strInventoryName = mainForm.SolutionExplorer.GetInventoryName(this.guid, type, number); string strInventoryName = mainForm.SolutionExplorer.GetInventoryName(this.guid, type, number);
if (strInventoryName == string.Empty) if (strInventoryName == string.Empty) {
return "**GetInventoryName only works in SolutionExplorer**"; return "**GetInventoryName only works in SolutionExplorer**";
}
return strInventoryName; return strInventoryName;
} }
public SecondLife.key GetInventoryKey(SecondLife.String name) public SecondLife.key GetInventoryKey(SecondLife.String name)
{ {
string strInventoryKey = mainForm.SolutionExplorer.GetInventoryKey(this.guid, name); string strInventoryKey = mainForm.SolutionExplorer.GetInventoryKey(this.guid, name);
if (strInventoryKey == string.Empty) if (strInventoryKey == string.Empty) {
return new SecondLife.key(Guid.Empty); return new SecondLife.key(Guid.Empty);
}
return new SecondLife.key(strInventoryKey); return new SecondLife.key(strInventoryKey);
} }
@ -963,16 +929,17 @@ namespace LSLEditor
return mainForm.SolutionExplorer.GetInventoryType(this.guid, name); return mainForm.SolutionExplorer.GetInventoryType(this.guid, name);
} }
public void RemoveInventory(SecondLife.String name) public void RemoveInventory(SecondLife.String name)
{ {
mainForm.SolutionExplorer.RemoveInventory(this.guid, name); mainForm.SolutionExplorer.RemoveInventory(this.guid, name);
} }
public System.Media.SoundPlayer GetSoundPlayer(string sound) public System.Media.SoundPlayer GetSoundPlayer(string sound)
{ {
string strPath = mainForm.SolutionExplorer.GetPath(this.guid, sound); string strPath = mainForm.SolutionExplorer.GetPath(this.guid, sound);
if (strPath == string.Empty) if (strPath == string.Empty) {
strPath = sound; strPath = sound;
}
return new System.Media.SoundPlayer(strPath); return new System.Media.SoundPlayer(strPath);
} }

File diff suppressed because it is too large Load diff

View file

@ -80,7 +80,7 @@ namespace LSLEditor
public static explicit operator String(float i) public static explicit operator String(float i)
{ {
return new String(string.Format("{0:0.000000}",i)); return new String(string.Format("{0:0.000000}", i));
} }
public static implicit operator string(String s) public static implicit operator string(String s)
@ -100,19 +100,16 @@ namespace LSLEditor
public static bool operator !=(String x, String y) public static bool operator !=(String x, String y)
{ {
return !(x==y); return !(x == y);
} }
// Public overrides // Public overrides
public override bool Equals(object o) public override bool Equals(object o)
{ {
try try {
{
return (bool)(this.value == o.ToString()); return (bool)(this.value == o.ToString());
} } catch {
catch
{
return false; return false;
} }
} }
@ -124,8 +121,9 @@ namespace LSLEditor
public override string ToString() public override string ToString()
{ {
if (this.value == null) if (this.value == null) {
this.value = ""; this.value = "";
}
return this.value; return this.value;
} }

View file

@ -57,8 +57,7 @@ namespace LSLEditor
{ {
get get
{ {
if (m_value == null) if (m_value == null) m_value = (Int32)0;
m_value = (Int32)0;
return (Int32)m_value; return (Int32)m_value;
} }
set set
@ -137,10 +136,7 @@ namespace LSLEditor
// Logical negation (NOT) operator // Logical negation (NOT) operator
public static integer operator !(integer x) public static integer operator !(integer x)
{ {
if (x.value == 0) return x.value == 0 ? TRUE : FALSE;
return TRUE;
else
return FALSE;
} }
// Bitwise AND operator // Bitwise AND operator
@ -257,22 +253,21 @@ namespace LSLEditor
public static int Compare(integer a, integer b) public static int Compare(integer a, integer b)
{ {
if (a.value < b.value) int intResult = 0;
return -1; if (a.value < b.value) {
if (a.value > b.value) intResult = -1;
return 1; } else if (a.value > b.value) {
return 0; intResult = 1;
}
return intResult;
} }
// Override the Object.Equals(object o) method: // Override the Object.Equals(object o) method:
public override bool Equals(object o) public override bool Equals(object o)
{ {
try try {
{
return (bool)(this == (integer)o); return (bool)(this == (integer)o);
} } catch {
catch
{
return false; return false;
} }
} }

View file

@ -84,25 +84,18 @@ namespace LSLEditor
// This is the one-and-only implicit typecasting in SecondLife // This is the one-and-only implicit typecasting in SecondLife
public static implicit operator key(string strGuid) public static implicit operator key(string strGuid)
{ {
if (strGuid == null) return strGuid == null ? new key("") : new key(strGuid);
return new key("");
else
return new key(strGuid);
} }
public static implicit operator key(String _strGuid) public static implicit operator key(String _strGuid)
{ {
string strGuid = _strGuid; string strGuid = _strGuid;
if (strGuid == null) return strGuid == null ? new key("") : new key(strGuid);
return new key("");
else
return new key(strGuid);
} }
public override string ToString() public override string ToString()
{ {
if (this.guid == null) if (this.guid == null) this.guid = "";
this.guid = "";
return this.guid.ToString(); return this.guid.ToString();
} }
@ -129,34 +122,27 @@ namespace LSLEditor
public static bool operator true(key k) public static bool operator true(key k)
{ {
if ((object)k == null) bool bResult = true;
return false; if ((object)k == null || k.guid == NULL_KEY || k.guid == "") {
if (k.guid == NULL_KEY) bResult = false;
return false; }
if (k.guid == "") return bResult;
return false;
return true;
} }
public static bool operator false(key k) public static bool operator false(key k)
{ {
if ((object)k == null) bool bResult = false;
return true; if ((object)k == null || k.guid == NULL_KEY || k.guid == "") {
if (k.guid == NULL_KEY) bResult = true;
return true; }
if (k.guid == "") return bResult;
return true;
return false;
} }
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
try try {
{
return (this == (key)obj); return (this == (key)obj);
} } catch {
catch
{
return false; return false;
} }
} }

View file

@ -70,94 +70,85 @@ namespace LSLEditor
{ {
get get
{ {
if (this.value == null) if (this.value == null) this.value = new ArrayList();
this.value = new ArrayList();
return this.value.Count; return this.value.Count;
} }
} }
public void AddRange(list c) public void AddRange(list c)
{ {
if(this.value == null) if (this.value == null) this.value = new ArrayList();
this.value = new ArrayList();
this.value.AddRange(c.ToArray()); this.value.AddRange(c.ToArray());
} }
public void Add(object value) public void Add(object value)
{ {
if (this.value == null) if (this.value == null) this.value = new ArrayList();
this.value = new ArrayList();
string strType = value.GetType().ToString(); string strType = value.GetType().ToString();
if (value is string) if (value is string) {
this.value.Add((String)value.ToString()); this.value.Add((String)value.ToString());
else if (value is int) } else if (value is int) {
this.value.Add(new integer((int)value)); this.value.Add(new integer((int)value));
else if (value is uint) } else if (value is uint) {
this.value.Add(new integer((int)(uint)value)); this.value.Add(new integer((int)(uint)value));
else if (value is double) } else if (value is double) {
this.value.Add(new Float((double)value)); this.value.Add(new Float((double)value));
else } else {
this.value.Add(value); this.value.Add(value);
}
} }
public object this[int index] public object this[int index]
{ {
get get
{ {
if (this.value == null) if (this.value == null) this.value = new ArrayList();
this.value = new ArrayList();
return this.value[index]; return this.value[index];
} }
set set
{ {
if (this.value == null) if (this.value == null) this.value = new ArrayList();
this.value = new ArrayList();
this.value[index] = value; this.value[index] = value;
} }
} }
public void Insert(int index, object value) public void Insert(int index, object value)
{ {
if (this.value == null) if (this.value == null) this.value = new ArrayList();
this.value = new ArrayList();
if (this.value == null) if (this.value == null) this.value = new ArrayList();
this.value = new ArrayList();
string strType = value.GetType().ToString(); string strType = value.GetType().ToString();
if (value is string) if (value is string) {
this.value.Insert(index, (String)value.ToString()); this.value.Insert(index, (String)value.ToString());
else if (value is int) } else if (value is int) {
this.value.Insert(index, new integer((int)value)); this.value.Insert(index, new integer((int)value));
else if (value is uint) } else if (value is uint) {
this.value.Insert(index, new integer((int)(uint)value)); this.value.Insert(index, new integer((int)(uint)value));
else if (value is double) } else if (value is double) {
this.value.Insert(index, new Float((double)value)); this.value.Insert(index, new Float((double)value));
else } else {
this.value.Insert(index, value); this.value.Insert(index, value);
}
} }
public object[] ToArray() public object[] ToArray()
{ {
if (this.value == null) if (this.value == null) this.value = new ArrayList();
this.value = new ArrayList();
return this.value.ToArray(); return this.value.ToArray();
} }
public static list operator +(list a, list b) public static list operator +(list a, list b)
{ {
list l = new list(); list l = new list();
if((object)a != null) if ((object)a != null) l.AddRange(a);
l.AddRange(a); if ((object)b != null) l.AddRange(b);
if ((object)b != null)
l.AddRange(b);
return l; return l;
} }
public static list operator +(object b, list a) public static list operator +(object b, list a)
{ {
list l = new list(); list l = new list();
if ((object)a != null) if ((object)a != null) l.AddRange(a);
l.AddRange(a);
l.Insert(0, b); l.Insert(0, b);
return l; return l;
} }
@ -165,8 +156,7 @@ namespace LSLEditor
public static list operator +(list a, object b) public static list operator +(list a, object b)
{ {
list l = new list(); list l = new list();
if ((object)a != null) if ((object)a != null) l.AddRange(a);
l.AddRange(a);
l.Add(b); l.Add(b);
return l; return l;
} }
@ -235,50 +225,50 @@ namespace LSLEditor
public static integer operator ==(list l, list m) public static integer operator ==(list l, list m)
{ {
if (l.Count != m.Count) int iResult = TRUE;
return FALSE; if (l.Count != m.Count) {
for (int intI = 0; intI < l.Count; intI++) iResult = FALSE;
if (!l[intI].Equals(m[intI])) } else {
return FALSE; for (int intI = 0; intI < l.Count; intI++) {
return TRUE; if (!l[intI].Equals(m[intI])) {
iResult = FALSE;
break;
}
}
}
return iResult;
} }
public static integer operator !=(list l, list m) public static integer operator !=(list l, list m)
{ {
int intDifferent=0; int intDifferent = 0;
if (m.Count == 0) // shortcut if (m.Count == 0) {// shortcut
return l.Count; intDifferent = l.Count;
for (int intI = 0; intI < l.Count; intI++) } else {
{ for (int intI = 0; intI < l.Count; intI++) {
bool blnFound = false; bool blnFound = false;
for (int intJ = 0; intJ < m.Count; intJ++) for (int intJ = 0; intJ < m.Count; intJ++) {
{ if (l[intI].Equals(m[intJ])) {
if (l[intI].Equals(m[intJ])) blnFound = true;
{ break;
blnFound = true; }
break;
} }
if (!blnFound) intDifferent++;
} }
if(!blnFound)
intDifferent++;
} }
return intDifferent; return intDifferent;
} }
public static bool operator true(list x) public static bool operator true(list x)
{ {
if ((object)x == null) return (object)x == null ? false : (x.value.Count != 0);
return false;
return (x.value.Count != 0);
} }
// Definitely false operator. Returns true if the operand is // Definitely false operator. Returns true if the operand is
// ==0, false otherwise: // ==0, false otherwise:
public static bool operator false(list x) public static bool operator false(list x)
{ {
if ((object)x == null) return (object)x == null ? true : (x.value.Count == 0);
return true;
return (x.value.Count == 0);
} }
@ -295,19 +285,19 @@ namespace LSLEditor
public string ToVerboseString() public string ToVerboseString()
{ {
if (this.value == null) if (this.value == null) {
this.value = new ArrayList(); this.value = new ArrayList();
}
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.Append('['); sb.Append('[');
for (int intI = 0; intI < this.value.Count; intI++) for (int intI = 0; intI < this.value.Count; intI++) {
{ if (intI > 0) sb.Append(',');
if(intI>0) if ((this.value[intI] is string) && Properties.Settings.Default.QuotesListVerbose) {
sb.Append(','); sb.Append("\"" + this.value[intI].ToString() + "\"");
if((this.value[intI] is string) && Properties.Settings.Default.QuotesListVerbose) } else {
sb.Append("\""+this.value[intI].ToString()+"\"");
else
sb.Append(this.value[intI].ToString()); sb.Append(this.value[intI].ToString());
}
} }
sb.Append(']'); sb.Append(']');
return sb.ToString(); return sb.ToString();
@ -315,33 +305,25 @@ namespace LSLEditor
public override string ToString() public override string ToString()
{ {
if (this.value == null) if (this.value == null) this.value = new ArrayList();
this.value = new ArrayList();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int intI = 0; intI < this.value.Count; intI++) for (int intI = 0; intI < this.value.Count; intI++) {
{ if (this.value[intI] is vector) {
if (this.value[intI] is vector)
{
vector v = (vector)this.value[intI]; 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); 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) {
else if (this.value[intI] is rotation)
{
rotation r = (rotation)this.value[intI]; 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); 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 {
else
sb.Append(this.value[intI].ToString()); sb.Append(this.value[intI].ToString());
}
} }
return sb.ToString(); return sb.ToString();
} }
public static explicit operator String(list l) public static explicit operator String(list l)
{ {
if ((object)l == null) return (object)l == null ? "" : l.ToString();
return "";
else
return l.ToString();
} }
} }

View file

@ -56,8 +56,7 @@ namespace LSLEditor
{ {
get get
{ {
if (m_x == null) if (m_x == null) m_x = (Float)0;
m_x = (Float)0;
return (Float)m_x; return (Float)m_x;
} }
set set
@ -70,8 +69,7 @@ namespace LSLEditor
{ {
get get
{ {
if (m_y == null) if (m_y == null) m_y = (Float)0;
m_y = (Float)0;
return (Float)m_y; return (Float)m_y;
} }
set set
@ -84,8 +82,7 @@ namespace LSLEditor
{ {
get get
{ {
if (m_z == null) if (m_z == null) m_z = (Float)0;
m_z = (Float)0;
return (Float)m_z; return (Float)m_z;
} }
set set
@ -98,8 +95,7 @@ namespace LSLEditor
{ {
get get
{ {
if (m_s == null) if (m_s == null) m_s = (Float)0;
m_s = (Float)0;
return (Float)m_s; return (Float)m_s;
} }
set set
@ -137,8 +133,7 @@ namespace LSLEditor
RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnorePatternWhitespace |
RegexOptions.Compiled); RegexOptions.Compiled);
Match m = regex.Match(a); Match m = regex.Match(a);
if (m.Success) if (m.Success) {
{
this.m_x = new Float(m.Groups["x"].Value); this.m_x = new Float(m.Groups["x"].Value);
this.m_y = new Float(m.Groups["y"].Value); this.m_y = new Float(m.Groups["y"].Value);
this.m_z = new Float(m.Groups["z"].Value); this.m_z = new Float(m.Groups["z"].Value);
@ -158,10 +153,11 @@ namespace LSLEditor
public static explicit operator String(rotation rot) public static explicit operator String(rotation rot)
{ {
if ((object)rot == null) if ((object)rot == null) {
return ZERO_ROTATION.ToString(); return ZERO_ROTATION.ToString();
else } else {
return rot.ToString(); return rot.ToString();
}
} }
// 23 feb 2008 // 23 feb 2008
@ -220,19 +216,19 @@ namespace LSLEditor
public static bool operator ==(rotation r1, rotation r2) public static bool operator ==(rotation r1, rotation r2)
{ {
if ((object)r1 == null) bool bReturn = true;
r1 = ZERO_ROTATION; if ((object)r1 == null) r1 = ZERO_ROTATION;
if ((object)r2 == null) if ((object)r2 == null) r2 = ZERO_ROTATION;
r2 = ZERO_ROTATION; if (Math.Abs(r1.x - r2.x) > EqualityTolerence) {
if (Math.Abs(r1.x - r2.x) > EqualityTolerence) bReturn = false;
return false; } else if (Math.Abs(r1.y - r2.y) > EqualityTolerence) {
if (Math.Abs(r1.y - r2.y) > EqualityTolerence) bReturn = false;
return false; } else if (Math.Abs(r1.z - r2.z) > EqualityTolerence) {
if (Math.Abs(r1.z - r2.z) > EqualityTolerence) bReturn = false;
return false; } else if (Math.Abs(r1.s - r2.s) > EqualityTolerence) {
if (Math.Abs(r1.s - r2.s) > EqualityTolerence) bReturn = false;
return false; }
return true; return bReturn;
} }
public static bool operator !=(rotation r, rotation s) public static bool operator !=(rotation r, rotation s)
@ -242,19 +238,23 @@ namespace LSLEditor
public static bool operator true(rotation r) public static bool operator true(rotation r)
{ {
if ((object)r == null) if ((object)r == null) {
return false; return false;
if (r.x == 0 && r.y == 0 && r.z == 0 && r.s == 1) }
if (r.x == 0 && r.y == 0 && r.z == 0 && r.s == 1) {
return false; return false;
}
return true; return true;
} }
public static bool operator false(rotation r) public static bool operator false(rotation r)
{ {
if ((object)r == null) if ((object)r == null) {
return true; return true;
if (r.x == 0 && r.y == 0 && r.z == 0 && r.s == 1) }
if (r.x == 0 && r.y == 0 && r.z == 0 && r.s == 1) {
return true; return true;
}
return false; return false;
} }
@ -266,12 +266,9 @@ namespace LSLEditor
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
try try {
{
return (this == (rotation)obj); return (this == (rotation)obj);
} } catch {
catch
{
return false; return false;
} }
} }

View file

@ -221,17 +221,17 @@ namespace LSLEditor
public static bool operator ==(vector v1, vector v2) public static bool operator ==(vector v1, vector v2)
{ {
if ((object)v1 == null) if ((object)v1 == null) v1 = ZERO_VECTOR;
v1 = ZERO_VECTOR; if ((object)v2 == null) v2 = ZERO_VECTOR;
if ((object)v2 == null)
v2 = ZERO_VECTOR;
if (Math.Abs(v1.x - v2.x) > EqualityTolerence) bool bResult = true;
return false; if (Math.Abs(v1.x - v2.x) > EqualityTolerence) {
if (Math.Abs(v1.y - v2.y) > EqualityTolerence) bResult = false;
return false; } else if (Math.Abs(v1.y - v2.y) > EqualityTolerence) {
if (Math.Abs(v1.z - v2.z) > EqualityTolerence) bResult = false;
return false; } else if (Math.Abs(v1.z - v2.z) > EqualityTolerence) {
bResult = false;
}
return true; return true;
} }
@ -242,19 +242,17 @@ namespace LSLEditor
public static bool operator true(vector v) public static bool operator true(vector v)
{ {
if ((object)v == null) if ((object)v == null || (v.x == 0 && v.y == 0 && v.z == 0)) {
return false;
if (v.x == 0 && v.y == 0 && v.z == 0)
return false; return false;
}
return true; return true;
} }
public static bool operator false(vector v) public static bool operator false(vector v)
{ {
if ((object)v == null) if ((object)v == null || (v.x == 0 && v.y == 0 && v.z == 0)) {
return true;
if (v.x == 0 && v.y == 0 && v.z == 0)
return true; return true;
}
return false; return false;
} }
@ -265,10 +263,11 @@ namespace LSLEditor
public static explicit operator String(vector v) public static explicit operator String(vector v)
{ {
if ((object)v == null) if ((object)v == null) {
return ZERO_VECTOR.ToString(); return ZERO_VECTOR.ToString();
else } else {
return v.ToString(); return v.ToString();
}
} }
public override int GetHashCode() public override int GetHashCode()
@ -278,12 +277,9 @@ namespace LSLEditor
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
try try {
{
return (this == (vector)obj); return (this == (vector)obj);
} } catch {
catch
{
return false; return false;
} }
} }

View file

@ -148,7 +148,7 @@ namespace LSLEditor
List<Guid> list; List<Guid> list;
int intLinkNum = e.linknum; int intLinkNum = e.iLinkIndex;
switch (intLinkNum) switch (intLinkNum)
{ {
case 1: // LINK_ROOT , root prim in linked set (but not in a single prim, which is 0) case 1: // LINK_ROOT , root prim in linked set (but not in a single prim, which is 0)

View file

@ -1992,28 +1992,28 @@ namespace LSLEditor.Solution
return typeSL; return typeSL;
} }
private delegate void DelegateRemoveInventory(Guid guid, SecondLife.String name); private delegate void DelegateRemoveInventory(Guid guid, SecondLife.String name);
public void RemoveInventory(Guid guid, SecondLife.String name) public void RemoveInventory(Guid guid, SecondLife.String name)
{ {
if (this.treeView1.InvokeRequired) if (this.treeView1.InvokeRequired)
{ {
this.treeView1.Invoke(new DelegateRemoveInventory(RemoveInventory), new object[] { guid, name }); this.treeView1.Invoke(new DelegateRemoveInventory(RemoveInventory), new object[] { guid, name });
return; return;
} }
TreeNode treeNode = FindGuid(this.treeView1.TopNode, guid); TreeNode treeNode = FindGuid(this.treeView1.TopNode, guid);
if (treeNode == null) if (treeNode == null)
return; return;
TreeNode parent = treeNode.Parent; TreeNode parent = treeNode.Parent;
for (int i = 0; i < parent.Nodes.Count; ++i) for (int i = 0; i < parent.Nodes.Count; ++i)
{ {
if (parent.Nodes[i].Text == name) if (parent.Nodes[i].Text == name)
{ {
parent.Nodes.RemoveAt(i); parent.Nodes.RemoveAt(i);
return; return;
} }
} }
} }
private delegate string DelegateGetInventoryName(Guid guid, int type, int number); private delegate string DelegateGetInventoryName(Guid guid, int type, int number);
public string GetInventoryName(Guid guid, int type, int number) public string GetInventoryName(Guid guid, int type, int number)
{ {
@ -2441,7 +2441,7 @@ namespace LSLEditor.Solution
break; break;
} }
} }
} }
public class NodeSorter : System.Collections.IComparer public class NodeSorter : System.Collections.IComparer
{ {
public int Compare(object x, object y) public int Compare(object x, object y)

View file

@ -202,11 +202,11 @@ namespace LSLEditor
if (strLine == null) if (strLine == null)
break; break;
int intSplit = strLine.IndexOf("="); int intSplit = strLine.IndexOf("=");
if (intSplit < 0) if (intSplit < 0)
continue; continue;
string strName = strLine.Substring(0, intSplit); string strName = strLine.Substring(0, intSplit);
string strValue = strLine.Substring(intSplit + 1); string strValue = strLine.Substring(intSplit + 1);
//All hashes are of the uncompressed file. However, different archives may contain different versions. //All hashes are of the uncompressed file. However, different archives may contain different versions.
@ -224,7 +224,7 @@ namespace LSLEditor
case "BZipUrl": case "BZipUrl":
bzip.uri = strValue; bzip.uri = strValue;
break; break;
case "GZipVersion": case "GZipVersion":
gzip = new versionInfo(strValue); gzip = new versionInfo(strValue);
break; break;
case "GZipHash": case "GZipHash":
@ -242,7 +242,7 @@ namespace LSLEditor
case "ZipUrl": case "ZipUrl":
wzip.uri = strValue; wzip.uri = strValue;
break; break;
case "HelpHash": case "HelpHash":
strHelpHashWeb = strValue; strHelpHashWeb = strValue;
break; break;
case "HelpUrl2": case "HelpUrl2":