---- LUA XMB Theme Cycler v0.1
---- Author: LuizLizard
-----------------------------------------------
---- Some code grabbed from SG57 flash example.

green = Color.new(0,255,0)
magenta = Color.new(255,0,255)
white = Color.new(255,255,255)
red = Color.new(255,0,0)
blue = Color.new(0,0,255)
yellow = Color.new(255,255,0)
control = 0

-- Create control file if not present
file = io.open("control.txt", "r")
if file then
control = file:read("*n")
file:close()
end
if control == "" then
file = io.open("control.txt", "w")
control = 1
file:write(control)
file:close()
end
--

-- Open and check wich theme to flash and increase count by 1 and reset to 0 if count = 3
file = io.open("control.txt", "r")
if file then
control = file:read("*n")
file:close()
end
theme = control
control = control + 1
if control == 4 then
control = 1
end
file = io.open("control.txt", "w")
file:write(control)
file:close()
--

-- Flash specified theme
-- Unassing flash0
System.Unassign("flash0:")
-- Reassing flash0 with writing rights
System.Assign("flash0:", "lflash0:0,0", "flashfat0:")
-- Start flashing
if theme == 1 then
		System.writeFile("ms0:/themecycler/1/topmenu_plugin.rco","flash0:/vsh/resource/topmenu_plugin.rco","no")

		System.writeFile("ms0:/themecycler/1/opening_plugin.rco","flash0:/vsh/resource/opening_plugin.rco","no")

		System.writeFile("ms0:/themecycler/1/savedata_plugin.rco","flash0:/vsh/resource/savedata_plugin.rco","no")
		
		System.writeFile("ms0:/themecycler/1/gameboot.pmf","flash0:/vsh/resource/gameboot.pmf","no")
		
		System.writeFile("ms0:/themecycler/1/system_plugin.rco","flash0:/vsh/resource/system_plugin.rco","no")

		System.writeFile("ms0:/themecycler/1/01-12.bmp","flash0:/vsh/resource/01-12.bmp","no")

		System.writeFile("ms0:/themecycler/1/impose_plugin.rco","flash0:/vsh/resource/impose_plugin.rco","no")

        System.writeFile("ms0:/themecycler/1/premo_plugin.rco","flash0:/vsh/resource/premo_plugin.rco","no")

		System.writeFile("ms0:/themecycler/1/system_plugin_fg.rco","flash0:/vsh/resource/system_plugin_fg.rco","no")

		System.writeFile("ms0:/themecycler/1/system_plugin_bg.rco","flash0:/vsh/resource/system_plugin_bg.rco","no")
	
		System.writeFile("ms0:/themecycler/1/photo_plugin.rco","flash0:/vsh/resource/photo_plugin.rco","no")

		System.writeFile("ms0:/themecycler/1/game_plugin.rco","flash0:/vsh/resource/game_plugin.rco","no")

		System.writeFile("ms0:/themecycler/1/sysconf_plugin.rco","flash0:/vsh/resource/sysconf_plugin.rco","no")

		System.writeFile("ms0:/themecycler/1/ltn0.pgf","flash0:/font/ltn0.pgf","no")

end

if theme == 2 then
		System.writeFile("ms0:/themecycler/2/topmenu_plugin.rco","flash0:/vsh/resource/topmenu_plugin.rco","no")

		System.writeFile("ms0:/themecycler/2/opening_plugin.rco","flash0:/vsh/resource/opening_plugin.rco","no")

		System.writeFile("ms0:/themecycler/2/savedata_plugin.rco","flash0:/vsh/resource/savedata_plugin.rco","no")
		
		System.writeFile("ms0:/themecycler/2/gameboot.pmf","flash0:/vsh/resource/gameboot.pmf","no")
		
        System.writeFile("ms0:/themecycler/2/premo_plugin.rco","flash0:/vsh/resource/premo_plugin.rco","no")

		System.writeFile("ms0:/themecycler/2/system_plugin.rco","flash0:/vsh/resource/system_plugin.rco","no")

		System.writeFile("ms0:/themecycler/2/01-12.bmp","flash0:/vsh/resource/01-12.bmp","no")

		System.writeFile("ms0:/themecycler/2/impose_plugin.rco","flash0:/vsh/resource/impose_plugin.rco","no")

		System.writeFile("ms0:/themecycler/2/system_plugin_fg.rco","flash0:/vsh/resource/system_plugin_fg.rco","no")

		System.writeFile("ms0:/themecycler/2/system_plugin_bg.rco","flash0:/vsh/resource/system_plugin_bg.rco","no")
	
		System.writeFile("ms0:/themecycler/2/photo_plugin.rco","flash0:/vsh/resource/photo_plugin.rco","no")

		System.writeFile("ms0:/themecycler/2/game_plugin.rco","flash0:/vsh/resource/game_plugin.rco","no")

		System.writeFile("ms0:/themecycler/2/sysconf_plugin.rco","flash0:/vsh/resource/sysconf_plugin.rco","no")

		System.writeFile("ms0:/themecycler/2/ltn0.pgf","flash0:/font/ltn0.pgf","no")

end

if theme == 3 then
		System.writeFile("ms0:/themecycler/3/topmenu_plugin.rco","flash0:/vsh/resource/topmenu_plugin.rco","no")

		System.writeFile("ms0:/themecycler/3/opening_plugin.rco","flash0:/vsh/resource/opening_plugin.rco","no")

		System.writeFile("ms0:/themecycler/3/savedata_plugin.rco","flash0:/vsh/resource/savedata_plugin.rco","no")
		
		System.writeFile("ms0:/themecycler/3/gameboot.pmf","flash0:/vsh/resource/gameboot.pmf","no")
		
        System.writeFile("ms0:/themecycler/3/premo_plugin.rco","flash0:/vsh/resource/premo_plugin.rco","no")

		System.writeFile("ms0:/themecycler/3/system_plugin.rco","flash0:/vsh/resource/system_plugin.rco","no")

		System.writeFile("ms0:/themecycler/3/01-12.bmp","flash0:/vsh/resource/01-12.bmp","no")

		System.writeFile("ms0:/themecycler/3/impose_plugin.rco","flash0:/vsh/resource/impose_plugin.rco","no")

		System.writeFile("ms0:/themecycler/3/system_plugin_fg.rco","flash0:/vsh/resource/system_plugin_fg.rco","no")

		System.writeFile("ms0:/themecycler/3/system_plugin_bg.rco","flash0:/vsh/resource/system_plugin_bg.rco","no")
	
		System.writeFile("ms0:/themecycler/3/photo_plugin.rco","flash0:/vsh/resource/photo_plugin.rco","no")

		System.writeFile("ms0:/themecycler/3/game_plugin.rco","flash0:/vsh/resource/game_plugin.rco","no")

		System.writeFile("ms0:/themecycler/3/sysconf_plugin.rco","flash0:/vsh/resource/sysconf_plugin.rco","no")

		System.writeFile("ms0:/themecycler/3/ltn0.pgf","flash0:/font/ltn0.pgf","no")

end

System.Quit()
















