examples/menus: add some text menus
This commit is contained in:
parent
29c4ad75c2
commit
fb1fee23a8
3 changed files with 50 additions and 0 deletions
5
examples/test_menus/assets/medium.lua
Normal file
5
examples/test_menus/assets/medium.lua
Normal file
|
@ -0,0 +1,5 @@
|
|||
return {
|
||||
filename = "medium.png",
|
||||
glyphs = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|} ",
|
||||
extraspacing = 1,
|
||||
}
|
BIN
examples/test_menus/assets/medium.png
Normal file
BIN
examples/test_menus/assets/medium.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
|
@ -29,6 +29,7 @@ local MenuType2 = require "gamecore.modules.menusystem.flowbox"
|
|||
local MenuType3 = require "gamecore.modules.menusystem.grid"
|
||||
local Widget = require "gamecore.modules.menusystem.widgets"
|
||||
|
||||
local MenuWidget = Widget.Text:extend()
|
||||
|
||||
function TestScene:new()
|
||||
TestScene.super.new(self)
|
||||
|
@ -73,14 +74,58 @@ function TestScene:new()
|
|||
self.menusystem.menus["testMenu3"]:addSlot(3, 5, 0, 3, 1)
|
||||
self.menusystem.menus["testMenu3"]:addSlot(4, 5, 1, 3, 4)
|
||||
|
||||
self.assets:addImageFont("medium", "examples/test_menus/assets/medium")
|
||||
|
||||
local w, h = 424/2, 240 - 48
|
||||
|
||||
local x, y = w / 2, 24
|
||||
|
||||
MenuType(self.menusystem, "text_menu1", x, y, w, h, 8)
|
||||
MenuType(self.menusystem, "text_menu2", x, y, w, h, 8)
|
||||
MenuType(self.menusystem, "text_menu3", x, y, w, h, 8)
|
||||
MenuType(self.menusystem, "text_menu4", x, y, w, h, 8)
|
||||
MenuType(self.menusystem, "text_menu5", x, y, w, h, 8)
|
||||
MenuType(self.menusystem, "text_menu6", x, y, w, h, 8)
|
||||
|
||||
self:addTextWidget("text_menu1", 4)
|
||||
self:addTextWidget("text_menu2", 10)
|
||||
self:addTextWidget("text_menu3", 5)
|
||||
self:addTextWidget("text_menu4", 12)
|
||||
self:addTextWidget("text_menu5", 9)
|
||||
self:addTextWidget("text_menu6", 5)
|
||||
|
||||
MenuWidget(self, "text_menu1", "text_menu2")
|
||||
MenuWidget(self, "text_menu1", "text_menu3")
|
||||
MenuWidget(self, "text_menu1", "text_menu4")
|
||||
MenuWidget(self, "text_menu1", "text_menu5")
|
||||
|
||||
MenuWidget(self, "text_menu3", "text_menu6")
|
||||
MenuWidget(self, "text_menu3", "text_menu6")
|
||||
end
|
||||
|
||||
function TestScene:update(dt)
|
||||
end
|
||||
|
||||
function TestScene:addTextWidget(menu, number)
|
||||
for i=1, number do
|
||||
Widget.Text(self.menusystem.menus[menu], self.assets.fonts["medium"], "lorem ipsum " .. i)
|
||||
end
|
||||
end
|
||||
|
||||
function TestScene:draw()
|
||||
love.graphics.setColor(0, 0, .4, 1)
|
||||
love.graphics.rectangle("fill", 0, 0, 424, 240)
|
||||
end
|
||||
|
||||
function MenuWidget:new(scene, menu, newmenu)
|
||||
self.scene = scene
|
||||
local widgetmenu = self.scene.menusystem.menus[menu]
|
||||
local font = self.scene.assets.fonts["medium"]
|
||||
MenuWidget.super.new(self, widgetmenu, font, newmenu)
|
||||
end
|
||||
|
||||
function MenuWidget:action()
|
||||
|
||||
end
|
||||
|
||||
return TestScene
|
||||
|
|
Loading…
Reference in a new issue