Пример #1
0
static void *InitLibrary(vout_display_sys_t *sys) {
    void *p_library;
    if ((p_library = LoadSurface("libsurfaceflinger_client.so", sys)))
        return p_library;
    if ((p_library = LoadSurface("libgui.so", sys)))
        return p_library;
    return LoadSurface("libui.so", sys);
}
Пример #2
0
//--------------------------------------------------------------------------
int UnitPakFiles(FileList &source_list, const char *output_path)
{
	if (source_list.containsItems() == 0)
	{
		return(_pak_files_ok);
	}

	Surface surface;

	int frameCount;

	frameCount = source_list.containsItems();

	if (LoadSurface(source_list.getString(0), surface) == _load_surface_invalid_type)
	{
		return _pak_files_invalid_source;
	}

	Surface workSurface(surface.getPixX(), surface.getPixY(), surface.getPixX(), frameCount);
	workSurface.fillAll(0);

	for (int i = 0; i < frameCount; i++)
	{
		workSurface.setFrame(i);

		if (LoadSurface(source_list.getString(i), surface) == _load_surface_invalid_type)
		{
			return _pak_files_invalid_source;
		}

		PIX background = surface.getPixel(0, 0);

		// Walk through the surface image and suck out the shadow.
		for (int x = 0; x < surface.getPixX(); x++)
		{
			for (int y = 0; y < surface.getPixY(); y++)
			{
				PIX color = surface.getPixel(x, y);

				if (color != background)
				{
					workSurface.putPixel(x, y, color);
				}
			}
		}
	}

	PackedSurface packedSurface;
	packedSurface.pack(workSurface);
	packedSurface.save(output_path);

	return _pak_files_ok;
}
Пример #3
0
void BuildGameWorld()
{
	HRESULT result;
	int x, y;
	LPDIRECT3DSURFACE9 tiles;

	//load the bitmap image containing all the tiles
	tiles = LoadSurface("groundtiles.bmp");

	//create the scrolling game world bitmap
	result = d3ddev->CreateOffscreenPlainSurface(
		GAMEWORLDWIDTH,         //width of the surface
		GAMEWORLDHEIGHT,        //height of the surface
		D3DFMT_X8R8G8B8,		
		D3DPOOL_DEFAULT,		
		&gameworld,             //pointer to the surface
		NULL);

	if (result != D3D_OK)
	{
		MessageBox(NULL,"Error creating working surface!","Error",0);
		return;
	}

	//fill the gameworld bitmap with tiles
	for (y=0; y < MAPHEIGHT; y++)
		for (x=0; x < MAPWIDTH; x++)
			DrawTile(tiles, MAPDATA[y * MAPWIDTH + x], 64, 64, 16, 
			gameworld, x * 64, y * 64);

	//now the tiles bitmap is no longer needed
	tiles->Release();
}
Пример #4
0
void MainWindow::OnFileOpen( wxCommandEvent& event )
{
    if (m_origSurface != NULL)
    {
        MRISfree(&m_origSurface);
        m_origSurface = NULL;
    }

    wxFileDialog* openDialog = new wxFileDialog(this,
            _("Choose a surface file to open"), m_lastLoadDir, wxEmptyString,
            _("All files (*)|*"),
            wxFD_OPEN, wxDefaultPosition);

    // Creates a "open file" dialog
    if (openDialog->ShowModal() == wxID_OK) // if the user click "Open" instead of "Cancel"
    {
        wxString filePath = openDialog->GetPath();
        LoadSurface(filePath);

        wxFileName fileName(filePath);
        m_lastLoadDir = fileName.GetPath();
    }


    // Clean up after ourselves
    openDialog->Destroy();

}
Пример #5
0
void TextureBuilder::PrepareSurface()
{
	if (m_prepared) return;

	if (!m_surface && m_filename.length() > 0)
		LoadSurface();

	TextureFormat targetTextureFormat;
	SDL_PixelFormat *targetPixelFormat;
	bool needConvert = !GetTargetFormat(m_surface->format, &targetTextureFormat, &targetPixelFormat, m_forceRGBA);

	if (needConvert) {
		SDL_Surface *s = SDL_ConvertSurface(m_surface, targetPixelFormat, SDL_SWSURFACE);
		SDL_FreeSurface(m_surface);
		m_surface = s;
	}

	unsigned int virtualWidth, actualWidth, virtualHeight, actualHeight;
	virtualWidth = actualWidth = m_surface->w;
	virtualHeight = actualHeight = m_surface->h;

	if (m_potExtend) {
		// extend to power-of-two if necessary
		actualWidth = ceil_pow2(m_surface->w);
		actualHeight = ceil_pow2(m_surface->h);
		if (actualWidth != virtualWidth || actualHeight != virtualHeight) {
			SDL_Surface *s = SDL_CreateRGBSurface(SDL_SWSURFACE, actualWidth, actualHeight, targetPixelFormat->BitsPerPixel,
				targetPixelFormat->Rmask, targetPixelFormat->Gmask, targetPixelFormat->Bmask, targetPixelFormat->Amask);

			SDL_SetAlpha(m_surface, 0, 0);
			SDL_SetAlpha(s, 0, 0);
			SDL_BlitSurface(m_surface, 0, s, 0);

			SDL_FreeSurface(m_surface);
			m_surface = s;
		}
	}

	else if (m_filename.length() > 0) {
		// power-of-to check
		unsigned long width = ceil_pow2(m_surface->w);
		unsigned long height = ceil_pow2(m_surface->h);

		if (width != virtualWidth || height != virtualHeight)
			fprintf(stderr, "WARNING: texture '%s' is not power-of-two and may not display correctly\n", m_filename.c_str());
	}

	m_descriptor = TextureDescriptor(
		targetTextureFormat,
		vector2f(actualWidth,actualHeight),
		vector2f(float(virtualWidth)/float(actualWidth),float(virtualHeight)/float(actualHeight)),
		m_sampleMode, m_generateMipmaps);
	
	m_prepared = true;
}
Пример #6
0
static void *InitLibrary(vout_display_sys_t *sys)
{
    static const char *libs[] = {
        "libsurfaceflinger_client.so",
        "libgui.so",
        "libui.so"
    };

    for (size_t i = 0; i < sizeof(libs) / sizeof(*libs); i++) {
        void *lib = LoadSurface(libs[i], sys);
        if (lib)
            return lib;
    }
    return NULL;
}
Пример #7
0
// Load new texture from file path
SDL_Texture* const j1Textures::Load(const char* path)
{
	SDL_Texture* texture = NULL;
	SDL_Surface* surface = IMG_Load(path);

	if(surface == NULL)
	{
		LOG("Could not load surface with path: %s. IMG_Load: %s", path, IMG_GetError());
	}
	else
	{
		texture = LoadSurface(surface);
		SDL_FreeSurface(surface);
	}

	return texture;
}
Пример #8
0
/*
...........................................................................................

bool LoadMedia( string * path);

Purpose:Loads the appropriate Bmp file to correspond with the correct key. Uses an enum to
simplify the data.

Entry: Takes input from an pointer to enum array.

Exit: Returns a bool to check that all the files were opened properly
...........................................................................................
*/
bool cSurfMan::LoadMedia(string * path)
{
	int textureIndex = 0;
	bool success = true;
	for (int i = 1; i <= PATH_TOTAL; i++)
	{	
		mTexture[textureIndex] = LoadSurface(path[i]); //First image
		if (mTexture[textureIndex] == nullptr)//Checks that the image successfully opened
		{
			cout << "Failed to load image!\n";
			success = false;
		}
		textureIndex++;	//increment index
	}	
	
	return success; //true bool returns successful 
}
Пример #9
0
CSurface::CSurface(SDL_Surface* inputsurface)
{
	m_Temp = 0;
	m_Surface = 0;
	m_Next = m_Prev = 0;
	m_UseKey = false;
	m_UseAlpha = true;
	m_Cached = false;
	m_Registered = false;
	Register(false);
	LoadSurface(inputsurface);
	m_SaveSurface = false;
	m_ColoredSurface = false;
	m_SpriteImage = 0;
	m_Message = "";

}
Пример #10
0
bool LoadMedia(display *d)
{
  bool success = true;
  gJukeBoxSurface[MUSIC_ON] = LoadSurface("JukeBox_on.bmp");
  if (gJukeBoxSurface[MUSIC_ON] == NULL) {
    SDL_Fail("Failed to load JukeBoxOn image!\n", d);
    success = false;
  }
  gJukeBoxSurface[MUSIC_OFF] = LoadSurface("JukeBox_Off.bmp");
  if (gJukeBoxSurface[MUSIC_OFF] == NULL) {
    SDL_Fail("Failed to load JukeBoxOff image!\n", d);
    success = false;
  }
  //--------------------
  gHoverSurface[GAME] = LoadSurface("Start.bmp");
  if (gHoverSurface[GAME] == NULL) {
    SDL_Fail("Failed to load gHoverSurface image!\n", d);
    success = false;
  }
  gHoverSurface[OPTION] = LoadSurface("Options.bmp");
  if (gHoverSurface[OPTION] == NULL) {
    SDL_Fail("option hover image fail", d);
    success = false;
  }
  gHoverSurface[ABOUT] = LoadSurface("Quit.bmp");
  if (gHoverSurface[ABOUT] == NULL) {
    SDL_Fail("about hover image fail", d);
    success = false;
  }
  gHoverSurface[3] = LoadSurface("Back_hover.bmp");
  if (gHoverSurface[3] == NULL) {
    SDL_Fail("back hover image fail", d);
    success = false;
  }
  return success;
}
Пример #11
0
void TriaLoop(int MaximumTrials, int nTrialsPerPhaseSet)
{
  T_PhaseCode          *PhaseCode, *FixedCode;
  T_FourierParameters  FP[1];
  T_PeakFlags          *PeakFlags;
  Fprec                *Surface;
  int                  StatLoadNextPhaseSet, iTrialsPerPhaseSet;
  long                 PosLoadNextPhaseSet;

  T_Ticks  Ticks;
  long     CheckTime = -SignalFileCheckInterval;


  nTrials = 0;
  nConvergedPhases = 0;
  nNotConvergedPhases = 0;

  StatLoadNextPhaseSet = 0;
  PosLoadNextPhaseSet = 1;
  iTrialsPerPhaseSet = 0;

  CheckMalloc(PhaseCode, nActivePhase);

  FixedCode = NULL;

  if (F_PhaseSetsFileName)
    CheckMalloc(FixedCode, nActivePhase);

  InitFourierParameters(FP, CodeTransl, nActivePhase);

  CheckMalloc(PeakFlags, Nx * Ny * Nz);
  DS_MarkEquiv(&SpgrInfo, PeakFlags, Nx, Ny, Nz);

  Surface = NULL;

  if (F_SurfaceFileName) {
    CheckMalloc(Surface, Nx * Ny * Nz);
    LoadSurface(Surface, Nx, Ny, Nz, PeakFlags);
  }

  /* initialize random number generator */
  DoRandomInitialization();

     (void) GetTicks(&Ticks);
  PrintTicks(stdout, &Ticks, "# Time ", "  Start of TriaLoop\n");
  Fflush(stdout);

  for (;;)
  {
    if (F_SignalFileName)
    {
      if (Ticks.sec_since_some_day - CheckTime >= SignalFileCheckInterval)
      {
        CheckSignalFile();
        CheckTime = Ticks.sec_since_some_day;
      }
    }

    if (QuitProgram)
      break;

    if (   FixedCode
        && (   StatLoadNextPhaseSet == 0
            || iTrialsPerPhaseSet >= nTrialsPerPhaseSet))
    {
      PosLoadNextPhaseSet = LoadNextPhaseSet(NULL) + 1;

      Fprintf(stdout,
        "# Looking for next phase set, starting at line #%ld in file %s\n",
        PosLoadNextPhaseSet, F_PhaseSetsFileName);

          StatLoadNextPhaseSet = LoadNextPhaseSet(FixedCode);
      if (StatLoadNextPhaseSet == -1)
        break;

      iTrialsPerPhaseSet = 0;
    }

    Fprintf(stdout, "WoT %d", nTrials);
    if (FixedCode)
      Fprintf(stdout, " PosPhaseSet %ld Fixed %ld Random %d Trial %d",
        PosLoadNextPhaseSet,
        (long) nActivePhase - StatLoadNextPhaseSet,
        StatLoadNextPhaseSet,
        iTrialsPerPhaseSet);
    putc('\n', stdout);
    Fflush(stdout);

    CurrPhaseCode_nCallRanmar = NextPhaseCode(PhaseCode, FixedCode);
    RecyclePhases(FP, PeakFlags, Surface, PhaseCode);

    nTrials++;
    if (FixedCode) iTrialsPerPhaseSet++;

       (void) GetTicks(&Ticks);
    PrintTicks(stdout, &Ticks, "# Time ", "\n");
    Fflush(stdout);

    if (MaximumTrials && MaximumTrials <= nTrials)
      break;
  }

  if (Surface) AppFree(Surface, Nx * Ny * Nz);
  AppFree(PeakFlags, Nx * Ny * Nz);
  FreeFourierParameters(FP);

  PrintTicks(stdout, NULL, "# Time ", "  End of TriaLoop\n");
}
Пример #12
0
Object::Object(SDL_Rect offset, std::string imagePath, bool doesColorKey, SDL_Color colorKey)
	: activeClip(nullptr), position({static_cast<double>(offset.x),static_cast<double>(offset.y)}), offsetRect(offset), isActive(true)
{
	texture = LoadSurface(imagePath, doesColorKey, colorKey);
}
Пример #13
0
void MainWindow::CommandLoadSurface( const wxArrayString& cmd )
{
    LoadSurface( cmd[1] );

}
Пример #14
0
void Graphics_Init(int fullscreen)
{
	switch (OPERATINGSYSTEM)
	{
		case 1:
			LoadSurface(ARCODATADIR "boss_linux.png",&GfxData[BOSS]);break;
		default:
			LoadSurface(ARCODATADIR "boss_windows.png",&GfxData[BOSS]);break;
	}
	LoadSurface(ARCODATADIR "menu.png",&GfxData[MENU]);
	LoadSurface(ARCODATADIR "menuitems.png",&GfxData[MENUITEMS]);
	LoadSurface(ARCODATADIR "credits.png",&GfxData[CREDITS]);
	LoadSurface(ARCODATADIR "deck.png",&GfxData[DECK]);
	SDL_SetColorKey(GfxData[DECK],SDL_SRCCOLORKEY,SDL_MapRGB(GfxData[DECK]->format,255,0,255));
	LoadSurface(ARCODATADIR "nums_big.png",&GfxData[NUMSBIG]);
	SDL_SetColorKey(GfxData[NUMSBIG],SDL_SRCCOLORKEY,SDL_MapRGB(GfxData[NUMSBIG]->format,255,0,255));
	LoadSurface(ARCODATADIR "gamebg.png",&GfxData[GAMEBG]);
	LoadSurface(ARCODATADIR "castle.png",&GfxData[CASTLE]);

	LoadSurface(ARCODATADIR "dlgmsg.png",&GfxData[DLGMSG]);
	LoadSurface(ARCODATADIR "dlgerror.png",&GfxData[DLGERROR]);
	LoadSurface(ARCODATADIR "dlgnetwork.png",&GfxData[DLGNETWORK]);
	LoadSurface(ARCODATADIR "dlgwinner.png",&GfxData[DLGWINNER]);
	LoadSurface(ARCODATADIR "dlglooser.png",&GfxData[DLGLOOSER]);

	SDL_SetColorKey(GfxData[CASTLE],SDL_SRCCOLORKEY,SDL_MapRGB(GfxData[CASTLE]->format,255,0,255));

	numssmall=BFont_LoadFont(ARCODATADIR "nums_small.png");
	if (!numssmall)
		FatalError("Data file 'nums_small.png' is missing or corrupt.");
	bigfont=BFont_LoadFont(ARCODATADIR "bigfont.png");
	if (!bigfont)
		FatalError("Data file 'bigfont.png' is missing or corrupt.");
	font=BFont_LoadFont(ARCODATADIR "font.png");
	if (!font)
		FatalError("Data file 'font.png' is missing or corrupt.");
	BFont_SetCurrentFont(font);

	if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE)<0)
		FatalError("Couldn't initialize SDL");
	SDL_WM_SetCaption("Arcomage v" ARCOVER,NULL);
	GfxData[SCREEN]=SDL_SetVideoMode(resX,resY,0,SDL_SWSURFACE|(fullscreen*SDL_FULLSCREEN));
	if (!GfxData[SCREEN])
		FatalError("Couldn't set 640x480 video mode");
	GfxData[BUFFER]=SDL_AllocSurface(GfxData[SCREEN]->flags,GfxData[SCREEN]->w,GfxData[SCREEN]->h,GfxData[SCREEN]->format->BitsPerPixel,GfxData[SCREEN]->format->Rmask,GfxData[SCREEN]->format->Gmask,GfxData[SCREEN]->format->Bmask,0);
	if (!GfxData[BUFFER])
		FatalError("Unable to create double buffer!");
}
Пример #15
0
// ------------------------------------------------------------------------------------------------
Map :: Map(Vector2df setScreenPos, GameBase* setGameBase)
{
    tileSurfaces[TILE_TYPE_SPACE] = LoadSurface("Surfaces/Space.png");
    tileSurfaces[TILE_TYPE_WALL] = LoadSurface("Surfaces/Metal_Wall_01.png");
    tileSurfaces[TILE_TYPE_UP_WELL] = LoadSurface("Surfaces/UpGravityWell.png");
    tileSurfaces[TILE_TYPE_DOWN_WELL] = LoadSurface("Surfaces/DownGravityWell.png");
    tileSurfaces[TILE_TYPE_LEFT_WELL] = LoadSurface("Surfaces/LeftGravityWell.png");
    tileSurfaces[TILE_TYPE_RIGHT_WELL] = LoadSurface("Surfaces/RightGravityWell.png");
    tileSurfaces[TILE_TYPE_BULLET_PICKUP] = LoadSurface("Surfaces/BulletPickUpTile.png");
    tileSurfaces[TILE_TYPE_MINE_PICKUP] = LoadSurface("Surfaces/MinePickupTile.png");
    tileSurfaces[TILE_TYPE_MISSILE_PICKUP] = LoadSurface("Surfaces/MissilePickUpTile.png");
    tileSurfaces[TILE_TYPE_REPAIR_PICKUP] = LoadSurface("Surfaces/RepairPickUpTile.png");
    tileSurfaces[TILE_TYPE_SPAWN] = LoadSurface("Surfaces/SpawnTile.png");

    screenPos = setScreenPos;
    game = setGameBase;
    currentSpawnPoint = 0;

    for(Tile y = 0; y < MAP_NUM_TILES_Y; y++)
    {
        for(Tile x = 0; x < MAP_NUM_TILES_X; x++)
        {
            tileTypes[x][y] = TILE_TYPE_SPACE;
        }
    }

} // ----------------------------------------------------------------------------------------------
Пример #16
0
void TextureBuilder::PrepareSurface()
{
	if (m_prepared) return;

	if (!m_surface && !m_filename.empty()) {
		std::string filename = m_filename;
		std::transform(filename.begin(), filename.end(), filename.begin(), ::tolower);
		if (ends_with_ci(filename, ".dds")) {
			LoadDDS();
		} else {
			LoadSurface();
		}
	}

	TextureFormat targetTextureFormat;
	unsigned int virtualWidth, actualWidth, virtualHeight, actualHeight, numberOfMipMaps = 0, numberOfImages = 1;
	if( m_surface ) {
		SDL_PixelFormat *targetPixelFormat;
		bool needConvert = !GetTargetFormat(m_surface->format, &targetTextureFormat, &targetPixelFormat, m_forceRGBA);

		if (needConvert) {
			if(m_textureType == TEXTURE_2D) {
				SDL_Surface *s = SDL_ConvertSurface(m_surface.Get(), targetPixelFormat, SDL_SWSURFACE);
				m_surface = SDLSurfacePtr::WrapNew(s);
			} else if(m_textureType == TEXTURE_CUBE_MAP) {
				assert(m_cubemap.size() == 6);
				for(unsigned int i = 0; i < 6; ++i) {
					SDL_Surface *s = SDL_ConvertSurface(m_cubemap[i].Get(), targetPixelFormat, SDL_SWSURFACE);
					m_cubemap[i] = SDLSurfacePtr::WrapNew(s);
				}
			} else {
				// Unknown texture type
				assert(0);
			}
		}

		virtualWidth = actualWidth = m_surface->w;
		virtualHeight = actualHeight = m_surface->h;

		if (m_potExtend) {
			// extend to power-of-two if necessary
			actualWidth = ceil_pow2(m_surface->w);
			actualHeight = ceil_pow2(m_surface->h);
			if (actualWidth != virtualWidth || actualHeight != virtualHeight) {
				if(m_textureType == TEXTURE_2D) {
					SDL_Surface *s = SDL_CreateRGBSurface(SDL_SWSURFACE, actualWidth, actualHeight, targetPixelFormat->BitsPerPixel,
						targetPixelFormat->Rmask, targetPixelFormat->Gmask, targetPixelFormat->Bmask, targetPixelFormat->Amask);
					SDL_SetSurfaceBlendMode(m_surface.Get(), SDL_BLENDMODE_NONE);
					SDL_BlitSurface(m_surface.Get(), 0, s, 0);

					m_surface = SDLSurfacePtr::WrapNew(s);
				} else if(m_textureType == TEXTURE_CUBE_MAP) {
					assert(m_cubemap.size() == 6);
					for(unsigned int i = 0; i < 6; ++i) {
						SDL_Surface *s = SDL_CreateRGBSurface(SDL_SWSURFACE, actualWidth, actualHeight, targetPixelFormat->BitsPerPixel,
							targetPixelFormat->Rmask, targetPixelFormat->Gmask, targetPixelFormat->Bmask, targetPixelFormat->Amask);
						SDL_SetSurfaceBlendMode(m_cubemap[i].Get(), SDL_BLENDMODE_NONE);
						SDL_BlitSurface(m_cubemap[i].Get(), 0, s, 0);
						m_cubemap[i] = SDLSurfacePtr::WrapNew(s);
					}
				} else {
					assert(0);
				}
			}
		}
		else if (! m_filename.empty()) {
			// power-of-two check
			unsigned long width = ceil_pow2(m_surface->w);
			unsigned long height = ceil_pow2(m_surface->h);

			if (width != virtualWidth || height != virtualHeight)
				Output("WARNING: texture '%s' is not power-of-two and may not display correctly\n", m_filename.c_str());
		}
	} else {
		switch(m_dds.GetTextureFormat()) {
		case PicoDDS::FORMAT_DXT1: targetTextureFormat = TEXTURE_DXT1; break;
		case PicoDDS::FORMAT_DXT5: targetTextureFormat = TEXTURE_DXT5; break;
		default:
			Output("ERROR: DDS texture with invalid format '%s' (only DXT1 and DXT5 are supported)\n", m_filename.c_str());
			assert(false);
			return;
		}

		virtualWidth = actualWidth = m_dds.imgdata_.width;
		virtualHeight = actualHeight = m_dds.imgdata_.height;
		numberOfMipMaps = m_dds.imgdata_.numMipMaps;
		numberOfImages = m_dds.imgdata_.numImages;
		if(m_textureType == TEXTURE_CUBE_MAP) {
			// Cube map must be fully defined (6 images) to be used correctly
			assert(numberOfImages == 6);
		}
	}

	m_descriptor = TextureDescriptor(
		targetTextureFormat,
		vector2f(actualWidth,actualHeight),
		vector2f(float(virtualWidth)/float(actualWidth),float(virtualHeight)/float(actualHeight)),
		m_sampleMode, m_generateMipmaps, m_compressTextures, numberOfMipMaps, m_textureType);

	m_prepared = true;
}
Пример #17
0
bool KrEncoder::ProcessDoc( const TiXmlDocument& doc, KrEngine* engine, KrConsole* console )
{
	TiXmlElement* root = 0;
	TiXmlElement* rootChild = 0;
	TiXmlElement* action = 0;
	TiXmlElement* frame = 0;
	TiXmlElement* file = 0;
	TiXmlElement* child = 0;

	if ( ( root = doc.FirstChildElement( "Definition" ) ) != 0 )
	{
		mode = DEFINITION;
	}
	else if ( ( root = doc.FirstChildElement( "Direct" ) ) != 0 )
	{
		mode = DIRECT;
	}
	else
	{
		console->Print( "ERROR: 'Definition' or 'Direct' root element not found.\n" );
		return false;
	}

	SDL_Surface* surface = 0;
	gedString error;

	if ( mode == DEFINITION )
	{
		// The surface.
		surface = LoadSurface( root, &error );
		if ( !surface )	
		{
			console->Print( "Error loading surface: '%s'\n", error.c_str() );
			return false;
		}

		// Walk the tree, and process.
		for( rootChild = root->FirstChildElement();
			 rootChild;
			 rootChild = rootChild->NextSiblingElement() )
		{
			AllInfo allInfo;
			if ( rootChild->Value() == "Sprite" )
			{
				for( action = rootChild->FirstChildElement( "Action" );
					 action;
					 action = action->NextSiblingElement( "Action" ) )
				{
					for( frame = action->FirstChildElement( "Frame" );
						 frame;
						 frame = frame->NextSiblingElement( "Frame" ) )
					{
							CalcAllInfo( frame, &allInfo, surface );
							EncodeSprite( surface, allInfo, console );
					}
				}
			}
			else if ( rootChild->Value() == "Tile" )
			{
				CalcAllInfo( rootChild, &allInfo, surface );
				EncodeTile( surface, allInfo, console );
			}
			else if ( rootChild->Value() == "Font" )
			{
				CalcAllInfo( rootChild, &allInfo, surface );
				EncodeFont( surface, allInfo, console );
			}
			else
			{
				console->Print( "ERROR: Unrecognized element name. (Not Sprite, Tile, or Font.).\n" );
				return false;
			}
			engine->Draw();
		}
		return true;
	}
	else
	{
		for( file = root->FirstChildElement( "File" );
			 file;
			 file = file->NextSiblingElement( "File" ) )
		{
			surface = LoadSurface( file, &error );
			if ( !surface )	
			{
				console->Print( "Error loading surface: '%s'\n", error.c_str() );
				return false;
			}
			scan.Init();

			for( child = file->FirstChildElement();
				 child;
				 child = child->NextSiblingElement() )
			{
				AllInfo allInfo;
				if ( child->Value() == "ColorKey" )
				{
					CalcAllInfo( child, &allInfo, surface );
					EncodeColorKey( surface, allInfo, console );
				}
				else if ( child->Value() == "Image" )
				{
					CalcAllInfo( child, &allInfo, surface );
					if ( allInfo.type == TYPE_SPRITE )
						EncodeSprite( surface, allInfo, console );
					else if ( allInfo.type == TYPE_TILE )
						EncodeTile( surface, allInfo, console );
					else
						console->Print( "ERROR: Direct encoding can not identify whether Sprite or Tile.\n" );
				}
				else
				{
					gedString aux(child->Value());
					console->Print( "ERROR: Unrecognized element name '%s'. (Not ColorKey or Image.).\n", aux.c_str() );
					return false;
				}
				engine->Draw();
			}
		}
		for (	file = root->FirstChildElement( "BinaryFile" );
				file;
				file = file->NextSiblingElement( "BinaryFile" ) )
		{
			EncodeBinary( file, console );
		}
		for (	file = root->FirstChildElement( "TextFile" );
				file;
				file = file->NextSiblingElement( "TextFile" ) )
		{
			EncodeText( file, console );
		}
		return false;
	}
}
Пример #18
-1
int PakFiles( FileList &source_list, const char *output_path )
 {
  //char buffer[1024];
  //char output_file[256];
  //char output_path[1024];
  //char *token;

  //char fname[_MAX_FNAME];
  //char ext[_MAX_EXT];

  if ( source_list.containsItems() == 0 )
   return( _pak_files_ok );

  /*
  _splitpath( source_list.getString( 0 ), 0, 0, fname, ext );
  
  token = strtok( fname, "0123456789" );
  strcpy( output_file, token );  
  
  strcpy( pak_file_name, output_file );
  strcat( pak_file_name, ".pak" );

  strcpy( output_path, output_dir );
  strcat( output_path, output_file );
  strcat( output_path, ".pak" );
  */

  Surface surface;
  int frame_count;

  Palette pal;
  pal.initNoColorTables("netp.act");

  frame_count = source_list.containsItems();

  if ( LoadSurface( source_list.getString( 0 ), surface ) == _load_surface_invalid_type )
   return( _pak_files_invalid_source );
  
  Surface work_surface( surface.getPixX(), surface.getPixY(), surface.getPixX(), frame_count );
   
  for( int i = 0; i < frame_count; i++ )
   {
    work_surface.setFrame(i);

    if ( LoadSurface( source_list.getString( i ), surface ) == _load_surface_invalid_type )
     return( _pak_files_invalid_source );
  		
    work_surface.fill(Color::orange);
	surface.blt(work_surface);   
   }
 
  PackedSurface packedSurface;
  packedSurface.pack(work_surface);
  packedSurface.save(output_path);

  surface.free();
  packedSurface.free();
  work_surface.free();
  return( _pak_files_ok );
 }