71
71
static GHashTable *stats;
74
options_gconf_key (const char *game_file)
74
options_gconf_key (const char *game_module)
76
76
static const char basekey[] = "/apps/aisleriot/rules/";
78
return g_strconcat (basekey, game_file, NULL);
78
return g_strdelimit (g_strconcat (basekey, game_module, ".scm", NULL), "-", '_');
82
game_module_to_game_name (const char *game_module)
86
game_name = g_strdelimit (g_strconcat (game_module, ".scm", NULL), "-", '_');
225
235
GConfValue *value;
228
gconf_key = options_gconf_key (game_file);
238
gconf_key = options_gconf_key (game_module);
229
239
entry = gconf_client_get_entry (gconf_client, gconf_key, NULL, TRUE, NULL);
230
240
g_free (gconf_key);
246
256
GError *error = NULL;
248
*options = ar_conf_get_integer (game_file, "Options", &error);
259
game_name = game_module_to_game_name (game_module);
260
*options = ar_conf_get_integer (game_name, "Options", &error);
250
263
g_error_free (error);
259
aisleriot_conf_set_options (const char *game_file,
272
aisleriot_conf_set_options (const char *game_module,
262
275
#ifdef HAVE_GNOME
263
276
GConfSchema *schema;
264
277
char *gconf_key, *schemas_key;
266
gconf_key = options_gconf_key (game_file);
279
gconf_key = options_gconf_key (game_module);
268
281
schemas_key = g_strconcat ("/schemas", gconf_key, NULL);
296
309
gconf_client_set_int (gconf_client, gconf_key, value, NULL);
297
310
g_free (gconf_key);
299
ar_conf_set_integer (game_file, "Options", value);
314
game_name = game_module_to_game_name (game_module);
315
ar_conf_set_integer (game_name, "Options", value);
300
317
#endif /* HAVE_GNOME */
304
aisleriot_conf_get_statistic (const char *game_file,
321
aisleriot_conf_get_statistic (const char *game_module,
305
322
AisleriotStatistic *statistic)
307
324
#ifdef HAVE_GNOME
308
325
AisleriotStatistic *game_stat;
310
game_stat = g_hash_table_lookup (stats, game_file);
328
game_name = game_module_to_game_name (game_module);
330
game_stat = g_hash_table_lookup (stats, game_name);
311
331
if (!game_stat) {
312
332
char *display_name;
314
334
/* Previous versions used the localised name as key, so try it as fall-back.
315
335
* See bug #406267 and bug #525177.
317
display_name = ar_filename_to_display_name (game_file);
337
display_name = ar_filename_to_display_name (game_module);
318
338
game_stat = g_hash_table_lookup (stats, display_name);
319
339
g_free (display_name);
325
345
memset (statistic, 0, sizeof (AisleriotStatistic));
332
354
GError *error = NULL;
357
game_name = game_module_to_game_name (game_module);
334
359
memset (statistic, 0, sizeof (AisleriotStatistic));
336
values = ar_conf_get_integer_list (game_file, "Statistic", &len, &error);
361
values = ar_conf_get_integer_list (game_name, "Statistic", &len, &error);
338
363
g_error_free (error);
361
389
#endif /* HAVE_GNOME */
365
aisleriot_conf_set_statistic (const char *game_file,
393
aisleriot_conf_set_statistic (const char *game_module,
366
394
AisleriotStatistic *statistic)
368
396
#ifdef HAVE_GNOME
369
397
AisleriotStatistic *game_stat;
371
game_stat = g_hash_table_lookup (stats, game_file);
400
game_name = game_module_to_game_name (game_module);
402
game_stat = g_hash_table_lookup (stats, game_name);
372
403
/* Backward compatibility with buggy old aisleriot versions
373
404
* which stored the localised game name.
375
406
if (!game_stat) {
376
407
char *localised_name;
378
localised_name = ar_filename_to_display_name (game_file);
409
localised_name = ar_filename_to_display_name (game_module);
379
410
game_stat = g_hash_table_lookup (stats, localised_name);
380
411
g_free (localised_name);
383
414
if (!game_stat) {
384
415
game_stat = g_new0 (AisleriotStatistic, 1);
385
g_hash_table_insert (stats, g_strdup (game_file), game_stat);
416
g_hash_table_insert (stats, g_strdup (game_name), game_stat);
388
419
*game_stat = *statistic;
390
421
save_statistics ();
430
game_name = game_module_to_game_name (game_module);
396
432
values[0] = statistic->wins;
397
433
values[1] = statistic->total;
398
434
values[2] = statistic->best;
399
435
values[3] = statistic->worst;
401
ar_conf_set_integer_list (game_file, "Statistic", values, G_N_ELEMENTS (values));
437
ar_conf_set_integer_list (game_name, "Statistic", values, G_N_ELEMENTS (values));
402
440
#endif /* HAVE_GNOME */