Оставляем одну тему, самую простую

This commit is contained in:
Alexander Yakovlev 2020-12-23 13:23:50 +07:00
parent a9a16ca945
commit 7ba390d485
Signed by: oreolek
GPG key ID: 1CDC4B7820C93BD3
10 changed files with 29 additions and 170 deletions

View file

@ -1,86 +0,0 @@
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
local themes = {}
for d in std.readdir(instead.gamepath().."/themes") do
if d ~= '.' and d ~= '..' then
local p = instead.gamepath().."/themes/" .. d
local f = io.open(p.."/theme.ini", "r")
if f then
local w, h
for l in f:lines() do
if l:find("scr%.w[ \t]*=[ \t]*[0-9]+") then
w = l:gsub("scr%.w[ \t]*=[ \t]*([0-9]+)", "%1")
elseif l:find("scr%.h[ \t]*=[ \t]*[0-9]+") then
h = l:gsub("scr%.h[ \t]*=[ \t]*([0-9]+)", "%1")
end
if w and h then break end
end
if w and h then
w = tonumber(w)
h = tonumber(h)
local r = w / h
if r < 1 then r = 1 / r end
table.insert(themes, {
nam = d,
w = w,
h = h,
vertical = w < h,
ratio = r
})
end
f:close()
end
end
end
if #themes == 1 then
return
end
local w, h = instead.screen_size()
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 - ratio)
if dd < d then
if mobile and (not vertical or v.vertical) then
d = dd
t = v
elseif not mobile and not v.vertical then
d = dd
t = v
end
end
end
if not t or t.nam == 'default' then
return
end
local name = instead.savepath().."/config.ini"
local name_tmp = name .. '.tmp'
local f = io.open(name_tmp, "w")
if f then
dprint("Autodetect theme: ", t.nam)
f:write("theme = "..t.nam.."\n")
f:close()
std.os.remove(name)
std.os.rename(name_tmp, name);
instead.restart()
end
end
std.mod_start(function()
autodetect_theme()
end, -100)

View file

@ -10,7 +10,6 @@ if instead.tiny then
end
if not instead.tiny then
require "autotheme"
require "theme"
end
@ -34,7 +33,6 @@ global {
}
game.dsc = ''
player.description = "Здесь нет зеркал. Но хотя бы ноги выглядят прекрасно.";
set_pic('wall.jpg')
pl.plural = false
pl.pronouns = 'fem'

29
theme.ini Normal file
View file

@ -0,0 +1,29 @@
;$Name:Парсер (микро)
scr.w = 500
scr.h = 600
scr.gfx.bg = bgr/wall.jpg
scr.col.bg = white
win.x = 20
win.y = 20
win.w = 460
win.h = 500
inv.x = 20
inv.y = 520
inv.w = 460
inv.h = 40
inv.col.link = #666666
inv.col.fg = #000000
menu.button.x = 474
menu.button.y = 868
inv.mode = horizontal-left
snd.click =
win.align = left
scr.gfx.x = 0
scr.gfx.y = 0
scr.gfx.w = 0
scr.gfx.h = 0
scr.gfx.mode = float-middle-center

BIN
themes/common/LiberationSerif-Bold.ttf (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
themes/common/LiberationSerif-Italic.ttf (Stored with Git LFS)

Binary file not shown.

BIN
themes/common/LiberationSerif-Regular.ttf (Stored with Git LFS)

Binary file not shown.

BIN
themes/common/menu.png (Stored with Git LFS)

Binary file not shown.

View file

@ -1,32 +0,0 @@
;$Name:FullHD
include = arctic
scr.w = 1920
scr.h = 1080
win.x = 20
win.y = 20
win.w = 964
win.h = 420
menu.button.x = 1000
menu.button.y = 552
inv.x = 20
inv.y = 460
inv.w = 964
inv.h = 100
inv.mode = horizontal-left
snd.click =
scr.gfx.x = 650
scr.gfx.y = 10
scr.gfx.w = 144
scr.gfx.h = 448
win.fnt.name = ../common/{LiberationSerif-Regular,LiberationSerif-Bold,LiberationSerif-Italic,LiberationSerif-BoldItalic}.ttf
win.fnt.size = 24
inv.fnt.name = ../common/{LiberationSerif-Regular,LiberationSerif-Bold,LiberationSerif-Italic,LiberationSerif-BoldItalic}.ttf
inv.fnt.size = 24
menu.gfx.button = ../common/menu.png
inv.col.link = #666666
inv.col.fg = #222222

View file

@ -1,35 +0,0 @@
;$Name:Tablet
include = arctic
scr.w = 800
scr.h = 600
scr.gfx.bg = ;bg.png
scr.col.bg = white
win.x = 20
win.y = 20
win.w = 964
win.h = 420
inv.col.link = #666666
inv.col.fg = #222222
menu.button.x = 1000
menu.button.y = 552
inv.x = 10
inv.y = 460
inv.w = 964
inv.h = 100
inv.mode = horizontal-left
snd.click =
scr.gfx.x = 650
scr.gfx.y = 10
scr.gfx.w = 144
scr.gfx.h = 448
scr.gfx.mode = embedded
win.fnt.name = ../common/{LiberationSerif-Regular,LiberationSerif-Bold,LiberationSerif-Italic,LiberationSerif-BoldItalic}.ttf
win.fnt.size = 18
inv.fnt.name = ../common/{LiberationSerif-Regular,LiberationSerif-Bold,LiberationSerif-Italic,LiberationSerif-BoldItalic}.ttf
inv.fnt.size = 18
menu.gfx.button = ../common/menu.png