Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'loop' feature #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/rendering/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ void State::defineOptions(){
_sharedInfos[s_scroll_speed_key] = {Category::PLAYBACK, s_scroll_speed_dsc, Type::FLOAT};
_sharedInfos[s_scroll_reverse_key] = {Category::PLAYBACK, s_scroll_reverse_dsc, Type::BOOLEAN};
_sharedInfos[s_scroll_horizontal_key] = {Category::PLAYBACK, s_scroll_horizontal_dsc, Type::BOOLEAN};
_sharedInfos[s_loop_key] = {Category::PLAYBACK, s_loop_dsc, Type::BOOLEAN};

// Effects
_sharedInfos[s_layers_key] = {Category::EFFECTS, s_layers_dsc, Type::OTHER};
Expand Down Expand Up @@ -474,6 +475,7 @@ void State::updateOptions(){
_boolInfos[s_smooth_key] = &applyAA;
_boolInfos[s_scroll_reverse_key] = &reverseScroll;
_boolInfos[s_scroll_horizontal_key] = &horizontalScroll;
_boolInfos[s_loop_key] = &loop;

_pathInfos[s_bg_img_path_key] = &background.imagePath;
_pathInfos[s_particles_paths_key] = &particles.imagePaths;
Expand Down Expand Up @@ -920,6 +922,7 @@ void State::reset(){
applyAA = false;
reverseScroll = false;
horizontalScroll = false;
loop = false;

_filePath = "";
}
Expand Down
1 change: 1 addition & 0 deletions src/rendering/State.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class State {
bool applyAA;
bool reverseScroll;
bool horizontalScroll;
bool loop;

std::array<int, 16> layersMap; ///< Location of each layer.

Expand Down
16 changes: 16 additions & 0 deletions src/rendering/Viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ SystemAction Viewer::draw(float currentTime) {
// playback is disabled.
_timer = _shouldPlay ? (currentTime - _timerStart) : _timer;

if (_shouldPlay && _state.loop && _timer >= _scene->duration()) {
reset();
}

// Render scene and blit, with GUI on top if needed.
drawScene(_useTransparency);

Expand Down Expand Up @@ -555,6 +559,18 @@ SystemAction Viewer::drawGUI(const float currentTime) {
ImGui::helpTooltip(s_scroll_reverse_dsc);
}

if(_liveplay){
ImGui::BeginDisabled();
}
ImGui::Checkbox("Loop", &_state.loop);
if(_liveplay){
ImGui::EndDisabled();
if(ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled)){
ImGui::SetTooltip("Not available in liveplay");
}
} else {
ImGui::helpTooltip(s_loop_dsc);
}
}

if(ImGui::CollapsingHeader("Notes##HEADER")){
Expand Down
3 changes: 3 additions & 0 deletions src/resources/strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ constexpr const char* s_scroll_reverse_dsc = "Notes scroll from bottom to t
constexpr const char* s_scroll_horizontal_key = "scroll-horizontal";
constexpr const char* s_scroll_horizontal_dsc = "Notes scroll from right to left when enabled";

constexpr const char* s_loop_key = "loop";
constexpr const char* s_loop_dsc = "Loop playback from start to end";

constexpr const char* s_layers_key = "layers";
constexpr const char* s_layers_dsc = "Active layers indices, from background to foreground";

Expand Down