Skip to content

Commit

Permalink
Unknown sheet.
Browse files Browse the repository at this point in the history
  • Loading branch information
nagolove committed Apr 1, 2020
1 parent ffdca57 commit cbc62c2
Show file tree
Hide file tree
Showing 6 changed files with 341 additions and 63 deletions.
6 changes: 5 additions & 1 deletion drawstat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ function statisticRender:drawHits(x, y)
self:drawHitQuads(x, y, "pos", self.border)
end

function statisticRender:getHitsRectHeight()
return (self.fontHeight + self:getHitQuadLineHeight()) * 4
end

function statisticRender:beforeDraw()
g.setFont(self.font)
g.setColor(pallete.statistic)
Expand All @@ -126,7 +130,7 @@ function statisticRender:draw(noInfo)
local w = g.getWidth()
self:beforeDraw()
local x = (w - w * self.width_k) / 2
local y = self.layout.middle.y + (self.layout.middle.h - (self.fontHeight + self:getHitQuadLineHeight()) * 4) / 2
local y = self.layout.middle.y + (self.layout.middle.h - self:getHitsRectHeight()) / 2
self:drawHits(x, y)
self:printInfo()
g.setColor{0.5, 0.5, 0.5}
Expand Down
12 changes: 8 additions & 4 deletions list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,17 @@ function List:wheelmoved(x, y)
end

function List:getBarRect()
return self.x + self.width + 2, self.y + self.bar.pos + 1,
self.bar.width - 3, self.bar.size
return self.x, self.y + self.bar.pos + 1,
self.bar.width - 3, self.bar.size
--return self.x + self.width + 2, self.y + self.bar.pos + 1,
--self.bar.width - 3, self.bar.size
end

function List:getItemRect(i)
return self.x + 2, self.y + ((self.item_height + 1) * (i - 1) + 1) - self:getOffset(),
self.width - 3, self.item_height
return self.x + self.bar.width, self.y + ((self.item_height + 1) * (i - 1) + 1) - self:getOffset(),
self.width - self.bar.width, self.item_height
--return self.x + 2, self.y + ((self.item_height + 1) * (i - 1) + 1) - self:getOffset(),
--self.width - 3, self.item_height
end

function List:draw()
Expand Down
4 changes: 2 additions & 2 deletions main.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
onAndroid = love.system.getOS() == "Android" or false
useKeyboard = true
onAndroid = true
--onAndroid = true

require "common"

Expand Down Expand Up @@ -171,7 +171,7 @@ function bindKeys()
kc.bindKeyPressed("changescreenmode", {"return", "lalt"}, function()
-- код дерьмовый, но работает
if screenMode == "fs" then
love.window.setMode(800, 600, {fullscreen = false}) screenMode = "win"
love.window.setMode(1024, 768, {fullscreen = false}) screenMode = "win"
dispatchWindowResize(love.graphics.getDimensions())
else
love.window.setMode(0, 0, {fullscreen = true, fullscreentype = "exclusive"})
Expand Down
71 changes: 35 additions & 36 deletions nback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,7 @@ end

-- use scancode, Luke!
function nback:keypressed(_, scancode)
if not useKeyboard then return end

if scancode == "escape" then
if scancode == "escape" or "achome" then
if self.is_run then
print("stop by escape")
self:stop()
Expand All @@ -682,41 +680,42 @@ function nback:keypressed(_, scancode)
end
end

if self.is_run then
if scancode == "a" then
self:check("sound")
elseif scancode == "f" then
self:check("color")
elseif scancode == "j" then
self:check("form")
elseif scancode == ";" then
self:check("pos")
end
else
-- здесь другое игровое состояние, почему используется условие и булев
-- флаг?
-- состояние - регулировка в меню перед игрой
if not self.show_statistic then
if scancode == "space" or scancode == "return" then
self.setupmenu:select()
elseif scancode == "up" or scancode == "k" then
self.setupmenu:scrollUp()
elseif scancode == "down" or scancode == "j" then
self.setupmenu:scrollDown()
elseif scancode == "left" or scancode == "h" then
self.setupmenu:leftPressed()
elseif scancode == "right" or scancode == "l" then
self.setupmenu:rightPressed()
if useKeyboard then
if self.is_run then
if scancode == "a" then
self:check("sound")
elseif scancode == "f" then
self:check("color")
elseif scancode == "j" then
self:check("form")
elseif scancode == ";" then
self:check("pos")
end
else
-- здесь другое игровое состояние, почему используется условие и булев
-- флаг?
-- состояние - регулировка в меню перед игрой
if not self.show_statistic then
if scancode == "space" or scancode == "return" then
self.setupmenu:select()
elseif scancode == "up" or scancode == "k" then
self.setupmenu:scrollUp()
elseif scancode == "down" or scancode == "j" then
self.setupmenu:scrollDown()
elseif scancode == "left" or scancode == "h" then
self.setupmenu:leftPressed()
elseif scancode == "right" or scancode == "l" then
self.setupmenu:rightPressed()
end
end
end
end

if scancode == "-" then
self:loverVolume()
elseif scancode == "=" then
self:raiseVolume()
elseif scancode == "2" then
linesbuf.show = not linesbuf.show
if scancode == "-" then
self:loverVolume()
elseif scancode == "=" then
self:raiseVolume()
elseif scancode == "2" then
linesbuf.show = not linesbuf.show
end
end
end

Expand Down
43 changes: 23 additions & 20 deletions pviewer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function pviewer.new()
local self = {
border = 40, --y axis border in pixels for drawing chart
font = love.graphics.newFont("gfx/DejaVuSansMono.ttf", 20),
scroolTipFont = love.graphics.newFont("gfx/DejaVuSansMono.ttf", 13),
activeIndex = 0, -- обработай случаи если таблица истории пустая
}
self.w, self.h = g.getDimensions()
Expand Down Expand Up @@ -65,7 +64,7 @@ function pviewer:updateRender(index)
end
end

function removeDataWithoutDateField(data)
local function removeDataWithoutDateField(data)
local cleanedData = {}
for k, v in pairs(data) do
if v.date then
Expand All @@ -75,23 +74,9 @@ function removeDataWithoutDateField(data)
return cleanedData
end

function pviewer:enter()
print("pviewer:enter()")
local tmp, size = love.filesystem.read(self.save_name)
if tmp ~= nil then
ok, self.data = serpent.load(tmp)
print("pviewer.data", inspect(self.data))
if not ok then
-- эту строчку с падением при ошибке заменить на показ пустой
-- статистики.
error("Something wrong in restoring data " .. self.save_name)
end
else
self.data = {}
end

self.list = require "list":new(self.layout.left.x, self.layout.left.y,
self.layout.left.w, self.layout.left.h)
function pviewer:makeList()
self.list = require "pviewer_list":new(self.layout.left.x, self.layout.left.y,
self.layout.left.w, self.layout.left.h)
self.list.onclick = function(item, idx)
self:updateRender(idx)
end
Expand All @@ -112,7 +97,24 @@ function pviewer:enter()
end
end
self.list:done()
end

function pviewer:enter()
print("pviewer:enter()")
local tmp, size = love.filesystem.read(self.save_name)
if tmp ~= nil then
ok, self.data = serpent.load(tmp)
print("pviewer.data", inspect(self.data))
if not ok then
-- эту строчку с падением при ошибке заменить на показ пустой
-- статистики.
error("Something wrong in restoring data " .. self.save_name)
end
else
self.data = {}
end

self:makeList()
self.data = removeDataWithoutDateField(self.data)
self.activeIndex = #self.data >= 1 and 1 or 0
self:updateRender(1)
Expand Down Expand Up @@ -156,7 +158,8 @@ function pviewer:draw()
g.clear(pallete.background)
if self.statisticRender then
self.statisticRender:beforeDraw()
self.statisticRender:drawHits(self.layout.bottom.x, self.layout.bottom.y)
local y = self.layout.bottom.y + (self.layout.bottom.h - self.statisticRender:getHitsRectHeight()) / 2
self.statisticRender:drawHits(self.layout.bottom.x, y)
end
g.setCanvas()
g.setColor{1, 1, 1}
Expand Down
Loading

0 comments on commit cbc62c2

Please sign in to comment.