Added blacklist, fixed compiler warnings
This commit is contained in:
parent
a87abaf976
commit
010e64b382
@ -3,21 +3,22 @@ System.createDirectory("ux0:/data/TrackPlug/")
|
|||||||
System.createDirectory("ux0:/data/TrackPlug/Records")
|
System.createDirectory("ux0:/data/TrackPlug/Records")
|
||||||
System.createDirectory("ux0:/data/TrackPlug/Config")
|
System.createDirectory("ux0:/data/TrackPlug/Config")
|
||||||
System.createDirectory("ux0:/data/TrackPlug/Assets")
|
System.createDirectory("ux0:/data/TrackPlug/Assets")
|
||||||
-- Scanning TrackPlug folder
|
-- Creating blacklist file if it doesn't exist
|
||||||
local tbl = System.listDirectory("ux0:/data/TrackPlug/Records")
|
if not System.doesFileExist("ux0:/data/TrackPlug/blacklist.txt") then
|
||||||
local blacklist = {}
|
local blacklist_file = System.openFile("ux0:/data/TrackPlug/blacklist.txt", FCREATE)
|
||||||
-- Removing blacklisted games
|
System.closeFile(blacklist_file)
|
||||||
--[[for i, file in pairs(tbl) do
|
|
||||||
local titleid = string.sub(file.name,1,-5)
|
|
||||||
for k, toberemoved in pairs(blacklist) do
|
|
||||||
if titleid == blacklist[k] then
|
|
||||||
System.deleteFile("ux0:/data/TrackPlug/Records"..file.name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
-- Reset the table
|
-- Reading blacklist file
|
||||||
tbl = System.listDirectory("ux0:/data/TrackPlug/Records")]]--
|
local blacklist_file = System.openFile("ux0:/data/TrackPlug/blacklist.txt", FREAD)
|
||||||
|
local blacklist_fsize = System.sizeFile(blacklist_file)
|
||||||
|
local blacklist_var = System.readFile(blacklist_file, blacklist_fsize)
|
||||||
|
System.closeFile(blacklist_file)
|
||||||
|
-- Removing blacklisted titles
|
||||||
|
for line in blacklist_var:gmatch("([^\n]*)\n?") do
|
||||||
|
System.deleteFile("ux0:/data/TrackPlug/Records/" .. line .. ".bin")
|
||||||
|
end
|
||||||
|
-- Read entries to a table
|
||||||
|
local tbl = System.listDirectory("ux0:/data/TrackPlug/Records")
|
||||||
if tbl == nil then
|
if tbl == nil then
|
||||||
tbl = {}
|
tbl = {}
|
||||||
end
|
end
|
||||||
@ -259,6 +260,7 @@ end
|
|||||||
local sel_val = 128
|
local sel_val = 128
|
||||||
local decrease = true
|
local decrease = true
|
||||||
local freeze = false
|
local freeze = false
|
||||||
|
local freeze_blacklist = false
|
||||||
local mov_y = 0
|
local mov_y = 0
|
||||||
local mov_step = 0
|
local mov_step = 0
|
||||||
local new_list_idx = nil
|
local new_list_idx = nil
|
||||||
@ -311,7 +313,7 @@ function RenderList()
|
|||||||
if i ~= list_idx + 5 then
|
if i ~= list_idx + 5 then
|
||||||
Graphics.drawImage(5, y + mov_y, big_tbl[i].icon)
|
Graphics.drawImage(5, y + mov_y, big_tbl[i].icon)
|
||||||
end
|
end
|
||||||
Graphics.debugPrint(150, y + 35 + mov_y, big_tbl[i].title, Color.new(230,140,175))
|
Graphics.debugPrint(150, y + 35 + mov_y, string.gsub(big_tbl[i].title, "\n", " "), Color.new(230,140,175))
|
||||||
--Graphics.debugPrint(150, y + 45 + mov_y, "Title ID: " .. big_tbl[i].id, white)
|
--Graphics.debugPrint(150, y + 45 + mov_y, "Title ID: " .. big_tbl[i].id, white)
|
||||||
--Graphics.debugPrint(150, y + 65 + mov_y, "Region: " .. big_tbl[i].region, white)
|
--Graphics.debugPrint(150, y + 65 + mov_y, "Region: " .. big_tbl[i].region, white)
|
||||||
Graphics.debugPrint(150, y + 65 + mov_y, "Playtime: " .. big_tbl[i].ptime, white)
|
Graphics.debugPrint(150, y + 65 + mov_y, "Playtime: " .. big_tbl[i].ptime, white)
|
||||||
@ -319,7 +321,7 @@ function RenderList()
|
|||||||
if r_idx == 0 then
|
if r_idx == 0 then
|
||||||
r_idx = #tbl
|
r_idx = #tbl
|
||||||
end
|
end
|
||||||
Graphics.debugPrint(920, y + 100 + mov_y, "#" .. r_idx, white)
|
Graphics.debugPrint(910, y + 100 + mov_y, "#" .. r_idx, white)
|
||||||
y = y + 132
|
y = y + 132
|
||||||
if real_i <= 0 then
|
if real_i <= 0 then
|
||||||
i = real_i
|
i = real_i
|
||||||
@ -331,23 +333,32 @@ end
|
|||||||
|
|
||||||
-- Main loop
|
-- Main loop
|
||||||
local f_idx = 1
|
local f_idx = 1
|
||||||
|
local f_idx_2 = 1
|
||||||
local useless = 0
|
local useless = 0
|
||||||
|
local blacklisted_title = "kek"
|
||||||
|
local blacklisted_title_id = "kek"
|
||||||
local oldpad = Controls.read()
|
local oldpad = Controls.read()
|
||||||
while #tbl > 0 do
|
while #tbl > 0 do
|
||||||
Graphics.initBlend()
|
Graphics.initBlend()
|
||||||
Graphics.fillRect(0,960,0,544,Color.new(10,5,15))
|
Graphics.fillRect(0,960,0,544,Color.new(10,5,15))
|
||||||
|
Graphics.fillRect(0,960,4,140,Color.new(20,20,20))
|
||||||
wav:init()
|
wav:init()
|
||||||
RenderList()
|
RenderList()
|
||||||
if freeze then
|
if freeze then
|
||||||
showAlarm("Do you want to delete this record permanently? \n" .. tbl[list_idx].title, f_idx)
|
showAlarm("Do you want to clear playtime of this record? \n" .. string.gsub(tbl[list_idx].title, "\n", " "), f_idx)
|
||||||
end
|
end
|
||||||
|
if freeze_blacklist then
|
||||||
|
showAlarm("Do you want to blacklist this record? \n" .. blacklisted_title, f_idx_2)
|
||||||
|
end
|
||||||
Graphics.termBlend()
|
Graphics.termBlend()
|
||||||
Screen.flip()
|
Screen.flip()
|
||||||
Screen.waitVblankStart()
|
Screen.waitVblankStart()
|
||||||
local pad = Controls.read()
|
local pad = Controls.read()
|
||||||
if Controls.check(pad, SCE_CTRL_UP) and mov_y == 0 then
|
if Controls.check(pad, SCE_CTRL_UP) and mov_y == 0 then
|
||||||
if freeze then
|
if freeze then
|
||||||
f_idx = 1
|
f_idx = 1
|
||||||
|
elseif freeze_blacklist then
|
||||||
|
f_idx_2 = 1
|
||||||
else
|
else
|
||||||
new_list_idx = list_idx - 1
|
new_list_idx = list_idx - 1
|
||||||
if new_list_idx == 0 then
|
if new_list_idx == 0 then
|
||||||
@ -357,7 +368,9 @@ while #tbl > 0 do
|
|||||||
end
|
end
|
||||||
elseif Controls.check(pad, SCE_CTRL_DOWN) and mov_y == 0 then
|
elseif Controls.check(pad, SCE_CTRL_DOWN) and mov_y == 0 then
|
||||||
if freeze then
|
if freeze then
|
||||||
f_idx = 2
|
f_idx = 2
|
||||||
|
elseif freeze_blacklist then
|
||||||
|
f_idx_2 = 2
|
||||||
else
|
else
|
||||||
new_list_idx = list_idx + 1
|
new_list_idx = list_idx + 1
|
||||||
if new_list_idx > #tbl then
|
if new_list_idx > #tbl then
|
||||||
@ -366,17 +379,30 @@ while #tbl > 0 do
|
|||||||
mov_y = -11
|
mov_y = -11
|
||||||
end
|
end
|
||||||
elseif Controls.check(pad, SCE_CTRL_TRIANGLE) and not Controls.check(oldpad, SCE_CTRL_TRIANGLE) and not freeze then
|
elseif Controls.check(pad, SCE_CTRL_TRIANGLE) and not Controls.check(oldpad, SCE_CTRL_TRIANGLE) and not freeze then
|
||||||
freeze = true
|
freeze = true
|
||||||
f_idx = 1
|
f_idx = 2
|
||||||
elseif Controls.check(pad, SCE_CTRL_CROSS) and not Controls.check(oldpad, SCE_CTRL_CROSS) and freeze then
|
f_idx_2 = 2
|
||||||
freeze = false
|
elseif Controls.check(pad, SCE_CTRL_CROSS) and not Controls.check(oldpad, SCE_CTRL_CROSS) and freeze then
|
||||||
if f_idx == 1 then -- Delete
|
freeze = false
|
||||||
System.deleteFile("ux0:/data/TrackPlug/Records/" .. tbl[list_idx].id .. ".bin")
|
if f_idx == 1 then -- Delete
|
||||||
|
blacklisted_title_id = tbl[list_idx].id
|
||||||
|
blacklisted_title = string.gsub(tbl[list_idx].title, "\n", " ")
|
||||||
|
System.deleteFile("ux0:/data/TrackPlug/Records/" .. tbl[list_idx].id .. ".bin")
|
||||||
|
freeze_blacklist = true
|
||||||
table.remove(tbl, list_idx)
|
table.remove(tbl, list_idx)
|
||||||
big_tbl = {}
|
big_tbl = {}
|
||||||
list_idx = list_idx - 1
|
list_idx = list_idx - 1
|
||||||
end
|
end
|
||||||
end
|
elseif Controls.check(pad, SCE_CTRL_CROSS) and not Controls.check(oldpad, SCE_CTRL_CROSS) and freeze_blacklist then
|
||||||
|
freeze_blacklist = false
|
||||||
|
if f_idx_2 == 1 then -- Blacklist
|
||||||
|
local file = System.openFile("ux0:/data/TrackPlug/blacklist.txt", FRDWR)
|
||||||
|
local file_size = System.sizeFile(file)
|
||||||
|
local file_var = System.readFile(file, file_size)
|
||||||
|
System.writeFile(file, blacklisted_title_id .. "\n", string.len(blacklisted_title_id) + 1)
|
||||||
|
System.closeFile(file)
|
||||||
|
end
|
||||||
|
end
|
||||||
oldpad = pad
|
oldpad = pad
|
||||||
end
|
end
|
||||||
|
|
||||||
|
13
src/main.c
13
src/main.c
@ -1,12 +1,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <taihen.h>
|
#include <taihen.h>
|
||||||
#include <psp2/io/fcntl.h>
|
#include <psp2kern/kernel/sysmem.h>
|
||||||
#include <psp2kern/kernel/sysmem.h>
|
#include <psp2kern/kernel/modulemgr.h>
|
||||||
|
#include <psp2kern/kernel/iofilemgr.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdarg.h>
|
|
||||||
#include <dolcesdkkern.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <psp2/appmgr.h>
|
|
||||||
|
|
||||||
#define printf ksceDebugPrintf
|
#define printf ksceDebugPrintf
|
||||||
#define SECOND 1000000
|
#define SECOND 1000000
|
||||||
@ -97,7 +94,7 @@ static void adrenaline_titlewriter(char *dummy_id,char *dummy_title){
|
|||||||
char pathfolder[128];
|
char pathfolder[128];
|
||||||
snprintf(path, 128, "ux0:/data/TrackPlug/Assets/%s/title.txt", dummy_id);
|
snprintf(path, 128, "ux0:/data/TrackPlug/Assets/%s/title.txt", dummy_id);
|
||||||
snprintf(pathfolder, 128, "ux0:/data/TrackPlug/Assets/%s/", dummy_id);
|
snprintf(pathfolder, 128, "ux0:/data/TrackPlug/Assets/%s/", dummy_id);
|
||||||
int dfd = ksceIoMkdir(pathfolder,6);
|
ksceIoMkdir(pathfolder,6);
|
||||||
SceUID fd = ksceIoOpen(path,
|
SceUID fd = ksceIoOpen(path,
|
||||||
SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
|
SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
|
||||||
if (fd < 0) return;
|
if (fd < 0) return;
|
||||||
@ -197,7 +194,7 @@ int event_handler(int pid, int ev, int a3, int a4, int *a5, int a6) {
|
|||||||
//Write games playtime and reset the variable. If Adrenaline was in XMB, no need
|
//Write games playtime and reset the variable. If Adrenaline was in XMB, no need
|
||||||
//to write it again as it will be handled by the thread.
|
//to write it again as it will be handled by the thread.
|
||||||
if (!isxmb) write_playtime(adrenaline_id);
|
if (!isxmb) write_playtime(adrenaline_id);
|
||||||
snprintf(adrenaline_id,12,"pleasePLEASE");
|
snprintf(adrenaline_id,12,"pleasePLEAS");
|
||||||
pspemu = 0;
|
pspemu = 0;
|
||||||
} else
|
} else
|
||||||
write_playtime(id);
|
write_playtime(id);
|
||||||
|
Reference in New Issue
Block a user