/**
 * defkey_cb
 * @widget: widget
 * @data: callback data
 *
 * Description:
 * handles message from the default key buttons
 **/
static void
defkey_cb (GtkWidget * widget, gpointer data)
{
  gint i;
  guint *dkeys = (guint *) data;

  for (i = 0; i < 12; ++i) {
    properties.keys[i] = dkeys[i];
    conf_set_control_key (i, properties.keys[i]);
  }
  keyboard_set (properties.keys);
}
/**
 * load_properties
 *
 * Description:
 * loads the game properties from a file
 *
 * Returns:
 * TRUE if the properties can be loaded, FALSE otherwise
 **/
gboolean
load_properties (void)
{
  gchar *cname = NULL;
  gint i;
  gchar *bgcolour;

  load_keys ();

  bgcolour = games_conf_get_string_with_default (KEY_PREFERENCES_GROUP,
                                                 KEY_BACKGROUND_COLOR, "#7590AE");
  gdk_color_parse (bgcolour, &properties.bgcolour);
  set_background_color (properties.bgcolour);

  properties.themename = games_conf_get_string_with_default (KEY_PREFERENCES_GROUP,
                                                             KEY_THEME, "robots");

  cname = games_conf_get_string_with_default (KEY_PREFERENCES_GROUP,
                                              KEY_CONFIGURATION, "classic_robots");

  properties.selected_config = 0;
  for (i = 0; i < num_game_configs (); ++i) {
    if (!strcmp (cname, game_config_name (i))) {
      properties.selected_config = i;
      break;
    }
  }
  g_free (cname);

  properties.safe_moves = games_conf_get_boolean (KEY_PREFERENCES_GROUP,
						  KEY_SAFE_MOVES, NULL);
  properties.super_safe_moves = games_conf_get_boolean (KEY_PREFERENCES_GROUP,
						        KEY_SUPER_SAFE_MOVES,
						        NULL);
  properties.sound = games_conf_get_boolean (KEY_PREFERENCES_GROUP,
                                             KEY_ENABLE_SOUND, NULL);
  properties.show_toolbar = games_conf_get_boolean (KEY_PREFERENCES_GROUP,
                                                    KEY_SHOW_TOOLBAR, NULL);

  games_sound_enable (properties.sound);
  set_game_graphics (properties.themename);
  set_game_config (properties.selected_config);
  keyboard_set (properties.keys);
  return TRUE;
}
Example #3
0
/**
 * defkey_cb
 * @widget: widget
 * @data: callback data
 *
 * Description:
 * handles message from the default key buttons
 **/
static void
defkey_cb (GtkWidget * widget, gpointer data)
{
  gint i;

  for (i = 0; i < N_KEYS; ++i) {
    GVariant *variant;
    char buffer[64];

    g_snprintf (buffer, sizeof (buffer), KEY_CONTROL_KEY, i);
    g_settings_reset (settings, buffer);
    variant = g_settings_get_default_value (settings, buffer);
    properties.keys[i] = g_variant_get_int32 (variant);
    g_variant_unref (variant);
  }

  keyboard_set (properties.keys);
}
Example #4
0
/**
 * load_properties
 *
 * Description:
 * loads the game properties from a file
 *
 * Returns:
 * TRUE if the properties can be loaded, FALSE otherwise
 **/
gboolean
load_properties (void)
{
  gchar *cname = NULL;
  gint i;
  gchar *bgcolour, *config;

  load_keys ();

  bgcolour = g_settings_get_string (settings, KEY_BACKGROUND_COLOR);
  gdk_rgba_parse (&properties.bgcolour, bgcolour);
  set_background_color (properties.bgcolour);

  properties.themename = g_settings_get_string (settings, KEY_THEME);

  cname = g_settings_get_string (settings, KEY_CONFIGURATION);

  properties.selected_config = 0;
  for (i = 0; i < num_game_configs (); ++i) {
    config = game_config_name (i);
    if (!strcmp (cname, config)) {
      g_free (config);
      properties.selected_config = i;
      break;
    }
    g_free (config);
  }
  g_free (cname);

  properties.safe_moves = g_settings_get_boolean (settings,
						  KEY_SAFE_MOVES);
  properties.super_safe_moves = g_settings_get_boolean (settings,
						        KEY_SUPER_SAFE_MOVES);
  properties.sound = g_settings_get_boolean (settings,
                                             KEY_ENABLE_SOUND);
  properties.show_toolbar = g_settings_get_boolean (settings,
                                                    KEY_SHOW_TOOLBAR);

  load_game_graphics ();
  set_game_config (properties.selected_config);
  keyboard_set (properties.keys);
  return TRUE;
}
/**
 * apply_changes
 *
 * Description:
 * Applies the changes made by the user
 **/
static void
apply_changes (void)
{
  load_keys ();
  keyboard_set (properties.keys);
}