diff --git a/autotheme.lua b/autotheme.lua index e02d0f1..6899a6b 100644 --- a/autotheme.lua +++ b/autotheme.lua @@ -1,20 +1,17 @@ +local msg = dprint or print + local function autodetect_theme() if not instead.screen_size then return end local f = io.open(instead.savepath().."/config.ini", "r") if f then + msg("Найден конфиг темы."); f:close() return end - f = io.open(instead.gamepath().."/themes/default/theme.ini", "r") - if not f then - return - end - f:close() local themes = {} - local vertical = false for d in std.readdir(instead.gamepath().."/themes") do if d ~= '.' and d ~= '..' then local p = instead.gamepath().."/themes/" .. d @@ -34,8 +31,13 @@ local function autodetect_theme() h = tonumber(h) local r = w / h if r < 1 then r = 1 / r end - table.insert(themes, { nam = d, w = w, h = h, mobile = w < h, ratio = r }) - vertical = vertical or (w < h) + table.insert(themes, { + nam = d, + w = w, + h = h, + vertical = w < h, + ratio = r + }) end f:close() end @@ -46,20 +48,18 @@ local function autodetect_theme() return end local w, h = instead.screen_size() - local r = w / h - local mobile = w < h or PLATFORM == "ANDROID" or PLATFORM == "IOS" or PLATFORM == "S60" or PLATFORM == "WINRT" or PLATFORM == "WINCE" - if w < h then - r = 1 / r - end + local ratio = w / h + local mobile = PLATFORM == "ANDROID" or PLATFORM == "IOS" or PLATFORM == "S60" or PLATFORM == "WINRT" or PLATFORM == "WINCE" + local vertical = w < h local d = 1000 local t = false for _, v in ipairs(themes) do - local dd = math.abs(v.ratio - r) + local dd = math.abs(v.ratio - ratio) if dd < d then - if mobile and (not vertical or v.mobile) then + if mobile and (not vertical or v.vertical) then d = dd t = v - elseif not mobile and not v.mobile then + elseif not mobile and not v.vertical then d = dd t = v end diff --git a/theme/LiberationSerif-Bold.ttf b/themes/common/LiberationSerif-Bold.ttf similarity index 100% rename from theme/LiberationSerif-Bold.ttf rename to themes/common/LiberationSerif-Bold.ttf diff --git a/theme/LiberationSerif-BoldItalic.ttf b/themes/common/LiberationSerif-BoldItalic.ttf similarity index 100% rename from theme/LiberationSerif-BoldItalic.ttf rename to themes/common/LiberationSerif-BoldItalic.ttf diff --git a/theme/LiberationSerif-Italic.ttf b/themes/common/LiberationSerif-Italic.ttf similarity index 100% rename from theme/LiberationSerif-Italic.ttf rename to themes/common/LiberationSerif-Italic.ttf diff --git a/theme/LiberationSerif-Regular.ttf b/themes/common/LiberationSerif-Regular.ttf similarity index 100% rename from theme/LiberationSerif-Regular.ttf rename to themes/common/LiberationSerif-Regular.ttf diff --git a/theme/menu.png b/themes/common/menu.png similarity index 100% rename from theme/menu.png rename to themes/common/menu.png diff --git a/theme.ini b/themes/fullhd/theme.ini similarity index 57% rename from theme.ini rename to themes/fullhd/theme.ini index ef014d2..8bb5bdd 100644 --- a/theme.ini +++ b/themes/fullhd/theme.ini @@ -1,6 +1,7 @@ +;$Name:Parser include = arctic -scr.w = 1024 -scr.h = 576 +scr.w = 1920 +scr.h = 1080 scr.gfx.bg = ;bg.png scr.col.bg = white win.x = 20 @@ -11,6 +12,7 @@ inv.x = 505 inv.y = 10 inv.col.link = #666666 inv.col.fg = #222222 + ;inv.w = 127 ;inv.h = 440 menu.button.x = 1000 @@ -28,10 +30,10 @@ scr.gfx.w = 144 scr.gfx.h = 448 scr.gfx.mode = embedded -win.fnt.name = theme/{LiberationSerif-Regular,LiberationSerif-Bold,LiberationSerif-Italic,LiberationSerif-BoldItalic}.ttf +win.fnt.name = ../common/{LiberationSerif-Regular,LiberationSerif-Bold,LiberationSerif-Italic,LiberationSerif-BoldItalic}.ttf win.fnt.size = 18 -inv.fnt.name = theme/{LiberationSerif-Regular,LiberationSerif-Bold,LiberationSerif-Italic,LiberationSerif-BoldItalic}.ttf +inv.fnt.name = ../common/{LiberationSerif-Regular,LiberationSerif-Bold,LiberationSerif-Italic,LiberationSerif-BoldItalic}.ttf inv.fnt.size = 18 -menu.gfx.button = theme/menu.png +menu.gfx.button = ../common/menu.png diff --git a/theme/theme.ini b/themes/tablet/theme.ini similarity index 62% rename from theme/theme.ini rename to themes/tablet/theme.ini index 5e89d73..d0edddb 100644 --- a/theme/theme.ini +++ b/themes/tablet/theme.ini @@ -30,10 +30,10 @@ scr.gfx.w = 144 scr.gfx.h = 448 scr.gfx.mode = embedded -win.fnt.name = {LiberationSerif-Regular,LiberationSerif-Bold,LiberationSerif-Italic,LiberationSerif-BoldItalic}.ttf +win.fnt.name = ../common/{LiberationSerif-Regular,LiberationSerif-Bold,LiberationSerif-Italic,LiberationSerif-BoldItalic}.ttf win.fnt.size = 18 -inv.fnt.name = {LiberationSerif-Regular,LiberationSerif-Bold,LiberationSerif-Italic,LiberationSerif-BoldItalic}.ttf +inv.fnt.name = ../common/{LiberationSerif-Regular,LiberationSerif-Bold,LiberationSerif-Italic,LiberationSerif-BoldItalic}.ttf inv.fnt.size = 18 -menu.gfx.button = menu.png +menu.gfx.button = ../common/menu.png