-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the unit type variation class to its own source/header files
- Loading branch information
Showing
15 changed files
with
200 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// _________ __ __ | ||
// / _____// |_____________ _/ |______ ____ __ __ ______ | ||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ | ||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | | ||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > | ||
// \/ \/ \//_____/ \/ | ||
// ______________________ ______________________ | ||
// T H E W A R B E G I N S | ||
// Stratagus - A free fantasy real time strategy game engine | ||
// | ||
/**@name unit_type_variation.h - The unit type variation header file. */ | ||
// | ||
// (c) Copyright 2014-2019 by Andrettin | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation; only version 2 of the License. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
// 02111-1307, USA. | ||
// | ||
|
||
#ifndef __UNIT_TYPE_VARIATION_H__ | ||
#define __UNIT_TYPE_VARIATION_H__ | ||
|
||
/*---------------------------------------------------------------------------- | ||
-- Includes | ||
----------------------------------------------------------------------------*/ | ||
|
||
#include "icons.h" | ||
#include "unit/unittype.h" //for the image layers enum | ||
#include "upgrade/upgrade_structs.h" //for the costs enum | ||
|
||
#include <map> | ||
#include <string> | ||
#include <vector> | ||
|
||
/*---------------------------------------------------------------------------- | ||
-- Declarations | ||
----------------------------------------------------------------------------*/ | ||
|
||
class CAnimations; | ||
class CConstruction; | ||
class CGraphic; | ||
class CPlayerColorGraphic; | ||
class CSeason; | ||
class CTerrainType; | ||
class CUnitType; | ||
|
||
class CUnitTypeVariation | ||
{ | ||
public: | ||
CUnitTypeVariation() | ||
{ | ||
memset(LayerSprites, 0, sizeof(LayerSprites)); | ||
memset(SpriteWhenLoaded, 0, sizeof(SpriteWhenLoaded)); | ||
memset(SpriteWhenEmpty, 0, sizeof(SpriteWhenEmpty)); | ||
} | ||
|
||
~CUnitTypeVariation(); | ||
|
||
int ID = -1; /// The variation's index within the appropriate variation vector of its unit type | ||
std::string VariationId; /// Variation's name. | ||
std::string TypeName; /// Type name. | ||
std::string File; /// Variation's graphics. | ||
std::string ShadowFile; /// Variation's shadow graphics. | ||
std::string LightFile; /// Variation's light graphics. | ||
int FrameWidth = 0; | ||
int FrameHeight = 0; | ||
int ResourceMin = 0; | ||
int ResourceMax = 0; | ||
int Weight = 1; /// The weight for when randomly choosing a variation | ||
IconConfig Icon; /// Icon to display for this unit | ||
CPlayerColorGraphic *Sprite = nullptr; /// The graphic corresponding to File. | ||
CGraphic *ShadowSprite = nullptr; /// The graphic corresponding to ShadowFile. | ||
CGraphic *LightSprite = nullptr; /// The graphic corresponding to LightFile. | ||
CAnimations *Animations = nullptr; /// Animation scripts | ||
CConstruction *Construction = nullptr; /// What is shown in construction phase | ||
|
||
std::vector<const CUpgrade *> UpgradesRequired; /// Upgrades required by variation | ||
std::vector<const CUpgrade *> UpgradesForbidden; /// If the player has one of these upgrades, the unit can't have this variation | ||
std::vector<int> ItemClassesEquipped; | ||
std::vector<int> ItemClassesNotEquipped; | ||
std::vector<const CUnitType *> ItemsEquipped; | ||
std::vector<const CUnitType *> ItemsNotEquipped; | ||
std::vector<const CTerrainType *> Terrains; | ||
std::vector<const CTerrainType *> TerrainsForbidden; | ||
std::vector<const CSeason *> Seasons; | ||
std::vector<const CSeason *> ForbiddenSeasons; | ||
|
||
std::string LayerFiles[MaxImageLayers]; /// Variation's layer graphics. | ||
std::string FileWhenLoaded[MaxCosts]; /// Change the graphic when the unit is loaded. | ||
std::string FileWhenEmpty[MaxCosts]; /// Change the graphic when the unit is empty. | ||
CPlayerColorGraphic *LayerSprites[MaxImageLayers]; /// The graphics corresponding to LayerFiles. | ||
CPlayerColorGraphic *SpriteWhenLoaded[MaxCosts]; /// The graphic corresponding to FileWhenLoaded. | ||
CPlayerColorGraphic *SpriteWhenEmpty[MaxCosts]; /// The graphic corresponding to FileWhenEmpty | ||
|
||
std::map<int, IconConfig> ButtonIcons; /// icons for button actions | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// _________ __ __ | ||
// / _____// |_____________ _/ |______ ____ __ __ ______ | ||
// \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ | ||
// / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | | ||
// /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > | ||
// \/ \/ \//_____/ \/ | ||
// ______________________ ______________________ | ||
// T H E W A R B E G I N S | ||
// Stratagus - A free fantasy real time strategy game engine | ||
// | ||
/**@name unit_type_variation.cpp - The unit type variation source file. */ | ||
// | ||
// (c) Copyright 2014-2019 by Andrettin | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation; only version 2 of the License. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | ||
// 02111-1307, USA. | ||
// | ||
|
||
/*---------------------------------------------------------------------------- | ||
-- Includes | ||
----------------------------------------------------------------------------*/ | ||
|
||
#include "stratagus.h" | ||
|
||
#include "unit/unit_type_variation.h" | ||
|
||
#include "video.h" | ||
|
||
/*---------------------------------------------------------------------------- | ||
-- Functions | ||
----------------------------------------------------------------------------*/ | ||
|
||
CUnitTypeVariation::~CUnitTypeVariation() | ||
{ | ||
if (this->Sprite) { | ||
CGraphic::Free(this->Sprite); | ||
} | ||
if (this->ShadowSprite) { | ||
CGraphic::Free(this->ShadowSprite); | ||
} | ||
if (this->LightSprite) { | ||
CGraphic::Free(this->LightSprite); | ||
} | ||
for (int i = 0; i < MaxImageLayers; ++i) { | ||
if (this->LayerSprites[i]) { | ||
CGraphic::Free(this->LayerSprites[i]); | ||
} | ||
} | ||
for (int res = 0; res < MaxCosts; ++res) { | ||
if (this->SpriteWhenLoaded[res]) { | ||
CGraphic::Free(this->SpriteWhenLoaded[res]); | ||
} | ||
if (this->SpriteWhenEmpty[res]) { | ||
CGraphic::Free(this->SpriteWhenEmpty[res]); | ||
} | ||
} | ||
} |
Oops, something went wrong.