2022-02-01 14:05:36 +00:00
|
|
|
interfaceDialog = {type = "Dialog"}
|
2022-02-03 04:31:25 +00:00
|
|
|
-- dialog boxes
|
2022-02-01 14:05:36 +00:00
|
|
|
function interfaceDialog:New(style)
|
|
|
|
|
|
|
|
o = {}
|
|
|
|
o.pos = {
|
|
|
|
x = 0,
|
|
|
|
y = game.height*80/100
|
|
|
|
}
|
|
|
|
o.size = {
|
|
|
|
w = game.width,
|
|
|
|
h = game.height*20/100
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-02-03 04:31:25 +00:00
|
|
|
o.value = 0
|
|
|
|
o.target_value = 0
|
2022-02-01 14:05:36 +00:00
|
|
|
|
2022-02-03 04:31:25 +00:00
|
|
|
local style = {}
|
2022-02-01 14:05:36 +00:00
|
|
|
|
|
|
|
o.style = {
|
|
|
|
content = style.content or nil,
|
|
|
|
color = style.color or {1,1,1},
|
|
|
|
color2 = style.color2 or {0,0,0},
|
|
|
|
--color3 = style.color3 or style.color2 or {0,0,0},
|
|
|
|
alpha = style.alpha or 1,
|
|
|
|
scale = style.scale or 1,
|
|
|
|
scale_x = style.scale_x or 1,
|
|
|
|
scale_y = style.scale_y or 1,
|
|
|
|
scale_proportion = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
AddElement(o)
|
|
|
|
|
|
|
|
setmetatable(o, self)
|
|
|
|
self.__index = self
|
|
|
|
|
|
|
|
return o
|
|
|
|
end
|
|
|
|
|
2022-02-03 04:31:25 +00:00
|
|
|
function interfaceDialog:updateContents()
|
|
|
|
if self.value < self.target_value then
|
|
|
|
self.contents = self.sequence[self.value]
|
|
|
|
if self.contents[1] == nil then self.contents[1] = "" end
|
|
|
|
if self.contents[2] == nil then self.contents[2] = "" end
|
|
|
|
if self.contents[3] == nil then self.contents[3] = "" end
|
|
|
|
end
|
2022-02-01 14:05:36 +00:00
|
|
|
end
|
|
|
|
|
2022-02-03 04:31:25 +00:00
|
|
|
function interfaceDialog:loadSequence(sequence)
|
|
|
|
self.sequence = sequence
|
|
|
|
self.value = 1
|
|
|
|
self.target_value = 1+#sequence
|
|
|
|
self:updateContents()
|
2022-02-01 14:05:36 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function interfaceDialog:checkConfirm()
|
|
|
|
if not self.clicked then
|
2022-02-03 04:31:25 +00:00
|
|
|
if love.mouse.isDown(1) then
|
2022-02-01 14:05:36 +00:00
|
|
|
self.clicked = true
|
|
|
|
self.value = self.value + 1
|
2022-02-03 04:31:25 +00:00
|
|
|
print(self.value.." of "..self.target_value)
|
|
|
|
self:updateContents()
|
2022-02-01 14:05:36 +00:00
|
|
|
end
|
2022-02-03 04:31:25 +00:00
|
|
|
elseif not love.mouse.isDown(1) then
|
2022-02-01 14:05:36 +00:00
|
|
|
self.clicked = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function interfaceDialog:Draw()
|
|
|
|
local c1, c2, c3, a = love.graphics.getColor()
|
|
|
|
|
|
|
|
love.graphics.setColor(self.style.color[1],self.style.color[2],self.style.color[3],self.style.alpha)
|
|
|
|
love.graphics.rectangle(
|
|
|
|
"fill",
|
|
|
|
self.pos.x*self.style.scale_x*self.style.scale_proportion,
|
|
|
|
self.pos.y*self.style.scale_y*self.style.scale_proportion,
|
|
|
|
self.size.w*self.style.scale_x*self.style.scale_proportion,
|
|
|
|
self.size.h*self.style.scale_y*self.style.scale_proportion)
|
|
|
|
love.graphics.setColor(self.style.color2[1],self.style.color2[2],self.style.color2[3],self.style.alpha)
|
|
|
|
love.graphics.rectangle(
|
|
|
|
"line",
|
|
|
|
self.pos.x*self.style.scale_x*self.style.scale_proportion,
|
|
|
|
self.pos.y*self.style.scale_y*self.style.scale_proportion,
|
|
|
|
self.size.w*self.style.scale_x*self.style.scale_proportion,
|
|
|
|
self.size.h*self.style.scale_y*self.style.scale_proportion)
|
|
|
|
|
2022-02-03 04:31:25 +00:00
|
|
|
if self.contents ~= nil then
|
|
|
|
love.graphics.printf(self.contents[1],self.pos.x+10,self.pos.y+(self.size.h/2),100,"left")
|
|
|
|
love.graphics.printf(self.contents[2],self.pos.x+(self.size.w/2),self.pos.y+(self.size.h/2),100,"center")
|
|
|
|
love.graphics.printf(self.contents[3],self.pos.x+(self.size.w)-10,self.pos.y+(self.size.h/2),100,"right")
|
2022-02-01 14:05:36 +00:00
|
|
|
else
|
|
|
|
love.graphics.printf("ERROR",self.pos.x+(self.size.w/2),self.pos.y+(self.size.h/2),100,"center")
|
|
|
|
end
|
2022-02-03 04:31:25 +00:00
|
|
|
|
2022-02-01 14:05:36 +00:00
|
|
|
love.graphics.setColor(c1,c2,c3,a)
|
|
|
|
end
|