indent mirror_flip.c
This commit is contained in:
parent
800d8af3b7
commit
18be491419
1 changed files with 77 additions and 95 deletions
|
|
@ -35,31 +35,25 @@
|
||||||
|
|
||||||
/* What tools we contain: */
|
/* What tools we contain: */
|
||||||
|
|
||||||
enum {
|
enum
|
||||||
|
{
|
||||||
TOOL_MIRROR,
|
TOOL_MIRROR,
|
||||||
TOOL_FLIP,
|
TOOL_FLIP,
|
||||||
NUM_TOOLS
|
NUM_TOOLS
|
||||||
};
|
};
|
||||||
|
|
||||||
static Mix_Chunk * snd_effects[NUM_TOOLS];
|
static Mix_Chunk *snd_effects[NUM_TOOLS];
|
||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
int mirror_flip_init(magic_api *);
|
int mirror_flip_init(magic_api *);
|
||||||
Uint32 mirror_flip_api_version(void);
|
Uint32 mirror_flip_api_version(void);
|
||||||
int mirror_flip_get_tool_count(magic_api *);
|
int mirror_flip_get_tool_count(magic_api *);
|
||||||
SDL_Surface * mirror_flip_get_icon(magic_api *, int);
|
SDL_Surface *mirror_flip_get_icon(magic_api *, int);
|
||||||
char * mirror_flip_get_name(magic_api *, int);
|
char *mirror_flip_get_name(magic_api *, int);
|
||||||
char * mirror_flip_get_description(magic_api *, int, int);
|
char *mirror_flip_get_description(magic_api *, int, int);
|
||||||
void mirror_flip_drag(magic_api *, int, SDL_Surface *,
|
void mirror_flip_drag(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, int, int, SDL_Rect *);
|
||||||
SDL_Surface *, int, int, int, int,
|
void mirror_flip_release(magic_api *, int, SDL_Surface *, SDL_Surface *, int, int, int, int, SDL_Rect *);
|
||||||
SDL_Rect *);
|
void mirror_flip_click(magic_api *, int, int, SDL_Surface *, SDL_Surface *, int, int, SDL_Rect *);
|
||||||
void mirror_flip_release(magic_api *, int, SDL_Surface *,
|
|
||||||
SDL_Surface *, int, int, int, int,
|
|
||||||
SDL_Rect *);
|
|
||||||
void mirror_flip_click(magic_api *, int, int,
|
|
||||||
SDL_Surface *, SDL_Surface *,
|
|
||||||
int, int,
|
|
||||||
SDL_Rect *);
|
|
||||||
void mirror_flip_shutdown(magic_api *);
|
void mirror_flip_shutdown(magic_api *);
|
||||||
void mirror_flip_set_color(magic_api *, Uint8, Uint8, Uint8);
|
void mirror_flip_set_color(magic_api *, Uint8, Uint8, Uint8);
|
||||||
int mirror_flip_requires_colors(magic_api *, int);
|
int mirror_flip_requires_colors(magic_api *, int);
|
||||||
|
|
@ -72,134 +66,127 @@ int mirror_flip_init(magic_api * api)
|
||||||
{
|
{
|
||||||
char fname[1024];
|
char fname[1024];
|
||||||
|
|
||||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/mirror.wav",
|
snprintf(fname, sizeof(fname), "%s/sounds/magic/mirror.wav", api->data_directory);
|
||||||
api->data_directory);
|
|
||||||
snd_effects[TOOL_MIRROR] = Mix_LoadWAV(fname);
|
snd_effects[TOOL_MIRROR] = Mix_LoadWAV(fname);
|
||||||
|
|
||||||
snprintf(fname, sizeof(fname), "%s/sounds/magic/flip.wav",
|
snprintf(fname, sizeof(fname), "%s/sounds/magic/flip.wav", api->data_directory);
|
||||||
api->data_directory);
|
|
||||||
snd_effects[TOOL_FLIP] = Mix_LoadWAV(fname);
|
snd_effects[TOOL_FLIP] = Mix_LoadWAV(fname);
|
||||||
|
|
||||||
return(1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint32 mirror_flip_api_version(void) { return(TP_MAGIC_API_VERSION); }
|
Uint32 mirror_flip_api_version(void)
|
||||||
|
{
|
||||||
|
return (TP_MAGIC_API_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
// We have multiple tools:
|
// We have multiple tools:
|
||||||
int mirror_flip_get_tool_count(magic_api * api ATTRIBUTE_UNUSED)
|
int mirror_flip_get_tool_count(magic_api * api ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
return(NUM_TOOLS);
|
return (NUM_TOOLS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load our icons:
|
// Load our icons:
|
||||||
SDL_Surface * mirror_flip_get_icon(magic_api * api, int which)
|
SDL_Surface *mirror_flip_get_icon(magic_api * api, int which)
|
||||||
{
|
{
|
||||||
char fname[1024];
|
char fname[1024];
|
||||||
|
|
||||||
if (which == TOOL_MIRROR)
|
if (which == TOOL_MIRROR)
|
||||||
{
|
{
|
||||||
snprintf(fname, sizeof(fname), "%s/images/magic/mirror.png",
|
snprintf(fname, sizeof(fname), "%s/images/magic/mirror.png", api->data_directory);
|
||||||
api->data_directory);
|
}
|
||||||
}
|
|
||||||
else if (which == TOOL_FLIP)
|
else if (which == TOOL_FLIP)
|
||||||
{
|
{
|
||||||
snprintf(fname, sizeof(fname), "%s/images/magic/flip.png",
|
snprintf(fname, sizeof(fname), "%s/images/magic/flip.png", api->data_directory);
|
||||||
api->data_directory);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return(IMG_Load(fname));
|
return (IMG_Load(fname));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return our names, localized:
|
// Return our names, localized:
|
||||||
char * mirror_flip_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
char *mirror_flip_get_name(magic_api * api ATTRIBUTE_UNUSED, int which)
|
||||||
{
|
{
|
||||||
if (which == TOOL_MIRROR)
|
if (which == TOOL_MIRROR)
|
||||||
return(strdup(gettext_noop("Mirror")));
|
return (strdup(gettext_noop("Mirror")));
|
||||||
else if (which == TOOL_FLIP)
|
else if (which == TOOL_FLIP)
|
||||||
return(strdup(gettext_noop("Flip")));
|
return (strdup(gettext_noop("Flip")));
|
||||||
|
|
||||||
return(NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return our descriptions, localized:
|
// Return our descriptions, localized:
|
||||||
char * mirror_flip_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
char *mirror_flip_get_description(magic_api * api ATTRIBUTE_UNUSED, int which, int mode ATTRIBUTE_UNUSED)
|
||||||
int which, int mode ATTRIBUTE_UNUSED)
|
|
||||||
{
|
{
|
||||||
if (which == TOOL_MIRROR)
|
if (which == TOOL_MIRROR)
|
||||||
return(strdup(
|
return (strdup(gettext_noop("Click to make a mirror image.")));
|
||||||
gettext_noop("Click to make a mirror image.")));
|
|
||||||
else
|
else
|
||||||
return(strdup(
|
return (strdup(gettext_noop("Click to flip the picture upside-down.")));
|
||||||
gettext_noop("Click to flip the picture upside-down.")));
|
|
||||||
|
|
||||||
return(NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We affect the whole canvas, so only do things on click, not drag:
|
// We affect the whole canvas, so only do things on click, not drag:
|
||||||
void mirror_flip_drag(magic_api * api ATTRIBUTE_UNUSED,
|
void mirror_flip_drag(magic_api * api ATTRIBUTE_UNUSED,
|
||||||
int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED,
|
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED,
|
||||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
|
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
|
||||||
{
|
{
|
||||||
// No-op
|
// No-op
|
||||||
}
|
}
|
||||||
|
|
||||||
void mirror_flip_release(magic_api * api ATTRIBUTE_UNUSED,
|
void mirror_flip_release(magic_api * api ATTRIBUTE_UNUSED,
|
||||||
int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED,
|
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED,
|
||||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
|
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
|
||||||
{
|
{
|
||||||
// No-op
|
// No-op
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affect the canvas on click:
|
// Affect the canvas on click:
|
||||||
void mirror_flip_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
void mirror_flip_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||||
SDL_Surface * canvas, SDL_Surface * last,
|
SDL_Surface * canvas, SDL_Surface * last,
|
||||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
|
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect)
|
||||||
SDL_Rect * update_rect)
|
|
||||||
{
|
{
|
||||||
int xx, yy;
|
int xx, yy;
|
||||||
SDL_Rect src, dest;
|
SDL_Rect src, dest;
|
||||||
|
|
||||||
if (which == TOOL_MIRROR)
|
if (which == TOOL_MIRROR)
|
||||||
{
|
|
||||||
for (xx = 0; xx < canvas->w; xx++)
|
|
||||||
{
|
{
|
||||||
src.x = xx;
|
for (xx = 0; xx < canvas->w; xx++)
|
||||||
src.y = 0;
|
{
|
||||||
src.w = 1;
|
src.x = xx;
|
||||||
src.h = canvas->h;
|
src.y = 0;
|
||||||
|
src.w = 1;
|
||||||
|
src.h = canvas->h;
|
||||||
|
|
||||||
dest.x = canvas->w - xx - 1;
|
dest.x = canvas->w - xx - 1;
|
||||||
dest.y = 0;
|
dest.y = 0;
|
||||||
|
|
||||||
SDL_BlitSurface(last, &src, canvas, &dest);
|
SDL_BlitSurface(last, &src, canvas, &dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
api->special_notify(SPECIAL_MIRROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
api->special_notify(SPECIAL_MIRROR);
|
|
||||||
}
|
|
||||||
else if (which == TOOL_FLIP)
|
else if (which == TOOL_FLIP)
|
||||||
{
|
|
||||||
for (yy = 0; yy < canvas->h; yy++)
|
|
||||||
{
|
{
|
||||||
src.x = 0;
|
for (yy = 0; yy < canvas->h; yy++)
|
||||||
src.y = yy;
|
{
|
||||||
src.w = canvas->w;
|
src.x = 0;
|
||||||
src.h = 1;
|
src.y = yy;
|
||||||
|
src.w = canvas->w;
|
||||||
|
src.h = 1;
|
||||||
|
|
||||||
dest.x = 0;
|
dest.x = 0;
|
||||||
dest.y = canvas->h - yy - 1;
|
dest.y = canvas->h - yy - 1;
|
||||||
|
|
||||||
SDL_BlitSurface(last, &src, canvas, &dest);
|
SDL_BlitSurface(last, &src, canvas, &dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
api->special_notify(SPECIAL_FLIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
api->special_notify(SPECIAL_FLIP);
|
|
||||||
}
|
|
||||||
|
|
||||||
update_rect->x = 0;
|
update_rect->x = 0;
|
||||||
update_rect->y = 0;
|
update_rect->y = 0;
|
||||||
update_rect->w = canvas->w;
|
update_rect->w = canvas->w;
|
||||||
|
|
@ -218,33 +205,28 @@ void mirror_flip_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't use colors:
|
// We don't use colors:
|
||||||
void mirror_flip_set_color(magic_api * api ATTRIBUTE_UNUSED,
|
void mirror_flip_set_color(magic_api * api ATTRIBUTE_UNUSED,
|
||||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED,
|
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED, Uint8 b ATTRIBUTE_UNUSED)
|
||||||
Uint8 b ATTRIBUTE_UNUSED)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't use colors:
|
// We don't use colors:
|
||||||
int mirror_flip_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
int mirror_flip_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||||
int which ATTRIBUTE_UNUSED)
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mirror_flip_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
void mirror_flip_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void mirror_flip_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
void mirror_flip_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int mirror_flip_modes(magic_api * api ATTRIBUTE_UNUSED,
|
int mirror_flip_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||||
int which ATTRIBUTE_UNUSED)
|
|
||||||
{
|
{
|
||||||
return(MODE_FULLSCREEN);
|
return (MODE_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue