diff --git a/objects/imagebutton.lua b/objects/imagebutton.lua index 682c64f..239c9e7 100644 --- a/objects/imagebutton.lua +++ b/objects/imagebutton.lua @@ -24,6 +24,7 @@ function newobject:initialize() self.clickable = true self.enabled = true self.image = nil + self.imagecolor = nil self.OnClick = nil end @@ -338,3 +339,24 @@ function newobject:GetImageHeight() end end + +--[[--------------------------------------------------------- + - func: SetColor(r, g, b, a) + - desc: sets the object's color +--]]--------------------------------------------------------- +function newobject:SetColor(r, g, b, a) + + self.imagecolor = {r, g, b, a} + return self + +end + +--[[--------------------------------------------------------- + - func: GetColor() + - desc: gets the object's color +--]]--------------------------------------------------------- +function newobject:GetColor() + + return unpack(self.imagecolor) + +end diff --git a/skins/Blue/skin.lua b/skins/Blue/skin.lua index 4609459..8d6140d 100644 --- a/skins/Blue/skin.lua +++ b/skins/Blue/skin.lua @@ -508,6 +508,7 @@ function skin.DrawImageButton(object) local text = object:GetText() local hover = object:GetHover() local image = object:GetImage() + local imagecolor = object.imagecolor or {255, 255, 255, 255} local down = object.down local font = skin.controls.imagebutton_text_font local twidth = font:getWidth(object.text) @@ -518,7 +519,7 @@ function skin.DrawImageButton(object) if down then if image then - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(imagecolor) love.graphics.draw(image, x + 1, y + 1) end love.graphics.setFont(font) @@ -528,7 +529,7 @@ function skin.DrawImageButton(object) love.graphics.print(text, x + width/2 - twidth/2 + 1, y + height - theight - 6 + 1) elseif hover then if image then - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(imagecolor) love.graphics.draw(image, x, y) end love.graphics.setFont(font) @@ -538,7 +539,7 @@ function skin.DrawImageButton(object) love.graphics.print(text, x + width/2 - twidth/2, y + height - theight - 6) else if image then - love.graphics.setColor(255, 255, 255, 255) + love.graphics.setColor(imagecolor) love.graphics.draw(image, x, y) end love.graphics.setFont(font)