forked from mkoloberdin/waze
-
Notifications
You must be signed in to change notification settings - Fork 0
/
roadmap_car.c
160 lines (130 loc) · 4.28 KB
/
roadmap_car.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/* roadmap_car.c - Manage car selection
*
* LICENSE:
*
* Copyright 2006 Ehud Shabtai
*
* This file is part of RoadMap.
*
* RoadMap is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* RoadMap is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RoadMap; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* SYNOPSYS:
*
* See roadmap_car.h
*/
#include <string.h>
#include <stdlib.h>
#include "roadmap.h"
#include "roadmap_types.h"
#include "roadmap_history.h"
#include "roadmap_locator.h"
#include "roadmap_street.h"
#include "roadmap_lang.h"
#include "roadmap_geocode.h"
#include "roadmap_trip.h"
#include "roadmap_lang.h"
#include "roadmap_display.h"
#include "roadmap_config.h"
#include "roadmap_path.h"
#include "roadmap_navigate.h"
#include "roadmap_analytics.h"
#include "ssd/ssd_keyboard_dialog.h"
#include "ssd/ssd_generic_list_dialog.h"
#ifdef IPHONE
#include "iphone/roadmap_list_menu.h"
#endif //IPHONE
#define MAX_CAR_ENTRIES 40
typedef struct {
const char *title;
RoadMapCallback callback;
} roadmap_car_list_dialog;
typedef struct {
char *value;
char *label;
char *icon;
} roadmap_car_list;
///////////////////////////////////////////////////////////////////////////////////////////
static int roadmap_car_call_back (SsdWidget widget, const char *new_value, const void *value, void *context) {
roadmap_car_list_dialog *list_context = (roadmap_car_list_dialog *)context;
RoadMapConfigDescriptor CarCfg =
ROADMAP_CONFIG_ITEM("Trip", "Car");
roadmap_config_declare
("user", &CarCfg, "car_blue", NULL);
roadmap_analytics_log_event(ANALYTICS_EVENT_CAR, ANALYTICS_EVENT_INFO_CHANGED_TO, value);
roadmap_config_set (&CarCfg, value);
#ifndef IPHONE
ssd_generic_list_dialog_hide ();
#else
roadmap_main_show_root(0);
#endif
if (list_context->callback)
(*list_context->callback)();
return 1;
}
#ifndef IPHONE
///////////////////////////////////////////////////////////////////////////////////////////
void roadmap_car_dialog (RoadMapCallback callback) {
char **files;
const char *cursor;
char **cursor2;
char* png_name;
char *directory = NULL;
int count = 0;
static roadmap_car_list_dialog context = {"roadmap_car", NULL};
static char *labels[MAX_CAR_ENTRIES] ;
static void *values[MAX_CAR_ENTRIES] ;
static void *icons[MAX_CAR_ENTRIES];
context.callback = callback;
for (cursor = roadmap_path_first ("skin");
cursor != NULL;
cursor = roadmap_path_next ("skin", cursor)) {
directory = roadmap_path_join (cursor, "cars");
files = roadmap_path_list (directory, ".png");
if ( *files == NULL )
{
// Try without extension
files = roadmap_path_list ( directory, NULL );
}
for (cursor2 = files; *cursor2 != NULL; ++cursor2) {
if (strstr(*cursor2, "_3D"))
continue;
values[count] = strtok(*cursor2,".");
png_name = malloc( strlen( (char*) values[count] ) + strlen( ".png" ) + 1 ); // Leaked
sprintf( png_name, "%s.png", (char*) values[count] );
labels[count] = (char *) roadmap_lang_get( png_name );
icons[count] = roadmap_path_join("cars", *cursor2);
count++;
}
}
free (directory);
ssd_generic_icon_list_dialog_show (roadmap_lang_get ("Select your car"),
count,
(const char **)labels,
(const void **)values,
(const char **)icons,
NULL,
roadmap_car_call_back,
NULL,
&context,
NULL,
NULL,
ADJ_SCALE(70),
0,
FALSE);
}
void roadmap_car(void){
roadmap_car_dialog(NULL);
}
#endif //IPHONE