/
bubbles.lua
1193 lines (987 loc) · 34.4 KB
/
bubbles.lua
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[
Licensed by Creative Commons Attribution-ShareAlike 4.0
http://creativecommons.org/licenses/by-sa/4.0/
Designed By Gdljjrod & DevDavisNunez.
Collaborators: BaltaR4 & Wzjk.
]]
bubbles = {}
bubbles.len, dels, total_empty = 0,0,0
local crono2, click = timer.new(), false -- Timer and Oldstate to click actions.
function bubbles.scan()
--id, type, version, dev, path, title
local list = game.list(__GAME_LIST_APP)
table.sort(list ,function (a,b) return string.lower(a.id)<string.lower(b.id) end)
bubbles.list = {}
for i=1, #list do
if files.exists(list[i].path.."/data/boot.inf") or files.exists(list[i].path.."/data/boot.bin") then
local entry = {
id = list[i].id, -- GAMEID of the game.
path = list[i].path, -- Path of the game.
boot = list[i].path.."/data/boot.bin", -- Path to the boot.bin
imgp = "ur0:appmeta/"..list[i].id.."/icon0.png", -- Path to icon0 of the game.
bg0 = "ur0:appmeta/"..list[i].id.."/livearea/contents/bg0.png", -- Path to bg0 of the game.
title = list[i].title, -- TITLEID of the game.
delete = false,
}
if files.exists(list[i].path.."/data/boot.bin") then
--checking magic
local fp = io.open(list[i].path.."/data/boot.bin","r")
if fp then
local magic = str2int(fp:read(4))
fp:close()
if magic == 0x00424241 then table.insert(bubbles.list, entry) end
end
else
AutoMakeBootBin(list[i])
if files.exists(list[i].path.."/data/boot.bin") then table.insert(bubbles.list, entry) end
end
end
end--for
bubbles.len = #bubbles.list
if bubbles.len > 0 then
table.sort(bubbles.list ,function (a,b) return string.lower(a.id)<string.lower(b.id) end)
--Read data/boot.bin
for i=1, bubbles.len do
bubbles.list[i].lines = {}
local fp = io.open(bubbles.list[i].boot,"r")
if fp then
--Driver
fp:seek("set",0x04)
local driver = str2int(fp:read(4))
if driver < 0 or driver > 2 then driver = 0 end
table.insert(bubbles.list[i].lines, driver)
--Execute
fp:seek("set",0x08)
local modebin = str2int(fp:read(4))
if modebin < 0 or modebin > 2 then modebin = 0 end
table.insert(bubbles.list[i].lines, modebin)
--Customized
fp:seek("set",0x0C)
local custom = str2int(fp:read(4))
if custom < 0 or custom > 1 then custom = 1 end
table.insert(bubbles.list[i].lines, custom)
--Path
fp:seek("set",0x20)
bubbles.list[i].iso = fp:read()
if files.exists(bubbles.list[i].iso) then bubbles.list[i].exist = true
else
bubbles.list[i].exist = false
total_empty += 1
end
--Close
fp:close()
end--fp
end
end
end
-- src = objet game to launch
function bubbles.install(src)
files.delete("ux0:data/ABMVPK/")
local i=0
while game.exists(string.format("%s%03d",string.sub("PSPEMU00",1,-3),i)) do
i+=1
end
local lastid = string.format("%s%03d",string.sub("PSPEMU00",1,-3),i)
local work_dir = "ux0:data/ABMVPK/"
files.mkdir(work_dir)
files.delete(work_dir+lastid)
files.copy("bubbles/pspemuxxx",work_dir)
files.rename(work_dir.."pspemuxxx", lastid)
work_dir += lastid.."/"
--Resources to 8bits
buttons.homepopup(0)
------------------------------icon0 & startup
local timg = nil
timg = game.geticon0(src.path)
if back2 then back2:blit(0,0) end
draw.fillrect(0,0,960,30, color.shine)
screen.print(10,10,STRINGS_CONVERTING)
screen.print(950,10,"ICON0.PNG",1, color.white, color.blue, __ARIGHT)
screen.print(10,40,src.title_bubble or STRINGS_UNK,1, color.white, color.blue, __ALEFT)
if timg then
timg:center()
timg:blit(480,272)
end
screen.flip()
if timg then
timg:reset()
if src.nostretched then
image.save(timg:copyscale(128,128),work_dir.."sce_sys/icon0.png", 1)
else
image.save(image.nostretched(timg, colors[src.selcc]), work_dir.."sce_sys/icon0.png", 1)
end
--startup.png
if src.setpack == STRINGS_OPTION_MSG_NO or src.setpack == STRINGS_PSP_PSX_BUBBLES then
image.save(timg, work_dir.."sce_sys/livearea/contents/startup.png", 1)
else
if files.exists(__PATHSETS..src.setpack.."/startup.png") then
timg = image.load(__PATHSETS..src.setpack.."/startup.png")
image.save(image.startup(timg), work_dir.."sce_sys/livearea/contents/startup.png", 1)
else
image.save(timg, work_dir.."sce_sys/livearea/contents/startup.png", 1)
end
end
else
files.copy("bubbles/sce_sys_lman/icon0.png", work_dir.."sce_sys")
files.copy("bubbles/sce_sys_lman/startup.png", work_dir.."sce_sys/livearea/contents/")
end
------------------------------pic0 (boot) & bg0
if src.setpack == STRINGS_OPTION_MSG_NO or src.setpack == STRINGS_PSP_PSX_BUBBLES then
if src.setpack == STRINGS_PSP_PSX_BUBBLES or src.orig then
if src.type == "ME" then--PS1 Game
timg = PSX_IMG
else
timg = PSP_IMG
end
else
timg = game.getpic1(src.path)
end
if back2 then back2:blit(0,0) end
draw.fillrect(0,0,960,30, color.shine)
screen.print(10,10,STRINGS_CONVERTING)
screen.print(950,10,"PIC0.PNG",1, color.white, color.gray, __ARIGHT)
screen.print(10,40,src.title_bubble or STRINGS_UNK,1, color.white, color.blue, __ALEFT)
if timg then
timg:scale(75)
timg:center()
timg:blit(480,272)
end
screen.flip()
if src.setpack == STRINGS_PSP_PSX_BUBBLES or src.orig then os.delay(250) end
if src.setpack == STRINGS_PSP_PSX_BUBBLES or src.orig then
if src.type == "ME" then--PS1 Game
files.copy("bubbles/sce_sys_lman/ps1/bg0.png", work_dir.."sce_sys/livearea/contents/")
files.copy("bubbles/sce_sys_lman/ps1/pic0.png", work_dir.."sce_sys/")
else
files.copy("bubbles/sce_sys_lman/psp/bg0.png", work_dir.."sce_sys/livearea/contents/")
files.copy("bubbles/sce_sys_lman/psp/pic0.png", work_dir.."sce_sys/")
end
else
if timg then
timg:reset()
image.save(timg:copyscale(960,544), work_dir.."sce_sys/pic0.png", 1)
files.copy(work_dir.."sce_sys/pic0.png", work_dir.."sce_sys/livearea/contents")
files.rename(work_dir.."/sce_sys/livearea/contents/pic0.png","bg0.png")
else
if src.type == "ME" then--PS1 Game
files.copy("bubbles/sce_sys_lman/ps1/bg0.png", work_dir.."sce_sys/livearea/contents/")
files.copy("bubbles/sce_sys_lman/ps1/pic0.png", work_dir.."sce_sys/")
else
files.copy("bubbles/sce_sys_lman/psp/bg0.png", work_dir.."sce_sys/livearea/contents/")
files.copy("bubbles/sce_sys_lman/psp/pic0.png", work_dir.."sce_sys/")
end
end
end
else
--"PIC0.PNG", w = 960, h = 544 SETX (1 to 5)
local setimg = false
timg = image.load(__PATHSETS..src.setpack.."/PIC0.PNG")
if timg then setimg = true
else timg = game.getpic1(src.path) end
if back2 then back2:blit(0,0) end
draw.fillrect(0,0,960,30, color.shine)
screen.print(10,10,STRINGS_CONVERTING)
screen.print(950,10,"PIC0.PNG",1, color.white, color.gray, __ARIGHT)
screen.print(10,40,src.title_bubble or STRINGS_UNK,1, color.white, color.blue, __ALEFT)
if timg then
timg:scale(75)
timg:center()
timg:blit(480,272)
end
screen.flip()
if src.setpack == STRINGS_PSP_PSX_BUBBLES or src.orig then os.delay(250) end
if timg then
timg:reset()
local scale = false
if timg:getrealw() != 960 or timg:getrealh() != 544 then
timg=timg:copyscale(960,544)
scale = true
end
if __8PNG == 1 then
image.save(timg, work_dir.."sce_sys/pic0.png", 1)
else
if scale then
image.save(timg, work_dir.."sce_sys/pic0.png", 1)
elseif setimg then
files.copy(__PATHSETS..src.setpack.."/PIC0.PNG", work_dir.."sce_sys/")
else
image.save(timg, work_dir.."sce_sys/pic0.png", 1)
end
end
else
if src.type == "ME" then--PS1 Game
files.copy("bubbles/sce_sys_lman/ps1/pic0.png", work_dir.."sce_sys/")
else
files.copy("bubbles/sce_sys_lman/psp/pic0.png", work_dir.."sce_sys/")
end
end
--"BG0.PNG", w = 840, h = 500
setimg = false
local bg0 = image.load(__PATHSETS..src.setpack.."/BG0.PNG")
if not bg0 then
if timg then bg0 = timg end
else
setimg = true
end
if back2 then back2:blit(0,0) end
draw.fillrect(0,0,960,30, color.shine)
screen.print(10,10,STRINGS_CONVERTING)
screen.print(950,10,"BG0.PNG",1, color.white, color.blue, __ARIGHT)
screen.print(10,40,src.title_bubble or STRINGS_UNK,1, color.white, color.blue, __ALEFT)
if bg0 then
bg0:scale(85)
bg0:center()
bg0:blit(480,272)
end
screen.flip()
if bg0 then
bg0:reset()
local scale = false
if bg0:getrealw() != 840 or bg0:getrealh() != 500 then
bg0 = bg0:copyscale(840,500)
scale = true
end
if __8PNG == 1 then
image.save(bg0, work_dir.."sce_sys/livearea/contents/bg0.png", 1)
else
if scale then
image.save(bg0, work_dir.."sce_sys/livearea/contents/bg0.png", 1)
elseif setimg then
files.copy(__PATHSETS..src.setpack.."/BG0.PNG", work_dir.."sce_sys/livearea/contents/")
else
image.save(bg0, work_dir.."sce_sys/livearea/contents/bg0.png", 1)
end
end
else
if src.type == "ME" then--PS1 Game
files.copy("bubbles/sce_sys_lman/ps1/bg0.png", work_dir.."sce_sys/livearea/contents/")
else
files.copy("bubbles/sce_sys_lman/psp/bg0.png", work_dir.."sce_sys/livearea/contents/")
end
end
--TEMPLATE.XML
if files.exists(__PATHSETS..src.setpack.."/TEMPLATE.XML") then
files.copy(__PATHSETS..src.setpack.."/TEMPLATE.XML", work_dir.."sce_sys/livearea/contents/")
end
--FRAMEX.PNG 1 to 5
for i=1,5 do
if files.exists(__PATHSETS..src.setpack.."/FRAME"..i..".PNG") then
if __8PNG == 1 then
local frame = image.load(__PATHSETS..src.setpack.."/FRAME"..i..".PNG")
if frame then
image.save(frame, work_dir.."sce_sys/livearea/contents/FRAME"..i..".PNG", 1)
else
files.copy(__PATHSETS..src.setpack.."/FRAME"..i..".PNG", work_dir.."sce_sys/livearea/contents/")
end
else
files.copy(__PATHSETS..src.setpack.."/FRAME"..i..".PNG", work_dir.."sce_sys/livearea/contents/")
end
end
end
end
buttons.homepopup(1)
-- Set SFO & TITLE
local fp_sfo = io.open(work_dir.."sce_sys/PARAM.SFO", "r+")
if fp_sfo then
--STITLE offset
fp_sfo:seek("set",0x2C8)
local stitle = src.title_bubble
local fill = 51 - #stitle
for j=1,fill do
stitle = stitle..string.char(00)
end
fp_sfo:write(string.sub(stitle,1,51))
--TITLE offset
fp_sfo:seek("set",0x2FC)
local title = src.title_bubble
local fill = 127 - #title
for j=1,fill do
title = title..string.char(00)
end
fp_sfo:write(string.sub(title,1,127))
--TITLE_ID offset
fp_sfo:seek("set",0x37C)
fp_sfo:write(tostring(lastid))
--Close
fp_sfo:close()
end
--[[
game.setsfo(work_dir.."sce_sys/PARAM.SFO", "TITLE", tostring(bubble_title), 0)
game.setsfo(work_dir.."sce_sys/PARAM.SFO", "STITLE", tostring(bubble_title), 0)
game.setsfo(work_dir.."sce_sys/PARAM.SFO", "TITLE_ID", tostring(lastid), 0)
]]
-- Path ISO/CSO/PBP to BOOT.BIN
local fp = io.open(work_dir.."data/boot.bin", "r+")
if fp then
--Customized
fp:seek("set",0x0C)
fp:write(int2str(__CUSTOM))
local path2game = src.path
local fill = 256 - #src.path
for j=1,fill do
path2game = path2game..string.char(00)
end
fp:seek("set",0x20)
fp:write(path2game)
--Close
fp:close()
end--fp
--Install Bubble
buttons.homepopup(0)
bubble_id = lastid
local result = game.installdir(work_dir)
buttons.read()
buttons.homepopup(1)
if result == 1 then
src.install,src.state = "b",true
if src.inst then
src.inst,src.nostretched = false,false
src.selcc = __COLOR
if toinstall >0 then toinstall-=1 end
end
if bubbles.list then
local entry = {
id = lastid,
path = "ux0:app/"..lastid,
boot = "ux0:app/"..lastid.."/boot.bin",
imgp = "ur0:appmeta/"..lastid.."/icon0.png",
bg0 = "ur0:appmeta/"..lastid.."/livearea/contents/bg0.png",
title = src.title_bubble,
delete = false,
exist = true
}
table.insert(bubbles.list, entry)-- Insert entry in list of bubbles! :)
--Path2Game
bubbles.list[#bubbles.list].iso = src.path:lower()
--Driver&Execute&Customized
bubbles.list[#bubbles.list].lines = {}
table.insert(bubbles.list[#bubbles.list].lines, 0) --Default: 0 Inferno
table.insert(bubbles.list[#bubbles.list].lines, 0) --Default: 0 Eboot.bin
table.insert(bubbles.list[#bubbles.list].lines, __CUSTOM) --Default: 1 Customized
bubbles.len = #bubbles.list
table.sort(bubbles.list ,function (a,b) return string.lower(a.id)<string.lower(b.id) end)
end
else
custom_msg(STRINGS_ERROR_INST,0)
end
----------------------------------------------------------------------------------------------------------------------------
files.delete("ux0:data/ABMVPK/")
end
local pic_alpha, cronopic, show_pic, bg0img = 0, timer.new(), false, nil
function restart_cronopic()
cronopic:reset()
cronopic:start()
show_pic, bg0img = false,nil
pic_alpha = 0
end
function bubbles.settings()
local options_edit = { "DRIVER:", "EXECUTE:", "CUSTOMIZED:" }
local drivers = { "INFERNO", "MARCH33", "NP9660" }
local bins = { "EBOOT.BIN", "BOOT.BIN", "EBOOT.OLD" }
local enables = { "NO", "YES" }
local selector, optsel, change, bmaxim = 1,1,false,9
local scrids, xscr1, xscr2 = newScroll(bubbles.list, bmaxim), 110, 15
local mark,preview = false,nil
buttons.interval(12,6)
while true do
buttons.read()
touch.read()
if back2 then back2:blit(0,0) end
if math.minmax(tonumber(os.date("%d%m")),2512,2512) == tonumber(os.date("%d%m")) then stars.render() end
draw.fillrect(0,0,960,30, 0x64545353) --UP
screen.print(480,5, BUBBLES_TITLE, 1, color.white, color.blue, __ACENTER)
screen.print(950,5,BUBBLES_COUNT.." "..bubbles.len, 1, color.red, color.gray, __ARIGHT)
draw.fillrect(70,45,820,454,color.new(105,105,105,230))
draw.gradline(70,295,890,295,color.blue,color.green)
draw.gradline(70,296,890,296,color.green,color.blue)
draw.rect(70,45,820,454,color.blue)
if show_pic then
if bg0img then
if pic_alpha < 60 then
pic_alpha += 1.005
end
bg0img:blit(480,270,pic_alpha)
end
end
if scrids.maxim > 0 then
local y = 60
for i=scrids.ini, scrids.lim do
if i == scrids.sel then
draw.fillrect(320,y-1,330,18,color.green:a(100))
if not preview then
preview = image.load(bubbles.list[scrids.sel].imgp)
if preview then
preview:resize(120,120)
preview:setfilter(__IMG_FILTER_LINEAR, __IMG_FILTER_LINEAR)
end
end
end
if bubbles.list[i].exist then
screen.print(480,y,bubbles.list[i].id or STRINGS_UNK,1.0,color.white,color.gray,__ACENTER)
else
screen.print(480,y," ! "..bubbles.list[i].id or STRINGS_UNK,1.0,color.yellow,color.gray,__ACENTER)
end
if bubbles.list[i].delete then
draw.fillrect(750,y-1,30,18,color.new(255,255,255,100))
screen.print(757,y,SYMBOL_CROSS,1.0,color.white,color.red)
end
y += 23
end
--Bar Scroll
local ybar,h=55, (bmaxim*24)-2
draw.fillrect(660, ybar-2, 8, h, color.shine)
if scrids.maxim >= bmaxim then -- Draw Scroll Bar
local pos_height = math.max(h/scrids.maxim, bmaxim)
draw.fillrect(660, ybar-2 + ((h-pos_height)/(scrids.maxim-1))*(scrids.sel-1), 8, pos_height, color.new(0,255,0))
end
if preview then
screen.clip(200,150, 120/2)
preview:center()
preview:blit(200,150)
screen.clip()
end
screen.print(480, 305, bubbles.list[scrids.sel].title or STRINGS_UNK,1,color.white,color.gray, __ACENTER)
--Options txts
local y1=356
for i=1,4 do
if change then
if i == optsel then
if i==4 then
draw.fillrect(73,329,813,19,color.green:a(100))
else
draw.fillrect(73,y1-1,813,19,color.green:a(100))
end
end
end
if i != 4 then
screen.print(280, y1, options_edit[i],1,color.white,color.gray, __ALEFT)
end
y1+=23
end
if not change then
if bubbles.list[scrids.sel].exist then ccolor = color.green else ccolor = color.orange end
else
if optsel == 4 then ccolor = color.yellow
else if bubbles.list[scrids.sel].exist then ccolor = color.green else ccolor = color.orange end
end
end
--Path2Game
if screen.textwidth(bubbles.list[scrids.sel].iso or STRINGS_UNK) > 765 then
xscr1 = screen.print(xscr1, 330, bubbles.list[scrids.sel].iso or STRINGS_UNK,1,ccolor,color.gray,__SLEFT,765)
else
screen.print(480, 330, bubbles.list[scrids.sel].iso or STRINGS_UNK,1,ccolor,color.gray, __ACENTER)
end
--Driver&Execute&Customized
screen.print(680, 356, drivers[ bubbles.list[scrids.sel].lines[1] + 1 ],1,color.white,color.gray, __ARIGHT)
screen.print(680, 379, bins[ bubbles.list[scrids.sel].lines[2] + 1 ],1,color.white,color.gray, __ARIGHT)
screen.print(680, 402, enables[ bubbles.list[scrids.sel].lines[3] + 1 ],1,color.white,color.gray, __ARIGHT)
if not change then
if total_empty > 0 and dels <= 0 then
screen.print(480,448, "SELECT: "..BUBBLES_EMPTY, 1, color.white, color.blue, __ACENTER)
elseif dels > 0 then
screen.print(80,448, "SELECT: "..BUBBLES_SELSMARKS, 1, color.white, color.blue, __ALEFT)
screen.print(880,448, BUBBLES_STARTMARKS, 1, color.white, color.blue, __ARIGHT)
end
screen.print(80,475, SYMBOL_SQUARE..": "..BUBBLES_UNINSTALL.." ("..dels..")", 1, color.white, color.blue, __ALEFT)
screen.print(480,475, SYMBOL_TRIANGLE..": "..BUBBLES_EDITBOOT_BIN, 1, color.white, color.blue, __ACENTER)
screen.print(880,475, SYMBOL_BACK2..": "..BUBBLES_INJECT, 1, color.white, color.blue, __ARIGHT)
screen.print(480,523, SYMBOL_BACK..": "..BUBBLES_GOTOBACK, 1, color.white, color.blue, __ACENTER)
else
if optsel == 4 then
screen.print(80,475, SYMBOL_BACK2..": "..BUBBLES_EDITPATH, 1, color.white, color.blue, __ALEFT)
screen.print(880,475, SYMBOL_TRIANGLE..": "..BUBBLES_DONE_EDIT, 1, color.white, color.blue, __ARIGHT)
else
screen.print(80,475, "<- -> "..BUBBLES_TOGGLE, 1, color.white, color.blue, __ALEFT)
screen.print(880,475, SYMBOL_TRIANGLE..": "..BUBBLES_DONE_EDIT, 1, color.white, color.blue, __ARIGHT)
end
end
else
screen.print(480,200, BUBBLES_NOT_BUBBLES, 1, color.white, color.red, __ACENTER)
screen.print(480,230, BUBBLES_CREAT_BB, 1, color.white, color.red, __ACENTER)
screen.print(480,470, SYMBOL_BACK..": "..BUBBLES_GOTOBACK, 1, color.white, color.blue, __ACENTER)
end
draw.fillrect(0,516,960,30, 0x64545353)--Down
screen.flip()
--Controls
if scrids.maxim > 0 then
if cronopic:time() > 1050 then
show_pic = true
end
if buttons.triangle then
change = not change
if change then buttons.homepopup(0)
if not bg0img then
bg0img = image.load(bubbles.list[scrids.sel].bg0)
if bg0img then
bg0img:resize(820,454)
bg0img:setfilter(__IMG_FILTER_LINEAR, __IMG_FILTER_LINEAR)
bg0img:center()
end
end
else
buttons.interval(12,6)
restart_cronopic()
if bubbles.list[scrids.sel].update then
local fp = io.open(bubbles.list[scrids.sel].boot, "r+")
if fp then
local offset = 0x04
--i=1 for drivers, i=2 for Execute, i=3 for Customized
for i=1,3 do
fp:seek("set", offset * i)
fp:write(int2str(bubbles.list[scrids.sel].lines[i]))
end
local path2game = bubbles.list[scrids.sel].iso
local fill = 256 - #bubbles.list[scrids.sel].iso
for j=1,fill do
path2game = path2game..string.char(00)
end
fp:seek("set",0x20)
fp:write(path2game)
fp:close()
if files.exists(bubbles.list[scrids.sel].iso) then bubbles.list[scrids.sel].exist = true else bubbles.list[scrids.sel].exist = false end
bubbles.list[scrids.sel].update = false
--Update
total_empty = 0
for i=1,bubbles.len do
if not bubbles.list[i].exist then
total_empty += 1
end
end
for i=1,scan.len do
scan.list[i].install,scan.list[i].state = "a",false
for j=1,bubbles.len do
if scan.list[i].path:lower() == bubbles.list[j].iso:lower() then
scan.list[i].install,scan.list[i].state = "b",true
break
end
end
end
end--fp
end
buttons.read()
buttons.homepopup(1)
optsel = 1
end
end
if not change then
if (buttons.up or buttons.held.l or buttons.analogly < -60) then
if scrids:up() then
preview = nil
restart_cronopic()
end
end
if (buttons.down or buttons.held.r or buttons.analogly > 60) then
if scrids:down() then preview = nil
restart_cronopic()
end
end
if buttons[accept] then
bubbles.edit(bubbles.list[scrids.sel], preview)
preview = nil
restart_cronopic()
end
if buttons.select then
if dels>=1 then
local vbuff = screen.toimage()
local tmp,c = dels,0
if custom_msg(BUBBLES_UNINSTALL_QUESTION.." "..dels.. " ? ",1) == true then
for i=bubbles.len,1,-1 do
if bubbles.list[i].delete then
if vbuff then vbuff:blit(0,0) end
draw.fillrect(70, 270, ( (tmp-c) * 820 )/tmp, 25, color.new(0,255,0))
screen.flip()
buttons.homepopup(0)
game.delete(bubbles.list[i].id)
if not game.exists(bubbles.list[i].id) then
preview = nil
restart_cronopic()
table.remove(bubbles.list, i)
bubbles.len -= 1
scrids:set(bubbles.list, bmaxim)
dels-=1
c+=1
end
buttons.read()
buttons.homepopup(1)
end
end--for
--Update
total_empty = 0
for i=1,bubbles.len do
if not bubbles.list[i].exist then
total_empty += 1
end
end
for i=1,scan.len do
scan.list[i].install,scan.list[i].state = "a",false
for j=1,bubbles.len do
if scan.list[i].path:lower() == bubbles.list[j].iso:lower() then
scan.list[i].install,scan.list[i].state = "b",true
break
end
end
end
end
else
local del_empty = false
total_empty = 0
for i=1,bubbles.len do
if not bubbles.list[i].exist then
total_empty += 1
end
end
if total_empty >= 1 then
if custom_msg(BUBBLES_UNINSTALL_EMPTYS.." : "..total_empty.." ? ",1) == true then
local vbuff = screen.toimage()
local tmp,c = total_empty,0
for i=bubbles.len,1,-1 do
if not bubbles.list[i].exist then
if vbuff then vbuff:blit(0,0) end
draw.fillrect(70, 270, ( (tmp-c) * 820 )/tmp, 25, color.new(0,255,0))
screen.flip()
buttons.homepopup(0)
game.delete(bubbles.list[i].id)
if not game.exists(bubbles.list[i].id) then
preview = nil
restart_cronopic()
table.remove(bubbles.list, i)
bubbles.len -= 1
scrids:set(bubbles.list, bmaxim)
total_empty-=1
c+=1
end
buttons.read()
buttons.homepopup(1)
end
end--for
--Update
for i=1,scan.len do
scan.list[i].install,scan.list[i].state = "a",false
for j=1,bubbles.len do
if scan.list[i].path:lower() == bubbles.list[j].iso:lower() then
scan.list[i].install,scan.list[i].state = "b",true
break
end
end
end
end--custom_msg
end
end
bubbles.len = #bubbles.list
end
if buttons.square then
bubbles.list[scrids.sel].delete = not bubbles.list[scrids.sel].delete
if bubbles.list[scrids.sel].delete then dels+=1 else dels-=1 end
end
if buttons.start then
mark = not mark
for i=1,bubbles.len do
bubbles.list[i].delete = mark
if mark then dels=bubbles.len else dels=0 end
end
end
if isTouched(125,80,270,215) and touch.front[1].released then
if click then
click = false
if crono2:time() <= 300 then -- Double click and in time to Go.
-- Your action here.
game.launch(bubbles.list[scrids.sel].id)
end
else
-- Your action here.
click = true
crono2:reset()
crono2:start()
end
end
if crono2:time() > 300 then -- First click, but long time to double click...
click = false
end
--edit
else
buttons.interval(20,12)
if buttons.up then optsel-=1 end
if buttons.down then optsel+=1 end
if optsel > #options_edit + 1 then optsel = 1 end
if optsel < 1 then optsel = #options_edit + 1 end
if (buttons.left or buttons.right) then
if buttons.left then selector-=1 end
if buttons.right then selector+=1 end
if optsel == 1 or optsel == 2 then --Driver&Execute
if selector > 3 then selector = 1 end
if selector < 1 then selector = 3 end
elseif optsel == 3 then --Customized
if selector > 2 then selector = 1 end
if selector < 1 then selector = 2 end
end
bubbles.list[scrids.sel].lines[optsel] = selector - 1
bubbles.list[scrids.sel].update = true
end
if (buttons[accept] and optsel == 4) and not bubbles.list[scrids.sel].exist then
local new_path = osk.init(BUBBLES_PATH2GAME, bubbles.list[scrids.sel].iso or "", 128, __OSK_TYPE_DEFAULT, __OSK_MODE_TEXT)
if not new_path or (string.len(new_path)<=0) then new_path = bubbles.list[scrids.sel].iso end
bubbles.list[scrids.sel].iso = new_path
if files.exists(bubbles.list[scrids.sel].iso) then bubbles.list[scrids.sel].exist = true else bubbles.list[scrids.sel].exist = false end
--Update
total_empty = 0
for i=1,bubbles.len do
if not bubbles.list[i].exist then
total_empty += 1
end
end
bubbles.list[scrids.sel].update = true
end
end--not change
end
if buttons[cancel] and not change then
restart_cronopic()
return false
end
end
end
function bubbles.edit(obj, simg)
local tmp = files.listdirs("ux0:ABM/")
if tmp then table.sort(tmp,function(a,b) return string.lower(a.name)<string.lower(b.name) end)
else tmp = {} end
local resources = {
{ name = "ICON0.PNG", w = 128, h = 128, dest = "/sce_sys/icon0.png", restore = "/sce_sys/" },
{ name = "STARTUP.PNG", w = 280, h = 158, dest = "/sce_sys/livearea/contents/startup.png", restore = "/sce_sys/livearea/contents/" },
{ name = "PIC0.PNG", w = 960, h = 544, dest = "/sce_sys/pic0.png", restore = "/sce_sys/" },
{ name = "BG0.PNG", w = 840, h = 500, dest = "/sce_sys/livearea/contents/bg0.png", restore = "/sce_sys/livearea/contents/" },
{ name = "TEMPLATE.XML", w = 0, h = 0, dest = "/sce_sys/livearea/contents/", restore = "/sce_sys/livearea/contents/" },
}
--FRAMEX.PNG 1 to 5
for i=1,5 do
table.insert(resources, { name = "FRAME"..i..".PNG", w = 0, h = 0, dest = "/sce_sys/livearea/contents/", restore = "/sce_sys/livearea/contents/" })
end
local preview, find_png, inside, backl = nil,false,false,{}
local maximset = 10
local scrids, newpath = newScroll(tmp, maximset),"ux0:ABM/"
buttons.interval(12,5)
while true do
buttons.read()
if back2 then back2:blit(0,0) end
if math.minmax(tonumber(os.date("%d%m")),2512,2512)== tonumber(os.date("%d%m")) then stars.render() end
draw.fillrect(0,0,960,30, 0x64545353) --UP
screen.print(480,5, BUBBLES_RE_EDIT, 1, color.white, color.blue, __ACENTER)
screen.print(950,5, BUBBLES_COUNT.." "..scrids.maxim, 1, color.red, color.gray, __ARIGHT)
if scrids.maxim > 0 then
screen.print(15,35, newpath, 1, color.white,color.blue)
local y = 75
for i=scrids.ini, scrids.lim do
if i == scrids.sel then
draw.fillrect(14,y-3,682,25,color.green:a(100))
if not preview then
if tmp[i].ext and tmp[i].ext:upper() == "PNG" then
preview = image.load(tmp[i].path)
if preview then
preview:resize(252,151)
preview:setfilter(__IMG_FILTER_LINEAR, __IMG_FILTER_LINEAR)
end
end
end
end
screen.print(20,y,tmp[i].name,1.0,color.white,color.blue,__ALEFT)
y += 32
end
--Bar Scroll
local ybar, h = 70, (maximset*32)-2
draw.fillrect(3, ybar-2, 8, h, color.shine)
if scrids.maxim >= maximset then -- Draw Scroll Bar
local pos_height = math.max(h/scrids.maxim, maximset)
draw.fillrect(3, ybar-2 + ((h-pos_height)/(scrids.maxim-1))*(scrids.sel-1), 8, pos_height, color.new(0,255,0))
end
if preview then
preview:blit(700,84)
end
local x1 = screen.print(15,430, BUBBLES_EDIT_BB, 1, color.white, color.blue, __ALEFT)
screen.print(15,455, obj.id, 1, color.white, color.blue, __ALEFT)
local x2 = screen.print(15,490, obj.title, 1, color.white, color.blue, __ALEFT)
if simg then
local px = x1
if x1 > x2 then px = x1 + 100 else px = x2 + 100 end
screen.clip(px,450, 120/2)
simg:center()
simg:blit(px,450)
screen.clip()
end
if inside and find_png then
screen.print(480,523,BUBBLES_REINSTALL,1.0,color.green,color.gray,__ACENTER)
end
else
screen.print(480,230, BUBBLES_NOTRESOURCES, 1, color.white, color.red, __ACENTER)
end
if inside then
screen.print(950,490, SYMBOL_BACK..": "..BUBBLES_GOTOBACK, 1, color.white, color.blue, __ARIGHT)
else
screen.print(480,523, SYMBOL_BACK..": "..BUBBLES_GOTOBACK, 1, color.white, color.blue, __ACENTER)
end
draw.fillrect(0,516,960,30, 0x64545353)--Down
screen.flip()
--Controls
if scrids.maxim > 0 then
if (buttons.up or buttons.analogly < -60) then
if scrids:up() then preview = nil end
end