-
Notifications
You must be signed in to change notification settings - Fork 6
/
Core.lua
123 lines (105 loc) · 3.61 KB
/
Core.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
NepgearsyMM = NepgearsyMM or class()
NepgearsyMM.SavePath = SavePath .. "NepgearsyMM_Preferences.txt"
NepgearsyMM.DescInfoPath = SavePath .. "NepgearsyMM_PersonalDescription.txt"
NepgearsyMM.DescInfo = ""
NepgearsyMM.AssetsDirectory = ModPath .. "assets/NepgearsyMM/"
NepgearsyMM.SoftAssetsDirectory = "assets/NepgearsyMM/"
NepgearsyMM.MenusDirectory = ModPath .. "menu/"
NepgearsyMM.Data = {}
NepgearsyMM.Localization = {}
NepgearsyMM.Localization[1] = ModPath .. "localization/english.txt"
NepgearsyMM.Localization[2] = ModPath .. "localization/german.txt"
NepgearsyMM.Localization[3] = ModPath .. "localization/russian.txt"
NepgearsyMM.Localization[4] = ModPath .. "localization/turkish.txt"
NepgearsyMM.Localization[5] = ModPath .. "localization/spanish.txt"
NepgearsyMM.Localization[6] = ModPath .. "localization/french.txt"
NepgearsyMM.Localization[7] = ModPath .. "localization/schinese.txt"
NepgearsyMM.Localization[8] = ModPath .. "localization/portuguese.txt"
NepgearsyMM.Localization[9] = ModPath .. "localization/thai.txt"
NepgearsyMM.CAN_ADD_FILES = false
NepgearsyMM.CAN_USE_SYSTEMFS = false
function NepgearsyMM:init()
self:_check_special_variables()
self:Load()
self:LoadDescriptionFile()
self:_init_icons()
self:_init_menus()
self:_check_other_mods()
self._initialized = true
self:log("init() finished!")
end
function NepgearsyMM:log(t)
local tostring_log = tostring(t)
log("[NepgearsyMM] - " .. tostring_log)
end
function NepgearsyMM:Load()
local file = io.open( self.SavePath , "r")
if file then
for k, v in pairs(json.decode(file:read("*all")) or {}) do
if k then
self.Data[k] = v
end
end
file:close()
end
end
function NepgearsyMM:Save()
if file.DirectoryExists( SavePath ) then
local file = io.open( self.SavePath , "w+")
if file then
file:write(json.encode(self.Data))
file:close()
end
end
end
function NepgearsyMM:LoadDescriptionFile()
local file = io.open( self.DescInfoPath , "r")
if file then
local content = file:read("*all")
self.DescInfo = content
else
io.open( self.DescInfoPath , "w+")
end
end
function NepgearsyMM:_check_special_variables()
if DB.create_entry then
self.CAN_ADD_FILES = true
end
if SystemFS and SystemFS.list then
self.CAN_USE_SYSTEMFS = true
end
end
function NepgearsyMM:create_texture_entry(texture_path_ingame, texture_path_inmod)
if not self.CAN_ADD_FILES then
return
end
DB:create_entry(Idstring("texture"), Idstring(texture_path_ingame), texture_path_inmod)
self:log("Loaded custom asset: " .. tostring(texture_path_inmod))
end
function NepgearsyMM:_init_icons()
if not self.CAN_USE_SYSTEMFS then
return
end
for i, v in ipairs(SystemFS:list(self.AssetsDirectory)) do
local wo_extension = string.gsub(v, ".texture", "")
self:create_texture_entry(self.SoftAssetsDirectory .. wo_extension, self.AssetsDirectory .. v)
end
self:log("Loaded all the custom assets!")
end
function NepgearsyMM:_init_menus()
if not self.CAN_USE_SYSTEMFS then
MenuHelper:LoadFromJsonFile(self.MenusDirectory .. "0_main.json", NepgearsyMM, NepgearsyMM.Data)
MenuHelper:LoadFromJsonFile(self.MenusDirectory .. "friendlist_options.json", NepgearsyMM, NepgearsyMM.Data)
MenuHelper:LoadFromJsonFile(self.MenusDirectory .. "scene_options.json", NepgearsyMM, NepgearsyMM.Data)
return
end
for i, v in ipairs(SystemFS:list(self.MenusDirectory)) do
MenuHelper:LoadFromJsonFile(self.MenusDirectory .. v, NepgearsyMM, NepgearsyMM.Data)
end
end
function NepgearsyMM:_check_other_mods()
self.POSER = false
if Poser then
self.POSER = true
end
end