diff options
author | Nils Wallménius <nils@rockbox.org> | 2007-08-06 13:08:36 +0000 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2007-08-06 13:08:36 +0000 |
commit | 5b76936a44de3c7ecd568300f26b5e6421901285 (patch) | |
tree | 504d9cf371d8f64c70a7bb40469a3a6f05a1b7cd /apps/gui/yesno.c | |
parent | d755c283caef258ae5d81278d324f907fcf402c8 (diff) | |
download | rockbox-5b76936a44de3c7ecd568300f26b5e6421901285.tar.gz rockbox-5b76936a44de3c7ecd568300f26b5e6421901285.zip |
Accept FS#6159 'Add voice to roughly 100 splash screens and yes-no menus' by Stephane Doyon with some minor tweaks by me. Rerun 'configure' and do a 'make clean' before rebuilding your voice files.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14213 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/yesno.c')
-rw-r--r-- | apps/gui/yesno.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/apps/gui/yesno.c b/apps/gui/yesno.c index b689ad923b..69912637f4 100644 --- a/apps/gui/yesno.c +++ b/apps/gui/yesno.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include "misc.h" | 23 | #include "misc.h" |
24 | #include "lang.h" | 24 | #include "lang.h" |
25 | #include "action.h" | 25 | #include "action.h" |
26 | #include "talk.h" | ||
26 | 27 | ||
27 | /* | 28 | /* |
28 | * Initializes the yesno asker | 29 | * Initializes the yesno asker |
@@ -97,7 +98,28 @@ static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result) | |||
97 | gui_textarea_put_message(yn->display, message, 0); | 98 | gui_textarea_put_message(yn->display, message, 0); |
98 | return(true); | 99 | return(true); |
99 | } | 100 | } |
101 | |||
100 | #include "debug.h" | 102 | #include "debug.h" |
103 | |||
104 | /* Processes a text_message whose lines may be virtual pointers | ||
105 | representing language / voicefont IDs (see settings.h). Copies out | ||
106 | the IDs to the ids array, which is of length maxlen, and replaces | ||
107 | the pointers in the text_message with the actual language strings. | ||
108 | The ids array is terminated with the TALK_FINAL_ID sentinel | ||
109 | element. */ | ||
110 | static void extract_talk_ids(struct text_message *m, long *ids, int maxlen) | ||
111 | { | ||
112 | int line, i=0; | ||
113 | if(m) | ||
114 | for(line=0; line<m->nb_lines; line++) { | ||
115 | long id = P2ID((unsigned char *)m->message_lines[line]); | ||
116 | if(id>=0 && i<maxlen-1) | ||
117 | ids[i++] = id; | ||
118 | m->message_lines[line] = (char *)P2STR((unsigned char *)m->message_lines[line]); | ||
119 | } | ||
120 | ids[i] = TALK_FINAL_ID; | ||
121 | } | ||
122 | |||
101 | enum yesno_res gui_syncyesno_run(struct text_message * main_message, | 123 | enum yesno_res gui_syncyesno_run(struct text_message * main_message, |
102 | struct text_message * yes_message, | 124 | struct text_message * yes_message, |
103 | struct text_message * no_message) | 125 | struct text_message * no_message) |
@@ -107,6 +129,13 @@ enum yesno_res gui_syncyesno_run(struct text_message * main_message, | |||
107 | int result=-1; | 129 | int result=-1; |
108 | bool result_displayed; | 130 | bool result_displayed; |
109 | struct gui_yesno yn[NB_SCREENS]; | 131 | struct gui_yesno yn[NB_SCREENS]; |
132 | long voice_ids[5]; | ||
133 | long talked_tick = 0; | ||
134 | /* The text messages may contain virtual pointers to IDs (see | ||
135 | settings.h) instead of plain strings. Copy the IDs out so we | ||
136 | can speak them, and unwrap the actual language strings. */ | ||
137 | extract_talk_ids(main_message, voice_ids, | ||
138 | sizeof(voice_ids)/sizeof(voice_ids[0])); | ||
110 | FOR_NB_SCREENS(i) | 139 | FOR_NB_SCREENS(i) |
111 | { | 140 | { |
112 | gui_yesno_init(&(yn[i]), main_message, yes_message, no_message); | 141 | gui_yesno_init(&(yn[i]), main_message, yes_message, no_message); |
@@ -115,7 +144,14 @@ enum yesno_res gui_syncyesno_run(struct text_message * main_message, | |||
115 | } | 144 | } |
116 | while (result==-1) | 145 | while (result==-1) |
117 | { | 146 | { |
118 | button = get_action(CONTEXT_YESNOSCREEN,TIMEOUT_BLOCK); | 147 | /* Repeat the question every 5secs (more or less) */ |
148 | if (talk_menus_enabled() | ||
149 | && (talked_tick==0 || TIME_AFTER(current_tick, talked_tick+HZ*5))) | ||
150 | { | ||
151 | talked_tick = current_tick; | ||
152 | talk_idarray(voice_ids, false); | ||
153 | } | ||
154 | button = get_action(CONTEXT_YESNOSCREEN, HZ*5); | ||
119 | switch (button) | 155 | switch (button) |
120 | { | 156 | { |
121 | case ACTION_YESNO_ACCEPT: | 157 | case ACTION_YESNO_ACCEPT: |
@@ -133,6 +169,13 @@ enum yesno_res gui_syncyesno_run(struct text_message * main_message, | |||
133 | } | 169 | } |
134 | FOR_NB_SCREENS(i) | 170 | FOR_NB_SCREENS(i) |
135 | result_displayed=gui_yesno_draw_result(&(yn[i]), result); | 171 | result_displayed=gui_yesno_draw_result(&(yn[i]), result); |
172 | extract_talk_ids((result == YESNO_YES) ? yes_message : no_message, | ||
173 | voice_ids, sizeof(voice_ids)/sizeof(voice_ids[0])); | ||
174 | if (talk_menus_enabled()) | ||
175 | { | ||
176 | talk_idarray(voice_ids, false); | ||
177 | talk_force_enqueue_next(); | ||
178 | } | ||
136 | if(result_displayed) | 179 | if(result_displayed) |
137 | sleep(HZ); | 180 | sleep(HZ); |
138 | return(result); | 181 | return(result); |