diff options
author | Stéphane Doyon <s.doyon@videotron.ca> | 2007-11-07 01:37:00 +0000 |
---|---|---|
committer | Stéphane Doyon <s.doyon@videotron.ca> | 2007-11-07 01:37:00 +0000 |
commit | 6f4c6ed99007f89099b74bfbb95f5ca58b0ead3c (patch) | |
tree | f524bf0c6e865b3be8fee11da4210fd7666a8798 /apps/gui/yesno.c | |
parent | fbdc0e6b57f326fccefaf044bd70f1072653db00 (diff) | |
download | rockbox-6f4c6ed99007f89099b74bfbb95f5ca58b0ead3c.tar.gz rockbox-6f4c6ed99007f89099b74bfbb95f5ca58b0ead3c.zip |
Straighten out voicing of yesno dialogs.
Make it so gui_syncyesno_run() does not modify the text_messages passed
as argument, simplify the code and even reduce size a bit.
The key is to support voicing at the level of the text_message itself.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15505 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/yesno.c')
-rw-r--r-- | apps/gui/yesno.c | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/apps/gui/yesno.c b/apps/gui/yesno.c index 4e86b017ca..891e73809b 100644 --- a/apps/gui/yesno.c +++ b/apps/gui/yesno.c | |||
@@ -101,25 +101,6 @@ static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result) | |||
101 | 101 | ||
102 | #include "debug.h" | 102 | #include "debug.h" |
103 | 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 | |||
123 | enum yesno_res gui_syncyesno_run(struct text_message * main_message, | 104 | enum yesno_res gui_syncyesno_run(struct text_message * main_message, |
124 | struct text_message * yes_message, | 105 | struct text_message * yes_message, |
125 | struct text_message * no_message) | 106 | struct text_message * no_message) |
@@ -129,13 +110,7 @@ enum yesno_res gui_syncyesno_run(struct text_message * main_message, | |||
129 | int result=-1; | 110 | int result=-1; |
130 | bool result_displayed; | 111 | bool result_displayed; |
131 | struct gui_yesno yn[NB_SCREENS]; | 112 | struct gui_yesno yn[NB_SCREENS]; |
132 | long voice_ids[5]; | ||
133 | long talked_tick = 0; | 113 | 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])); | ||
139 | FOR_NB_SCREENS(i) | 114 | FOR_NB_SCREENS(i) |
140 | { | 115 | { |
141 | gui_yesno_init(&(yn[i]), main_message, yes_message, no_message); | 116 | gui_yesno_init(&(yn[i]), main_message, yes_message, no_message); |
@@ -149,7 +124,7 @@ enum yesno_res gui_syncyesno_run(struct text_message * main_message, | |||
149 | && (talked_tick==0 || TIME_AFTER(current_tick, talked_tick+HZ*5))) | 124 | && (talked_tick==0 || TIME_AFTER(current_tick, talked_tick+HZ*5))) |
150 | { | 125 | { |
151 | talked_tick = current_tick; | 126 | talked_tick = current_tick; |
152 | talk_idarray(voice_ids, false); | 127 | talk_text_message(main_message, false); |
153 | } | 128 | } |
154 | button = get_action(CONTEXT_YESNOSCREEN, HZ*5); | 129 | button = get_action(CONTEXT_YESNOSCREEN, HZ*5); |
155 | switch (button) | 130 | switch (button) |
@@ -168,16 +143,13 @@ enum yesno_res gui_syncyesno_run(struct text_message * main_message, | |||
168 | } | 143 | } |
169 | } | 144 | } |
170 | 145 | ||
171 | /* extract_talk_ids also converts ID to STR */ | ||
172 | extract_talk_ids((result == YESNO_YES) ? yes_message : no_message, | ||
173 | voice_ids, sizeof(voice_ids)/sizeof(voice_ids[0])); | ||
174 | |||
175 | FOR_NB_SCREENS(i) | 146 | FOR_NB_SCREENS(i) |
176 | result_displayed=gui_yesno_draw_result(&(yn[i]), result); | 147 | result_displayed=gui_yesno_draw_result(&(yn[i]), result); |
177 | 148 | ||
178 | if (global_settings.talk_menu) | 149 | if (global_settings.talk_menu) |
179 | { | 150 | { |
180 | talk_idarray(voice_ids, false); | 151 | talk_text_message((result == YESNO_YES) ? yes_message |
152 | : no_message, false); | ||
181 | talk_force_enqueue_next(); | 153 | talk_force_enqueue_next(); |
182 | } | 154 | } |
183 | if(result_displayed) | 155 | if(result_displayed) |