Change Details
| src/gmenu2x.cpp |
| 1867 | 1867 | |
| 1868 | 1868 | int ret = statvfs("/card/gmenu2x", &b); |
| 1869 | 1869 | if (ret==0) { |
| 1870 | | /*unsigned long free = b.f_bfree*b.f_frsize/1048576; |
| 1871 | | unsigned long total = b.f_blocks*b.f_frsize/1048576; |
| 1872 | | ss << free << "/" << total << "MB";*/ |
| 1873 | | double free = (double)b.f_bfree * (double)b.f_bsize / 1048576.0; |
| 1874 | | double total = (double)b.f_blocks * (double)b.f_frsize / 1048576.0; |
| 1875 | | ss << (unsigned long)free << "/" << (unsigned long)total << "MB"; |
| 1870 | unsigned long long free = b.f_bfree * b.f_bsize / 1048576; |
| 1871 | unsigned long long total = b.f_blocks * b.f_frsize / 1048576; |
| 1872 | ss << free << "/" << total << "MB"; |
| 1876 | 1873 | ss >> df; |
| 1877 | 1874 | } else cout << "\033[0;34mGMENU2X:\033[0;31m statvfs failed with error '" << strerror(errno) << "'\033[0m" << endl; |
| 1878 | 1875 | return df; |
| src/menu.cpp |
| 364 | 364 | setLinkIndex(iLink+1); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) |
| 368 | |
| 367 | 369 | void Menu::linkUp() { |
| 368 | 370 | int l = iLink-gmenu2x->linkColumns; |
| 369 | 371 | if (l<0) { |
| 370 | | uint rows = (uint)ceil(sectionLinks()->size()/(double)gmenu2x->linkColumns); |
| 372 | unsigned int rows; |
| 373 | rows = DIV_ROUND_UP(sectionLinks()->size(), gmenu2x->linkColumns); |
| 371 | 374 | l = (rows*gmenu2x->linkColumns)+l; |
| 372 | 375 | if (l >= (int)sectionLinks()->size()) |
| 373 | 376 | l -= gmenu2x->linkColumns; |
| ... | ... | |
| 378 | 381 | void Menu::linkDown() { |
| 379 | 382 | uint l = iLink+gmenu2x->linkColumns; |
| 380 | 383 | if (l >= sectionLinks()->size()) { |
| 381 | | uint rows = (uint)ceil(sectionLinks()->size()/(double)gmenu2x->linkColumns); |
| 382 | | uint curCol = (uint)ceil((iLink+1)/(double)gmenu2x->linkColumns); |
| 384 | unsigned int rows, curCol; |
| 385 | rows = DIV_ROUND_UP(sectionLinks()->size(), gmenu2x->linkColumns); |
| 386 | curCol = DIV_ROUND_UP(iLink + 1, gmenu2x->linkColumns); |
| 383 | 387 | if (rows > curCol) |
| 384 | 388 | l = sectionLinks()->size()-1; |
| 385 | 389 | else |
| src/utilities.cpp |
| 123 | 123 | return *val; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | | float max (float a, float b) { |
| 127 | | return a>b ? a : b; |
| 128 | | } |
| 129 | | float min (float a, float b) { |
| 130 | | return a<b ? a : b; |
| 131 | | } |
| 132 | | float constrain (float x, float imin, float imax) { |
| 133 | | return min( imax, max(imin,x) ); |
| 134 | | } |
| 135 | | |
| 136 | 126 | bool split (vector<string> &vec, const string &str, const string &delim, bool destructive) { |
| 137 | 127 | vec.clear(); |
| 138 | 128 | |
| ... | ... | |
| 188 | 178 | |
| 189 | 179 | int intTransition(int from, int to, long tickStart, long duration, long tickNow) { |
| 190 | 180 | if (tickNow<0) tickNow = SDL_GetTicks(); |
| 191 | | float elapsed = (float)(tickNow-tickStart)/duration; |
| 181 | return constrain(((tickNow-tickStart) * (to-from)) / duration, from, to); |
| 192 | 182 | // elapsed increments |
| 193 | | return constrain(round(elapsed*(to-from)),from,to); |
| 194 | 183 | } |
| src/utilities.h |
| 71 | 71 | string evalStrConf (string val, string def); |
| 72 | 72 | string evalStrConf (string *val, string def); |
| 73 | 73 | |
| 74 | | float max (float a, float b); |
| 75 | | float min (float a, float b); |
| 76 | | float constrain (float x, float imin, float imax); |
| 77 | | |
| 78 | 74 | bool split (vector<string> &vec, const string &str, const string &delim, bool destructive=true); |
| 79 | 75 | |
| 80 | 76 | int intTransition(int from, int to, long int tickStart, long duration=500, long tickNow=-1); |
Download the corresponding diff file