Skip to content

Commit

Permalink
fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
nagolove committed Jun 17, 2021
1 parent 1db6edf commit d110121
Show file tree
Hide file tree
Showing 11 changed files with 429 additions and 98 deletions.
4 changes: 2 additions & 2 deletions help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require("common")
require("globals")
require("layout")
require("love")
require("menu-new")
require("menu-main")
require("nback")
require("tiledbackground")

Expand Down Expand Up @@ -170,7 +170,7 @@ end
function Help:keypressed(key)
if key == "escape" then

menu:goBack()
mainMenu:goBack()
end
end

Expand Down
4 changes: 2 additions & 2 deletions help.tl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require "common"
require "globals"
require "layout"
require "love"
require "menu-new"
require "menu-main"
require "nback"
require "tiledbackground"

Expand Down Expand Up @@ -170,7 +170,7 @@ end
function Help:keypressed(key: string)
if key == "escape" then
--restoreGooi(self.gooi)
menu:goBack()
mainMenu:goBack()
end
end

Expand Down
4 changes: 2 additions & 2 deletions i18n/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ function i18n.loadFile(path, callback)
end
local data = chunk()
i18n.load(data)
print("i18n", inspect(i18n))
print("locale", inspect(locale))
--print("i18n", inspect(i18n))
--print("i18n.loadFile", inspect(locale))
end

setmetatable(i18n, {__call = function(_, ...) return i18n.translate(...) end})
Expand Down
49 changes: 22 additions & 27 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require("globals")
require("help")
require("languageselector")
require("love")
require("menu-new")
require("menu-main")
require("nbtypes")
require("pviewer")
require("tiledbackground")
Expand Down Expand Up @@ -51,11 +51,11 @@ local function quit()
end

function loadLocales()
local files = love.filesystem.getDirectoryItems("locales")
local files = love.filesystem.getDirectoryItems(SCENEPREFIX .. "locales")
print("locale files", inspect(files))
for _, v in ipairs(files) do
i18n.loadFile("locales/" .. v, function(path)
local chunk, errmsg = love.filesystem.load(path)
local chunk, errmsg = love.filesystem.load(SCENEPREFIX .. path)
if not chunk then
error(errmsg)
end
Expand Down Expand Up @@ -120,29 +120,23 @@ function subInit()

nback:init(SAVE_NAME)
pviewer:init(SAVE_NAME)

print('menu2', menu2)


print('menu', menu)
help:init()
menu:init()







mainMenu:init()



mainMenu:addItem(i18n("mainMenu.play"), nback)
mainMenu:addItem(i18n("mainMenu.viewProgress"), pviewer)
mainMenu:addItem(i18n("mainMenu.help"), help)

if not onAndroid then
mainMenu:addItem(i18n("mainMenu.exit"), function() love.event.quit() end)
end
end

local function init()
settings = readSettings()
print("SUUKA")
print(inspect(settings))
loadLocales()

Expand All @@ -165,7 +159,7 @@ local function init()
subInit()

table.insert(to_resize, nback)
table.insert(to_resize, menu)
table.insert(to_resize, mainMenu)
table.insert(to_resize, pviewer)
table.insert(to_resize, help)
table.insert(to_resize, languageSelector)
Expand All @@ -192,7 +186,7 @@ function update(dt)
languageSelector = nil
end
else
menu:update(dt)
mainMenu:update(dt)
timer:update(dt)
end
linesbuf:update()
Expand Down Expand Up @@ -259,12 +253,12 @@ local function keypressed(scancode)
languageSelector:keypressed(scancode)
else
keyconfig.keypressed(scancode)
menu:keypressed(scancode)
mainMenu:keypressed(scancode)
end
end

local function keyreleased(key)
menu:keyreleased(key)
mainMenu:keyreleased(key)
end

local function draw()
Expand All @@ -273,7 +267,7 @@ local function draw()
languageSelector:draw()
else
cam:attach()

mainMenu:draw()
cam:detach()


Expand All @@ -298,47 +292,48 @@ local function mousemoved(x, y, dx, dy, istouch)
if languageSelector then
languageSelector:mousemoved(x, y, dx, dy, istouch)
else
menu:mousemoved(x, y, dx, dy, istouch)
mainMenu:mousemoved(x, y, dx, dy, istouch)
end
end

local function mousepressed(x, y, button, istouch)
if languageSelector then
languageSelector:mousepressed(x, y, button, istouch)
else
menu:mousepressed(x, y, button, istouch)
mainMenu:mousepressed(x, y, button, istouch)
end
end

local function mousereleased(x, y, button, istouch)
if languageSelector then


else
menu:mousereleased(x, y, button, istouch)
mainMenu:mousereleased(x, y, button, istouch)
end
end

local function touchpressed(id, x, y, dx, dy, pressure)
if languageSelector then
languageSelector:touchpressed(id, x, y)
else
menu:touchpressed(id, x, y, dx, dy, pressure)
mainMenu:touchpressed(id, x, y, dx, dy, pressure)
end
end

local function touchreleased(id, x, y, dx, dy, pressure)
if languageSelector then
languageSelector:touchreleased(id, x, y)
else
menu:touchreleased(id, x, y, dx, dy, pressure)
mainMenu:touchreleased(id, x, y, dx, dy, pressure)
end
end

local function touchmoved(id, x, y, dx, dy, pressure)
if languageSelector then
languageSelector:touchmoved(id, x, y)
else
menu:touchmoved(id, x, y, dx, dy, pressure)
mainMenu:touchmoved(id, x, y, dx, dy, pressure)
end
end

Expand Down
49 changes: 22 additions & 27 deletions init.tl
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ local function quit()
end

function loadLocales()
local files = love.filesystem.getDirectoryItems("locales")
local files = love.filesystem.getDirectoryItems(SCENEPREFIX .. "locales")
print("locale files", inspect(files))
for _, v in ipairs(files) do
i18n.loadFile("locales/" .. v, function(path: string): any
local chunk, errmsg = love.filesystem.load(path)
local chunk, errmsg = love.filesystem.load(SCENEPREFIX .. path)
if not chunk then
error(errmsg)
end
Expand Down Expand Up @@ -120,29 +120,23 @@ function subInit()

nback:init(SAVE_NAME)
pviewer:init(SAVE_NAME)

--print('menu2', menu2)
--menu2:init()

print('menu', menu)
help:init()
--print('main menu', mainMenu)
mainMenu:init()

-- XXX не работает!
--menu:addItem(i18n("mainMenu.play"), nback)
--menu:addItem(i18n("mainMenu.viewProgress"), pviewer)
--menu:addItem(i18n("mainMenu.help"), help)
--print('i18n("mainMenu.play)"', i18n("mainMenu.play"))

-- XXX не работает!
--if not onAndroid then
--menu:addItem(i18n("mainMenu.exit"), function() love.event.quit() end)
--end
mainMenu:addItem(i18n("mainMenu.play"), nback as MenuObject)
mainMenu:addItem(i18n("mainMenu.viewProgress"), pviewer as MenuObject)
mainMenu:addItem(i18n("mainMenu.help"), help as MenuObject)

if not onAndroid then
mainMenu:addItem(i18n("mainMenu.exit"), function() love.event.quit() end as MenuObject)
end
end

local function init()
settings = readSettings()
print("SUUKA")
print(inspect(settings))
loadLocales()

Expand All @@ -165,7 +159,7 @@ local function init()
subInit()

table.insert(to_resize, nback as Resizable)
table.insert(to_resize, menu as Resizable)
table.insert(to_resize, mainMenu as Resizable)
table.insert(to_resize, pviewer as Resizable)
table.insert(to_resize, help as Resizable)
table.insert(to_resize, languageSelector as Resizable)
Expand All @@ -192,7 +186,7 @@ function update(dt: number)
languageSelector = nil
end
else
menu:update(dt)
mainMenu:update(dt)
timer:update(dt)
end
linesbuf:update()
Expand Down Expand Up @@ -259,12 +253,12 @@ local function keypressed(scancode: string)
languageSelector:keypressed(scancode)
else
keyconfig.keypressed(scancode)
menu:keypressed(scancode)
mainMenu:keypressed(scancode)
end
end

local function keyreleased(key: string)
menu:keyreleased(key)
mainMenu:keyreleased(key)
end

local function draw()
Expand All @@ -273,7 +267,7 @@ local function draw()
languageSelector:draw()
else
cam:attach()
--menu:draw()
mainMenu:draw()
cam:detach()
--drawProfilingReport()
--linesbuf:pushi("average FPS for 30 seconds")
Expand All @@ -298,47 +292,48 @@ local function mousemoved(x: number, y: number, dx: number, dy: number, istouch:
if languageSelector then
languageSelector:mousemoved(x, y, dx, dy, istouch)
else
menu:mousemoved(x, y, dx, dy, istouch)
mainMenu:mousemoved(x, y, dx, dy, istouch)
end
end

local function mousepressed(x: number, y: number, button: number, istouch: boolean)
if languageSelector then
languageSelector:mousepressed(x, y, button, istouch)
else
menu:mousepressed(x, y, button, istouch)
mainMenu:mousepressed(x, y, button, istouch)
end
end

local function mousereleased(x: number, y: number, button: number, istouch: boolean)
if languageSelector then
-- почему отлючено?
--languageSelector:mousereleased(x, y, button, istouch)
else
menu:mousereleased(x, y, button, istouch)
mainMenu:mousereleased(x, y, button, istouch)
end
end

local function touchpressed(id: number, x: number, y: number, dx: number, dy: number, pressure: number)
if languageSelector then
languageSelector:touchpressed(id, x, y)
else
menu:touchpressed(id, x, y, dx, dy, pressure)
mainMenu:touchpressed(id, x, y, dx, dy, pressure)
end
end

local function touchreleased(id: number, x: number, y: number, dx: number, dy: number, pressure: number)
if languageSelector then
languageSelector:touchreleased(id as any, x, y)
else
menu:touchreleased(id, x, y, dx, dy, pressure)
mainMenu:touchreleased(id, x, y, dx, dy, pressure)
end
end

local function touchmoved(id: number, x: number, y: number, dx: number, dy: number, pressure: number)
if languageSelector then
languageSelector:touchmoved(id as any, x, y)
else
menu:touchmoved(id, x, y, dx, dy, pressure)
mainMenu:touchmoved(id, x, y, dx, dy, pressure)
end
end

Expand Down
Loading

0 comments on commit d110121

Please sign in to comment.