Commit 0642152d authored by nanahira's avatar nanahira

Merge branch 'master' into server

parents f710e8f8 fd5f1af5
......@@ -129,6 +129,8 @@ bool Game::Initialize() {
skinSystem->applySkin(skins[index].c_str());
}
}
xScale = 1;
yScale = 1;
linePatternD3D = 0;
linePatternGL = 0x0f0f;
waitFrame = 0;
......@@ -1554,15 +1556,15 @@ void Game::ShowCardInfo(int code, bool resize) {
wcscat(formatBuffer, scaleBuffer);
}
stDataInfo->setText(formatBuffer);
int offset_sayuri = 0;
int offset_arrows = 0;
if(cd.type & TYPE_LINK && cd.level > 5 && window_size.Width < 1220.0)
offset_sayuri = 15;
stDataInfo->setRelativePosition(rect<s32>(15, 60, 300 * xScale - 13, (83 + offset_sayuri)));
//stSetName->setRelativePosition(rect<s32>(15, (83 + offset_sayuri) * yScale, 296 * xScale, (83 + offset_sayuri) * yScale + offset));
//stText->setRelativePosition(rect<s32>(15, (83 + offset_sayuri) * yScale + offset, 287 * xScale, 324 * yScale));
stSetName->setRelativePosition(rect<s32>(15, (83 + offset_sayuri), 296 * xScale, (83 + offset_sayuri) + offset));
stText->setRelativePosition(rect<s32>(15, (83 + offset_sayuri) + offset, 287 * xScale, 324 * yScale));
scrCardText->setRelativePosition(rect<s32>(287 * xScale - 20, (83 + offset_sayuri) + offset, 287 * xScale, 324 * yScale));
offset_arrows = 15;
stDataInfo->setRelativePosition(rect<s32>(15, 60, 300 * xScale - 13, (83 + offset_arrows)));
//stSetName->setRelativePosition(rect<s32>(15, (83 + offset_arrows) * yScale, 296 * xScale, (83 + offset_arrows) * yScale + offset));
//stText->setRelativePosition(rect<s32>(15, (83 + offset_arrows) * yScale + offset, 287 * xScale, 324 * yScale));
stSetName->setRelativePosition(rect<s32>(15, (83 + offset_arrows), 296 * xScale, (83 + offset_arrows) + offset));
stText->setRelativePosition(rect<s32>(15, (83 + offset_arrows) + offset, 287 * xScale, 324 * yScale));
scrCardText->setRelativePosition(rect<s32>(287 * xScale - 20, (83 + offset_arrows) + offset, 287 * xScale, 324 * yScale));
} else {
myswprintf(formatBuffer, L"[%ls]", dataManager.FormatType(cd.type));
stInfo->setText(formatBuffer);
......@@ -1818,6 +1820,9 @@ void Game::OnResize() {
//old_guiFont->drop();
old_textFont->drop();
imageManager.ClearTexture();
imageManager.ResizeTexture();
wMainMenu->setRelativePosition(ResizeWin(370, 200, 650, 415));
wDeckEdit->setRelativePosition(Resize(309, 5, 605, 130));
cbDBLFList->setRelativePosition(Resize(80, 5, 220, 30));
......@@ -1948,8 +1953,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;
......
......@@ -11,17 +11,9 @@ ImageManager imageManager;
bool ImageManager::Initial() {
RefreshRandomImageList();
tCover[0] = GetRandomImage(TEXTURE_COVER_S);
if(!tCover[0])
tCover[0] = driver->getTexture("textures/cover.jpg");
tCover[1] = GetRandomImage(TEXTURE_COVER_O);
if(!tCover[1])
tCover[1] = driver->getTexture("textures/cover2.jpg");
if(!tCover[1])
tCover[1] = GetRandomImage(TEXTURE_COVER_S);
if(!tCover[1])
tCover[1] = tCover[0];
//tUnknown = driver->getTexture("textures/unknown.jpg");
tCover[0] = NULL;
tCover[1] = NULL;
//tUnknown = NULL;
tUnknown[0] = NULL;
tUnknown[1] = NULL;
tUnknown[2] = NULL;
......@@ -45,25 +37,9 @@ 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 = GetRandomImage(TEXTURE_DUEL);
if(!tBackGround)
tBackGround = driver->getTexture("textures/bg.jpg");
if(!tBackGround)
tBackGround = driver->getTexture("textures/bg_duel.jpg");
tBackGround_menu = GetRandomImage(TEXTURE_MENU);
if(!tBackGround_menu)
tBackGround_menu = driver->getTexture("textures/bg_menu.jpg");
if(!tBackGround_menu)
tBackGround_menu = GetRandomImage(TEXTURE_DUEL);
if(!tBackGround_menu)
tBackGround_menu = tBackGround;
tBackGround_deck = GetRandomImage(TEXTURE_DECK);
if(!tBackGround_deck)
tBackGround_deck = driver->getTexture("textures/bg_deck.jpg");
if(!tBackGround_deck)
tBackGround_deck = GetRandomImage(TEXTURE_DUEL);
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");
......@@ -78,20 +54,37 @@ bool ImageManager::Initial() {
tLScale[i] = driver->getTexture(buff);
}
tClock = driver->getTexture("textures/clock.png");
ResizeTexture();
return true;
}
irr::video::ITexture* ImageManager::GetRandomImage(int image_type) {
int count = ImageList[image_type].size();
if(count <= 0)
return 0;
return NULL;
char ImageName[1024];
wchar_t fname[1024];
int image_id = rand() % count;
if(saved_image_id[image_type] == -1)
saved_image_id[image_type] = rand() % count;
int image_id = saved_image_id[image_type];
auto name = ImageList[image_type][image_id].c_str();
myswprintf(fname, L"./textures/%ls", name);
BufferIO::EncodeUTF8(fname, ImageName);
return driver->getTexture(ImageName);
}
irr::video::ITexture* ImageManager::GetRandomImage(int image_type, s32 width, s32 height) {
int count = ImageList[image_type].size();
if(count <= 0)
return NULL;
char ImageName[1024];
wchar_t fname[1024];
if(saved_image_id[image_type] == -1)
saved_image_id[image_type] = rand() % count;
int image_id = saved_image_id[image_type];
auto name = ImageList[image_type][image_id].c_str();
myswprintf(fname, L"./textures/%ls", name);
BufferIO::EncodeUTF8(fname, ImageName);
return GetTextureFromFile(ImageName, width, height);
}
void ImageManager::RefreshRandomImageList() {
RefreshImageDir(L"bg/", TEXTURE_DUEL);
RefreshImageDir(L"bg_duel/", TEXTURE_DUEL);
......@@ -101,6 +94,10 @@ void ImageManager::RefreshRandomImageList() {
RefreshImageDir(L"cover2/", TEXTURE_COVER_O);
RefreshImageDir(L"attack/", TEXTURE_ATTACK);
RefreshImageDir(L"act/", TEXTURE_ACTIVATE);
for(int i = 0; i < 7; ++ i) {
saved_image_id[i] = -1;
}
}
void ImageManager::RefreshImageDir(std::wstring path, int image_type) {
#ifdef _WIN32
......@@ -158,7 +155,7 @@ void ImageManager::ClearTexture() {
tMap[0].clear();
tMap[1].clear();
tThumb.clear();
tThumb.clear();
tFields.clear();
for(int i = 0; i < 3; ++i)
if(tUnknown[i] != NULL) {
driver->removeTexture(tUnknown[i]);
......@@ -179,6 +176,48 @@ 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] = GetRandomImage(TEXTURE_COVER_S, imgWidth, imgHeight);
if(!tCover[0])
tCover[0] = GetTextureFromFile("textures/cover.jpg", imgWidth, imgHeight);
tCover[1] = GetRandomImage(TEXTURE_COVER_O, imgWidth, imgHeight);
if(!tCover[1])
tCover[1] = GetTextureFromFile("textures/cover2.jpg", imgWidth, imgHeight);
if(!tCover[1])
tCover[1] = GetRandomImage(TEXTURE_COVER_S, imgWidth, imgHeight);
if(!tCover[1])
tCover[1] = tCover[0];
//driver->removeTexture(tUnknown);
//tUnknown = GetTextureFromFile("textures/unknown.jpg", imgWidth, imgHeight);
driver->removeTexture(tBackGround);
tBackGround = GetRandomImage(TEXTURE_DUEL, bgWidth, bgHeight);
if(!tBackGround)
tBackGround = GetTextureFromFile("textures/bg.jpg", bgWidth, bgHeight);
if(!tBackGround)
tBackGround = GetTextureFromFile("textures/bg_duel.jpg", bgWidth, bgHeight);
driver->removeTexture(tBackGround_menu);
tBackGround_menu = GetRandomImage(TEXTURE_MENU, bgWidth, bgHeight);
if(!tBackGround_menu)
tBackGround_menu = GetTextureFromFile("textures/bg_menu.jpg", bgWidth, bgHeight);
if(!tBackGround_menu)
tBackGround_menu = GetRandomImage(TEXTURE_DUEL, bgWidth, bgHeight);
if(!tBackGround_menu)
tBackGround_menu = tBackGround;
driver->removeTexture(tBackGround_deck);
tBackGround_deck = GetRandomImage(TEXTURE_DECK, bgWidth, bgHeight);
if(!tBackGround_deck)
tBackGround_deck = GetTextureFromFile("textures/bg_deck.jpg", bgWidth, bgHeight);
if(!tBackGround_deck)
tBackGround_deck = GetRandomImage(TEXTURE_DUEL, 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;
......
......@@ -10,14 +10,17 @@ namespace ygo {
class ImageManager {
public:
std::vector<std::wstring> ImageList[7];
int saved_image_id[7];
bool Initial();
//random image
irr::video::ITexture* GetRandomImage(int image_type);
irr::video::ITexture* GetRandomImage(int image_type, s32 width, s32 height);
void RefreshRandomImageList();
void RefreshImageDir(std::wstring path, int image_type);
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* GetTextureUnknown(s32 width, s32 height, int index);
irr::video::ITexture* GetTexture(int code, bool fit = false);
......
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