sscharter 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/lib/sscharter/version.rb +1 -1
- data/lib/sscharter.rb +88 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1695717274c0888590e92f6a3dabf86fca4a2d34aaad9f17dc9a88ab20311207
|
4
|
+
data.tar.gz: 78096695809b63551d5f48a3c11d4120ead84157c1146b4064a9f8f1262b66c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e64530c4c426710eae970e9bd7fd4609d307a75102cdea4920f9ed5ae8208313cc48efae86c545b95cdecaec79e6da6738d92d5db1f8861ea142b3f2b843c88
|
7
|
+
data.tar.gz: 64725aa5bf3336f3ab3965f583cf4ed80e02296a18a1be9c1427542d9bc79164b602f99b19a2c7f45e243d32e8456911940971ffd3794e8027ec6e4db17d5221
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sscharter (0.
|
4
|
+
sscharter (0.7.0)
|
5
5
|
concurrent-ruby (~> 1.3)
|
6
6
|
em-websocket (~> 0.5)
|
7
7
|
filewatcher (~> 2.0)
|
@@ -14,7 +14,7 @@ GEM
|
|
14
14
|
specs:
|
15
15
|
addressable (2.8.7)
|
16
16
|
public_suffix (>= 2.0.2, < 7.0)
|
17
|
-
concurrent-ruby (1.3.
|
17
|
+
concurrent-ruby (1.3.4)
|
18
18
|
em-websocket (0.5.3)
|
19
19
|
eventmachine (>= 0.12.9)
|
20
20
|
http_parser.rb (~> 0)
|
@@ -24,7 +24,7 @@ GEM
|
|
24
24
|
http_parser.rb (0.8.0)
|
25
25
|
launchy (2.5.2)
|
26
26
|
addressable (~> 2.8)
|
27
|
-
minitest (5.
|
27
|
+
minitest (5.25.1)
|
28
28
|
module_methods (0.1.0)
|
29
29
|
public_suffix (6.0.1)
|
30
30
|
rake (13.2.1)
|
data/lib/sscharter/version.rb
CHANGED
data/lib/sscharter.rb
CHANGED
@@ -324,6 +324,7 @@ class Sunniesnow::Charter
|
|
324
324
|
@name = name
|
325
325
|
init_chart_info
|
326
326
|
init_state
|
327
|
+
init_bookmarks
|
327
328
|
end
|
328
329
|
|
329
330
|
def init_chart_info
|
@@ -337,8 +338,11 @@ class Sunniesnow::Charter
|
|
337
338
|
@events = []
|
338
339
|
end
|
339
340
|
|
341
|
+
def init_bookmarks
|
342
|
+
@bookmarks = {}
|
343
|
+
end
|
344
|
+
|
340
345
|
def init_state
|
341
|
-
@current_offset = nil
|
342
346
|
@current_beat = nil
|
343
347
|
@bpm_changes = nil
|
344
348
|
@tip_point_mode_stack = [:none]
|
@@ -399,9 +403,8 @@ class Sunniesnow::Charter
|
|
399
403
|
|
400
404
|
def offset offset
|
401
405
|
raise ArgumentError, 'offset must be a number' unless offset.is_a? Numeric
|
402
|
-
@current_offset = offset.to_f
|
403
406
|
@current_beat = 0r
|
404
|
-
@bpm_changes = BpmChangeList.new
|
407
|
+
@bpm_changes = BpmChangeList.new offset.to_f
|
405
408
|
end
|
406
409
|
|
407
410
|
def bpm bpm
|
@@ -449,27 +452,72 @@ class Sunniesnow::Charter
|
|
449
452
|
alias_method "tp_#{mode}", "tip_point_#{mode}"
|
450
453
|
end
|
451
454
|
|
455
|
+
def backup_beat
|
456
|
+
{current_beat: @current_beat, bpm_changes: @bpm_changes}
|
457
|
+
end
|
458
|
+
|
459
|
+
def restore_beat backup
|
460
|
+
@current_beat = backup[:current_beat]
|
461
|
+
@bpm_changes = backup[:bpm_changes]
|
462
|
+
end
|
463
|
+
|
452
464
|
def group preserve_beat: true, &block
|
453
465
|
raise ArgumentError, 'no block given' unless block
|
454
466
|
@groups.push result = []
|
455
|
-
unless preserve_beat
|
456
|
-
last_beat = @current_beat
|
457
|
-
last_offset = @current_offset
|
458
|
-
last_bpm_changes = @bpm_changes
|
459
|
-
end
|
467
|
+
beat_backup = backup_beat unless preserve_beat
|
460
468
|
instance_eval &block
|
461
|
-
unless preserve_beat
|
462
|
-
@current_beat = last_beat
|
463
|
-
@current_offset = last_offset
|
464
|
-
@bpm_changes = last_bpm_changes
|
465
|
-
end
|
469
|
+
restore_beat beat_backup unless preserve_beat
|
466
470
|
@groups.delete_if { result.equal? _1 }
|
467
471
|
result
|
468
472
|
end
|
469
473
|
|
474
|
+
def backup_state
|
475
|
+
{
|
476
|
+
current_beat: @current_beat,
|
477
|
+
bpm_changes: @bpm_changes,
|
478
|
+
tip_point_mode_stack: @tip_point_mode_stack.dup,
|
479
|
+
current_tip_point_stack: @current_tip_point_stack.dup,
|
480
|
+
current_tip_point_group_stack: @current_tip_point_group_stack.dup,
|
481
|
+
current_duplicate: @current_duplicate,
|
482
|
+
tip_point_start_to_add_stack: @tip_point_start_to_add_stack.dup,
|
483
|
+
groups: @groups.dup
|
484
|
+
}
|
485
|
+
end
|
486
|
+
|
487
|
+
def restore_state backup
|
488
|
+
@current_beat = backup[:current_beat]
|
489
|
+
@bpm_changes = backup[:bpm_changes]
|
490
|
+
@tip_point_mode_stack = backup[:tip_point_mode_stack]
|
491
|
+
@current_tip_point_stack = backup[:current_tip_point_stack]
|
492
|
+
@current_tip_point_group_stack = backup[:current_tip_point_group_stack]
|
493
|
+
@current_duplicate = backup[:current_duplicate]
|
494
|
+
@tip_point_start_to_add_stack = backup[:tip_point_start_to_add_stack]
|
495
|
+
@groups = backup[:groups]
|
496
|
+
nil
|
497
|
+
end
|
498
|
+
|
499
|
+
def mark name
|
500
|
+
@bookmarks[name] = backup_state
|
501
|
+
name
|
502
|
+
end
|
503
|
+
|
504
|
+
def at name, preserve_beat: false, update_mark: false, &block
|
505
|
+
raise ArgumentError, 'no block given' unless block
|
506
|
+
raise ArgumentError, "unknown bookmark #{name}" unless bookmark = @bookmarks[name]
|
507
|
+
backup = backup_state
|
508
|
+
restore_state bookmark
|
509
|
+
result = group &block
|
510
|
+
mark name if update_mark
|
511
|
+
beat_backup = backup_beat if preserve_beat
|
512
|
+
restore_state backup
|
513
|
+
restore_beat beat_backup if preserve_beat
|
514
|
+
result
|
515
|
+
end
|
516
|
+
|
470
517
|
def tip_point mode, *args, preserve_beat: true, **opts, &block
|
471
518
|
@tip_point_mode_stack.push mode
|
472
519
|
if mode == :none
|
520
|
+
@tip_point_start_to_add_stack.push nil
|
473
521
|
@current_tip_point_stack.push nil
|
474
522
|
else
|
475
523
|
@tip_point_start_to_add_stack.push TipPointStart.new *args, **opts
|
@@ -659,4 +707,31 @@ class Sunniesnow::Charter
|
|
659
707
|
"#<Sunniesnow::Charter #@name>"
|
660
708
|
end
|
661
709
|
|
710
|
+
def check(
|
711
|
+
notes_in_bound: true,
|
712
|
+
bg_notes_in_bound: true
|
713
|
+
)
|
714
|
+
out_of_bound_events = [] if notes_in_bound || bg_notes_in_bound
|
715
|
+
@events.each do |event|
|
716
|
+
if %i[tap hold drag flick].include?(event.type) && notes_in_bound || event.type == :bg_note && bg_notes_in_bound
|
717
|
+
if event[:x] < -100-1e-10 || event[:x] > 100+1e-10 || event[:y] < -50-1e-10 || event[:y] > 50+1e-10
|
718
|
+
out_of_bound_events.push event
|
719
|
+
end
|
720
|
+
end
|
721
|
+
end
|
722
|
+
if notes_in_bound || bg_notes_in_bound
|
723
|
+
if out_of_bound_events.empty?
|
724
|
+
puts "===== All notes are in bound ====="
|
725
|
+
else
|
726
|
+
puts "===== Out-of-bound notes ====="
|
727
|
+
out_of_bound_events.each do |event|
|
728
|
+
p event
|
729
|
+
puts "at time #{event.time}"
|
730
|
+
puts 'defined at:'
|
731
|
+
puts event.backtrace
|
732
|
+
end
|
733
|
+
end
|
734
|
+
end
|
735
|
+
end
|
736
|
+
|
662
737
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sscharter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ulysses Zhan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|