~ubuntu-branches/ubuntu/trusty/manaplus/trusty-proposed

« back to all changes in this revision

Viewing changes to src/gui/palette.cpp

  • Committer: Package Import Robot
  • Author(s): Patrick Matthäi, Andrei Karas, Patrick Matthäi
  • Date: 2013-05-27 09:14:03 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130527091403-4b1jceqok7g2v5on
Tags: 1.3.5.26-1
[ Andrei Karas ]
* Add new files to copyright file.
* Update homepage URL.

[ Patrick Matthäi ]
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
    gcn::Color(153, 0, 153)
50
50
};
51
51
 
52
 
/** Number of Elemets of RAINBOW_COLORS */
53
52
const int Palette::RAINBOW_COLOR_COUNT = 7;
54
53
 
55
54
Palette::Palette(const int size) :
66
65
    mInstances.erase(this);
67
66
}
68
67
 
69
 
const gcn::Color& Palette::getCharColor(const signed char c, bool &valid)
 
68
const gcn::Color& Palette::getCharColor(const signed char c, bool &valid) const
70
69
{
71
70
    const CharColors::const_iterator it = mCharColors.find(c);
72
71
    if (it != mCharColors.end())
79
78
    return BLACK;
80
79
}
81
80
 
82
 
int Palette::getIdByChar(const signed char c, bool &valid)
 
81
int Palette::getIdByChar(const signed char c, bool &valid) const
83
82
{
84
83
    const CharColors::const_iterator it = mCharColors.find(c);
85
84
    if (it != mCharColors.end())
102
101
{
103
102
    if (get_elapsed_time(mRainbowTime) > 5)
104
103
    {
105
 
        int pos, colIndex, colVal, delay, numOfColors;
106
104
        // For slower systems, advance can be greater than one (advance > 1
107
105
        // skips advance-1 steps). Should make gradient look the same
108
106
        // independent of the framerate.
111
109
 
112
110
        for (size_t i = 0, sz = mGradVector.size(); i < sz; i++)
113
111
        {
114
 
            if (!mGradVector[i])
 
112
            ColorElem *const elem = mGradVector[i];
 
113
            if (!elem)
115
114
                continue;
116
115
 
117
 
            delay = mGradVector[i]->delay;
 
116
            int delay = elem->delay;
118
117
 
119
 
            if (mGradVector[i]->grad == PULSE)
 
118
            if (elem->grad == PULSE)
120
119
                delay = delay / 20;
121
120
 
122
 
            numOfColors = (mGradVector[i]->grad == SPECTRUM ? 6 :
123
 
                           mGradVector[i]->grad == PULSE ? 127 :
124
 
                           RAINBOW_COLOR_COUNT);
125
 
 
126
 
            mGradVector[i]->gradientIndex =
127
 
                                    (mGradVector[i]->gradientIndex + advance) %
128
 
                                    (delay * numOfColors);
129
 
 
130
 
            pos = mGradVector[i]->gradientIndex % delay;
 
121
            const int numOfColors = (elem->grad == SPECTRUM ? 6 :
 
122
                elem->grad == PULSE ? 127 :
 
123
                RAINBOW_COLOR_COUNT);
 
124
 
 
125
            elem->gradientIndex = (elem->gradientIndex + advance)
 
126
                % (delay * numOfColors);
 
127
 
 
128
            const int gradIndex = elem->gradientIndex;
 
129
            const int pos = gradIndex % delay;
 
130
            int colIndex;
131
131
            if (delay)
132
 
                colIndex = mGradVector[i]->gradientIndex / delay;
 
132
                colIndex = gradIndex / delay;
133
133
            else
134
 
                colIndex = mGradVector[i]->gradientIndex;
 
134
                colIndex = gradIndex;
135
135
 
136
 
            ColorElem *const elem = mGradVector[i];
137
136
            gcn::Color &color = elem->color;
 
137
            int colVal;
138
138
 
139
139
            if (elem->grad == PULSE)
140
140
            {