make construction lazy loaded as well
This commit is contained in:
parent
875f438778
commit
2cfbbed268
3 changed files with 13 additions and 3 deletions
src
|
@ -135,7 +135,7 @@ public:
|
|||
}
|
||||
~CConstruction();
|
||||
void Clean();
|
||||
void Load();
|
||||
void Load(bool force = false);
|
||||
|
||||
public:
|
||||
std::string Ident; /// construction identifier
|
||||
|
|
|
@ -85,7 +85,7 @@ void CConstruction::Clean()
|
|||
this->ShadowFile.Height = 0;
|
||||
}
|
||||
|
||||
void CConstruction::Load()
|
||||
void CConstruction::Load(bool force)
|
||||
{
|
||||
if (this->Ident.empty()) {
|
||||
return;
|
||||
|
@ -94,6 +94,11 @@ void CConstruction::Load()
|
|||
|
||||
this->Width = this->File.Width;
|
||||
this->Height = this->File.Height;
|
||||
#ifdef DYNAMIC_LOAD
|
||||
if (!force) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (!file.empty()) {
|
||||
ShowLoadProgress(_("Construction %s"), file.c_str());
|
||||
this->Sprite = CPlayerColorGraphic::New(file, this->Width, this->Height);
|
||||
|
|
|
@ -882,9 +882,14 @@ static void DrawConstruction(const int player, const CConstructionFrame *cframe,
|
|||
{
|
||||
PixelPos pos = screenPos;
|
||||
if (cframe->File == ConstructionFileConstruction) {
|
||||
const CConstruction &construction = *type.Construction;
|
||||
CConstruction &construction = *type.Construction;
|
||||
pos.x -= construction.Width / 2;
|
||||
pos.y -= construction.Height / 2;
|
||||
#ifdef DYNAMIC_LOAD
|
||||
if (!construction.Sprite) {
|
||||
construction.Load(true);
|
||||
}
|
||||
#endif
|
||||
if (frame < 0) {
|
||||
construction.Sprite->DrawPlayerColorFrameClipX(player, -frame - 1, pos.x, pos.y);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue