diff --git a/src/AnimationWallet.cpp b/src/AnimationWallet.cpp index 33ced52..4dfdbe5 100644 --- a/src/AnimationWallet.cpp +++ b/src/AnimationWallet.cpp @@ -5,14 +5,14 @@ AnimationWallet::AnimationWallet() this->not_initialized = true; } -AnimationWallet::AnimationWallet(std::string dolphin_path) +AnimationWallet::AnimationWallet(std::string dolphin_path, bool sort_anims) { this->dolphin_path = dolphin_path; this->not_initialized = false; - this->load_animations(); + this->load_animations(sort_anims); } -void AnimationWallet::load_animations() +void AnimationWallet::load_animations(bool sort_anims) { std::string dolphin_path = this->dolphin_path; @@ -68,6 +68,9 @@ void AnimationWallet::load_animations() } } + if (sort_anims) + std::sort(this->animations_names_temp.begin(), this->animations_names_temp.end()); + this->total_animations__loading = this->animations_names_temp.size(); if(dolphin_path.at(dolphin_path.size() - 1) == '/' || dolphin_path.at(dolphin_path.size() - 1) == '\\') diff --git a/src/AnimationWallet.hpp b/src/AnimationWallet.hpp index 8f836be..acc552a 100644 --- a/src/AnimationWallet.hpp +++ b/src/AnimationWallet.hpp @@ -30,9 +30,9 @@ class AnimationWallet public: AnimationWallet(); - AnimationWallet(std::string dolphin_path); + AnimationWallet(std::string dolphin_path, bool sort_anims); ~AnimationWallet(); - void load_animations(); + void load_animations(bool sort_anims); void add_animation(std::string anim_folder, std::string anim_name); void parse_manifest(); bool get_is_folder_correct(); diff --git a/src/main.cpp b/src/main.cpp index 5907fa3..4d2b8f7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -70,6 +70,8 @@ int main(int argc, char* argv[]) SDL_SetWindowMinimumSize(window, 1280, 720); SDL_GL_SetSwapInterval(1); // Enable vsync + bool sort_anims = false; + AnimationWallet* animations_wallet; char current_animations_folder[1024] = {0}; @@ -78,7 +80,7 @@ int main(int argc, char* argv[]) if(strlen(argv[1]) <= 1024) { strcpy(current_animations_folder, argv[1]); - animations_wallet = new AnimationWallet(current_animations_folder); + animations_wallet = new AnimationWallet(current_animations_folder, sort_anims); } else animations_wallet = new AnimationWallet(); @@ -421,10 +423,17 @@ int main(int argc, char* argv[]) { ImGui::Checkbox("Minimal UI Mode", &theater_mode); + if(ImGui::Checkbox("Sort animations", &sort_anims)) + { + animation_wallet_loaded = false; + delete(animations_wallet); + animations_wallet = new AnimationWallet(current_animations_folder, sort_anims); + } + ImGui::MenuItem("About"); if(ImGui::IsItemClicked()) ImGui::OpenPopup("About"); - + ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(20, 20)); ImGui::SetNextWindowSize(ImVec2(500, 350)); if(ImGui::BeginPopupModal("About", NULL, ImGuiWindowFlags_NoResize)) @@ -649,7 +658,7 @@ int main(int argc, char* argv[]) { animation_wallet_loaded = false; delete(animations_wallet); - animations_wallet = new AnimationWallet(current_animations_folder); + animations_wallet = new AnimationWallet(current_animations_folder, sort_anims); } if(!animation_wallet_loaded) { @@ -689,20 +698,20 @@ int main(int argc, char* argv[]) ImGui::SetWindowFontScale(default_font_size); ImGui::EndPopup(); } - + if(file_dialog.showFileDialog("Select Folder", imgui_addons::ImGuiFileBrowser::DialogMode::SELECT, ImVec2(700, 510))) { animation_wallet_loaded = false; strcpy(current_animations_folder, file_dialog.selected_path.c_str()); delete(animations_wallet); - animations_wallet = new AnimationWallet(current_animations_folder); + animations_wallet = new AnimationWallet(current_animations_folder, sort_anims); } if(ImGui::Button("Load")) { animation_wallet_loaded = false; delete(animations_wallet); - animations_wallet = new AnimationWallet(current_animations_folder); + animations_wallet = new AnimationWallet(current_animations_folder, sort_anims); } if(animations_wallet->get_is_folder_correct()) {