Пример #1
0
Errcode open_curpic(Boolean load_colors)
{
Errcode err;
Names single_pdr;
Names *check_name;

	if(pcb.loadpdr[0])
	{
		check_name = &single_pdr;
		single_pdr.name = pcb.loadpdr;
	}
	else
	{
		check_name = &check_pdrs[Array_els(check_pdrs)-1];
	}


	while(check_name)
	{
		if((err = load_picture(check_name->name,pcb.fliname,
							   load_colors)) >= Success)
		{
			break;
		}
		if(err == Err_no_file)
			break;
		check_name = check_name->next;
	}
	return(err);
}
Пример #2
0
int load_nextimg( char *name, MFDB *mfdb, INFO_IMAGE *inf, VSS_INFO *vss_info, GEM_WINDOW *wprog )
{
  int ret ;

  display_status( STATUS_LOADING ) ;
  ret = img_format( name, inf ) ;
  if ( ret != 0 )
  {
    if ( inf->palette ) free( inf->palette ) ;
  }
  else
  {
    memset( mfdb, 0, sizeof(MFDB) ) ;
    mfdb->fd_nplanes = nb_plane ;
    if ( nb_plane == 16 ) Force16BitsLoad = 1 ;
    else                  Force16BitsLoad = 0 ;
    mouse_busy() ;
    ret = load_picture( name, mfdb, inf, wprog ) ;
    mouse_restore() ;
    mfdb->fd_w = inf->largeur ; /* Evite la bande sur la droite */
    if ( ( vss_info->display_type & DISPLAYTYPE_ZOOM ) &&
        ( ( mfdb->fd_w < 1+Xmax ) || ( mfdb->fd_h < 1+Ymax ) )
      )
     strech_img( mfdb ) ;
   else
    if ( ( vss_info->display_type & DISPLAYTYPE_REDUC ) &&
         ( ( mfdb->fd_w > 1+Xmax ) || ( mfdb->fd_h > 1+Ymax ) )
      )
     strech_img( mfdb ) ;
  }

  log_event( CMD_DISPLAY, name ) ;

  return( ret ) ;
}
Пример #3
0
GtkWidget *
picture_create_widget (GtkWidget * dlg)
{
  GtkWidget *sw;

  sw = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_NONE);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), options.hscroll_policy, options.vscroll_policy);

  viewport = gtk_viewport_new (gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (sw)),
                               gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (sw)));
  gtk_container_add (GTK_CONTAINER (sw), viewport);

  picture = gtk_image_new ();
  gtk_container_add (GTK_CONTAINER (viewport), picture);

  /* load picture */
  if (options.common_data.uri &&
      g_file_test (options.common_data.uri, G_FILE_TEST_EXISTS))
    load_picture (options.common_data.uri);
  else
    gtk_image_set_from_stock (GTK_IMAGE (picture), "gtk-missing-image", GTK_ICON_SIZE_DIALOG);

  if (loaded && !animated)
    {
      create_popup_menu ();
      g_signal_connect (G_OBJECT (viewport), "button-press-event", G_CALLBACK (button_handler), NULL);
      g_signal_connect (G_OBJECT (viewport), "key-press-event", G_CALLBACK (key_handler), NULL);
    }

  return sw;
}
Пример #4
0
int init_cards(struct Card (*cards)[], char FileName[])
{	
	FILE *f;
	f = fopen(FileName, "r");

	for (int i = 0; i < ARRAY_LENGTH; i++)
	{
		/*int *x; BSP für malloc
		x = (int *)malloc(sizeof(int));*/
		(*cards)[i].picture = (struct Picture *)malloc(sizeof(struct Picture));
		(*cards)[i].picture->picture = NULL;
	}

	int j = 0;
	char c[100]; //string für den Dateipfad
	while (fscanf(f, "%s %d %d", &c, &(*cards)[j].difficulty, &(*cards)[j].type) != EOF) //End of File =  EOF
	{
		*(*cards)[j].picture = load_picture(*(*cards)[j].picture, c);

		if ((*cards)[j].picture->picture == NULL)
			return FAILED_LOADING_IMAGE;

		(*cards)[j].visible = 0;
		j++;
	}

	return 0;
}
Пример #5
0
void GfxEngine::load_pictures(const std::list<Picture*> &ioPictures)
{
    for (std::list<Picture*>::const_iterator it = ioPictures.begin(); it!= ioPictures.end(); ++it)
    {
        // for every picture
        Picture& pic = *(*it);
        load_picture(pic);
    }
}
Пример #6
0
picture
cached_load_picture (url file_name, int w, int h, bool permanent) {
    tree key= tuple (file_name->t, as_string (w), as_string (h));
    if (picture_is_cached (file_name, w, h))
        return picture_cache [key];
    //cout << "Loading " << key << "\n";
    picture pic= load_picture (file_name, w, h);
    if (permanent || picture_count[key] > 0) {
        int pic_modif= last_modified (file_name, false);
        picture_cache (key)= pic;
        picture_stamp (key)= pic_modif;
    }
    return pic;
}
Пример #7
0
int Load_Game()
{
    FILE *f = fopen("Savegame.txt", "r");
    if (fprintf(f, "") == EOF)
        return -1;

    int GameSizeX = 0, GameSizeY = 0, amPlayers = 0;
    char FileName[FILENAME_LENGHT];
    if (fscanf(f, "%d %d %d %s", amPlayers, GameSizeX, GameSizeY, &FileName) == EOF)
        return FAILED_LOADING_SAVEGAME;

    struct Card cards[ARRAY_LENGTH];
    int amCards = init_cards(&cards, "Savegame_Cards.txt");
    if (amCards < 0)
        return amCards;

    Card_Background = load_picture(Card_Background, FileName);

    start_game(amPlayers, cards, amCards, GameSizeX, GameSizeY, &Card_Background, 1);

    return 0;
}
Пример #8
0
int tool_main(int argc, char** argv) {
    SkCommandLineFlags::SetUsage("apply lua script to .skp files.");
    SkCommandLineFlags::Parse(argc, argv);

    if (FLAGS_skpPath.isEmpty()) {
        SkDebugf(".skp files or directories are required.\n");
        exit(-1);
    }
    if (FLAGS_luaFile.isEmpty()) {
        SkDebugf("missing luaFile(s)\n");
        exit(-1);
    }

    const char* summary = gSummarizeFunc;
    if (!FLAGS_tailFunc.isEmpty()) {
        summary = FLAGS_tailFunc[0];
    }

    SkAutoGraphics ag;
    SkLua L(summary);

    for (int i = 0; i < FLAGS_luaFile.count(); ++i) {
        SkAutoDataUnref data(SkData::NewFromFileName(FLAGS_luaFile[i]));
        if (NULL == data.get()) {
            data.reset(SkData::NewEmpty());
        }
        if (!FLAGS_quiet) {
            SkDebugf("loading %s...\n", FLAGS_luaFile[i]);
        }
        if (!L.runCode(data->data(), data->size())) {
            SkDebugf("failed to load luaFile %s\n", FLAGS_luaFile[i]);
            exit(-1);
        }
    }

    if (!FLAGS_headCode.isEmpty()) {
        L.runCode(FLAGS_headCode[0]);
    }

    int moduloRemainder = -1;
    int moduloDivisor = -1;
    SkString moduloStr;

    if (FLAGS_modulo.count() == 2) {
        moduloRemainder = atoi(FLAGS_modulo[0]);
        moduloDivisor = atoi(FLAGS_modulo[1]);
        if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= moduloDivisor) {
            SkDebugf("invalid modulo values.\n");
            return -1;
        }
    }

    for (int i = 0; i < FLAGS_skpPath.count(); i ++) {
        SkTArray<SkString> paths;
        if (sk_isdir(FLAGS_skpPath[i])) {
            // Add all .skp in this directory.
            const SkString directory(FLAGS_skpPath[i]);
            SkString filename;
            SkOSFile::Iter iter(FLAGS_skpPath[i], "skp");
            while(iter.next(&filename)) {
                paths.push_back() = SkOSPath::Join(directory.c_str(), filename.c_str());
            }
        } else {
            // Add this as an .skp itself.
            paths.push_back() = FLAGS_skpPath[i];
        }

        for (int i = 0; i < paths.count(); i++) {
            if (moduloRemainder >= 0) {
                if ((i % moduloDivisor) != moduloRemainder) {
                    continue;
                }
                moduloStr.printf("[%d.%d] ", i, moduloDivisor);
            }
            const char* path = paths[i].c_str();
            if (!FLAGS_quiet) {
                SkDebugf("scraping %s %s\n", path, moduloStr.c_str());
            }

            SkAutoTUnref<SkPicture> pic(load_picture(path));
            if (pic.get()) {
                SkAutoTUnref<SkLuaCanvas> canvas(
                                    new SkLuaCanvas(SkScalarCeilToInt(pic->cullRect().width()), 
                                                    SkScalarCeilToInt(pic->cullRect().height()),
                                                    L.get(), gAccumulateFunc));

                call_canvas(L.get(), canvas.get(), path, gStartCanvasFunc);
                canvas->drawPicture(pic);
                call_canvas(L.get(), canvas.get(), path, gEndCanvasFunc);

            } else {
                SkDebugf("failed to load\n");
            }
        }
    }
    return 0;
}
Пример #9
0
int print_image(MFDB *raster, INFO_IMAGE *in_info)
{
  GEM_WINDOW *wprog = NULL ;
  DLGDATA    dlg_data ;
  DLGPRINTER_USER_DATA dlg_user_data ;
  GEM_WINDOW *dlg ;
  MFDB       src ;
  float      sizex, sizey ;
  float      ptpx, ptpy ;
  int        pintin[256], pintout[256] ;
  int        xyarray[4] ;
  int        print_handle ;
  int        i, xoffset, yoffset ;
  int        bouton ;
  int        dither_mono, print_color ;
  char       *filename = dlg_user_data.filename ;
  char       *c ;
  char       buffer[200] ;
  char       nom[30] ;

  if ( !Gdos ) return(PNOGDOS) ;
  if ( !printer_init ) scan_drivers() ;
  if ( nb_drivers <= 0 ) return( PNODRIVER ) ;

  memset( &dlg_user_data, 0, sizeof(DLGPRINTER_USER_DATA) ) ;
  if ( raster ) memcpy( &dlg_user_data.raster, raster, sizeof(MFDB) ) ;
  if ( in_info ) memcpy( &dlg_user_data.info, in_info, sizeof(INFO_IMAGE) ) ;

  while ( dlg_user_data.raster.fd_w == 0 )
  {
    strcpy( buffer, filename ) ;
    c = strrchr( buffer, '\\' ) ;
    if ( c ) *c = 0 ;
    strcat( buffer, "\\*.*" ) ;
    if ( file_name( buffer, "", buffer ) == 1 )
    {
      INFO_IMAGE inf ;

      strcpy( dlg_user_data.filename, buffer ) ;
      if ( img_format(dlg_user_data.filename, &inf) == 0 )
      {
        memcpy(&dlg_user_data.info, &inf, sizeof(INFO_IMAGE)) ;
        memset(&dlg_user_data.raster, 0, sizeof(MFDB)) ;
        dlg_user_data.raster.fd_w       = inf.largeur ;
        dlg_user_data.raster.fd_h       = inf.hauteur ;
        dlg_user_data.raster.fd_nplanes = inf.nplans ;
        dlg_user_data.raster.fd_wdwidth = dlg_user_data.raster.fd_w/16 ;
        if (dlg_user_data.raster.fd_w % 16) dlg_user_data.raster.fd_wdwidth++ ;
      }
    }
    else return(PCANCEL) ;
  }

  memset( &dlg_data, 0, sizeof(DLGDATA) ) ;
  dlg_data.RsrcId         = FORM_PRINT ;
  dlg_data.UserData       = &dlg_user_data ;
  dlg_data.ExtensionSize  = 0 ; /* Sera alloue par OnInitPrinterDialog */
  dlg_data.OnInitDialog   = OnInitPrinterDialog ;
  dlg_data.OnObjectNotify = OnObjectNotifyPrinterDialog ;
  dlg_data.OnCloseDialog  = OnClosePrinterDialog ;

  dlg    = GWCreateDialog( &dlg_data ) ;
  bouton = GWDoModal( dlg, PRINT_XPC ) ;
  if ( bouton == IDCANCEL ) return( PCANCEL ) ;

  printer_index = dlg_user_data.printer_index ;
  type_index    = dlg_user_data.type_index ;

  if ( dlg_user_data.filename[0] )
  {
    INFO_IMAGE inf ;
    int        analyse = img_analyse ;

    img_analyse = 0 ;
    if ( img_format( dlg_user_data.filename, &inf ) == 0 )
    {
      memcpy(&dlg_user_data.info, &inf, sizeof(INFO_IMAGE)) ;
      src.fd_nplanes = -1 ; /* Conserver le nombre de plans */
      Force16BitsLoad = 0 ;
      wprog = DisplayStdProg( msg[MSG_LOADINGIMG], "", dlg_user_data.filename, 0 ) ;
      if ( load_picture( dlg_user_data.filename, &src, &inf, wprog ) != 0 )
      {
        GWDestroyWindow( wprog ) ;
        img_analyse = analyse ;
        return(PCANCEL) ;
      }
      StdProgWText( wprog, 1, "" ) ;
    }
    else
    {
      img_analyse = analyse ;
      return( PCANCEL ) ;
    }

    img_analyse = analyse ;
    GWDestroyWindow( wprog ) ;
    wprog = NULL ;
  }
  else
    memcpy( &src, &dlg_user_data.raster, sizeof(MFDB) ) ;

  pintin[0] = id[dlg_user_data.printer_index] ;
  if ((pintin[0] < 21) || (pintin[0] > 30)) return( PNOHANDLE ) ;
  for (i = 1; i < 10; i++) pintin[i] = 1 ;
  pintin[10] = 2 ;
  v_opnwk( pintin, &print_handle, pintout ) ;
  if ( print_handle <= 0 ) return(PNOHANDLE) ;

  ptpx = (float)pintout[3] ; /* Largeur d'un point imprimante en microns */
  ptpy = (float)pintout[4] ; /* Hauteur d'un point imprimante en microns */
  wprog = DisplayStdProg( "", "", "", CLOSER ) ;

  dither_mono = (dlg_user_data.type_index == 1) && (src.fd_nplanes > 1) ;
  print_color = (dlg_user_data.type_index == 0) ;
  if ( dither_mono ) /* Mode noir et blanc */
  {
    MFDB virtuel ;
    int  pc_x, pc_y ;

    StdProgWText( wprog, 0, msg[MSG_DITHER] ) ;
    virtuel.fd_nplanes = 1 ;
    if ( dlg_user_data.rotate90 )
      pc_x = (int) (dlg_user_data.xpc*(float)dlg_user_data.info.lpix/ptpy) ;
    else
      pc_x = (int) (dlg_user_data.xpc*(float)dlg_user_data.info.lpix/ptpx) ;
    if ( dlg_user_data.rotate90 )
      pc_y = (int) (dlg_user_data.ypc*(float)dlg_user_data.info.hpix/ptpx) ;
    else
      pc_y = (int) (dlg_user_data.ypc*(float)dlg_user_data.info.hpix/ptpy) ;
    mouse_busy() ;
    if ( dither_ratio(&src, &dlg_user_data.info, &virtuel, pc_x, pc_y, wprog ) == -1 )
    {
      if ( dlg_user_data.filename[0] )
      {
        free( src.fd_addr ) ;
        if ( dlg_user_data.filename[0] && dlg_user_data.info.palette ) free( dlg_user_data.info.palette ) ;
      }
      mouse_restore() ;
      GWDestroyWindow( wprog ) ;
      v_clswk( print_handle ) ;
      return( PROTERR ) ;
    }
    wprog->ProgPc( wprog, 0, NULL ) ;
    mouse_restore() ;
    if ( dlg_user_data.filename[0] ) free( src.fd_addr ) ;
    memcpy( &src, &virtuel, sizeof(MFDB) ) ;
  }

  if ( dlg_user_data.rotate90 )
  {
    MFDB virtuel ;
 
    StdProgWText( wprog, 0, msg[MSG_ROTATING] ) ;
    mouse_busy() ;
    if ( raster_r90( &src, &virtuel, wprog ) != 0 )
    {
      if ( dither_mono || dlg_user_data.filename[0] ) free( src.fd_addr ) ;
      if ( dlg_user_data.filename[0] && dlg_user_data.info.palette ) free( dlg_user_data.info.palette ) ;
      mouse_restore() ;
      GWDestroyWindow( wprog ) ;
      v_clswk( print_handle ) ;
      return( PROTERR ) ;
    }
    mouse_restore() ;
    if ( dither_mono || dlg_user_data.filename[0] ) free(src.fd_addr ) ;
    memcpy( &src, &virtuel, sizeof(MFDB) ) ;
  }

  sizex = (float)src.fd_w*(float)dlg_user_data.info.lpix*dlg_user_data.xpc/100.0 ;
  sizey = (float)src.fd_h*(float)dlg_user_data.info.hpix*dlg_user_data.ypc/100.0 ;
  sizex /= 10000.0 ;
  sizey /= 10000.0 ;
  if ( !print_color )
  {
    StdProgWText( wprog, 0, msg[MSG_DOGDOSIMG] ) ;
    strcpy(nom, "VSCRAP.IMG") ;
    if ( img_sauve( nom, &src, &dlg_user_data.info, wprog ) )
    {
      if ( dither_mono || dlg_user_data.filename[0] || dlg_user_data.rotate90 ) free( src.fd_addr ) ;
      if ( dlg_user_data.filename[0] && dlg_user_data.info.palette ) free( dlg_user_data.info.palette ) ;
      GWDestroyWindow( wprog ) ;
      v_clswk( print_handle ) ;
      return( PWRITERR ) ;
    }
  }
  else
  {
    INFO_IMAGE new_info ;
    MFDB       new_img ;

    memcpy( &new_info, &dlg_user_data.info, sizeof(INFO_IMAGE) ) ;
    memcpy( &new_img, &src, sizeof(MFDB) ) ;
    if ( new_img.fd_nplanes <= 8 )
    {
      new_info.nb_cpal   = 0 ;
      new_info.palette   = NULL ;
      new_info.nplans    = 16 ;
      new_img.fd_addr    = NULL ;
      new_img.fd_nplanes = 16 ;
      StdProgWText( wprog, 0, msg[MSG_DOGDOSIMG] ) ;
      if ( index2truecolor( &src, &dlg_user_data.info, &new_img, wprog ) != 0 )
      {
        if ( dither_mono || dlg_user_data.filename[0] || dlg_user_data.rotate90 ) free( src.fd_addr ) ;
        if ( dlg_user_data.filename[0] && dlg_user_data.info.palette ) free( dlg_user_data.info.palette ) ;
        v_clswk( print_handle ) ;
        GWDestroyWindow( wprog ) ;
        return( PWRITERR ) ;
      }
    }
    strcpy( nom, "VSCRAP.TGA" ) ;
    if ( targa_sauve( nom, &new_img, &new_info, wprog ) )
    {
      if ( dither_mono || dlg_user_data.filename[0] || dlg_user_data.rotate90 ) free( src.fd_addr ) ;
      if ( dlg_user_data.filename[0] && dlg_user_data.info.palette ) free( dlg_user_data.info.palette ) ;
      v_clswk( print_handle ) ;
      GWDestroyWindow( wprog ) ;
      return( PWRITERR ) ;
    }
    if ( src.fd_nplanes <= 8 ) free( new_img.fd_addr ) ;
  }

  if ( dither_mono || dlg_user_data.filename[0] || dlg_user_data.rotate90 ) free( src.fd_addr ) ;
  if ( dlg_user_data.filename[0] && dlg_user_data.info.palette ) free( dlg_user_data.info.palette ) ;

  StdProgWText( wprog, 0, msg[MSG_PRINTING] ) ;
  vst_unload_fonts( handle, 0 ) ;
  xoffset = (int) (10000.0*dlg_user_data.posx/ptpx) ;
  yoffset = (int) (10000.0*dlg_user_data.posy/ptpy) ;
  xyarray[0] = xoffset ;
  xyarray[1] = yoffset ;
  xyarray[2] = xoffset+(int) (10000.0*sizex/ptpx) ;
  xyarray[3] = yoffset+(int) (10000.0*sizey/ptpy) ;

  mouse_busy() ;
  vs_page_info(print_handle, APPL,	MENU_NAME) ;
  vs_page_info(print_handle, DOC,	nom) ;
  vs_page_info(print_handle, CREAT,	"") ;
  vs_page_info(print_handle, REM,	"Thanks to Thierry Rodolfo !" ) ;

  if (dither_mono)
    v_bit_image(print_handle, nom, 0, INTEGER, INTEGER, 0, 0, xyarray) ;
  else
    v_bit_image(print_handle, nom, 0, FRACTIONAL, FRACTIONAL, 0, 0, xyarray) ;
  v_updwk(print_handle) ;
  v_clrwk(print_handle) ;
  v_clswk(print_handle) ;
  vst_load_fonts(handle, 0) ;
  mouse_restore() ;
  unlink(nom) ;
  GWDestroyWindow( wprog ) ;

  return( 0 ) ;
}
Пример #10
0
int init_game(int AmPlayers, struct Card (*stack)[], int AmCards, int AmX, int AmY)
{
    FILE *f;
    f = fopen("./resources/config.txt", "r");

    int i = 0;
    // Loading Background
    char c[100];
    if (fscanf(f, "%s %3d %3d %3d", &c, &objects[i].x, &objects[i].y, &objects[i].type) != EOF)
    {
        objects[i].picture = load_picture(objects[i].picture, c);
        if (objects[i].picture.picture == NULL)
            return FAILED_LOADING_BACKGROUND;

        objects[i].enabled = 1;
        i++;
    }

    if (fscanf(f, "%d %d %d %d", &Gamefield.x, &Gamefield.y, &Gamefield.w, &Gamefield.h) == EOF)
        return FAILED_LOADING_GAMEFIELD;

    for (int j = 0; j < 8; j++)
        if (fscanf(f, "%d %d", &PlayerPointsPosition[j].x, &PlayerPointsPosition[j].y) == EOF)
            return FAILED_LOADING_PlAYERPOINTSPOSITION;

    srand(time(NULL));  /* start random number generater */

    AktPlayer = rand() % (AmPlayers + 1);

    // Paint the player-labels
    for (int j = 0; j < AmPlayers; j++)
    {
        objects[i].x = PlayerPointsPosition[j].x;
        objects[i].y = PlayerPointsPosition[j].y;
        objects[i].type = 100;
        objects[i].enabled = 1;
        char *c = (char *)malloc(sizeof(char));
        sprintf(c, "%d", j + 1);
        objects[i].picture = Create_Picture_By_Text(objects[i].picture, concat("Player ", c), j == AktPlayer ? 1 : 0);

        pairs[j] = 0;
        textfield[j][0] = i++;

        objects[i].x = PlayerPointsPosition[j].x;
        objects[i].y = 30 + PlayerPointsPosition[j].y;
        objects[i].type = 101;
        objects[i].enabled = 1;
        objects[i].picture = Create_Picture_By_Text(objects[i].picture, "0 pairs found", 0);

        pairs[j] = 0;
        textfield[j][1] = i++;
    }

    int X, Y;
    if (fscanf(f, "%d %d", &X, &Y) != EOF)
    {
        objects[i].x = X;
        objects[i].y = Y;
        objects[i].type = 0;
        objects[i].enabled = 1;
        char *c = (char *)malloc(sizeof(char));

        NuOfRePairs = AmCards / 2;
        sprintf(c, "%d", NuOfRePairs);
        objects[i].picture = Create_Picture_By_Text(objects[i].picture, concat("Number of remaining pairs: ", c), 0);

        PosOfReCards = i++;
    }

    if (fscanf(f, "%s", &c) == EOF)
        return FAILED_LOADING_PIC_BUTTON_ADDRESS;

    Pic_Button = load_picture(Pic_Button, c);

    if (fscanf(f, "%s", &c) == EOF)
        return FAILED_LOADING_PIC_BUTTON_CLICKED_ADDRESS;

    Pic_Button_Clicked = load_picture(Pic_Button_Clicked, c);

    // Load the buttons
    for (int j = 0; j < 4; j++)
    {
        objects[i].type = 2;
        objects[i].enabled = 1;

        int x = 0, y = 0;
        if (fscanf(f, "%d %d %s %d", &x, &y, &c, &objects[i].button.Type) == EOF)
            return -1;

        objects[i].button = New_Button(objects[i].button, &Pic_Button, &Pic_Button_Clicked);
        objects[i].picture = objects[i].button.Picture;
        objects[i].x = x;
        objects[i].y = y;

        i++;
    }


    // Load Objects

    while (fscanf(f, "%s %3d %3d %3d", &c, &objects[i].x, &objects[i].y, &objects[i].type) != EOF)
    {
        objects[i].picture = load_picture(objects[i].picture, c);
        if (objects[i].picture.picture == NULL)
            return FAILED_LOADING_IMAGE;

        objects[i].enabled = 1;
        i++;
    }

    // Shuffle Cards in Stack - Knuth-Fisher-Yates shuffle **/
    for (int j = AmCards - 1; j; j--) {
        int k = rand() % (j + 1);  /* random variable modulo remaining cards */
        /* swap entries of fields i and j */
        struct Card swap = (*stack)[j];
        (*stack)[j] = (*stack)[k];
        (*stack)[k] = swap;
    }

    // Draw Cards on gamefield

    int j = 0;
    int SizeX = (*(*stack)[0].picture).picture->w;
    int SizeY = (*(*stack)[0].picture).picture->h;

    for (int x = 0; x < AmX; x++)
        for (int y = 0; y < AmY; y++)
        {
            if ((*(*stack)[j].picture).picture == NULL)
                break;

            objects[i].type = 1; // objects is card
            objects[i].card = (*stack)[j++];
            objects[i].picture = *objects[i].card.picture;
            objects[i].card.picture = &objects[i].picture;
            objects[i].enabled = 1;
            objects[i].x = Gamefield.x + Gamefield.w / AmX * x;
            objects[i].y = Gamefield.y + Gamefield.h / AmY * y;
            i++;
        }

    return 0;
}
Пример #11
0
int DisplayImg(GEM_WINDOW *wnd, int create_open, int reload)
{
  WBROWSER   *wb   = wnd->Extension ;
  OBJECT     *bobj = wnd->DlgData->BaseObject ;
  int        ret, w, h ;
  int        xo, yo, wo, ho ;
  int        xco, yco, wco, hco ;
  char       *slash ;

  mouse_busy() ;
  wb->img_valid   = 0 ;
  wb->loading_img = 1 ;
  wb->load_err    = 0 ;
  wb->obj_notify  = 0 ;
  free_current_img( wb ) ;
  strcpy( wb->base_path, wb->nom ) ;
  slash = strrchr( wb->base_path, '\\' ) ;
  if ( slash ) *slash = 0 ;
  if ( reload ) free_current_folder( wb ) ;
  GWInvalidate( wnd ) ;
  if ( ( config.color_protect != 0 ) && ( nb_colors == 256 ) ) img_analyse = 1 ;
  else                                                         img_analyse = 0 ;
  ret = img_format( wb->nom, &wb->inf_img ) ;
  if ( ret == 0 )
  {
    w = wb->inf_img.largeur ;
    h = wb->inf_img.hauteur + bobj[0].ob_height ;
    if ( w < wb->mini_w ) w = wb->mini_w ;
    else                  bobj[0].ob_width = w ;
    open_where( wnd->window_kind, w, h, &xo, &yo, &wo, &ho ) ;
    if ( reload ) build_flist( wb ) ;
    if ( create_open ) GWOpenWindow( wnd, xo, yo, wo, ho ) ;
    else
    {
      GWGetCurrXYWH( wnd, &xco, &yco, &wco, &hco ) ;
      if ( ( xco + wo > Xmax ) || ( yco + ho > Ymax ) ) 
        GWSetCurrXYWH( wnd, xo, yo, wo, ho ) ;
      else
        GWSetCurrXYWH( wnd, xco, yco, wo, ho ) ;
    }
    GWGetWorkXYWH( wnd, &bobj[0].ob_x, &bobj[0].ob_y, &w, &h  ) ;
    wb->raster.fd_nplanes = nb_plane ;
    if ( nb_plane == 16 ) Force16BitsLoad = 1 ;
    else                  Force16BitsLoad = 0 ;
    ret = load_picture( wb->nom, &wb->raster, &wb->inf_img, wnd ) ;
    write_text( bobj, IMGB_TEXT, "" ) ;
    xobjc_draw( wnd->window_handle, bobj, IMGB_TEXT ) ;
    if ( ret == 0 )
    {
      if ( wb->pzoom_index == 0 ) wb->pczoom = -1 ;
      else
      {
        wb->pczoom = 100 ;
        wb->pzoom_index = SEL_100PC ;
      }
      adapt_display( wnd ) ;
      set_imgpalette( (VXIMAGE*) wb ) ;
    }
    wb->img_valid = ( ret == 0 ) ;
  }
  mouse_restore() ;
  wb->load_err    = ret ;
  wb->loading_img = 0 ;
  GWSetWindowCaption( wnd, wb->nom ) ;

  if ( wb->obj_notify ) OnObjectNotifyIBrowser( wnd, wb->obj_notify ) ;

  shareware_reminder( 8 ) ;

  return( ret ) ;
}