Commit 88f360d8 authored by mercury233's avatar mercury233

update resize texture

parent 8aaae618
...@@ -40,6 +40,8 @@ bool Game::Initialize() { ...@@ -40,6 +40,8 @@ bool Game::Initialize() {
device = irr::createDeviceEx(params); device = irr::createDeviceEx(params);
if(!device) if(!device)
return false; return false;
xScale = 1;
yScale = 1;
linePatternD3D = 0; linePatternD3D = 0;
linePatternGL = 0x0f0f; linePatternGL = 0x0f0f;
waitFrame = 0; waitFrame = 0;
...@@ -1528,6 +1530,9 @@ void Game::OnResize() { ...@@ -1528,6 +1530,9 @@ void Game::OnResize() {
//old_guiFont->drop(); //old_guiFont->drop();
old_textFont->drop(); old_textFont->drop();
imageManager.ClearTexture();
imageManager.ResizeTexture();
wMainMenu->setRelativePosition(ResizeWin(370, 200, 650, 415)); wMainMenu->setRelativePosition(ResizeWin(370, 200, 650, 415));
wDeckEdit->setRelativePosition(Resize(309, 5, 605, 130)); wDeckEdit->setRelativePosition(Resize(309, 5, 605, 130));
cbDBLFList->setRelativePosition(Resize(80, 5, 220, 30)); cbDBLFList->setRelativePosition(Resize(80, 5, 220, 30));
...@@ -1657,8 +1662,6 @@ void Game::OnResize() { ...@@ -1657,8 +1662,6 @@ void Game::OnResize() {
btnChainWhenAvail->setRelativePosition(Resize(205, 180, 295, 215)); btnChainWhenAvail->setRelativePosition(Resize(205, 180, 295, 215));
btnShuffle->setRelativePosition(Resize(205, 230, 295, 265)); btnShuffle->setRelativePosition(Resize(205, 230, 295, 265));
btnCancelOrFinish->setRelativePosition(Resize(205, 230, 295, 265)); btnCancelOrFinish->setRelativePosition(Resize(205, 230, 295, 265));
imageManager.ClearTexture();
} }
recti Game::Resize(s32 x, s32 y, s32 x2, s32 y2) { recti Game::Resize(s32 x, s32 y, s32 x2, s32 y2) {
x = x * xScale; x = x * xScale;
......
...@@ -6,11 +6,9 @@ namespace ygo { ...@@ -6,11 +6,9 @@ namespace ygo {
ImageManager imageManager; ImageManager imageManager;
bool ImageManager::Initial() { bool ImageManager::Initial() {
tCover[0] = driver->getTexture("textures/cover.jpg"); tCover[0] = 0;
tCover[1] = driver->getTexture("textures/cover2.jpg"); tCover[1] = 0;
if(!tCover[1]) tUnknown = 0;
tCover[1] = tCover[0];
tUnknown = driver->getTexture("textures/unknown.jpg");
tAct = driver->getTexture("textures/act.png"); tAct = driver->getTexture("textures/act.png");
tAttack = driver->getTexture("textures/attack.png"); tAttack = driver->getTexture("textures/attack.png");
tChain = driver->getTexture("textures/chain.png"); tChain = driver->getTexture("textures/chain.png");
...@@ -27,17 +25,14 @@ bool ImageManager::Initial() { ...@@ -27,17 +25,14 @@ bool ImageManager::Initial() {
tHand[0] = driver->getTexture("textures/f1.jpg"); tHand[0] = driver->getTexture("textures/f1.jpg");
tHand[1] = driver->getTexture("textures/f2.jpg"); tHand[1] = driver->getTexture("textures/f2.jpg");
tHand[2] = driver->getTexture("textures/f3.jpg"); tHand[2] = driver->getTexture("textures/f3.jpg");
tBackGround = driver->getTexture("textures/bg.jpg"); tBackGround = 0;
tBackGround_menu = driver->getTexture("textures/bg_menu.jpg"); tBackGround_menu = 0;
if(!tBackGround_menu) tBackGround_deck = 0;
tBackGround_menu = tBackGround;
tBackGround_deck = driver->getTexture("textures/bg_deck.jpg");
if(!tBackGround_deck)
tBackGround_deck = tBackGround;
tField[0] = driver->getTexture("textures/field2.png"); tField[0] = driver->getTexture("textures/field2.png");
tFieldTransparent[0] = driver->getTexture("textures/field-transparent2.png"); tFieldTransparent[0] = driver->getTexture("textures/field-transparent2.png");
tField[1] = driver->getTexture("textures/field3.png"); tField[1] = driver->getTexture("textures/field3.png");
tFieldTransparent[1] = driver->getTexture("textures/field-transparent3.png"); tFieldTransparent[1] = driver->getTexture("textures/field-transparent3.png");
ResizeTexture();
return true; return true;
} }
void ImageManager::SetDevice(irr::IrrlichtDevice* dev) { void ImageManager::SetDevice(irr::IrrlichtDevice* dev) {
...@@ -60,6 +55,7 @@ void ImageManager::ClearTexture() { ...@@ -60,6 +55,7 @@ void ImageManager::ClearTexture() {
tMap[0].clear(); tMap[0].clear();
tMap[1].clear(); tMap[1].clear();
tThumb.clear(); tThumb.clear();
tFields.clear();
} }
void ImageManager::RemoveTexture(int code) { void ImageManager::RemoveTexture(int code) {
auto tit = tMap[0].find(code); auto tit = tMap[0].find(code);
...@@ -75,6 +71,30 @@ void ImageManager::RemoveTexture(int code) { ...@@ -75,6 +71,30 @@ void ImageManager::RemoveTexture(int code) {
tMap[1].erase(tit); tMap[1].erase(tit);
} }
} }
void ImageManager::ResizeTexture() {
irr::s32 imgWidth = CARD_IMG_WIDTH * mainGame->xScale;
irr::s32 imgHeight = CARD_IMG_HEIGHT * mainGame->yScale;
irr::s32 bgWidth = 1024 * mainGame->xScale;
irr::s32 bgHeight = 640 * mainGame->yScale;
driver->removeTexture(tCover[0]);
driver->removeTexture(tCover[1]);
tCover[0] = GetTextureFromFile("textures/cover.jpg", imgWidth, imgHeight);
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(tBackGround);
tBackGround = GetTextureFromFile("textures/bg.jpg", bgWidth, bgHeight);
driver->removeTexture(tBackGround_menu);
tBackGround_menu = GetTextureFromFile("textures/bg_menu.jpg", bgWidth, bgHeight);
if(!tBackGround_menu)
tBackGround_menu = tBackGround;
driver->removeTexture(tBackGround_deck);
tBackGround_deck = GetTextureFromFile("textures/bg_deck.jpg", bgWidth, bgHeight);
if(!tBackGround_deck)
tBackGround_deck = tBackGround;
}
// function by Warr1024, from https://github.com/minetest/minetest/issues/2419 , modified // function by Warr1024, from https://github.com/minetest/minetest/issues/2419 , modified
void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) { void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
double sx, sy, minsx, maxsx, minsy, maxsy, area, ra, ga, ba, aa, pw, ph, pa; double sx, sy, minsx, maxsx, minsy, maxsy, area, ra, ga, ba, aa, pw, ph, pa;
......
...@@ -13,6 +13,7 @@ public: ...@@ -13,6 +13,7 @@ public:
void SetDevice(irr::IrrlichtDevice* dev); void SetDevice(irr::IrrlichtDevice* dev);
void ClearTexture(); void ClearTexture();
void RemoveTexture(int code); void RemoveTexture(int code);
void ResizeTexture();
irr::video::ITexture* GetTextureFromFile(char* file, s32 width, s32 height); irr::video::ITexture* GetTextureFromFile(char* file, s32 width, s32 height);
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);
......
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