From 358708fe521d9d31c11b9d10c65c4bd8985cd7bf Mon Sep 17 00:00:00 2001 From: martin-s Date: Mon, 22 Feb 2010 09:02:21 +0000 Subject: [PATCH] Add:Core:Script Command to set destination git-svn-id: https://navit.svn.sourceforge.net/svnroot/navit/trunk@2958 ffa7fe5e-494d-0410-b361-a75ebd5db220 --- navit/navit/attr.h | 1 + navit/navit/navit.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/navit/navit/attr.h b/navit/navit/attr.h index 6c357d9..b433fe8 100644 --- a/navit/navit/attr.h +++ b/navit/navit/attr.h @@ -85,6 +85,7 @@ enum attr_position_valid { #define ATTR_IS_NUMERIC(x) (ATTR_IS_INT(x) || ATTR_IS_DOUBLE(x)) #define ATTR_IS_COLOR(x) ((x) >= attr_type_color_begin && (x) <= attr_type_color_end) #define ATTR_IS_PCOORD(x) ((x) >= attr_type_pcoord_begin && (x) <= attr_type_pcoord_end) +#define ATTR_IS_COORD(x) ((x) >= attr_type_coord_begin && (x) <= attr_type_coord_end) struct attr { enum attr_type type; diff --git a/navit/navit/navit.c b/navit/navit/navit.c index 49cf60a..d4bfbc7 100644 --- a/navit/navit/navit.c +++ b/navit/navit/navit.c @@ -632,6 +632,7 @@ navit_cmd_zoom_out(struct navit *this_) return 0; } + static void navit_cmd_say(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) { @@ -639,12 +640,46 @@ navit_cmd_say(struct navit *this, char *function, struct attr **in, struct attr navit_say(this, in[0]->u.str); } +static void +navit_cmd_set_destination(struct navit *this, char *function, struct attr **in, struct attr ***out, int *valid) +{ + struct pcoord pc; + char *description=NULL; + if (!in) + return; + if (!in[0]) + return; + pc.pro = transform_get_projection(this->trans); + if (ATTR_IS_COORD(in[0]->type)) { + pc.x=in[0]->u.coord->x; + pc.y=in[0]->u.coord->y; + in++; + } else if (ATTR_IS_PCOORD(in[0]->type)) { + pc=*in[0]->u.pcoord; + in++; + } else if (in[1] && in[2] && ATTR_IS_INT(in[0]->type) && ATTR_IS_INT(in[1]->type) && ATTR_IS_INT(in[2]->type)) { + pc.pro=in[0]->u.num; + pc.x=in[1]->u.num; + pc.y=in[2]->u.num; + in+=3; + } else if (in[1] && ATTR_IS_INT(in[0]->type) && ATTR_IS_INT(in[1]->type)) { + pc.x=in[0]->u.num; + pc.y=in[1]->u.num; + in+=2; + } else + return; + if (in[0] && ATTR_IS_STRING(in[0]->type)) + description=in[0]->u.str; + navit_set_destination(this, &pc, description, 1); +} + static struct command_table commands[] = { {"zoom_in",command_cast(navit_cmd_zoom_in)}, {"zoom_out",command_cast(navit_cmd_zoom_out)}, {"zoom_to_route",command_cast(navit_cmd_zoom_to_route)}, {"say",command_cast(navit_cmd_say)}, {"set_center_cursor",command_cast(navit_cmd_set_center_cursor)}, + {"set_destination",command_cast(navit_cmd_set_destination)}, {"announcer_toggle",command_cast(navit_cmd_announcer_toggle)}, }; -- 2.7.4