using System; using System.Collections.Generic; using System.Text; namespace Bytebot { public class LuaFrame { private string texture = null; private string name = null; private string type = null; private string parent = null; private string template = null; private int width = 10; private int height = 10; private int x = 0; private int y = 0; public LuaFrame(string Name, string Type, string Parent, string Template) { name = Name; type = Type; parent = Parent; template = Template; if (template != "") { Game.Instance.WoWScript(string.Format("{0} = CreateFrame('{1}',nil,{2},'{3}')", name, type, parent, template)); } else { Game.Instance.WoWScript(string.Format("{0} = CreateFrame('{1}',nil,{2})", name, type, parent)); } Game.Instance.WoWScript(string.Format("{0}:SetFrameStrata('BACKGROUND')",name)); Game.Instance.WoWScript(string.Format("{0}:SetPoint('CENTER',{1},{2})", name, x, y)); Game.Instance.WoWScript(string.Format("t_{0} = {1}:CreateTexture(nil,'BACKGROUND')", Name, Name)); } ~LuaFrame() { Hide(); } public string Name { get { return name; } } public int X { get { return x; } set { x = value; Game.Instance.WoWScript(string.Format("{0}:SetPoint('CENTER',{1},{2})", name, x, y)); } } public int Y { get { return y; } set { y = value; Game.Instance.WoWScript(string.Format("{0}:SetPoint('CENTER',{1},{2})", name, x, y)); } } public string Texture { get { return texture; } set { texture = value; Game.Instance.WoWScript(string.Format("t_{0}:SetTexture('{1}')", name, texture)); Game.Instance.WoWScript(string.Format("t_{0}:SetAllPoints('{1}')", name, name)); Game.Instance.WoWScript(string.Format("{0}.texture = t_{1}", name, name)); } } public int Width { get { return width; } set { width = value; Game.Instance.WoWScript(string.Format("{0}:SetWidth({1})", name, width)); } } public int Height { get { return height; } set { height = value; Game.Instance.WoWScript(string.Format("{0}:SetHeight({1})", name, height)); } } public void Hide() { Game.Instance.WoWScript(string.Format("{0}:Hide()",name)); } public void Show() { Game.Instance.WoWScript(string.Format("{0}:Show()",name)); } } public class LuaWindow : LuaFrame { public LuaWindow(string Name) : base(Name, "Frame", "UIParent", "") { Game.Instance.WoWScript(string.Format("{0}:RegisterForDrag('LeftButton')", Name)); Game.Instance.WoWScript(string.Format("{0}:SetMovable(true)", Name)); Texture = "Interface/Tooltips/UI-Tooltip-Background"; } } public class LuaButton : LuaFrame { private string text = null; private string leftclick = null; public LuaButton(string Name, string Text, LuaWindow Parent) : base(Name, "Button", Parent.Name, "UIPanelButtonTemplate") { Game.Instance.WoWScript(string.Format("{0}:SetFrameStrata('HIGH')", Name)); this.Text = Text; } public string LeftClick { get { return leftclick; } set { leftclick = value; Game.Instance.WoWScript(string.Format("{0}:SetScript('OnClick',function() ISCommand('{1}') end)", Name, leftclick)); } } public string Text { get { return text; } set { text = value; Game.Instance.WoWScript(string.Format("{0}:SetText('{1}')", Name,text)); } } } }