Skip to content

Commit

Permalink
gamelist auto-update, updated to VitaGrafix 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirezar committed Oct 14, 2018
1 parent a4050e8 commit 1403b48
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 28 deletions.
46 changes: 44 additions & 2 deletions build/gamelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ IB=960x544
FPS=false

[Borderlands 2]
ID=PCSF00570,PCSE00383
ID=PCSF00570,PCSE00383,PCSF00576
FB=OFF
IB=false
FPS=false
Expand All @@ -16,11 +16,17 @@ FB=false
IB=960x544
FPS=false

[Dragon Ball Z: Battle of Z]
ID=PCSB00396,PCSE00305,PCSG00213
FB=false
IB=OFF
FPS=false

[Dragon Quest Builders]
ID=PCSE00912,PCSB00981,PCSE00912
FB=false
IB=960x544
FPS=false
FPS=OFF

[F1 2011]
ID=PCSB00027
Expand Down Expand Up @@ -106,12 +112,42 @@ FB=false
IB=960x544
FPS=false

[Ninja Gaiden Sigma 2 Plus]
ID=PCSB00294,PCSE00233,PCSG00157
FB=false
IB=OFF
FPS=false

[Persona 4 Golden]
ID=PCSB00245,PCSE00120,PCSG00004,PCSG00563,PCSH00021
FB=false
IB=960x544
FPS=false

[Ratchet & Clank]
ID=PCSF00484,PCSF00482,PCSA00133
FB=OFF
IB=false
FPS=false

[Ratchet & Clank: Going Commando / Ratchet & Clank 2: Locked and Loaded]
ID=PCSF00485,PCSF00482,PCSA00133
FB=OFF
IB=false
FPS=false

[Ratchet & Clank: Up Your Arsenal / Ratchet & Clank 3]
ID=PCSF00486,PCSF00482,PCSA00133
FB=OFF
IB=false
FPS=false

[Ratchet & Clank: QForce / Ratchet & Clank: Full Frontal Assault]
ID=PCSF00191,PCSA00086
FB=OFF
IB=false
FPS=false

[Ridge Racer]
ID=PCSB00048,PCSE00001,PCSG00001
FB=false
Expand Down Expand Up @@ -142,6 +178,12 @@ FB=false
IB=960x544
FPS=false

[Utawarerumono: Chiriyuku Mono he no Komoriuta]
ID=PCSG01079
FB=false
IB=672x384
FPS=false

[World of Final Fantasy]
ID=PCSB00951,PCSE00880,PCSH00223,PCSG00709
FB=false
Expand Down
120 changes: 95 additions & 25 deletions build/index.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ isWaitingToScroll = false
pad = 0 -- Controller
previousPad = 0 -- Controller previous state, used to check if a button was just pressed, or if it is held down

needsToGetVersion = true
checkForUpgrade = false
result = ""
list_version = ""
app_version = ""
list_v_num = 0
app_v_num = 0
app_folder = "VGCF00001"

auto_update = false

timerObj = Timer.new()

-- Set Buttons to nil each frame
Expand All @@ -81,6 +83,38 @@ function NilButtons()
save_button = nil
end

function ReadAppConfig()

local file = nil
if System.doesFileExist("ux0:data/VitaGrafix/appconfig.txt") == false then
file = System.openFile("ux0:data/VitaGrafix/appconfig.txt", FCREATE)
local str = "auto_update=0"
System.writeFile(file, str, string.len(str))
System.closeFile(file)
end
file = System.openFile("ux0:data/VitaGrafix/appconfig.txt", FREAD)
System.seekFile(file, 0, SET)
local app_cfg = System.readFile(file, System.sizeFile(file))
System.closeFile(file)

if string.match( app_cfg, "auto_update=1") then
auto_update = true
end

end

function WriteAppConfig()
local file = System.openFile("ux0:data/VitaGrafix/appconfig.txt", FCREATE)
local str = "auto_update="
if auto_update then
str = str .. 1
else
str = str .. 0
end
System.writeFile(file, str, string.len(str))
System.closeFile(file)
end

function DownloadFile(str)
-- Opening a new socket and connecting to the host
skt = Socket.connect("vgcfvita.000webhostapp.com", 80)
Expand Down Expand Up @@ -170,10 +204,26 @@ function GetLocalVersion()
ux_app_version = string.sub(ux_version_text, i, j)
local ux_app_version_num = GetNumber(ux_app_version)

list_v_num = ux_list_version_num
app_v_num = ux_app_version_num

if list_version_num > ux_list_version_num or app_version_num > ux_app_version_num then
file = System.openFile("ux0:data/Vitagrafix/versions.txt", FCREATE)
System.writeFile(file, version_text, string.len(version_text))
System.closeFile(file)

file = System.openFile("app0:/gamelist.txt", FREAD)
System.seekFile(file, 0, SET)
local gamelisttext = System.readFile(file, System.sizeFile(file))
System.closeFile(file)

file = System.openFile("ux0:data/Vitagrafix/gamelist.txt", FCREATE)
System.writeFile(file, gamelisttext, string.len(gamelisttext))
System.closeFile(file)

list_v_num = list_version_num
app_v_num = app_version_num

end


Expand All @@ -197,6 +247,8 @@ function GetVersion()
local app_version_num = GetNumber(app_version)

-- Initializing Network


Network.init()

-- Checking if connection is available
Expand All @@ -222,7 +274,7 @@ function GetVersion()

--if not string.match(new_app_version, app_version) then

if not string.match(new_list_version, list_version) then
if list_version_num < new_list_number then
local wantsToUpdate = 0

while wantsToUpdate == 0 do
Expand Down Expand Up @@ -299,7 +351,6 @@ function GetVersion()
app_version = string.sub(version_text, i, j)
app_v_num = GetNumber(app_version)


end

function GetNumber(str)
Expand Down Expand Up @@ -695,6 +746,8 @@ function GUI()

Graphics.debugPrint(5, 150, "Enabled", Color.new(255,255,255))
Graphics.debugPrint(5, 180, "OSD", Color.new(255,255,255))
Graphics.debugPrint(5, 210, "Auto Update List", Color.new(255,255,255))
Graphics.debugPrint(5, 240, "Update Lists Now", Color.new(255,255,255))

if main_enable == 1 then
Graphics.debugPrint(250, 150, "X", Color.new(255,255,255))
Expand All @@ -708,14 +761,20 @@ function GUI()
Graphics.debugPrint(250, 180, "", Color.new(255,255,255))
end

if auto_update then
Graphics.debugPrint(250, 210, "X", Color.new(255,255,255))
else
Graphics.debugPrint(250, 210, "", Color.new(255,255,255))
end



objectNum = 2
objectNum = 4

Graphics.debugPrint(5, 150 + 30 * objectNum, "Save Config", Color.new(255,255,255))
save_button = objectNum + 1

available_buttons = 3
available_buttons = 5

else -- If on any game

Expand Down Expand Up @@ -768,23 +827,23 @@ function GUI()
if games[gameCounter].fb ~= "false" then
Graphics.debugPrint(5, 150 + 30 * objectNum, "Framebuffer", Color.new(255,255,255))
Graphics.debugPrint(250, 150 + 30 * objectNum, games[gameCounter].fb, Color.new(255,255,255))
Graphics.debugPrint(400, 150 + 30 * objectNum, "(Default: " .. games[gameCounter].default_fb .. ")", Color.new(255,255,255))
Graphics.debugPrint(550, 150 + 30 * objectNum, "(Default: " .. games[gameCounter].default_fb .. ")", Color.new(255,255,255))
objectNum = objectNum + 1
fb_button = objectNum
end

if games[gameCounter].ib ~= "false" then
Graphics.debugPrint(5, 150 + 30 * objectNum, "Internal Resolution", Color.new(255,255,255))
Graphics.debugPrint(250, 150 + 30 * objectNum, games[gameCounter].ib, Color.new(255,255,255))
Graphics.debugPrint(400, 150 + 30 * objectNum, "(Default: " .. games[gameCounter].default_ib .. ")", Color.new(255,255,255))
Graphics.debugPrint(550, 150 + 30 * objectNum, "(Default: " .. games[gameCounter].default_ib .. ")", Color.new(255,255,255))
objectNum = objectNum + 1
ib_button = objectNum
end

if games[gameCounter].fps ~= "false" then
Graphics.debugPrint(5, 150 + 30 * objectNum, "FPS Cap", Color.new(255,255,255))
Graphics.debugPrint(250, 150 + 30 * objectNum, games[gameCounter].fps, Color.new(255,255,255))
Graphics.debugPrint(400, 150 + 30 * objectNum, "(Default: " .. games[gameCounter].default_fps .. ")", Color.new(255,255,255))
Graphics.debugPrint(550, 150 + 30 * objectNum, "(Default: " .. games[gameCounter].default_fps .. ")", Color.new(255,255,255))
objectNum = objectNum + 1
fps_button = objectNum
end
Expand Down Expand Up @@ -818,7 +877,16 @@ end

-- Function called when X was pressed
function CrossPressed()
if selected_button == 1 then -- Button 1 is the enabled option
if selected_button == save_button then -- Save button, saves ENTIRE CONFIG (not game specific changes)
WriteToFile()
WriteAppConfig()
EndDraw()
BeginDraw()
Graphics.debugPrint(350, 252, "Configuration Saved!", Color.new(255,255,255))
EndDraw()

System.wait(1000000)
elseif selected_button == 1 then -- Button 1 is the enabled option
if gameCounter == 0 then
main_enable = SwitchBool(main_enable)
else
Expand All @@ -832,15 +900,15 @@ function CrossPressed()
end
elseif selected_button == ib_button then -- Internal res button, opens keyboard
Keyboard.clear()
Keyboard.show("0 < X <= 960 and 0 < Y <= 544 or OFF", games[gameCounter].ib, 7, TYPE_DEFAULT, MODE_TEXT)
elseif selected_button == save_button then -- Save button, saves ENTIRE CONFIG (not game specific changes)
WriteToFile()
EndDraw()
BeginDraw()
Graphics.debugPrint(350, 252, "Configuration Saved!", Color.new(255,255,255))
EndDraw()

System.wait(1000000)
Keyboard.show("0 < X <= 960 and 0 < Y <= 544 or OFF", games[gameCounter].ib, 15, TYPE_DEFAULT, MODE_TEXT)
elseif selected_button == 3 then -- Button 3 is the Auto Update button
if gameCounter == 0 then
auto_update = not auto_update
end
elseif selected_button == 4 then -- Button 4 is the Update Now button
if gameCounter == 0 then
checkForUpgrade = true;
end
end
end

Expand Down Expand Up @@ -929,11 +997,17 @@ end

-- Initialization function
function Start()

CreateGameList()
FindCurrentSettings()
GetRegions()
WriteToFile()
--GetVersion()
GetLocalVersion()
ReadAppConfig()
pad = Controls.read()
if auto_update == true and not Controls.check(pad, SCE_CTRL_LTRIGGER) then
checkForUpgrade = true
end
end

------------------------------------------------------------------------------------------------- Code Execution ----------------------------------------------------------------------------
Expand All @@ -948,15 +1022,11 @@ while true do

Timer.reset(timerObj)

if needsToGetVersion then
if (checkForUpgrade) then
GetVersion()
needsToGetVersion = false
checkForUpgrade = false
end

if System.getAsyncState() == 1 then
result = System.getAsyncResult()
end

BeginDraw()
if Keyboard.getState() ~= RUNNING then

Expand Down
2 changes: 1 addition & 1 deletion build/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
gamelist=2.4
gamelist=3.1
app=1.2

0 comments on commit 1403b48

Please sign in to comment.