Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require"ui/ui_base"
- local Button = UIClass("Button",UI.Base)
- UI.Button = Button
- local bg_col, hov_col, t_col, t_hov_col =
- Color(220,220,220,170), Color(170,220,255,220), Color(0,0,0), Color(50,50,50)
- local d_col, a_col = Color(165,205,230,220), Color(255,255,255,90)
- VarFunc(Button,"Text","Button")
- VarFunc(Button,"Font",GAME.Fonts["vollkornsc-regular_18"])
- VarFunc(Button,"TextColor",t_col)
- VarFunc(Button,"HTextColor",t_hov_col)
- VarFunc(Button,"Color",bg_col)
- VarFunc(Button,"HColor",hov_col)
- VarFunc(Button,"DColor",d_col)
- function Button:init()
- end
- function Button:SetFont(str)
- self.Font = GAME.Fonts[str] or GAME.Fonts["vollkornsc-regular_18"]
- end
- local rect = love.graphics.rectangle
- local drawtext = love.graphics.print
- local setfont = love.graphics.setFont
- local setcolor,getcolor = love.graphics.setColor, love.graphics.getColor
- local align = "center"
- function Button:Draw(x,y,w,h)
- if self.Font ~= "" then setfont(self.Font) end
- local tw,th = self.Font:getWidth(self.Text), self.Font:getHeight(self.Text)
- if self.press then
- setcolor(self.DColor)
- rect("fill",x,y,w,h)
- setcolor(a_col)
- rect("line",x,y,w,h)
- setcolor(self.HTextColor)
- elseif self.hover then
- setcolor(self.HColor)
- rect("fill",x,y,w,h)
- setcolor(a_col)
- rect("line",x,y,w,h)
- setcolor(self.HTextColor)
- else
- setcolor(self.Color)
- rect("fill",x,y,w,h)
- setcolor(a_col)
- rect("line",x,y,w,h)
- setcolor(self.TextColor)
- end
- drawtext(self.Text,x+(w-tw)/2,y+(h-th)/2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement