Fixing indentation and braces in trunk/

This commit is contained in:
Ima Mechanique 2013-07-14 16:49:03 +01:00
parent 6437594240
commit af230cbed7
13 changed files with 962 additions and 1180 deletions

View file

@ -74,7 +74,7 @@ namespace LSLEditor
private void About_Load(object sender, EventArgs e) private void About_Load(object sender, EventArgs e)
{ {
string strExeFileName = Path.GetFileName(Assembly.GetExecutingAssembly().CodeBase); string strExeFileName = Path.GetFileName(Assembly.GetExecutingAssembly().CodeBase);
this.webBrowser1.Navigate("res://" + strExeFileName + "/"+ Properties.Settings.Default.About); this.webBrowser1.Navigate("res://" + strExeFileName + "/" + Properties.Settings.Default.About);
} }
} }
} }

View file

@ -69,46 +69,37 @@ namespace LSLEditor
{ {
WebBrowser axWebBrowser1 = sender as WebBrowser; WebBrowser axWebBrowser1 = sender as WebBrowser;
ToolStripStatusLabel status = axWebBrowser1.Tag as ToolStripStatusLabel; ToolStripStatusLabel status = axWebBrowser1.Tag as ToolStripStatusLabel;
if (status == null) if (status != null) {
return; status.Text = axWebBrowser1.StatusText;
status.Text = axWebBrowser1.StatusText; }
} }
private void axWebBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e) private void axWebBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{ {
string strUrl = e.Url.ToString(); string strUrl = e.Url.ToString();
if (strUrl.EndsWith(".lsl")) if (strUrl.EndsWith(".lsl")) {
{
e.Cancel = true; e.Cancel = true;
if (MessageBox.Show("Import LSL script?", "Import script", MessageBoxButtons.OKCancel) == DialogResult.Cancel) if (MessageBox.Show("Import LSL script?", "Import script", MessageBoxButtons.OKCancel) != DialogResult.Cancel) {
return; WebBrowser axWebBrowser1 = sender as WebBrowser;
axWebBrowser1.Stop();
WebBrowser axWebBrowser1 = sender as WebBrowser; this.lslEditorForm.OpenFile(strUrl, Guid.NewGuid());
axWebBrowser1.Stop(); }
this.lslEditorForm.OpenFile(strUrl,Guid.NewGuid());
} }
} }
public void ShowWebBrowser(string strTabName, string strUrl) public void ShowWebBrowser(string strTabName, string strUrl)
{ {
WebBrowser axWebBrowser1 = null; WebBrowser axWebBrowser1 = null;
try try {
{ if (!Properties.Settings.Default.HelpNewTab) {
if (!Properties.Settings.Default.HelpNewTab)
{
TabPage tabPage = this.tabControl1.TabPages[0]; TabPage tabPage = this.tabControl1.TabPages[0];
tabPage.Text = strTabName + " "; tabPage.Text = strTabName + " ";
axWebBrowser1 = tabPage.Controls[0] as WebBrowser; axWebBrowser1 = tabPage.Controls[0] as WebBrowser;
} }
} } catch { }
catch
{
}
if (axWebBrowser1 == null) if (axWebBrowser1 == null) {
{
TabPage tabPage = new TabPage(strTabName + " "); TabPage tabPage = new TabPage(strTabName + " ");
tabPage.BackColor = Color.White; tabPage.BackColor = Color.White;
@ -117,7 +108,7 @@ namespace LSLEditor
ToolStripStatusLabel toolStripStatusLabel1 = new ToolStripStatusLabel(); ToolStripStatusLabel toolStripStatusLabel1 = new ToolStripStatusLabel();
StatusStrip statusStrip1 = new StatusStrip(); StatusStrip statusStrip1 = new StatusStrip();
statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripStatusLabel1}); statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripStatusLabel1 });
statusStrip1.Location = new System.Drawing.Point(0, 318); statusStrip1.Location = new System.Drawing.Point(0, 318);
statusStrip1.Name = "statusStrip1"; statusStrip1.Name = "statusStrip1";
statusStrip1.Size = new System.Drawing.Size(584, 22); statusStrip1.Size = new System.Drawing.Size(584, 22);
@ -148,29 +139,26 @@ namespace LSLEditor
private void closeToolStripMenuItem_Click(object sender, EventArgs e) private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{ {
int intTabToClose = (int)this.contextMenuStrip1.Tag; int intTabToClose = (int)this.contextMenuStrip1.Tag;
if (intTabToClose >= this.tabControl1.TabCount) if (intTabToClose < this.tabControl1.TabCount) {
return; this.tabControl1.TabPages.RemoveAt(intTabToClose);
this.tabControl1.TabPages.RemoveAt(intTabToClose); }
} }
private void tabControl1_MouseDown(object sender, MouseEventArgs e) private void tabControl1_MouseDown(object sender, MouseEventArgs e)
{ {
TabControl tabControl = sender as TabControl; TabControl tabControl = sender as TabControl;
if (tabControl == null) if (tabControl != null) {
return; if (e.Button == MouseButtons.Right) {
if (e.Button == MouseButtons.Right) for (int intI = 0; intI < tabControl.TabCount; intI++) {
{ Rectangle rt = tabControl.GetTabRect(intI);
for (int intI = 0; intI < tabControl.TabCount; intI++) if (e.X > rt.Left && e.X < rt.Right
{ && e.Y > rt.Top && e.Y < rt.Bottom) {
Rectangle rt = tabControl.GetTabRect(intI); this.contextMenuStrip1.Tag = intI;
if (e.X > rt.Left && e.X < rt.Right this.contextMenuStrip1.Show(this.tabControl1, new Point(e.X, e.Y));
&& e.Y > rt.Top && e.Y < rt.Bottom) }
{
this.contextMenuStrip1.Tag = intI;
this.contextMenuStrip1.Show(this.tabControl1, new Point(e.X, e.Y));
} }
} }
} }
} }
} }
} }

View file

@ -65,18 +65,14 @@ namespace LSLEditor
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)
{ {
if (m.Msg == WM_NCACTIVATE) if (m.Msg == WM_NCACTIVATE) {
{ if (m.LParam != IntPtr.Zero) {
if (m.LParam != IntPtr.Zero)
{
m.WParam = new IntPtr(1); m.WParam = new IntPtr(1);
} } else {
else
{
this.numberedTextBoxUC1.TextBox.MakeAllInvis(); this.numberedTextBoxUC1.TextBox.MakeAllInvis();
} }
} }
try { base.WndProc(ref m); } catch {} try { base.WndProc(ref m); } catch { }
} }
public SyntaxRichTextBox TextBox public SyntaxRichTextBox TextBox
@ -123,10 +119,11 @@ namespace LSLEditor
} }
set set
{ {
if(value) if (value) {
this.tabPage1.Text = "Script"; this.tabPage1.Text = "Script";
else } else {
this.tabPage1.Text = "Text"; this.tabPage1.Text = "Text";
}
this.TextBox.ToolTipping = value; this.TextBox.ToolTipping = value;
} }
} }
@ -160,12 +157,9 @@ namespace LSLEditor
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();
@ -178,8 +172,9 @@ namespace LSLEditor
void EditForm_Layout(object sender, LayoutEventArgs e) void EditForm_Layout(object sender, LayoutEventArgs e)
{ {
if (this.WindowState == FormWindowState.Minimized) if (this.WindowState == FormWindowState.Minimized) {
this.numberedTextBoxUC1.TextBox.MakeAllInvis(); this.numberedTextBoxUC1.TextBox.MakeAllInvis();
}
} }
void EditForm_Position(object sender, EventArgs e) void EditForm_Position(object sender, EventArgs e)
@ -190,13 +185,15 @@ namespace LSLEditor
void TextBox_OnDirtyChanged(object sender, EventArgs e) void TextBox_OnDirtyChanged(object sender, EventArgs e)
{ {
this.Text = this.ScriptName; this.Text = this.ScriptName;
if (this.numberedTextBoxUC1.TextBox.Dirty) if (this.numberedTextBoxUC1.TextBox.Dirty) {
this.Text = this.Text.Trim()+"* "; this.Text = this.Text.Trim() + "* ";
else } else {
this.Text = this.Text.Trim()+" "; this.Text = this.Text.Trim() + " ";
}
TabPage tabPage = this.Tag as TabPage; TabPage tabPage = this.Tag as TabPage;
if (tabPage != null) if (tabPage != null) {
tabPage.Text = this.Text; tabPage.Text = this.Text;
}
this.parent.OnDirtyChanged(this.numberedTextBoxUC1.TextBox.Dirty); this.parent.OnDirtyChanged(this.numberedTextBoxUC1.TextBox.Dirty);
} }
@ -216,20 +213,19 @@ namespace LSLEditor
{ {
this.m_FullPathName = value; this.m_FullPathName = value;
string strDirectory = Path.GetDirectoryName(this.m_FullPathName); string strDirectory = Path.GetDirectoryName(this.m_FullPathName);
if (Directory.Exists(strDirectory)) if (Directory.Exists(strDirectory)) {
{
Properties.Settings.Default.WorkingDirectory = strDirectory; Properties.Settings.Default.WorkingDirectory = strDirectory;
} } else {
else if (!Directory.Exists(Properties.Settings.Default.WorkingDirectory)) {
{
if(!Directory.Exists(Properties.Settings.Default.WorkingDirectory))
Properties.Settings.Default.WorkingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); Properties.Settings.Default.WorkingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
}
this.m_FullPathName = Path.Combine(Properties.Settings.Default.WorkingDirectory, this.m_FullPathName); this.m_FullPathName = Path.Combine(Properties.Settings.Default.WorkingDirectory, this.m_FullPathName);
} }
this.Text = this.ScriptName; this.Text = this.ScriptName;
TabPage tabPage = this.Tag as TabPage; TabPage tabPage = this.Tag as TabPage;
if (tabPage != null) if (tabPage != null) {
tabPage.Text = this.Text + " "; tabPage.Text = this.Text + " ";
}
} }
} }
@ -263,53 +259,50 @@ namespace LSLEditor
private int PercentageIndentTab() private int PercentageIndentTab()
{ {
int intResult;
int intSpaces = 0; int intSpaces = 0;
int intTabs = 0; int intTabs = 0;
StringReader sr = new StringReader(this.TextBox.Text); StringReader sr = new StringReader(this.TextBox.Text);
while (true) while (true) {
{
string strLine = sr.ReadLine(); string strLine = sr.ReadLine();
if (strLine == null) if (strLine == null) break;
break; if (strLine.Length == 0) continue;
if (strLine.Length == 0) if (strLine[0] == ' ') {
continue;
if (strLine[0] == ' ')
intSpaces++; intSpaces++;
else if (strLine[0] == '\t') } else if (strLine[0] == '\t') {
intTabs++; intTabs++;
}
} }
if (intTabs == 0 && intSpaces==0) if (intTabs == 0 && intSpaces == 0) {
return 50; intResult = 50;
return (int)Math.Round((100.0 * intTabs) / (intTabs + intSpaces)); } else {
intResult = (int)Math.Round((100.0 * intTabs) / (intTabs + intSpaces));
}
return intResult;
} }
public void LoadFile(string strPath) public void LoadFile(string strPath)
{ {
if(strPath.StartsWith("http://")) if (strPath.StartsWith("http://")) {
this.FullPathName = Path.GetFileName(strPath); this.FullPathName = Path.GetFileName(strPath);
else } else {
this.FullPathName = strPath; this.FullPathName = strPath;
}
this.encodedAs = this.numberedTextBoxUC1.TextBox.LoadFile(strPath); this.encodedAs = this.numberedTextBoxUC1.TextBox.LoadFile(strPath);
if (!this.IsScript) if (this.IsScript) {
return;
if (Properties.Settings.Default.IndentAutoCorrect) if (Properties.Settings.Default.IndentAutoCorrect) {
{ this.TextBox.FormatDocument();
this.TextBox.FormatDocument(); this.TextBox.ClearUndoStack();
this.TextBox.ClearUndoStack(); } else {
} if (Properties.Settings.Default.IndentWarning) {
else if ((PercentageIndentTab() > 50 && Properties.Settings.Default.SL4SpacesIndent) ||
{ (PercentageIndentTab() < 50 && !Properties.Settings.Default.SL4SpacesIndent)) {
if (Properties.Settings.Default.IndentWarning) if (MessageBox.Show("Indent scheme differs from settings\nDo you want to correct it?\nIt can also be corrected by pressing Ctrl-D or turn on Autocorrection (tools menu)", "Indent Warning!!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) {
{ this.TextBox.FormatDocument();
if ((PercentageIndentTab() > 50 && Properties.Settings.Default.SL4SpacesIndent) || //this.TextBox.ClearUndoStack();
(PercentageIndentTab() < 50 && !Properties.Settings.Default.SL4SpacesIndent)) }
{
if (MessageBox.Show("Indent scheme differs from settings\nDo you want to correct it?\nIt can also be corrected by pressing Ctrl-D or turn on Autocorrection (tools menu)", "Indent Warning!!", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
this.TextBox.FormatDocument();
//this.TextBox.ClearUndoStack();
} }
} }
} }
@ -320,10 +313,8 @@ namespace LSLEditor
{ {
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;
@ -337,9 +328,7 @@ namespace LSLEditor
encodeAs = Encoding.Default; encodeAs = Encoding.Default;
break; break;
} }
} } else if (encodeAs == null) {
else if (encodeAs == null)
{
encodeAs = Encoding.UTF8; encodeAs = Encoding.UTF8;
} }
@ -381,16 +370,15 @@ namespace LSLEditor
{ {
this.numberedTextBoxUC1.TextBox.MakeAllInvis(); this.numberedTextBoxUC1.TextBox.MakeAllInvis();
if (runtime != null) if (runtime != null) {
{
this.components.Remove(runtime); this.components.Remove(runtime);
if (!runtime.IsDisposed) if (!runtime.IsDisposed) {
runtime.Dispose(); runtime.Dispose();
}
runtime = null; runtime = null;
} }
for (int intI = this.tabControl1.TabPages.Count - 1; intI > 0; intI--) for (int intI = this.tabControl1.TabPages.Count - 1; intI > 0; intI--) {
{
this.tabControl1.TabPages.RemoveAt(intI); this.tabControl1.TabPages.RemoveAt(intI);
} }
} }
@ -400,65 +388,62 @@ namespace LSLEditor
public bool StartCompiler() public bool StartCompiler()
{ {
bool blnResult = false;
//if (this.disableCompilesyntaxCheckToolStripMenuItem.Checked) //if (this.disableCompilesyntaxCheckToolStripMenuItem.Checked)
// return false; // return false;
if (!this.IsScript) if (this.IsScript) {
return false; StopCompiler();
StopCompiler(); if (this.parent != null) {
runtime = new RuntimeConsole(this.parent);
if (this.parent == null) // for disposing
return false; this.components.Add(runtime);
runtime = new RuntimeConsole(this.parent); if (!runtime.Compile(this)) {
this.tabControl1.SelectedIndex = 0;
return false;
}
// for disposing TabPage tabPage = new TabPage("Debug");
this.components.Add(runtime); tabPage.Controls.Add(runtime);
this.tabControl1.TabPages.Add(tabPage);
if (!runtime.Compile(this)) this.tabControl1.SelectedIndex = 1;
{ blnResult = true;
this.tabControl1.SelectedIndex = 0; }
return false;
} }
return blnResult;
TabPage tabPage = new TabPage("Debug");
tabPage.Controls.Add(runtime);
this.tabControl1.TabPages.Add(tabPage);
this.tabControl1.SelectedIndex = 1;
return true;
} }
public bool SyntaxCheck() public bool SyntaxCheck()
{ {
bool blnResult = false;
//if (this.disableCompilesyntaxCheckToolStripMenuItem.Checked) //if (this.disableCompilesyntaxCheckToolStripMenuItem.Checked)
// return false; // return false;
if (!this.IsScript) if (this.IsScript) {
return false; LSL2CSharp translator = new LSL2CSharp(ConfLSL);
string strCSharp = translator.Parse(SourceCode);
LSL2CSharp translator = new LSL2CSharp(ConfLSL); if (System.Diagnostics.Debugger.IsAttached) {
string strCSharp = translator.Parse(SourceCode); for (int intI = this.tabControl1.TabPages.Count - 1; intI > 0; intI--) {
this.tabControl1.TabPages.RemoveAt(intI);
}
if (System.Diagnostics.Debugger.IsAttached) // TODO
{ TabPage tabPage = new TabPage("C#");
for (int intI = this.tabControl1.TabPages.Count - 1; intI > 0; intI--) NumberedTextBox.NumberedTextBoxUC numberedTextBoxUC1 = new NumberedTextBox.NumberedTextBoxUC();
{ numberedTextBoxUC1.TextBox.Init(null, this.ConfCSharp);
this.tabControl1.TabPages.RemoveAt(intI); numberedTextBoxUC1.TextBox.Text = strCSharp;
numberedTextBoxUC1.TextBox.ReadOnly = true;
numberedTextBoxUC1.Dock = DockStyle.Fill;
tabPage.Controls.Add(numberedTextBoxUC1);
this.tabControl.TabPages.Add(tabPage);
} }
blnResult = (null != CompilerHelper.CompileCSharp(this, strCSharp));
// TODO
TabPage tabPage = new TabPage("C#");
NumberedTextBox.NumberedTextBoxUC numberedTextBoxUC1 = new NumberedTextBox.NumberedTextBoxUC();
numberedTextBoxUC1.TextBox.Init(null, this.ConfCSharp);
numberedTextBoxUC1.TextBox.Text = strCSharp;
numberedTextBoxUC1.TextBox.ReadOnly = true;
numberedTextBoxUC1.Dock = DockStyle.Fill;
tabPage.Controls.Add(numberedTextBoxUC1);
this.tabControl.TabPages.Add(tabPage);
} }
return blnResult;
return (null != CompilerHelper.CompileCSharp(this, strCSharp));
} }
public int Find(string strSearch, int intStart, int intEnd, RichTextBoxFinds options) public int Find(string strSearch, int intStart, int intEnd, RichTextBoxFinds options)
@ -476,13 +461,13 @@ namespace LSLEditor
private void EditForm_FormClosing(object sender, FormClosingEventArgs e) private void EditForm_FormClosing(object sender, FormClosingEventArgs e)
{ {
this.parent.CancelClosing = false; this.parent.CancelClosing = false;
if (this.Dirty) if (this.Dirty) {
{
DialogResult dialogResult = MessageBox.Show(this, @"Save """ + this.ScriptName + @"""?", "File has changed", MessageBoxButtons.YesNoCancel); DialogResult dialogResult = MessageBox.Show(this, @"Save """ + this.ScriptName + @"""?", "File has changed", MessageBoxButtons.YesNoCancel);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes) {
e.Cancel = !this.parent.SaveFile(this,false); e.Cancel = !this.parent.SaveFile(this, false);
else } else {
e.Cancel = (dialogResult == DialogResult.Cancel); e.Cancel = (dialogResult == DialogResult.Cancel);
}
} }
this.parent.CancelClosing = e.Cancel; this.parent.CancelClosing = e.Cancel;
} }
@ -497,11 +482,9 @@ namespace LSLEditor
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);
@ -509,7 +492,7 @@ namespace LSLEditor
//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);
} }
} }
@ -518,7 +501,7 @@ namespace LSLEditor
private void tvOutline_AfterSelect(object sender, TreeViewEventArgs e) private void tvOutline_AfterSelect(object sender, TreeViewEventArgs e)
{ {
//this.TextBox.Select //this.TextBox.Select
} }
@ -532,4 +515,4 @@ namespace LSLEditor
this.tvOutline.ExpandAll(); this.tvOutline.ExpandAll();
} }
} }
} }

View file

@ -89,14 +89,12 @@ namespace LSLEditor
set set
{ {
this.label1.Text = ""; // clear out message this.label1.Text = ""; // clear out message
if (value != "") if (value != "") {
{
this.comboBoxFind.Text = value; this.comboBoxFind.Text = value;
} } else {
else if (this.comboBoxFind.Items.Count > 0) {
{
if (this.comboBoxFind.Items.Count > 0)
this.comboBoxFind.SelectedIndex = this.comboBoxFind.Items.Count - 1; this.comboBoxFind.SelectedIndex = this.comboBoxFind.Items.Count - 1;
}
} }
} }
} }
@ -106,17 +104,16 @@ namespace LSLEditor
string strText = comboBox.Text; string strText = comboBox.Text;
bool Found = false; bool Found = false;
foreach (string strC in comboBox.Items) foreach (string strC in comboBox.Items) {
{ if (strC == strText) {
if (strC == strText)
{
Found = true; Found = true;
break; break;
} }
} }
if (!Found) if (!Found) {
comboBox.Items.Add(strText); comboBox.Items.Add(strText);
}
return Found; return Found;
} }
@ -124,40 +121,35 @@ namespace LSLEditor
{ {
this.label1.Text = ""; this.label1.Text = "";
EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm; EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm;
if (editForm == null) if (editForm != null) {
return; if (!UpdateComboBox(this.comboBoxFind)) {
editForm.TextBox.SelectionLength = 0;
editForm.TextBox.SelectionStart = 0;
}
if (!UpdateComboBox(this.comboBoxFind)) RichTextBoxFinds options = RichTextBoxFinds.None;
{
editForm.TextBox.SelectionLength = 0;
editForm.TextBox.SelectionStart = 0;
}
RichTextBoxFinds options = RichTextBoxFinds.None; if (this.checkBoxMatchCase.Checked) options |= RichTextBoxFinds.MatchCase;
if (this.checkBoxReverse.Checked) options |= RichTextBoxFinds.Reverse;
if (this.checkBoxWholeWord.Checked) options |= RichTextBoxFinds.WholeWord;
if (this.checkBoxMatchCase.Checked) options |= RichTextBoxFinds.MatchCase; if (this.checkBoxReverse.Checked) {
if (this.checkBoxReverse.Checked) options |= RichTextBoxFinds.Reverse; intStart = 0; // start cant change ;-)
if (this.checkBoxWholeWord.Checked) options |= RichTextBoxFinds.WholeWord; intEnd = editForm.TextBox.SelectionStart;
} else {
intStart = editForm.TextBox.SelectionStart + editForm.TextBox.SelectionLength;
if (intStart == editForm.TextBox.Text.Length) {
intStart = 0;
}
intEnd = editForm.TextBox.Text.Length - 1; // length can change!!
}
if (this.checkBoxReverse.Checked) string strFind = this.comboBoxFind.Text;
{ int intIndex = editForm.Find(strFind, intStart, intEnd, options);
intStart = 0; // start cant change ;-) if (intIndex < 0) {
intEnd = editForm.TextBox.SelectionStart; this.label1.Text = "Not found...";
} return;
else }
{
intStart = editForm.TextBox.SelectionStart + editForm.TextBox.SelectionLength;
if (intStart == editForm.TextBox.Text.Length)
intStart = 0;
intEnd = editForm.TextBox.Text.Length - 1; // length can change!!
}
string strFind = this.comboBoxFind.Text;
int intIndex = editForm.Find(strFind, intStart, intEnd, options);
if (intIndex < 0)
{
this.label1.Text = "Not found...";
return;
} }
} }
@ -169,15 +161,11 @@ namespace LSLEditor
private void comboBoxFind_KeyDown(object sender, KeyEventArgs e) private void comboBoxFind_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.KeyCode == Keys.Return) if (e.KeyCode == Keys.Return) {
{ if (this.Replace.Enabled) {
if (this.Replace.Enabled)
{
this.comboBoxReplace.Focus(); this.comboBoxReplace.Focus();
e.SuppressKeyPress = true; e.SuppressKeyPress = true;
} } else {
else
{
Find(); Find();
e.SuppressKeyPress = true; e.SuppressKeyPress = true;
} }
@ -187,30 +175,26 @@ namespace LSLEditor
private void Replace_Click(object sender, EventArgs e) private void Replace_Click(object sender, EventArgs e)
{ {
EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm; EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm;
if (editForm == null) if (editForm != null) {
return; UpdateComboBox(this.comboBoxReplace);
UpdateComboBox(this.comboBoxReplace); if (editForm.TextBox.SelectionLength > 0) {
string strReplacement = this.comboBoxReplace.Text;
editForm.TextBox.ReplaceSelectedText(strReplacement);
}
if (editForm.TextBox.SelectionLength > 0) Find();
{ this.Focus();
string strReplacement = this.comboBoxReplace.Text;
editForm.TextBox.ReplaceSelectedText(strReplacement);
} }
Find();
this.Focus();
} }
// WildCardToRegex not used!! // WildCardToRegex not used!!
private string WildCardToRegex(string strWildCard) private string WildCardToRegex(string strWildCard)
{ {
StringBuilder sb = new StringBuilder(strWildCard.Length + 8); StringBuilder sb = new StringBuilder(strWildCard.Length + 8);
for (int intI = 0; intI < strWildCard.Length; intI++) for (int intI = 0; intI < strWildCard.Length; intI++) {
{
char chrC = strWildCard[intI]; char chrC = strWildCard[intI];
switch (chrC) switch (chrC) {
{
case '*': case '*':
sb.Append(".*"); sb.Append(".*");
break; break;
@ -233,42 +217,41 @@ namespace LSLEditor
private void ReplaceAll_Click(object sender, EventArgs e) private void ReplaceAll_Click(object sender, EventArgs e)
{ {
EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm; EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm;
if (editForm == null) if (editForm == null) {
return; UpdateComboBox(this.comboBoxReplace);
UpdateComboBox(this.comboBoxReplace); string strPattern;
string strFind = Regex.Escape(this.comboBoxFind.Text);
string strReplacement = this.comboBoxReplace.Text;
string strSourceCode = editForm.SourceCode;
string strPattern; RegexOptions regexOptions = RegexOptions.Compiled;
string strFind = Regex.Escape(this.comboBoxFind.Text); if (!this.checkBoxMatchCase.Checked) {
string strReplacement = this.comboBoxReplace.Text; regexOptions |= RegexOptions.IgnoreCase;
string strSourceCode = editForm.SourceCode; }
if (this.checkBoxWholeWord.Checked) {
strPattern = @"\b" + strFind + @"\b";
} else {
strPattern = strFind;
}
RegexOptions regexOptions = RegexOptions.Compiled; Regex regex = new Regex(strPattern, regexOptions);
if (!this.checkBoxMatchCase.Checked)
regexOptions |= RegexOptions.IgnoreCase;
if (this.checkBoxWholeWord.Checked)
strPattern = @"\b" + strFind + @"\b";
else
strPattern = strFind;
Regex regex = new Regex(strPattern, regexOptions); int intCount = 0;
foreach (Match m in regex.Matches(strSourceCode)) {
int intCount = 0; if (m.Value.Length > 0) {
foreach(Match m in regex.Matches(strSourceCode)) intCount++;
{ }
if (m.Value.Length > 0) }
intCount++; if (intCount == 0) {
MessageBox.Show("No matches found");
} else {
if (MessageBox.Show("There are " + intCount + " occurences, replace them all?", "Find and Replace", MessageBoxButtons.YesNoCancel) == DialogResult.Yes) {
editForm.SourceCode = regex.Replace(strSourceCode, strReplacement);
}
}
this.Focus();
} }
if (intCount == 0)
{
MessageBox.Show("No matches found");
}
else
{
if (MessageBox.Show("There are " + intCount + " occurences, replace them all?", "Find and Replace", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
editForm.SourceCode = regex.Replace(strSourceCode, strReplacement);
}
this.Focus();
} }
private void FindWindow_FormClosing(object sender, FormClosingEventArgs e) private void FindWindow_FormClosing(object sender, FormClosingEventArgs e)
@ -281,22 +264,19 @@ namespace LSLEditor
private void FindWindow_KeyDown(object sender, KeyEventArgs e) private void FindWindow_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.KeyData == Keys.Escape) if (e.KeyData == Keys.Escape) {
{
this.Visible = false; this.Visible = false;
e.SuppressKeyPress = true; e.SuppressKeyPress = true;
e.Handled = true; e.Handled = true;
} }
if (e.KeyCode == Keys.Return) if (e.KeyCode == Keys.Return) {
{
Find(); Find();
e.SuppressKeyPress = true; e.SuppressKeyPress = true;
this.Focus(); this.Focus();
} }
if (e.KeyCode == Keys.F3) if (e.KeyCode == Keys.F3) {
{
Find(); Find();
e.SuppressKeyPress = true; e.SuppressKeyPress = true;
this.Focus(); this.Focus();
@ -309,7 +289,5 @@ namespace LSLEditor
{ {
this.comboBoxFind.Focus(); this.comboBoxFind.Focus();
} }
} }
} }

View file

@ -56,7 +56,7 @@ namespace LSLEditor
this.lslEditForm = lslEditForm; this.lslEditForm = lslEditForm;
EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm; EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm;
this.label1.Text = "Line number (1-"+editForm.TextBox.Lines.Length+")"; this.label1.Text = "Line number (1-" + editForm.TextBox.Lines.Length + ")";
} }
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
@ -67,16 +67,12 @@ namespace LSLEditor
private void Goto() private void Goto()
{ {
EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm; EditForm editForm = this.lslEditForm.ActiveMdiForm as EditForm;
if (editForm == null) if (editForm != null) {
return; try {
try int intLine = Convert.ToInt32(this.textBox1.Text);
{ editForm.TextBox.Goto(intLine);
int intLine = Convert.ToInt32(this.textBox1.Text); this.Close();
editForm.TextBox.Goto(intLine); } catch { }
this.Close();
}
catch
{
} }
} }
@ -87,12 +83,11 @@ namespace LSLEditor
private void textBox1_KeyDown(object sender, KeyEventArgs e) private void textBox1_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.KeyCode == Keys.Return) if (e.KeyCode == Keys.Return) {
{
Goto(); Goto();
e.SuppressKeyPress = true; e.SuppressKeyPress = true;
} }
} }
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -72,28 +72,35 @@ namespace LSLEditor
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if ((intPermissions & SecondLife.PERMISSION_DEBIT) == SecondLife.PERMISSION_DEBIT) if ((intPermissions & SecondLife.PERMISSION_DEBIT) == SecondLife.PERMISSION_DEBIT) {
sb.AppendLine("Take Linden dollars (L$) from you"); sb.AppendLine("Take Linden dollars (L$) from you");
}
if ((intPermissions & SecondLife.PERMISSION_TAKE_CONTROLS) == SecondLife.PERMISSION_TAKE_CONTROLS) if ((intPermissions & SecondLife.PERMISSION_TAKE_CONTROLS) == SecondLife.PERMISSION_TAKE_CONTROLS) {
sb.AppendLine("Act on your control inputs"); sb.AppendLine("Act on your control inputs");
}
if ((intPermissions & SecondLife.PERMISSION_TRIGGER_ANIMATION) == SecondLife.PERMISSION_TRIGGER_ANIMATION) if ((intPermissions & SecondLife.PERMISSION_TRIGGER_ANIMATION) == SecondLife.PERMISSION_TRIGGER_ANIMATION) {
sb.AppendLine("Animate your avatar"); sb.AppendLine("Animate your avatar");
}
if ((intPermissions & SecondLife.PERMISSION_ATTACH) == SecondLife.PERMISSION_ATTACH) if ((intPermissions & SecondLife.PERMISSION_ATTACH) == SecondLife.PERMISSION_ATTACH) {
sb.AppendLine("Attach to your avatar"); sb.AppendLine("Attach to your avatar");
}
if ((intPermissions & SecondLife.PERMISSION_CHANGE_LINKS) == SecondLife.PERMISSION_CHANGE_LINKS) if ((intPermissions & SecondLife.PERMISSION_CHANGE_LINKS) == SecondLife.PERMISSION_CHANGE_LINKS) {
sb.AppendLine("Link and delink from other objects"); sb.AppendLine("Link and delink from other objects");
}
if ((intPermissions & SecondLife.PERMISSION_TRACK_CAMERA) == SecondLife.PERMISSION_TRACK_CAMERA) if ((intPermissions & SecondLife.PERMISSION_TRACK_CAMERA) == SecondLife.PERMISSION_TRACK_CAMERA) {
sb.AppendLine("Track your camera"); sb.AppendLine("Track your camera");
}
if ((intPermissions & SecondLife.PERMISSION_CONTROL_CAMERA) == SecondLife.PERMISSION_CONTROL_CAMERA) if ((intPermissions & SecondLife.PERMISSION_CONTROL_CAMERA) == SecondLife.PERMISSION_CONTROL_CAMERA) {
sb.AppendLine("Control your camera"); sb.AppendLine("Control your camera");
}
this.label1.Text = "'"+strObjectName+"', an object owned by '"+strOwner + "',\nwould like to:"; this.label1.Text = "'" + strObjectName + "', an object owned by '" + strOwner + "',\nwould like to:";
this.label2.Text = sb.ToString(); this.label2.Text = sb.ToString();
} }
@ -109,4 +116,4 @@ namespace LSLEditor
this.Close(); this.Close();
} }
} }
} }

View file

@ -70,7 +70,7 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// We use a Major.Minor.Bugfix.Build pattern. // We use a Major.Minor.Bugfix.Build pattern.
[assembly: AssemblyVersion("2.999.999.7")] [assembly: AssemblyVersion("2.999.999.13")]
// //
// In order to sign your assembly you must specify a key to use. Refer to the // In order to sign your assembly you must specify a key to use. Refer to the
@ -100,4 +100,4 @@ using System.Runtime.InteropServices;
[assembly: AssemblyDelaySign(false)] [assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyName("")] //[assembly: AssemblyKeyName("")]
[assembly: ComVisibleAttribute(false)] [assembly: ComVisibleAttribute(false)]
[assembly: AssemblyFileVersionAttribute("2.999.999.7")] [assembly: AssemblyFileVersionAttribute("2.999.999.13")]

View file

@ -74,27 +74,29 @@ namespace LSLEditor
private bool GetNewHost() private bool GetNewHost()
{ {
bool blnResult = false;
Assembly assembly = CompilerHelper.CompileCSharp(editForm, CSharpCode); Assembly assembly = CompilerHelper.CompileCSharp(editForm, CSharpCode);
if (assembly == null) if (assembly != null) {
return false; if (SecondLifeHost != null) {
SecondLifeHost.Dispose();
}
SecondLifeHost = null;
if(SecondLifeHost!=null) SecondLifeHost = new SecondLifeHost(this.mainForm, assembly, editForm.FullPathName, editForm.guid);
SecondLifeHost.Dispose(); SecondLifeHost.OnChat += editForm.ChatHandler;
SecondLifeHost = null; SecondLifeHost.OnMessageLinked += editForm.MessageLinkedHandler;
SecondLifeHost.OnDie += new EventHandler(host_OnDie);
SecondLifeHost.OnReset += new EventHandler(SecondLifeHost_OnReset);
SecondLifeHost.OnListenChannelsChanged += new EventHandler(SecondLifeHost_OnListenChannelsChanged);
SecondLifeHost = new SecondLifeHost(this.mainForm, assembly, editForm.FullPathName, editForm.guid); SecondLifeHost.OnVerboseMessage += new SecondLifeHost.SecondLifeHostMessageHandler(host_OnVerboseMessage);
SecondLifeHost.OnChat += editForm.ChatHandler; SecondLifeHost.OnStateChange += new SecondLifeHost.SecondLifeHostMessageHandler(host_OnStateChange);
SecondLifeHost.OnMessageLinked += editForm.MessageLinkedHandler;
SecondLifeHost.OnDie += new EventHandler(host_OnDie);
SecondLifeHost.OnReset += new EventHandler(SecondLifeHost_OnReset);
SecondLifeHost.OnListenChannelsChanged += new EventHandler(SecondLifeHost_OnListenChannelsChanged);
SecondLifeHost.OnVerboseMessage += new SecondLifeHost.SecondLifeHostMessageHandler(host_OnVerboseMessage); SecondLifeHost.State("default", true);
SecondLifeHost.OnStateChange += new SecondLifeHost.SecondLifeHostMessageHandler(host_OnStateChange);
SecondLifeHost.State("default", true); blnResult = true;
}
return true; return blnResult;
} }
public bool Compile(EditForm editForm) public bool Compile(EditForm editForm)
@ -119,8 +121,7 @@ namespace LSLEditor
private void ResetScriptWatch() private void ResetScriptWatch()
{ {
while (true) while (true) {
{
this.ResetScriptEvent.WaitOne(); this.ResetScriptEvent.WaitOne();
SecondLifeHost.Dispose(); SecondLifeHost.Dispose();
@ -131,13 +132,10 @@ namespace LSLEditor
private delegate void AddListenChannelsDelegate(ComboBox comboBox, string[] channels); private delegate void AddListenChannelsDelegate(ComboBox comboBox, string[] channels);
private void AddListenChannelsToComboxBox(ComboBox comboBox, string[] channels) private void AddListenChannelsToComboxBox(ComboBox comboBox, string[] channels)
{ {
if (comboBox.InvokeRequired) if (comboBox.InvokeRequired) {
{
comboBox.Invoke(new AddListenChannelsDelegate(AddListenChannelsToComboxBox), comboBox.Invoke(new AddListenChannelsDelegate(AddListenChannelsToComboxBox),
new object[] { comboBox , channels }); new object[] { comboBox, channels });
} } else {
else
{
comboBox.Items.Clear(); comboBox.Items.Clear();
comboBox.Items.AddRange(channels); comboBox.Items.AddRange(channels);
comboBox.SelectedIndex = 0; comboBox.SelectedIndex = 0;
@ -145,18 +143,19 @@ namespace LSLEditor
} }
private void SecondLifeHost_OnListenChannelsChanged(object sender, EventArgs e) private void SecondLifeHost_OnListenChannelsChanged(object sender, EventArgs e)
{ {
foreach (Control control in this.panel4.Controls) foreach (Control control in this.panel4.Controls) {
{
GroupboxEvent gbe = control as GroupboxEvent; GroupboxEvent gbe = control as GroupboxEvent;
if (gbe == null) if (gbe == null) {
continue; continue;
foreach (Control control1 in gbe.Controls) }
{ foreach (Control control1 in gbe.Controls) {
GroupBox gb = control1 as GroupBox; GroupBox gb = control1 as GroupBox;
if (gb == null) if (gb == null) {
continue; continue;
if (gb.Name!="listen_0") }
if (gb.Name != "listen_0") {
continue; continue;
}
ComboBox comboBox = gb.Controls[0] as ComboBox; ComboBox comboBox = gb.Controls[0] as ComboBox;
AddListenChannelsToComboxBox(comboBox, SecondLifeHost.GetListenChannels()); AddListenChannelsToComboxBox(comboBox, SecondLifeHost.GetListenChannels());
} }
@ -165,13 +164,10 @@ namespace LSLEditor
void host_OnDie(object sender, EventArgs e) void host_OnDie(object sender, EventArgs e)
{ {
if(this.panel1.InvokeRequired) if (this.panel1.InvokeRequired) {
{
// using Evenhandler definition as a delegate // using Evenhandler definition as a delegate
this.panel1.Invoke(new EventHandler(host_OnDie)); this.panel1.Invoke(new EventHandler(host_OnDie));
} } else {
else
{
this.panel1.Enabled = false; this.panel1.Enabled = false;
} }
} }
@ -185,16 +181,11 @@ namespace LSLEditor
private delegate void SetStateComboboxDelegate(string strName); private delegate void SetStateComboboxDelegate(string strName);
public void SetStateCombobox(string strName) public void SetStateCombobox(string strName)
{ {
if (this.comboBox1.InvokeRequired) if (this.comboBox1.InvokeRequired) {
{
this.comboBox1.Invoke(new SetStateComboboxDelegate(SetStateCombobox), new object[] { strName }); this.comboBox1.Invoke(new SetStateComboboxDelegate(SetStateCombobox), new object[] { strName });
} } else {
else for (int intI = 0; intI < this.comboBox1.Items.Count; intI++) {
{ if (this.comboBox1.Items[intI].ToString() == strName) {
for (int intI = 0; intI < this.comboBox1.Items.Count; intI++)
{
if (this.comboBox1.Items[intI].ToString() == strName)
{
this.comboBox1.SelectedIndex = intI; this.comboBox1.SelectedIndex = intI;
break; break;
} }
@ -204,13 +195,13 @@ namespace LSLEditor
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e) private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{ {
if (SecondLifeHost == null) if (SecondLifeHost != null) {
return; string strStateName = (string)this.comboBox1.Items[this.comboBox1.SelectedIndex];
string strStateName = (string)this.comboBox1.Items[this.comboBox1.SelectedIndex]; if (strStateName != "") {
if (strStateName != "") if (SecondLifeHost.CurrentStateName != strStateName) {
{ SecondLifeHost.State(strStateName, true);
if (SecondLifeHost.CurrentStateName != strStateName) }
SecondLifeHost.State(strStateName,true); }
} }
} }
@ -230,8 +221,7 @@ namespace LSLEditor
strC = translator.Parse(strC); strC = translator.Parse(strC);
foreach (string strState in translator.States) foreach (string strState in translator.States) {
{
this.comboBox1.Items.Add(strState); this.comboBox1.Items.Add(strState);
} }
return strC; return strC;
@ -240,18 +230,14 @@ namespace LSLEditor
private delegate void ShowLifeEventsDelegate(); private delegate void ShowLifeEventsDelegate();
private void ShowLifeEvents() private void ShowLifeEvents()
{ {
if (this.panel4.InvokeRequired) if (this.panel4.InvokeRequired) {
{
this.panel4.Invoke(new ShowLifeEventsDelegate(ShowLifeEvents), null); this.panel4.Invoke(new ShowLifeEventsDelegate(ShowLifeEvents), null);
} } else {
else
{
int intX = 8; int intX = 8;
int intY = 0; int intY = 0;
this.panel4.Controls.Clear(); this.panel4.Controls.Clear();
foreach (string strEventName in SecondLifeHost.GetEvents()) foreach (string strEventName in SecondLifeHost.GetEvents()) {
{
string strArgs = SecondLifeHost.GetArgumentsFromMethod(strEventName); string strArgs = SecondLifeHost.GetArgumentsFromMethod(strEventName);
GroupboxEvent ge = new GroupboxEvent(new Point(intX, intY), strEventName, strArgs, new System.EventHandler(this.buttonEvent_Click)); GroupboxEvent ge = new GroupboxEvent(new Point(intX, intY), strEventName, strArgs, new System.EventHandler(this.buttonEvent_Click));
this.panel4.Controls.Add(ge); this.panel4.Controls.Add(ge);
@ -265,28 +251,23 @@ namespace LSLEditor
// Verbose // Verbose
public void VerboseConsole(string strLine) public void VerboseConsole(string strLine)
{ {
if (this.textBox2.IsDisposed) if (!this.textBox2.IsDisposed) {
return; if (this.textBox2.InvokeRequired) {
if (this.textBox2.InvokeRequired) this.textBox2.Invoke(new AppendTextDelegate(VerboseConsole), new object[] { strLine });
{ } else {
this.textBox2.Invoke(new AppendTextDelegate(VerboseConsole), new object[] { strLine }); this.textBox2.AppendText(strLine.Replace("\n", "\r\n") + "\r\n");
} }
else
{
this.textBox2.AppendText(strLine.Replace("\n", "\r\n") + "\r\n");
} }
} }
private string GetArgumentValue(string strName) private string GetArgumentValue(string strName)
{ {
foreach (Control parent in this.panel4.Controls) foreach (Control parent in this.panel4.Controls) {
{ if (parent.Name == "GroupboxTextbox") {
if (parent.Name == "GroupboxTextbox") foreach (Control c in parent.Controls) {
{ if (c.Name == strName) {
foreach (Control c in parent.Controls)
{
if (c.Name == strName)
return c.Controls[0].Text; return c.Controls[0].Text;
}
} }
} }
} }
@ -295,71 +276,62 @@ namespace LSLEditor
private object[] GetArguments(string strName, string strArgs) private object[] GetArguments(string strName, string strArgs)
{ {
if (strArgs == "") object[] objResult = new object[0];
return new object[0]; if (strArgs != "") {
try {
try string[] args = strArgs.Trim().Split(new char[] { ',' });
{ object[] argobjects = new object[args.Length];
string[] args = strArgs.Trim().Split(new char[] { ',' }); for (int intI = 0; intI < argobjects.Length; intI++) {
object[] argobjects = new object[args.Length]; string[] argument = args[intI].Trim().Split(new char[] { ' ' });
for (int intI = 0; intI < argobjects.Length; intI++) if (argument.Length == 2) {
{ string[] arArgs;
string[] argument = args[intI].Trim().Split(new char[] { ' ' }); string strArgumentValue = GetArgumentValue(strName + "_" + intI);
if (argument.Length == 2) string strArgumentName = argument[1];
{ string strArgumentType = argument[0];
string[] arArgs; switch (strArgumentType) {
string strArgumentValue = GetArgumentValue(strName + "_" + intI); case "System.String":
string strArgumentName = argument[1]; argobjects[intI] = strArgumentValue;
string strArgumentType = argument[0]; break;
switch (strArgumentType) case "System.Int32":
{ argobjects[intI] = int.Parse(strArgumentValue);
case "System.String": break;
argobjects[intI] = strArgumentValue; case "LSLEditor.SecondLife+Float":
break; argobjects[intI] = new SecondLife.Float(strArgumentValue);
case "System.Int32": break;
argobjects[intI] = int.Parse(strArgumentValue); case "LSLEditor.SecondLife+integer":
break; argobjects[intI] = new SecondLife.integer(int.Parse(strArgumentValue));
case "LSLEditor.SecondLife+Float": break;
argobjects[intI] = new SecondLife.Float(strArgumentValue); case "LSLEditor.SecondLife+String":
break; argobjects[intI] = new SecondLife.String(strArgumentValue);
case "LSLEditor.SecondLife+integer": break;
argobjects[intI] = new SecondLife.integer(int.Parse(strArgumentValue)); case "LSLEditor.SecondLife+key":
break; argobjects[intI] = new SecondLife.key(strArgumentValue);
case "LSLEditor.SecondLife+String": break;
argobjects[intI] = new SecondLife.String(strArgumentValue); case "LSLEditor.SecondLife+list":
break; argobjects[intI] = new SecondLife.list(new string[] { strArgumentValue });
case "LSLEditor.SecondLife+key": break;
argobjects[intI] = new SecondLife.key(strArgumentValue); case "LSLEditor.SecondLife+rotation":
break; arArgs = strArgumentValue.Replace("<", "").Replace(">", "").Replace(" ", "").Split(new char[] { ',' });
case "LSLEditor.SecondLife+list": argobjects[intI] = new SecondLife.rotation(double.Parse(arArgs[0]), double.Parse(arArgs[1]), double.Parse(arArgs[2]), double.Parse(arArgs[3]));
argobjects[intI] = new SecondLife.list(new string[] { strArgumentValue } ); break;
break; case "LSLEditor.SecondLife+vector":
case "LSLEditor.SecondLife+rotation": arArgs = strArgumentValue.Replace("<", "").Replace(">", "").Replace(" ", "").Split(new char[] { ',' });
arArgs = strArgumentValue.Replace("<", "").Replace(">", "").Replace(" ", "").Split(new char[] { ',' }); argobjects[intI] = new SecondLife.vector(double.Parse(arArgs[0]), double.Parse(arArgs[1]), double.Parse(arArgs[2]));
argobjects[intI] = new SecondLife.rotation(double.Parse(arArgs[0]), double.Parse(arArgs[1]), double.Parse(arArgs[2]), double.Parse(arArgs[3])); break;
break; default:
case "LSLEditor.SecondLife+vector": MessageBox.Show("Compiler->GetArguments->[" + strArgumentType + "][" + strArgumentName + "]");
arArgs = strArgumentValue.Replace("<", "").Replace(">", "").Replace(" ", "").Split(new char[] { ',' }); argobjects[intI] = null;
argobjects[intI] = new SecondLife.vector(double.Parse(arArgs[0]), double.Parse(arArgs[1]), double.Parse(arArgs[2])); break;
break; }
default: } else {
MessageBox.Show("Compiler->GetArguments->[" + strArgumentType + "][" + strArgumentName + "]"); MessageBox.Show("Argument must be 'type name' [" + args[intI] + "]");
argobjects[intI] = null; break;
break;
} }
} }
else objResult = argobjects;
{ } catch { }
MessageBox.Show("Argument must be 'type name' [" + args[intI] + "]");
break;
}
}
return argobjects;
}
catch
{
return new object[0];
} }
return objResult;
} }
private void buttonEvent_Click(object sender, System.EventArgs e) private void buttonEvent_Click(object sender, System.EventArgs e)
@ -374,8 +346,9 @@ namespace LSLEditor
private void Die() private void Die()
{ {
if (this.SecondLifeHost != null) if (this.SecondLifeHost != null) {
this.SecondLifeHost.Die(); this.SecondLifeHost.Die();
}
} }
// Die // Die
@ -386,8 +359,9 @@ namespace LSLEditor
private void textBox2_KeyDown(object sender, KeyEventArgs e) private void textBox2_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.Control && e.KeyCode == Keys.A) if (e.Control && e.KeyCode == Keys.A) {
this.textBox2.SelectAll(); this.textBox2.SelectAll();
}
} }
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e) private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)

View file

@ -71,10 +71,12 @@ namespace LSLEditor
this.History = new List<string>(); this.History = new List<string>();
this.intHistory = 0; this.intHistory = 0;
if (Properties.Settings.Default.SimulatorLocation != Point.Empty) if (Properties.Settings.Default.SimulatorLocation != Point.Empty) {
this.Location = Properties.Settings.Default.SimulatorLocation; this.Location = Properties.Settings.Default.SimulatorLocation;
if (Properties.Settings.Default.SimulatorSize != Size.Empty) }
if (Properties.Settings.Default.SimulatorSize != Size.Empty) {
this.Size = Properties.Settings.Default.SimulatorSize; this.Size = Properties.Settings.Default.SimulatorSize;
}
this.Clear(); this.Clear();
@ -86,11 +88,11 @@ namespace LSLEditor
this.LocationChanged += new EventHandler(SimulatorConsole_LocationChanged); this.LocationChanged += new EventHandler(SimulatorConsole_LocationChanged);
foreach (Form form in this.Children) foreach (Form form in this.Children) {
{
EditForm editForm = form as EditForm; EditForm editForm = form as EditForm;
if (editForm == null || editForm.IsDisposed) if (editForm == null || editForm.IsDisposed) {
continue; continue;
}
editForm.ChatHandler = chathandler; editForm.ChatHandler = chathandler;
editForm.MessageLinkedHandler = messagelinkedhandler; editForm.MessageLinkedHandler = messagelinkedhandler;
editForm.StartCompiler(); editForm.StartCompiler();
@ -99,11 +101,11 @@ namespace LSLEditor
public void Stop() public void Stop()
{ {
foreach (Form form in this.Children) foreach (Form form in this.Children) {
{
EditForm editForm = form as EditForm; EditForm editForm = form as EditForm;
if (editForm == null || editForm.IsDisposed) if (editForm == null || editForm.IsDisposed) {
continue; continue;
}
editForm.StopCompiler(); editForm.StopCompiler();
} }
} }
@ -118,24 +120,26 @@ namespace LSLEditor
this.Listen(e); this.Listen(e);
// talk only to the owner // talk only to the owner
if (e.how == CommunicationType.OwnerSay) if (e.how != CommunicationType.OwnerSay) {
return; foreach (Form form in this.Children) {
EditForm editForm = form as EditForm;
if (editForm == null || editForm.IsDisposed) {
continue;
}
foreach (Form form in this.Children) if (editForm.runtime == null) {
{ continue;
EditForm editForm = form as EditForm; }
if (editForm == null || editForm.IsDisposed)
continue;
if (editForm.runtime == null) if (editForm.runtime.SecondLifeHost == null) {
continue; continue;
}
if (editForm.runtime.SecondLifeHost == null) // prevent loops loops loops loops, dont talk to myself
continue; if (sender != editForm.runtime.SecondLifeHost) {
editForm.runtime.SecondLifeHost.Listen(e);
// prevent loops loops loops loops, dont talk to myself }
if (sender != editForm.runtime.SecondLifeHost) }
editForm.runtime.SecondLifeHost.Listen(e);
} }
} }
@ -149,8 +153,7 @@ namespace LSLEditor
List<Guid> list; List<Guid> list;
int intLinkNum = e.iLinkIndex; 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)
list = this.solutionExplorer.GetScripts(RootObjectGuid, false); list = this.solutionExplorer.GetScripts(RootObjectGuid, false);
break; break;
@ -160,8 +163,7 @@ namespace LSLEditor
case -2: // LINK_ALL_OTHERS , all other prims in object besides prim function is in case -2: // LINK_ALL_OTHERS , all other prims in object besides prim function is in
list = this.solutionExplorer.GetScripts(RootObjectGuid, true); list = this.solutionExplorer.GetScripts(RootObjectGuid, true);
// remove scripts in prim itself, and below // remove scripts in prim itself, and below
foreach (Guid guid in this.solutionExplorer.GetScripts(ObjectGuid, true)) foreach (Guid guid in this.solutionExplorer.GetScripts(ObjectGuid, true)) {
{
if (list.Contains(guid)) if (list.Contains(guid))
list.Remove(guid); list.Remove(guid);
} }
@ -169,19 +171,18 @@ namespace LSLEditor
case -3: // LINK_ALL_CHILDREN , all child prims in object case -3: // LINK_ALL_CHILDREN , all child prims in object
list = this.solutionExplorer.GetScripts(RootObjectGuid, true); list = this.solutionExplorer.GetScripts(RootObjectGuid, true);
// remove root itself // remove root itself
foreach (Guid guid in this.solutionExplorer.GetScripts(RootObjectGuid, false)) foreach (Guid guid in this.solutionExplorer.GetScripts(RootObjectGuid, false)) {
{
if (list.Contains(guid)) if (list.Contains(guid))
list.Remove(guid); list.Remove(guid);
} }
break; break;
case -4: // LINK_THIS case -4: // LINK_THIS
/* /*
* From SL Wiki: "Causes the script to act only upon the prim the prim the script is in." * From SL Wiki: "Causes the script to act only upon the prim the prim the script is in."
* This means LINK_THIS, links to every script in the prim, not just the caller. * This means LINK_THIS, links to every script in the prim, not just the caller.
* @author = MrSoundless * @author = MrSoundless
* @date = 28 April 2011 * @date = 28 April 2011
*/ */
list = new List<Guid>(); list = new List<Guid>();
//list.Add(secondLifeHostSender.guid); // 4 feb 2008 //list.Add(secondLifeHostSender.guid); // 4 feb 2008
list = this.solutionExplorer.GetScripts(ObjectGuid, true); // 28 april 2011 list = this.solutionExplorer.GetScripts(ObjectGuid, true); // 28 april 2011
@ -193,36 +194,41 @@ namespace LSLEditor
} }
// only send message to running scripts in list // only send message to running scripts in list
foreach (Form form in this.Children) foreach (Form form in this.Children) {
{
EditForm editForm = form as EditForm; EditForm editForm = form as EditForm;
if (editForm == null || editForm.IsDisposed) if (editForm == null || editForm.IsDisposed) {
continue; continue;
}
if (editForm.runtime == null) if (editForm.runtime == null) {
continue; continue;
}
if (editForm.runtime.SecondLifeHost == null) if (editForm.runtime.SecondLifeHost == null) {
continue; continue;
}
if(list.Contains(editForm.guid)) if (list.Contains(editForm.guid)) {
editForm.runtime.SecondLifeHost.LinkMessage(e); editForm.runtime.SecondLifeHost.LinkMessage(e);
}
} }
} }
private void SimulatorConsole_OnControl(object sender, EventArgs e) private void SimulatorConsole_OnControl(object sender, EventArgs e)
{ {
foreach (Form form in this.Children) foreach (Form form in this.Children) {
{
EditForm editForm = form as EditForm; EditForm editForm = form as EditForm;
if (editForm == null || editForm.IsDisposed) if (editForm == null || editForm.IsDisposed) {
continue; continue;
}
if (editForm.runtime == null) if (editForm.runtime == null) {
continue; continue;
}
if (editForm.runtime.SecondLifeHost == null) if (editForm.runtime.SecondLifeHost == null) {
continue; continue;
}
editForm.runtime.SecondLifeHost.SendControl((Keys)sender); editForm.runtime.SecondLifeHost.SendControl((Keys)sender);
} }
@ -231,47 +237,48 @@ namespace LSLEditor
private delegate void AppendTextDelegate(string strLine); private delegate void AppendTextDelegate(string strLine);
public void TalkToSimulatorConsole(string strLine) public void TalkToSimulatorConsole(string strLine)
{ {
if (this.textBox2.InvokeRequired) if (this.textBox2.InvokeRequired) {
{
this.textBox2.Invoke(new AppendTextDelegate(TalkToSimulatorConsole), new object[] { strLine }); this.textBox2.Invoke(new AppendTextDelegate(TalkToSimulatorConsole), new object[] { strLine });
} } else {
else
{
this.textBox2.AppendText(strLine.Replace("\n", "\r\n") + "\r\n"); this.textBox2.AppendText(strLine.Replace("\n", "\r\n") + "\r\n");
} }
} }
private void Chat(int channel, string name, SecondLife.key id, string message, CommunicationType how) private void Chat(int channel, string name, SecondLife.key id, string message, CommunicationType how)
{ {
if (OnChat != null) if (OnChat != null) {
OnChat(this, new SecondLifeHostChatEventArgs(channel, name, id, message, how)); OnChat(this, new SecondLifeHostChatEventArgs(channel, name, id, message, how));
}
} }
public void Listen(SecondLifeHostChatEventArgs e) public void Listen(SecondLifeHostChatEventArgs e)
{ {
// Translate the incomming messages a bit so it looks like SL. // Translate the incomming messages a bit so it looks like SL.
string strHow = ": "; string strHow = ": ";
if (e.how == CommunicationType.Shout) if (e.how == CommunicationType.Shout) {
strHow = " shout: "; strHow = " shout: ";
}
if (e.how == CommunicationType.Whisper) if (e.how == CommunicationType.Whisper) {
strHow = " whispers: "; strHow = " whispers: ";
}
string strWho = e.name; string strWho = e.name;
string strMessage = e.message; string strMessage = e.message;
if (e.name == Properties.Settings.Default.AvatarName) if (e.name == Properties.Settings.Default.AvatarName) {
strWho = "You"; strWho = "You";
}
if (e.message.ToString().StartsWith("/me")) if (e.message.ToString().StartsWith("/me")) {
{
strWho = e.name; strWho = e.name;
strHow = " "; strHow = " ";
strMessage = e.message.ToString().Substring(3).Trim(); strMessage = e.message.ToString().Substring(3).Trim();
} }
if (e.channel == 0) if (e.channel == 0) {
TalkToSimulatorConsole(strWho + strHow + strMessage); TalkToSimulatorConsole(strWho + strHow + strMessage);
}
} }
private void Speak(CommunicationType how) private void Speak(CommunicationType how)
@ -283,35 +290,26 @@ namespace LSLEditor
intHistory = History.Count; intHistory = History.Count;
if (strMessage == "") if (strMessage != ""){
return; if (strMessage[0] == '/') {
if (strMessage.StartsWith("/me")) {
if (strMessage[0] == '/') // do nothing
{ } else {
if (strMessage.StartsWith("/me")) string strChannel = "";
{ for (int intI = 1; intI < strMessage.Length; intI++) {
// do nothing if (strMessage[intI] >= '0' && strMessage[intI] <= '9') {
} strChannel += strMessage[intI];
else if (intI < 10) {
{ continue;
string strChannel = ""; }
for (int intI = 1; intI < strMessage.Length; intI++) }
{ try {
if (strMessage[intI] >= '0' && strMessage[intI] <= '9') intChannel = Convert.ToInt32(strChannel);
{ strMessage = strMessage.Substring(intI).Trim();
strChannel += strMessage[intI]; } catch {
if (intI < 10) }
continue; break;
} }
try
{
intChannel = Convert.ToInt32(strChannel);
strMessage = strMessage.Substring(intI).Trim();
}
catch
{
}
break;
} }
} }
} }
@ -336,13 +334,16 @@ namespace LSLEditor
private void ScrollChat(KeyEventArgs e) private void ScrollChat(KeyEventArgs e)
{ {
e.SuppressKeyPress = true; e.SuppressKeyPress = true;
if (e.KeyCode == Keys.Up) if (e.KeyCode == Keys.Up) {
intHistory = Math.Max(0, intHistory - 1); intHistory = Math.Max(0, intHistory - 1);
if (e.KeyCode == Keys.Down) }
if (e.KeyCode == Keys.Down) {
intHistory = Math.Min(History.Count, intHistory + 1); intHistory = Math.Min(History.Count, intHistory + 1);
}
this.textBox1.Clear(); this.textBox1.Clear();
if (intHistory != History.Count) if (intHistory != History.Count) {
this.textBox1.AppendText(History[intHistory]); this.textBox1.AppendText(History[intHistory]);
}
} }
private void textBox1_KeyDown(object sender, KeyEventArgs e) private void textBox1_KeyDown(object sender, KeyEventArgs e)
@ -350,23 +351,16 @@ namespace LSLEditor
this.buttonSay.Enabled = true; this.buttonSay.Enabled = true;
this.buttonShout.Enabled = true; this.buttonShout.Enabled = true;
if (e.KeyCode == Keys.Return) if (e.KeyCode == Keys.Return) {
{
Speak(CommunicationType.Say); Speak(CommunicationType.Say);
e.SuppressKeyPress = true; e.SuppressKeyPress = true;
} }
if (e.Control && (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)) if (e.Control && (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down)) {
{
ScrollChat(e); ScrollChat(e);
} } else if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Up ) {
else if (e.KeyCode == Keys.Down || if (OnControl != null) {
e.KeyCode == Keys.Left ||
e.KeyCode == Keys.Right ||
e.KeyCode == Keys.Up
)
{
if (OnControl != null)
OnControl(e.KeyCode, new EventArgs()); OnControl(e.KeyCode, new EventArgs());
}
e.SuppressKeyPress = true; e.SuppressKeyPress = true;
} }
} }
@ -391,8 +385,9 @@ namespace LSLEditor
private void textBox2_KeyDown(object sender, KeyEventArgs e) private void textBox2_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.Control && e.KeyCode == Keys.A) if (e.Control && e.KeyCode == Keys.A) {
this.textBox2.SelectAll(); this.textBox2.SelectAll();
}
} }
private void copyToolStripMenuItem_Click(object sender, EventArgs e) private void copyToolStripMenuItem_Click(object sender, EventArgs e)

View file

@ -112,10 +112,11 @@ namespace LSLEditor
{ {
Uri url; Uri url;
string strVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); string strVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
if (Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location).Contains("beta")) if (Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location).Contains("beta")) {
url = new Uri(Properties.Settings.Default.UpdateManifest + "?beta-" + strVersion); url = new Uri(Properties.Settings.Default.UpdateManifest + "?beta-" + strVersion);
else } else {
url = new Uri(Properties.Settings.Default.UpdateManifest + "?" + strVersion); url = new Uri(Properties.Settings.Default.UpdateManifest + "?" + strVersion);
}
manifest = new WebClient(); manifest = new WebClient();
manifest.DownloadStringCompleted += new DownloadStringCompletedEventHandler(manifest_DownloadCompleted); manifest.DownloadStringCompleted += new DownloadStringCompletedEventHandler(manifest_DownloadCompleted);
@ -130,28 +131,26 @@ namespace LSLEditor
public void CheckForUpdate(bool blnForce) public void CheckForUpdate(bool blnForce)
{ {
if (!blnForce) if (!blnForce) {
{ if (Properties.Settings.Default.DeleteOldFiles) {
if (Properties.Settings.Default.DeleteOldFiles)
DeleteOldFile(); DeleteOldFile();
}
DateTime dateTime = Properties.Settings.Default.CheckDate; DateTime dateTime = Properties.Settings.Default.CheckDate;
if (Properties.Settings.Default.CheckEveryDay) if (Properties.Settings.Default.CheckEveryDay) {
{
TimeSpan lastUpdate = DateTime.Now - dateTime; TimeSpan lastUpdate = DateTime.Now - dateTime;
if (lastUpdate.TotalDays >= 1.0) if (lastUpdate.TotalDays >= 1.0) {
blnForce = true; blnForce = true;
} }
else if (Properties.Settings.Default.CheckEveryWeek) } else if (Properties.Settings.Default.CheckEveryWeek) {
{
TimeSpan lastUpdate = DateTime.Now - dateTime; TimeSpan lastUpdate = DateTime.Now - dateTime;
if(lastUpdate.TotalDays >= 7.0) if (lastUpdate.TotalDays >= 7.0) {
blnForce = true; blnForce = true;
}
} }
} }
if (blnForce) if (blnForce) {
{
Properties.Settings.Default.CheckDate = DateTime.Now; Properties.Settings.Default.CheckDate = DateTime.Now;
Properties.Settings.Default.Save(); // save also all settings Properties.Settings.Default.Save(); // save also all settings
@ -164,7 +163,7 @@ namespace LSLEditor
if (e.Error != null) if (e.Error != null)
return; return;
versionInfo bzip = new versionInfo(); versionInfo bzip = new versionInfo();
versionInfo gzip = new versionInfo(); versionInfo gzip = new versionInfo();
versionInfo wzip = new versionInfo(); versionInfo wzip = new versionInfo();
@ -176,19 +175,13 @@ namespace LSLEditor
string strHelpHashMe = ""; string strHelpHashMe = "";
string strHelpFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Properties.Settings.Default.HelpOfflineFile); string strHelpFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Properties.Settings.Default.HelpOfflineFile);
if (File.Exists(strHelpFile)) if (File.Exists(strHelpFile)) {
{
strHelpHashMe = Decompressor.MD5Verify.ComputeHash(strHelpFile); strHelpHashMe = Decompressor.MD5Verify.ComputeHash(strHelpFile);
} } else {
else
{
// help file does not exist // help file does not exist
if (Properties.Settings.Default.HelpOffline || blnOnlyHelpFile) if (Properties.Settings.Default.HelpOffline || blnOnlyHelpFile) {
{
strHelpHashMe = "*"; // force new update strHelpHashMe = "*"; // force new update
} } else {
else
{
strHelpHashMe = ""; // no update strHelpHashMe = ""; // no update
this.labelHelpFile.Visible = false; this.labelHelpFile.Visible = false;
this.labelHelpversionString.Visible = false; this.labelHelpversionString.Visible = false;
@ -196,22 +189,22 @@ namespace LSLEditor
} }
StringReader sr = new StringReader(e.Result); StringReader sr = new StringReader(e.Result);
for (int intI = 0; intI < 255; intI++) for (int intI = 0; intI < 255; intI++) {
{
string strLine = sr.ReadLine(); string strLine = sr.ReadLine();
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.
switch (strName) switch (strName) {
{
case "Version": case "Version":
case "BZipVersion": case "BZipVersion":
bzip = new versionInfo(strValue); bzip = new versionInfo(strValue);
@ -274,46 +267,39 @@ namespace LSLEditor
this.labelOurVersionString.Text = current.version.ToString(); this.labelOurVersionString.Text = current.version.ToString();
this.labelLatestVersionString.Text = web.version.ToString(); this.labelLatestVersionString.Text = web.version.ToString();
if (String.IsNullOrEmpty(web.uri) || (web.version.CompareTo(current.version) != 1)) if (String.IsNullOrEmpty(web.uri) || (web.version.CompareTo(current.version) != 1)) {
{
return; return;
} }
if (strHelpHashMe == "") if (strHelpHashMe == "") {
strHelpHashMe = strHelpHashWeb; strHelpHashMe = strHelpHashWeb;
}
if (strHelpHashMe == strHelpHashWeb) if (strHelpHashMe == strHelpHashWeb) {
{
this.labelHelpversionString.Text = "Up to date"; this.labelHelpversionString.Text = "Up to date";
this.strHelpUrl = null; this.strHelpUrl = null;
} } else {
else
{
this.labelHelpversionString.Text = "Out of date"; this.labelHelpversionString.Text = "Out of date";
} }
if (current.hash == web.hash) if (current.hash == web.hash) {
{
this.strDownloadUrl = null; this.strDownloadUrl = null;
} } else {
else
{
this.strDownloadUrl = web.uri; this.strDownloadUrl = web.uri;
} }
if (this.blnOnlyHelpFile) if (this.blnOnlyHelpFile) {
{
this.strDownloadUrl = null; this.strDownloadUrl = null;
this.labelLatestVersion.Visible = false; this.labelLatestVersion.Visible = false;
this.labelLatestVersionString.Visible = false; this.labelLatestVersionString.Visible = false;
} }
if (this.strHelpUrl != null || this.strDownloadUrl != null) if (this.strHelpUrl != null || this.strDownloadUrl != null) {
{
this.buttonUpdate.Enabled = true; this.buttonUpdate.Enabled = true;
if (OnUpdateAvailable != null) if (OnUpdateAvailable != null) {
OnUpdateAvailable(this, null); OnUpdateAvailable(this, null);
}
} }
} }
@ -330,85 +316,85 @@ namespace LSLEditor
private void Download() private void Download()
{ {
if (strHelpUrl != null) if (strHelpUrl != null) {
DownloadHelpFile(); // starts also DownloadProgram when finished DownloadHelpFile(); // starts also DownloadProgram when finished
else } else {
DownloadProgram(); DownloadProgram();
}
} }
private void DownloadHelpFile() private void DownloadHelpFile()
{ {
if (strHelpUrl == null) if (strHelpUrl != null) {
return; Uri url = new Uri(strHelpUrl);
Uri url = new Uri(strHelpUrl); client = new WebClient();
client = new WebClient(); if (this.strHelpReferer != null) {
client.Headers.Add("Referer", strHelpReferer);
}
if(this.strHelpReferer != null) client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadHelpFileCompleted);
client.Headers.Add("Referer", strHelpReferer); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadHelpFileCompleted); string strCurrentFile = Assembly.GetExecutingAssembly().Location;
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); string strDirectory = Path.GetDirectoryName(strCurrentFile);
string strNewFile = Path.Combine(strDirectory, Properties.Settings.Default.HelpOfflineFile);
string strCurrentFile = Assembly.GetExecutingAssembly().Location; if (File.Exists(strNewFile)) {
string strDirectory = Path.GetDirectoryName(strCurrentFile); File.Delete(strNewFile);
string strNewFile = Path.Combine(strDirectory, Properties.Settings.Default.HelpOfflineFile); }
if (File.Exists(strNewFile)) client.DownloadFileAsync(url, strNewFile);
File.Delete(strNewFile); }
client.DownloadFileAsync(url, strNewFile);
} }
void client_DownloadHelpFileCompleted(object sender, AsyncCompletedEventArgs e) void client_DownloadHelpFileCompleted(object sender, AsyncCompletedEventArgs e)
{ {
try try {
{ if (e.Error != null) {
if (e.Error != null)
throw e.Error; throw e.Error;
}
string strCurrentFile = Assembly.GetExecutingAssembly().Location; string strCurrentFile = Assembly.GetExecutingAssembly().Location;
string strDirectory = Path.GetDirectoryName(strCurrentFile); string strDirectory = Path.GetDirectoryName(strCurrentFile);
string strNewFile = Path.Combine(strDirectory, Properties.Settings.Default.HelpOfflineFile); string strNewFile = Path.Combine(strDirectory, Properties.Settings.Default.HelpOfflineFile);
string strComputedHash = Decompressor.MD5Verify.ComputeHash(strNewFile); string strComputedHash = Decompressor.MD5Verify.ComputeHash(strNewFile);
if (strComputedHash != strHelpHashWeb) if (strComputedHash != strHelpHashWeb) {
{
this.buttonUpdate.Enabled = true; this.buttonUpdate.Enabled = true;
throw new Exception("MD5 Hash of HelpFile not correct, try downloading again!"); throw new Exception("MD5 Hash of HelpFile not correct, try downloading again!");
} }
if (this.strDownloadUrl != null) if (this.strDownloadUrl != null) {
DownloadProgram(); DownloadProgram();
else } else {
this.Close(); this.Close();
} }
catch (Exception exception) } catch (Exception exception) {
{
MessageBox.Show(exception.Message, "Oops...", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(exception.Message, "Oops...", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void DownloadProgram() private void DownloadProgram()
{ {
if (strDownloadUrl == null) if (strDownloadUrl != null) {
return; Uri url = new Uri(strDownloadUrl);
Uri url = new Uri(strDownloadUrl); client = new WebClient();
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
client = new WebClient(); string strCurrentFile = Assembly.GetExecutingAssembly().Location;
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted); string strDirectory = Path.GetDirectoryName(strCurrentFile);
client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged); string strNewFileName = Path.GetFileName(strDownloadUrl);
string strNewFile = Path.Combine(strDirectory, strNewFileName);
string strCurrentFile = Assembly.GetExecutingAssembly().Location; if (File.Exists(strNewFile)) {
string strDirectory = Path.GetDirectoryName(strCurrentFile); File.Delete(strNewFile);
string strNewFileName = Path.GetFileName(strDownloadUrl); }
string strNewFile = Path.Combine(strDirectory, strNewFileName);
if (File.Exists(strNewFile)) client.DownloadFileAsync(url, strNewFile, strNewFileName);
File.Delete(strNewFile); }
client.DownloadFileAsync(url, strNewFile, strNewFileName);
} }
void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
@ -418,10 +404,10 @@ namespace LSLEditor
void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{ {
try try {
{ if (e.Error != null) {
if (e.Error != null)
throw e.Error; throw e.Error;
}
string strNewFileName = e.UserState.ToString(); string strNewFileName = e.UserState.ToString();
@ -433,8 +419,7 @@ namespace LSLEditor
string strOldFile = Path.Combine(strDirectory, "_LSLEditor.exe"); string strOldFile = Path.Combine(strDirectory, "_LSLEditor.exe");
string strExtension = Path.GetExtension(strNewFileName); string strExtension = Path.GetExtension(strNewFileName);
switch (strExtension) switch (strExtension) {
{
case ".bz2": case ".bz2":
Decompressor.BZip2.Decompress(File.OpenRead(strZipFile), File.Create(strNewFile)); Decompressor.BZip2.Decompress(File.OpenRead(strZipFile), File.Create(strNewFile));
break; break;
@ -449,16 +434,16 @@ namespace LSLEditor
break; break;
} }
string strComputedHash = Decompressor.MD5Verify.ComputeHash(strNewFile); string strComputedHash = Decompressor.MD5Verify.ComputeHash(strNewFile);
if (strComputedHash == strHashWeb) if (strComputedHash == strHashWeb) {
{
if (File.Exists(strOldFile)) if (File.Exists(strOldFile))
File.Delete(strOldFile); File.Delete(strOldFile);
File.Move(strCurrentFile, strOldFile); File.Move(strCurrentFile, strOldFile);
File.Move(strNewFile, strCurrentFile); File.Move(strNewFile, strCurrentFile);
if (File.Exists(strZipFile)) if (File.Exists(strZipFile)) {
File.Delete(strZipFile); File.Delete(strZipFile);
}
// save all there is pending (if any) // save all there is pending (if any)
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
@ -466,32 +451,28 @@ namespace LSLEditor
System.Diagnostics.Process.Start(strCurrentFile); System.Diagnostics.Process.Start(strCurrentFile);
Environment.Exit(0); Environment.Exit(0);
} } else {
else
{
this.buttonUpdate.Enabled = true; this.buttonUpdate.Enabled = true;
throw new Exception("MD5 Hash not correct, try downloading again!"); throw new Exception("MD5 Hash not correct, try downloading again!");
} }
} } catch (Exception exception) {
catch (Exception exception)
{
MessageBox.Show(exception.Message, "Oops...", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(exception.Message, "Oops...", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void UpdateApplicationForm_FormClosing(object sender, FormClosingEventArgs e) private void UpdateApplicationForm_FormClosing(object sender, FormClosingEventArgs e)
{ {
if (client != null) if (client != null) {
{ if (client.IsBusy) {
if (client.IsBusy)
client.CancelAsync(); client.CancelAsync();
}
client.Dispose(); client.Dispose();
} }
client = null; client = null;
if (manifest != null) if (manifest != null) {
{ if (manifest.IsBusy) {
if (manifest.IsBusy)
manifest.CancelAsync(); manifest.CancelAsync();
}
manifest.Dispose(); manifest.Dispose();
} }
manifest = null; manifest = null;
@ -502,9 +483,10 @@ namespace LSLEditor
string strCurrentFile = Assembly.GetExecutingAssembly().Location; string strCurrentFile = Assembly.GetExecutingAssembly().Location;
string strDirectory = Path.GetDirectoryName(strCurrentFile); string strDirectory = Path.GetDirectoryName(strCurrentFile);
string strOldFile = Path.Combine(strDirectory, "_LSLEditor.exe"); string strOldFile = Path.Combine(strDirectory, "_LSLEditor.exe");
if (File.Exists(strOldFile)) if (File.Exists(strOldFile)) {
File.Delete(strOldFile); File.Delete(strOldFile);
}
} }
} }
} }

View file

@ -58,7 +58,7 @@ namespace LSLEditor
private string OwnerName; private string OwnerName;
private SecondLife.key id; private SecondLife.key id;
public llDialogForm(SecondLifeHost host, SecondLife.String strObjectName, SecondLife.key id, SecondLife.String strOwner, SecondLife.String strMessage, SecondLife.list buttons, SecondLife.integer intChannel) public llDialogForm(SecondLifeHost host, SecondLife.String strObjectName, SecondLife.key id, SecondLife.String strOwner, SecondLife.String strMessage, SecondLife.list buttons, SecondLife.integer intChannel)
{ {
InitializeComponent(); InitializeComponent();
@ -68,21 +68,19 @@ namespace LSLEditor
this.ObjectName = strObjectName; this.ObjectName = strObjectName;
this.id = id; this.id = id;
for (int intI = 1; intI <= 12; intI++) for (int intI = 1; intI <= 12; intI++) {
{
Button button = this.Controls["Button" + intI] as Button; Button button = this.Controls["Button" + intI] as Button;
button.Visible = false; button.Visible = false;
} }
this.label1.Text = strOwner + "'s '" + strObjectName +"'"; this.label1.Text = strOwner + "'s '" + strObjectName + "'";
this.label2.Text = strMessage.ToString().Replace("&","&&"); this.label2.Text = strMessage.ToString().Replace("&", "&&");
for (int intI = 1; intI <= buttons.Count; intI++) for (int intI = 1; intI <= buttons.Count; intI++) {
{
Button button = this.Controls["Button" + intI] as Button; Button button = this.Controls["Button" + intI] as Button;
if (button == null) if (button == null)
continue; continue;
button.Text = buttons[intI - 1].ToString().Replace("&","&&"); button.Text = buttons[intI - 1].ToString().Replace("&", "&&");
button.Visible = true; button.Visible = true;
button.Click += new EventHandler(button_Click); button.Click += new EventHandler(button_Click);
} }
@ -91,10 +89,10 @@ namespace LSLEditor
void button_Click(object sender, EventArgs e) void button_Click(object sender, EventArgs e)
{ {
Button button = sender as Button; Button button = sender as Button;
if (button == null) if (button != null) {
return; host.Chat(this, this.Channel, this.OwnerName, this.id, button.Text.Replace("&&", "&"), CommunicationType.Say);
host.Chat(this,this.Channel, this.OwnerName, this.id, button.Text.Replace("&&","&"), CommunicationType.Say); this.Close();
this.Close(); }
} }
private void button13_Click(object sender, EventArgs e) private void button13_Click(object sender, EventArgs e)
@ -102,4 +100,4 @@ namespace LSLEditor
this.Close(); this.Close();
} }
} }
} }

View file

@ -12,40 +12,39 @@ using System.Windows.Forms;
namespace LSLEditor namespace LSLEditor
{ {
public partial class llTextBoxForm : Form public partial class llTextBoxForm : Form
{ {
private SecondLifeHost host; private SecondLifeHost host;
private int Channel; private int Channel;
private string ObjectName; private string ObjectName;
private string OwnerName; private string OwnerName;
private SecondLife.key id; private SecondLife.key id;
public llTextBoxForm(SecondLifeHost host, SecondLife.String strObjectName, SecondLife.key id, SecondLife.String strOwner, SecondLife.String strMessage, SecondLife.integer intChannel) public llTextBoxForm(SecondLifeHost host, SecondLife.String strObjectName, SecondLife.key id, SecondLife.String strOwner, SecondLife.String strMessage, SecondLife.integer intChannel)
{ {
InitializeComponent(); InitializeComponent();
this.host = host; this.host = host;
this.Channel = intChannel; this.Channel = intChannel;
this.OwnerName = strOwner; this.OwnerName = strOwner;
this.ObjectName = strObjectName; this.ObjectName = strObjectName;
this.id = id; this.id = id;
this.label1.Text = strMessage.ToString().Replace("&", "&&"); this.label1.Text = strMessage.ToString().Replace("&", "&&");
} }
private void buttonIgnore_Click(object sender, EventArgs e) private void buttonIgnore_Click(object sender, EventArgs e)
{ {
this.Close();
}
private void buttonOK_Click(object sender, EventArgs e)
{
Button button = sender as Button;
if (button == null)
return;
host.Chat(this,this.Channel, this.OwnerName, this.id, textBox.Text.Replace("&&","&"), CommunicationType.Say);
this.Close(); this.Close();
} }
}
} private void buttonOK_Click(object sender, EventArgs e)
{
Button button = sender as Button;
if (button != null) {
host.Chat(this, this.Channel, this.OwnerName, this.id, textBox.Text.Replace("&&", "&"), CommunicationType.Say);
this.Close();
}
}
}
}