You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bastion/ui.lua

301 lines
12 KiB

local Tinkr, Bastion = ...
--local Common = Tinkr.Common
--local Exports = Tinkr:require('Routine.Modules.Exports')
local Command = Tinkr.Util.Commands:New('rex')
--local OM = Tinkr.Util.ObjectManager
--UI Co-ordinates
local GUI = { points = {"CENTER"}, }
local SETTINGS = { points = {"CENTER"}, }
local ESP = { points = {"CENTER"}, }
local BUTTONS = { points = {"CENTER"}, }
Tinkr:require('scripts.bastion.libs.LibStub.LibStub', Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.StdUi", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.StdUiConfig", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.StdUiPosition", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.StdUiUtil", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.StdUiLayout", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.StdUiGrid", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.StdUiBuilder", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.StdUiBuilder", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.Basic", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.Window", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.Button", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.EditBox", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.CheckBox", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.Dropdown", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.Autocomplete", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.Label", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.Scroll", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.ScrollTable", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.Slider", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.Tooltip", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.Table", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.ProgressBar", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.ColorPicker", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.Tab", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.Spell", Bastion)
Tinkr:require("scripts.bastion.libs.StdUi.widgets.ContextMenu", Bastion)
-- Class colours
-- Death Knight 0.77 0.12 0.23 Red
-- Demon Hunter 0.64 0.19 0.79 Dark Magenta
-- Druid 1.00 0.49 0.04 Orange
-- Hunter 0.67 0.83 0.45 Green
-- Mage 0.25 0.78 0.92 Light Blue
-- Monk 0.00 1.00 0.60 Spring Green
-- Paladin 0.96 0.55 0.73 Pink
-- Priest 1.00 1.00 1.00 White
-- Rogue 1.00 0.96 0.41 Yellow
-- Shaman 0.00 0.44 0.87 Blue
-- Warlock 0.53 0.53 0.93 Purple
-- Warrior 0.78 0.61 0.43 Tan
--Initial Frame Setup
function Bastion.setupsettingsframe(config, title, width, height, newr, newg, newb)
local StdUi = LibStub('StdUi'):NewInstance()
StdUi.config = {
font = {
family = 'GameFontNormal',
size = 10,
titleSize = 12,
effect = 'NONE',
strata = 'OVERLAY',
color = {
normal = { r = 1, g = 1, b = 1, a = 1 },
disabled = { r = 0.55, g = 0.55, b = 0.55, a = 1 },
header = { r = newr, g = newg, b = newb, a = 1 },
}
},
backdrop = {
texture = [[Interface\Buttons\WHITE8X8]],
panel = { r = 0.0588, g = 0.0588, b = 0, a = 0.8 },
slider = { r = newr, g = newg, b = newb, a = 1 },
highlight = { r = 0.40, g = 0.40, b = 0.40, a = 0.5 },
button = { r = 0.20, g = 0.20, b = 0.20, a = 1 },
buttonDisabled = { r = 0.15, g = 0.15, b = 0.15, a = 1 },
border = { r = 0.00, g = 0.00, b = 0.00, a = 1 },
borderDisabled = { r = 0.40, g = 0.40, b = 0.40, a = 1 }
},
progressBar = { color = { r = newr, g = newg, b = newb, a = 0.5 }, },
highlight = {
color = { r = newr, g = newg, b = newb, a = 0.4 },
blank = { r = 0, g = 0, b = 0, a = 0 }
},
dialog = {
width = 400,
height = 100,
button = {
width = 100,
height = 20,
margin = 5
}
},
tooltip = { padding = 10 }
}
local settingsframe = StdUi:Window(UIParent, width, height, title)
settingsframe:Hide()
settingsframe:SetPoint(SETTINGS.points[1], SETTINGS.points[2], SETTINGS.points[3], SETTINGS.points[4], SETTINGS.points[5])
--settingsframe:SetFont(StdUi.config.font.family,StdUi.config.font.titleSize)
StdUi:BuildWindow(settingsframe, config)
StdUi:EasyLayout(settingsframe, { padding = { top = 40 } })
settingsframe:SetScript("OnMouseUp", function(self)
self:StopMovingOrSizing()
local a,b,c,d,e = self:GetPoint()
SETTINGS.points = {a, nil, c, d, e}
end)
--Main Menu (Settings, Enable Rotation, ESP, Buttons)
_G.buttons = {}
local enabled = false
local espenabled = false
local espunitsenabled = false
local espobjectsenabled = false
buttons.aoeenabled = false
buttons.buffsenabled = false
buttons.cooldownsenabled = false
buttons.dispelenabled = false
buttons.dpsenabled = false
buttons.healenabled = false
buttons.rotationenabled = false
local mainmenu = StdUi:Window(nil, 150, 310, title)
mainmenu:Hide()
mainmenu:SetPoint(GUI.points[1], GUI.points[2], GUI.points[3], GUI.points[4], GUI.points[5])
--mainmenu:SetFont(StdUi.config.font.family,StdUi.config.font.titleSize)
mainmenu:SetUserPlaced(true)
local aoebutton = StdUi:HighlightButton(mainmenu, 130, 20, 'AOE')
StdUi:GlueTop(aoebutton, mainmenu, 10, -40, 'LEFT')
local buffsbutton = StdUi:HighlightButton(mainmenu, 130, 20, 'Buffs')
StdUi:GlueTop(buffsbutton, aoebutton, 0, -30, 'LEFT')
local cooldownsbutton = StdUi:HighlightButton(mainmenu, 130, 20, 'Cooldowns')
StdUi:GlueTop(cooldownsbutton, buffsbutton, 0, -30, 'LEFT')
local dispelbutton = StdUi:HighlightButton(mainmenu, 130, 20, 'Dispel')
StdUi:GlueTop(dispelbutton, cooldownsbutton, 0, -30, 'LEFT')
local dpsbutton = StdUi:HighlightButton(mainmenu, 130, 20, 'DPS')
StdUi:GlueTop(dpsbutton, dispelbutton, 0, -30, 'LEFT')
local healbutton = StdUi:HighlightButton(mainmenu, 130, 20, 'Heal')
StdUi:GlueTop(healbutton, dpsbutton, 0, -30, 'LEFT')
local enablebutton = StdUi:HighlightButton(mainmenu, 130, 20, 'Rotation')
StdUi:GlueTop(enablebutton, healbutton, 0, -30, 'LEFT')
local espbutton = StdUi:Button(mainmenu, 130, 20, 'Open ESP')
StdUi:GlueTop(espbutton, enablebutton, 0, -30, 'LEFT')
local settingsbutton = StdUi:Button(mainmenu, 130, 20, 'Settings')
StdUi:GlueTop(settingsbutton, espbutton, 0, -30, 'LEFT')
mainmenu:SetScript("OnMouseUp", function(self)
self:StopMovingOrSizing()
local a,b,c,d,e = self:GetPoint()
GUI.points = {a, nil, c, d, e}
end)
--ESP Menu
local espmenu = StdUi:Window(nil, 200, 140, 'ESP Settings')
espmenu:Hide()
espmenu:SetPoint(ESP.points[1], ESP.points[2], ESP.points[3], ESP.points[4], ESP.points[5])
--espmenu:SetFont(StdUi.config.font.family,StdUi.config.font.titleSize)
espmenu:SetUserPlaced(true)
local enableespcheck = StdUi:Button(espmenu, 180, 20, 'Enable/Disable ESP');
StdUi:GlueTop(enableespcheck, espmenu, 10, -40, 'LEFT');
local espunitscheck = StdUi:Button(espmenu, 180, 20, 'Show Units');
StdUi:GlueTop(espunitscheck, enableespcheck, 0, -30, 'LEFT');
local espobjectscheck = StdUi:Button(espmenu, 180, 20, 'Show Objects');
StdUi:GlueTop(espobjectscheck, espunitscheck, 0, -30, 'LEFT');
espmenu:SetScript("OnMouseUp", function(self)
self:StopMovingOrSizing()
local a,b,c,d,e = self:GetPoint()
ESP.points = {a, nil, c, d, e}
end)
--Open/Hide Settings Window OnClick
settingsbutton:SetScript('OnClick', function ()
if settingsframe:IsShown() then
settingsframe:Hide()
else
settingsframe:Show()
end
end)
--Enable/Disable Rotation OnClick
enablebutton:SetScript('OnClick', function ()
if enabled == false then
Eval('RunMacroText("/bastion toggle")', 'bastion')
enabled = true
elseif enabled == true then
Eval('RunMacroText("/bastion toggle")', 'bastion')
enabled = false
end
end)
--Open/Hide ESP Window OnClick
espbutton:SetScript('OnClick', function ()
if espmenu:IsShown() then
espmenu:Hide()
else
espmenu:Show()
end
end)
--Enable/Disable ESP Draw OnClick
enableespcheck:SetScript('OnClick', function ()
if espenabled == false then
rexesp('enable', nil, nil)
espenabled = true
elseif espenabled == true then
rexesp('disable', nil, nil)
espenabled = false
end
end)
--Enable/Disable ESP Units OnClick
espunitscheck:SetScript('OnClick', function ()
if espunitsenabled == false then
rexesp(nil, 'unitenable', nil)
espunitsenabled = true
end
end)
--Enable/Disable ESP Objects OnClick
espobjectscheck:SetScript('OnClick', function ()
if espobjectsenabled == false then
rexesp(nil, nil, 'objectenable')
espobjectsenabled = true
end
end)
--Enable/Disable AOE Button OnClick
aoebutton:SetScript('OnClick', function()
if buttons.aoeenabled == false then
cooldownsbutton:LockHighlight()
buttons.aoeenabled = true
elseif buttons.aoeenabled == true then
cooldownsbutton:UnlockHighlight()
buttons.aoeenabled = false
end
end)
--Enable/Disable Buffs Button OnClick
buffsbutton:SetScript('OnClick', function()
if buttons.buffsenabled == false then
buffsbutton:LockHighlight()
buttons.buffsenabled = true
elseif buttons.buffsenabled == true then
buffsbutton:UnlockHighlight()
buttons.buffsenabled = false
end
end)
--Enable/Disable Cooldown Button OnClick
cooldownsbutton:SetScript('OnClick', function()
if buttons.cooldownsenabled == false then
cooldownsbutton:LockHighlight()
buttons.cooldownsenabled = true
elseif buttons.cooldownsenabled == true then
cooldownsbutton:UnlockHighlight()
buttons.cooldownsenabled = false
end
end)
--Enable/Disable Dispel Button OnClick
dispelbutton:SetScript('OnClick', function()
if buttons.dispelenabled == false then
dispelbutton:LockHighlight()
buttons.dispelenabled = true
elseif buttons.dispelenabled == true then
dispelbutton:UnlockHighlight()
buttons.dispelenabled = false
end
end)
--Enable/Disable DPS Button OnClick
dpsbutton:SetScript('OnClick', function()
if buttons.dpsenabled == false then
dpsbutton:LockHighlight()
buttons.dpsenabled = true
elseif buttons.dpsenabled == true then
dpsbutton:UnlockHighlight()
buttons.dpsenabled = false
end
end)
--Enable/Disable Heal Button OnClick
healbutton:SetScript('OnClick', function()
if buttons.healenabled == false then
healbutton:LockHighlight()
buttons.healenabled = true
elseif buttons.healenabled == true then
healbutton:UnlockHighlight()
buttons.healenabled = false
end
end)
--Enable/Disable Rotation Button OnClick HIGHLIGHT ONLY
enablebutton:SetScript('OnClick', function()
if buttons.rotationenabled == false then
enablebutton:LockHighlight()
Eval('RunMacroText("/bastion toggle")', 'bastion')
buttons.rotationenabled = true
elseif buttons.rotationenabled == true then
enablebutton:UnlockHighlight()
Eval('RunMacroText("/bastion toggle")', 'bastion')
buttons.rotationenabled = false
end
end)
--Toggle Main Menu
Command:Register({'open'}, function()
if mainmenu:IsShown() then
mainmenu:Hide()
else
mainmenu:Show()
end
end)
end