From: ole1986 Date: Fri, 14 Mar 2014 16:00:03 +0000 (+0100) Subject: ole1986: hook/unhook the "Is Running" and "Is Mono" properly when opening scripts... X-Git-Tag: 2.18~17^2 X-Git-Url: http://git.osdn.net/view?p=radegast%2Fradegast.git;a=commitdiff_plain;h=7e4a39325bd07b9ef130f20dcc557fe5784e30df ole1986: hook/unhook the "Is Running" and "Is Mono" properly when opening scripts from an object --- diff --git a/Radegast/GUI/Consoles/Assets/ScriptEditor.cs b/Radegast/GUI/Consoles/Assets/ScriptEditor.cs index 5a8a6d4..a627d87 100644 --- a/Radegast/GUI/Consoles/Assets/ScriptEditor.cs +++ b/Radegast/GUI/Consoles/Assets/ScriptEditor.cs @@ -87,6 +87,8 @@ namespace Radegast if (prim != null) { client.Assets.RequestInventoryAsset(script.AssetUUID, script.UUID, prim.ID, prim.OwnerID, script.AssetType, true, Assets_OnAssetReceived); + client.Inventory.RequestGetScriptRunning(prim.ID, script.UUID); + client.Inventory.ScriptRunningReply += OnScriptRunningReplyReceived; } else { @@ -103,6 +105,20 @@ namespace Radegast void SscriptEditor_Disposed(object sender, EventArgs e) { + client.Inventory.ScriptRunningReply -= OnScriptRunningReplyReceived; + } + + void OnScriptRunningReplyReceived(object sender, ScriptRunningReplyEventArgs e) + { + if (InvokeRequired) + { + if (!instance.MonoRuntime || IsHandleCreated) + BeginInvoke(new MethodInvoker(() => OnScriptRunningReplyReceived(sender, e))); + return; + } + + cbRunning.Checked = e.IsRunning; + cbMono.Checked = e.IsMono; } void Assets_OnAssetReceived(AssetDownload transfer, Asset asset) @@ -682,63 +698,63 @@ namespace Radegast private void tbtbSave_Click(object sender, EventArgs e) { InventoryManager.ScriptUpdatedCallback handler = (bool uploadSuccess, string uploadStatus, bool compileSuccess, List compileMessages, UUID itemID, UUID assetID) => - { - if (!IsHandleCreated && instance.MonoRuntime) return; + { + if (!IsHandleCreated && instance.MonoRuntime) return; - BeginInvoke(new MethodInvoker(() => + BeginInvoke(new MethodInvoker(() => + { + if (uploadSuccess && compileSuccess) + { + lblScripStatus.Text = "Saved OK"; + } + else + { + if (!compileSuccess) { - if (uploadSuccess && compileSuccess) - { - lblScripStatus.Text = "Saved OK"; - } - else + lblScripStatus.Text = "Compilation failed"; + if (compileMessages != null) { - if (!compileSuccess) + txtStatus.Show(); + txtStatus.Text = string.Empty; + for (int i = 0; i < compileMessages.Count; i++) { - lblScripStatus.Text = "Compilation failed"; - if (compileMessages != null) + Match m = Regex.Match(compileMessages[i], @"\((?\d+),\s*(?\d+)\s*\)\s*:\s*(?\w+)\s*:\s*(?.*)", RegexOptions.IgnoreCase); + + if (m.Success) { - txtStatus.Show(); - txtStatus.Text = string.Empty; - for (int i = 0; i < compileMessages.Count; i++) + int line = 1 + int.Parse(m.Groups["line"].Value, Utils.EnUsCulture); + int column = 1 + int.Parse(m.Groups["column"].Value, Utils.EnUsCulture); + string kind = m.Groups["kind"].Value; + string msg = m.Groups["msg"].Value; + instance.TabConsole.DisplayNotificationInChat( + string.Format("{0} on line {1}, column {2}: {3}", kind, line, column, msg), + ChatBufferTextStyle.Invisible); + txtStatus.Text += string.Format("{0} (Ln {1}, Col {2}): {3}", kind, line, column, msg); + + if (i == 0) { - Match m = Regex.Match(compileMessages[i], @"\((?\d+),\s*(?\d+)\s*\)\s*:\s*(?\w+)\s*:\s*(?.*)", RegexOptions.IgnoreCase); - - if (m.Success) - { - int line = 1 + int.Parse(m.Groups["line"].Value, Utils.EnUsCulture); - int column = 1 + int.Parse(m.Groups["column"].Value, Utils.EnUsCulture); - string kind = m.Groups["kind"].Value; - string msg = m.Groups["msg"].Value; - instance.TabConsole.DisplayNotificationInChat( - string.Format("{0} on line {1}, column {2}: {3}", kind, line, column, msg), - ChatBufferTextStyle.Invisible); - txtStatus.Text += string.Format("{0} (Ln {1}, Col {2}): {3}", kind, line, column, msg); - - if (i == 0) - { - rtb.CursorPosition = new RRichTextBox.CursorLocation(line - 1, column - 1); - ReadCursorPosition(); - rtb.Focus(); - } - } - else - { - txtStatus.Text += compileMessages[i] + Environment.NewLine; - instance.TabConsole.DisplayNotificationInChat(compileMessages[i]); - } + rtb.CursorPosition = new RRichTextBox.CursorLocation(line - 1, column - 1); + ReadCursorPosition(); + rtb.Focus(); } } + else + { + txtStatus.Text += compileMessages[i] + Environment.NewLine; + instance.TabConsole.DisplayNotificationInChat(compileMessages[i]); + } } - else - { - lblScripStatus.Text = rtb.Text = "Failed to download."; - } - } } - )); - }; + else + { + lblScripStatus.Text = rtb.Text = "Failed to download."; + } + + } + } + )); + }; lblScripStatus.Text = "Saving...";