Date:2010-05-01 13:20:47 (7 years 6 months ago)
Author:Lars C.
Commit:667fb05a35703ccee5a9493a7d2c33b83cb96bc8
Message:Kill float and double

Files: src/gmenu2x.cpp (1 diff)
src/menu.cpp (2 diffs)
src/utilities.cpp (2 diffs)
src/utilities.h (1 diff)

Change Details

src/gmenu2x.cpp
18671867
18681868    int ret = statvfs("/card/gmenu2x", &b);
18691869    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";
18761873        ss >> df;
18771874    } else cout << "\033[0;34mGMENU2X:\033[0;31m statvfs failed with error '" << strerror(errno) << "'\033[0m" << endl;
18781875    return df;
src/menu.cpp
364364        setLinkIndex(iLink+1);
365365}
366366
367#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
368
367369void Menu::linkUp() {
368370    int l = iLink-gmenu2x->linkColumns;
369371    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);
371374        l = (rows*gmenu2x->linkColumns)+l;
372375        if (l >= (int)sectionLinks()->size())
373376            l -= gmenu2x->linkColumns;
...... 
378381void Menu::linkDown() {
379382    uint l = iLink+gmenu2x->linkColumns;
380383    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);
383387        if (rows > curCol)
384388            l = sectionLinks()->size()-1;
385389        else
src/utilities.cpp
123123    return *val;
124124}
125125
126float max (float a, float b) {
127    return a>b ? a : b;
128}
129float min (float a, float b) {
130    return a<b ? a : b;
131}
132float constrain (float x, float imin, float imax) {
133    return min( imax, max(imin,x) );
134}
135
136126bool split (vector<string> &vec, const string &str, const string &delim, bool destructive) {
137127    vec.clear();
138128
...... 
188178
189179int intTransition(int from, int to, long tickStart, long duration, long tickNow) {
190180    if (tickNow<0) tickNow = SDL_GetTicks();
191    float elapsed = (float)(tickNow-tickStart)/duration;
181    return constrain(((tickNow-tickStart) * (to-from)) / duration, from, to);
192182    // elapsed increments
193    return constrain(round(elapsed*(to-from)),from,to);
194183}
src/utilities.h
7171string evalStrConf (string val, string def);
7272string evalStrConf (string *val, string def);
7373
74float max (float a, float b);
75float min (float a, float b);
76float constrain (float x, float imin, float imax);
77
7874bool split (vector<string> &vec, const string &str, const string &delim, bool destructive=true);
7975
8076int intTransition(int from, int to, long int tickStart, long duration=500, long tickNow=-1);

Archive Download the corresponding diff file



interactive