142 lines
4.8 KiB
Lua
142 lines
4.8 KiB
Lua
-- 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 "framework.modules.scenes"
|
|
local TestScene = Scene:extend()
|
|
|
|
local MenuType = require "framework.modules.gui.menus.listbox"
|
|
local MenuType2 = require "framework.modules.gui.menus.flowbox"
|
|
local MenuType3 = require "framework.modules.gui.menus.grid"
|
|
local Widget = require "framework.modules.gui.menus.widgets"
|
|
|
|
local MenuWidget = Widget.Text:extend()
|
|
|
|
function TestScene:new()
|
|
TestScene.super.new(self)
|
|
self.assets:addImageFont("medium", "assets/fonts/medium")
|
|
|
|
MenuType(self.menusystem, "testMenu1", 32, 32, 100, 24*8, 4)
|
|
MenuWidget(self, "testMenu1", "text_menu1")
|
|
Widget.Base("testMenu1")
|
|
Widget.Base("testMenu1")
|
|
Widget.Base("testMenu1")
|
|
Widget.Base("testMenu1")
|
|
Widget.Base("testMenu1")
|
|
|
|
MenuType2(self.menusystem, "testMenu2", 164, 32, 24*8, 24*2, 8, 2)
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
Widget.Base("testMenu2")
|
|
|
|
MenuType3(self.menusystem, "testMenu3", 164, 32 + 72, 24*8, 24*5, 8, 5)
|
|
Widget.Base("testMenu3")
|
|
Widget.Base("testMenu3")
|
|
Widget.Base("testMenu3")
|
|
Widget.Base("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)
|
|
|
|
self.menusystem.menus["testMenu1"].isLocked = true
|
|
self.menusystem.menus["testMenu2"].isLocked = true
|
|
self.menusystem.menus["testMenu3"].isLocked = true
|
|
|
|
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.menusystem.menus["text_menu1"]:setDepth(-1)
|
|
self.menusystem.menus["text_menu2"]:setDepth(-1)
|
|
self.menusystem.menus["text_menu3"]:setDepth(-1)
|
|
self.menusystem.menus["text_menu4"]:setDepth(-1)
|
|
self.menusystem.menus["text_menu5"]:setDepth(-1)
|
|
self.menusystem.menus["text_menu6"]:setDepth(-1)
|
|
|
|
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")
|
|
|
|
self.menusystem:switchMenu("testMenu1")
|
|
end
|
|
|
|
function TestScene:update(dt)
|
|
end
|
|
|
|
function TestScene:addTextWidget(menu, number)
|
|
for i=1, number do
|
|
Widget.Text(menu, "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
|
|
self.newmenu = newmenu
|
|
MenuWidget.super.new(self, menu, "menu", newmenu)
|
|
end
|
|
|
|
function MenuWidget:action()
|
|
self.scene.menusystem:switchMenu(self.newmenu)
|
|
end
|
|
|
|
return TestScene
|