summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2007-08-06 13:08:36 +0000
committerNils Wallménius <nils@rockbox.org>2007-08-06 13:08:36 +0000
commit5b76936a44de3c7ecd568300f26b5e6421901285 (patch)
tree504d9cf371d8f64c70a7bb40469a3a6f05a1b7cd /apps/gui
parentd755c283caef258ae5d81278d324f907fcf402c8 (diff)
downloadrockbox-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')
-rw-r--r--apps/gui/gwps-common.c2
-rw-r--r--apps/gui/splash.c12
-rw-r--r--apps/gui/yesno.c45
3 files changed, 57 insertions, 2 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 5f437824b8..82bf7541f2 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -294,7 +294,7 @@ bool gui_wps_display(void)
294#ifdef HAVE_LCD_BITMAP 294#ifdef HAVE_LCD_BITMAP
295 gui_syncstatusbar_draw(&statusbars, true); 295 gui_syncstatusbar_draw(&statusbars, true);
296#endif 296#endif
297 gui_syncsplash(HZ, str(LANG_END_PLAYLIST)); 297 gui_syncsplash(HZ, ID2P(LANG_END_PLAYLIST));
298 return true; 298 return true;
299 } 299 }
300 else 300 else
diff --git a/apps/gui/splash.c b/apps/gui/splash.c
index 72279a371d..94d9ef6a5c 100644
--- a/apps/gui/splash.c
+++ b/apps/gui/splash.c
@@ -22,6 +22,9 @@
22#include "stdio.h" 22#include "stdio.h"
23#include "kernel.h" 23#include "kernel.h"
24#include "screen_access.h" 24#include "screen_access.h"
25#include "lang.h"
26#include "settings.h"
27#include "talk.h"
25 28
26#ifndef MAX 29#ifndef MAX
27#define MAX(a, b) (((a)>(b))?(a):(b)) 30#define MAX(a, b) (((a)>(b))?(a):(b))
@@ -197,6 +200,15 @@ void gui_syncsplash(int ticks, const unsigned char *fmt, ...)
197{ 200{
198 va_list ap; 201 va_list ap;
199 int i; 202 int i;
203 long id;
204 /* fmt may be a so called virtual pointer. See settings.h. */
205 if((id = P2ID(fmt)) >= 0)
206 /* If fmt specifies a voicefont ID, and voice menus are
207 enabled, then speak it. */
208 cond_talk_ids_fq(id);
209 /* If fmt is a lang ID then get the corresponding string (which
210 still might contain % place holders). */
211 fmt = P2STR(fmt);
200 va_start( ap, fmt ); 212 va_start( ap, fmt );
201 FOR_NB_SCREENS(i) 213 FOR_NB_SCREENS(i)
202 splash(&(screens[i]), fmt, ap); 214 splash(&(screens[i]), fmt, ap);
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. */
110static 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
101enum yesno_res gui_syncyesno_run(struct text_message * main_message, 123enum 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);