-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvr_options.lua
More file actions
336 lines (247 loc) · 7.34 KB
/
Copy pathvr_options.lua
File metadata and controls
336 lines (247 loc) · 7.34 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
local SCREEN_ID = "VersaoVermelhaOptions"
local M = {}
function M.install(mod)
-- ==========================================
-- Opções persistentes
-- ==========================================
mod.options:define({
{
key = "idioma_golpes",
type = "choice",
default = "portuguese1",
choices = {
{ "PT-BR (17)", "portuguese1" },
--{ "PT-BR (12)", "portuguese2" },
{ "INGLÊS (12)", "english" },
},
},
{
key = "mostrar_inimigo",
type = "choice",
default = false,
choices = {
{ "SIM", true },
{ "NÃO", false },
},
},
{
key = "precos_linha",
type = "choice",
default = true,
choices = {
{ "LINHA DE BAIXO", true },
{ "MESMA LINHA", false },
},
},
{
key = "trainer_card",
type = "choice",
default = true,
choices = {
{ "CORRIGIDO", true },
{ "ORIGINAL", false },
},
},
})
-- ==========================================
-- Funções de opção
-- ==========================================
local function getOption(game, key)
local options = game.save and game.save.options
local bucket = options
and options.modOptions
and options.modOptions[mod.id]
if bucket and bucket[key] ~= nil then
return bucket[key]
end
return mod.options:get(key)
end
local function setOption(game, key, value)
game.save.options.modOptions =
game.save.options.modOptions or {}
game.save.options.modOptions[mod.id] =
game.save.options.modOptions[mod.id] or {}
game.save.options.modOptions[mod.id][key] = value
if game.mods then
game.mods.modOptions =
game.mods.modOptions or {}
game.mods.modOptions[mod.id] =
game.mods.modOptions[mod.id] or {}
game.mods.modOptions[mod.id][key] = value
end
if game.writeOptions then
game:writeOptions()
end
end
-- ==========================================
-- Tela de opções
-- ==========================================
mod.content.screens:register(SCREEN_ID, {
new = function(game)
if mod.exports.precos_linha == nil then
mod.exports.precos_linha = true
end
if mod.exports.trainer_card == nil then
mod.exports.trainer_card = true
end
local Font = mod.ui.Font
-- Carrega os valores salvos
mod.exports.idioma_golpes =
getOption(game, "idioma_golpes")
mod.exports.mostrar_inimigo =
getOption(game, "mostrar_inimigo")
mod.exports.precos_linha =
getOption(game, "precos_linha")
mod.exports.trainer_card =
getOption(game, "trainer_card")
local rows = {
{
label = "IDIOMA DOS GOLPES",
key = "idioma_golpes",
value = mod.exports.idioma_golpes,
},
{
label = "MOSTRAR “INIMIGO”",
key = "mostrar_inimigo",
value = mod.exports.mostrar_inimigo,
},
{
label = "PREÇOS E QTDs.",
key = "precos_linha",
value = mod.exports.precos_linha,
},
{
label = "TRAINER CARD",
key = "trainer_card",
value = mod.exports.trainer_card,
},
}
local screen = {
game = game,
rows = rows,
index = 1,
isOpaque = true,
}
function screen:update()
local input = game.input
local row = self.rows[self.index]
if input:wasPressed("up") then
self.index = self.index > 1
and self.index - 1
or #self.rows
elseif input:wasPressed("down") then
self.index = self.index < #self.rows
and self.index + 1
or 1
elseif input:wasPressed("left")
or input:wasPressed("right")
or input:wasPressed("a") then
-- ==========================================
-- IDIOMA DOS GOLPES
-- ==========================================
if self.index == 1 then
if row.value == "english" then
row.value = "portuguese1"
--elseif row.value == "portuguese1" then
--w row.value = "portuguese2"
else
row.value = "english"
end
setOption(
game,
"idioma_golpes",
row.value
)
mod.exports.idioma_golpes = row.value
-- ==========================================
-- MOSTRAR "INIMIGO"
-- ==========================================
elseif self.index == 2 then
row.value = not row.value
setOption(
game,
"mostrar_inimigo",
row.value
)
mod.exports.mostrar_inimigo = row.value
-- ==========================================
-- PREÇOS E QTDs.
-- ==========================================
elseif self.index == 3 then
row.value = not row.value
setOption(
game,
"precos_linha",
row.value
)
mod.exports.precos_linha = row.value
-- ==========================================
-- TRAINER CARD
-- ==========================================
elseif self.index == 4 then
row.value = not row.value
setOption(
game,
"trainer_card",
row.value
)
mod.exports.trainer_card = row.value
end
elseif input:wasPressed("b") then
game.stack:pop()
end
end
function screen:draw()
Font.drawBox(0, 0, 20, 18)
for i, row in ipairs(self.rows) do
local y = 8 + (i - 1) * 24
if i == self.index then
Font.drawCode(0xED, 16, y + 8)
end
Font.draw(row.label, 16, y)
local value = row.value
if row.key == "idioma_golpes" then
if value == "english" then
value = "INGLÊS (12)"
elseif value == "portuguese1" then
value = "PT-BR (17)"
elseif value == "portuguese2" then
value = "PT-BR (12)"
end
elseif row.key == "mostrar_inimigo" then
value = value and "SIM" or "NÃO"
elseif row.key == "precos_linha" then
value = value and "LINHA DE BAIXO" or "MESMA LINHA"
elseif row.key == "trainer_card" then
value = value and "CORRIGIDO" or "ORIGINAL"
end
Font.draw(value, 24, y + 8)
end
Font.draw("B: VOLTAR", 8, 112)
Font.draw("OBS: RESETE PARA", 8, 120)
Font.draw(" OPÇÕES 1 E 2", 8, 128)
end
return screen
end,
})
-- ==========================================
-- OPTIONS > MODS
-- ==========================================
mod.hooks:wrap("ui.options.rows", function(next, game, rows)
local out = next(game, rows)
if type(out) ~= "table" then
return out
end
return mod.ui.insertBefore(out, "MODS", {
id = "versaovermelha",
label = "VERSÃO BRASILEIRA",
value = function()
return " OPÇÕES EXTRAS"
end,
activate = function(g)
mod.ui.push(g, SCREEN_ID)
end,
})
end)
end
return M