Repository navigation
Expand file tree
/
Copy pathmalverk.lua
More file actions
243 lines (224 loc) · 15.8 KB
/
Copy pathmalverk.lua
File metadata and controls
243 lines (224 loc) · 15.8 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
Malverk = SMODS.current_mod
Malverk.badges = {}
assert(SMODS.load_file('api/AltTexture.lua'))()
assert(SMODS.load_file('utils/keys.lua'))()
assert(SMODS.load_file('utils/ui.lua'))()
if Malverk.testing then SMODS.load_file('testing/test.lua')() end
function Malverk.set_defaults()
local pack = TexturePacks['default']
for _, key in pairs(pack.textures) do
local texture = AltTextures[key]
local game_table = AltTextures_Utils.game_table[texture.set] or 'P_CENTERS'
for i, center in ipairs(texture.keys or {}) do
if G[game_table][center] then
if texture.set == 'Seal' then
G.P_SEALS[center].default_pos = G.P_SEALS[center].default_pos or copy_table(G[game_table][center].sprite_pos)
G[game_table][center]:remove()
G[game_table][center] = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS['centers'], G.P_SEALS[center].default_pos)
else
G[game_table][center].default_atlas = G[game_table][center].default_atlas or texture.atlas.name
G[game_table][center].atlas = G[game_table][center].default_atlas
end
if center == 'c_soul' then
G.default_soul = G.default_soul or Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS["centers"], G.P_CENTERS.soul.pos)
G.shared_soul = G.default_soul
end
G[game_table][center].default_pos = G[game_table][center].default_pos or G[game_table][center].pos
G[game_table][center].pos = G[game_table][center].default_pos
G[game_table][center].default_soul = G[game_table][center].default_soul or G[game_table][center].soul_pos and copy_table(G[game_table][center].soul_pos) or "1"
if G[game_table][center].default_soul == "1" then
G[game_table][center].soul_pos = false
else
G[game_table][center].soul_pos = G[game_table][center].default_soul
end
if texture.set == "Stake" or texture.set == 'Sticker' then
G.default_stickers = G.default_stickers or Malverk.copy_stickers()
for k, v in pairs(G.default_stickers) do
G.shared_stickers[k]:remove()
G.shared_stickers[k] = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS[v.atlas.name or v.atlas.key], v.sprite_pos)
if G['shared_sticker_'..k] then
G['shared_sticker_'..k]:remove()
G['shared_sticker_'..k] = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS[v.atlas.name or v.atlas.key], v.sprite_pos)
end
end
end
G[game_table][center].default_card_type_badge = G[game_table][center].default_card_type_badge or (G[game_table][center].set_card_type_badge and copy_table(G[game_table][center].set_card_type_badge) or '1')
if G[game_table][center].default_card_type_badge == '1' then
G[game_table][center].set_card_type_badge = false
else
G[game_table][center].set_card_type_badge = G[game_table][center].default_card_type_badge
end
G[game_table][center].default_loc_txt = G[game_table][center].default_loc_txt or copy_table(G.localization.descriptions[AltTextures_Utils.loc_table[texture.set] or texture.set][center .. (texture.set == Seal and '_seal' or '')])
local default_loc = G[game_table][center].default_loc_txt
SMODS.process_loc_text(G.localization.descriptions[AltTextures_Utils.loc_table[texture.set] or texture.set][center .. (texture.set == Seal and '_seal' or '')], 'name', default_loc, 'name')
SMODS.process_loc_text(G.localization.descriptions[AltTextures_Utils.loc_table[texture.set] or texture.set][center .. (texture.set == Seal and '_seal' or '')], 'text', default_loc, 'text')
end
end
end
init_localization()
end
function Malverk.update_atlas(atlas_type)
if table.size(TexturePacks) == 0 then return end
Malverk.set_defaults()
for _, pack_key in ipairs(Malverk.config.selected) do
if TexturePacks[pack_key] then
local pack = TexturePacks[pack_key]
if pack.key == 'default' then Malverk.set_defaults() else
for _, key in pairs(pack.textures) do
if Malverk.config.texture_configs[pack_key][key] then
local texture = AltTextures[key]
local game_table = AltTextures_Utils.game_table[texture.set] or 'P_CENTERS'
local soul_count = 0
for i, center in ipairs(texture.keys or {}) do
if G[game_table][center] then
if texture.set == 'Seal' then
G[game_table][center]:remove()
G[game_table][center] = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS[texture.atlas.key], (texture.columns and not texture.original_sheet and Malverk.get_pos_on_sheet(center, texture) or G.P_SEALS[center].default_pos))
else
G[game_table][center].atlas = texture.atlas.key
end
if texture.columns and not texture.original_sheet then -- update atlas
G[game_table][center].pos = {x = (i+soul_count-1) % texture.columns, y = math.floor((i+soul_count-1)/texture.columns)}
else
G[game_table][center].pos = G[game_table][center].default_pos or G[game_table][center].pos
end
if center == 'c_soul' then
if texture.soul then
G.shared_soul:remove()
G.shared_soul = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS[texture.soul_atlas.key], G.P_CENTERS.soul.pos)
else
G.shared_soul = G.default_soul
end
if texture.soul_keys and table.contains(texture.soul_keys, center) then
soul_count = soul_count + 1
G.shared_soul:remove()
G.shared_soul = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS[texture.atlas.key], {x = (i+soul_count-1) % texture.columns, y = math.floor((i+soul_count-1)/texture.columns)})
end
end
if texture.set == 'Sticker' then
if G['shared_sticker_'..center] then
G['shared_sticker_'..center]:remove()
G.shared_stickers[center]:remove()
G['shared_sticker_'..center] = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS[texture.atlas and texture.atlas.key or 'stickers'], texture.columns and not texture.original_sheet and {x = (i-1) % texture.columns, y = math.floor((i-1)/texture.columns)} or G.default_stickers[center].sprite_pos)
G.shared_stickers[center] = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS[texture.atlas and texture.atlas.key or 'stickers'], texture.columns and not texture.original_sheet and {x = (i-1) % texture.columns, y = math.floor((i-1)/texture.columns)} or G.default_stickers[center].sprite_pos)
end
end
if texture.soul_keys and table.contains(texture.soul_keys, center) then
soul_count = soul_count + 1
G[game_table][center].soul_pos = {x = (i+soul_count-1) % texture.columns, y = math.floor((i+soul_count-1)/texture.columns)}
elseif G[game_table][center].soul_pos and center ~= 'c_soul' then
if G[game_table][center].default_soul == "1" then
G[game_table][center].soul_pos = false
else
G[game_table][center].soul_pos = G[game_table][center].default_soul
end
-- G[game_table][center].soul_pos = G[game_table][center].default_soul == "1" and false or G[game_table][center].default_soul
end
if texture.stickers then
G.shared_stickers[center:sub(7)]:remove()
G.shared_stickers[center:sub(7)] = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS[texture.stickers.key], texture.columns and not texture.original_sheet and {x = (i-1) % texture.columns, y = math.floor((i-1)/texture.columns)} or G.default_stickers[center:sub(7)].sprite_pos)
end
local default_loc = G[game_table][center].default_loc_txt
local new_loc = {}
if texture.localization then -- if loc_txt exists, set it
if texture.set == 'Booster' then
local temp_center = center:sub(1, -3)
new_loc = G.localization.descriptions.alt_texture[texture.key][temp_center] or type(texture.localization) == 'table' and texture.localization[temp_center] or {}
SMODS.process_loc_text(G.localization.descriptions.Other[temp_center], 'name', new_loc.name and new_loc or default_loc, 'name')
SMODS.process_loc_text(G.localization.descriptions.Other[temp_center], 'text', new_loc.text and new_loc or default_loc, 'text')
else
new_loc = G.localization.descriptions.alt_texture[texture.key][center] or type(texture.localization) == 'table' and texture.localization[center] or {}
SMODS.process_loc_text(G.localization.descriptions[AltTextures_Utils.loc_table[texture.set] or texture.set][center .. (texture.set == Seal and '_seal' or '')], 'name', new_loc.name and new_loc or default_loc, 'name')
SMODS.process_loc_text(G.localization.descriptions[AltTextures_Utils.loc_table[texture.set] or texture.set][center .. (texture.set == Seal and '_seal' or '')], 'text', new_loc.text and new_loc or default_loc, 'text')
end
G[game_table][center].set_card_type_badge = new_loc.badge and Malverk.badges[new_loc.badge] or (G[game_table][center].default_card_type_badge ~= '1' and G[game_table][center].default_card_type_badge or false)
end
end
end
end
end
end
if pack.localization then
local loc = G.localization.descriptions.texture_packs[pack.key].localization
for center, new_loc in pairs(loc) do
local object = G.P_CENTERS[center] or nil
if object then
local game_table = AltTextures_Utils.game_table[object.set] or 'P_CENTERS'
local default_loc = G[game_table][center].default_loc_txt
if object.set == 'Booster' then
local temp_center = center:sub(1, -3)
SMODS.process_loc_text(G.localization.descriptions.Other[temp_center], 'name', new_loc.name and new_loc or default_loc, 'name')
SMODS.process_loc_text(G.localization.descriptions.Other[temp_center], 'text', new_loc.text and new_loc or default_loc, 'text')
else
SMODS.process_loc_text(G.localization.descriptions[AltTextures_Utils.loc_table[object.set] or object.set][center .. (object.set == Seal and '_seal' or '')], 'name', new_loc.name and new_loc or default_loc, 'name')
SMODS.process_loc_text(G.localization.descriptions[AltTextures_Utils.loc_table[object.set] or object.set][center .. (object.set == Seal and '_seal' or '')], 'text', new_loc.text and new_loc or default_loc, 'text')
end
G[game_table][center].set_card_type_badge = new_loc.badge and Malverk.badges[new_loc.badge] or (G[game_table][center].default_card_type_badge ~= '1' and G[game_table][center].default_card_type_badge or false)
end
end
end
end
end
-- update all visible cards
for _, card in pairs(G.I.CARD) do
if card.set_sprites and not card.params.texture_pack then
local _center = G.P_CENTERS[card.config.center_key]
if _center.atlas or G.ASSET_ATLAS[_center.set] then
card.children.center.scale = {
x=G.ASSET_ATLAS[_center.atlas or _center.set].px,
y=G.ASSET_ATLAS[_center.atlas or _center.set].py
}
end
card:set_sprites(_center)
end
end
init_localization() -- update localizations
end
Malverk.update_stake = function(stake_key, texture, i)
local table
for i, v in ipairs(G.P_CENTER_POOLS.Stake) do
if v.key == stake_key then table = v end
end
table.atlas = texture.atlas.key
if texture.columns and not texture.original_sheet then -- update atlas
table.pos = {x = (i-1) % texture.columns, y = math.floor((i-1)/texture.columns)}
else
table.pos = table.default_pos or table.pos
end
local default_loc = table.default_loc_txt
local new_loc = {}
if texture.localisation and texture.localisation[stake_key] then -- if loc_txt exists, set it
new_loc = texture.localisation[stake_key]
end
SMODS.process_loc_text(G.localization.descriptions[AltTextures_Utils.loc_table[texture.set] or texture.set][stake_key], 'name', new_loc.name and new_loc or default_loc, 'name')
SMODS.process_loc_text(G.localization.descriptions[AltTextures_Utils.loc_table[texture.set] or texture.set][stake_key], 'text', new_loc.text and new_loc or default_loc, 'text')
end
Malverk.copy_stickers = function()
local stickers = {}
for k, v in pairs(G.shared_stickers) do
stickers[k] = Sprite(0, 0, G.CARD_W, G.CARD_H, G.ASSET_ATLAS[v.atlas and (v.atlas.name or v.atlas.key) or 'stickers'], v.sprite_pos)
end
return stickers
end
local main_menu = Game.main_menu
function Game:main_menu(context)
Malverk.update_atlas()
main_menu(self, context)
end
local load_profile_ref = G.FUNCS.load_profile
G.FUNCS.load_profile = function(delete_prof_data)
Malverk.set_defaults()
load_profile_ref(delete_prof_data)
end
SMODS.Atlas.pre_inject_class = function (self)
for _, atlas in pairs(G.ASSET_ATLAS) do
atlas.atlas_table = "ASSET_ATLAS"
atlas.columns = atlas.image:getWidth() / atlas.px
atlas.rows = atlas.image:getHeight() / atlas.py
end
for _, atlas in pairs(G.ANIMATION_ATLAS) do
atlas.atlas_table = "ANIMATION_ATLAS"
atlas.columns = atlas.image:getWidth() / atlas.px
atlas.rows = atlas.image:getHeight() / atlas.py
end
end