@@ -45,40 +45,15 @@ auto vamp_zero::active_part(vamp_zero::app_state const &state) -> vamp_zero::lib
|
||||
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.catalog->practice.types.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto index = state.selected_practice_type_index - 1U;
|
||||
if (index >= state.catalog->practice.types.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
return &state.catalog->practice.types[index];
|
||||
}
|
||||
|
||||
auto vamp_zero::selected_practice_lesson(vamp_zero::app_state const &state) -> vamp_zero::practice_lesson_group const * {
|
||||
auto const *type = vamp_zero::selected_practice_type(state);
|
||||
if (state.selected_practice_lesson_index == 0U || type == nullptr || type->lesson_groups.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto index = state.selected_practice_lesson_index - 1U;
|
||||
if (index >= type->lesson_groups.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
return &type->lesson_groups[index];
|
||||
}
|
||||
|
||||
auto vamp_zero::selected_practice_exercise(vamp_zero::app_state const &state) -> vamp_zero::practice_exercise const * {
|
||||
auto const *lesson = vamp_zero::selected_practice_lesson(state);
|
||||
if (state.selected_practice_exercise_index == 0U || lesson == nullptr || lesson->exercises.empty()) {
|
||||
if (state.selected_practice_exercise_index == 0U) {
|
||||
return nullptr;
|
||||
}
|
||||
auto index = state.selected_practice_exercise_index - 1U;
|
||||
if (index >= lesson->exercises.size()) {
|
||||
if (index >= state.catalog->practice.exercises.size()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto exercise_index = lesson->exercises[index];
|
||||
return exercise_index < state.catalog->practice.exercises.size() ? &state.catalog->practice.exercises[exercise_index] : nullptr;
|
||||
return &state.catalog->practice.exercises[index];
|
||||
}
|
||||
|
||||
auto vamp_zero::active_practice(vamp_zero::app_state const &state) -> vamp_zero::practice_exercise const * {
|
||||
@@ -91,17 +66,10 @@ auto vamp_zero::active_practice(vamp_zero::app_state const &state) -> vamp_zero:
|
||||
return found == state.catalog->practice.exercises.end() ? nullptr : &*found;
|
||||
}
|
||||
|
||||
auto vamp_zero::supports_key_selection(vamp_zero::practice_exercise const &exercise) -> std::bool_t {
|
||||
return vamp_zero::practice_type_supports_key_selection(exercise.practice_type_id);
|
||||
}
|
||||
|
||||
auto vamp_zero::selected_practice_variant(vamp_zero::app_state const &state, vamp_zero::practice_exercise const &exercise) -> vamp_zero::practice_exercise::score_variant const * {
|
||||
if (exercise.variants.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (!vamp_zero::supports_key_selection(exercise)) {
|
||||
return &exercise.variants.front();
|
||||
}
|
||||
if (state.selected_practice_key_index == 0U) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -122,7 +90,7 @@ auto vamp_zero::selected_practice_key(vamp_zero::app_state const &state, vamp_ze
|
||||
|
||||
auto vamp_zero::practice_key_row_count(vamp_zero::app_state const &state) -> std::size_t {
|
||||
auto const *exercise = vamp_zero::selected_practice_exercise(state);
|
||||
if (exercise == nullptr || !vamp_zero::supports_key_selection(*exercise)) {
|
||||
if (exercise == nullptr) {
|
||||
return 1U;
|
||||
}
|
||||
return menu_row_count(exercise->variants.size());
|
||||
@@ -148,13 +116,3 @@ auto vamp_zero::active_pages(vamp_zero::app_state const &state) -> std::size_t {
|
||||
}
|
||||
return 0U;
|
||||
}
|
||||
|
||||
auto vamp_zero::practice_fallback_menu(vamp_zero::app_state const &state) -> vamp_zero::app_mode {
|
||||
if (vamp_zero::selected_practice_lesson(state) != nullptr) {
|
||||
return vamp_zero::app_mode::PRACTICE_EXERCISE_MENU;
|
||||
}
|
||||
if (vamp_zero::selected_practice_type(state) != nullptr) {
|
||||
return vamp_zero::app_mode::PRACTICE_LESSON_MENU;
|
||||
}
|
||||
return vamp_zero::app_mode::PRACTICE_TYPE_MENU;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user