Ejemplo n.º 1
0
static const char *get_dist_to_destination(void){
  static char text[256];

  	if (roadmap_message_format (text, sizeof(text), "%D (%W)|%D"))
  		return &text[0];
  	return "";
}
Ejemplo n.º 2
0
void roadmap_voice_announce (const char *title) {

    int   i;
    char  text[1024];
    char  expanded[1024];
    char *final;
    char *arguments;

    if (!featureEnabled)
       return;

    if (RoadMapVoiceMuted) {
       if (strcasecmp
             (roadmap_config_get (&RoadMapVoiceMute), "no") == 0) {
          RoadMapVoiceMuted = 0;
       } else {
          return;
       }
    }

    RoadMapVoiceActive.handler = roadmap_voice_complete;


    for (i = 0; RoadMapVoiceText[i].default_text != NULL; ++i) {

        if (strcmp (title, RoadMapVoiceText[i].config.name) == 0) {
            break;
        }
    }

    if (RoadMapVoiceText[i].default_text == NULL) {
        roadmap_log (ROADMAP_ERROR, "invalid voice %s", title);
        return;
    }

    if (!roadmap_message_format
             (text, sizeof(text),
              roadmap_config_get (&RoadMapVoiceText[i].config)) ||

         (text[0] == 0)) {

       /* No message. */
       return;
    }

    if (roadmap_voice_expand (text, expanded, sizeof(expanded))) {
        final = expanded;
    } else {
Ejemplo n.º 3
0
void roadmap_ticker_show(void){
   char text[256];
   gTickerHide = FALSE;

   if (! roadmap_message_format (text, sizeof(text), "%*|%X")) {
      roadmap_message_set('*', "%d", 0);
      roadmap_ticker_set_last_event(default_event);
   }

   if (gTickerSupressHide)
      roadmap_main_remove_periodic (roadmap_ticker_supress_hide);

   roadmap_main_set_periodic (15000, roadmap_ticker_supress_hide);

   gTickerSupressHide = TRUE;
   if (!roadmap_screen_refresh())
     roadmap_screen_redraw();
}
Ejemplo n.º 4
0
const char * get_current_street(void){
	static char text[256];
	roadmap_message_format (text, sizeof(text), "%Y");
	return &text[0];

}
Ejemplo n.º 5
0
void roadmap_ticker_display() {

   char text[256];
   char points[20];
   char rank[20];
   int text_width, ascent, descent;
   RoadMapGuiPoint position;
   RoadMapGuiPoint text_position;
   RoadMapImage image;
   int start,end, start_x;
	int iMyTotalPoints;
	int iMyRanking;
   int allign;
   int width;
   int text_offset_y = 25;
	int point_start_x = 190;
	int rank_start_x = 270;
   int new_pnts_start_x = 50;
   RoadMapImage x_image = NULL;

   const char * point_text = NULL;

   if ( roadmap_screen_is_hd_screen() )
   {
		text_offset_y = 22;
		point_start_x = 200;
		rank_start_x = 280;
		new_pnts_start_x = 65;
   }

   width = roadmap_canvas_width();


    if (!gInitialized) return ;

    if (!ticker_cfg_on() && !gTickerSupressHide){
       gTickerOn = FALSE;
       return;
    }


    if (gTickerHide ){
		gTickerOn = FALSE;
	 	return;
	}

    if (!roadmap_message_format (text, sizeof(text), "%X|%*")) {
    	if (gTickerSupressHide){
    		roadmap_message_set('*', "%d", 0);
    		roadmap_message_format (text, sizeof(text), "%*");
    	}
    	else{
    		show_close_icon();
    		gTickerOn = FALSE;
        	return;
    	}
    }

	gTickerOn = TRUE;
   roadmap_canvas_get_text_extents (text, 14, &text_width, &ascent, &descent, NULL);


   roadmap_canvas_select_pen (RoadMapTickerPen);

   end = roadmap_canvas_width();
   start = 1;
   start_x = 1;

   image = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, TICKER_MIDDLE_IMAGE);
   if ( image )
   {
	   while (start < end){
			position.x = start;
			position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset();
			roadmap_canvas_draw_image ( image, &position, 0, IMAGE_NORMAL);
			start += roadmap_canvas_image_width( image );
		}
   }
	position.x = 0;

	if (ssd_widget_rtl(NULL)){
	   allign = ROADMAP_CANVAS_RIGHT;
	   text_position.x = roadmap_canvas_width() -4;
	}
	else{
	   allign = ROADMAP_CANVAS_LEFT;
	   text_position.x = 4;
	}
   text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + 2;
	roadmap_canvas_draw_string_size (&text_position,
	                                 allign |ROADMAP_CANVAS_TOP,
	                                 14,roadmap_lang_get("Your Points (updated daily)"));

   text_position.x = 4;
	text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + 2 +TICKER_TOP_BAR_TEXT_OFFSET;

	switch( gLastUpdateEvent ) {
    case default_event:
        point_text = roadmap_lang_get("New points");
        break;
    case report_event:
  	    point_text = roadmap_lang_get("Road report");
        break;
    case comment_event:
        point_text = roadmap_lang_get("Event comment");
        break;
    case confirm_event:
        point_text= roadmap_lang_get("Prompt response");
        break;
    case road_munching_event :
    	 point_text= roadmap_lang_get("Road munching");
    	break;
    case user_contribution_event :
    	point_text= roadmap_lang_get("Traffic detection");
    	break;
    case bonus_points :
      point_text= roadmap_lang_get("Bonus points");
      break;
	}


	roadmap_canvas_draw_string_size (&text_position,
	                                    ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP,
	                                   14,point_text);


	image = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, TICKER_DIVIDER);

	if ( image )
	{
	   position.y = roadmap_bar_top_height() + TICKER_TOP_BAR_DIVIDER_OFFSET;
	   position.x = width /3 +4 + 30;
	   roadmap_canvas_draw_image ( image, &position, 0, IMAGE_NORMAL);

		position.y = roadmap_bar_top_height() + TICKER_TOP_BAR_DIVIDER_OFFSET;
	    position.x = 2*width/3+4 +15;
	    roadmap_canvas_draw_image ( image, &position, 0, IMAGE_NORMAL);
	}

	text_position.x =  (width/3) + (width/3)/4 + 30;
	text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + 2 + TICKER_TOP_BAR_TEXT_OFFSET;
  	roadmap_canvas_draw_string_size (&text_position,
       	    	                     ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP,
           	    	                 14,roadmap_lang_get("Total"));

   text_position.x = (width/3) + (width/3)/4+ 30;
	text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + text_offset_y +TICKER_TOP_BAR_TEXT_OFFSET;
	iMyTotalPoints = editor_points_get_total_points();
	if (iMyTotalPoints != -1){
		if (iMyTotalPoints < 10000){
			sprintf(points,"%d", iMyTotalPoints);
		}
		else{
			sprintf(points,"%dK", (int)iMyTotalPoints/1000);
		}
	}
	else{
		strcpy(points,"");
	}
  	roadmap_canvas_draw_string_size (&text_position,
       	    	                     ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP,
           	    	                 14,points);

	text_position.x = width - (width/3) + (width/3)/4+ 15;
	text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + 2 +TICKER_TOP_BAR_TEXT_OFFSET;
	iMyRanking = RealTime_GetMyRanking();
	if (iMyRanking == -1)
		strcpy(rank,"");
	else
		sprintf(rank, "%d", iMyRanking);
  	roadmap_canvas_draw_string_size (&text_position,
       	    	                     ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP,
           	    	                 14,roadmap_lang_get("Rank"));

   text_position.x = width - (width/3) + (width/3)/4+ 12;
   text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + text_offset_y +TICKER_TOP_BAR_TEXT_OFFSET;
  	roadmap_canvas_draw_string_size (&text_position,
       	    	                     ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP,
           	    	                 14,rank);

  	if (strcmp(text,"0")){
  	   text_position.x = new_pnts_start_x - start_x + 30;
  	   text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + text_offset_y +TICKER_TOP_BAR_TEXT_OFFSET;
  	   roadmap_canvas_draw_string_size (&text_position,
                     ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP,
                     14,"+");


  	   text_position.x = new_pnts_start_x - start_x + 40;
  	   text_position.y = roadmap_bar_top_height() + roadmap_ticker_top_bar_offset() + text_offset_y +TICKER_TOP_BAR_TEXT_OFFSET;
  	   roadmap_canvas_draw_string_size (&text_position,
  	            ROADMAP_CANVAS_LEFT|ROADMAP_CANVAS_TOP,
                     14,text);
   }

#ifdef TOUCH_SCREEN
   x_image = (RoadMapImage) roadmap_res_get(RES_BITMAP, RES_SKIN, "x_close");
   if ( x_image ) {
       position.x = roadmap_canvas_width() - roadmap_canvas_image_width(x_image) - 5;
       position.y = roadmap_bar_top_height() + gMiddleImageSize.height -roadmap_canvas_image_height(x_image) -5;
       roadmap_canvas_draw_image ( x_image, &position, 0, IMAGE_NORMAL);
   }
#endif

}
Ejemplo n.º 6
0
int roadmap_display_activate
        (const char *title,
         const PluginLine *line,
         const RoadMapPosition *position,
         PluginStreet *street) {

    int   street_has_changed;
    int   message_has_changed;
    const char *format;
    char  text[256];
    RoadMapSign *sign;
    PluginStreetProperties properties;

    roadmap_log_push ("roadmap_display_activate");

    sign = roadmap_display_search_sign (title);
    if (sign == NULL) {
        roadmap_log_pop ();
        return -1;
    }

    if (sign->format_descriptor.category == NULL) {
       return -1; /* This is not a sign: this is a text. */
    }
    format = roadmap_config_get (&sign->format_descriptor);

    street_has_changed = 0;

    if (!roadmap_plugin_same_line (&sign->line, line)) {

       roadmap_plugin_get_street (line, street);

        if (sign->id != NULL) {
            free (sign->id);
        }

        sign->id =
            strdup (roadmap_plugin_street_full_name (line));

        sign->line = *line;
        sign->was_visible = 0;

        if (!roadmap_plugin_same_street (street, &sign->street)) {
           sign->street = *street;
           street_has_changed = 1;
        }
    }


    roadmap_message_set ('F', sign->id);

    roadmap_plugin_get_street_properties (line, &properties, 0);

    roadmap_message_set ('#', properties.address);
    roadmap_message_set ('N', properties.street);
    //roadmap_message_set ('T', properties.street_t2s);
    roadmap_message_set ('C', properties.city);

    if (!strcmp(title, "Current Street")){
    	roadmap_message_set ('Y', properties.street);
    	roadmap_message_set ('Z', properties.city);
    }

    if (! roadmap_message_format (text, sizeof(text), roadmap_lang_get(format))) {
        roadmap_log_pop ();
        *street = sign->street;
        return 0;
    }
    message_has_changed =
        (sign->content == NULL || strcmp (sign->content, text) != 0);

    if (roadmap_config_get_integer (&RoadMapConfigDisplayDuration) == -1) {
       sign->deadline = -1;

    } else {

       sign->deadline =
           time(NULL)
               + roadmap_config_get_integer (&RoadMapConfigDisplayDuration);
    }


    if (street_has_changed) {
        roadmap_voice_announce (sign->title);
    }

    if (message_has_changed) {

        if (sign->content != NULL) {
            free (sign->content);
        }
        if (text[0] == 0) {
            sign->content = strdup("(this street has no name)");
        } else {
            sign->content = strdup (text);
        }
    }

	roadmap_plugin_line_from (line, &sign->endpoint[0]);
    roadmap_plugin_line_to (line, &sign->endpoint[1]);

    if (position == NULL) {
        sign->has_position = 0;
    } else {
        sign->has_position = 1;
        sign->position = *position;
    }

    roadmap_log_pop ();
    *street = sign->street;
    return 0;
}
Ejemplo n.º 7
0
static void roadmap_display_console_box
                (int type, int corner, const char *format) {

    char text[256];
    int count;
    int width, ascent, descent;
    int warning_font_size = 13;
    int offset = 62;

#ifdef ANDROID
    warning_font_size = 15;
#endif


    RoadMapGuiPoint frame[4];

#ifdef _WIN32
   offset = 33;
#endif

    count = 4;

    if (! roadmap_message_format (text, sizeof(text), format)) {
        return;
    }

#ifdef QTMOBILITY
    {
        roadmap_display_set_message(text);
        return;
    }
#endif

    if ( type == ROADMAP_CONSOLE_WARNING ){
        	roadmap_canvas_get_text_extents (text, warning_font_size, &width, &ascent, &descent, NULL);
        	while (width > (roadmap_canvas_width()-10)){
        	   warning_font_size--;
        	   roadmap_canvas_get_text_extents (text, warning_font_size, &width, &ascent, &descent, NULL);
        	}
    }
    else if (type == ROADMAP_CONSOLE_ACTIVITY ){
    	roadmap_canvas_get_text_extents (text, 12, &width, &ascent, &descent, NULL);
    }
    else
    {
    	roadmap_canvas_get_text_extents (text, 16, &width, &ascent, &descent, NULL);
    }

    if (roadmap_screen_is_hd_screen())
       offset = 94;

    if (type == ROADMAP_CONSOLE_ACTIVITY) {
#ifdef TOUCH_SCREEN
       if (roadmap_horizontal_screen_orientation())
   		frame[2].x = roadmap_canvas_width() - offset;
       else
#endif
          frame[2].x = roadmap_canvas_width() ;
   		frame[0].x = frame[2].x - width - 4;
    } else if (corner & ROADMAP_CANVAS_RIGHT) {
#ifdef TOUCH_SCREEN
       if (roadmap_horizontal_screen_orientation())
        frame[2].x = roadmap_canvas_width() - 5-offset;
       else
#endif
        frame[2].x = roadmap_canvas_width() - 1 ;
        frame[0].x = frame[2].x - width - 6;
    } else {
        frame[0].x = 5;
        frame[2].x = frame[0].x + width + 6;
    }
    frame[1].x = frame[0].x;
    frame[3].x = frame[2].x;

    if (corner & ROADMAP_CANVAS_BOTTOM) {
        frame[0].y = roadmap_canvas_height () - ascent - descent - 11 - 22;
        frame[1].y = roadmap_canvas_height () - 6 - 22;
    } else {
       if ( type == ROADMAP_CONSOLE_ACTIVITY || type == ROADMAP_CONSOLE_WARNING )
       {
    	   frame[0].y = roadmap_bar_top_height() +  roadmap_ticker_height()+ roadmap_message_ticker_height()+1;
       }
       else
       {
          frame[0].y = 40;
       }

       frame[1].y = ascent + descent + frame[0].y + 6;
    }
    frame[2].y = frame[1].y;
    frame[3].y = frame[0].y;



    count = 4;

    if (type == ROADMAP_CONSOLE_WARNING ) {
    	roadmap_canvas_select_pen (RoadMapWarningBackground);
      roadmap_canvas_set_opacity(181);
    }
    else if (type == ROADMAP_CONSOLE_ACTIVITY) {
       roadmap_canvas_select_pen (RoadMapActivityBackground);
    } else {
       roadmap_canvas_select_pen (RoadMapConsoleBackground);
    }

   roadmap_canvas_draw_multiple_polygons (1, &count, frame, 1, 0);
  	if (type == ROADMAP_CONSOLE_WARNING) {
  		roadmap_canvas_select_pen (RoadMapWarningForeground);
  	}
  	else if (type == ROADMAP_CONSOLE_ACTIVITY) {
      roadmap_canvas_select_pen (RoadMapActivityForeground);
    } else {
       roadmap_canvas_select_pen (RoadMapConsoleForeground);
    }

   if (type != ROADMAP_CONSOLE_WARNING )
    roadmap_canvas_draw_multiple_polygons (1, &count, frame, 0, 0);

    frame[0].x = frame[3].x - 3;
    frame[0].y = frame[3].y + 1;
    if (type == ROADMAP_CONSOLE_WARNING )
    {
    	roadmap_canvas_draw_string_size (frame,
    	        	    	                    ROADMAP_CANVAS_RIGHT|ROADMAP_CANVAS_TOP,
    	        	    	                warning_font_size,text);
    }
    else if (type == ROADMAP_CONSOLE_ACTIVITY)
    	roadmap_canvas_draw_string_size (frame,
        	    	                    ROADMAP_CANVAS_RIGHT|ROADMAP_CANVAS_TOP,
            	    	                12,text);
	else
	    roadmap_canvas_draw_string (frame,
    	                            ROADMAP_CANVAS_RIGHT|ROADMAP_CANVAS_TOP,
        	                        text);
}