Example #1
0
int main(int argc, char ** argv)
{
    QApplication * app = new QApplication(argc, argv);

    int cx = -1;
    int cy = -1;
    int w = QApplication::desktop()->width();
    int h = QApplication::desktop()->height();

    QSettings settings(QSettings::IniFormat, QSettings::UserScope, "DoUML", "settings");
    settings.setIniCodec(QTextCodec::codecForName("UTF-8"));
    int uid = settings.value("Main/id", -1).toInt();
    int l, t, r, b;
    l = settings.value("Desktop/left", -1).toInt();
    r = settings.value("Desktop/right", -1).toInt();
    t = settings.value("Desktop/top", -1).toInt();
    b = settings.value("Desktop/bottom", -1).toInt();

    if(l != -1 && r != -1 && t != -1 && b != -1)
    {
      if (!((r == 0) && (t == 0) && (r == 0) && (b == 0)) &&
          !((r < 0) || (t < 0) || (r < 0) || (b < 0)) &&
          !((r <= l) || (b <= t)))
      {
        cx = (r + l) / 2;
        cy = (t + b) / 2;
        w = r - l;
        h = b - t;
      }
    }

    if (uid == -1)
        QMessageBox::critical(0, "Synchro project", "Own identifier not defined");
    else if ((uid < 2) || (uid > 127))
        QMessageBox::critical(0, "Synchro project", "invalid Identifier");
    else {
        set_user_id(uid, homeDir.dirName());
        app->connect(app, SIGNAL(lastWindowClosed()), SLOT(quit()));
        init_pixmaps();

        SynchroWindow * ww = new SynchroWindow();

        ww->resize((w * 3) / 5, (h * 3) / 5);

        if (cx != -1)
            ww->move(ww->x() + cx - (ww->x() + ww->width() / 2),
                     ww->y() + cy - (ww->y() + ww->height() / 2));

        ww->show();

        if (argc > 1)
            ww->load(argc - 1, argv + 1);

        app->exec();
    }

    return 0;
}
Example #2
0
void
initrock(Window win)
{
  rockstruct *rp = &rocks[screen];
  unsigned int i;
  static int first = 1;
  XWindowAttributes xgwa;

  (void) XGetWindowAttributes(dsp, win, &xgwa);

  rp->width = xgwa.width;
  rp->height = xgwa.height;
  rp->midx = rp->width / 2;
  rp->midy = rp->height / 2;
  rp->speed = 100;
  rp->rotate_p = False;
  rp->move_p = False;
  rp->dep_x = 0;
  rp->dep_y = 0;
  if (batchcount < 1)
    batchcount = 1;
  rp->nrocks = batchcount;
  if (rp->speed < 1) rp->speed = 1;
  if (rp->speed > 100) rp->speed = 100;

  if (first) {
    first = 0;
    for (i = 0; i < RESOLUTION; i++) {
      sin_array[i] = sin((((double) i) / (RESOLUTION / 2)) * M_PI);
      cos_array[i] = cos((((double) i) / (RESOLUTION / 2)) * M_PI);
    }
    /* we actually only need i/speed of these, but wtf */
    for (i = 1; i < (sizeof(depths) / sizeof(depths[0])); i++)
      depths[i] = atan(((double) 0.5) / (((double) i) / DEPTH_SCALE));
    depths[0] = M_PI_2; /* avoid division by 0 */
  }
  if (!rp->arocks) {
    rp->arocks = (arock *) calloc(rp->nrocks, sizeof(arock));
    init_pixmaps(win);
  }
  XSetForeground(dsp, Scr[screen].gc, BlackPixel(dsp, screen));
  XFillRectangle(dsp, win, Scr[screen].gc, 0, 0, rp->width, rp->height);
}
Example #3
0
static void *
rocks_init (Display *d, Window w)
{
  struct state *st = (struct state *) calloc (1, sizeof(*st));
  int i;
  XGCValues gcv;
  Colormap cmap;
  XWindowAttributes xgwa;
  unsigned int bg;
  st->dpy = d;
  st->window = w;
  XGetWindowAttributes (st->dpy, st->window, &xgwa);

  st->width = xgwa.width;
  st->height = xgwa.height;
  st->midx = st->width/2;
  st->midy = st->height/2;

  cmap = xgwa.colormap;
  st->delay = get_integer_resource (st->dpy, "delay", "Integer");
  if (st->delay < 0) st->delay = 0;
  st->speed = get_integer_resource (st->dpy, "speed", "Integer");
  if (st->speed < 1) st->speed = 1;
  if (st->speed > 100) st->speed = 100;
  st->rotate_p = get_boolean_resource (st->dpy, "rotate", "Boolean");
  st->move_p = get_boolean_resource (st->dpy, "move", "Boolean");
  if (mono_p)
    st->ncolors = 2;
  else
    st->ncolors = get_integer_resource (st->dpy, "colors", "Colors");

  if (st->ncolors < 2)
    {
      st->ncolors = 2;
      mono_p = True;
  }

  st->colors = (XColor *) malloc(st->ncolors * sizeof(*st->colors));
  st->draw_gcs = (GC *) malloc(st->ncolors * sizeof(*st->draw_gcs));

  bg = get_pixel_resource (st->dpy, cmap, "background", "Background");
  st->colors[0].pixel = bg;
  st->colors[0].flags = DoRed|DoGreen|DoBlue;
  XQueryColor(st->dpy, cmap, &st->colors[0]);

  st->ncolors--;
  make_random_colormap(xgwa.screen, xgwa.visual, cmap,
                       st->colors+1, &st->ncolors, True,
		       True, 0, True);
  st->ncolors++;

  if (st->ncolors < 2)
    {
      st->ncolors = 2;
      mono_p = True;
  }

  if (mono_p)
    {
      unsigned int fg = get_pixel_resource(st->dpy, cmap, "foreground", "Foreground");
      st->colors[1].pixel = fg;
      st->colors[1].flags = DoRed|DoGreen|DoBlue;
      XQueryColor(st->dpy, cmap, &st->colors[1]);
      gcv.foreground = fg;
      gcv.background = bg;
      st->draw_gcs[0] = XCreateGC (st->dpy, st->window, GCForeground|GCBackground, &gcv);
      st->draw_gcs[1] = st->draw_gcs[0];
    }
  else
    for( i = 0; i < st->ncolors; i++ )
      {
	gcv.foreground = st->colors[i].pixel;
	gcv.background = bg;
	st->draw_gcs[i] = XCreateGC (st->dpy, st->window, GCForeground|GCBackground, &gcv);
      }

  gcv.foreground = bg;
  st->erase_gc = XCreateGC (st->dpy, st->window, GCForeground|GCBackground, &gcv);

  st->max_dep = (st->move_p ? MAX_DEP : 0);

  for (i = 0; i < SIN_RESOLUTION; i++)
    {
      st->sins [i] = sin ((((double) i) / (SIN_RESOLUTION / 2)) * M_PI);
      st->coss [i] = cos ((((double) i) / (SIN_RESOLUTION / 2)) * M_PI);
    }
  /* we actually only need i/speed of these, but wtf */
  for (i = 1; i < (sizeof (st->depths) / sizeof (st->depths[0])); i++)
    st->depths [i] = atan (((double) 0.5) / (((double) i) / DEPTH_SCALE));
  st->depths [0] = M_PI/2; /* avoid division by 0 */

  st->threed = get_boolean_resource(st->dpy, "use3d", "Boolean");
  if (st->threed)
    {
      gcv.background = bg;
      gcv.foreground = get_pixel_resource (st->dpy, cmap, "left3d", "Foreground");
      st->threed_left_gc = XCreateGC (st->dpy, st->window, GCForeground|GCBackground,&gcv);
      gcv.foreground = get_pixel_resource (st->dpy, cmap, "right3d", "Foreground");
      st->threed_right_gc = XCreateGC (st->dpy, st->window,GCForeground|GCBackground,&gcv);
      st->threed_delta = get_float_resource(st->dpy, "delta3d", "Integer");
    }

  /* don't want any exposure events from XCopyPlane */
  for( i = 0; i < st->ncolors; i++)
    XSetGraphicsExposures (st->dpy, st->draw_gcs[i], False);
  XSetGraphicsExposures (st->dpy, st->erase_gc, False);

  st->nrocks = get_integer_resource (st->dpy, "count", "Count");
  if (st->nrocks < 1) st->nrocks = 1;
  st->rocks = (struct rock *) calloc (st->nrocks, sizeof (struct rock));
  init_pixmaps (st);
  XClearWindow (st->dpy, st->window);
  return st;
}
Example #4
0
int main(int argc, char ** argv)
{

    ExitOnError = FALSE;

    QApplication a(argc, argv);

    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

//#ifdef DEBUG
    QsLogging::Logger & logger = QsLogging::Logger::instance();
    logger.setLoggingLevel(QsLogging::TraceLevel);
    QDir dir;
    dir.setPath(qApp->applicationDirPath());
    dir.remove(QString("douml") + QString(".log"));
    const QString sLogPath(QDir(qApp->applicationDirPath()).filePath(QString("douml") + QString(".log")));
    QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination(sLogPath));
    QsLogging::DestinationPtr debugDestination(QsLogging::DestinationFactory::MakeDebugOutputDestination());
    logger.addDestination(debugDestination.get());
    logger.addDestination(fileDestination.get());
    QLOG_INFO() << "Starting the log";
//#endif


    An<EdgeMenuFactory> factory;
    factory->AddFactory(TypeIdentifier<ClassDialog>::id(), CreateClassDialogMenu);
    factory->AddConnectionFunctor(TypeIdentifier<ClassDialog>::id(), ConnectToClassDialog<EdgeMenuDialog>);
    factory->AddFactory(TypeIdentifier<OperationDialog>::id(), CreateClassDialogMenu);
    factory->AddConnectionFunctor(TypeIdentifier<OperationDialog>::id(), ConnectToClassDialog<EdgeMenuDialog>);
    factory->AddFactory(TypeIdentifier<ArtifactDialog>::id(), CreateLimitedDialogMenu);
    factory->AddConnectionFunctor(TypeIdentifier<ArtifactDialog>::id(), ConnectToLimitedDialog<EdgeMenuDialog>);
    factory->AddFactory(TypeIdentifier<ConstructorInitializerDialog>::id(), CreateLimitedDialogMenu);
    factory->AddConnectionFunctorQt4(TypeIdentifier<ConstructorInitializerDialog>::id(), ConnectToLimitedDialog<EdgeMenuDialogQt4>);


    UmlDesktop::init();
    QSettings settings("settings.ini", QSettings::IniFormat);
    settings.setIniCodec(QTextCodec::codecForName("UTF-8"));
    bool overridePresent = QFileInfo("override_transition.txt").exists();
    if(settings.value("Main/compatibility_save") .toInt() == 1 && !overridePresent)
    {
    QMessageBox::warning(0, QObject::tr("Warning"),
                         QObject::tr("Douml is working in transitional mode.\n All UI improvements are yours to use,  "
                                     "but saving is done in the format of Bouml 4.22 "
                                     "which loses all new c++11 and hierarchy specifiers\n\n"
                                     "To suppress this warning place empty file override_transition.txt into the application folder\n"
                                     "To disable the mode - change compatibility_save parameter to 0 in settings.ini\n"));
    }

    // note : bool conv_env = !QDir::home().exists(".doumlrc") doesn't work
    // if the path contains non latin1 characters, for instance cyrillic !
    QString s = QDir::home().absFilePath(".doumlrc");
    FILE * fp = fopen((const char *) s, "r");
    bool conv_env = (fp == 0);


    if (conv_env)
        EnvDialog::edit(TRUE);
    else
        fclose(fp);

    read_doumlrc();	// for virtual desktop
    init_pixmaps();
    init_font();
    Shortcut::init(conv_env);

    bool exec = FALSE;
    bool no_gui = FALSE;

    if (argc > 3) {
        if (!strcmp(argv[2], "-execnogui"))
            exec = no_gui = TRUE;
        else
            exec = !strcmp(argv[2], "-exec");
    }

    UmlWindow * uw = new UmlWindow(exec);

    if (no_gui)
        UmlDesktop::set_nogui();
    else
    {
        uw->showMaximized();
    }

    if (argc > 1) {
        try {
            if ((argc == 3) &&
                !strcmp(argv[2], "-root") &&
                (msg_critical(TR("DO NOT CONFIRM"),
                              TR("Root mode protection\n\n"
                                 "This mode allows me to develop BOUML\n\n"
                                 "do NOT confirm to avoid a disaster !!!\n\n"
                                 "confirm ?"),
                              QMessageBox::Yes, QMessageBox::No)
                 == QMessageBox::Yes)) {
                set_user_id(0);
                set_editor(getenv("BOUML_EDITOR")); // no environment file
                argc = 1;
            }

            uw->load_it(argv[1]);
        }
        catch (...) {
            // cannot read a file
            return -1;

        }
    }

    QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));

    try {
        if (argc > 2) {
            if (exec) {
                bool with_exit = FALSE;

                if (!strcmp(argv[argc - 1], "-exit")) {
                    with_exit = TRUE;
                    argc -= 1;
                }

                WrapperStr cmd = argv[3];
                WrapperStr space = " ";
                int index;

                for (index = 4; index != argc; index += 1)
                    cmd += space + WrapperStr(argv[index]);

                ToolCom::run((const char *) cmd, BrowserView::get_project(), with_exit);
            }
            else
                msg_warning(TR("Error"), TR("Bouml was called with wrong parameters, ignore them"));
        }


        ExitOnError = TRUE;
        a.exec();
    }
    catch (...) {
        ;
    }


    return exit_value();
}
Example #5
0
int main(int argc, char ** argv)
{
    QApplication * app = new QApplication(argc, argv);

    int uid = -1;
    // note : QFile fp(QDir::home().absFilePath(".boumlrc")) doesn't work
    // if the path contains non latin1 characters, for instance cyrillic !
    QDir homeDir = QDir::home();
    QString s = homeDir.absFilePath(".boumlrc");
    FILE * fp = fopen((const char *) s, "r");


















    int cx = -1;
    int cy = -1;
    int w = QApplication::desktop()->width();
    int h = QApplication::desktop()->height();

    if (fp != 0) {
        char line[512];

        while (fgets(line, sizeof(line) - 1, fp) != 0) {
            remove_crlf(line);

            if (!strncmp(line, "ID ", 3)) {
                sscanf(line+3, "%d", &uid);
                break;
            }
            else if (!strncmp(line, "DESKTOP ", 8)) {
                int l, t, r, b;

                if (sscanf(line+8, "%d %d %d %d", &l, &t, &r, &b) == 4) {
                    if (!((r == 0) && (t == 0) && (r == 0) && (b == 0)) &&
                            !((r < 0) || (t < 0) || (r < 0) || (b < 0)) &&
                            !((r <= l) || (b <= t))) {
                        cx = (r + l) / 2;
                        cy = (t + b) / 2;
                        w = r - l;
                        h = b - t;
                    }
                }
            }
        }

        fclose(fp);
    }

    if (uid == -1)
        QMessageBox::critical(0, "Control project", "Own identifier not defined");
    else if ((uid < 2) || (uid > 127))
        QMessageBox::critical(0, "Control project", "invalid Identifier");
    else {
        set_user_id(uid, homeDir.dirName());
        app->connect(app, SIGNAL(lastWindowClosed()), SLOT(quit()) );
        init_pixmaps();

        ControlWindow * ww = new ControlWindow(homeDir);

        ww->resize((w * 3)/5, (h * 3)/5);

        if (cx != -1)
            ww->move(ww->x() + cx - (ww->x() + ww->width() / 2),
                     ww->y() + cy - (ww->y() + ww->height() / 2));

        ww->show();

        app->exec();
    }

    return 0;
}
Example #6
0
int
lincity_main (int argc, char *argv[])
{
#if defined (LC_X11)
    char *geometry = NULL;
#endif

#if defined (SVGALIB)
    int q;
    vga_init ();
#endif

#if !defined (WIN32)
    signal (SIGPIPE, SIG_IGN);    /* broken pipes are ignored. */
#endif

    /* Initialize some global variables */
    make_dir_ok_flag = 1;
    main_screen_originx = 1;
    main_screen_originy = 1;
    given_scene[0] = 0;
    quit_flag = network_flag = load_flag = save_flag 
	    = prefs_flag = cheat_flag = monument_bul_flag
	    = river_bul_flag = shanty_bul_flag;
    prefs_drawn_flag = 0;
    kmouse_val = 8;

#ifdef LC_X11
    borderx = 0;
    bordery = 0;
    parse_xargs (argc, argv, &geometry);
#endif

    /* I18n */
    lincity_set_locale ();

    /* Set up the paths to certain files and directories */
    init_path_strings ();

    /* Make sure that things are installed where they should be */
    verify_package ();

    /* Make sure the save directory exists */
    check_savedir ();

    /* Load preferences */
    load_lincityrc ();

#ifndef CS_PROFILE
#ifdef SEED_RAND
    srand (time (0));
#endif
#endif

#ifdef LC_X11
#if defined (commentout)
    borderx = 0;
    bordery = 0;
    parse_xargs (argc, argv, &geometry);
#endif
    Create_Window (geometry);
    pirate_cursor = XCreateFontCursor (display.dpy, XC_pirate);
#elif defined (WIN32)
    /* Deal with all outstanding messages */
    ProcessPendingEvents ();
#else
    parse_args (argc, argv);
    q = vga_setmode (G640x480x256);
    gl_setcontextvga (G640x480x256);
#endif

#if defined (WIN32) || defined (LC_X11)
    initialize_pixmap ();
#endif

    init_fonts ();

#if defined (SKIP_OPENING_SCENE)
    skip_splash_screen = 1;
#endif
    if (!skip_splash_screen) {
	load_start_image ();
    }

#ifdef LC_X11
    unlock_window_size ();
#endif

    Fgl_setfont (8, 8, main_font);
    Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);

    initialize_geometry (&scr);

#if defined (SVGALIB)
    set_vga_mode ();
#endif

    initialize_monthgraph ();
    init_mouse_registry ();
    init_mini_map_mouse ();

#ifdef LC_X11
    x_key_value = 0;
#elif defined (WIN32)
    RefreshScreen ();
#endif
    setcustompalette ();
    draw_background ();
    prog_box (_("Loading the game"), 1);
    init_types ();
    init_modules();
    init_mappoint_array ();
    initialize_tax_rates ();
    prog_box ("", 95);
    mouse_hide_count = 0;
    suppress_ok_buttons = 0;
    prog_box ("", 100);
#ifdef USE_PIXMAPS
    prog_box (_("Creating pixmaps"), 1);
    init_pixmaps ();
    prog_box ("", 100);
#endif
    //draw_normal_mouse (1, 1);
#if defined (LC_X11)
    init_x_mouse ();
#endif
    init_timer_buttons();
    mouse_initialized = 1;
    //set_selected_module (CST_TRACK_LR);
    screen_setup ();

    /* Main loop! */
    client_main_loop ();

#if defined (SVGALIB)
    mouse_close ();
    vga_setmode (TEXT);
#endif

    print_results ();

#if defined (WIN32) || defined (LC_X11)
    free_pixmap ();
#endif

#if defined (WIN32)
    return 0;
#else
    exit (0);
#endif
}