Commit 5a6295c5 authored by argon.sun's avatar argon.sun

merge

parents 8af6db19 6b40d746
......@@ -703,11 +703,21 @@ void Game::WaitFrameSignal(int frame) {
frameSignal.Wait();
}
void Game::DrawThumb(code_pointer cp, position2di pos, std::unordered_map<int, int>* lflist) {
const int width = 44; //standard pic size, maybe it should be defined in game.h
const int height = 64;
int code = cp->first;
int lcode = cp->second.alias;
if(lcode == 0)
lcode = code;
driver->draw2DImage(imageManager.GetTextureThumb(code), pos);
irr::video::ITexture* img = imageManager.GetTextureThumb(code);
if(img == NULL)
return; //NULL->getSize() will cause a crash
dimension2d<u32> size = img->getSize();
if(size.Width == width and size.Height == height)
driver->draw2DImage(img, pos);
else
driver->draw2DImage(img, rect<s32>(pos.X, pos.Y,pos.X+width,pos.Y+height), rect<s32>(0,0,size.Width,size.Height));
if(lflist->count(lcode)) {
switch((*lflist)[lcode]) {
case 0:
......
......@@ -711,6 +711,7 @@ void Game::ShowCardInfo(int code) {
wchar_t formatBuffer[256];
dataManager.GetData(code, &cd);
imgCard->setImage(imageManager.GetTexture(code));
imgCard->setScaleImage(true); //I don't know weather check size or not will be faster; if Irrlicht don't check size internal and cause slow, check size like Game::DrawThumb()
if(cd.alias != 0 && (cd.alias - code < 10 || code - cd.alias < 10))
myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(cd.alias), cd.alias);
else myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(code), code);
......
......@@ -19,6 +19,7 @@ int main(int argc, char* argv[]) {
ygo::mainGame = &_game;
if(!ygo::mainGame->Initialize())
return 0;
if(argc >= 2)
if(!strcmp(argv[1], "-debug"))
enable_log = true;
......@@ -35,6 +36,7 @@ int main(int argc, char* argv[]) {
if(!strcmp(argv[1], "-j")) {
event.GUIEvent.Caller = ygo::mainGame->btnLanMode;
ygo::mainGame->device->postEventFromUser(event);
//TODO: wait for wLanWindow show. if network connection faster than wLanWindow, wLanWindow will still show on duel scene.
event.GUIEvent.Caller = ygo::mainGame->btnJoinHost;
ygo::mainGame->device->postEventFromUser(event);
} else if(!strcmp(argv[1], "-d")) {
......@@ -45,12 +47,14 @@ int main(int argc, char* argv[]) {
ygo::mainGame->device->postEventFromUser(event);
ygo::mainGame->lstReplayList->setSelected(0);
event.GUIEvent.Caller = ygo::mainGame->btnLoadReplay;
ygo::mainGame->device->postEventFromUser(event);
}
}
ygo::mainGame->MainLoop();
#ifdef _WIN32
WSACleanup();
#else
#endif //_WIN32
return EXIT_SUCCESS;
}
......@@ -42,7 +42,7 @@ void ImageManager::ClearTexture() {
}
void ImageManager::RemoveTexture(int code) {
auto tit = tMap.find(code);
if(tit != tMap.end()) {
if(tit != tMap.end() and tThumb.find(code)->second != tit->second) { //if member of tThumb point to this; don't remove
if(tit->second)
driver->removeTexture(tit->second);
tMap.erase(tit);
......@@ -54,8 +54,14 @@ irr::video::ITexture* ImageManager::GetTexture(int code) {
auto tit = tMap.find(code);
if(tit == tMap.end()) {
char file[256];
sprintf(file, "pics/%d.jpg", code);
sprintf(file, "pics/%d.jpg", code); //suggest that define the path in game.h
irr::video::ITexture* img = driver->getTexture(file);
if(img == NULL){
sprintf(file, "pics/thumbnail/%d.jpg", code);
img = driver->getTexture(file);
if(img)
tThumb[code] = img;
}
tMap[code] = img;
return img;
}
......@@ -66,15 +72,24 @@ irr::video::ITexture* ImageManager::GetTexture(int code) {
}
irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if(code == 0)
return 0;
return tUnknown;
auto tit = tThumb.find(code);
if(tit == tThumb.end()) {
char file[32];
sprintf(file, "pics/thumbnail/%d.jpg", code);
irr::video::ITexture* img = driver->getTexture(file);
if(img == NULL){
sprintf(file, "pics/%d.jpg", code);
img = driver->getTexture(file);
if(img)
tMap[code] = img;
}
tThumb[code] = img;
return img;
}
if(tit->second)
return tit->second;
else
return tUnknown;
}
}
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