Commit d67e7239 authored by mercury233's avatar mercury233

Merge commit 'e154490f' into test

parents 641ca439 e154490f
......@@ -40,6 +40,8 @@ bool Game::Initialize() {
device = irr::createDeviceEx(params);
if(!device)
return false;
xScale = 1;
yScale = 1;
linePatternD3D = 0;
linePatternGL = 0x0f0f;
waitFrame = 0;
......@@ -1547,6 +1549,9 @@ void Game::OnResize() {
//old_guiFont->drop();
old_textFont->drop();
imageManager.ClearTexture();
imageManager.ResizeTexture();
recti menuposition = ResizeWin(370, 200, 650, 415);
wMainMenu->setRelativePosition(recti(menuposition.UpperLeftCorner.X, menuposition.UpperLeftCorner.Y, menuposition.LowerRightCorner.X + 300, menuposition.LowerRightCorner.Y + 185));
wDeckEdit->setRelativePosition(Resize(309, 5, 605, 130));
......@@ -1677,8 +1682,6 @@ void Game::OnResize() {
btnChainWhenAvail->setRelativePosition(Resize(205, 180, 295, 215));
btnShuffle->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) {
x = x * xScale;
......
......@@ -6,11 +6,9 @@ namespace ygo {
ImageManager imageManager;
bool ImageManager::Initial() {
tCover[0] = driver->getTexture("textures/cover.jpg");
tCover[1] = driver->getTexture("textures/cover2.jpg");
if(!tCover[1])
tCover[1] = tCover[0];
tUnknown = driver->getTexture("textures/unknown.jpg");
tCover[0] = NULL;
tCover[1] = NULL;
tUnknown = NULL;
tAct = driver->getTexture("textures/act.png");
tAttack = driver->getTexture("textures/attack.png");
tChain = driver->getTexture("textures/chain.png");
......@@ -27,17 +25,14 @@ bool ImageManager::Initial() {
tHand[0] = driver->getTexture("textures/f1.jpg");
tHand[1] = driver->getTexture("textures/f2.jpg");
tHand[2] = driver->getTexture("textures/f3.jpg");
tBackGround = driver->getTexture("textures/bg.jpg");
tBackGround_menu = driver->getTexture("textures/bg_menu.jpg");
if(!tBackGround_menu)
tBackGround_menu = tBackGround;
tBackGround_deck = driver->getTexture("textures/bg_deck.jpg");
if(!tBackGround_deck)
tBackGround_deck = tBackGround;
tBackGround = NULL;
tBackGround_menu = NULL;
tBackGround_deck = NULL;
tField[0] = driver->getTexture("textures/field2.png");
tFieldTransparent[0] = driver->getTexture("textures/field-transparent2.png");
tField[1] = driver->getTexture("textures/field3.png");
tFieldTransparent[1] = driver->getTexture("textures/field-transparent3.png");
ResizeTexture();
return true;
}
void ImageManager::SetDevice(irr::IrrlichtDevice* dev) {
......@@ -60,6 +55,7 @@ void ImageManager::ClearTexture() {
tMap[0].clear();
tMap[1].clear();
tThumb.clear();
tFields.clear();
}
void ImageManager::RemoveTexture(int code) {
auto tit = tMap[0].find(code);
......@@ -75,6 +71,30 @@ void ImageManager::RemoveTexture(int code) {
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
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;
......
......@@ -13,6 +13,7 @@ public:
void SetDevice(irr::IrrlichtDevice* dev);
void ClearTexture();
void RemoveTexture(int code);
void ResizeTexture();
irr::video::ITexture* GetTextureFromFile(char* file, s32 width, s32 height);
irr::video::ITexture* GetTexture(int code, bool fit = false);
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