Removing warnings on snow and tint by finaiized as a task in GCI

This commit is contained in:
Pere Pujal i Carabantes 2011-12-18 23:49:01 +00:00
parent 712e8295e9
commit a1ebbd5a14
2 changed files with 105 additions and 57 deletions

View file

@ -73,6 +73,29 @@ const char * snow_descs[snow_NUM_TOOLS] = {
gettext_noop("Click to add snow flakes to your picture."),
};
Uint32 snow_api_version(void);
int snow_init(magic_api * api);
int snow_get_tool_count(magic_api * api);
SDL_Surface * snow_get_icon(magic_api * api, int which);
char * snow_get_name(magic_api * api, int which);
char * snow_get_description(magic_api * api, int which);
static void do_snow(void * ptr,SDL_Surface * canvas, SDL_Surface * last, int which, int snowAmount);
void snow_drag(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * last, int ox, int oy, int x, int y,
SDL_Rect * update_rect);
void snow_click(magic_api * api, int which, int mode,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect);
void snow_release(magic_api * api, int which,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect);
void snow_shutdown(magic_api * api);
void snow_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b);
int snow_requires_colors(magic_api * api, int which);
void snow_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
void snow_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
int snow_modes(magic_api * api, int which);
Uint32 snow_api_version(void) { return(TP_MAGIC_API_VERSION); }
//Load sounds
@ -102,7 +125,7 @@ int snow_init(magic_api * api){
return(1);
}
int snow_get_tool_count(magic_api * api){
int snow_get_tool_count(magic_api * api ATTRIBUTE_UNUSED){
return(snow_NUM_TOOLS);
}
@ -114,12 +137,12 @@ SDL_Surface * snow_get_icon(magic_api * api, int which){
}
// Return our names, localized:
char * snow_get_name(magic_api * api, int which){
char * snow_get_name(magic_api * api ATTRIBUTE_UNUSED, int which){
return(strdup(gettext_noop(snow_names[which])));
}
// Return our descriptions, localized:
char * snow_get_description(magic_api * api, int which){
char * snow_get_description(magic_api * api ATTRIBUTE_UNUSED, int which){
return(strdup(gettext_noop(snow_descs[which])));
}
@ -157,16 +180,16 @@ static void do_snow(void * ptr,SDL_Surface * canvas, SDL_Surface * last, int whi
}
// Affect the canvas on drag:
void snow_drag(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * last, int ox, int oy, int x, int y,
SDL_Rect * update_rect){
void snow_drag(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
SDL_Surface * last ATTRIBUTE_UNUSED, int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
SDL_Rect * update_rect ATTRIBUTE_UNUSED){
// No-op
}
// Affect the canvas on click:
void snow_click(magic_api * api, int which, int mode,
void snow_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect){
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect){
update_rect->x = 0;
update_rect->y = 0;
update_rect->w = canvas->w;
@ -177,14 +200,14 @@ void snow_click(magic_api * api, int which, int mode,
}
// Affect the canvas on release:
void snow_release(magic_api * api, int which,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect)
void snow_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
{
}
// No setup happened:
void snow_shutdown(magic_api * api)
void snow_shutdown(magic_api * api ATTRIBUTE_UNUSED)
{
//Clean up sounds
int i;
@ -202,24 +225,24 @@ void snow_shutdown(magic_api * api)
}
// Record the color from Tux Paint:
void snow_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b)
void snow_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED)
{
}
// Use colors:
int snow_requires_colors(magic_api * api, int which)
int snow_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
{
return 0;
}
void snow_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas){
void snow_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED){
}
void snow_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
void snow_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
{
}
int snow_modes(magic_api * api, int which)
int snow_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
{
return(MODE_FULLSCREEN);
}

View file

@ -78,6 +78,34 @@ const char * tint_descs[tint_NUM_TOOLS][2] = {
gettext_noop("Click to turn your entire picture into white and a color you choose.")}
};
int tint_init(magic_api * api);
Uint32 tint_api_version(void);
int tint_get_tool_count(magic_api * api);
SDL_Surface * tint_get_icon(magic_api * api, int which);
char * tint_get_name(magic_api * api, int which);
char * tint_get_description(magic_api * api, int which, int mode);
static int tint_grey(Uint8 r1,Uint8 g1,Uint8 b1);
static void do_tint_pixel(void * ptr, int which,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y);
static void do_tint_full(void * ptr,SDL_Surface * canvas, SDL_Surface * last, int which);
static void do_tint_brush(void * ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
void tint_drag(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * last, int ox, int oy, int x, int y,
SDL_Rect * update_rect);
void tint_click(magic_api * api, int which, int mode,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect);
void tint_release(magic_api * api, int which,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect);
void tint_shutdown(magic_api * api);
void tint_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b);
int tint_requires_colors(magic_api * api, int which);
void tint_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
void tint_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
int tint_modes(magic_api * api, int which);
Uint32 tint_api_version(void) { return(TP_MAGIC_API_VERSION); }
//Load sounds
@ -92,7 +120,7 @@ int tint_init(magic_api * api){
return(1);
}
int tint_get_tool_count(magic_api * api){
int tint_get_tool_count(magic_api * api ATTRIBUTE_UNUSED){
return(tint_NUM_TOOLS);
}
@ -104,12 +132,12 @@ SDL_Surface * tint_get_icon(magic_api * api, int which){
}
// Return our names, localized:
char * tint_get_name(magic_api * api, int which){
char * tint_get_name(magic_api * api ATTRIBUTE_UNUSED, int which){
return(strdup(gettext_noop(tint_names[which])));
}
// Return our descriptions, localized:
char * tint_get_description(magic_api * api, int which, int mode){
char * tint_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode){
return(strdup(gettext_noop(tint_descs[which][mode-1])));
}
@ -119,38 +147,35 @@ static int tint_grey(Uint8 r1,Uint8 g1,Uint8 b1){
}
static void do_tint_pixel(void * ptr, int which,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y){
magic_api * api = (magic_api *) ptr;
Uint8 r,g,b;
float h,s,v;
SDL_GetRGB(api->getpixel(last, x, y), last->format, &r, &g, &b);
{
int greyValue = tint_grey(r,g,b);
if (which == TOOL_TINT){
api->rgbtohsv(tint_r, tint_g, tint_b, &h, &s, &v);
api->hsvtorgb(h, s, greyValue/255.0, &r, &g, &b);
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, r, g, b));
}else if (which == TOOL_THRESHOLD){
int thresholdValue = (tint_max-tint_min)/2;
if (greyValue < thresholdValue){
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, tint_r, tint_g, tint_b));
}else{
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, 255, 255, 255));
}
}
}
SDL_Surface * canvas, SDL_Surface * last,
int x, int y){
magic_api * api = (magic_api *) ptr;
Uint8 r,g,b;
float h,s,v;
SDL_GetRGB(api->getpixel(last, x, y), last->format, &r, &g, &b);
{
int greyValue = tint_grey(r,g,b);
if (which == TOOL_TINT){
api->rgbtohsv(tint_r, tint_g, tint_b, &h, &s, &v);
api->hsvtorgb(h, s, greyValue/255.0, &r, &g, &b);
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, r, g, b));
} else if (which == TOOL_THRESHOLD){
int thresholdValue = (tint_max-tint_min)/2;
if (greyValue < thresholdValue){
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, tint_r, tint_g, tint_b));
} else{
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, 255, 255, 255));
}
}
}
}
// Do the effect:
static void do_tint_full(void * ptr,SDL_Surface * canvas, SDL_Surface * last, int which){
magic_api * api = (magic_api *) ptr;
int x,y;
for (y = 0; y < last->h; y++){
for (x=0; x < last->w; x++){
@ -211,14 +236,14 @@ void tint_click(magic_api * api, int which, int mode,
}
// Affect the canvas on release:
void tint_release(magic_api * api, int which,
SDL_Surface * canvas, SDL_Surface * last,
int x, int y, SDL_Rect * update_rect)
void tint_release(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
{
}
// No setup happened:
void tint_shutdown(magic_api * api)
void tint_shutdown(magic_api * api ATTRIBUTE_UNUSED)
{
//Clean up sounds
int i;
@ -230,7 +255,7 @@ void tint_shutdown(magic_api * api)
}
// Record the color from Tux Paint:
void tint_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b)
void tint_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b)
{
tint_r = r;
tint_g = g;
@ -238,12 +263,12 @@ void tint_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b)
}
// Use colors:
int tint_requires_colors(magic_api * api, int which)
int tint_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
{
return 1;
}
void tint_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas){
void tint_switchin(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas){
int x,y;
Uint8 r1,g1,b1;
@ -264,11 +289,11 @@ void tint_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas){
}
}
void tint_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas)
void tint_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
{
}
int tint_modes(magic_api * api, int which)
int tint_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
{
return(MODE_FULLSCREEN|MODE_PAINT);
}