Shared Catalog
This commit is contained in:
@@ -12,14 +12,14 @@ auto menu_row_count(std::size_t item_count) -> std::size_t {
|
||||
}
|
||||
|
||||
auto vamp_zero::selected_group(vamp_zero::app_state const &state) -> vamp_zero::song_group const * {
|
||||
if (state.selected_song_index == 0U || state.performance.groups.empty()) {
|
||||
if (state.selected_song_index == 0U || state.catalog->performance.groups.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto index = state.selected_song_index - 1U;
|
||||
if (index >= state.performance.groups.size()) {
|
||||
if (index >= state.catalog->performance.groups.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
return &state.performance.groups[index];
|
||||
return &state.catalog->performance.groups[index];
|
||||
}
|
||||
|
||||
auto vamp_zero::selected_part(vamp_zero::app_state const &state) -> vamp_zero::library_part const * {
|
||||
@@ -31,28 +31,29 @@ auto vamp_zero::selected_part(vamp_zero::app_state const &state) -> vamp_zero::l
|
||||
if (index >= group->parts.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
return &group->parts[index];
|
||||
auto part_index = group->parts[index];
|
||||
return part_index < state.catalog->performance.parts.size() ? &state.catalog->performance.parts[part_index] : nullptr;
|
||||
}
|
||||
|
||||
auto vamp_zero::active_part(vamp_zero::app_state const &state) -> vamp_zero::library_part const * {
|
||||
if (state.active_part_id.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto found = std::find_if(state.performance.parts.begin(), state.performance.parts.end(), [&](auto const &part) {
|
||||
auto found = std::find_if(state.catalog->performance.parts.begin(), state.catalog->performance.parts.end(), [&](auto const &part) {
|
||||
return part.id == state.active_part_id;
|
||||
});
|
||||
return found == state.performance.parts.end() ? nullptr : &*found;
|
||||
return found == state.catalog->performance.parts.end() ? nullptr : &*found;
|
||||
}
|
||||
|
||||
auto vamp_zero::selected_practice_type(vamp_zero::app_state const &state) -> vamp_zero::practice_type_group const * {
|
||||
if (state.selected_practice_type_index == 0U || state.practice.types.empty()) {
|
||||
if (state.selected_practice_type_index == 0U || state.catalog->practice.types.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto index = state.selected_practice_type_index - 1U;
|
||||
if (index >= state.practice.types.size()) {
|
||||
if (index >= state.catalog->practice.types.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
return &state.practice.types[index];
|
||||
return &state.catalog->practice.types[index];
|
||||
}
|
||||
|
||||
auto vamp_zero::selected_practice_lesson(vamp_zero::app_state const &state) -> vamp_zero::practice_lesson_group const * {
|
||||
@@ -76,17 +77,18 @@ auto vamp_zero::selected_practice_exercise(vamp_zero::app_state const &state) ->
|
||||
if (index >= lesson->exercises.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
return &lesson->exercises[index];
|
||||
auto exercise_index = lesson->exercises[index];
|
||||
return exercise_index < state.catalog->practice.exercises.size() ? &state.catalog->practice.exercises[exercise_index] : nullptr;
|
||||
}
|
||||
|
||||
auto vamp_zero::active_practice(vamp_zero::app_state const &state) -> vamp_zero::practice_exercise const * {
|
||||
if (state.active_practice_id.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto found = std::find_if(state.practice.exercises.begin(),
|
||||
state.practice.exercises.end(),
|
||||
auto found = std::find_if(state.catalog->practice.exercises.begin(),
|
||||
state.catalog->practice.exercises.end(),
|
||||
[&](auto const &exercise) { return exercise.id == state.active_practice_id; });
|
||||
return found == state.practice.exercises.end() ? nullptr : &*found;
|
||||
return found == state.catalog->practice.exercises.end() ? nullptr : &*found;
|
||||
}
|
||||
|
||||
auto vamp_zero::supports_key_selection(vamp_zero::practice_exercise const &exercise) -> std::bool_t {
|
||||
@@ -131,7 +133,7 @@ auto vamp_zero::effective_practice_key(vamp_zero::app_state const &state, vamp_z
|
||||
variant != nullptr && !variant->key_signature.empty()) {
|
||||
return variant->key_signature;
|
||||
}
|
||||
return exercise.key_signature.empty() ? std::string{"C"} : exercise.key_signature;
|
||||
return exercise.variants.empty() ? std::string{} : exercise.variants.front().key_signature;
|
||||
}
|
||||
|
||||
auto vamp_zero::active_pages(vamp_zero::app_state const &state) -> std::size_t {
|
||||
|
||||
Reference in New Issue
Block a user