-
-
Save roblarky/5c16e5c269b6ba585202525b41932247 to your computer and use it in GitHub Desktop.
Bevy O Bars Hider.lua - tabbed layout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
New version of the hider bar module | |
]]-- | |
if not pcall(function() import "JackdawPlugins.Bevy2.Isil" end) then | |
--Default colour scheme if Isil.lua is not present. | |
BackColor= Turbine.UI.Color(1,0.5,0.5,0.5) | |
ButtonBackColor = Turbine.UI.Color(1,0,0,0.5) | |
TooltipColor= Turbine.UI.Color(0.5,0,0,0) | |
TooltipLabelBackColor= Turbine.UI.Color( 0.5, 0, 0,0) | |
TooltipLabelForeColor= Turbine.UI.Color(0.85, 0.69, 0.23) | |
ForeColor= Turbine.UI.Color(0.85, 0.69, 0.23) | |
Opac=0.9 | |
end | |
if type(Modules.hider)~="table" and Modules.hider~=nil then | |
--First load - set defaults | |
Modules.hider={} | |
Modules.hider.x=0 | |
Modules.hider.y=0 | |
end | |
--Create the Bar | |
Hider={} | |
Hider.Window=Turbine.UI.Window() | |
Hider.Window:SetVisible(true) | |
Hider.Window:SetPosition(Modules.hider.x,Modules.hider.y) | |
Hider.Window.DragBar = Deusdictum.UI.DragBar( Hider.Window,"Hider Bar") | |
Hider.Window:SetBackColor ( BackColor) | |
Hider.Window:SetOpacity ( 0.4 ) | |
Hider.Window.PositionChanged=function (sender,args) | |
Modules.hider.x,Modules.hider.y=Hider.Window:GetPosition() | |
end | |
Hider.Window.MouseEnter = function (sender,args) | |
Hider.Window:SetOpacity ( 0.8 ) | |
end | |
Hider.Window.MouseLeave = function (sender,args) | |
Hider.Window:SetOpacity ( 0.4 ) | |
end | |
--Create the Buttons - this is a function | |
Hider.Button={} | |
function BarUpdate() | |
--Delete the Buttons! This is to avoid errors when bars are created or destroyed. | |
for i,v in pairs(Hider.Button) do | |
Hider.Button[i]:SetVisible(false) | |
Hider.Button[i]=nil | |
end | |
--Create the buttons | |
local j=0 --Counts the number of buttons | |
local buttonOffset = 1 | |
for i=1,#Bar do | |
if not(Bar[i].delete) then | |
if Bar[i].Data.hider~=nil then | |
j=j+1 | |
buttonOffset = j; | |
Hider.Button[i]=Turbine.UI.Button() | |
Hider.Button[i] :SetPosition ( 56*(j-1)+buttonOffset,1) | |
Hider.Button[i] :SetSize ( 56,20 ) | |
Hider.Button[i] :SetVisible ( true ) | |
Hider.Button[i] :SetOpacity ( 1 ) | |
Hider.Button[i] :SetParent ( Hider.Window ) | |
Hider.Button[i] :SetBackColor ( Turbine.UI.Color( 1, 0, 0, 0 ) ) | |
Hider.Button[i] :SetTextAlignment( Turbine.UI.ContentAlignment.MiddleCenter ) | |
Hider.Button[i] :SetFont(Turbine.UI.Lotro.Font.VerdanaBold16) | |
Hider.Button[i] :SetText(Bar[i].Data.name) | |
if Bar[i].Data.hider.vis then | |
Hider.Button[i] :SetForeColor( Turbine.UI.Color( 1, 0.92, 0.87, 0.21 ) ) | |
Bar[i]:Show() | |
else | |
Hider.Button[i] :SetForeColor( Turbine.UI.Color( 1, 1, 1, 1 ) ) | |
Bar[i]:Hide() | |
end | |
Hider.Button[i].MouseDown = function( sender, args ) | |
if Bar[i].Data.hider.vis then | |
Bar[i].Data.hider.vis=false | |
Bar[i]:Hide() | |
Hider.Button[i] :SetForeColor( Turbine.UI.Color( 1, 1, 1, 1 ) ) | |
else | |
for bi=1,#Bar do | |
if Bar[bi].Data.hider~=nil then | |
if Bar[bi].Data.hider.vis then | |
Bar[bi].Data.hider.vis=false | |
Bar[bi]:Hide() | |
Hider.Button[bi] :SetForeColor( Turbine.UI.Color( 1, 1, 1, 1 ) ) | |
end | |
end | |
end | |
Bar[i].Data.hider.vis=true | |
Hider.Button[i] :SetForeColor( Turbine.UI.Color( 1, 0.92, 0.87, 0.21 ) ) | |
Bar[i]:Show() | |
end | |
end | |
--[[ | |
Hider.Button[i].MouseEnter = function (sender,args) | |
Hider.Window:SetOpacity ( 0.8 ) | |
end | |
Hider.Button[i].MouseLeave = function (sender,args) | |
Hider.Window:SetOpacity ( 0.5 ) | |
end | |
]] | |
end | |
end | |
end | |
Hider.Window:SetSize(56*j+1+buttonOffset,22) | |
end | |
--Context Menu function | |
table.insert(Context, | |
function (self,contextMenu,contextMenuItems) | |
--Add the "Hider Bar" option to every Bar. | |
local HiderBar = Turbine.UI.MenuItem( "Hider Bar Button for "..self.Data.name,true,self.Data.hider~=nil); | |
HiderBar.Click = function( sender, args ) | |
if self.Data.hider==nil then | |
self.Data.hider={} | |
self.Data.hider.vis=true | |
else | |
self.Data.hider=nil | |
end | |
BarUpdate() | |
end | |
contextMenuItems:Add( HiderBar ) | |
end) | |
--Option Box functions | |
table.insert(Opt.Module, | |
function() | |
Opt.Hider=CollapseBox("Hider Bar Options","f",1,true) | |
Opt.ListBox:AddItem(Opt.Hider) | |
Opt.hider=Opt.CheckBox("Hider?",function(k,i) | |
if k then | |
Bar[i].Data.hider={} | |
Bar[i].Data.hider.vis=true | |
else | |
Bar[i].Data.hider=nil | |
end | |
BarUpdate() | |
end ) | |
Opt.Hider.Content:AddItem(Opt.hider) | |
table.insert(Opt.source,"hider") | |
Opt.table.hider=true | |
end) | |
BarUpdate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment