indent blind.c
This commit is contained in:
parent
d62e1ec901
commit
5b76d99ae6
1 changed files with 127 additions and 117 deletions
|
|
@ -36,15 +36,19 @@ int BLIND_THICKNESS = 30;
|
||||||
int blind_side; /* 0 top, 1 left, 2 bottom, 3 right */
|
int blind_side; /* 0 top, 1 left, 2 bottom, 3 right */
|
||||||
|
|
||||||
static Uint8 blind_r, blind_g, blind_b, blind_light;
|
static Uint8 blind_r, blind_g, blind_b, blind_light;
|
||||||
enum blind_sides{
|
enum blind_sides
|
||||||
|
{
|
||||||
BLIND_SIDE_TOP,
|
BLIND_SIDE_TOP,
|
||||||
BLIND_SIDE_LEFT,
|
BLIND_SIDE_LEFT,
|
||||||
BLIND_SIDE_BOTTOM,
|
BLIND_SIDE_BOTTOM,
|
||||||
BLIND_SIDE_RIGHT};
|
BLIND_SIDE_RIGHT
|
||||||
|
};
|
||||||
|
|
||||||
enum blind_tools{
|
enum blind_tools
|
||||||
|
{
|
||||||
BLIND_TOOL_BLIND,
|
BLIND_TOOL_BLIND,
|
||||||
BLIND_NUMTOOLS};
|
BLIND_NUMTOOLS
|
||||||
|
};
|
||||||
|
|
||||||
Mix_Chunk *blind_snd;
|
Mix_Chunk *blind_snd;
|
||||||
|
|
||||||
|
|
@ -58,17 +62,13 @@ char * blind_get_name(magic_api * api, int which);
|
||||||
char *blind_get_description(magic_api * api, int which, int mode);
|
char *blind_get_description(magic_api * api, int which, int mode);
|
||||||
int blind_requires_colors(magic_api * api, int which);
|
int blind_requires_colors(magic_api * api, int which);
|
||||||
void blind_release(magic_api * api, int which,
|
void blind_release(magic_api * api, int which,
|
||||||
SDL_Surface * canvas, SDL_Surface * snapshot,
|
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y, SDL_Rect * update_rect);
|
||||||
int x, int y, SDL_Rect * update_rect);
|
|
||||||
void blind_shutdown(magic_api * api);
|
void blind_shutdown(magic_api * api);
|
||||||
void blind_paint_blind(void * ptr_to_api, int which_tool,
|
void blind_paint_blind(void *ptr_to_api, int which_tool, SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
||||||
SDL_Surface * canvas, SDL_Surface * snapshot, int x, int y);
|
|
||||||
void blind_drag(magic_api * api, int which, SDL_Surface * canvas,
|
void blind_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||||
SDL_Rect * update_rect);
|
|
||||||
void blind_click(magic_api * api, int which, int mode,
|
void blind_click(magic_api * api, int which, int mode,
|
||||||
SDL_Surface * canvas, SDL_Surface * last,
|
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||||
int x, int y, SDL_Rect * update_rect);
|
|
||||||
void blind_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
void blind_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||||
void blind_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
void blind_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||||
int blind_modes(magic_api * api, int which);
|
int blind_modes(magic_api * api, int which);
|
||||||
|
|
@ -106,8 +106,7 @@ SDL_Surface * blind_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
char fname[1024];
|
char fname[1024];
|
||||||
|
|
||||||
snprintf(fname, sizeof(fname), "%s/images/magic/blind.png",
|
snprintf(fname, sizeof(fname), "%s/images/magic/blind.png", api->data_directory);
|
||||||
api->data_directory);
|
|
||||||
|
|
||||||
return (IMG_Load(fname));
|
return (IMG_Load(fname));
|
||||||
}
|
}
|
||||||
|
|
@ -119,7 +118,9 @@ char * blind_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUS
|
||||||
|
|
||||||
char *blind_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
char *blind_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
return strdup(gettext_noop("Click towards the edge of your picture to pull window blinds over it. Move perpendicularly to open or close the blinds."));
|
return
|
||||||
|
strdup(gettext_noop
|
||||||
|
("Click towards the edge of your picture to pull window blinds over it. Move perpendicularly to open or close the blinds."));
|
||||||
}
|
}
|
||||||
|
|
||||||
int blind_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
int blind_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||||
|
|
@ -145,7 +146,9 @@ void blind_paint_blind(void * ptr_to_api, int which_tool ATTRIBUTE_UNUSED,
|
||||||
{
|
{
|
||||||
magic_api *api = (magic_api *) ptr_to_api;
|
magic_api *api = (magic_api *) ptr_to_api;
|
||||||
|
|
||||||
api->putpixel(canvas, x, y, SDL_MapRGB(canvas->format, (blind_r + blind_light) / 2, (blind_g + blind_light) / 2, (blind_b + blind_light) / 2));
|
api->putpixel(canvas, x, y,
|
||||||
|
SDL_MapRGB(canvas->format, (blind_r + blind_light) / 2, (blind_g + blind_light) / 2,
|
||||||
|
(blind_b + blind_light) / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* void blind_do_blind(void * ptr_to_api, int which_tool,
|
/* void blind_do_blind(void * ptr_to_api, int which_tool,
|
||||||
|
|
@ -159,8 +162,7 @@ void blind_paint_blind(void * ptr_to_api, int which_tool ATTRIBUTE_UNUSED,
|
||||||
|
|
||||||
*/
|
*/
|
||||||
void blind_drag(magic_api * api, int which, SDL_Surface * canvas,
|
void blind_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
SDL_Surface * snapshot, int ox, int oy, int x, int y,
|
SDL_Surface * snapshot, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||||
SDL_Rect * update_rect)
|
|
||||||
{
|
{
|
||||||
int opaque;
|
int opaque;
|
||||||
|
|
||||||
|
|
@ -168,6 +170,7 @@ void blind_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
switch (blind_side)
|
switch (blind_side)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
case BLIND_SIDE_TOP:
|
case BLIND_SIDE_TOP:
|
||||||
opaque = max((x * BLIND_THICKNESS) / canvas->w + 2, 2);
|
opaque = max((x * BLIND_THICKNESS) / canvas->w + 2, 2);
|
||||||
for (i = y; i >= 0; i -= BLIND_THICKNESS)
|
for (i = y; i >= 0; i -= BLIND_THICKNESS)
|
||||||
|
|
@ -266,32 +269,39 @@ void blind_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||||
}
|
}
|
||||||
|
|
||||||
void blind_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
void blind_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||||
SDL_Surface * canvas, SDL_Surface * last,
|
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect)
|
||||||
int x, int y, SDL_Rect * update_rect)
|
|
||||||
{
|
{
|
||||||
if (y < canvas->h / 2)
|
if (y < canvas->h / 2)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (x < y) blind_side = 1; /* left */
|
if (x < y)
|
||||||
else if (canvas->w - x < y) blind_side = 3; /* right */
|
blind_side = 1; /* left */
|
||||||
else blind_side = 0; /* top */
|
else if (canvas->w - x < y)
|
||||||
|
blind_side = 3; /* right */
|
||||||
|
else
|
||||||
|
blind_side = 0; /* top */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (x < canvas->h - y) blind_side = 1; /* left */
|
if (x < canvas->h - y)
|
||||||
else if (canvas->w - x < canvas->h - y) blind_side = 3; /* right */
|
blind_side = 1; /* left */
|
||||||
else blind_side = 2; /* bottom */
|
else if (canvas->w - x < canvas->h - y)
|
||||||
|
blind_side = 3; /* right */
|
||||||
|
else
|
||||||
|
blind_side = 2; /* bottom */
|
||||||
}
|
}
|
||||||
|
|
||||||
blind_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
blind_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void blind_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
void blind_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||||
|
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void blind_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
void blind_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||||
|
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue