Exemple #1
0
/**************************************************************************
  Entry point of the freeciv-modpack program
**************************************************************************/
int main(int argc, char *argv[])
{
  GtkWidget *toplevel;
  int loglevel = LOG_NORMAL;
  int ui_options;

  init_nls();
  init_character_encodings(FC_DEFAULT_DATA_ENCODING, FALSE);

  fc_init_network();
  
  g_thread_init(NULL);

  log_init(NULL, loglevel, NULL, NULL, -1);

  /* This modifies argv! */
  ui_options = fcmp_parse_cmdline(argc, argv);

  if (ui_options != -1) {

    /* Process GTK arguments */
    gtk_init(&ui_options, &argv);

    toplevel = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    gtk_widget_realize(toplevel);
    gtk_widget_set_name(toplevel, "Freeciv-modpack");
    gtk_window_set_title(GTK_WINDOW(toplevel), _("Freeciv modpack installer"));

    /* Keep the icon of the executable on Windows */
#ifndef WIN32_NATIVE
    {
      /* Unlike main client, this only works if installed. Ignore any
       * errors loading the icon. */
      GError *err;
      (void) gtk_window_set_icon_from_file(GTK_WINDOW(toplevel), MPICON_PATH,
                                           &err);
    }
#endif /* WIN32_NATIVE */

    g_signal_connect(toplevel, "delete_event",
                     G_CALLBACK(quit_dialog_callback), NULL);

    modinst_setup_widgets(toplevel);

    gtk_widget_show_all(toplevel);

    gtk_main();
  }

  return EXIT_SUCCESS;
}
Exemple #2
0
/**************************************************************************
  Main entry point for freeciv-ruledit
**************************************************************************/
int main(int argc, char **argv)
{
  enum log_level loglevel = LOG_NORMAL;
  int ui_options;

  init_nls();

#ifdef ENABLE_NLS
  (void) bindtextdomain("freeciv-ruledit", LOCALEDIR);
#endif

  registry_module_init();
  init_character_encodings(FC_DEFAULT_DATA_ENCODING, FALSE);

  log_init(NULL, loglevel, NULL, NULL, -1);

  ui_options = re_parse_cmdline(argc, argv);

  if (ui_options != -1) {
    init_connections();

    settings_init(FALSE);

    /* Reset aifill to zero */
    game.info.aifill = 0;

    game_init();
    i_am_server();

    if (source_rs !=  NULL) {
      sz_strlcpy(game.server.rulesetdir, source_rs);
    }

    if (load_rulesets(NULL, FALSE)) {
      log_normal("Terrains:     %d", game.control.terrain_count);
      log_normal("Resources:    %d", game.control.resource_count);
      log_normal("Techs:        %d", game.control.num_tech_types);
      log_normal("Unit classes: %d", game.control.num_unit_classes);
      log_normal("Unit types:   %d", game.control.num_unit_types);
      log_normal("Buildings:    %d", game.control.num_impr_types);
      log_normal("Nations:      %d", game.control.nation_count);
      log_normal("City Styles:  %d", game.control.styles_count);
      log_normal("Specialists:  %d", game.control.num_specialist_types);
      log_normal("Governments:  %d", game.control.government_count);
      log_normal("Disasters:    %d", game.control.num_disaster_types);
      log_normal("Achievements: %d", game.control.num_achievement_types);
      log_normal("Extras:       %d", game.control.num_extra_types);
      log_normal("Bases:        %d", game.control.num_base_types);
      log_normal("Roads:        %d", game.control.num_road_types);

      ruledit_qt_setup(ui_options, argv);
      ruledit_qt_run();
      ruledit_qt_close();
    } else {
      log_error("Loading ruleset %s failed", game.server.rulesetdir);
    }
  }

  log_close();
  registry_module_close();

  return EXIT_SUCCESS;
}