scenes/mainmenu: add icons to basic menu

This commit is contained in:
Kazhnuz 2019-03-10 10:01:35 +01:00
parent 4960c8238d
commit e370f1a04f
6 changed files with 11 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 943 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

View File

@ -29,8 +29,8 @@ function MenuObject:new(scene)
self.isActive = true self.isActive = true
MapWidget(self) MapWidget(self)
MainWidget(self, "MANAGE PIGS") MainWidget(self, "MANAGE PIGS", "blue", "manage")
MainWidget(self, "BONUS", "green") MainWidget(self, "BONUS", "green", "bonus")
OptionsWidget(self) OptionsWidget(self)
ExitWidget(self) ExitWidget(self)
self:addSlot(1, 0, 0, 13, 6) self:addSlot(1, 0, 0, 13, 6)
@ -40,17 +40,20 @@ function MenuObject:new(scene)
self:addSlot(5, 13, 9, 13, 3) self:addSlot(5, 13, 9, 13, 3)
end end
function MainWidget:new(menusystem, label, color) function MainWidget:new(menusystem, label, color, icon)
MainWidget.super.new(self, menusystem) MainWidget.super.new(self, menusystem)
self.scene = menusystem.scene self.scene = menusystem.scene
self.label = label or "" self.label = label or ""
self.color = color or "blue" self.color = color or "blue"
self.icon = icon or "exit"
end end
function MainWidget:redrawCanvas() function MainWidget:redrawCanvas()
self.width, self.height = self.menu:getWidgetSize(self.id) self.width, self.height = self.menu:getWidgetSize(self.id)
local filename = "assets/sprites/gui/textbox/" .. self.color .. "box.png" local filename = "assets/sprites/gui/textbox/" .. self.color .. "box.png"
self.textbox = game.gui.newTextBox(filename, self.width, self.height) self.textbox = game.gui.newTextBox(filename, self.width, self.height)
local iconname = "assets/sprites/menu/" .. self.icon .. ".png"
self.icon = love.graphics.newImage(iconname)
MainWidget.super.redrawCanvas(self) MainWidget.super.redrawCanvas(self)
end end
@ -58,8 +61,11 @@ function MainWidget:drawCanvas()
love.graphics.draw(self.textbox, 0, 0) love.graphics.draw(self.textbox, 0, 0)
if self.height >= 64 then if self.height >= 64 then
love.graphics.printf(self.label, 0, 8, self.width, "center") love.graphics.printf(self.label, 0, 8, self.width, "center")
love.graphics.draw(self.icon, self.width/2, self.height/2 + 12, 0, 1, 1, 19, 19)
else else
love.graphics.printf(self.label, 64, 16, self.width, "left") love.graphics.printf(self.label, 64, 16, self.width, "left")
love.graphics.draw(self.icon, 19+16, self.height/2, 0, 1, 1, 19, 19)
end end
end end
@ -78,7 +84,7 @@ function MainWidget:draw(x, y)
end end
function MapWidget:new(menusystem) function MapWidget:new(menusystem)
MapWidget.super.new(self, menusystem, "WORLD MAP", "red") MapWidget.super.new(self, menusystem, "WORLD MAP", "red", "worldmap")
end end
function MapWidget:action() function MapWidget:action()
@ -94,7 +100,7 @@ function ExitWidget:action()
end end
function OptionsWidget:new(menusystem) function OptionsWidget:new(menusystem)
OptionsWidget.super.new(self, menusystem, "OPTIONS", "yellow") OptionsWidget.super.new(self, menusystem, "OPTIONS", "yellow", "options")
end end
function OptionsWidget:action() function OptionsWidget:action()