Add a GUITextList class and methods to RenderPanel, similar behavior to AddMessage except that the x,y can be set, and duration has no time limit (and should be handled by the caller). The intent is for an on screen Ram Watch feature, and eventually a way to do the Lua function gui.text()

This commit is contained in:
andres.delikat 2011-09-11 23:31:46 +00:00
parent 8ee8711b1a
commit 7db54e08a8
1 changed files with 30 additions and 0 deletions

View File

@ -111,6 +111,8 @@ namespace BizHawk.MultiClient
void Render(IVideoProvider video);
bool Resized { get; set; }
void AddMessage(string msg);
void AddGUIText(string msg, int x, int y);
void ClearGUIText();
string FPS { get; set; }
string MT { get; set; }
}
@ -142,6 +144,8 @@ namespace BizHawk.MultiClient
}
RetainedViewportPanel backingControl;
public void AddMessage(string msg) { }
public void AddGUIText(string msg, int x, int y) { }
public void ClearGUIText() { }
}
@ -466,12 +470,23 @@ namespace BizHawk.MultiClient
}
private List<UIMessage> messages = new List<UIMessage>(5);
private List<UIDisplay> GUITextList = new List<UIDisplay>();
public void AddMessage(string message)
{
messages.Add(new UIMessage { Message = message, ExpireAt = DateTime.Now + TimeSpan.FromSeconds(2) });
}
public void AddGUIText(string message, int x, int y)
{
GUITextList.Add(new UIDisplay { Message = message, X = x, Y = y });
}
public void ClearGUIText()
{
GUITextList.Clear();
}
private void DrawMessages()
{
messages.RemoveAll(m => DateTime.Now > m.ExpireAt);
@ -484,6 +499,13 @@ namespace BizHawk.MultiClient
MessageFont.DrawString(null, messages[i].Message, x + 2, y + 2, Color.Black);
MessageFont.DrawString(null, messages[i].Message, x, y, Color.FromArgb(Global.Config.MessagesColor));
}
for (int x = 0; x < GUITextList.Count; x++)
{
MessageFont.DrawString(null, GUITextList[x].Message,
GUITextList[x].X + 2, GUITextList[x].Y + 2, Color.Black);
MessageFont.DrawString(null, GUITextList[x].Message,
GUITextList[x].X, GUITextList[x].Y, Color.FromArgb(Global.Config.MessagesColor));
}
}
private bool disposed;
@ -523,4 +545,12 @@ namespace BizHawk.MultiClient
public string Message;
public DateTime ExpireAt;
}
class UIDisplay
{
public string Message;
public DateTime ExpireAt;
public int X;
public int Y;
}
}