forked from Mogara/QSanguosha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sanguosha.lua
48 lines (37 loc) · 1.18 KB
/
sanguosha.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- This is the start script of QSanguosha
package.path = package.path .. ";./lua/lib/?.lua"
package.cpath = package.cpath .. ";./lua/clib/?.dll"
dofile "lua/sgs_ex.lua"
function load_translation(file)
local t = dofile(file)
if type(t) ~= "table" then
error(("file %s is should return a table!"):format(file))
end
sgs.LoadTranslationTable(t)
end
function load_translations()
local lang = sgs.GetConfig("Language", "zh_CN")
local lang_dir = "lang/" .. lang
local lang_files = sgs.GetFileNames(lang_dir)
for _, file in ipairs(lang_files) do
load_translation(("%s/%s"):format(lang_dir, file))
end
end
function load_extensions(just_require)
local scripts = sgs.GetFileNames("extensions")
for _, script in ipairs(scripts) do
if script:match(".+%.lua$") then
local name = script:sub(script:find("%w+"))
local module_name = "extensions." .. name
local loaded = require(module_name)
sgs.Sanguosha:addPackage(loaded.extension)
end
end
end
load_extensions()
local done_loading = sgs.Sanguosha:property("DoneLoading"):toBool()
if not done_loading then
load_translations()
done_loading = sgs.QVariant(true)
sgs.Sanguosha:setProperty("DoneLoading", done_loading)
end