mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
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
This commit is contained in:
parent
fbdc0e6b57
commit
6f4c6ed990
3 changed files with 28 additions and 32 deletions
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "textarea.h"
|
#include "textarea.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
#include "lang.h"
|
||||||
|
#include "talk.h"
|
||||||
|
|
||||||
void gui_textarea_clear(struct screen * display)
|
void gui_textarea_clear(struct screen * display)
|
||||||
{
|
{
|
||||||
|
@ -51,7 +53,8 @@ int gui_textarea_put_message(struct screen * display,
|
||||||
int i;
|
int i;
|
||||||
gui_textarea_clear(display);
|
gui_textarea_clear(display);
|
||||||
for(i=0;i<message->nb_lines && i+ystart<display->nb_lines;i++)
|
for(i=0;i<message->nb_lines && i+ystart<display->nb_lines;i++)
|
||||||
display->puts_scroll(0, i+ystart, (unsigned char *)message->message_lines[i]);
|
display->puts_scroll(0, i+ystart, P2STR((unsigned char *)message->
|
||||||
|
message_lines[i]));
|
||||||
gui_textarea_update(display);
|
gui_textarea_update(display);
|
||||||
return(i);
|
return(i);
|
||||||
}
|
}
|
||||||
|
@ -74,3 +77,18 @@ void gui_textarea_update_nblines(struct screen * display)
|
||||||
#endif
|
#endif
|
||||||
display->nb_lines = height / display->char_height;
|
display->nb_lines = height / display->char_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void talk_text_message(struct text_message * message, bool enqueue)
|
||||||
|
{
|
||||||
|
int line;
|
||||||
|
if(message)
|
||||||
|
for(line=0; line<message->nb_lines; line++)
|
||||||
|
{
|
||||||
|
long id = P2ID((unsigned char *)message->message_lines[line]);
|
||||||
|
if(id>=0)
|
||||||
|
{
|
||||||
|
talk_id(id, enqueue);
|
||||||
|
enqueue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -59,6 +59,12 @@ extern int gui_textarea_put_message(struct screen * display,
|
||||||
*/
|
*/
|
||||||
extern void gui_textarea_update_nblines(struct screen * display);
|
extern void gui_textarea_update_nblines(struct screen * display);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Speak a text_message. The message's lines may be virtual pointers
|
||||||
|
* representing language / voicefont IDs (see settings.h).
|
||||||
|
*/
|
||||||
|
extern void talk_text_message(struct text_message * message, bool enqueue);
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
/*
|
/*
|
||||||
* Compute the number of pixels from which text can be displayed
|
* Compute the number of pixels from which text can be displayed
|
||||||
|
|
|
@ -101,25 +101,6 @@ static bool gui_yesno_draw_result(struct gui_yesno * yn, enum yesno_res result)
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
/* Processes a text_message whose lines may be virtual pointers
|
|
||||||
representing language / voicefont IDs (see settings.h). Copies out
|
|
||||||
the IDs to the ids array, which is of length maxlen, and replaces
|
|
||||||
the pointers in the text_message with the actual language strings.
|
|
||||||
The ids array is terminated with the TALK_FINAL_ID sentinel
|
|
||||||
element. */
|
|
||||||
static void extract_talk_ids(struct text_message *m, long *ids, int maxlen)
|
|
||||||
{
|
|
||||||
int line, i=0;
|
|
||||||
if(m)
|
|
||||||
for(line=0; line<m->nb_lines; line++) {
|
|
||||||
long id = P2ID((unsigned char *)m->message_lines[line]);
|
|
||||||
if(id>=0 && i<maxlen-1)
|
|
||||||
ids[i++] = id;
|
|
||||||
m->message_lines[line] = (char *)P2STR((unsigned char *)m->message_lines[line]);
|
|
||||||
}
|
|
||||||
ids[i] = TALK_FINAL_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum yesno_res gui_syncyesno_run(struct text_message * main_message,
|
enum yesno_res gui_syncyesno_run(struct text_message * main_message,
|
||||||
struct text_message * yes_message,
|
struct text_message * yes_message,
|
||||||
struct text_message * no_message)
|
struct text_message * no_message)
|
||||||
|
@ -129,13 +110,7 @@ enum yesno_res gui_syncyesno_run(struct text_message * main_message,
|
||||||
int result=-1;
|
int result=-1;
|
||||||
bool result_displayed;
|
bool result_displayed;
|
||||||
struct gui_yesno yn[NB_SCREENS];
|
struct gui_yesno yn[NB_SCREENS];
|
||||||
long voice_ids[5];
|
|
||||||
long talked_tick = 0;
|
long talked_tick = 0;
|
||||||
/* The text messages may contain virtual pointers to IDs (see
|
|
||||||
settings.h) instead of plain strings. Copy the IDs out so we
|
|
||||||
can speak them, and unwrap the actual language strings. */
|
|
||||||
extract_talk_ids(main_message, voice_ids,
|
|
||||||
sizeof(voice_ids)/sizeof(voice_ids[0]));
|
|
||||||
FOR_NB_SCREENS(i)
|
FOR_NB_SCREENS(i)
|
||||||
{
|
{
|
||||||
gui_yesno_init(&(yn[i]), main_message, yes_message, no_message);
|
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,
|
||||||
&& (talked_tick==0 || TIME_AFTER(current_tick, talked_tick+HZ*5)))
|
&& (talked_tick==0 || TIME_AFTER(current_tick, talked_tick+HZ*5)))
|
||||||
{
|
{
|
||||||
talked_tick = current_tick;
|
talked_tick = current_tick;
|
||||||
talk_idarray(voice_ids, false);
|
talk_text_message(main_message, false);
|
||||||
}
|
}
|
||||||
button = get_action(CONTEXT_YESNOSCREEN, HZ*5);
|
button = get_action(CONTEXT_YESNOSCREEN, HZ*5);
|
||||||
switch (button)
|
switch (button)
|
||||||
|
@ -168,16 +143,13 @@ enum yesno_res gui_syncyesno_run(struct text_message * main_message,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* extract_talk_ids also converts ID to STR */
|
|
||||||
extract_talk_ids((result == YESNO_YES) ? yes_message : no_message,
|
|
||||||
voice_ids, sizeof(voice_ids)/sizeof(voice_ids[0]));
|
|
||||||
|
|
||||||
FOR_NB_SCREENS(i)
|
FOR_NB_SCREENS(i)
|
||||||
result_displayed=gui_yesno_draw_result(&(yn[i]), result);
|
result_displayed=gui_yesno_draw_result(&(yn[i]), result);
|
||||||
|
|
||||||
if (global_settings.talk_menu)
|
if (global_settings.talk_menu)
|
||||||
{
|
{
|
||||||
talk_idarray(voice_ids, false);
|
talk_text_message((result == YESNO_YES) ? yes_message
|
||||||
|
: no_message, false);
|
||||||
talk_force_enqueue_next();
|
talk_force_enqueue_next();
|
||||||
}
|
}
|
||||||
if(result_displayed)
|
if(result_displayed)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue