battlesystem: kill entirely old menu system
This commit is contained in:
parent
5aa8b2da36
commit
d77dc0057c
1 changed files with 2 additions and 115 deletions
|
@ -13,19 +13,7 @@ local MENU_ITEM_NUMBER = 6
|
|||
|
||||
function MenuConstructor:new( controller )
|
||||
self.controller = controller
|
||||
self.isActive = false
|
||||
self.techList = {}
|
||||
|
||||
self.menu = {}
|
||||
self.menu[1] = BaseMenu
|
||||
|
||||
self.texture = love.graphics.newImage("assets/gui/attacklist.png")
|
||||
self.cursorTexture = love.graphics.newImage("assets/gui/cursor-menulist.png")
|
||||
self.font = love.graphics.newFont("assets/gui/fonts/PixelOperator.ttf", 16)
|
||||
self.controller.assets:addFont("small", "assets/gui/fonts/PixelOperator.ttf", 16)
|
||||
self.cursor = 1
|
||||
self.cursorTransition = 1
|
||||
self.view = 1
|
||||
end
|
||||
|
||||
function MenuConstructor:reconstruct(character)
|
||||
|
@ -47,18 +35,7 @@ function MenuConstructor:buildBaseMenu(character)
|
|||
end
|
||||
|
||||
function MenuConstructor:set(currentCharacter)
|
||||
self.isActive = true
|
||||
self.cursor = 1
|
||||
self.cursorTransition = 0
|
||||
self.activeMenu = 1
|
||||
|
||||
self.character = currentCharacter
|
||||
|
||||
--self:reconstruct(currentCharacter)
|
||||
|
||||
self.menu[2] = self:getSkillList()
|
||||
self.menu[3] = {"healitems", "rings", "wisps", "other", "back"}
|
||||
|
||||
self:reconstruct(currentCharacter)
|
||||
end
|
||||
|
||||
function MenuConstructor:getSkillList()
|
||||
|
@ -79,70 +56,6 @@ end
|
|||
|
||||
function MenuConstructor:update(dt)
|
||||
if (self.isActive) then
|
||||
local keys = self.controller.keys
|
||||
|
||||
if self.cursor < self.view then
|
||||
self.view = self.cursor
|
||||
end
|
||||
if self.cursor > self.view + 5 then
|
||||
self.view = self.cursor - 5
|
||||
end
|
||||
|
||||
local relativecursor = self.cursor - self.view
|
||||
|
||||
local transition = self.cursorTransition - relativecursor
|
||||
|
||||
if math.abs(transition) < 0.1 then
|
||||
self.cursorTransition = relativecursor
|
||||
else
|
||||
self.cursorTransition = (self.cursorTransition) + ((relativecursor) - (self.cursorTransition)) * dt*45
|
||||
end
|
||||
|
||||
if (keys["up"].isPressed) then
|
||||
if (self.cursor == 1) then
|
||||
self.cursor = #self.menu[self.activeMenu]
|
||||
else
|
||||
self.cursor = self.cursor - 1
|
||||
end
|
||||
end
|
||||
|
||||
if (keys["down"].isPressed) then
|
||||
if (self.cursor == #self.menu[self.activeMenu]) then
|
||||
self.cursor = 1
|
||||
else
|
||||
self.cursor = self.cursor + 1
|
||||
end
|
||||
end
|
||||
|
||||
if keys["left"].isPressed then
|
||||
self.character.direction = -1
|
||||
end
|
||||
|
||||
if keys["right"].isPressed then
|
||||
self.character.direction = 1
|
||||
end
|
||||
|
||||
if (keys["A"].isPressed) then
|
||||
if self.activeMenu == 1 then
|
||||
if (self.cursor == 2 or self.cursor == 3) then
|
||||
self.activeMenu = self.cursor
|
||||
self.cursor = 1
|
||||
else
|
||||
self:sendSignal(self.activeMenu, self.cursor)
|
||||
end
|
||||
else
|
||||
self:sendSignal(self.activeMenu, self.cursor)
|
||||
end
|
||||
end
|
||||
|
||||
if (keys["B"].isPressed) then
|
||||
if self.activeMenu == 1 then
|
||||
self:sendSignal(1, 6)
|
||||
else
|
||||
self.cursor = self.activeMenu
|
||||
self.activeMenu = 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -157,33 +70,7 @@ function MenuConstructor:sendSignal(menu, id)
|
|||
end
|
||||
|
||||
function MenuConstructor:draw()
|
||||
if (self.isActive) then
|
||||
local x, y, addition
|
||||
x = 32
|
||||
y = 32
|
||||
addition = 16
|
||||
local currentMenu = self.menu[self.activeMenu]
|
||||
-- MENUPOS_X1, MENUPOS_X2, MENUPOS_Y
|
||||
local MENUPOS_X = MENUPOS_X1
|
||||
local maxView = math.min(#currentMenu, (self.view + 5))
|
||||
|
||||
for i = self.view, maxView do
|
||||
love.graphics.draw(self.texture, MENUPOS_X - 16, MENUPOS_Y + (i-self.view)*addition + 3)
|
||||
love.graphics.setFont(self.font)
|
||||
love.graphics.setColor(0, 0, 0, .8)
|
||||
love.graphics.print(currentMenu[i], MENUPOS_X + 1, MENUPOS_Y + (i-self.view)*addition + 1)
|
||||
if (i == self.cursor) then
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
else
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
end
|
||||
love.graphics.print(currentMenu[i], MENUPOS_X, MENUPOS_Y + (i-self.view)*addition)
|
||||
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
end
|
||||
|
||||
love.graphics.draw(self.cursorTexture, MENUPOS_X - 12, MENUPOS_Y + (self.cursorTransition) * addition + 2 )
|
||||
end
|
||||
-- remove in order to avoid crash
|
||||
end
|
||||
|
||||
-- CHARACTER_MENU
|
||||
|
|
Loading…
Reference in a new issue