No right or middle clicking. Pop up a warning if they try to too much!

This commit is contained in:
William Kendrick 2005-01-14 10:04:19 +00:00
parent 28f9f83230
commit a954b48cf8
2 changed files with 178 additions and 88 deletions

View file

@ -103,6 +103,10 @@ http://www.newbreedsoftware.com/tuxpaint/
* Middle and right mouse buttons no longer do anything.
(No reason to teach kids that all the buttons do the same thing!)
* If middle or right mouse buttons are clicked too much, a pop-up
appears explaining to click the left button, and includes a small
picture of a mouse with the left button being 'clicked.'
* Thumbnail of selected image now shown on "Erase this image?"
confirmation pop-up.

View file

@ -2039,6 +2039,8 @@ static SDL_Surface * img_openlabels_open, * img_openlabels_erase,
static SDL_Surface * img_tux[NUM_TIP_TUX];
static SDL_Surface * img_mouse, * img_mouse_click;
#ifdef LOW_QUALITY_COLOR_SELECTOR
static SDL_Surface * img_paintcan;
#else
@ -2102,6 +2104,9 @@ typedef enum { Left, Right, Bottom, Top } an_edge;
static SDL_Event scrolltimer_event;
int non_left_click_count = 0;
static char * savedir;
typedef struct dirent2 {
@ -2203,6 +2208,7 @@ static void do_wait(void);
static void load_current(void);
static void save_current(void);
static char * get_fname(const char * const name);
static int do_prompt_image_flash(const char * const text, const char * const btn_yes, const char * const btn_no, SDL_Surface * img1, SDL_Surface * img2, SDL_Surface * img3, int animate);
static int do_prompt_image(const char * const text, const char * const btn_yes, const char * const btn_no, SDL_Surface * img1, SDL_Surface * img2, SDL_Surface * img3);
static int do_prompt(const char * const text, const char * const btn_yes, const char * const btn_no);
static void cleanup(void);
@ -2424,6 +2430,9 @@ int main(int argc, char * argv[])
#define PROMPT_ERASE_YES gettext_noop("Yes")
#define PROMPT_ERASE_NO gettext_noop("No")
#define PROMPT_TIP_LEFTCLICK_TXT gettext_noop("Remember to use the left mouse button!")
#define PROMPT_TIP_LEFTCLICK_YES gettext_noop("OK")
enum {
SHAPE_TOOL_MODE_STRETCH,
@ -3724,6 +3733,27 @@ static void mainloop(void)
update_screen_rect(&r_toolopt);
}
}
else if (event.type == SDL_MOUSEBUTTONDOWN &&
event.button.button >= 2 &&
event.button.button <= 3)
{
/* They're using the middle or right mouse buttons! */
non_left_click_count++;
if (non_left_click_count == 10 ||
non_left_click_count == 20 ||
(non_left_click_count % 50) == 0)
{
/* Pop up an informative animation: */
do_prompt_image_flash(PROMPT_TIP_LEFTCLICK_TXT,
PROMPT_TIP_LEFTCLICK_YES,
"",
img_mouse, img_mouse_click, NULL, 1);
}
}
else if (event.type == SDL_USEREVENT)
{
if (event.user.code == USEREVENT_TEXT_UPDATE)
@ -7352,6 +7382,10 @@ static void setup(int argc, char * argv[])
show_progress_bar();
}
img_mouse = loadimage(DATA_PREFIX "images/ui/mouse.png");
img_mouse_click = loadimage(DATA_PREFIX "images/ui/mouse_click.png");
show_progress_bar();
/* Create toolbox and selector labels: */
@ -11053,10 +11087,16 @@ static int do_prompt(const char * const text, const char * const btn_yes, const
static int do_prompt_image(const char * const text, const char * const btn_yes, const char * const btn_no, SDL_Surface * img1, SDL_Surface * img2, SDL_Surface * img3)
{
return(do_prompt_image_flash(text, btn_yes, btn_no, img1, img2, img3, 0));
}
static int do_prompt_image_flash(const char * const text, const char * const btn_yes, const char * const btn_no, SDL_Surface * img1, SDL_Surface * img2, SDL_Surface * img3, int animate)
{
SDL_Event event;
SDL_Rect dest;
int done, ans, w;
int done, ans, w, counter;
SDL_Color black = {0, 0, 0, 0};
SDLKey key;
SDLKey key_y, key_n;
@ -11177,7 +11217,7 @@ static int do_prompt_image(const char * const text, const char * const btn_yes,
1);
/* Draw the images (if any): */
/* Draw the images (if any, and if not animated): */
img_x = 457 + PROMPTOFFSETX - offset;
img_y = 100 + PROMPTOFFSETY + 4;
@ -11189,9 +11229,12 @@ static int do_prompt_image(const char * const text, const char * const btn_yes,
SDL_BlitSurface(img1, NULL, screen, &dest);
if (!animate)
img_y = img_y + img1->h + 4;
}
if (!animate)
{
if (img2 != NULL)
{
dest.x = img_x + (max_img_w - img2->w) / 2;
@ -11211,6 +11254,7 @@ static int do_prompt_image(const char * const text, const char * const btn_yes,
img_y = img_y + img3->h + 4; // unnecessary
}
}
/* Draw yes button: */
@ -11247,12 +11291,13 @@ static int do_prompt_image(const char * const text, const char * const btn_yes,
SDL_Flip(screen);
done = 0;
counter = 0;
ans = 0;
do
{
mySDL_WaitEvent(&event);
while (mySDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
ans = 0;
@ -11344,6 +11389,47 @@ static int do_prompt_image(const char * const text, const char * const btn_yes,
}
}
}
SDL_Delay(100);
if (animate)
{
counter++;
if (counter == 5)
{
dest.x = img_x + (max_img_w - img2->w) / 2;
dest.y = img_y;
SDL_BlitSurface(img2, NULL, screen, &dest);
SDL_Flip(screen);
}
else if (counter == 10)
{
if (img3 != NULL)
{
dest.x = img_x + (max_img_w - img3->w) / 2;
dest.y = img_y;
SDL_BlitSurface(img3, NULL, screen, &dest);
SDL_Flip(screen);
}
else
counter = 15;
}
if (counter == 15)
{
dest.x = img_x + (max_img_w - img1->w) / 2;
dest.y = img_y;
SDL_BlitSurface(img1, NULL, screen, &dest);
SDL_Flip(screen);
counter = 0;
}
}
}
while (!done);