core/menusystem: rename isSlave to isChild

This commit is contained in:
Kazhnuz 2019-02-13 17:10:57 +01:00
parent 2aac02c223
commit 80bd57c4fe

View file

@ -23,7 +23,7 @@ function GridBox:new(menusystem, name, x, y, w, h, slots_hor, slots_vert)
self.listSlot[i] = {} self.listSlot[i] = {}
self.listSlot[i].sizeH = 1 self.listSlot[i].sizeH = 1
self.listSlot[i].sizeW = 1 self.listSlot[i].sizeW = 1
self.listSlot[i].isSlave = 0 self.listSlot[i].isChild = 0
self.listSlot[i].widgetID = i self.listSlot[i].widgetID = i
end end
end end
@ -36,8 +36,8 @@ end
function GridBox:update(dt) function GridBox:update(dt)
self.begin = 1 self.begin = 1
local slotID = self:getSlotbyCoord(self.cursor.x, self.cursor.y) local slotID = self:getSlotbyCoord(self.cursor.x, self.cursor.y)
if self.listSlot[slotID].isSlave > 0 then if self.listSlot[slotID].isChild > 0 then
slotID = self.listSlot[slotID].isSlave slotID = self.listSlot[slotID].isChild
end end
self.widget.selected = self.listSlot[slotID].widgetID self.widget.selected = self.listSlot[slotID].widgetID
self.cursor.x, self.cursor.y = self:getCoord(slotID) self.cursor.x, self.cursor.y = self:getCoord(slotID)
@ -46,7 +46,7 @@ end
function GridBox:regenSlots() function GridBox:regenSlots()
local widgetID = 1 local widgetID = 1
for i,v in ipairs(self.listSlot) do for i,v in ipairs(self.listSlot) do
if v.isSlave == 0 and (widgetID <= #self.widget.list) then if v.isChild == 0 and (widgetID <= #self.widget.list) then
self.listSlot[i].widgetID = widgetID self.listSlot[i].widgetID = widgetID
widgetID = widgetID + 1 widgetID = widgetID + 1
end end
@ -56,9 +56,9 @@ end
function GridBox:addCol(slotID) function GridBox:addCol(slotID)
local col, line = self:getCoord(slotID) local col, line = self:getCoord(slotID)
if (col + self.listSlot[slotID].sizeW + 1) <= self.slots_hor then if (col + self.listSlot[slotID].sizeW + 1) <= self.slots_hor then
slotSlave = slotID + self.listSlot[slotID].sizeW slotChild = slotID + self.listSlot[slotID].sizeW
for i = 1, self.listSlot[slotID].sizeH do for i = 1, self.listSlot[slotID].sizeH do
self.listSlot[slotSlave + ((i-1)* self.slots_hor)].isSlave = slotID self.listSlot[slotChild + ((i-1)* self.slots_hor)].isChild = slotID
end end
self.listSlot[slotID].sizeW = self.listSlot[slotID].sizeW + 1 self.listSlot[slotID].sizeW = self.listSlot[slotID].sizeW + 1
end end
@ -67,9 +67,9 @@ end
function GridBox:addLine(slotID) function GridBox:addLine(slotID)
local col, line = self:getCoord(slotID) local col, line = self:getCoord(slotID)
if (line + self.listSlot[slotID].sizeH + 1) <= self.slots_vert then if (line + self.listSlot[slotID].sizeH + 1) <= self.slots_vert then
slotSlave = slotID + (self.listSlot[slotID].sizeH * self.slots_hor) slotChild = slotID + (self.listSlot[slotID].sizeH * self.slots_hor)
for i = 1, self.listSlot[slotID].sizeW do for i = 1, self.listSlot[slotID].sizeW do
self.listSlot[slotSlave + (i-1)].isSlave = slotID self.listSlot[slotChild + (i-1)].isChild = slotID
end end
self.listSlot[slotID].sizeH = self.listSlot[slotID].sizeH + 1 self.listSlot[slotID].sizeH = self.listSlot[slotID].sizeH + 1
end end
@ -120,8 +120,8 @@ function GridBox:moveCursor(newcol, newline)
previousSlot = self:getSlotbyCoord(col, line) previousSlot = self:getSlotbyCoord(col, line)
newSlot = self:getSlotbyCoord(self.cursor.x, self.cursor.y) newSlot = self:getSlotbyCoord(self.cursor.x, self.cursor.y)
if (self.listSlot[newSlot].isSlave > 0) or (self.listSlot[newSlot].widgetID > #self.widget.list) then if (self.listSlot[newSlot].isChild > 0) or (self.listSlot[newSlot].widgetID > #self.widget.list) then
if (self.listSlot[newSlot].isSlave == previousSlot) or (self.listSlot[newSlot].widgetID > #self.widget.list) then if (self.listSlot[newSlot].isChild == previousSlot) or (self.listSlot[newSlot].widgetID > #self.widget.list) then
self:moveCursor(self.cursor.x + relcol, self.cursor.y + relline) self:moveCursor(self.cursor.x + relcol, self.cursor.y + relline)
end end
end end
@ -184,8 +184,8 @@ function GridBox:mousepressed(x, y, button, isTouch)
newcol = math.floor(x / self.widget.w) newcol = math.floor(x / self.widget.w)
newselect = (newline * self.slots_hor) + newcol + 1 newselect = (newline * self.slots_hor) + newcol + 1
if self.listSlot[newselect].isSlave > 0 then if self.listSlot[newselect].isChild > 0 then
slotID = self.listSlot[newselect].isSlave slotID = self.listSlot[newselect].isChild
else else
slotID = newselect slotID = newselect
end end
@ -203,7 +203,7 @@ function GridBox:draw()
self:regenSlots() -- On reget les slots au cas où :p self:regenSlots() -- On reget les slots au cas où :p
for i,v in ipairs(self.listSlot) do for i,v in ipairs(self.listSlot) do
if (v.isSlave == 0) and (v.widgetID <= #self.widget.list) then if (v.isChild == 0) and (v.widgetID <= #self.widget.list) then
--self.widget.list[v.widgetID]:draw(widgetx, widgety, self.widget.w * v.sizeW, self.widget.h * v.sizeH) --self.widget.list[v.widgetID]:draw(widgetx, widgety, self.widget.w * v.sizeW, self.widget.h * v.sizeH)
if self.widget.selected == v.widgetID and self:haveFocus() == true then if self.widget.selected == v.widgetID and self:haveFocus() == true then
self.widget.list[v.widgetID]:drawSelected(widgetx, widgety, self.widget.w * v.sizeW, self.widget.h * v.sizeH) self.widget.list[v.widgetID]:drawSelected(widgetx, widgety, self.widget.w * v.sizeW, self.widget.h * v.sizeH)
@ -211,7 +211,7 @@ function GridBox:draw()
self.widget.list[v.widgetID]:draw(widgetx, widgety, self.widget.w * v.sizeW, self.widget.h * v.sizeH) self.widget.list[v.widgetID]:draw(widgetx, widgety, self.widget.w * v.sizeW, self.widget.h * v.sizeH)
end end
end end
if (v.isSlave > 0) and false then if (v.isChild > 0) and false then
love.graphics.setColor(255,255,255,128) love.graphics.setColor(255,255,255,128)
love.graphics.rectangle("fill", widgetx, widgety, self.widget.w, self.widget.h) love.graphics.rectangle("fill", widgetx, widgety, self.widget.w, self.widget.h)
end end