Skip to content

Commit

Permalink
code.
Browse files Browse the repository at this point in the history
  • Loading branch information
nagolove committed Jun 17, 2021
1 parent 2edf3e0 commit 9efea88
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 25 deletions.
2 changes: 1 addition & 1 deletion fonts.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require("love")
require("globals")
local lg = love.graphics
SCENEPREFIX = "scenes/nback3/"
print('Fonts module loading..')
local t = {
help = {
Expand Down
2 changes: 1 addition & 1 deletion fonts.tl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "love"
require "globals"
local lg = love.graphics
global SCENEPREFIX = "scenes/nback3/"
print('Fonts module loading..')
local t = {
help = {
Expand Down
1 change: 1 addition & 0 deletions globals.lua
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

SCENEPREFIX = "scenes/nback3/"
3 changes: 3 additions & 0 deletions globals.tl
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

global SCENEPREFIX = "scenes/nback3/"

--require "menu"
--require "pviewer"
--require "help"
Expand Down
2 changes: 1 addition & 1 deletion help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require("layout")
require("love")
require("menu-new")
require("nback")

require("tiledbackground")

local pallete = require("pallete")
local fonts = require("fonts")
Expand Down
2 changes: 1 addition & 1 deletion help.tl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require "layout"
require "love"
require "menu-new"
require "nback"
require "tiledbackground"

--local gooi = require "gooi.gooi"
local pallete = require "pallete"
local fonts = require "fonts"
local i18n = require "i18n"
Expand Down
1 change: 1 addition & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require("love")
require("menu-new")
require("nbtypes")
require("pviewer")
require("tiledbackground")



Expand Down
1 change: 1 addition & 0 deletions init.tl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require "love"
require "menu-new"
require "nbtypes"
require "pviewer"
require "tiledbackground"

--preventiveFirstRun = false
--onAndroid = true
Expand Down
8 changes: 4 additions & 4 deletions languageselector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@ local LanguageSelector_mt = {
__index = LanguageSelector,
}

local prefix = "scenes/nback2/"

function LanguageSelector.new()
local self = setmetatable({}, LanguageSelector_mt)
self.languages = {}
self.font = require("fonts").languageSelector
self.locale = nil
for _, v in ipairs(love.filesystem.getDirectoryItems(prefix .. "locales")) do
local chunk, errmsg = love.filesystem.load(prefix .. "locales/" .. v)
for _, v in ipairs(love.filesystem.getDirectoryItems(SCENEPREFIX .. "locales")) do
local chunk, errmsg = love.filesystem.load(SCENEPREFIX .. "locales/" .. v)
print("--", chunk(), errmsg)
if not errmsg and type(chunk) == "function" then

Expand All @@ -82,13 +80,15 @@ function LanguageSelector:prepareDraw()

for _, v in ipairs(self.languages) do
local width = self.font:getWidth(v.id)
print('in cycle width = ', width)
if width > menuWidth then
menuWidth = width
end
end

local x0, y0 = 0., 0.
self.x, self.y = (w - menuWidth) / 2, (h - menuHeight) / 2
print("menuWidth, menuHeight", menuWidth, menuHeight)
self.canvas = gr.newCanvas(menuWidth, menuHeight)
gr.setFont(self.font)
gr.setColor(pallete.languageMenuText)
Expand Down
8 changes: 4 additions & 4 deletions languageselector.tl
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@ local LanguageSelector_mt: metatable<LanguageSelector> = {
__index = LanguageSelector,
}

local prefix = "scenes/nback2/"

function LanguageSelector.new(): LanguageSelector
local self = setmetatable({} as LanguageSelector, LanguageSelector_mt)
self.languages = {}
self.font = require "fonts".languageSelector
self.locale = nil
for _, v in ipairs(love.filesystem.getDirectoryItems(prefix .. "locales")) do
local chunk, errmsg: function, string = love.filesystem.load(prefix .. "locales/" .. v)
for _, v in ipairs(love.filesystem.getDirectoryItems(SCENEPREFIX .. "locales")) do
local chunk, errmsg: function, string = love.filesystem.load(SCENEPREFIX .. "locales/" .. v)
print("--", chunk(), errmsg)
if not errmsg and type(chunk) == "function" then
-- FIXME setfenv not work in Teal
Expand All @@ -82,13 +80,15 @@ function LanguageSelector:prepareDraw()

for _, v in ipairs(self.languages) do
local width = self.font:getWidth(v.id)
print('in cycle width = ', width)
if width > menuWidth then
menuWidth = width
end
end

local x0, y0 = 0., 0.
self.x, self.y = (w - menuWidth) / 2, (h - menuHeight) / 2
print("menuWidth, menuHeight", menuWidth, menuHeight)
self.canvas = gr.newCanvas(menuWidth, menuHeight)
gr.setFont(self.font)
gr.setColor(pallete.languageMenuText)
Expand Down
5 changes: 5 additions & 0 deletions menu-new.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ require("common")
require("cmn")
require("background")

local inspect = require("inspect")
local g = love.graphics

MenuObject = {}
Expand Down Expand Up @@ -259,16 +260,20 @@ function Menu:drawList()
g.printf(k.name, 0, y, self.w, "center")
y = y + self.font:getHeight()
end

end

function Menu:drawCursor()
print("Menu:drawCursor() self", self.items_rects[self.active_item])

local v = self.items_rects[self.active_item]
g.setLineWidth(3)
g.setColor({ 1, 0, 0 })
g.rectangle("line", v.x, v.y, v.w, v.h)
end

function Menu:draw()
print("Menu:draw() self", inspect(self))
g.clear(0, 0, 0, 0)
if self.active then
local obj = self.items[self.active_item].obj
Expand Down
5 changes: 5 additions & 0 deletions menu-new.tl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ require "common"
require "cmn"
require "background"

local inspect = require "inspect"
local g = love.graphics

global record MenuObject
Expand Down Expand Up @@ -259,16 +260,20 @@ function Menu:drawList()
g.printf(k.name, 0, y, self.w, "center")
y = y + self.font:getHeight()
end
--print("Menu:drawList() self", inspect(self))
end

function Menu:drawCursor()
print("Menu:drawCursor() self", self.items_rects[self.active_item])

local v = self.items_rects[self.active_item]
g.setLineWidth(3)
g.setColor{1, 0, 0}
g.rectangle("line", v.x, v.y, v.w, v.h)
end

function Menu:draw()
print("Menu:draw() self", inspect(self))
g.clear(0, 0, 0, 0)
if self.active then
local obj = self.items[self.active_item].obj
Expand Down
7 changes: 4 additions & 3 deletions pviewer.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local math = _tl_compat and _tl_compat.math or math; local os = _tl_compat and _tl_compat.os or os; local table = _tl_compat and _tl_compat.table or table; require("love")
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local ipairs = _tl_compat and _tl_compat.ipairs or ipairs; local math = _tl_compat and _tl_compat.math or math; local os = _tl_compat and _tl_compat.os or os; local table = _tl_compat and _tl_compat.table or table; require("button")
require("common")
require("drawstat")
require("nback")
require("layout")
require("button")
require("love")
require("menu-new")
require("nback")
require("tiledbackground")

local i18n = require("i18n")

Expand Down
7 changes: 4 additions & 3 deletions pviewer.tl
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
require "love"
require "button"
require "common"
require "drawstat"
require "nback"
require "layout"
require "button"
require "love"
require "menu-new"
require "nback"
require "tiledbackground"

local i18n = require "i18n"
--local inspect = require "inspect"
Expand Down
8 changes: 4 additions & 4 deletions tiledbackground.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local math = _tl_compat and _tl_compat.math or math; require("love")
local gr = love.graphics
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local math = _tl_compat and _tl_compat.math or math; require("globals")
require("love")

local prefix = "scenes/nback2/"
local gr = love.graphics

TiledBackround = {}

Expand All @@ -20,7 +20,7 @@ local TiledBackround_mt = {

function TiledBackround.new()
local self = setmetatable({}, TiledBackround_mt)
self.img = gr.newImage(prefix .. "gfx/tile1.png")
self.img = gr.newImage(SCENEPREFIX .. "gfx/tile1.png")
self:prepareDrawing()
return self
end
Expand Down
6 changes: 3 additions & 3 deletions tiledbackground.tl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "globals"
require "love"
local gr = love.graphics

local prefix = "scenes/nback2/"
local gr = love.graphics

global type TiledBackround = record
new: function(): TiledBackround
Expand All @@ -20,7 +20,7 @@ local TiledBackround_mt: metatable<TiledBackround> = {

function TiledBackround.new(): TiledBackround
local self = setmetatable({} as TiledBackround, TiledBackround_mt)
self.img = gr.newImage(prefix .. "gfx/tile1.png") as love.graphics.Texture
self.img = gr.newImage(SCENEPREFIX .. "gfx/tile1.png") as love.graphics.Texture
self:prepareDrawing()
return self
end
Expand Down

0 comments on commit 9efea88

Please sign in to comment.