// $Id$
//
using System;
+using OpenMetaverse;
namespace Radegast
{
public class ChatBufferItem
{
private DateTime timestamp;
+ private string from;
+ private UUID id;
private string text;
private ChatBufferTextStyle style;
+ private ChatEventArgs rawMessage;
public ChatBufferItem()
{
}
- public ChatBufferItem(DateTime timestamp, string text, ChatBufferTextStyle style)
+ public ChatBufferItem(DateTime timestamp, string from, UUID id, string text, ChatBufferTextStyle style)
{
this.timestamp = timestamp;
this.text = text;
set { timestamp = value; }
}
+ public string From
+ {
+ get { return from; }
+ set { from = value; }
+ }
+
+ public UUID ID
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
public string Text
{
get { return text; }
get { return style; }
set { style = value; }
}
+
+ public ChatEventArgs RawMessage
+ {
+ get { return rawMessage; }
+ set { rawMessage = value; }
+ }
}
public enum ChatBufferTextStyle
{
public class ChatTextManager : IDisposable
{
+ public event EventHandler<ChatLineAddedArgs> ChatLineAdded;
+
private RadegastInstance instance;
private RadegastNetcom netcom { get { return instance.Netcom; } }
private GridClient client { get { return instance.Client; } }
if (e.Message.ToLower().Contains("autopilot canceled")) return; //workaround the stupid autopilot alerts
ChatBufferItem item = new ChatBufferItem(
- DateTime.Now, "Alert message: " + e.Message, ChatBufferTextStyle.Alert);
+ DateTime.Now, "Alert message", UUID.Zero, ": " + e.Message, ChatBufferTextStyle.Alert);
ProcessBufferItem(item, true);
}
public void PrintStartupMessage()
{
ChatBufferItem title = new ChatBufferItem(
- DateTime.Now, Properties.Resources.RadegastTitle + "." + RadegastBuild.CurrentRev, ChatBufferTextStyle.StartupTitle);
+ DateTime.Now, "", UUID.Zero, Properties.Resources.RadegastTitle + "." + RadegastBuild.CurrentRev, ChatBufferTextStyle.StartupTitle);
ChatBufferItem ready = new ChatBufferItem(
- DateTime.Now, "Ready.", ChatBufferTextStyle.StatusBlue);
+ DateTime.Now, "", UUID.Zero, "Ready.", ChatBufferTextStyle.StatusBlue);
ProcessBufferItem(title, true);
ProcessBufferItem(ready, true);
public void ProcessBufferItem(ChatBufferItem item, bool addToBuffer)
{
+ if (ChatLineAdded != null)
+ {
+ ChatLineAdded(this, new ChatLineAddedArgs(item));
+ }
+
lock (SyncChat)
{
instance.LogClientMessage("chat.txt", item.Text);
break;
}
- textPrinter.PrintTextLine(item.Text);
+ textPrinter.PrintTextLine(item.From + item.Text);
}
}
{
StringBuilder sb = new StringBuilder();
- sb.AppendFormat("(channel {0}) {1}", e.Channel, client.Self.Name);
-
switch (e.Type)
{
case ChatType.Normal:
sb.Append(e.Message);
ChatBufferItem item = new ChatBufferItem(
- DateTime.Now, sb.ToString(), ChatBufferTextStyle.StatusDarkBlue);
+ DateTime.Now, string.Format("(channel {0}) {1}", e.Channel, client.Self.Name), client.Self.AgentID, sb.ToString(), ChatBufferTextStyle.StatusDarkBlue);
ProcessBufferItem(item, true);
#endif
}
+ ChatBufferItem item = new ChatBufferItem();
+ item.ID = e.SourceID;
+ item.RawMessage = e;
StringBuilder sb = new StringBuilder();
- // if (e.SourceType == ChatSourceType.Object) {
- // sb.Append(e.Position + " ");
- // }
+
if (e.SourceType == ChatSourceType.Agent)
{
- sb.Append(instance.Names.Get(e.SourceID, e.FromName));
+ item.From = instance.Names.Get(e.SourceID, e.FromName);
}
else
{
- sb.Append(e.FromName);
+ item.From = e.FromName;
}
bool isEmote = e.Message.ToLower().StartsWith("/me ");
sb.Append(e.Message);
}
- ChatBufferItem item = new ChatBufferItem();
item.Timestamp = DateTime.Now;
item.Text = sb.ToString();
set { textPrinter = value; }
}
}
+
+ public class ChatLineAddedArgs : EventArgs
+ {
+ ChatBufferItem mItem;
+
+ public ChatLineAddedArgs(ChatBufferItem item)
+ {
+ mItem = item;
+ }
+ }
}
ProcessChatInput(cbxInput.Text, ChatType.Normal);
}
- private void ProcessChatInput(string input, ChatType type)
+ public void ProcessChatInput(string input, ChatType type)
{
if (string.IsNullOrEmpty(input)) return;
chatHistory.Add(input);
private GridClient client { get { return instance.Client; } }
private RadegastNetcom netcom { get { return instance.Netcom; } }
private ChatTextManager mainChatManger;
+ public ChatTextManager MainChatManger { get { return mainChatManger; } }
private Dictionary<string, RadegastTab> tabs = new Dictionary<string, RadegastTab>();
public Dictionary<string, RadegastTab> Tabs { get { return tabs; } }
{
ChatBufferItem line = new ChatBufferItem(
DateTime.Now,
+ string.Empty,
+ UUID.Zero,
msg,
style
);
--- /dev/null
+//
+// Radegast Metaverse Client
+// Copyright (c) 2009-2011, Radegast Development Team
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of the application "Radegast", nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// $Id$
+//
+
+using System;
+using System.Windows.Forms;
+
+namespace Radegast.Rendering
+{
+ public class ChatBox : TextBox
+ {
+ }
+}
--- /dev/null
+//
+// Radegast Metaverse Client
+// Copyright (c) 2009-2011, Radegast Development Team
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice,
+// this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of the application "Radegast", nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// $Id$
+//
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Drawing;
+
+namespace Radegast.Rendering
+{
+ public class ChatOverlay : IDisposable
+ {
+ RadegastInstance Instance;
+ SceneWindow Window;
+ float runningTime;
+
+ public ChatOverlay(RadegastInstance instance, SceneWindow window)
+ {
+ this.Instance = instance;
+ this.Window = window;
+ Instance.TabConsole.MainChatManger.ChatLineAdded += new EventHandler<ChatLineAddedArgs>(MainChatManger_ChatLineAdded);
+ }
+
+ public void Dispose()
+ {
+ Instance.TabConsole.MainChatManger.ChatLineAdded -= new EventHandler<ChatLineAddedArgs>(MainChatManger_ChatLineAdded);
+ }
+
+ void MainChatManger_ChatLineAdded(object sender, ChatLineAddedArgs e)
+ {
+ }
+
+ public void RenderChat(float time)
+ {
+ runningTime += time;
+ }
+ }
+}
this.cbAA = new System.Windows.Forms.CheckBox();\r
this.chkWireFrame = new System.Windows.Forms.CheckBox();\r
this.ctxMenu = new System.Windows.Forms.ContextMenuStrip(this.components);\r
+ this.pnlChat = new System.Windows.Forms.Panel();\r
+ this.cbChatType = new System.Windows.Forms.ComboBox();\r
+ this.btnSay = new System.Windows.Forms.Button();\r
+ this.txtChat = new Radegast.Rendering.ChatBox();\r
this.pnlDebug.SuspendLayout();\r
((System.ComponentModel.ISupportInitialize)(this.tbDrawDistance)).BeginInit();\r
+ this.pnlChat.SuspendLayout();\r
this.SuspendLayout();\r
// \r
// pnlDebug\r
this.ctxMenu.Size = new System.Drawing.Size(61, 4);\r
this.ctxMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ctxObjects_Opening);\r
// \r
+ // pnlChat\r
+ // \r
+ this.pnlChat.Controls.Add(this.cbChatType);\r
+ this.pnlChat.Controls.Add(this.btnSay);\r
+ this.pnlChat.Controls.Add(this.txtChat);\r
+ this.pnlChat.Dock = System.Windows.Forms.DockStyle.Bottom;\r
+ this.pnlChat.Location = new System.Drawing.Point(0, 314);\r
+ this.pnlChat.Name = "pnlChat";\r
+ this.pnlChat.Size = new System.Drawing.Size(779, 23);\r
+ this.pnlChat.TabIndex = 9;\r
+ // \r
+ // cbChatType\r
+ // \r
+ this.cbChatType.AccessibleName = "Chat type";\r
+ this.cbChatType.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\r
+ this.cbChatType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;\r
+ this.cbChatType.Enabled = false;\r
+ this.cbChatType.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\r
+ this.cbChatType.FormattingEnabled = true;\r
+ this.cbChatType.Items.AddRange(new object[] {\r
+ "Whisper",\r
+ "Normal",\r
+ "Shout"});\r
+ this.cbChatType.Location = new System.Drawing.Point(700, 0);\r
+ this.cbChatType.Name = "cbChatType";\r
+ this.cbChatType.Size = new System.Drawing.Size(73, 21);\r
+ this.cbChatType.TabIndex = 2;\r
+ // \r
+ // btnSay\r
+ // \r
+ this.btnSay.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));\r
+ this.btnSay.Enabled = false;\r
+ this.btnSay.FlatAppearance.BorderSize = 0;\r
+ this.btnSay.FlatStyle = System.Windows.Forms.FlatStyle.Flat;\r
+ this.btnSay.Location = new System.Drawing.Point(650, 0);\r
+ this.btnSay.Name = "btnSay";\r
+ this.btnSay.Size = new System.Drawing.Size(50, 22);\r
+ this.btnSay.TabIndex = 1;\r
+ this.btnSay.Text = "Say";\r
+ this.btnSay.UseVisualStyleBackColor = true;\r
+ this.btnSay.Click += new System.EventHandler(this.btnSay_Click);\r
+ // \r
+ // txtChat\r
+ // \r
+ this.txtChat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)\r
+ | System.Windows.Forms.AnchorStyles.Right)));\r
+ this.txtChat.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;\r
+ this.txtChat.Location = new System.Drawing.Point(0, 1);\r
+ this.txtChat.Name = "txtChat";\r
+ this.txtChat.Size = new System.Drawing.Size(650, 20);\r
+ this.txtChat.TabIndex = 0;\r
+ this.txtChat.TextChanged += new System.EventHandler(this.txtChat_TextChanged);\r
+ this.txtChat.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtChat_KeyDown);\r
+ // \r
// SceneWindow\r
// \r
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
+ this.Controls.Add(this.pnlChat);\r
this.Controls.Add(this.pnlDebug);\r
this.Name = "SceneWindow";\r
this.Size = new System.Drawing.Size(779, 500);\r
this.pnlDebug.ResumeLayout(false);\r
this.pnlDebug.PerformLayout();\r
((System.ComponentModel.ISupportInitialize)(this.tbDrawDistance)).EndInit();\r
+ this.pnlChat.ResumeLayout(false);\r
+ this.pnlChat.PerformLayout();\r
this.ResumeLayout(false);\r
\r
}\r
public System.Windows.Forms.CheckBox chkWireFrame;\r
public System.Windows.Forms.Button btnResetView;\r
public System.Windows.Forms.Label label2;\r
- private System.Windows.Forms.HScrollBar hsSpecular;\r
- private System.Windows.Forms.HScrollBar hsDiffuse;\r
- private System.Windows.Forms.HScrollBar hsAmbient;\r
- private System.Windows.Forms.HScrollBar hsLOD;\r
- private System.Windows.Forms.Button button_vparam;\r
- private System.Windows.Forms.TextBox textBox_x;\r
- private System.Windows.Forms.ComboBox comboBox1;\r
- private System.Windows.Forms.TextBox textBox_z;\r
- private System.Windows.Forms.TextBox textBox_y;\r
- private System.Windows.Forms.Label label4;\r
- private System.Windows.Forms.TextBox textBox_sx;\r
- private System.Windows.Forms.Label label3;\r
- private System.Windows.Forms.Label label1;\r
- private System.Windows.Forms.TextBox textBox_sz;\r
- private System.Windows.Forms.TextBox textBox_sy;\r
- private System.Windows.Forms.Button button1;\r
- private System.Windows.Forms.TextBox textBox_morphamount;\r
- private System.Windows.Forms.Label label5;\r
- private System.Windows.Forms.ComboBox comboBox_morph;\r
- private System.Windows.Forms.Button button_driver;\r
- private System.Windows.Forms.TextBox textBox_driveramount;\r
- private System.Windows.Forms.Label label6;\r
- private System.Windows.Forms.ComboBox comboBox_driver;\r
- private System.Windows.Forms.TrackBar tbDrawDistance;\r
- private System.Windows.Forms.Label lblDrawDistance;\r
- private System.Windows.Forms.CheckBox cbMisc;\r
+ public System.Windows.Forms.Panel pnlChat;\r
+ public Radegast.Rendering.ChatBox txtChat;\r
+ public System.Windows.Forms.HScrollBar hsSpecular;\r
+ public System.Windows.Forms.HScrollBar hsDiffuse;\r
+ public System.Windows.Forms.HScrollBar hsAmbient;\r
+ public System.Windows.Forms.HScrollBar hsLOD;\r
+ public System.Windows.Forms.Button button_vparam;\r
+ public System.Windows.Forms.TextBox textBox_x;\r
+ public System.Windows.Forms.ComboBox comboBox1;\r
+ public System.Windows.Forms.TextBox textBox_z;\r
+ public System.Windows.Forms.TextBox textBox_y;\r
+ public System.Windows.Forms.Label label4;\r
+ public System.Windows.Forms.TextBox textBox_sx;\r
+ public System.Windows.Forms.Label label3;\r
+ public System.Windows.Forms.Label label1;\r
+ public System.Windows.Forms.TextBox textBox_sz;\r
+ public System.Windows.Forms.TextBox textBox_sy;\r
+ public System.Windows.Forms.Button button1;\r
+ public System.Windows.Forms.TextBox textBox_morphamount;\r
+ public System.Windows.Forms.Label label5;\r
+ public System.Windows.Forms.ComboBox comboBox_morph;\r
+ public System.Windows.Forms.Button button_driver;\r
+ public System.Windows.Forms.TextBox textBox_driveramount;\r
+ public System.Windows.Forms.Label label6;\r
+ public System.Windows.Forms.ComboBox comboBox_driver;\r
+ public System.Windows.Forms.TrackBar tbDrawDistance;\r
+ public System.Windows.Forms.Label lblDrawDistance;\r
+ public System.Windows.Forms.CheckBox cbMisc;\r
+ public System.Windows.Forms.Button btnSay;\r
+ public System.Windows.Forms.ComboBox cbChatType;\r
\r
}\r
}\r
/// </summary>\r
public bool CacheDecodedTextures = false;\r
\r
+ /// <summary>\r
+ /// Size of OpenGL window we're drawing on\r
+ /// </summary>\r
+ int[] Viewport = new int[4];\r
+\r
#endregion Public fields\r
\r
#region Private fields\r
\r
+ ChatOverlay chatOverlay;\r
Camera Camera;\r
SceneObject trackedObject;\r
Vector3 lastTrackedObjectPos = RHelp.InvalidPosition;\r
Dictionary<UUID, Bitmap> sculptCache = new Dictionary<UUID, Bitmap>();\r
OpenTK.Matrix4 ModelMatrix;\r
OpenTK.Matrix4 ProjectionMatrix;\r
- int[] Viewport = new int[4];\r
System.Diagnostics.Stopwatch renderTimer;\r
float lastFrameTime = 0f;\r
float advTimerTick = 0f;\r
InitCamera();\r
SetWaterPlanes();\r
\r
+ chatOverlay = new ChatOverlay(instance, this);\r
+ cbChatType.SelectedIndex = 1;\r
+\r
tbDrawDistance.Value = (int)DrawDistance;\r
lblDrawDistance.Text = string.Format("Draw distance: {0}", tbDrawDistance.Value);\r
pnlDebug.Visible = Instance.GlobalSettings["scene_viewer_debug_panel"];\r
\r
PendingTextures.Close();\r
\r
+ if (chatOverlay != null)\r
+ {\r
+ chatOverlay.Dispose();\r
+ chatOverlay = null;\r
+ }\r
+\r
Client.Objects.TerseObjectUpdate -= new EventHandler<TerseObjectUpdateEventArgs>(Objects_TerseObjectUpdate);\r
Client.Objects.ObjectUpdate -= new EventHandler<PrimEventArgs>(Objects_ObjectUpdate);\r
Client.Objects.ObjectDataBlockUpdate -= new EventHandler<ObjectDataBlockUpdateEventArgs>(Objects_ObjectDataBlockUpdate);\r
GLHUDBegin();\r
RenderText(RenderPass.Simple);\r
RenderStats();\r
+ chatOverlay.RenderChat(lastFrameTime);\r
GLHUDEnd();\r
GL.Disable(EnableCap.Blend);\r
}\r
}\r
\r
#endregion\r
+\r
+ private void txtChat_TextChanged(object sender, EventArgs e)\r
+ {\r
+ if (txtChat.Text.Length > 0)\r
+ {\r
+ btnSay.Enabled = cbChatType.Enabled = true;\r
+ if (!txtChat.Text.StartsWith("/"))\r
+ {\r
+ if (!Instance.State.IsTyping && !Instance.GlobalSettings["no_typing_anim"])\r
+ {\r
+ Instance.State.SetTyping(true);\r
+ }\r
+ }\r
+ }\r
+ else\r
+ {\r
+ btnSay.Enabled = cbChatType.Enabled = false;\r
+ if (!Instance.GlobalSettings["no_typing_anim"])\r
+ {\r
+ Instance.State.SetTyping(false);\r
+ }\r
+ }\r
+ }\r
+\r
+ private void txtChat_KeyDown(object sender, KeyEventArgs e)\r
+ {\r
+ if (e.KeyCode != Keys.Enter) return;\r
+ e.Handled = e.SuppressKeyPress = true;\r
+ ChatConsole chat = (ChatConsole)Instance.TabConsole.Tabs["chat"].Control;\r
+ \r
+ if (e.Shift)\r
+ chat.ProcessChatInput(txtChat.Text, ChatType.Whisper);\r
+ else if (e.Control)\r
+ chat.ProcessChatInput(txtChat.Text, ChatType.Shout);\r
+ else\r
+ chat.ProcessChatInput(txtChat.Text, ChatType.Normal);\r
+\r
+ txtChat.Text = string.Empty;\r
+ }\r
+\r
+ private void btnSay_Click(object sender, EventArgs e)\r
+ {\r
+ ChatConsole chat = (ChatConsole)Instance.TabConsole.Tabs["chat"].Control;\r
+ chat.ProcessChatInput(txtChat.Text, (ChatType)cbChatType.SelectedIndex);\r
+ txtChat.Select();\r
+ txtChat.Text = string.Empty;\r
+ }\r
}\r
}\r
<Compile Include="GUI\Notifications\TeleportNotification.Designer.cs">\r
<DependentUpon>TeleportNotification.cs</DependentUpon>\r
</Compile>\r
+ <Compile Include="GUI\Rendering\ChatBox.cs">\r
+ <SubType>Component</SubType>\r
+ </Compile>\r
+ <Compile Include="GUI\Rendering\ChatOverlay.cs" />\r
<Compile Include="GUI\Rendering\Compat.cs" />\r
<Compile Include="GUI\Rendering\Frustum.cs" />\r
<Compile Include="GUI\Rendering\ImageUtils.cs" />\r