diff options
-rw-r--r-- | data/mg/street.c | 6 | ||||
-rw-r--r-- | graphics.c | 16 | ||||
-rw-r--r-- | graphics.h | 3 | ||||
-rw-r--r-- | graphics/gtk_drawing_area/graphics_gtk_drawing_area.c | 15 | ||||
-rw-r--r-- | gui/gtk/gui_gtk_action.c | 1 | ||||
-rw-r--r-- | gui/sdl/gui_sdl_window.cpp | 5 | ||||
-rw-r--r-- | item_def.h | 2 | ||||
-rw-r--r-- | map.c | 11 | ||||
-rw-r--r-- | navigation.c | 154 | ||||
-rw-r--r-- | navigation.h | 4 | ||||
-rw-r--r-- | navit.c | 79 | ||||
-rw-r--r-- | navit.xml | 6 | ||||
-rw-r--r-- | popup.c | 16 | ||||
-rw-r--r-- | route.c | 20 | ||||
-rw-r--r-- | route.h | 4 | ||||
-rw-r--r-- | speech.c | 3 | ||||
-rw-r--r-- | speech/cmdline/speech_cmdline.c | 6 | ||||
-rw-r--r-- | xmlconfig.c | 26 | ||||
-rw-r--r-- | xpm/Makefile.am | 2 | ||||
-rw-r--r-- | xpm/flag_bk_tr.xpm | 27 | ||||
-rw-r--r-- | xpm/flag_bk_wh.xpm | 28 | ||||
-rw-r--r-- | xpm/flag_bl_wh.xpm | 28 |
22 files changed, 396 insertions, 66 deletions
diff --git a/data/mg/street.c b/data/mg/street.c index befbddaf..26bfaedb 100644 --- a/data/mg/street.c +++ b/data/mg/street.c @@ -219,12 +219,12 @@ street_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) } return 0; case attr_label: + street->attr_next=attr_street_name; nameid=L(street->str->nameid); if (! nameid) return 0; if (! street->name.len) street_name_get_by_id(&street->name,street->name_file,nameid); - street->attr_next=attr_street_name; attr->u.str=street->name.name2; if (attr->u.str && attr->u.str[0]) return 1; @@ -233,22 +233,22 @@ street_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr) return 1; return 0; case attr_street_name: + street->attr_next=attr_street_name_systematic; nameid=L(street->str->nameid); if (! nameid) return 0; if (! street->name.len) street_name_get_by_id(&street->name,street->name_file,nameid); attr->u.str=street->name.name2; - street->attr_next=attr_street_name_systematic; return ((attr->u.str && attr->u.str[0]) ? 1:0); case attr_street_name_systematic: + street->attr_next=attr_limit; nameid=L(street->str->nameid); if (! nameid) return 0; if (! street->name.len) street_name_get_by_id(&street->name,street->name_file,nameid); attr->u.str=street->name.name1; - street->attr_next=attr_limit; return ((attr->u.str && attr->u.str[0]) ? 1:0); case attr_limit: if (street->str->type & 0x40) { @@ -4,12 +4,12 @@ #include "debug.h" #include "string.h" #include "draw_info.h" +#include "point.h" #include "graphics.h" #include "map.h" #include "coord.h" #include "transform.h" #include "projection.h" -#include "point.h" #include "plugin.h" #include "profile.h" #include "mapset.h" @@ -128,7 +128,11 @@ graphics_image_new(struct graphics *gra, char *path) struct graphics_image *this_; this_=g_new0(struct graphics_image,1); - this_->priv=gra->meth.image_new(gra->priv, &this_->meth, path, &this_->width, &this_->height); + this_->priv=gra->meth.image_new(gra->priv, &this_->meth, path, &this_->width, &this_->height, &this_->hot); + if (! this_->priv) { + g_free(this_); + this_=NULL; + } return this_; } @@ -361,9 +365,11 @@ xdisplay_draw_elements(struct graphics *gra, GHashTable *display_list, struct it if (! img) g_warning("failed to load icon '%s'\n", e->u.icon.src); } - p.x=di->pnt[0].x - img->width/2; - p.y=di->pnt[0].y - img->height/2; - gra->meth.draw_image(gra->priv, gra->gc[0]->priv, &p, img->priv); + if (img) { + p.x=di->pnt[0].x - img->hot.x; + p.y=di->pnt[0].y - img->hot.y; + gra->meth.draw_image(gra->priv, gra->gc[0]->priv, &p, img->priv); + } break; case element_image: printf("image: '%s'\n", di->label); @@ -38,7 +38,7 @@ struct graphics_methods { struct graphics_gc_priv *(*gc_new)(struct graphics_priv *gr, struct graphics_gc_methods *meth); void (*background_gc)(struct graphics_priv *gr, struct graphics_gc_priv *gc); struct graphics_priv *(*overlay_new)(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h); - struct graphics_image_priv *(*image_new)(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h); + struct graphics_image_priv *(*image_new)(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot); void *(*get_data)(struct graphics_priv *gr, char *type); void (*register_resize_callback)(struct graphics_priv *gr, void (*callback)(void *data, int w, int h), void *data); void (*register_button_callback)(struct graphics_priv *gr, void (*callback)(void *data, int pressed, int button, struct point *p), void *data); @@ -77,6 +77,7 @@ struct graphics_image { struct graphics_image_methods meth; int width; int height; + struct point hot; }; /* prototypes */ diff --git a/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c b/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c index 339d904f..cd38b2ac 100644 --- a/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c +++ b/graphics/gtk_drawing_area/graphics_gtk_drawing_area.c @@ -184,10 +184,11 @@ static struct graphics_gc_priv *gc_new(struct graphics_priv *gr, struct graphics static struct graphics_image_priv * -image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h) +image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *name, int *w, int *h, struct point *hot) { GdkPixbuf *pixbuf; struct graphics_image_priv *ret; + const char *option; pixbuf=gdk_pixbuf_new_from_file(name, NULL); if (! pixbuf) @@ -198,6 +199,18 @@ image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *n ret->h=gdk_pixbuf_get_height(pixbuf); *w=ret->w; *h=ret->h; + if (hot) { + option=gdk_pixbuf_get_option(pixbuf, "x_hot"); + if (option) + hot->x=atoi(option); + else + hot->x=ret->w/2-1; + option=gdk_pixbuf_get_option(pixbuf, "y_hot"); + if (option) + hot->y=atoi(option); + else + hot->y=ret->h/2-1; + } return ret; } diff --git a/gui/gtk/gui_gtk_action.c b/gui/gtk/gui_gtk_action.c index 4dcb0592..ab75c7d6 100644 --- a/gui/gtk/gui_gtk_action.c +++ b/gui/gtk/gui_gtk_action.c @@ -1,7 +1,6 @@ #include <string.h> #include <gtk/gtk.h> #include "navit.h" -#include "graphics.h" #include "gui_gtk.h" #include "menu.h" #include "coord.h" diff --git a/gui/sdl/gui_sdl_window.cpp b/gui/sdl/gui_sdl_window.cpp index fdcd1ffc..9d103ebd 100644 --- a/gui/sdl/gui_sdl_window.cpp +++ b/gui/sdl/gui_sdl_window.cpp @@ -12,10 +12,11 @@ #include "gui.h" #include "coord.h" #include "plugin.h" -#include "graphics.h" #include "callback.h" +#include "point.h" +#include "graphics.h" #include "gui_sdl.h" - +#include "item.h" #include "navigation.h" #include "CEGUI.h" @@ -63,6 +63,8 @@ ITEM(poi_lake) ITEM(poi_island) ITEM(poi) ITEM(waypoint) +ITEM(bookmark) +ITEM(former_destination) ITEM(poi_land_feature) ITEM(poi_cape) ITEM(poi_rock) @@ -163,9 +163,14 @@ map_search_new(struct map *m, struct item *item, struct attr *search_attr, int p this->search_attr=*search_attr; if (search_attr->type >= attr_country_all && search_attr->type <= attr_country_name) this->priv=country_search_new(&this->search_attr, partial); - else - this->priv=m->meth.map_search_new(m->priv, item, search_attr, partial); - + else { + if (m->meth.map_search_new) + this->priv=m->meth.map_search_new(m->priv, item, search_attr, partial); + else { + g_free(this); + this=NULL; + } + } return this; } diff --git a/navigation.c b/navigation.c index ac1d43b3..3e4aec18 100644 --- a/navigation.c +++ b/navigation.c @@ -23,8 +23,15 @@ struct navigation { struct navigation_command *cmd_last; struct callback_list *callback_speech; struct callback_list *callback; + int level_last; + struct item item_last; + int turn_around; + int distance_turn; + int distance_last; + int announce[route_item_last-route_item_first+1][3]; }; + struct navigation_command { struct navigation_itm *itm; struct navigation_command *next; @@ -49,10 +56,20 @@ struct street_data { struct navigation * navigation_new(struct mapset *ms) { + int i,j; struct navigation *ret=g_new(struct navigation, 1); ret->ms=ms; ret->callback=callback_list_new(); ret->callback_speech=callback_list_new(); + ret->level_last=-2; + ret->distance_last=-2; + ret->distance_turn=50; + + for (j = 0 ; j <= route_item_last-route_item_first ; j++) { + for (i = 0 ; i < 3 ; i++) { + ret->announce[j][i]=-1; + } + } return ret; } @@ -63,6 +80,33 @@ navigation_set_mapset(struct navigation *this_, struct mapset *ms) this_->ms=ms; } +int +navigation_set_announce(struct navigation *this_, enum item_type type, int *level) +{ + int i; + if (type < route_item_first || type > route_item_last) { + dbg(0,"street type %d out of range [%d,%d]", type, route_item_first, route_item_last); + return 0; + } + for (i = 0 ; i < 3 ; i++) + this_->announce[type-route_item_first][i]=level[i]; + return 1; +} + +static int +navigation_get_announce_level(struct navigation *this_, enum item_type type, int dist) +{ + int i; + + if (type < route_item_first || type > route_item_last) + return -1; + for (i = 0 ; i < 3 ; i++) { + if (dist <= this_->announce[type-route_item_first][i]) + return i; + } + return i; +} + struct navigation_itm { char *name1; char *name2; @@ -87,7 +131,7 @@ road_angle(struct coord *c1, struct coord *c2, int dir) return ret; } -int +static int round_distance(int dist) { if (dist < 100) { @@ -119,20 +163,29 @@ round_distance(int dist) } static char * -get_distance(char *prefix, int dist, enum navigation_mode mode) +get_distance(int dist, enum navigation_mode mode) { if (mode == navigation_mode_long) return g_strdup_printf("%d m", dist); if (dist < 1000) - return g_strdup_printf(gettext("%s %d metern"), prefix, dist); + return g_strdup_printf(gettext("%d metern"), dist); if (dist < 5000) { int rem=(dist/100)%10; if (rem) - return g_strdup_printf(gettext("%s %d,%d kilometern"), prefix, dist/1000, rem); + return g_strdup_printf(gettext("%d,%d kilometern"), dist/1000, rem); } if ( dist == 1000) - return g_strdup_printf(gettext("%s einem kilometer"), prefix); - return g_strdup_printf(gettext("%s %d kilometer"), prefix, dist/1000); + return g_strdup_printf(gettext("einem kilometer")); + return g_strdup_printf(gettext("%d kilometer"), dist/1000); +} + +static char * +get_distance_fmt(char *fmt, int dist, enum navigation_mode mode) +{ + char *d=get_distance(dist, mode); + char *ret=g_strdup_printf(fmt, d); + g_free(d); + return ret; } static struct navigation_itm * @@ -288,12 +341,14 @@ make_maneuvers(struct navigation *this_) } static char * -show_maneuver(struct navigation_itm *itm, struct navigation_command *cmd, enum navigation_mode mode) +show_maneuver(struct navigation *nav, struct navigation_itm *itm, struct navigation_command *cmd, enum navigation_mode mode) { char *dir="rechts",*strength=""; int distance=itm->dest_length-cmd->itm->dest_length; char *d,*ret; int delta=cmd->delta; + int level; + level=1; if (delta < 0) { dir="links"; delta=-delta; @@ -308,7 +363,29 @@ show_maneuver(struct navigation_itm *itm, struct navigation_command *cmd, enum n dbg(0,"delta=%d\n", delta); strength="unbekannt "; } - d=get_distance("In", round_distance(distance), mode); + distance=round_distance(distance); + if (mode == navigation_mode_speech) { + if (nav->turn_around) + return g_strdup("Wenn möglich bitte wenden"); + level=navigation_get_announce_level(nav, itm->item.type, distance); + dbg(0,"distance=%d level=%d type=0x%x\n", distance, level, itm->item.type); + } + switch(level) { + case 3: + ret=get_distance_fmt("Dem Strassenverlauf %s folgen", distance, mode); + return ret; + case 2: + d=g_strdup("Demnächst"); + break; + case 1: + d=get_distance_fmt("In %s", distance, mode); + break; + case 0: + d=g_strdup("Jetzt"); + break; + default: + d=g_strdup("Error"); + } if (cmd->itm->next) ret=g_strdup_printf("%s %s%s abbiegen", d, strength, dir); else @@ -333,7 +410,7 @@ navigation_list_get(struct navigation_list *this_, enum navigation_mode mode) if (!this_->cmd) return NULL; g_free(this_->str); - this_->str=show_maneuver(this_->itm, this_->cmd, mode); + this_->str=show_maneuver(this_->nav, this_->itm, this_->cmd, mode); this_->itm=this_->cmd->itm; this_->cmd=this_->cmd->next; @@ -348,6 +425,44 @@ navigation_list_destroy(struct navigation_list *this_) g_free(this_); } +static void +navigation_call_callbacks(struct navigation *this_, int force_speech) +{ + int distance, level; + void *p=this_; + callback_list_call(this_->callback, 1, &p); + distance=round_distance(this_->first->dest_length-this_->cmd_first->itm->dest_length); + level=navigation_get_announce_level(this_, this_->first->item.type, distance); + if (level < this_->level_last) { + dbg(0,"level %d < %d\n", level, this_->level_last); + this_->level_last=level; + force_speech=1; + } + if (!item_is_equal(this_->cmd_first->itm->item, this_->item_last)) { + dbg(0,"item different\n"); + this_->item_last=this_->cmd_first->itm->item; + force_speech=1; + } + if (this_->turn_around) { + if (distance > this_->distance_turn) { + if (force_speech) { + this_->level_last=4; + return; + } + force_speech=1; + if (this_->distance_turn > 500) + this_->distance_turn*=2; + else + this_->distance_turn=500; + } + } else + this_->distance_turn=50; + if (force_speech) { + dbg(0,"distance=%d level=%d type=0x%x\n", distance, level, this_->first->item.type); + callback_list_call(this_->callback_speech, 1, &p); + } +} + void navigation_update(struct navigation *this_, struct route *route) { @@ -358,7 +473,6 @@ navigation_update(struct navigation *this_, struct route *route) struct street_data *sd; int *speedlist; int len,end_flag=0; - void *p; pos=route_get_pos(route); @@ -393,9 +507,13 @@ navigation_update(struct navigation *this_, struct route *route) itm=navigation_itm_new(this_, NULL, NULL); route_path_close(rph); calculate_dest_distance(this_); + if (this_->first->dest_length > this_->distance_last && this_->distance_last >= 0) + this_->turn_around=1; + else + this_->turn_around=0; + this_->distance_last=this_->first->dest_length; make_maneuvers(this_); - p=this_; - callback_list_call(this_->callback, 1, &p); + navigation_call_callbacks(this_, FALSE); } void @@ -409,12 +527,18 @@ navigation_destroy(struct navigation *this_) int navigation_register_callback(struct navigation *this_, enum navigation_mode mode, struct callback *cb) { - callback_list_add(this_->callback, cb); + if (mode == navigation_mode_speech) + callback_list_add(this_->callback_speech, cb); + else + callback_list_add(this_->callback, cb); return 1; } void -navigation_unregister_callback(struct navigation *this_, struct callback *cb) +navigation_unregister_callback(struct navigation *this_, enum navigation_mode mode, struct callback *cb) { - callback_list_remove_destroy(this_->callback, cb); + if (mode == navigation_mode_speech) + callback_list_remove_destroy(this_->callback_speech, cb); + else + callback_list_remove_destroy(this_->callback, cb); } diff --git a/navigation.h b/navigation.h index f06a8bdd..4268a612 100644 --- a/navigation.h +++ b/navigation.h @@ -8,6 +8,7 @@ enum navigation_mode { }; /* prototypes */ +enum item_type; enum navigation_mode; struct callback; struct mapset; @@ -16,13 +17,14 @@ struct navigation_list; struct route; struct navigation *navigation_new(struct mapset *ms); void navigation_set_mapset(struct navigation *this_, struct mapset *ms); +int navigation_set_announce(struct navigation *this_, enum item_type type, int *level); struct navigation_list *navigation_list_new(struct navigation *this_); char *navigation_list_get(struct navigation_list *this_, enum navigation_mode mode); void navigation_list_destroy(struct navigation_list *this_); void navigation_update(struct navigation *this_, struct route *route); void navigation_destroy(struct navigation *this_); int navigation_register_callback(struct navigation *this_, enum navigation_mode mode, struct callback *cb); -void navigation_unregister_callback(struct navigation *this_, struct callback *cb); +void navigation_unregister_callback(struct navigation *this_, enum navigation_mode mode, struct callback *cb); /* end of prototypes */ #ifdef __cplusplus } @@ -223,23 +223,35 @@ navit_set_destination_menu(struct menu *menu, void *this__p, void *c_p) } -void -navit_set_destination(struct navit *this_, struct coord *c, char *description) +static void +navit_append_coord(char *file, struct coord *c, char *type, char *description) { int fd; char *buffer; - buffer=g_strdup_printf("0x%x 0x%x %s\n", c->x, c->y, description); - fd=open("destination.txt", O_RDWR|O_CREAT|O_APPEND, 0644); + buffer=g_strdup_printf("0x%x 0x%x type=%s label=\"%s\"\n", c->x, c->y, type, description); + fd=open(file, O_RDWR|O_CREAT|O_APPEND, 0644); if (fd != -1) write(fd, buffer, strlen(buffer)); close(fd); g_free(buffer); +} + +void +navit_set_destination(struct navit *this_, struct coord *c, char *description) +{ + navit_append_coord("destination.txt", c, "former_destination", description); if (this_->route) { route_set_destination(this_->route, c); navit_draw(this_); } } +void +navit_add_bookmark(struct navit *this_, struct coord *c, char *description) +{ + navit_append_coord("bookmark.txt", c, "bookmark", description); +} + struct navit *global_navit; static void @@ -329,14 +341,19 @@ navit_add_menu_maps(struct navit *this_, struct mapset *ms, struct menu *men) } void -navit_add_menu_former_destinationss(struct navit *this_, struct menu *men, struct route *route) +navit_add_menu_destinations(struct navit *this_, char *file, struct menu *rmen, struct route *route) { struct coord c; int pos,flag=0; FILE *f; char buffer[2048]; - - f=fopen("destination.txt", "r"); + char buffer2[2048]; + char *s,*i,*n; + struct menu *men,*nmen; + GHashTable *h; + + h=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); + f=fopen(file, "r"); if (f) { while (! feof(f) && fgets(buffer, 2048, f)) { if ((pos=coord_parse(buffer, projection_mg, &c))) { @@ -344,22 +361,53 @@ navit_add_menu_former_destinationss(struct navit *this_, struct menu *men, struc struct coord *cn=g_new(struct coord, 1); *cn=c; buffer[strlen(buffer)-1]='\0'; - if (men) - menu_add(men, buffer+pos+1, menu_type_menu, navit_set_destination_menu, this_, cn); + s=buffer+pos+1; + if (!strncmp(s,"type=", 5)) { + i=index(s, '"'); + if (i) { + s=i+1; + i=index(s, '"'); + if (i) + *i='\0'; + } + } + if (rmen) { + i=s; + n=s; + men=rmen; + while ((i=index(n, '/'))) { + strcpy(buffer2, s); + buffer2[i-s]='\0'; + if (!(nmen=g_hash_table_lookup(h, buffer2))) { + nmen=menu_add(men, buffer2+(n-s), menu_type_submenu, NULL, NULL, NULL); + g_hash_table_insert(h, g_strdup(buffer2), nmen); + } + n=i+1; + men=nmen; + } + menu_add(men, n, menu_type_menu, navit_set_destination_menu, this_, cn); + } } flag=1; } } fclose(f); - if (flag) + if (route && flag) route_set_destination(route, &c); } + g_hash_table_destroy(h); } void navit_add_menu_former_destinations(struct navit *this_, struct menu *men, struct route *route) { - navit_add_menu_former_destinationss(this_, men ? menu_add(men, "Former Destinations", menu_type_submenu, NULL, NULL, NULL) : NULL, route); + navit_add_menu_destinations(this_, "destination.txt", men ? menu_add(men, "Former Destinations", menu_type_submenu, NULL, NULL, NULL) : NULL, route); +} + +void +navit_add_menu_bookmarks(struct navit *this_, struct menu *men) +{ + navit_add_menu_destinations(this_, "bookmark.txt", men ? menu_add(men, "Bookmarks", menu_type_submenu, NULL, NULL, NULL) : NULL, NULL); } void @@ -368,12 +416,10 @@ navit_speak(struct navit *this_) struct navigation *nav=this_->navigation; struct navigation_list *list; char *text; - printf("navit=%p\n", this_); list=navigation_list_new(nav); text=navigation_list_get(list, navigation_mode_speech); - printf("Hallo %s\n", text); - + speech_say(this_->speech, text); navigation_list_destroy(list); } @@ -399,12 +445,13 @@ navit_init(struct navit *this_) navit_add_menu_maps(this_, ms, men); } men=menu_add(this_->menubar, "Route", menu_type_submenu, NULL, NULL, NULL); - if (men) + if (men) { navit_add_menu_former_destinations(this_, men, this_->route); + navit_add_menu_bookmarks(this_, men); + } } } if (this_->navigation && this_->speech) { - printf("navit=%p navigation %p\n", this_, this_->navigation); this_->nav_speech_cb=callback_new(navit_speak, 1, &this_); navigation_register_callback(this_->navigation, navigation_mode_speech, this_->nav_speech_cb); } @@ -26,7 +26,11 @@ <speed type="ferry" value="40" /> </route> <navigation> - <announce type="water_poly" value="10" units="s" /> + <announce type="street_0,street_1_city" level0="10" level1="100" level2="200" unit="m" /> + <announce type="street_2_city,street_3_city,street_4_city,ramp" level0="20" level1="200" level2="500" unit="m" /> + <announce type="highway_city,street_1_land,street_2_land,street_3_land,street_4_land" level0="40" level1="400" level2="1000" unit="m" /> + <announce type="street_n_lanes,highway_land" level0="100" level1="1000" level2="2000" unit="m" /> + </navigation> <speech type="cmdline" data="echo 'Fix the speech tag in navit.xml to let navit say:' '%s'" /> <mapset> @@ -53,6 +53,20 @@ popup_set_destination(struct menu *menu, void *data1, void *data2) navit_set_destination(nav, c, buffer); } +static void +popup_set_bookmark(struct menu *menu, void *data1, void *data2) +{ + struct navit *nav=data1; + struct coord *c=data2; + struct coord_geo g; + char buffer[1024]; + char buffer_geo[1024]; + transform_to_geo(transform_get_projection(navit_get_trans(nav)), c, &g); + transform_geo_text(&g, buffer_geo); + sprintf(buffer,"Map Point %s", buffer_geo); + navit_add_bookmark(nav, c, buffer); +} + extern void *vehicle; @@ -106,6 +120,7 @@ popup_show_attr_val(void *menu, struct attr *attr) { char *attr_name=attr_to_name(attr->type); + printf("attr\n"); if (attr->type == attr_limit) popup_printf(menu, menu_type_menu, "%s: %d", attr_name, attr->u.num); else @@ -216,5 +231,6 @@ popup(struct navit *nav, int button, struct point *p) dbg(0,"%p %p\n", nav, &c); popup_printf_cb(men, menu_type_menu, popup_set_position, nav, &c, "Set as position"); popup_printf_cb(men, menu_type_menu, popup_set_destination, nav, &c, "Set as destination"); + popup_printf_cb(men, menu_type_menu, popup_set_bookmark, nav, &c, "Add as bookmark"); popup_display(nav, popup, p); } @@ -16,13 +16,11 @@ #include "item.h" #include "route.h" #include "track.h" +#include "point.h" #include "graphics.h" #include "transform.h" #include "fib.h" -#define route_item_first type_street_0 -#define route_item_last type_ferry - #if 0 static int speed_list[]={ 10, /* street_0 */ @@ -189,12 +187,11 @@ route_get_speedlist(struct route *this) int route_set_speed(struct route *this, enum item_type type, int value) { - int idx=type-route_item_first; - if (idx > route_item_last-route_item_first || idx < 0) { - dbg(0,"street idx(%d) out of range [0,%d]", idx, route_item_last-route_item_first); + if (type < route_item_first || type > route_item_last) { + dbg(0,"street type %d out of range [%d,%d]", type, route_item_first, route_item_last); return 0; } - this->speedlist[idx]=value; + this->speedlist[type-route_item_first]=value; return 1; } @@ -528,12 +525,11 @@ route_graph_destroy(struct route_graph *this) int route_time(int *speedlist, struct item *item, int len) { - int idx=(item->type-route_item_first); - if (idx > route_item_last-route_item_first || idx < 0) { - dbg(0,"street idx(%d) out of range [0,%d]", idx, route_item_last-route_item_first); + if (item->type < route_item_first || item->type > route_item_last) { + dbg(0,"street type %d out of range [%d,%d]", item->type, route_item_first, route_item_last); return len*36; } - return len*36/speedlist[idx]; + return len*36/speedlist[item->type-route_item_first]; } @@ -752,8 +748,8 @@ route_path_new(struct route_graph *this, struct route_info *pos, struct route_in printf("start->value=%d 0x%x,0x%x\n", start->value, start->c.x, start->c.y); #endif seg_len=s->len; + seg_time=route_time(speedlist, &s->item, seg_len); #if 0 - seg_time=route_time(&s->item, seg_len); time+=seg_time; #endif len+=seg_len; @@ -8,6 +8,10 @@ struct route_crossings { struct route_crossing crossing[0]; }; +#define route_item_first type_street_0 +#define route_item_last type_ferry + + /* prototypes */ enum item_type; struct coord; @@ -14,6 +14,7 @@ speech_new(const char *type, const char *data) struct speech *this_; struct speech_priv *(*speech_new)(const char *data, struct speech_methods *meth); + dbg("enter type=%s data=%s\n", type, data); speech_new=plugin_get_speech_type(type); dbg(1,"new=%p\n", speech_new); if (! speech_new) { @@ -21,6 +22,7 @@ speech_new(const char *type, const char *data) } this_=g_new0(struct speech, 1); this_->priv=speech_new(data, &this_->meth); + dbg(1, "say=%p\n", this_->meth.say); dbg(1,"priv=%p\n", this_->priv); if (! this_->priv) { g_free(this_); @@ -33,5 +35,6 @@ speech_new(const char *type, const char *data) int speech_say(struct speech *this_, const char *text) { + dbg(1, "this_=%p text='%s' calling %p\n", this_, text, this_->meth.say); return (this_->meth.say)(this_->priv, text); } diff --git a/speech/cmdline/speech_cmdline.c b/speech/cmdline/speech_cmdline.c index 6fb43008..936f3723 100644 --- a/speech/cmdline/speech_cmdline.c +++ b/speech/cmdline/speech_cmdline.c @@ -33,10 +33,8 @@ speechd_new(char *data, struct speech_methods *meth) { if (! data) return NULL; this=g_new(struct speech_priv,1); - if (this) { - this->cmdline=g_strdup(data); - *meth=speechd_meth; - } + this->cmdline=g_strdup(data); + *meth=speechd_meth; return this; } diff --git a/xmlconfig.c b/xmlconfig.c index 452c66a7..577cd1cc 100644 --- a/xmlconfig.c +++ b/xmlconfig.c @@ -266,6 +266,32 @@ xmlconfig_navigation(struct xmlstate *state) static int xmlconfig_announce(struct xmlstate *state) { + const char *type,*value; + char key[32]; + int level[3]; + int i; + enum item_type itype; + char *saveptr, *tok, *type_str, *str; + + type=find_attribute(state, "type", 1); + if (! type) + return 0; + for (i = 0 ; i < 3 ; i++) { + sprintf(key,"level%d", i); + value=find_attribute(state, key, 0); + if (value) + level[i]=convert_number(value); + else + level[i]=-1; + } + type_str=g_strdup(type); + str=type_str; + while ((tok=strtok_r(str, ",", &saveptr))) { + itype=item_from_name(tok); + navigation_set_announce(state->parent->element_object, itype, level); + str=NULL; + } + g_free(type_str); return 1; } diff --git a/xpm/Makefile.am b/xpm/Makefile.am index 2545d046..1c4507ca 100644 --- a/xpm/Makefile.am +++ b/xpm/Makefile.am @@ -1,3 +1,3 @@ include $(top_srcdir)/Makefile.inc -xpm_DATA = camping.xpm car_dealer.xpm fuel.xpm hospital.xpm hotel.xpm parking.xpm restaurant.xpm unknown.xpm +xpm_DATA = camping.xpm car_dealer.xpm flag_bk_tr.xpm flag_bk_wh.xpm flag_bl_wh.xpm fuel.xpm hospital.xpm hotel.xpm parking.xpm restaurant.xpm unknown.xpm EXTRA_DIST = $(xpm_DATA) diff --git a/xpm/flag_bk_tr.xpm b/xpm/flag_bk_tr.xpm new file mode 100644 index 00000000..a115ecd3 --- /dev/null +++ b/xpm/flag_bk_tr.xpm @@ -0,0 +1,27 @@ +/* XPM */ +static char *flag_bk_tr[] = { +"22 22 2 1 0 21", +" c None", +"+ c #000000", +"+++++++ ", +"+ +++++++++ ", +"+ +++ +++++++++ ", +"+ +++ +++ +++ ", +"++++ +++ +++ ", +"++++ +++ +++ ", +"++++ +++ +++ + ", +"+ ++++++ +++ + ", +"+ +++ ++++++ + ", +"+ +++ +++ +++ ", +"++++ +++ +++ ", +"++++ +++ +++ ", +"++++++++++ +++ + ", +"+ +++++++++ + ", +"+ ++++++ ", +"+ ", +"+ ", +"+ ", +"+ ", +"+ ", +"+ ", +"+ "}; diff --git a/xpm/flag_bk_wh.xpm b/xpm/flag_bk_wh.xpm new file mode 100644 index 00000000..6b87fa8d --- /dev/null +++ b/xpm/flag_bk_wh.xpm @@ -0,0 +1,28 @@ +/* XPM */ +static char *flag_bk_wh[]={ +"22 22 3 1 0 21", +" c None", +"+ c #000000", +"* c #ffffff", +"+++++++ ", +"+***+++++++++ ", +"+***+++***+++++++++ ", +"+***+++***+++***+++ ", +"++++******+++***+++ ", +"++++***+++******+++ ", +"++++***+++***+++**+ ", +"+***++++++***+++**+ ", +"+***+++***++++++**+ ", +"+***+++***+++***+++ ", +"++++******+++***+++ ", +"++++***+++******+++ ", +"++++++++++***+++**+ ", +"+ +++++++++**+ ", +"+ ++++++ ", +"+ ", +"+ ", +"+ ", +"+ ", +"+ ", +"+ ", +"+ "}; diff --git a/xpm/flag_bl_wh.xpm b/xpm/flag_bl_wh.xpm new file mode 100644 index 00000000..7fa9856f --- /dev/null +++ b/xpm/flag_bl_wh.xpm @@ -0,0 +1,28 @@ +/* XPM */ +static char *flag_bl_wh[]={ +"22 22 3 1 0 21", +" c None", +"+ c #0000ff", +"* c #ffffff", +"+++++++ ", +"+***+++++++++ ", +"+***+++***+++++++++ ", +"+***+++***+++***+++ ", +"++++******+++***+++ ", +"++++***+++******+++ ", +"++++***+++***+++**+ ", +"+***++++++***+++**+ ", +"+***+++***++++++**+ ", +"+***+++***+++***+++ ", +"++++******+++***+++ ", +"++++***+++******+++ ", +"++++++++++***+++**+ ", +"+ +++++++++**+ ", +"+ ++++++ ", +"+ ", +"+ ", +"+ ", +"+ ", +"+ ", +"+ ", +"+ "}; |