Minor bug fixes. Updated moon mission sample

This commit is contained in:
Pranav Srinivas Kumar
2019-12-04 15:33:27 -06:00
parent 5ff5c06ee6
commit f9b3e6696b
2 changed files with 27 additions and 9 deletions

View File

@@ -136,7 +136,7 @@ private:
} }
std::cout << _prefix_text; std::cout << _prefix_text;
std::cout << _start; std::cout << _start;
float pos = _progress * static_cast<float>(_bar_width) / 100.0; auto pos = static_cast<size_t>(_progress * static_cast<float>(_bar_width) / 100.0);
for (size_t i = 0; i < _bar_width; ++i) { for (size_t i = 0; i < _bar_width; ++i) {
if (i < pos) if (i < pos)
std::cout << _fill; std::cout << _fill;

View File

@@ -228,7 +228,7 @@ int main() {
} }
else else
p.tick(); p.tick();
std::this_thread::sleep_for(std::chrono::milliseconds(60)); std::this_thread::sleep_for(std::chrono::milliseconds(40));
} }
}; };
std::thread thread(job); std::thread thread(job);
@@ -246,16 +246,34 @@ int main() {
auto job = [&p]() { auto job = [&p]() {
while (true) { while (true) {
auto current = p.current(); auto current = p.current();
if (current == 25) { if (current == 24) {
p.set_prefix_text(" - ✔");
p.hide_spinner();
}
else if (current == 25) {
std::cout << std::endl; std::cout << std::endl;
p.show_spinner();
p.set_prefix_text(" - ");
p.set_postfix_text("Designing spaceship"); p.set_postfix_text("Designing spaceship");
} }
else if (current == 49) {
p.set_prefix_text(" - ✔");
p.hide_spinner();
}
else if (current == 50) { else if (current == 50) {
std::cout << std::endl; std::cout << std::endl;
p.show_spinner();
p.set_prefix_text(" - ");
p.set_postfix_text("Contacting Elon Musk"); p.set_postfix_text("Contacting Elon Musk");
} }
else if (current == 74) {
p.set_prefix_text(" - ✔");
p.hide_spinner();
}
else if (current == 75) { else if (current == 75) {
std::cout << std::endl; std::cout << std::endl;
p.show_spinner();
p.set_prefix_text(" - ");
p.set_postfix_text("Launching rocket"); p.set_postfix_text("Launching rocket");
} }
else if (current == 95) { else if (current == 95) {
@@ -268,13 +286,13 @@ int main() {
// NESTED PROGRESS BAR // NESTED PROGRESS BAR
// //
indica::ProgressBar p2; indica::ProgressBar p2;
p2.set_bar_width(50); p2.set_bar_width(30);
p2.set_prefix_text(" - "); p2.set_prefix_text(" - ");
p2.start_bar_with("["); p2.start_bar_with("[🌎");
p2.fill_bar_progress_with("="); p2.fill_bar_progress_with(" ");
p2.lead_bar_progress_with(">"); p2.lead_bar_progress_with("🚀");
p2.fill_bar_remainder_with(" "); p2.fill_bar_remainder_with(" ");
p2.end_bar_with("]"); p2.end_bar_with("🌑]");
p2.set_postfix_text("Achieved low-Earth orbit"); p2.set_postfix_text("Achieved low-Earth orbit");
p2.set_foreground_color(indica::Color::WHITE); p2.set_foreground_color(indica::Color::WHITE);
auto job2 = [&p2]() { auto job2 = [&p2]() {