Fix display of collision zones in the linear view

This commit is contained in:
Stepland 2022-11-20 00:23:04 +01:00
parent 3fe5985900
commit a9b20518ce
2 changed files with 16 additions and 10 deletions

View File

@ -1042,7 +1042,13 @@ void EditorState::display_sound_settings() {
}
void EditorState::display_editor_settings() {
if (ImGui::Begin("Editor Settings", &show_editor_settings)) {
if (
ImGui::Begin(
"Editor Settings",
&show_editor_settings,
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize
)
) {
static const std::uint64_t step = 1;
if (ImGui::InputScalar("Snap##Editor Settings", ImGuiDataType_U64, &snap, &step, nullptr, "%d")) {
snap = std::clamp(snap, 1UL, 1000UL);
@ -1064,17 +1070,17 @@ void EditorState::display_editor_settings() {
}
ImGui::SameLine();
feis::HelpMarker(
"Change the underlying snap value, this allows setting snap "
"values that aren't a divisor of 240. "
"This changes the underlying value that's multiplied "
"by 4 before being shown in the status bar"
"Suggested minimal duration between two notes on the same "
"button.\n"
"If two notes are closer than this they \"collide\" and are "
"highlighted in red everywhere"
);
const std::array<std::pair<const char*, sf::Time>, 3> presets{{
{"F.E.I.S default", sf::seconds(1)},
{"Safe", sf::milliseconds(1066)},
{"jubeat plus", sf::milliseconds(1030)}
}};
if (ImGui::BeginCombo("Collision Zone Presets", presets[0].first)) {
if (ImGui::BeginCombo("Collision Zone Presets", "Choose ...")) {
for (const auto& [name, value] : presets) {
if (ImGui::Selectable(name, false)) {
config.editor.collision_zone = value;

View File

@ -157,9 +157,9 @@ void LinearView::draw(
const float note_x = timeline_left + note_width * (lane + 0.5f);
const float note_y = static_cast<double>(beats_to_pixels_absolute.transform(tap_note.get_time()));
const auto note_seconds = timing.time_at(tap_note.get_time());
const auto first_colliding_beat = timing.beats_at(note_seconds - sf::milliseconds(500));
const auto first_colliding_beat = timing.beats_at(note_seconds - collision_zone * 0.5f);
const auto collision_zone_y = beats_to_pixels_absolute.transform(first_colliding_beat);
const auto last_colliding_beat = timing.beats_at(note_seconds + sf::milliseconds(500));
const auto last_colliding_beat = timing.beats_at(note_seconds + collision_zone * 0.5f);
const auto collision_zone_height = beats_to_pixels_proportional.transform(last_colliding_beat - first_colliding_beat);
const sf::Vector2f collision_zone_pos = {
note_x,
@ -210,10 +210,10 @@ void LinearView::draw(
float note_x = timeline_left + note_width * (lane + 0.5f);
float note_y = static_cast<double>(beats_to_pixels_absolute.transform(long_note.get_time()));
const auto note_start_seconds = timing.time_at(long_note.get_time());
const auto first_colliding_beat = timing.beats_at(note_start_seconds - sf::milliseconds(500));
const auto first_colliding_beat = timing.beats_at(note_start_seconds - collision_zone * 0.5f);
const auto collision_zone_y = beats_to_pixels_absolute.transform(first_colliding_beat);
const auto note_end_seconds = timing.time_at(long_note.get_end());
const auto last_colliding_beat = timing.beats_at(note_end_seconds + sf::milliseconds(500));
const auto last_colliding_beat = timing.beats_at(note_end_seconds + collision_zone * 0.5f);
const auto collision_zone_height = beats_to_pixels_proportional.transform(last_colliding_beat - first_colliding_beat);
const sf::Vector2f collision_zone_pos = {
note_x,