mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2026-08-04 07:18:50 +00:00
moved progressbar from dhrg-utils to main
This commit is contained in:
+27
@@ -573,4 +573,31 @@ EX void rate_limited_error(const string& s, const string& t IS("")) {
|
||||
}
|
||||
}
|
||||
|
||||
#if HDR
|
||||
struct progressbar : indenter_finish {
|
||||
string name;
|
||||
static constexpr int PBSIZE = 64;
|
||||
int step = -1, total, drawat = 0, count = -1;
|
||||
|
||||
void operator ++ (int) {
|
||||
step++;
|
||||
while(step >= drawat && total) {
|
||||
count++;
|
||||
drawat = (total * (count+1)) / PBSIZE;
|
||||
fprintf(stderr, "%s [", get_stamp().c_str());
|
||||
for(int k=0; k<count; k++) fprintf(stderr, "#");
|
||||
for(int k=count; k<64; k++) fprintf(stderr, "-");
|
||||
fprintf(stderr, "] %s\x1b[K\r", name.c_str());
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
~progressbar() {
|
||||
fprintf(stderr, "\x1b[K");
|
||||
}
|
||||
|
||||
progressbar(int t, string n) : indenter_finish(n) { hlog.indentation -= 2; println(hlog, name); hlog.indentation += 2; total = t; (*this)++; }
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
// general utilities
|
||||
#include <sys/time.h>
|
||||
|
||||
namespace dhrg {
|
||||
|
||||
struct progressbar : indenter_finish {
|
||||
string name;
|
||||
static constexpr int PBSIZE = 64;
|
||||
int step = -1, total, drawat = 0, count = -1;
|
||||
|
||||
void operator ++ (int) {
|
||||
step++;
|
||||
while(step >= drawat && total) {
|
||||
count++;
|
||||
drawat = (total * (count+1)) / PBSIZE;
|
||||
fprintf(stderr, "%s [", get_stamp().c_str());
|
||||
for(int k=0; k<count; k++) fprintf(stderr, "#");
|
||||
for(int k=count; k<64; k++) fprintf(stderr, "-");
|
||||
fprintf(stderr, "] %s\x1b[K\r", name.c_str());
|
||||
fflush(stderr);
|
||||
}
|
||||
}
|
||||
|
||||
~progressbar() {
|
||||
fprintf(stderr, "\x1b[K");
|
||||
}
|
||||
|
||||
progressbar(int t, string n) : indenter_finish(n) { hlog.indentation -= 2; println(hlog, name); hlog.indentation += 2; total = t; (*this)++; }
|
||||
};
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
namespace rogueviz { extern string fname; }
|
||||
|
||||
#include "readgraph.cpp"
|
||||
#include "dhrg-utils.cpp"
|
||||
#include "regular.cpp"
|
||||
#include "gridmapping.cpp"
|
||||
#include "mycell.cpp"
|
||||
|
||||
Reference in New Issue
Block a user