examples/inventory: add an exit widget
This commit is contained in:
parent
2462b29ea3
commit
d1497836a2
1 changed files with 14 additions and 2 deletions
|
@ -30,6 +30,7 @@ local Widget = require "gamecore.modules.menusystem.widgets"
|
|||
|
||||
local InventoryWidget = Widget.Text:extend()
|
||||
local ItemWidget = Widget.Text:extend()
|
||||
local ExitWidget = Widget.Text:extend()
|
||||
|
||||
function Inventory:new()
|
||||
Inventory.super.new(self)
|
||||
|
@ -40,6 +41,7 @@ function Inventory:new()
|
|||
self:addSubMenu("weapon", "Weapons")
|
||||
self:addSubMenu("shield", "Shields")
|
||||
self:addSubMenu("stuff", "Stuff")
|
||||
ExitWidget(self, "main", "Exit")
|
||||
|
||||
self:addItem("weapon", 3)
|
||||
self:addItem("weapon", 2)
|
||||
|
@ -52,8 +54,6 @@ function Inventory:new()
|
|||
self.menusystem:switchMenu("main")
|
||||
self.menusystem.menus["weapon"].isVisible = true
|
||||
self.menusystem.menus["weapon"].isActive = true
|
||||
|
||||
|
||||
end
|
||||
|
||||
-- MENU FUNCTION
|
||||
|
@ -113,5 +113,17 @@ function ItemWidget:action()
|
|||
|
||||
end
|
||||
|
||||
-- Exit widget
|
||||
|
||||
function ExitWidget:new(scene, menu, fullname)
|
||||
self.scene = scene
|
||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
||||
local font = self.scene.assets.fonts["medium"]
|
||||
ExitWidget.super.new(self, widgetmenu, font, fullname)
|
||||
end
|
||||
|
||||
function ExitWidget:action(source)
|
||||
core.scenemanager:setStoredScene("mainmenu")
|
||||
end
|
||||
|
||||
return Inventory
|
||||
|
|
Loading…
Reference in a new issue