Commit d411fc66 authored by nanahira's avatar nanahira

update unknown card display

parent 235391f1
...@@ -21,7 +21,10 @@ bool ImageManager::Initial() { ...@@ -21,7 +21,10 @@ bool ImageManager::Initial() {
tCover[1] = GetRandomImage(TEXTURE_COVER_S); tCover[1] = GetRandomImage(TEXTURE_COVER_S);
if(!tCover[1]) if(!tCover[1])
tCover[1] = tCover[0]; tCover[1] = tCover[0];
tUnknown = driver->getTexture("textures/unknown.jpg"); //tUnknown = driver->getTexture("textures/unknown.jpg");
tUnknown[0] = NULL;
tUnknown[1] = NULL;
tUnknown[2] = NULL;
tAct = GetRandomImage(TEXTURE_ACTIVATE); tAct = GetRandomImage(TEXTURE_ACTIVATE);
tAttack = GetRandomImage(TEXTURE_ATTACK); tAttack = GetRandomImage(TEXTURE_ATTACK);
if(!tAct) if(!tAct)
...@@ -155,6 +158,12 @@ void ImageManager::ClearTexture() { ...@@ -155,6 +158,12 @@ void ImageManager::ClearTexture() {
tMap[0].clear(); tMap[0].clear();
tMap[1].clear(); tMap[1].clear();
tThumb.clear(); tThumb.clear();
tThumb.clear();
for(int i = 0; i < 3; ++i)
if(tUnknown[i] != NULL) {
driver->removeTexture(tUnknown[i]);
tUnknown[i] = NULL;
}
} }
void ImageManager::RemoveTexture(int code) { void ImageManager::RemoveTexture(int code) {
auto tit = tMap[0].find(code); auto tit = tMap[0].find(code);
...@@ -263,9 +272,12 @@ irr::video::ITexture* ImageManager::GetTextureFromFile(char* file, s32 width, s3 ...@@ -263,9 +272,12 @@ irr::video::ITexture* ImageManager::GetTextureFromFile(char* file, s32 width, s3
return driver->getTexture(file); return driver->getTexture(file);
} }
} }
irr::video::ITexture* ImageManager::GetTextureUnknown(s32 width, s32 height, int index) {
if(tUnknown[index] == NULL)
tUnknown[index] = GetTextureFromFile("textures/unknown.jpg", width, height);
return tUnknown[index];
}
irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) { irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
if(code == 0)
return tUnknown;
int width = CARD_IMG_WIDTH; int width = CARD_IMG_WIDTH;
int height = CARD_IMG_HEIGHT; int height = CARD_IMG_HEIGHT;
if(fit) { if(fit) {
...@@ -275,6 +287,8 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) { ...@@ -275,6 +287,8 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
width = width * mul; width = width * mul;
height = height * mul; height = height * mul;
} }
if(code == 0)
return GetTextureUnknown(width, height, fit ? 1 : 0);
auto tit = tMap[fit ? 1 : 0].find(code); auto tit = tMap[fit ? 1 : 0].find(code);
if(tit == tMap[fit ? 1 : 0].end()) { if(tit == tMap[fit ? 1 : 0].end()) {
char file[256]; char file[256];
...@@ -297,19 +311,19 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) { ...@@ -297,19 +311,19 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
return GetTextureThumb(code); return GetTextureThumb(code);
} }
tMap[fit ? 1 : 0][code] = img; tMap[fit ? 1 : 0][code] = img;
return (img == NULL) ? tUnknown : img; return (img == NULL) ? GetTextureUnknown(width, height, fit ? 1 : 0) : img;
} }
if(tit->second) if(tit->second)
return tit->second; return tit->second;
else else
return mainGame->gameConf.use_image_scale ? tUnknown : GetTextureThumb(code); return mainGame->gameConf.use_image_scale ? GetTextureUnknown(width, height, fit ? 1 : 0) : GetTextureThumb(code);
} }
irr::video::ITexture* ImageManager::GetTextureThumb(int code) { irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if(code == 0)
return tUnknown;
auto tit = tThumb.find(code); auto tit = tThumb.find(code);
int width = CARD_THUMB_WIDTH * mainGame->xScale; int width = CARD_THUMB_WIDTH * mainGame->xScale;
int height = CARD_THUMB_HEIGHT * mainGame->yScale; int height = CARD_THUMB_HEIGHT * mainGame->yScale;
if(code == 0)
return GetTextureUnknown(width, height, 2);
if(tit == tThumb.end()) { if(tit == tThumb.end()) {
char file[256]; char file[256];
sprintf(file, "expansions/pics/thumbnail/%d.png", code); sprintf(file, "expansions/pics/thumbnail/%d.png", code);
...@@ -343,12 +357,12 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) { ...@@ -343,12 +357,12 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
} }
} }
tThumb[code] = img; tThumb[code] = img;
return (img == NULL) ? tUnknown : img; return (img == NULL) ? GetTextureUnknown(width, height, 2) : img;
} }
if(tit->second) if(tit->second)
return tit->second; return tit->second;
else else
return tUnknown; return GetTextureUnknown(width, height, 2);
} }
irr::video::ITexture* ImageManager::GetTextureField(int code) { irr::video::ITexture* ImageManager::GetTextureField(int code) {
if(code == 0) if(code == 0)
......
...@@ -19,6 +19,7 @@ public: ...@@ -19,6 +19,7 @@ public:
void ClearTexture(); void ClearTexture();
void RemoveTexture(int code); void RemoveTexture(int code);
irr::video::ITexture* GetTextureFromFile(char* file, s32 width, s32 height); irr::video::ITexture* GetTextureFromFile(char* file, s32 width, s32 height);
irr::video::ITexture* GetTextureUnknown(s32 width, s32 height, int index);
irr::video::ITexture* GetTexture(int code, bool fit = false); irr::video::ITexture* GetTexture(int code, bool fit = false);
irr::video::ITexture* GetTextureThumb(int code); irr::video::ITexture* GetTextureThumb(int code);
irr::video::ITexture* GetTextureField(int code); irr::video::ITexture* GetTextureField(int code);
...@@ -29,7 +30,7 @@ public: ...@@ -29,7 +30,7 @@ public:
irr::IrrlichtDevice* device; irr::IrrlichtDevice* device;
irr::video::IVideoDriver* driver; irr::video::IVideoDriver* driver;
irr::video::ITexture* tCover[2]; irr::video::ITexture* tCover[2];
irr::video::ITexture* tUnknown; irr::video::ITexture* tUnknown[3];
irr::video::ITexture* tAct; irr::video::ITexture* tAct;
irr::video::ITexture* tAttack; irr::video::ITexture* tAttack;
irr::video::ITexture* tNegated; irr::video::ITexture* tNegated;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment