Skip to content

Commit 0c859ba

Browse files
committed
Add a status message when some actions drop notes
Closes #46.
1 parent dc0239b commit 0c859ba

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

globals/Controller.gd

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,16 @@ func update_status(message: String, level: StatusLevel = StatusLevel.INFO) -> vo
281281
status_updated.emit(level, message)
282282

283283

284+
func update_status_notes_dropped(dropped_amount: int) -> void:
285+
if dropped_amount <= 0:
286+
return
287+
288+
if dropped_amount == 1:
289+
update_status("%d NOTE WAS REMOVED (CTRL + Z TO UNDO)" % [ dropped_amount ], Controller.StatusLevel.WARNING)
290+
else:
291+
update_status("%d NOTES WERE REMOVED (CTRL + Z TO UNDO)" % [ dropped_amount ], Controller.StatusLevel.WARNING)
292+
293+
284294
# Song editing.
285295

286296
func set_current_song(song: Song) -> void:
@@ -672,6 +682,8 @@ func delete_instrument(instrument_index: int) -> void:
672682
state_context.reset_patterns_affected.clear()
673683
state_context.shifted_patterns.clear()
674684

685+
var total_affected_count := 0
686+
675687
# Validate instruments in available patterns.
676688

677689
# Note that we actually want the current pattern here, not the one that was current when we
@@ -683,10 +695,11 @@ func delete_instrument(instrument_index: int) -> void:
683695
# If we deleted this instrument, set the pattern to the first available.
684696
if pattern.instrument_idx == instrument_index:
685697
state_context.reset_patterns_keys.push_back(pattern.key) # When changing to a drumkit, this is reset.
686-
698+
687699
var affected := pattern.change_instrument(0, current_song.instruments[0])
688700
state_context.reset_patterns.push_back(pattern_idx)
689701
state_context.reset_patterns_affected.push_back(affected)
702+
total_affected_count += affected.size()
690703

691704
if pattern_idx == current_pattern_index:
692705
current_pattern_affected = true
@@ -701,6 +714,9 @@ func delete_instrument(instrument_index: int) -> void:
701714

702715
song_instrument_changed.emit()
703716

717+
if total_affected_count > 0:
718+
update_status_notes_dropped(total_affected_count)
719+
704720
# Properly signal that the instrument has changed for the currently edited pattern.
705721
if current_pattern_affected:
706722
refresh_current_pattern_instrument()
@@ -786,18 +802,24 @@ func _set_current_instrument_by_voice(voice_data: VoiceManager.VoiceData) -> voi
786802
state_context.reset_patterns_keys.clear()
787803
state_context.reset_patterns_affected.clear()
788804

805+
var total_affected_count := 0
806+
789807
# Validate instruments in available patterns.
790808
for pattern_idx in current_song.patterns.size():
791809
var pattern := current_song.patterns[pattern_idx]
792810

793811
if pattern.instrument_idx == instrument_idx:
794812
state_context.reset_patterns_keys.push_back(pattern.key) # When changing to a drumkit, this is reset.
795-
813+
796814
var affected := pattern.change_instrument(instrument_idx, instrument)
797815
state_context.reset_patterns.push_back(pattern_idx)
798816
state_context.reset_patterns_affected.push_back(affected)
799-
817+
total_affected_count += affected.size()
818+
800819
song_instrument_changed.emit()
820+
821+
if total_affected_count > 0:
822+
update_status_notes_dropped(total_affected_count)
801823
)
802824
song_state.add_undo_action(func() -> void:
803825
current_song.instruments[instrument_idx] = old_instrument

gui/views/PatternEditor.gd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ func _change_instrument() -> void:
200200

201201
state_context.key = reference_pattern.key # When changing to a drumkit, this is reset.
202202
state_context.affected = reference_pattern.change_instrument(instrument_idx, pattern_instrument)
203+
204+
if not state_context.affected.is_empty():
205+
Controller.update_status_notes_dropped(state_context.affected.size())
203206
)
204207
pattern_state.add_undo_action(func() -> void:
205208
var reference_pattern := Controller.current_song.patterns[pattern_state.reference_id]
@@ -231,6 +234,9 @@ func _change_scale() -> void:
231234
pattern_state.add_do_action(func() -> void:
232235
var reference_pattern := Controller.current_song.patterns[pattern_state.reference_id]
233236
state_context.affected = reference_pattern.change_scale(scale_id)
237+
238+
if not state_context.affected.is_empty():
239+
Controller.update_status_notes_dropped(state_context.affected.size())
234240
)
235241
pattern_state.add_undo_action(func() -> void:
236242
var reference_pattern := Controller.current_song.patterns[pattern_state.reference_id]

0 commit comments

Comments
 (0)