2019-03-16 15:38:02 +01:00
|
|
|
-- scenes/test :: a basic test scene
|
|
|
|
|
|
|
|
--[[
|
|
|
|
Copyright © 2019 Kazhnuz
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
this software and associated documentation files (the "Software"), to deal in
|
|
|
|
the Software without restriction, including without limitation the rights to
|
|
|
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
|
|
subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
]]
|
|
|
|
|
|
|
|
local Scene = require "gamecore.modules.scenes"
|
|
|
|
local TestScene = Scene:extend()
|
|
|
|
|
|
|
|
local MenuType = require "gamecore.modules.menusystem.listbox"
|
|
|
|
local MenuType2 = require "gamecore.modules.menusystem.flowbox"
|
|
|
|
local MenuType3 = require "gamecore.modules.menusystem.grid"
|
|
|
|
local Widget = require "gamecore.modules.menusystem.widgets"
|
|
|
|
|
2019-03-18 19:30:25 +01:00
|
|
|
local MenuWidget = Widget.Text:extend()
|
2019-03-16 15:38:02 +01:00
|
|
|
|
|
|
|
function TestScene:new()
|
|
|
|
TestScene.super.new(self)
|
|
|
|
|
|
|
|
MenuType(self.menusystem, "testMenu1", 32, 32, 100, 24*8, 4)
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu1"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu1"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu1"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu1"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu1"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu1"])
|
|
|
|
|
|
|
|
MenuType2(self.menusystem, "testMenu2", 164, 32, 24*8, 24*2, 8, 2)
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu2"])
|
|
|
|
|
|
|
|
MenuType3(self.menusystem, "testMenu3", 164, 32 + 72, 24*8, 24*5, 8, 5)
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu3"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu3"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu3"])
|
|
|
|
Widget.Base(self.menusystem.menus["testMenu3"])
|
|
|
|
self.menusystem.menus["testMenu3"]:addSlot(1, 0, 0, 4, 3)
|
|
|
|
self.menusystem.menus["testMenu3"]:addSlot(2, 0, 3, 5, 2)
|
|
|
|
self.menusystem.menus["testMenu3"]:addSlot(3, 5, 0, 3, 1)
|
|
|
|
self.menusystem.menus["testMenu3"]:addSlot(4, 5, 1, 3, 4)
|
|
|
|
|
2019-03-22 17:22:45 +01:00
|
|
|
self.menusystem.menus["testMenu1"].isLocked = true
|
|
|
|
self.menusystem.menus["testMenu2"].isLocked = true
|
|
|
|
self.menusystem.menus["testMenu3"].isLocked = true
|
|
|
|
|
2019-03-18 19:30:25 +01:00
|
|
|
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")
|
2019-03-22 17:22:45 +01:00
|
|
|
|
|
|
|
self.menusystem:setAllMenuVisibility(false)
|
2019-03-16 15:38:02 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function TestScene:update(dt)
|
|
|
|
end
|
|
|
|
|
2019-03-18 19:30:25 +01:00
|
|
|
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
|
|
|
|
|
2019-03-16 15:38:02 +01:00
|
|
|
function TestScene:draw()
|
|
|
|
love.graphics.setColor(0, 0, .4, 1)
|
|
|
|
love.graphics.rectangle("fill", 0, 0, 424, 240)
|
|
|
|
end
|
|
|
|
|
2019-03-18 19:30:25 +01:00
|
|
|
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
|
|
|
|
|
2019-03-16 15:38:02 +01:00
|
|
|
return TestScene
|