Example #1
0
/**
**  Load the graphics for the constructions.
**
**  HELPME: who make this better terrain depended and extendable
**  HELPME: filename constuction.
*/
void LoadConstructions(void)
{
	const char *file;
	std::vector<CConstruction *>::iterator i;

	for (i = Constructions.begin(); i != Constructions.end(); ++i) {
		if ((*i)->Ident.empty()) {
			continue;
		}
		file = (*i)->File.File.c_str();
		(*i)->Width = (*i)->File.Width;
		(*i)->Height = (*i)->File.Height;
		if (file && *file) {
			ShowLoadProgress("Construction %s", file);
			(*i)->Sprite = CPlayerColorGraphic::New(file, (*i)->Width, (*i)->Height);
			(*i)->Sprite->Load();
			(*i)->Sprite->Flip();
		}
		file = (*i)->ShadowFile.File.c_str();
		(*i)->ShadowWidth = (*i)->ShadowFile.Width;
		(*i)->ShadowHeight = (*i)->ShadowFile.Height;
		if (file && *file) {
			ShowLoadProgress("Construction %s", file);
			(*i)->ShadowSprite = CGraphic::ForceNew(file,
				(*i)->ShadowWidth, (*i)->ShadowHeight);
			(*i)->ShadowSprite->Load();
			(*i)->ShadowSprite->Flip();
			(*i)->ShadowSprite->MakeShadow();
		}
	}
}
Example #2
0
void CConstruction::Load()
{
	if (this->Ident.empty()) {
		return;
	}
	std::string file = this->File.File;

	this->Width = this->File.Width;
	this->Height = this->File.Height;
	if (!file.empty()) {
		ShowLoadProgress(_("Construction %s"), file.c_str());
		this->Sprite = CPlayerColorGraphic::New(file, this->Width, this->Height);
		this->Sprite->Load();
		this->Sprite->Flip();
	}
	file = this->ShadowFile.File;
	this->ShadowWidth = this->ShadowFile.Width;
	this->ShadowHeight = this->ShadowFile.Height;
	if (!file.empty()) {
		ShowLoadProgress(_("Construction %s"), file.c_str());
		this->ShadowSprite = CGraphic::ForceNew(file, this->ShadowWidth, this->ShadowHeight);
		this->ShadowSprite->Load();
		this->ShadowSprite->Flip();
		this->ShadowSprite->MakeShadow();
	}
}
Example #3
0
/**
** Load the graphics for the unit-types.
*/
void LoadUnitTypes(void)
{
	CUnitType *type;

	for (size_t i = 0; i < UnitTypes.size(); ++i) {
		type = UnitTypes[i];

		//
		// Lookup icons.
		//
		type->Icon.Load();
		//
		// Lookup missiles.
		//
		type->Missile.Missile = MissileTypeByIdent(type->Missile.Name);
		if (!type->Explosion.Name.empty()) {
			type->Explosion.Missile = MissileTypeByIdent(type->Explosion.Name);
		}
		//
		// Lookup corpse.
		//
		if (!type->CorpseName.empty()) {
			type->CorpseType = UnitTypeByIdent(type->CorpseName);
		}

		//
		// Load Sprite
		//
		if (!type->Sprite) {
			ShowLoadProgress("Unit \"%s\"", type->Name.c_str());
			LoadUnitTypeSprite(type);
		}
	}
}
Example #4
0
/**
** Load the graphics for the unit-types.
*/
void LoadUnitTypes()
{
	for (std::vector<CUnitType *>::size_type i = 0; i < UnitTypes.size(); ++i) {
		CUnitType &type = *UnitTypes[i];

		// Lookup icons.
		type.Icon.Load();
		// Lookup missiles.
		type.Missile.MapMissile();
		type.Explosion.MapMissile();

		// Lookup impacts
		for (int i = 0; i < ANIMATIONS_DEATHTYPES + 2; ++i) {
			type.Impact[i].MapMissile();
		}
		// Lookup corpse.
		if (!type.CorpseName.empty()) {
			type.CorpseType = UnitTypeByIdent(type.CorpseName);
		}
#ifndef DYNAMIC_LOAD
		// Load Sprite
		if (!type.Sprite) {
			ShowLoadProgress(_("Unit \"%s\""), type.Name.c_str());
			LoadUnitTypeSprite(type);
		}
#endif
		// FIXME: should i copy the animations of same graphics?
	}
}
Example #5
0
/**
**	Load all fonts.
*/
global void LoadFonts(void)
{
    unsigned i;

    for( i=0; i<sizeof(Fonts)/sizeof(*Fonts); ++i ) {
	ShowLoadProgress("\tFonts %s\n",Fonts[i].File);
	LoadSprite(Fonts[i].File,&Fonts[i].Sprite);
    }
}
Example #6
0
/**
**  Load the graphics for the icons.
*/
void LoadIcons()
{
	for (IconMap::iterator it = Icons.begin(); it != Icons.end(); ++it) {
		CIcon &icon = *(*it).second;

		ShowLoadProgress(_("Icons %s"), icon.G->File.c_str());
		icon.Load();
	}
}
Example #7
0
/**
**  Load decoration.
*/
void LoadDecorations(void)
{
	std::vector<Decoration>::iterator i;
	for (i = DecoSprite.SpriteArray.begin(); i != DecoSprite.SpriteArray.end(); ++i) {
		ShowLoadProgress("Decorations `%s'", (*i).File.c_str());
		(*i).Sprite = CGraphic::New((*i).File, (*i).Width, (*i).Height);
		(*i).Sprite->Load();
	}
}
Example #8
0
/**
** Load tileset and setup ::Map for this tileset.
**
** @see Map @see Map.Tileset.
*/
void LoadTileset()
{
	//  Load and prepare the tileset
	PixelTileSize = Map.Tileset.PixelTileSize;

	ShowLoadProgress("Tileset `%s'", Map.Tileset.ImageFile.c_str());
	//Map.TileGraphic = CGraphic::New(Map.Tileset.ImageFile);
	Map.TileGraphic = CGraphic::New(Map.Tileset.ImageFile, PixelTileSize.x, PixelTileSize.y);
	Map.TileGraphic->Load();
}
Example #9
0
/**
**  Load the Icon
*/
bool IconConfig::Load()
{
	if (LoadNoLog() == true) {
		ShowLoadProgress(_("Icon %s"), this->Name.c_str());
		return true;
	} else {
		fprintf(stderr, _("Can't find icon %s\n"), this->Name.c_str());
		return false;
	}
}
Example #10
0
/**
**  Load decoration.
*/
void LoadDecorations(void)
{
	// In a Visual C++ 2010 debug build the iterator throws an exception.
	// Is the iterator invalidated because of the new Sprint assignment?
	// debug build will work in Visual C++ 2008.
	std::vector<Decoration>::iterator i;
	for (i = DecoSprite.SpriteArray.begin(); i != DecoSprite.SpriteArray.end(); ++i) {
		ShowLoadProgress("Decorations `%s'", (*i).File.c_str());
		(*i).Sprite = CGraphic::New((*i).File, (*i).Width, (*i).Height);
		(*i).Sprite->Load();
	}
}
Example #11
0
/**
**	Load decoration.
*/
global void LoadDecorations(void)
{
    if( HealthSprite.File ) {
	ShowLoadProgress("\tDecorations `%s'\n",HealthSprite.File);
	HealthSprite.Sprite=LoadSprite(HealthSprite.File
		,HealthSprite.Width,HealthSprite.Height);
    }
    if( ManaSprite.File ) {
	ShowLoadProgress("\tDecorations `%s'\n",ManaSprite.File);
	ManaSprite.Sprite=LoadSprite(ManaSprite.File
		,ManaSprite.Width,ManaSprite.Height);
    }
    if( ShadowSprite.File ) {
	ShowLoadProgress("\tDecorations `%s'\n",ShadowSprite.File);
	ShadowSprite.Sprite=LoadSprite(ShadowSprite.File
		,ShadowSprite.Width,ShadowSprite.Height);
    }
    if( SpellSprite.File ) {
	ShowLoadProgress("\tDecorations `%s'\n",SpellSprite.File);
	SpellSprite.Sprite=LoadSprite(SpellSprite.File
		,SpellSprite.Width,SpellSprite.Height);
    }
}
Example #12
0
/**
**	Load the graphics for the constructions.
**
**	HELPME:	who make this better terrain depended and extendable
**	HELPME: filename constuction.
*/
global void LoadConstructions(void)
{
    const char* file;
    Construction** cop;

    if( (cop=Constructions) ) {
        while( *cop ) {
            if( !(*cop)->Ident ) {
                continue;
            }
            file=(*cop)->File[TheMap.Terrain];
            if( !file ) {			// default one
                file=(*cop)->File[0];
            }
            if( *file ) {
                char* buf;

                buf=alloca(strlen(file)+9+1);
                file=strcat(strcpy(buf,"graphics/"),file);
                ShowLoadProgress("\tConstruction %s\n",file);
                (*cop)->Sprite=LoadSprite(file
                                          ,(*cop)->Width,(*cop)->Height);
            }
            if( (file=(*cop)->ShadowFile) ) {
                char *buf;

                buf=alloca(strlen(file)+9+1);
                file=strcat(strcpy(buf,"graphics/"),file);
                ShowLoadProgress("\tConstruction %s\n",file);
                (*cop)->ShadowSprite=LoadSprite(file
                                                ,(*cop)->ShadowWidth,(*cop)->ShadowHeight);
            }
            ++cop;
        }
    }
}
Example #13
0
/**
**	Load the graphics for the missiles.
*/
global void LoadMissileSprites(void)
{
    int i;
    const char* file;

    for( i=0; i<sizeof(MissileTypes)/sizeof(*MissileTypes); ++i ) {
        if( (file=MissileTypes[i].File) ) {
            char* buf;

            buf=alloca(strlen(file)+9+1);
            file=strcat(strcpy(buf,"graphic/"),file);
            ShowLoadProgress("\tMissile %s\n",file);
            MissileTypes[i].RleSprite=LoadRleSprite(
                                          file,MissileTypes[i].Width,MissileTypes[i].Height);
        }
        MissileTypes[i].Type=i;
    }
}
Example #14
0
/**
**  Load stratagus config file.
*/
void LoadCcl(void)
{
	char buf[PATH_MAX];

	//
	//  Load and evaluate configuration file
	//
	CclInConfigFile = 1;
	LibraryFileName(CclStartFile.c_str(), buf, sizeof(buf));
	if (access(buf, R_OK)) {
		fprintf(stderr, "Maybe you need to specify another gamepath with '-d /path/to/datadir'?\n");
		ExitFatal(-1);
	}

	ShowLoadProgress("Script %s\n", buf);
	LuaLoadFile(buf);
	CclInConfigFile = 0;
	CclGarbageCollect(0);  // Cleanup memory after load
}
Example #15
0
/**
**	Load all fonts.
*/
global void LoadFonts(void)
{
    unsigned i;

#ifdef USE_OPENGL
    VideoDrawChar=VideoDrawCharOpenGL;
#else
    switch( VideoBpp ) {
	case 8:
	    VideoDrawChar=VideoDrawChar8;
	    break;

	case 15:
	case 16:
	    VideoDrawChar=VideoDrawChar16;
	    break;

	case 24:
	    VideoDrawChar=VideoDrawChar24;
	    break;

	case 32:
	    VideoDrawChar=VideoDrawChar32;
	    break;

	default:
	    DebugLevel0Fn("unsupported %d bpp\n" _C_ VideoBpp);
	    abort();
    }
#endif

    for( i=0; i<sizeof(Fonts)/sizeof(*Fonts); ++i ) {
	if( Fonts[i].File ) {
	    ShowLoadProgress("\tFonts %s\n",Fonts[i].File);
	    Fonts[i].Graphic=LoadGraphic(Fonts[i].File);
	    FontMeasureWidths(Fonts+i);
#ifdef USE_OPENGL
	    MakeFontBitmap(Fonts[i].Graphic,i);
#endif
	}
    }
}
Example #16
0
/**
**  Define tileset
**
**  @param l  Lua state.
*/
static int CclDefineTileset(lua_State *l)
{
	Map.Tileset->parse(l);

	//  Load and prepare the tileset
	PixelTileSize = Map.Tileset->getPixelTileSize();

	ShowLoadProgress(_("Loading Tileset \"%s\""), Map.Tileset->ImageFile.c_str());
	Map.TileGraphic = CGraphic::New(Map.Tileset->ImageFile, PixelTileSize.x, PixelTileSize.y);
	Map.TileGraphic->Load();
	//Wyrmgus start
	for (size_t i = 0; i != Map.Tileset->solidTerrainTypes.size(); ++i) {
		if (!Map.Tileset->solidTerrainTypes[i].ImageFile.empty()) {
			Map.SolidTileGraphics[i] = CGraphic::New(Map.Tileset->solidTerrainTypes[i].ImageFile, PixelTileSize.x, PixelTileSize.y);
			Map.SolidTileGraphics[i]->Load();
		}
	}
	//Wyrmgus end
	return 0;
}
Example #17
0
/**
**	Load the graphics for the constructions.
**
**	HELPME:	who make this better terrain depended and extendable
**	HELPME: filename constuction.
*/
global void LoadConstructions(void)
{
    int i;
    const char* file;

    for( i=0; i<sizeof(Constructions)/sizeof(*Constructions); ++i ) {
	file=Constructions[i].File[TheMap.Terrain];
	if( !file ) {			// default one
	    file=Constructions[i].File[0];
	}
	if( *file ) {
	    char* buf;

	    buf=alloca(strlen(file)+9+1);
	    file=strcat(strcpy(buf,"graphic/"),file);
	    ShowLoadProgress("\tConstruction %s\n",file);
	    Constructions[i].RleSprite=LoadRleSprite(file
		    ,Constructions[i].Width,Constructions[i].Height);
	}
    }
}
Example #18
0
/**
**  Load all fonts.
*/
void LoadFonts()
{
	for (FontFamiliesType::iterator iter = FontFamilies.begin();
	     iter != FontFamilies.end(); ++iter) {
		CFontFamily *fontFamily = iter->second;
		CGraphic *g = fontFamily->G;
		if (g) {
			ShowLoadProgress("Fonts %s", g->File.c_str());
			g->Load();
			fontFamily->MeasureWidths();
			if (UseOpenGL) {
				fontFamily->MakeFontColorGraphics();
			}
		}
	}

	// TODO: remove this
	SmallFont = CFont::Get("small");
	GameFont = CFont::Get("game");
	LargeFont = CFont::Get("large");
}
Example #19
0
/**
**  Initialize the user interface.
*/
void InitUserInterface()
{
	ShowLoadProgress("%s", _("Loading User Interface"));
	
	UI.Offset640X = (Video.Width - 640) / 2;
	UI.Offset480Y = (Video.Height - 480) / 2;

	//
	// Calculations
	//
	if (Map.Info.MapWidth) {
		UI.MapArea.EndX = std::min<int>(UI.MapArea.EndX, UI.MapArea.X + Map.Info.MapWidth * Map.GetCurrentPixelTileSize().x - 1);
		UI.MapArea.EndY = std::min<int>(UI.MapArea.EndY, UI.MapArea.Y + Map.Info.MapHeight * Map.GetCurrentPixelTileSize().y - 1);
	}

	UI.SelectedViewport = UI.Viewports;

	SetViewportMode(VIEWPORT_SINGLE);

	UI.CompletedBarColor = Video.MapRGB(TheScreen->format, UI.CompletedBarColorRGB);
	UI.ViewportCursorColor = ColorWhite;
}
Example #20
0
/**
**	Load all cursor sprites.
*/
global void LoadCursors(void)
{
    int i;
    const char* file;

    for( i=0; i<sizeof(Cursors)/sizeof(*Cursors); ++i ) {
	if( !(file=Cursors[i].File[ThisPlayer->Race]) ) {
	    file=Cursors[i].File[0];	// default one, no race specific
	}
	// FIXME: size and hot-point extra!
	if( file ) {
	    char* buf;

	    buf=alloca(strlen(file)+9+1);
	    file=strcat(strcpy(buf,"graphic/"),file);
	    ShowLoadProgress("\tCursor %s\n",file);
	    Cursors[i].RleSprite=LoadRleSprite(file
		    ,0,0);
	    // FIXME: this is hack!!
		    //,Cursors[i].Width,Cursors[i].Height);
	}
    }
}
Example #21
0
/**
**	Load all cursor sprites.
**
**	@param race	Cursor graphics of this race to load.
*/
global void LoadCursors(const char* race)
{
    int i;
    const char* file;

    //
    //	Free old cursor sprites.
    //
    for( i=0; Cursors[i].OType; ++i ) {
	VideoSaveFree(Cursors[i].Sprite);
	Cursors[i].Sprite = NULL;
    }

    //
    //	Load the graphics
    //
    for( i=0; Cursors[i].OType; ++i ) {
	//
	//	Only load cursors of this race or universal cursors.
	//
	if( Cursors[i].Race && strcmp(Cursors[i].Race,race) ) {
	    continue;
	}

	file=Cursors[i].File;
	if( file ) {
	    char* buf;

	    buf=alloca(strlen(file)+9+1);
	    file=strcat(strcpy(buf,"graphics/"),file);
	    ShowLoadProgress("\tCursor %s\n",file);
	    Cursors[i].Sprite=LoadSprite(file,
		    Cursors[i].Width,Cursors[i].Height);
	}
    }
}