diff --git a/joomer-ftxui-bsz-browser.cpp b/joomer-ftxui-bsz-browser.cpp index 7dde640..70deddd 100644 --- a/joomer-ftxui-bsz-browser.cpp +++ b/joomer-ftxui-bsz-browser.cpp @@ -12,6 +12,7 @@ #include // For std::this_thread (C++ standard library) #include // For timing operations (C++ standard library) #include // For freopen +#include std::string directory_path = "."; int selected_index = -1; // Global variable to hold the selected index @@ -370,6 +371,34 @@ int main(int argc, char* argv[]) { // Get the latest progress string from the observer std::string current_progress = engineObserver.getProgress(); + float progress = 0.0f; + + // Find number in string + std::regex number_regex(R"((\d+(\.\d+)?))"); + std::smatch match; + + if (std::regex_search(current_progress, match, number_regex)) { + try { + float value = std::stof(match.str()); // "9.26" -> 9.26 + progress = std::clamp(value / 100.0f, 0.0f, 1.0f); // normalize + } + catch (...) { + progress = 0.0f; + } + } + + /* float progress = 0.0f; + + if (!current_progress.empty()) { + try { + int value = std::stoi(current_progress); // "45" -> 45 + progress = std::clamp(value / 100.0f, 0.0f, 1.0f); + } + catch (...) { + progress = 0.0f; // fallback if not numeric + } + }*/ + return ftxui::vbox({ // Header showing the current directory @@ -390,7 +419,7 @@ int main(int argc, char* argv[]) { ftxui::text(current_progress.empty() ? "Idle" : current_progress) | ftxui::color(ftxui::Color::Green), }), - + ftxui::gauge(progress), ftxui::separator(), ftxui::hbox({ ftxui::text("Enter folder #: "),