Added italic sound effects.

Only update font if in text tool.
This commit is contained in:
William Kendrick 2005-01-08 07:50:10 +00:00
parent 2e588634bf
commit 67a2fdcaf1
2 changed files with 58 additions and 22 deletions

View file

@ -4,11 +4,11 @@
For Tux Paint For Tux Paint
List of sound effects. List of sound effects.
Copyright (c) 2002 by Bill Kendrick Copyright (c) 2005 by Bill Kendrick
bill@newbreedsoftware.com bill@newbreedsoftware.com
http://www.newbreedsoftware.com/tuxpaint/ http://www.newbreedsoftware.com/tuxpaint/
June 15, 2002 - December 12, 2004 June 15, 2002 - January 7, 2005
*/ */
@ -50,9 +50,12 @@ enum {
SND_TINT, /* Magic tint */ SND_TINT, /* Magic tint */
SND_CARTOON, /* Magic cartoon */ SND_CARTOON, /* Magic cartoon */
SND_KEYCLICK, /* Text tool keyboard click feedback */ SND_KEYCLICK, /* Text tool keyboard click feedback */
SND_KEYCLICKRING, /* Text tool keyboard click feedback with bell ring */
SND_RETURN, /* Text tool carriage return sound */ SND_RETURN, /* Text tool carriage return sound */
SND_SHRINK, /* Stamp shrink */ SND_SHRINK, /* Stamp shrink */
SND_GROW, /* Stamp grow */ SND_GROW, /* Stamp grow */
SND_ITALIC_ON, /* Italic on */
SND_ITALIC_OFF, /* Italic off */
NUM_SOUNDS NUM_SOUNDS
}; };
@ -94,8 +97,11 @@ const char * const sound_fnames[NUM_SOUNDS] = {
DATA_PREFIX "sounds/tint.wav", DATA_PREFIX "sounds/tint.wav",
DATA_PREFIX "sounds/cartoon.wav", DATA_PREFIX "sounds/cartoon.wav",
DATA_PREFIX "sounds/keyclick.wav", DATA_PREFIX "sounds/keyclick.wav",
DATA_PREFIX "sounds/typewriterbell.wav",
DATA_PREFIX "sounds/return.wav", DATA_PREFIX "sounds/return.wav",
DATA_PREFIX "sounds/shrink.wav", DATA_PREFIX "sounds/shrink.wav",
DATA_PREFIX "sounds/grow.wav" DATA_PREFIX "sounds/grow.wav",
DATA_PREFIX "sounds/italic_on.wav",
DATA_PREFIX "sounds/italic_off.wav"
}; };

View file

@ -22,12 +22,12 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt) (See COPYING.txt)
June 14, 2002 - January 6, 2005 June 14, 2002 - January 7, 2005
*/ */
#define VER_VERSION "0.9.15" #define VER_VERSION "0.9.15"
#define VER_DATE "2005-01-06" #define VER_DATE "2005-01-07"
//#define VIDEO_BPP 15 // saves memory //#define VIDEO_BPP 15 // saves memory
@ -2632,7 +2632,7 @@ static void mainloop(void)
{ {
texttool_len--; texttool_len--;
texttool_str[texttool_len] = '\0'; texttool_str[texttool_len] = '\0';
playsound(0, SND_KEYCLICK, 1); playsound(0, SND_KEYCLICK, 0);
do_render_cur_text(0); do_render_cur_text(0);
} }
@ -2653,10 +2653,23 @@ static void mainloop(void)
playsound(0, SND_RETURN, 1); playsound(0, SND_RETURN, 1);
} }
else if (key_down == SDLK_TAB)
{
if (texttool_len > 0)
{
rec_undo_buffer();
do_render_cur_text(1);
cursor_x = min(cursor_x + cursor_textwidth,
canvas->w);
texttool_len = 0;
cursor_textwidth = 0;
}
}
else if (isprint(key_unicode)) else if (isprint(key_unicode))
{ {
if (texttool_len < sizeof(texttool_str) - MAX_UTF8_CHAR_LENGTH) if (texttool_len < sizeof(texttool_str) - MAX_UTF8_CHAR_LENGTH)
{ {
int old_cursor_textwidth = cursor_textwidth;
#ifdef DEBUG #ifdef DEBUG
printf(" key = %c\n" printf(" key = %c\n"
"unicode = %c (%d)\n\n", "unicode = %c (%d)\n\n",
@ -2666,8 +2679,18 @@ static void mainloop(void)
texttool_str[texttool_len++] = key_unicode; texttool_str[texttool_len++] = key_unicode;
texttool_str[texttool_len] = '\0'; texttool_str[texttool_len] = '\0';
playsound(0, SND_KEYCLICK, 1);
do_render_cur_text(0); do_render_cur_text(0);
if (cursor_x + old_cursor_textwidth <= canvas->w - 50 &&
cursor_x + cursor_textwidth > canvas->w - 50)
{
playsound(0, SND_KEYCLICKRING, 1);
}
else
{
playsound(0, SND_KEYCLICK, 0);
}
} }
} }
} }
@ -3107,12 +3130,12 @@ static void mainloop(void)
if (text_state & TTF_STYLE_ITALIC) if (text_state & TTF_STYLE_ITALIC)
{ {
text_state &= ~TTF_STYLE_ITALIC; text_state &= ~TTF_STYLE_ITALIC;
control_sound = SND_CHALK; control_sound = SND_ITALIC_ON;
} }
else else
{ {
text_state |= TTF_STYLE_ITALIC; text_state |= TTF_STYLE_ITALIC;
control_sound = SND_SMUDGE; control_sound = SND_ITALIC_OFF;
} }
} }
else else
@ -3133,19 +3156,24 @@ static void mainloop(void)
if (control_sound != -1) if (control_sound != -1)
{ {
playsound(0, control_sound, 0); playsound(0, control_sound, 0);
// need to invalidate all the cached user fonts, causing reload on demand
int i;
for (i = 0; i < num_font_families; i++) if (cur_tool == TOOL_TEXT)
{ {
if (user_font_families[i] && user_font_families[i]->handle) // need to invalidate all the cached user fonts, causing reload on demand
{ int i;
TTF_CloseFont(user_font_families[i]->handle); for (i = 0; i < num_font_families; i++)
user_font_families[i]->handle = NULL; {
} if (user_font_families[i] && user_font_families[i]->handle)
} {
// FIXME: is setting do_draw enough? TTF_CloseFont(user_font_families[i]->handle);
draw_fonts(); user_font_families[i]->handle = NULL;
update_screen_rect(&r_toolopt); }
}
// FIXME: is setting do_draw enough?
draw_fonts();
update_screen_rect(&r_toolopt);
}
} }
} }
} }
@ -7969,6 +7997,8 @@ static void draw_fonts(void)
SDL_Color black = {0, 0, 0, 0}; SDL_Color black = {0, 0, 0, 0};
printf("Redrawing fonts\n");
/* Draw the title: */ /* Draw the title: */
draw_image_title(TITLE_LETTERS, r_ttoolopt); draw_image_title(TITLE_LETTERS, r_ttoolopt);