Subversion Repositories tpanel

Rev

Rev 59 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 59 Rev 108
Line 56... Line 56...
56
            return splitColors(pd);
56
            return splitColors(pd);
57
 
57
 
58
        return TColor::COLOR_T();
58
        return TColor::COLOR_T();
59
    }
59
    }
60
 
60
 
-
 
61
    // Check if we've an index number
-
 
62
    if (color.length() <= 2 && isdigit(color[0]))
-
 
63
    {
-
 
64
        int idx = atoi(color.c_str());
-
 
65
 
-
 
66
        if (idx < 0 || idx > 88)
-
 
67
            return TColor::COLOR_T();
-
 
68
 
-
 
69
        PDATA_T pd = mPalette->findColor(idx);
-
 
70
 
-
 
71
        if (!pd.name.empty())
-
 
72
            return splitColors(pd);
-
 
73
 
-
 
74
        return TColor::COLOR_T();
-
 
75
    }
-
 
76
 
61
    TColor::COLOR_T ct;
77
    TColor::COLOR_T ct;
62
    ct.red = (int)strtol(color.substr(pos+1, 2).c_str(), NULL, 16);
78
    ct.red = (int)strtol(color.substr(pos+1, 2).c_str(), NULL, 16);
63
    ct.green = (int)strtol(color.substr(pos+3, 2).c_str(), NULL, 16);
79
    ct.green = (int)strtol(color.substr(pos+3, 2).c_str(), NULL, 16);
64
    ct.blue = (int)strtol(color.substr(pos+5, 2).c_str(), NULL, 16);
80
    ct.blue = (int)strtol(color.substr(pos+5, 2).c_str(), NULL, 16);
65
 
81
 
Line 246... Line 262...
246
    }
262
    }
247
 
263
 
248
    return colRange;
264
    return colRange;
249
}
265
}
250
 
266
 
-
 
267
bool TColor::isValidAMXcolor(const string& color)
-
 
268
{
-
 
269
    DECL_TRACER("TColor::isValidAMXcolor(const string& color)");
-
 
270
 
-
 
271
    if (color.empty())
-
 
272
        return false;
-
 
273
 
-
 
274
    size_t pos = color.find('#');
-
 
275
 
-
 
276
    if (pos == string::npos)
-
 
277
    {
-
 
278
        if (!mPalette)
-
 
279
        {
-
 
280
            MSG_ERROR("No palette was set! First set a palette to be able to get any color!");
-
 
281
            return false;
-
 
282
        }
-
 
283
 
-
 
284
        PDATA_T pd = mPalette->findColor(color);
-
 
285
 
-
 
286
        if (!pd.name.empty())
-
 
287
            return true;
-
 
288
 
-
 
289
        return false;
-
 
290
    }
-
 
291
 
-
 
292
    // Check if we've an index number
-
 
293
    if (color.length() <= 2 && isdigit(color[0]))
-
 
294
    {
-
 
295
        int idx = atoi(color.c_str());
-
 
296
 
-
 
297
        if (idx < 0 || idx > 88)
-
 
298
            return false;
-
 
299
 
-
 
300
        return true;
-
 
301
    }
-
 
302
 
-
 
303
    if (color.length() >= 7)    // #RRGGBBAA
-
 
304
        return true;
-
 
305
 
-
 
306
    return false;
-
 
307
}
-
 
308
 
251
int TColor::setAlpha(ulong color, int alpha)
309
int TColor::setAlpha(ulong color, int alpha)
252
{
310
{
253
    DECL_TRACER("TColor::setAlpha(ulong color, int alpha)");
311
    DECL_TRACER("TColor::setAlpha(ulong color, int alpha)");
254
 
312
 
255
    if (alpha > 0x00ff)
313
    if (alpha > 0x00ff)