mirror of
https://github.com/pyrollo/display_modpack.git
synced 2025-10-15 08:35:35 +02:00
Add luacheck, update translations, replace ABMs, bug fixes (#1)
* luacheck, mt 5 translation, german translation, maintenance * fix luacheck warnings * Fix digital clock nodebox and texture * Fix luacheck usage * Add comment why fonts are not split into several lines
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
-- Deprecation
|
||||
|
||||
function deprecated_global_table(deprecated_global_name, replacement_global_name)
|
||||
local function deprecated_global_table(deprecated_global_name, replacement_global_name)
|
||||
assert(type(deprecated_global_name) == 'string', "deprecated_global_name should be a string.")
|
||||
assert(type(replacement_global_name) == 'string', "replacement_global_name should be a string.")
|
||||
assert(deprecated_global_name ~= '', "deprecated_global_name should not be empty.")
|
||||
|
@@ -53,7 +53,7 @@ return {
|
||||
['×'] = 'x', ['Ý'] = 'Y',
|
||||
|
||||
-- Lower case accents
|
||||
['à'] = 'a', ['à'] = 'a', ['á'] = 'a', ['â'] = 'a',
|
||||
['à'] = 'a', ['á'] = 'a', ['â'] = 'a',
|
||||
['ã'] = 'a', ['ä'] = 'a', ['å'] = 'a',
|
||||
['æ'] = 'ae', ['ç'] = 'c',
|
||||
['è'] = 'e', ['é'] = 'e', ['ê'] = 'e', ['ë'] = 'e',
|
||||
|
@@ -212,7 +212,7 @@ end
|
||||
-- @return Texture string
|
||||
|
||||
function Font:render(text, texturew, textureh, style)
|
||||
local style = style or {}
|
||||
style = style or {}
|
||||
|
||||
-- Split text into lines (and limit to style.lines # of lines)
|
||||
local lines = {}
|
||||
@@ -243,17 +243,17 @@ function Font:render(text, texturew, textureh, style)
|
||||
|
||||
y = y + (self.margintop or 0)
|
||||
|
||||
for _, line in pairs(lines) do
|
||||
for _, l in pairs(lines) do
|
||||
if style.halign == "left" then
|
||||
x = 0
|
||||
elseif style.halign == "right" then
|
||||
x = texturew - line.width
|
||||
x = texturew - l.width
|
||||
else
|
||||
x = (texturew - line.width) / 2
|
||||
x = (texturew - l.width) / 2
|
||||
end
|
||||
|
||||
while line.text ~= '' do
|
||||
codepoint, line.text = self:get_next_char(line.text)
|
||||
while l.text ~= '' do
|
||||
codepoint, l.text = self:get_next_char(l.text)
|
||||
if codepoint == nil then return '' end -- UTF Error
|
||||
|
||||
-- Add image only if it is visible (at least partly)
|
||||
|
@@ -16,6 +16,9 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
--]]
|
||||
|
||||
local S = font_api.S
|
||||
local FS = function(...) return minetest.formspec_escape(S(...)) end
|
||||
|
||||
local modname = minetest.get_current_modname()
|
||||
|
||||
local contexts = {}
|
||||
@@ -101,9 +104,9 @@ local function show_font_formspec(playername)
|
||||
table.sort(fonts)
|
||||
|
||||
local fs = string.format(
|
||||
"size[4,%s]%s%s%sbutton_exit[0,%s;4,1;cancel;Cancel]",
|
||||
"size[4,%s]%s%s%sbutton_exit[0,%s;4,1;cancel;%s]",
|
||||
#fonts + 0.8, default.gui_bg, default.gui_bg_img, default.gui_slots,
|
||||
#fonts)
|
||||
#fonts, FS("Cancel"))
|
||||
|
||||
for line = 1, #fonts do
|
||||
local font = font_api.get_font(fonts[line])
|
||||
|
@@ -23,6 +23,9 @@ font_api = {}
|
||||
font_api.name = minetest.get_current_modname()
|
||||
font_api.path = minetest.get_modpath(font_api.name)
|
||||
|
||||
-- Translation support
|
||||
font_api.S = minetest.get_translator(font_api.name)
|
||||
|
||||
-- Inclusions
|
||||
-------------
|
||||
|
||||
|
2
font_api/locale/font_api.de.tr
Normal file
2
font_api/locale/font_api.de.tr
Normal file
@@ -0,0 +1,2 @@
|
||||
# textdomain: font_api
|
||||
Cancel=Schließen
|
2
font_api/locale/template.txt
Normal file
2
font_api/locale/template.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
# textdomain: font_api
|
||||
Cancel=
|
@@ -58,12 +58,9 @@ local function get_default_font()
|
||||
end
|
||||
end
|
||||
|
||||
-- If failed, chose first font
|
||||
-- If failed, choose the first registered font
|
||||
if default_font == nil then
|
||||
for _, font in pairs(font_api.registered_fonts) do
|
||||
default_font = font
|
||||
break
|
||||
end
|
||||
default_font = next(font_api.registered_fonts)
|
||||
end
|
||||
|
||||
-- Error, no font registered
|
||||
|
Reference in New Issue
Block a user