rendered paste bodyusing 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('TOPLEFT',{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('TOPLEFT',{1},{2})", name, x, y));
}
}
public int Y
{
get
{
return y;
}
set
{
y = value;
Game.Instance.WoWScript(string.Format("{0}:SetPoint('TOPLEFT',{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}:SetMovable(true)", Name));
Game.Instance.WoWScript(string.Format("{0}:RegisterForDrag('LeftButton')", Name));
Game.Instance.WoWScript(string.Format("{0}:SetScript('OnDragStart',function() {0}:StartMoving(); end)", Name, Name));
Game.Instance.WoWScript(string.Format("{0}:SetScript('OnDragStop',function() {0}:StopMovingOrSizing(); end)", Name, Name));
Texture = "Interface/DialogFrame/UI-DialogBox-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));
}
}
}
public sealed class MainWindow
{
static readonly MainWindow instance = new MainWindow();
#region Singleton stuff
static MainWindow()
{
}
MainWindow()
{
}
~MainWindow()
{
Hide();
}
public static MainWindow Instance
{
get
{
return instance;
}
}
#endregion
public void Show()
{
LuaWindow mainwindow = new LuaWindow("Main");
mainwindow.Height = 200;
mainwindow.Width = 200;
mainwindow.Show();
mainwindow.X = 50;
mainwindow.Y = -100;
LuaButton bStart = new LuaButton("bStart", "Start", mainwindow);
bStart.LeftClick = "Event[BYTEBOT]:Execute[START]";
bStart.Width = 100;
bStart.Height = 30;
bStart.X = 10;
bStart.Y = -10;
bStart.Show();
LuaButton bStop = new LuaButton("bStop", "Stop", mainwindow);
bStop.LeftClick = "Event[BYTEBOT]:Execute[STOP]";
bStop.Width = 100;
bStop.Height = 30;
bStop.X = 10;
bStop.Y = -55;
bStop.Show();
LuaButton bQuit = new LuaButton("bQuit", "Quit", mainwindow);
bQuit.LeftClick = "Event[BYTEBOT]:Execute[QUIT]";
bQuit.Width = 100;
bQuit.Height = 30;
bQuit.X = 10;
bQuit.Y = -100;
bQuit.Show();
}
public void Hide()
{
LuaWindow mainwindow = new LuaWindow("Main");
mainwindow.Hide();
}
}
}