Skip to content

Commit 447ae5e

Browse files
authored
Vita Nearest Neighbour Option
some bugs fixed
1 parent 1591032 commit 447ae5e

File tree

11 files changed

+220
-43
lines changed

11 files changed

+220
-43
lines changed

AUTOPLUG2/menu.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ function menu_gral()
7272
if buttons.up or buttons.analogly < -60 then scroll:up() end
7373
if buttons.down or buttons.analogly > 60 then scroll:down() end
7474

75-
--if buttons.select then error("Debugger") end
76-
7775
if buttons.accept then menu[scroll.sel].funct() end
7876

7977
vol_mp3()

AUTOPLUG2/scripts/psvita/autoboot.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function autoboot()
3838
buttons.interval(10,6)
3939
while true do
4040
buttons.read()
41-
if change then buttons.homepopup(0) else buttons.homepopup(1) end
41+
if change or ReloadConfig then buttons.homepopup(0) else buttons.homepopup(1) end
4242

4343
if back then back:blit(0,0) end
4444

AUTOPLUG2/scripts/psvita/autoplugin.lua

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ function plugins_installation(tb,sel)
138138
else
139139
os.message(LANGUAGE["UPDATE_WIFI_IS_ON"])
140140
end
141-
142-
141+
143142
elseif tb[sel].path == "VitaGrafix.suprx" then
144143
files.delete("tmp")
145144
if back2 then back2:blit(0,0) end
@@ -329,7 +328,7 @@ function autoplugin()
329328
--local icon0 = nil
330329
while true do
331330
buttons.read()
332-
if change then buttons.homepopup(0) else buttons.homepopup(1) end
331+
if change or ReloadConfig then buttons.homepopup(0) else buttons.homepopup(1) end
333332
if back2 then back2:blit(0,0) end
334333

335334
screen.print(10,15,LANGUAGE["LIST_PLUGINS"].." "..toinstall.."/"..#tb_cop,1,color.white)
@@ -428,7 +427,6 @@ function autoplugin()
428427

429428
-------------------------- Controls --------------------------
430429

431-
--if buttons.select then error("FTP") end
432430
if buttons.cancel then
433431
--Clean
434432
for i=1,scr.maxim do

AUTOPLUG2/scripts/psvita/catherine.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function Catherine_HD()
2222
local scroll,selector,xscroll = newScroll(patchs,#patchs),1,10
2323
while true do
2424
buttons.read()
25-
if change then buttons.homepopup(0) else buttons.homepopup(1) end
25+
if change or ReloadConfig then buttons.homepopup(0) else buttons.homepopup(1) end
2626

2727
if back2 then back2:blit(0,0) end
2828

AUTOPLUG2/scripts/psvita/menu_psvita.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ dofile("scripts/psvita/autoplugin.lua")
2020
dofile("scripts/psvita/plugins_online.lua")
2121
dofile("scripts/psvita/p4golden.lua")
2222
dofile("scripts/psvita/catherine.lua")
23+
dofile("scripts/psvita/nearest.lua")
2324

2425
Catherine = false
2526
if game.exists("PCSG01179") then Catherine = true end
@@ -40,6 +41,10 @@ local onlineplugins_callback = function ()
4041
plugins_online2()
4142
end
4243

44+
local VitaNearest_callback = function ()
45+
VitaNearest()
46+
end
47+
4348
local p4_callback = function ()
4449
P4Golden_HD()
4550
end
@@ -59,8 +64,9 @@ function menu_ps()
5964
{ text = LANGUAGE["MENU_PSVITA_INSTALL_PLUGINS"], desc = LANGUAGE["MENU_PSVITA_INSTALL_PLUGINS_DESC"], funct = installp_callback },
6065
{ text = LANGUAGE["MENU_PSVITA_UNINSTALL_PLUGINS"], desc = LANGUAGE["MENU_PSVITA_UNINSTALL_PLUGINS_DESC"], funct = uinstallp_callback },
6166
{ text = LANGUAGE["MENU_PSVITA_INSTALL_SD2VITA"], desc = LANGUAGE["MENU_PSVITA_INSTALL_SD2VITA_DESC"], funct = sd2vita_callback },
67+
{ text = LANGUAGE["MENU_PSVITA_INSTALL_NEAREST"], desc = LANGUAGE["INSTALLP_DESC_VITANEARESTN"], funct = VitaNearest_callback },
6268
}
63-
69+
6470
if P4Golden then
6571
table.insert(menu, { text = LANGUAGE["MENU_PSVITA_INSTALL_P4G_HD"], desc = LANGUAGE["MENU_PSVITA_INSTALL_P4G_HD_DESC"], funct = p4_callback } )
6672
end
@@ -84,7 +90,9 @@ function menu_ps()
8490
{ text = LANGUAGE["MENU_PSVITA_INSTALL_PLUGINS"], desc = LANGUAGE["MENU_PSVITA_INSTALL_PLUGINS_DESC"], funct = installp_callback },
8591
{ text = LANGUAGE["MENU_PSVITA_UNINSTALL_PLUGINS"], desc = LANGUAGE["MENU_PSVITA_UNINSTALL_PLUGINS_DESC"], funct = uinstallp_callback },
8692
{ text = LANGUAGE["MENU_PSVITA_INSTALL_SD2VITA"], desc = LANGUAGE["MENU_PSVITA_INSTALL_SD2VITA_DESC"], funct = sd2vita_callback },
93+
{ text = LANGUAGE["MENU_PSVITA_INSTALL_NEAREST"], desc = LANGUAGE["INSTALLP_DESC_VITANEARESTN"], funct = VitaNearest_callback },
8794
}
95+
8896
if P4Golden then
8997
table.insert(menu, { text = LANGUAGE["MENU_PSVITA_INSTALL_P4G_HD"], desc = LANGUAGE["MENU_PSVITA_INSTALL_P4G_HD_DESC"], funct = p4_callback } )
9098
end
@@ -99,7 +107,7 @@ function menu_ps()
99107
end
100108

101109
buttons.read()
102-
if change then buttons.homepopup(0) else buttons.homepopup(1) end
110+
if change or ReloadConfig then buttons.homepopup(0) else buttons.homepopup(1) end
103111

104112
if back then back:blit(0,0) end
105113

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
function search_gameid()
2+
3+
local descript = LANGUAGE["MENU_PSVITA_INSTALL_NEAREST"]
4+
for j=1,#plugins do
5+
if "INSTALLP_DESC_VITANEARESTN" == plugins[j].KEY then
6+
descript = plugins[j].name
7+
end
8+
end
9+
10+
local list_tmp = game.list(__GAME_LIST_APP)
11+
local tmp = {
12+
title = "ALL", id = "ALL"
13+
}
14+
15+
if list_tmp then
16+
table.sort(list_tmp, function (a,b) return string.lower(a.title)<string.lower(b.title) end)
17+
table.insert(list_tmp, 1, tmp)
18+
end
19+
20+
local limit = 9
21+
local scroll = newScroll(list_tmp,limit)
22+
local xscroll = 13
23+
24+
buttons.interval(10,6)
25+
while true do
26+
buttons.read()
27+
if change or ReloadConfig then buttons.homepopup(0) else buttons.homepopup(1) end
28+
29+
if back then back:blit(0,0) end
30+
31+
draw.offsetgradrect(0,0,960,55,color.blue:a(85),color.blue:a(85),0x0,0x0,20)
32+
screen.print(480,20,LANGUAGE["MENU_PSVITA_INSTALL_NEAREST"],1.2,color.white,0x0,__ACENTER)
33+
34+
local y = 65
35+
for i=scroll.ini, scroll.lim do
36+
if i == scroll.sel then draw.offsetgradrect(5,y-12,943,40,color.shine:a(75),color.shine:a(135),0x0,0x0,21) end
37+
38+
if screen.textwidth(list_tmp[i].title) > 925 then
39+
xscroll = screen.print(xscroll, y, list_tmp[i].title,1,color.white,color.blue,__SLEFT,935)
40+
else
41+
screen.print(13, y, list_tmp[i].title,1,color.white,color.blue,__ALEFT)
42+
end
43+
44+
screen.print(938,y,list_tmp[i].id,1.2,color.white,0x0,__ARIGHT)
45+
y += 45
46+
end
47+
48+
---- Draw Scroll Bar
49+
local ybar,hbar = 55, (limit*45)
50+
draw.fillrect(950,ybar-2,8,hbar,color.shine)
51+
--if scroll.maxim >= limit then
52+
local pos_height = math.max(hbar/scroll.maxim, limit)
53+
--Bar Scroll
54+
draw.fillrect(950, ybar-2 + ((hbar-pos_height)/(scroll.maxim-1))*(scroll.sel-1), 8, pos_height, color.new(0,255,0))
55+
--end
56+
57+
screen.print(480, 490, descript,1,color.white,color.blue,__ACENTER)
58+
59+
if buttonskey then buttonskey:blitsprite(10,523,scancel) end
60+
screen.print(45,525,LANGUAGE["STRING_BACK"],1,color.white,color.black, __ALEFT)
61+
62+
if buttonskey3 then buttonskey3:blitsprite(920,518,1) end
63+
screen.print(915,522,LANGUAGE["STRING_CLOSE"],1,color.white,color.blue, __ARIGHT)
64+
65+
screen.flip()
66+
67+
-------------------------- Controls --------------------------
68+
69+
if buttons.released.cancel then break end
70+
71+
--Exit
72+
if buttons.start then
73+
exit_bye_bye()
74+
end
75+
76+
vol_mp3()
77+
78+
if scroll.maxim > 0 then
79+
if buttons.left or buttons.right then xscroll = 10 end
80+
81+
if buttons.up or buttons.analogly < -60 then
82+
if scroll:up() then xscroll = 10 end
83+
end
84+
if buttons.down or buttons.analogly > 60 then
85+
if scroll:down() then xscroll = 10 end
86+
end
87+
88+
if buttons.accept then
89+
return list_tmp[scroll.sel].id
90+
end
91+
end
92+
93+
end
94+
95+
end
96+
97+
98+
function VitaNearest()
99+
100+
--if os.dialog(LANGUAGE["MENU_PSVITA_INSTALL_NEAREST_Q"], LANGUAGE["MENU_PSVITA_INSTALL_NEAREST"], __DIALOG_MODE_OK_CANCEL) == true then
101+
local _section = search_gameid()
102+
if _section then
103+
104+
--os.message(_section)
105+
106+
if _section == "ALL" then
107+
--Buscar todos los gameids de este plugin y borrarlos de tai
108+
local ids = tai.findALL("VitaNearestNeighbour.suprx")
109+
if ids then
110+
for i=1,#ids do
111+
--os.message()
112+
tai.del(ids[i].section,"VitaNearestNeighbour.suprx")
113+
end
114+
end
115+
116+
files.copy(path_plugins.."VitaNearestNeighbour.suprx", path_tai)
117+
tai.put("ALL", "ur0:tai/VitaNearestNeighbour.suprx")
118+
ReloadConfig = true
119+
120+
os.message("VitaNearestNeighbour.suprx\n\nALL\n\n"..LANGUAGE["STRING_INSTALLED"])
121+
122+
else
123+
files.copy(path_plugins.."VitaNearestNeighbour.suprx", path_tai)
124+
tai.del("ALL", "VitaNearestNeighbour.suprx")
125+
tai.put(_section, "ur0:tai/VitaNearestNeighbour.suprx")
126+
ReloadConfig = true
127+
128+
os.message("VitaNearestNeighbour.suprx".."\n\n".._section.."\n\n"..LANGUAGE["STRING_INSTALLED"])
129+
end
130+
131+
end
132+
133+
end

AUTOPLUG2/scripts/psvita/p4golden.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function P4Golden_HD()
4141
local scroll,selector,xscroll = newScroll(patchs,#patchs),1,10
4242
while true do
4343
buttons.read()
44-
if change then buttons.homepopup(0) else buttons.homepopup(1) end
44+
if change or ReloadConfig then buttons.homepopup(0) else buttons.homepopup(1) end
4545

4646
if back2 then back2:blit(0,0) end
4747

AUTOPLUG2/scripts/psvita/plugins_online.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ function plugins_online2()
291291
while true do
292292
buttons.read()
293293

294-
if change then buttons.homepopup(0) else buttons.homepopup(1) end
294+
if change or ReloadConfig then buttons.homepopup(0) else buttons.homepopup(1) end
295295

296296
if back then back:blit(0,0) end
297297

AUTOPLUG2/scripts/psvita/pmanager.lua

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function searchPlugByPath(p, sect, path)
1313
--print(string.format("SPP [%s]: %s|%d", (sect or "NOTHING"), (path or "unkpath"), (idx or 999)))
1414
if not p or not sect or not p[sect] then return nil end
1515
for i=1, #p[sect] do
16-
if path == files.nopath(p[sect][i].path:lower()) then
16+
if path:lower() == files.nopath(p[sect][i].path:lower()) then
1717
return i;
1818
end
1919
end
@@ -179,7 +179,7 @@ function pluginsmanager()
179179
end
180180

181181
if buttons.accept and not plugs[sections[over]][scroll.sel].is_sys then
182-
if os.dialog(plugs[sections[over]][scroll.sel].file, LANGUAGE["UNINSTALLP_QUESTION"], __DIALOG_MODE_OK_CANCEL, __ACENTER) == true then
182+
if os.dialog(plugs[sections[over]][scroll.sel].file, LANGUAGE["UNINSTALLP_QUESTION"], __DIALOG_MODE_OK_CANCEL) == true then
183183

184184
-- Special for Yamt
185185
if plugs[sections[over]][scroll.sel].file == "yamt.suprx" then --Yamt
@@ -227,37 +227,52 @@ function pluginsmanager()
227227
change = true
228228
end
229229
end
230-
230+
231+
-- Special for VitaNearestNeighbour
231232
local section1 = sections[over]
232233
local path1 = files.nopath(plugs[sections[over]][scroll.sel].path:lower())
234+
233235
local section2 = ""
234236
local path2 = ""
235-
if plugs[sections[over]][scroll.sel].bridge then -- Remove second plug of the selected
236-
section1 = plugs[sections[over]][scroll.sel].bridge.section
237-
path1 = plugs[sections[over]][scroll.sel].bridge.path:lower()
238-
--os.message("bridge: "..path1.."\n"..section1)
239-
if plugs[sections[over]][scroll.sel].bridge.section2 then
240-
section2 = plugs[sections[over]][scroll.sel].bridge.section2
241-
path2 = plugs[sections[over]][scroll.sel].bridge.path2:lower()
242-
--os.message("bridge2: "..path2.."\n"..section2)
237+
238+
if plugs[sections[over]][scroll.sel].file:lower() == "vitanearestneighbour.suprx" then
239+
local idx3 = searchPlugByPath(plugs, sections[over], "vitanearestneighbour.suprx")
240+
if idx3 then
241+
--os.message("ESPECIAL")
242+
tai.del(sections[over], plugs[sections[over]][idx3].path)
243+
table.remove(plugs[sections[over]], idx3)
244+
bridge_n["vitanearestneighbour.suprx"][sections[over]] = nil
245+
ReloadConfig = true
243246
end
244-
end
247+
else
245248

246-
local idx = searchPlugByPath(plugs, section1, path1);
247-
if idx then
248-
--os.message("idx: "..path1.."\n"..section1)
249-
--Delete plugin
250-
if path1 then
251-
--os.message(path1)
252-
if path1 != "adrenaline_kernel.skprx" then
253-
--files.delete(plugs[section1][idx].path)
249+
if plugs[sections[over]][scroll.sel].bridge then -- Remove second plug of the selected
250+
section1 = plugs[sections[over]][scroll.sel].bridge.section
251+
path1 = plugs[sections[over]][scroll.sel].bridge.path:lower()
252+
--os.message("bridge: "..path1.."\n"..section1)
253+
if plugs[sections[over]][scroll.sel].bridge.section2 then
254+
section2 = plugs[sections[over]][scroll.sel].bridge.section2
255+
path2 = plugs[sections[over]][scroll.sel].bridge.path2:lower()
256+
--os.message("bridge2: "..path2.."\n"..section2)
257+
end
258+
end
259+
260+
local idx = searchPlugByPath(plugs, section1, path1);
261+
if idx then
262+
--os.message("idx: "..path1.."\n"..section1)
263+
--Delete plugin
264+
if path1 then
265+
--os.message(path1)
266+
if path1 != "adrenaline_kernel.skprx" then
267+
--files.delete(plugs[section1][idx].path)
268+
end
254269
end
270+
--print(string.format("E [%s]: %s|%d", path1, section1, (idx or 300)))
271+
--print(plugs[section1][idx].path)
272+
tai.del(section1, plugs[section1][idx].path)
273+
table.remove(plugs[section1], idx)
274+
bridge_n[path1][section1] = nil
255275
end
256-
--print(string.format("E [%s]: %s|%d", path1, section1, (idx or 300)))
257-
--print(plugs[section1][idx].path)
258-
tai.del(section1, plugs[section1][idx].path)
259-
table.remove(plugs[section1], idx)
260-
bridge_n[path1][section1] = nil
261276
end
262277

263278
ReloadConfig = true
@@ -275,7 +290,7 @@ function pluginsmanager()
275290

276291
if #need_second > 0 then
277292
if os.dialog(path2.." "..ENGLISH_US["UNINSTALLP_QUESTION_NEED"].."\n"..(table.concat(msg_need, '\n'))..LANGUAGE["UNINSTALLP_PLUGINS_NEED"],
278-
LANGUAGE["MENU_PSVITA_UNINSTALL_PLUGINS_DESC"], __DIALOG_MODE_OK_CANCEL, __ACENTER) then
293+
LANGUAGE["MENU_PSVITA_UNINSTALL_PLUGINS_DESC"], __DIALOG_MODE_OK_CANCEL) == true then
279294
for i=1, #need_second do
280295
local _path = need_second[i].path or ""
281296
local _section = need_second[i].section or ""

AUTOPLUG2/scripts/psvita/sd2vita.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function install()
2020
local x_lenw1, x_lenw2, x_lenw3, x_lenw4, x_lenw5 = 25, 25, 25, 25, 25
2121
while true do
2222
buttons.read()
23-
if change then buttons.homepopup(0) else buttons.homepopup(1) end
23+
if change or ReloadConfig then buttons.homepopup(0) else buttons.homepopup(1) end
2424
if back2 then back2:blit(0, 0) end
2525

2626
screen.print(480, 18, LANGUAGE["MENU_TITLE_SD2VITA"], 1.2, color.white, 0x0, __ACENTER)
@@ -137,7 +137,7 @@ function configure()
137137

138138
while true do
139139
buttons.read()
140-
if change then buttons.homepopup(0) else buttons.homepopup(1) end
140+
if change or ReloadConfig then buttons.homepopup(0) else buttons.homepopup(1) end
141141
if back2 then back2:blit(0, 0) end
142142

143143
draw.offsetgradrect(0,0,960,55,color.blue:a(85),color.blue:a(85),0x0,0x0,20)

0 commit comments

Comments
 (0)