gui.text() - add a 5th parameters "anchor" that will anchor the text to top, left, bottom, or right. Same functionality as the message config anchor option.

This commit is contained in:
adelikat 2012-03-26 02:58:24 +00:00
parent 74648bd806
commit 7daf318134
3 changed files with 26 additions and 12 deletions

View File

@ -347,14 +347,24 @@ namespace BizHawk.MultiClient
//----------------------------------------------------
//Gui library
//----------------------------------------------------
public void gui_text(object luaX, object luaY, object luaStr)
public void gui_text(object luaX, object luaY, object luaStr, object anchor = null)
{
Global.RenderPanel.AddGUIText(luaStr.ToString(), LuaInt(luaX), LuaInt(luaY), false);
gui_text_implementation(LuaVarArgs(luaX, luaY, luaStr, anchor));
}
private void gui_text_implementation(object[] parameters)
{
int anchor;
if (parameters.Length == 3)
anchor = 0;
else
anchor = LuaInt(parameters[3]);
Global.RenderPanel.AddGUIText(parameters[2].ToString(), LuaInt(parameters[0]), LuaInt(parameters[1]), false, anchor);
}
public void gui_alert(object luaX, object luaY, object luaStr)
{
Global.RenderPanel.AddGUIText(luaStr.ToString(), LuaInt(luaX), LuaInt(luaY), true);
Global.RenderPanel.AddGUIText(luaStr.ToString(), LuaInt(luaX), LuaInt(luaY), true, 0);
}
//----------------------------------------------------

View File

@ -115,7 +115,7 @@ namespace BizHawk.MultiClient
void Render(IVideoProvider video);
bool Resized { get; set; }
void AddMessage(string msg);
void AddGUIText(string msg, int x, int y, bool alert);
void AddGUIText(string msg, int x, int y, bool alert, int anchor);
void ClearGUIText();
string FPS { get; set; }
string MT { get; set; }
@ -148,7 +148,7 @@ namespace BizHawk.MultiClient
}
RetainedViewportPanel backingControl;
public void AddMessage(string msg) { }
public void AddGUIText(string msg, int x, int y, bool alert) { }
public void AddGUIText(string msg, int x, int y, bool alert, int anchor) { }
public void ClearGUIText() { }
}
@ -481,9 +481,9 @@ namespace BizHawk.MultiClient
messages.Add(new UIMessage { Message = message, ExpireAt = DateTime.Now + TimeSpan.FromSeconds(2) });
}
public void AddGUIText(string message, int x, int y, bool alert)
public void AddGUIText(string message, int x, int y, bool alert, int anchor)
{
GUITextList.Add(new UIDisplay { Message = message, X = x, Y = y, Alert = alert });
GUITextList.Add(new UIDisplay { Message = message, X = x, Y = y, Alert = alert, Anchor = anchor});
}
public void ClearGUIText()
@ -505,17 +505,20 @@ namespace BizHawk.MultiClient
}
for (int x = 0; x < GUITextList.Count; x++)
{
int posx = GetX(GUITextList[x].X, GUITextList[x].Anchor);
int posy = GetX(GUITextList[x].X, GUITextList[x].Anchor);
MessageFont.DrawString(null, GUITextList[x].Message,
GUITextList[x].X + 2, GUITextList[x].Y + 2, Color.Black);
posx + 2, posy + 2, Color.Black);
MessageFont.DrawString(null, GUITextList[x].Message,
GUITextList[x].X + 1, GUITextList[x].Y + 1, Color.Gray);
posx + 1, posy + 1, Color.Gray);
if (GUITextList[x].Alert)
MessageFont.DrawString(null, GUITextList[x].Message,
GUITextList[x].X, GUITextList[x].Y, Color.FromArgb(Global.Config.AlertMessageColor));
posx, posy, Color.FromArgb(Global.Config.AlertMessageColor));
else
MessageFont.DrawString(null, GUITextList[x].Message,
GUITextList[x].X, GUITextList[x].Y, Color.FromArgb(Global.Config.MessagesColor));
posx, posy, Color.FromArgb(Global.Config.MessagesColor));
}
}
@ -565,5 +568,6 @@ namespace BizHawk.MultiClient
public int X;
public int Y;
public bool Alert;
public int Anchor;
}
}

View File

@ -80,7 +80,7 @@ namespace BizHawk.MultiClient
{
bool alert = Global.CheatList.IsActiveCheat(Domain, watchList[x].address);
Global.RenderPanel.AddGUIText(watchList[x].ToString(),
Global.Config.DispRamWatchx, (Global.Config.DispRamWatchy + (x * 12)), alert);
Global.Config.DispRamWatchx, (Global.Config.DispRamWatchy + (x * 12)), alert, 0);
}
}