Commit 24fe16fd authored by nanahira's avatar nanahira Committed by mercury233

update unknown card display (#12)

parent a00b05ba
......@@ -12,7 +12,9 @@ bool ImageManager::Initial() {
tCover[3] = GetTextureFromFile("textures/cover2.jpg", CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
if(!tCover[3])
tCover[3] = tCover[2];
tUnknown = NULL;
tUnknown[0] = NULL;
tUnknown[1] = NULL;
tUnknown[2] = NULL;
tAct = driver->getTexture("textures/act.png");
tAttack = driver->getTexture("textures/attack.png");
tChain = driver->getTexture("textures/chain.png");
......@@ -60,6 +62,12 @@ void ImageManager::ClearTexture() {
tMap[1].clear();
tThumb.clear();
tFields.clear();
for(int i = 0; i < 3; ++i) {
if(tUnknown[i] != NULL) {
driver->removeTexture(tUnknown[i]);
tUnknown[i] = NULL;
}
}
}
void ImageManager::RemoveTexture(int code) {
auto tit = tMap[0].find(code);
......@@ -86,8 +94,8 @@ void ImageManager::ResizeTexture() {
tCover[1] = GetTextureFromFile("textures/cover2.jpg", imgWidth, imgHeight);
if(!tCover[1])
tCover[1] = tCover[0];
driver->removeTexture(tUnknown);
tUnknown = GetTextureFromFile("textures/unknown.jpg", imgWidth, imgHeight);
//driver->removeTexture(tUnknown);
//tUnknown = GetTextureFromFile("textures/unknown.jpg", imgWidth, imgHeight);
driver->removeTexture(tBackGround);
tBackGround = GetTextureFromFile("textures/bg.jpg", bgWidth, bgHeight);
driver->removeTexture(tBackGround_menu);
......@@ -192,9 +200,12 @@ irr::video::ITexture* ImageManager::GetTextureFromFile(char* file, s32 width, s3
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) {
if(code == 0)
return tUnknown;
int width = CARD_IMG_WIDTH;
int height = CARD_IMG_HEIGHT;
if(fit) {
......@@ -204,6 +215,8 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
width = width * mul;
height = height * mul;
}
if(code == 0)
return GetTextureUnknown(width, height, fit ? 1 : 0);
auto tit = tMap[fit ? 1 : 0].find(code);
if(tit == tMap[fit ? 1 : 0].end()) {
char file[256];
......@@ -218,19 +231,19 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
return GetTextureThumb(code);
}
tMap[fit ? 1 : 0][code] = img;
return (img == NULL) ? tUnknown : img;
return (img == NULL) ? GetTextureUnknown(width, height, fit ? 1 : 0) : img;
}
if(tit->second)
return tit->second;
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) {
if(code == 0)
return tUnknown;
auto tit = tThumb.find(code);
int width = CARD_THUMB_WIDTH * mainGame->xScale;
int height = CARD_THUMB_HEIGHT * mainGame->yScale;
if(code == 0)
return GetTextureUnknown(width, height, 2);
if(tit == tThumb.end()) {
char file[256];
sprintf(file, "expansions/pics/thumbnail/%d.jpg", code);
......@@ -248,12 +261,12 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
}
}
tThumb[code] = img;
return (img == NULL) ? tUnknown : img;
return (img == NULL) ? GetTextureUnknown(width, height, 2) : img;
}
if(tit->second)
return tit->second;
else
return tUnknown;
return GetTextureUnknown(width, height, 2);
}
irr::video::ITexture* ImageManager::GetTextureField(int code) {
if(code == 0)
......
......@@ -15,6 +15,7 @@ public:
void RemoveTexture(int code);
void ResizeTexture();
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* GetTextureThumb(int code);
irr::video::ITexture* GetTextureField(int code);
......@@ -25,7 +26,7 @@ public:
irr::IrrlichtDevice* device;
irr::video::IVideoDriver* driver;
irr::video::ITexture* tCover[4];
irr::video::ITexture* tUnknown;
irr::video::ITexture* tUnknown[3];
irr::video::ITexture* tAct;
irr::video::ITexture* tAttack;
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