Recompute density graph on more occasions

This commit is contained in:
Stepland 2022-11-20 01:38:56 +01:00
parent a9b20518ce
commit 16d163c0dc
3 changed files with 20 additions and 7 deletions

View File

@ -41,6 +41,7 @@ void ChartState::cut(
chart.notes->erase(note);
}
history.push(std::make_shared<RemoveNotes>(difficulty_name, selected_stuff.notes));
density_graph.should_recompute = true;
}
if (not selected_stuff.bpm_events.empty()) {
const auto before = timing;
@ -147,6 +148,7 @@ void ChartState::delete_(
chart.notes->erase(note);
}
selected_stuff.notes.clear();
density_graph.should_recompute = true;
}
if (not selected_stuff.bpm_events.empty()) {
const auto before = timing;

View File

@ -1106,11 +1106,16 @@ void EditorState::display_timing_menu() {
playback_position
);
if (feis::InputDecimal("BPM", &bpm, ImGuiInputTextFlags_EnterReturnsTrue)) {
const auto before = *applicable_timing;
applicable_timing->insert(better::BPMAtBeat{bpm, current_snaped_beats()});
if (*applicable_timing != before) {
reload_sounds_that_depend_on_timing();
history.push(std::make_shared<ChangeTiming>(before, *applicable_timing, timing_origin()));
if (bpm > 0) {
const auto before = *applicable_timing;
applicable_timing->insert(better::BPMAtBeat{bpm, current_snaped_beats()});
if (*applicable_timing != before) {
reload_sounds_that_depend_on_timing();
history.push(std::make_shared<ChangeTiming>(before, *applicable_timing, timing_origin()));
}
if (chart_state) {
chart_state->density_graph.should_recompute = true;
}
}
}
auto offset = applicable_timing->get_offset();
@ -1118,6 +1123,9 @@ void EditorState::display_timing_menu() {
applicable_timing->set_offset(offset);
reload_sounds_that_depend_on_timing();
set_playback_position(current_exact_beats());
if (chart_state) {
chart_state->density_graph.should_recompute = true;
}
}
}
ImGui::End();
@ -1222,7 +1230,6 @@ void EditorState::undo(NotificationsQueue& nq) {
if (previous) {
nq.push(std::make_shared<UndoNotification>(**previous));
(*previous)->undo_action(*this);
chart_state->density_graph.should_recompute = true;
}
};
@ -1231,7 +1238,6 @@ void EditorState::redo(NotificationsQueue& nq) {
if (next) {
nq.push(std::make_shared<RedoNotification>(**next));
(*next)->do_action(*this);
chart_state->density_graph.should_recompute = true;
}
};

View File

@ -44,6 +44,7 @@ void AddNotes::do_action(EditorState& ed) const {
for (const auto& [_, note] : notes) {
ed.chart_state->chart.notes->insert(note);
}
ed.chart_state->density_graph.should_recompute = true;
}
}
@ -56,6 +57,7 @@ void AddNotes::undo_action(EditorState& ed) const {
for (const auto& [_, note] : notes) {
ed.chart_state->chart.notes->erase(note);
}
ed.chart_state->density_graph.should_recompute = true;
}
}
@ -316,4 +318,7 @@ void ChangeTiming::set_value(EditorState& ed, const better::Timing& value) const
std::visit(set_value_, origin);
ed.reload_applicable_timing();
ed.reload_sounds_that_depend_on_timing();
if (ed.chart_state) {
ed.chart_state->density_graph.should_recompute = true;
}
}