-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_gui_event.rb
1961 lines (1892 loc) · 82.5 KB
/
main_gui_event.rb
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
#! ruby -Ks
# -*- mode:ruby; coding:shift_jis -*-
$KCODE='s'
#==============================================================================
#Project Name : BeatSaber Movie Cut TOOL
#File Name : bs_movie_cut.rb _frm_bs_movie_cut.rb sub_library.rb
# : dialog_gui.rb main_gui_event.rb main_gui_sub.rb
# : language_en.rb language_jp.rb
#Creation Date : 2020/01/08
#
#Copyright : 2020 リュナン (Twitter @rynan4818)
#License : MIT License
#Tool : ActiveScriptRuby(1.8.7-p330)
# https://www.artonx.org/data/asr/
# FormDesigner for Project VisualuRuby Ver 060501
# https://ja.osdn.net/projects/fdvr/
#RubyGems Package: rubygems-update (1.8.21) https://rubygems.org/
# json (1.4.6 x86-mswin32)
# sqlite3 (1.3.3 x86-mswin32-60)
#==============================================================================
class Form_main
include VRDropFileTarget
include VRDestroySensitive
##GUIイベント処理##
#起動時処理
def self_created
if $Exerb
#アイコンの設定
extractIconA = Win32API.new('shell32','ExtractIconA','LPI','L')
myIconData = extractIconA.Call(0, "#{EXE_DIR}#{File.basename(MAIN_RB, '.*')}.exe", 0)
sendMessage(128, 0, myIconData)
end
self.caption += " Ver #{SOFT_VER}"
@tz_static.caption = Time.now.zone
@movie_files = [] #動画リスト
@convert_list = [] #切り出しマップリスト
@original_convert_list = [] #データベースから読みだした初期値
@list_sort = nil #リストのソート対象
@list_desc_order = false #リストの降順
$main_windowrect = self.windowrect
setting_load
printing_check
if $beatsaber_dbfile
unless File.exist?($beatsaber_dbfile)
messageBox("'#{$beatsaber_dbfile}' #{MAIN_SELF_CREATED_DBFILE_CHECK1_MAIN}", MAIN_SELF_CREATED_DBFILE_CHECK1_TITLE,48)
exit unless VRLocalScreen.openModalDialog(self,nil,Modaldlg_setting,nil,nil) #設定画面のモーダルダイアログを開く
setting_save(false)
end
else
messageBox(MAIN_SELF_CREATED_DBFILE_CHECK2_MAIN, MAIN_SELF_CREATED_DBFILE_CHECK2_TITLE,48)
exit unless VRLocalScreen.openModalDialog(self,nil,Modaldlg_setting,nil,nil) #設定画面のモーダルダイアログを開く
setting_save(false)
end
exit unless $beatsaber_dbfile
exit unless File.exist? $beatsaber_dbfile
db_check
#リストボックスにタブストップを設定
#[0x192,タブストップの数,[タブストップの位置,…]] FormDesignerでstyleのLBS_USETABSTOPSのチェックが必要
#0x192:LB_SETTABSTOPS l*:32bit符号つき整数
@listBox_map.sendMessage(0x192, 13,[7,31,87,109,135,156,188,209,234,260,290,310,462].pack('l*'))
@listBox_file.sendMessage(0x192, 1,[24].pack('l*'))
@statusbar.setparts(4,[80,160,240,-1])
@statusbar.setTextOf(0,"0 #{STATUSBAR_FILE}",0)
@statusbar.setTextOf(1,"0 #{STATUSBAR_MAP}",0)
@statusbar.setTextOf(2,"0 #{STATUSBAR_SELECT}",0)
@statusbar.setTextOf(3,"",0)
@static_new_release.caption = "#{NEW_RELEASE_MES}#{$new_version}" if $new_version_check && $new_version
end
#終了時処理
def self_destroy
setting_save(false)
end
#ドラッグ&ドロップ貼り付け
def self_dropfiles(files)
@movie_files = files
listbox_load
end
#FFmpegオプションの項目変更時処理
def comboBox_ffmpeg_selchanged
printing_check
end
#譜面リスト選択変更時処理
def listBox_map_selchanged
select_count = @listBox_map.sendMessage(WMsg::LB_GETSELCOUNT,0,0)
@statusbar.setTextOf(2,"#{select_count} #{STATUSBAR_SELECT}",0)
return unless target = @convert_list[@listBox_map.selectedString]
songAuthorName = target[1][@fields.index('songAuthorName')]
mode = target[1][@fields.index('mode')]
bpm = target[1][@fields.index('songBPM')]
njs = target[1][@fields.index('noteJumpSpeed')]
length = target[1][@fields.index('length')].to_i
notes = target[1][@fields.index('notesCount')].to_i
bombs = target[1][@fields.index('bombsCount')]
obstacles = target[1][@fields.index('obstaclesCount')]
instaFail = target[1][@fields.index('instaFail')] #IF
be = target[1][@fields.index('batteryEnergy')] #BE
da = target[1][@fields.index('disappearingArrows')] #DA
gn = target[1][@fields.index('ghostNotes')] #GN
songSpeed = target[1][@fields.index('songSpeed')] #FS,SS
nf = target[1][@fields.index('noFail')] #NF
no = target[1][@fields.index('obstacles')] #NO
nb = target[1][@fields.index('noBombs')] #NB
na = target[1][@fields.index('noArrows')] #NA
sl = target[1][@fields.index('staticLights')] #SL
lh = target[1][@fields.index('leftHanded')] #LH
rd = target[1][@fields.index('reduceDebris')] #RD
nh = target[1][@fields.index('noHUD')] #NH
mod = ""
mod += "IF," if instaFail == 1
mod += "BE," if be == 1
mod += "DA," if da == 1
mod += "GN," if gn == 1
mod += "FS," if songSpeed == "Faster"
mod += "SS," if songSpeed == "Slower"
mod += "NF," if nf == 1
mod += "NO," if no == 0
mod += "NB," if nb == 1
mod += "NA," if na == 1
player_setting = ""
player_setting += "SL," if sl == 1
player_setting += "LH," if lh == 1
player_setting += "RD," if rd == 1
player_setting += "NH," if nh == 1
if length > 0
notes_sec = (notes.to_f / (length.to_f / 10000.0)).round.to_f / 10.0
else
notes_sec = "err"
end
text = "#{STATUSBAR_INFO_ARTIST}: #{songAuthorName[0,12]} #{STATUSBAR_INFO_MODE}: #{mode} NJS: #{njs.to_f.round} BPM: #{bpm.to_f.round} "
text += "#{STATUSBAR_INFO_NOTES}: #{notes} [#{notes_sec}/s] #{STATUSBAR_INFO_BOMBS}: #{bombs} #{STATUSBAR_INFO_OBSTACLES}: #{obstacles}#{' Mod: ' unless mod == ''}#{mod.sub(/,$/,'')}"
text += "#{' Set: ' unless player_setting == ''}#{player_setting.sub(/,$/,'')}"
@statusbar.setTextOf(3,text,0)
end
def button_run_clicked
Dir.chdir(EXE_DIR)
@button_run.style = 1476395008
refresh
@static_message.caption = "### Now converting!! ###"
show(0)
@convert_list.each_with_index do |target,idx|
#マップ リストボックスの選択状態確認
sel = 0
@listBox_map.eachSelected do |i|
sel = 1 if i == idx
end
next if sel == 0
next unless target[7] == 1
#データベースカラムの読み出し
startTime = target[1][@fields.index('startTime')]
endTime = target[1][@fields.index('endTime')]
menuTime = target[1][@fields.index('menuTime')]
cleared = target[1][@fields.index('cleared')]
endFlag = target[1][@fields.index('endFlag')]
pauseCount = target[1][@fields.index('pauseCount')]
pluginVersion = target[1][@fields.index('pluginVersion')]
gameVersion = target[1][@fields.index('gameVersion')]
scene = target[1][@fields.index('scene')]
mode = target[1][@fields.index('mode')]
songName = target[1][@fields.index('songName')]
songSubName = target[1][@fields.index('songSubName')]
songAuthorName = target[1][@fields.index('songAuthorName')]
levelAuthorName = target[1][@fields.index('levelAuthorName')]
songHash = target[1][@fields.index('songHash')]
songBPM = target[1][@fields.index('songBPM')]
noteJumpSpeed = target[1][@fields.index('noteJumpSpeed')]
songTimeOffset = target[1][@fields.index('songTimeOffset')]
start = target[1][@fields.index('start')]
paused = target[1][@fields.index('paused')]
length = target[1][@fields.index('length')]
difficulty = target[1][@fields.index('difficulty')]
notesCount = target[1][@fields.index('notesCount')]
bombsCount = target[1][@fields.index('bombsCount')]
obstaclesCount = target[1][@fields.index('obstaclesCount')]
maxScore = target[1][@fields.index('maxScore')]
maxRank = target[1][@fields.index('maxRank')]
environmentName = target[1][@fields.index('environmentName')]
scorePercentage = target[1][@fields.index('scorePercentage')]
score = target[1][@fields.index('score')]
currentMaxScore = target[1][@fields.index('currentMaxScore')]
rank = target[1][@fields.index('rank')]
passedNotes = target[1][@fields.index('passedNotes')]
hitNotes = target[1][@fields.index('hitNotes')]
missedNotes = target[1][@fields.index('missedNotes')]
lastNoteScore = target[1][@fields.index('lastNoteScore')]
passedBombs = target[1][@fields.index('passedBombs')]
hitBombs = target[1][@fields.index('hitBombs')]
combo = target[1][@fields.index('combo')]
maxCombo = target[1][@fields.index('maxCombo')]
multiplier = target[1][@fields.index('multiplier')]
obstacles = target[1][@fields.index('obstacles')]
instaFail = target[1][@fields.index('instaFail')]
noFail = target[1][@fields.index('noFail')]
batteryEnergy = target[1][@fields.index('batteryEnergy')]
disappearingArrows = target[1][@fields.index('disappearingArrows')]
noBombs = target[1][@fields.index('noBombs')]
songSpeed = target[1][@fields.index('songSpeed')]
songSpeedMultiplier = target[1][@fields.index('songSpeedMultiplier')]
noArrows = target[1][@fields.index('noArrows')]
ghostNotes = target[1][@fields.index('ghostNotes')]
failOnSaberClash = target[1][@fields.index('failOnSaberClash')]
strictAngles = target[1][@fields.index('strictAngles')]
fastNotes = target[1][@fields.index('fastNotes')]
staticLights = target[1][@fields.index('staticLights')]
leftHanded = target[1][@fields.index('leftHanded')]
playerHeight = target[1][@fields.index('playerHeight')]
reduceDebris = target[1][@fields.index('reduceDebris')]
noHUD = target[1][@fields.index('noHUD')]
advancedHUD = target[1][@fields.index('advancedHUD')]
autoRestart = target[1][@fields.index('autoRestart')]
hdt = target[8].to_i
##分割処理
time_name = Time.at(startTime.to_i / 1000).localtime.strftime($time_format)
if cleared == 'finished' && missedNotes.to_i == 0
miss = "FULLCOMBO"
else
miss = "Miss#{missedNotes}"
end
file_name = ''
#分割後のファイル名決定
file_name_code = '"' + @comboBox_filename.getTextOf(@comboBox_filename.selectedString).strip.sub(/^#[^#]+#/,'').strip + '"'
#bsrの取得
if file_name_code =~ /bsr/
bsr,beatsaver_data = bsr_search(songHash)
end
begin
eval("file_name = " + file_name_code)
rescue SyntaxError #SyntaxErrorのrescueはクラス指定しないと取得できない
messageBox(MAIN_BUTTON_RUN_FILE_NAME_SYNTAXERROR, MAIN_BUTTON_RUN_FILE_NAME_SYNTAXERROR_TITLE, 48)
@button_run.style = 1342177280
@static_message.caption = "Paste the file to be converted by drag and drop"
refresh
return
rescue Exception => e
messageBox("#{MAIN_BUTTON_RUN_FILE_NAME_EXCEPTION}\r\n#{e.inspect}", MAIN_BUTTON_RUN_FILE_NAME_EXCEPTION_TITLE, 48)
@button_run.style = 1342177280
@static_message.caption = "Paste the file to be converted by drag and drop"
refresh
return
end
file_name = file_name_check(file_name)
file = target[0]
ffmpeg_option = ' ' + @comboBox_ffmpeg.getTextOf(@comboBox_ffmpeg.selectedString).strip.sub(/^#[^#]+#/,'').strip
out_dir = @comboBox_folder.getTextOf(@comboBox_folder.selectedString).strip.sub(/^#[^#]+#/,'').strip
if $use_endtime
stoptime = endTime
else
stoptime = menuTime
end
str_dir = File.dirname($subtitle_file.to_s.strip) + "\\"
str_file = File.basename($subtitle_file, ".*") + '.srt'
if @keyframecut && @checkBox_key_frame.checked?
key_frame_data = key_frame_check(file,startTime,target,stoptime)
else
key_frame_data = nil
end
if @normalize && @checkBox_normalize.checked?
max_volume_data = volume_check(file,startTime,target,stoptime)
else
max_volume_data = nil
end
if @checkBox_printing.checked? && @printing || @checkBox_subtitles.checked?
movie_sub_create(target,str_dir,str_file,startTime,stoptime,key_frame_data)
offset_time, cut_time = ffmpeg_run(file,file_name,ffmpeg_option,out_dir,startTime,target,stoptime,str_dir + str_file,true,key_frame_data)
else
#字幕ファイル削除
File.delete str_dir + str_file if File.exist? str_dir + str_file
offset_time, cut_time = ffmpeg_run(file,file_name,ffmpeg_option,out_dir,startTime,target,stoptime,false,true,key_frame_data,max_volume_data)
end
#データベースに切り出し記録を残す
db_open
sql = "INSERT INTO MovieCutFile(startTime, datetime, out_dir, filename, stoptime, offsetTime, cutTime) VALUES (?, ?, ?, ?, ?, ?, ?);"
if $ascii_mode
@db.execute(sql,startTime,Time.now.to_i,out_dir,file_name,stoptime,offset_time + $offset, cut_time)
else
@db.execute(utf8cv(sql),startTime,Time.now.to_i,utf8cv(out_dir),utf8cv(file_name),stoptime,offset_time + $offset, cut_time)
end
@db.close
end
show
@button_run.style = 1342177280
@static_message.caption = "Paste the file to be converted by drag and drop"
refresh
end
#all select ボタン
def button_all_select_clicked
@listBox_map.countStrings.times do |idx|
@listBox_map.sendMessage(WMsg::LB_SETSEL,1,idx) #全て選択状態にする。
end
listBox_map_selchanged
end
def button_all_unselect_clicked
@listBox_map.countStrings.times do |idx|
@listBox_map.sendMessage(WMsg::LB_SETSEL,0,idx) #全て未選択状態にする。
end
listBox_map_selchanged
end
def button_fullcombo_clicked
@listBox_map.countStrings.times do |idx|
if @convert_list[idx][1][@fields.index("cleared")] == 'finished' && @convert_list[idx][1][@fields.index("missedNotes")].to_i == 0
@listBox_map.sendMessage(WMsg::LB_SETSEL,1,idx) #選択状態にする。
else
@listBox_map.sendMessage(WMsg::LB_SETSEL,0,idx) #未選択状態にする。
end
end
listBox_map_selchanged
end
def button_finished_clicked
@listBox_map.countStrings.times do |idx|
if @convert_list[idx][1][@fields.index("cleared")] == 'finished'
@listBox_map.sendMessage(WMsg::LB_SETSEL,1,idx) #選択状態にする。
else
@listBox_map.sendMessage(WMsg::LB_SETSEL,0,idx) #未選択状態にする。
end
end
listBox_map_selchanged
end
def button_filter_clicked
true_song = {}
@listBox_map.countStrings.times do |idx|
songHash = @convert_list[idx][1][@fields.index('songHash')]
time = ((@convert_list[idx][1][@fields.index('endTime')].to_i - @convert_list[idx][1][@fields.index('startTime')].to_i) / 1000).to_i
length = (@convert_list[idx][1][@fields.index('length')].to_i / 1000).to_i
flag = false
flag = true if @checkBox_finished.checked? && @convert_list[idx][1][@fields.index("cleared")] == 'finished'
flag = true if @checkBox_failed.checked? && @convert_list[idx][1][@fields.index("cleared")] == 'failed'
flag = true if @checkBox_pause.checked? && @convert_list[idx][1][@fields.index("cleared")] == 'pause'
flag = true if @checkBox_softFail.checked? && @convert_list[idx][1][@fields.index("cleared")] == 'softFail'
flag = false if @checkBox_miss.checked? && @convert_list[idx][1][@fields.index("missedNotes")].to_i > @edit_miss.text.to_i
flag = false if @checkBox_score.checked? && @convert_list[idx][1][@fields.index("scorePercentage")].to_f < @edit_score.text.to_f
flag = false if @checkBox_diff.checked? && (time - length).abs > @edit_difftime.text.to_i
flag = false if @checkBox_speed.checked? && @convert_list[idx][1][@fields.index("songSpeedMultiplier")].to_f != 1.0
true_song[songHash] = true if flag
unless @checkBox_all_same_song.checked?
if flag
@listBox_map.sendMessage(WMsg::LB_SETSEL,1,idx) #選択状態にする。
else
@listBox_map.sendMessage(WMsg::LB_SETSEL,0,idx) #未選択状態にする。
end
end
end
if @checkBox_all_same_song.checked?
@listBox_map.countStrings.times do |idx|
songHash = @convert_list[idx][1][@fields.index('songHash')]
if true_song[songHash]
@listBox_map.sendMessage(WMsg::LB_SETSEL,1,idx) #選択状態にする。
else
@listBox_map.sendMessage(WMsg::LB_SETSEL,0,idx) #未選択状態にする。
end
end
end
listBox_map_selchanged
end
def button_close_clicked
close
end
def button_preview_clicked
Dir.chdir(EXE_DIR)
unless File.exist? $preview_tool.to_s
messageBox("'#{$preview_tool.to_s}' #{MAIN_BUTTON_PREVIEW_TOOL_CHECK}", MAIN_BUTTON_PREVIEW_TOOL_CHECK_TITLE, 48)
return
end
return unless target = @convert_list[@listBox_map.selectedString]
case target[7]
when 1
file = target[0]
out_dir = File.dirname($preview_file.to_s.strip) + "\\"
file_name = File.basename($preview_file.to_s.strip)
unless File.directory?(out_dir)
messageBox("'#{out_dir}'\r\n#{MAIN_BUTTON_PREVIEW_DIR_CHECK}", MAIN_BUTTON_PREVIEW_DIR_CHECK_TITLE, 48)
return
end
if file_name.strip == ''
messageBox(MAIN_BUTTON_PREVIEW_FILE_CHECK, MAIN_BUTTON_PREVIEW_FILE_CHECK_TITLE, 48)
return
end
if $preview_encode
ffmpeg_option = ' ' + @comboBox_ffmpeg.getTextOf(@comboBox_ffmpeg.selectedString).strip.sub(/^#[^#]+#/,'').strip
vf = true
key_frame_cut = @keyframecut && @checkBox_key_frame.checked?
normalize_check = @normalize && @checkBox_normalize.checked?
else
ffmpeg_option = $preview_ffmpeg
vf = false
key_frame_cut = $preview_keycut
normalize_check = false
end
startTime = target[1][@fields.index('startTime')]
endTime = target[1][@fields.index('endTime')]
menuTime = target[1][@fields.index('menuTime')]
if $use_endtime
stoptime = endTime
else
stoptime = menuTime
end
@button_preview.style = 1476395008
show(0)
refresh
str_dir = File.dirname($subtitle_file.to_s.strip) + "\\"
str_file = File.basename($subtitle_file, ".*") + '.srt'
if key_frame_cut
key_frame_data = key_frame_check(file,startTime,target,stoptime)
else
key_frame_data = nil
end
if normalize_check
max_volume_data = volume_check(file,startTime,target,stoptime)
else
max_volume_data = nil
end
if @checkBox_printing.checked? && @printing && vf || @checkBox_subtitles.checked?
movie_sub_create(target,str_dir,str_file,startTime,stoptime,key_frame_data)
ffmpeg_run(file,file_name,ffmpeg_option,out_dir,startTime,target,stoptime,str_dir + str_file,vf,key_frame_data,max_volume_data)
else
#字幕ファイル削除
File.delete str_dir + str_file if File.exist? str_dir + str_file
ffmpeg_run(file,file_name,ffmpeg_option,out_dir,startTime,target,stoptime,str_dir + str_file,vf,key_frame_data,max_volume_data)
end
@button_preview.style = 1342177280
refresh
show
preview_movie = out_dir + file_name
when 2
preview_movie = target[0]
else
return
end
begin
#外部プログラム呼び出しで、処理待ちしないためWSHのRunを使う
option = ""
option = " " + $preview_tool_option.strip unless $preview_tool_option.strip == ""
$winshell.Run(%Q!"#{$preview_tool.to_s}"#{option} "#{preview_movie}"!)
rescue Exception => e
messageBox("#{MAIN_BUTTON_PREVIEW_ERROR}\r\n#{e.inspect}", MAIN_BUTTON_PREVIEW_ERROR_TITLE, 48)
end
end
def button_file_sort_clicked
listbox_sort("File")
end
def button_datetime_sort_clicked
listbox_sort("startTime","i")
end
def button_time_sort_clicked
listbox_sort("Time")
end
def button_diff_sort_clicked
listbox_sort("Diff")
end
def button_speed_sort_clicked
listbox_sort("songSpeedMultiplier","f")
end
def button_cleared_sort_clicked
listbox_sort("cleared")
end
def button_rank_sort_clicked
listbox_sort("rank")
end
def button_score_sort_clicked
listbox_sort("scorePercentage","f")
end
def button_miss_sort_clicked
listbox_sort("missedNotes","i")
end
def button_difficulty_clicked
listbox_sort("difficulty")
end
def button_songname_sort_clicked
listbox_sort("songName")
end
def button_levelauthor_sort_clicked
listbox_sort("levelAuthorName")
end
def button_notes_sort_clicked
listbox_sort("NotesScore")
end
def button_hdt_sort_clicked
listbox_sort("HDT")
end
def button_organizing_reversing_clicked
@listBox_map.countStrings.times do |idx|
select = false
@listBox_map.eachSelected do |i|
if i == idx
select = true
break
end
end
if select
@listBox_map.sendMessage(WMsg::LB_SETSEL,0,idx)
else
@listBox_map.sendMessage(WMsg::LB_SETSEL,1,idx)
end
end
listBox_map_selchanged
end
def button_organizing_remove_clicked
temp = []
@convert_list.each_with_index do |target,idx|
select = false
@listBox_map.eachSelected do |i|
if idx == i
select = true
break
end
end
unless select
temp.push target
end
end
@convert_list = temp
listbox_refresh
end
def button_organizing_reset_clicked
@convert_list = []
@original_convert_list.each {|map_data| @convert_list.push map_data}
listbox_refresh
end
def button_search_clicked
$main_windowrect = self.windowrect
Modaldlg_search.set(@convert_list[@listBox_map.selectedString],@fields)
return unless result = VRLocalScreen.openModalDialog(self,nil,Modaldlg_search,nil,nil) #検索画面のモーダルダイアログを開く
songname,level_author,ranked = result
return if songname == "" && level_author == "" && ranked == 0
temp = []
scoresaber_check = true
@convert_list.each do |target|
flag1 = false
flag2 = false
flag3 = false
if songname == ""
flag1 = true
else
if target[1][@fields.index('songName')] =~ Regexp.new("#{Regexp.escape(songname)}",Regexp::IGNORECASE)
flag1 = true
else
flag1 = false
end
end
if level_author == ""
flag2 = true
else
if target[1][@fields.index('levelAuthorName')] =~ Regexp.new("#{Regexp.escape(level_author)}",Regexp::IGNORECASE)
flag2 = true
else
flag2 = false
end
end
if ranked == 0
flag3 = true
else
result = ranked_check(self,target[1][@fields.index('songHash')],target[1][@fields.index('difficulty')],target[1][@fields.index('mode')])
case result
when 1
if ranked == 1
flag3 =true
else
flag3 = false
end
when 2
if ranked == 2
flag3 = true
else
flag3 = false
end
else
flag3 = true
scoresaber_check = false
end
end
temp.push target if flag1 && flag2 && flag3
end
unless scoresaber_check
messageBox(MAIN_BUTTON_SEARCH_SCORESABER_CHECK, MAIN_BUTTON_SEARCH_SCORESABER_CHECK_TITLE, 48)
end
@convert_list = temp
listbox_refresh
end
def button_open_preview_dir_clicked
out_dir = File.dirname($preview_file.to_s.strip) + "\\"
$winshell.Run("\"#{out_dir}\"") if File.directory?(out_dir)
end
def button_ffmpeg_edit_clicked
$main_windowrect = self.windowrect
target = []
@comboBox_ffmpeg.eachString {|a| target.push a}
Modaldlg_list_option_setting.set(target, false, false, $ffmpeg_option_select, FFMPEG_EDIT_TITLE)
return unless result = VRLocalScreen.openModalDialog(self,nil,Modaldlg_list_option_setting,nil,nil)
@comboBox_ffmpeg.setListStrings result[0]
$ffmpeg_option_select = result[1]
@comboBox_ffmpeg.select($ffmpeg_option_select)
setting_save(false,1)
end
def button_filename_edit_clicked
$main_windowrect = self.windowrect
variable_list = ["time_name","miss","bsr","startTime","endTime","menuTime","cleared","endFlag",
"pauseCount","pluginVersion","gameVersion","scene","mode","songName","songSubName",
"songAuthorName","levelAuthorName","songHash","songBPM","noteJumpSpeed","songTimeOffset",
"start","paused","length","difficulty","notesCount","bombsCount","obstaclesCount",
"maxScore","maxRank","environmentName","scorePercentage","score","currentMaxScore",
"rank","passedNotes","hitNotes","missedNotes","lastNoteScore","passedBombs","hitBombs",
"combo","maxCombo","multiplier","obstacles","instaFail","noFail","batteryEnergy",
"disappearingArrows","noBombs","songSpeed","songSpeedMultiplier","noArrows","ghostNotes",
"failOnSaberClash","strictAngles","fastNotes","staticLights","leftHanded","playerHeight",
"reduceDebris","noHUD","advancedHUD","autoRestart","hdt"]
target = []
@comboBox_filename.eachString {|a| target.push a}
Modaldlg_list_option_setting.set(target,variable_list, false, $out_file_name_select, FILENAME_EDIT_TITLE, true, true, OUT_FOLDER_EDIT_NOTES)
return unless result = VRLocalScreen.openModalDialog(self,nil,Modaldlg_list_option_setting,nil,nil)
@comboBox_filename.setListStrings result[0]
$out_file_name_select = result[1]
@comboBox_filename.select($out_file_name_select)
setting_save(false,2)
end
def button_out_folder_edit_clicked
$main_windowrect = self.windowrect
target = []
@comboBox_folder.eachString {|a| target.push a}
Modaldlg_list_option_setting.set(target, false, 2, $out_folder_select, OUT_FOLDER_EDIT_TITLE, true)
return unless result = VRLocalScreen.openModalDialog(self,nil,Modaldlg_list_option_setting,nil,nil)
@comboBox_folder.setListStrings result[0]
$out_folder_select = result[1]
@comboBox_folder.select($out_folder_select)
setting_save(false,3)
end
def button_out_open_clicked
out_dir = @comboBox_folder.getTextOf(@comboBox_folder.selectedString).strip.sub(/^#[^#]+#/,'').strip
$winshell.Run("\"#{out_dir}\"") if File.directory?(out_dir)
end
def menu_open_clicked
ext_set = [["Mkv File (*.mkv)","*.mkv"],["Avi File (*.avi)","*.avi"],["mp4 File (*.mp4)","*.mp4"],["All File (*.*)","*.*"]]
def_ext = "*.#{$movie_default_extension.downcase}"
if i = ext_set.index {|v| v[1] == def_ext}
ext_set.unshift ext_set.delete_at(i)
else
ext_set.unshift ["#{$movie_default_extension.downcase} File (#{def_ext})",def_ext]
end
filenames = SWin::CommonDialog::openFilename(self,ext_set,0x81204, MAIN_MENU_OPEN_TITLE,def_ext,$open_dir) #ファイルを開くダイアログを開く
return unless filenames #ファイルが選択されなかった場合、キャンセルされた場合は戻る
if filenames =~ /\000/
folder,*files = filenames.split("\000")
else
folder = File.dirname(filenames)
files = [File.basename(filenames)]
end
@movie_files = []
files.each do |file|
@movie_files.push "#{folder}\\#{file}"
end
listbox_load
end
def menu_latest_open_clicked
if File.directory?($open_dir)
movie_list = []
Dir.glob("#{$open_dir}\\*.#{$movie_default_extension.downcase}".gsub(/\\/,'/')) do |file|
movie_list.push [File.stat(file).mtime, file]
end
movie_list.sort!{|a,b| b[0] <=> a[0]}
if movie_list[0]
@movie_files = [movie_list[0][1].gsub(/\//,'\\')]
listbox_load
return
end
end
messageBox("#{LATEST_MOVIE_OPEN_ERR_MES}", LATEST_MOVIE_OPEN_ERR_MES_TITLE, 48)
end
def menu_exit_clicked
close
end
def menu_setting_clicked
$main_windowrect = self.windowrect
a = $ascii_mode
return unless VRLocalScreen.openModalDialog(self,nil,Modaldlg_setting,nil,nil) #設定画面のモーダルダイアログを開く
setting_save(false)
listbox_load unless a == $ascii_mode
end
def menu_timestamp_clicked
$main_windowrect = self.windowrect
result = VRLocalScreen.openModalDialog(self,nil,Modaldlg_timestamp,nil,nil)#設定画面のモーダルダイアログを開く
if result
listbox_load if @movie_files.include?(result)
end
end
def menu_version_clicked
messageBox(APP_VER_COOMENT, MAIN_MENU_VERSION_TITLE, 0)
end
def menu_manual_clicked
open_url(MANUAL_URL)
end
def menu_release_clicked
open_url(RELEASE_URL)
end
def menu_save_clicked
setting_save
messageBox(MAIN_MENU_SAVE, MAIN_MENU_SAVE_TITLE, 0)
end
def menu_modsetting_clicked
$main_windowrect = self.windowrect
new_mod = true
new_mod = false if File.basename($mod_setting_file.strip) == HTTPSTATUS_DB_MOD_SETTING_FILE_NAME
if File.exist?($mod_setting_file.strip)
setting = JSON.parse(File.read($mod_setting_file.strip))
new_mod = false if setting['http_scenechange']
end
result = [nil,nil]
until result[0] == 'ok'
if new_mod
Modaldlg_modsetting2.set(result[1])
result = VRLocalScreen.openModalDialog(self,nil,Modaldlg_modsetting2,nil,nil)
return unless result
else
Modaldlg_modsetting.set(result[1])
result = VRLocalScreen.openModalDialog(self,nil,Modaldlg_modsetting,nil,nil)
return unless result
end
if result[0] == 'new'
new_mod = true
else
new_mod = false
end
end
setting_save(false)
end
def menu_notescore_clicked
target = @convert_list[@listBox_map.selectedString]
unless target
messageBox(MAIN_NOT_SELECT_MES, MAIN_NOT_SELECT_MES_TITLE, 48)
return
end
songName = target[1][@fields.index('songName')]
startTime = target[1][@fields.index('startTime')]
time_name = Time.at(startTime.to_i / 1000).localtime.strftime($time_format)
sql = "SELECT * FROM NoteScore WHERE startTime = #{startTime};"
result = db_execute(sql)
if result
fields,rows = result
else
return
end
if rows.size == 0
messageBox(MAIN_NOT_NOTES_SCORE_DB_MES, MAIN_NOT_NOTES_SCORE_DB_MES_TITLE, 48)
return
end
savefile = file_name_check("#{time_name}_#{songName}.csv")
fn = SWin::CommonDialog::saveFilename(self,[["CSV FIle(*.csv)","*.csv"],["All File(*.*)","*.*"]],0x1004,NOTES_SCORE_FILE_SAVE_TITLE,'*.csv',0,savefile)
return unless fn
CSV.open(fn,'w') do |record|
record << "unixTime,movieTime,event,score,score%,rank,hitNotes,missedNotes,combo,batteryEnergy,noteID,noteType,noteCutDirection,noteLine,noteLayer,beforeScore,initialScore,afterScore,cutDistanceScore,finalScore,cutMultiplier,saberSpeed,saberType,timeDeviation,cutDirectionDeviation,cutDistanceToCenter,timeToNextBasicNote".split(",")
record << "時間(unixtime ms),動画時間,イベント,スコア,スコア%,ランク,ヒット数,ミス数,コンボ数,ライフ,ノーツID,ノーツ種類,ノーツ矢印,水平位置(→),垂直位置(↑),カット前角度スコア,カット前スコア,カット後スコア,中心分スコア,合計スコア,コンボ乗数,セイバー速度,セイバー種類,最適時間からオフセット,完全角度からのオフセット,中心からのカット距離,次のノーツまでの時間".split(",") unless $ascii_mode
rows.each do |cols|
line = []
line << cols[fields.index("time")]
movie_time = ((cols[fields.index("time")] - startTime).to_f / 1000.0).round
movie_time_min = movie_time / 60
movie_time_sec = movie_time % 60
line << "#{movie_time_min}:#{movie_time_sec}"
line << cols[fields.index("event")]
line << cols[fields.index("score")]
if cols[fields.index("currentMaxScore")].to_f == 0.0
line << 100.0
else
line << (cols[fields.index("score")].to_f / cols[fields.index("currentMaxScore")].to_f * 1000.0).round / 10.0
end
line << cols[fields.index("rank")]
line << cols[fields.index("hitNotes")]
line << cols[fields.index("missedNotes")]
line << cols[fields.index("combo")]
line << cols[fields.index("batteryEnergy")]
line << cols[fields.index("noteID")]
line << cols[fields.index("noteType")]
line << cols[fields.index("noteCutDirection")]
line << cols[fields.index("noteLine")]
line << cols[fields.index("noteLayer")]
line << cols[fields.index("beforeScore")]
line << cols[fields.index("initialScore")]
line << cols[fields.index("afterScore")]
line << cols[fields.index("cutDistanceScore")]
line << cols[fields.index("finalScore")]
line << cols[fields.index("cutMultiplier")]
line << cols[fields.index("saberSpeed")]
line << cols[fields.index("saberType")]
line << cols[fields.index("timeDeviation")]
line << cols[fields.index("cutDirectionDeviation")]
line << cols[fields.index("cutDistanceToCenter")]
line << cols[fields.index("timeToNextBasicNote")]
record << line
end
end
end
def menu_subtitle_setting_clicked
$main_windowrect = self.windowrect
return unless VRLocalScreen.openModalDialog(self,nil,Modaldlg_subtitle_setting,nil,nil) #設定画面のモーダルダイアログを開く
setting_save(false)
end
def menu_dbopen_clicked
$main_windowrect = self.windowrect
search_dir = []
@comboBox_folder.eachString {|a| search_dir.push a.strip.sub(/^#[^#]+#/,'').strip}
Modaldlg_db_view.set(search_dir)
return unless result = VRLocalScreen.openModalDialog(self,nil,Modaldlg_db_view,nil,nil) #日付範囲画面のモーダルダイアログを開く
allread, start_time, end_time, search_dir_list, input_movie_search_dir_change, cut_only, ambiguous = result
db_map_load_time(allread, start_time, end_time, search_dir_list, cut_only, ambiguous)
setting_save(false) if input_movie_search_dir_change
listbox_refresh
end
def menu_copy_bsr_clicked
if bsr = select_to_bsr
Clipboard.open(self.hWnd) do |cb|
cb.setText "!bsr #{bsr}"
end
messageBox("#{MAIN_MENU_COPY_BSR}#{bsr}", MAIN_MENU_COPY_BSR_TITLE, 0x40)
end
end
def menu_beatsaver_clicked
if bsr = select_to_bsr
open_url(BEATSAVER_URL.sub(/#bsr#/,bsr))
end
end
def menu_beastsaber_clicked
if bsr = select_to_bsr
open_url(BEASTSABER_URL.sub(/#bsr#/,bsr))
end
end
def menu_post_commnet_clicked
$main_windowrect = self.windowrect
unless target = @convert_list[@listBox_map.selectedString]
messageBox(MAIN_NOT_SELECT_MES, MAIN_NOT_SELECT_MES_TITLE, 48)
return
end
Modaldlg_post_comment.set(target,@fields)
return unless result = VRLocalScreen.openModalDialog(self,nil,Modaldlg_post_comment,nil,nil) #検索画面のモーダルダイアログを開く
setting_save(false)
end
def menu_maplist_clicked
output = []
file_list = {}
if @convert_list.size == 0
messageBox(MAIN_NOT_SELECT_MES2, MAIN_NOT_SELECT_MES2_TITLE, 48)
return
end
@listBox_map.eachSelected do |i|
file_list[@convert_list[i][6]] = true
output.push [@listBox_map.getTextOf(i).split("\t"),@convert_list[i]]
end
if output.size == 0
messageBox(MAIN_NOT_SELECT_MES2, MAIN_NOT_SELECT_MES2_TITLE, 48)
return
end
savefile = Time.now.strftime($time_format) + ".csv"
fn = SWin::CommonDialog::saveFilename(self,[["CSV FIle(*.csv)","*.csv"],["All File(*.*)","*.*"]],0x1004,PLAY_MAP_LIST_FILE_SAVE_TITLE,'*.csv',0,savefile)
return unless fn
CSV.open(fn,'w') do |record|
list_file = []
@listBox_file.countStrings.times do |i|
list_file << @listBox_file.getTextOf(i).split("\t") if file_list[i]
end
if list_file.size > 0
record << "File,MovieFile".split(",")
list_file.each { |a| record << a }
record << []
record << []
end
record << "File,DateTime,Time,Diff,Speed,Cleared,Rank,Score,Miss,Difficulty,SongName,levelAuthorName,songSubName,songAuthorName,mode,songBPM,noteJumpSpeed,notesCount,bombsCount,obstaclesCount,maxScore,maxRank,environmentName,score,currentMaxScore,passedNotes,hitNotes,missedNotes,passedBombs,hitBombs,combo,maxCombo,multiplier,obstacles,instaFail,noFail,batteryEnergy,disappearingArrows,noBombs,songSpeed,songSpeedMultiplier,noArrows,ghostNotes,failOnSaberClash,strictAngles,fastNotes,staticLights,leftHanded,playerHeight,reduceDebris,noHUD,advancedHUD,autoRestart,levelId,pluginVersion,gameVersion,pauseCount,endFlag,startTime,endTime,menuTime,filename,create_time,access_time,write_time,file_type".split(",")
output.each do |out_target|
line = []
line << out_target[0][0] #File
line << out_target[0][1] #DateTime
line << out_target[0][2] #Time
line << out_target[0][3] #Diff
line << out_target[0][4] #Speed
line << out_target[0][5] #Cleared
line << out_target[0][6] #Rank
line << out_target[0][7] #Score
line << out_target[0][8] #Miss
line << out_target[0][9] #Difficulty
line << out_target[1][1][@fields.index("songName")]
line << out_target[1][1][@fields.index("levelAuthorName")]
line << out_target[1][1][@fields.index("songSubName")]
line << out_target[1][1][@fields.index("songAuthorName")]
line << out_target[1][1][@fields.index("mode")]
line << out_target[1][1][@fields.index("songBPM")]
line << out_target[1][1][@fields.index("noteJumpSpeed")]
line << out_target[1][1][@fields.index("notesCount")]
line << out_target[1][1][@fields.index("bombsCount")]
line << out_target[1][1][@fields.index("obstaclesCount")]
line << out_target[1][1][@fields.index("maxScore")]
line << out_target[1][1][@fields.index("maxRank")]
line << out_target[1][1][@fields.index("environmentName")]
line << out_target[1][1][@fields.index("score")]
line << out_target[1][1][@fields.index("currentMaxScore")]
line << out_target[1][1][@fields.index("passedNotes")]
line << out_target[1][1][@fields.index("hitNotes")]
line << out_target[1][1][@fields.index("missedNotes")]
line << out_target[1][1][@fields.index("passedBombs")]
line << out_target[1][1][@fields.index("hitBombs")]
line << out_target[1][1][@fields.index("combo")]
line << out_target[1][1][@fields.index("maxCombo")]
line << out_target[1][1][@fields.index("multiplier")]
line << out_target[1][1][@fields.index("obstacles")]
line << out_target[1][1][@fields.index("instaFail")]
line << out_target[1][1][@fields.index("noFail")]
line << out_target[1][1][@fields.index("batteryEnergy")]
line << out_target[1][1][@fields.index("disappearingArrows")]
line << out_target[1][1][@fields.index("noBombs")]
line << out_target[1][1][@fields.index("songSpeed")]
line << out_target[1][1][@fields.index("songSpeedMultiplier")]
line << out_target[1][1][@fields.index("noArrows")]
line << out_target[1][1][@fields.index("ghostNotes")]
line << out_target[1][1][@fields.index("failOnSaberClash")]
line << out_target[1][1][@fields.index("strictAngles")]
line << out_target[1][1][@fields.index("fastNotes")]
line << out_target[1][1][@fields.index("staticLights")]
line << out_target[1][1][@fields.index("leftHanded")]
line << out_target[1][1][@fields.index("playerHeight")]
line << out_target[1][1][@fields.index("reduceDebris")]
line << out_target[1][1][@fields.index("noHUD")]
line << out_target[1][1][@fields.index("advancedHUD")]
line << out_target[1][1][@fields.index("autoRestart")]
line << out_target[1][1][@fields.index("levelId")]
line << out_target[1][1][@fields.index("pluginVersion")]
line << out_target[1][1][@fields.index("gameVersion")]
line << out_target[1][1][@fields.index("pauseCount")]
line << out_target[1][1][@fields.index("endFlag")]
line << out_target[1][1][@fields.index("startTime")]
line << out_target[1][1][@fields.index("endTime")]
line << out_target[1][1][@fields.index("menuTime")]
line << out_target[1][0] #filename
line << out_target[1][3] #create_time
line << out_target[1][4] #access_time
line << out_target[1][5] #write_time
line << out_target[1][6] #file_type
record << line
end
end
end
def menu_stat_mapper_clicked
if @convert_list.size == 0
messageBox(MAIN_NOT_SELECT_MES3, MAIN_NOT_SELECT_MES3_TITLE, 48)
return
end