Commit d0c25cce authored by nanahira's avatar nanahira

Merge branch 'master' into server

parents fddec5f9 d4ae3326
No preview for this file type
......@@ -12,6 +12,9 @@ namespace ygo {
ClientField::ClientField() {
panel = 0;
is_dragging_cardtext = false;
dragging_cardtext_start_pos = 0;
dragging_cardtext_start_y = 0;
hovered_card = 0;
clicked_card = 0;
highlighting_card = 0;
......
......@@ -117,6 +117,9 @@ public:
void RefreshCardCountDisplay();
irr::gui::IGUIElement* panel;
bool is_dragging_cardtext;
int dragging_cardtext_start_pos;
int dragging_cardtext_start_y;
std::vector<int> ancard;
int hovered_controler;
int hovered_location;
......
......@@ -496,7 +496,7 @@ void Game::DrawMisc() {
driver->setTransform(irr::video::ETS_WORLD, im);
driver->drawVertexPrimitiveList(matManager.vActivate, 4, matManager.iRectangle, 2);
}
if(dField.chains.size() > 1) {
if(dField.chains.size() > 1 || mainGame->gameConf.draw_single_chain) {
for(size_t i = 0; i < dField.chains.size(); ++i) {
if(dField.chains[i].solved)
break;
......@@ -1072,6 +1072,8 @@ void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) {
fadingList.push_back(fu);
}
void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) {
if(!win->isVisible() && !set_action)
return;
FadingUnit fu;
fu.fadingSize = win->getRelativePosition();
for(auto fit = fadingList.begin(); fit != fadingList.end(); ++fit)
......@@ -1287,8 +1289,13 @@ void Game::DrawDeckBd() {
DrawShadowText(numFont, deckBuilder.result_string, Resize(875, 137, 935, 157), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true);
driver->draw2DRectangle(Resize(805, 160, 1020, 630), 0x400000ff, 0x400000ff, 0x40000000, 0x40000000);
driver->draw2DRectangleOutline(Resize(804, 159, 1020, 630));
for(size_t i = 0; i < 7 && i + scrFilter->getPos() < deckBuilder.results.size(); ++i) {
for(size_t i = 0; i < 9 && i + scrFilter->getPos() < deckBuilder.results.size(); ++i) {
code_pointer ptr = deckBuilder.results[i + scrFilter->getPos()];
if(i >= 7)
{
imageManager.GetTextureThumb(ptr->second.code);
break;
}
if(deckBuilder.hovered_pos == 4 && deckBuilder.hovered_seq == (int)i)
driver->draw2DRectangle(0x80000000, Resize(806, 164 + i * 66, 1019, 230 + i * 66));
DrawThumb(ptr, position2di(810, 165 + i * 66), deckBuilder.filterList);
......
......@@ -267,6 +267,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
#endif
switch(pktType) {
case STOC_GAME_MSG: {
if(!mainGame->dInfo.isStarted)
break;
ClientAnalyze(pdata, len - 1);
break;
}
......@@ -466,24 +468,17 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->dField.Clear();
mainGame->is_building = true;
mainGame->is_siding = true;
mainGame->CloseGameWindow();
mainGame->wChat->setVisible(false);
mainGame->wPhase->setVisible(false);
mainGame->wDeckEdit->setVisible(false);
mainGame->wFilter->setVisible(false);
mainGame->wSort->setVisible(false);
mainGame->stTip->setVisible(false);
if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false);
mainGame->btnSideOK->setVisible(true);
mainGame->btnSideShuffle->setVisible(true);
mainGame->btnSideSort->setVisible(true);
mainGame->btnSideReload->setVisible(true);
if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false);
mainGame->btnSpectatorSwap->setVisible(false);
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
mainGame->btnShuffle->setVisible(false);
mainGame->deckBuilder.result_string[0] = L'0';
mainGame->deckBuilder.result_string[1] = 0;
mainGame->deckBuilder.results.clear();
......@@ -586,12 +581,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->RefreshCategoryDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect);
mainGame->cbCategorySelect->setEnabled(true);
mainGame->cbDeckSelect->setEnabled(true);
if(mainGame->wCreateHost->isVisible())
mainGame->HideElement(mainGame->wCreateHost);
else if(mainGame->wLanWindow->isVisible())
mainGame->HideElement(mainGame->wLanWindow);
else if(mainGame->wSinglePlay->isVisible())
mainGame->HideElement(mainGame->wSinglePlay);
mainGame->HideElement(mainGame->wCreateHost);
mainGame->HideElement(mainGame->wLanWindow);
mainGame->HideElement(mainGame->wSinglePlay);
mainGame->ShowElement(mainGame->wHostPrepare);
//if(!mainGame->chkIgnore1->isChecked())
mainGame->wChat->setVisible(true);
......@@ -753,14 +745,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->gMutex.lock();
if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false);
mainGame->btnSpectatorSwap->setVisible(false);
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
if(!mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
mainGame->dInfo.isReplaySkiping = false;
mainGame->wSurrender->setVisible(false);
mainGame->CloseGameButtons();
mainGame->stMessage->setText(dataManager.GetSysString(1500));
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.unlock();
......@@ -801,14 +788,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
case STOC_REPLAY: {
mainGame->gMutex.lock();
mainGame->wPhase->setVisible(false);
mainGame->wSurrender->setVisible(false);
if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false);
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
mainGame->btnShuffle->setVisible(false);
mainGame->CloseGameButtons();
char* prep = pdata;
Replay new_replay;
memcpy(&new_replay.pheader, prep, sizeof(ReplayHeader));
......@@ -2610,8 +2592,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dInfo.is_swapped = !mainGame->dInfo.is_swapped;
return true;
}
if(mainGame->wSurrender->isVisible())
mainGame->HideElement(mainGame->wSurrender);
mainGame->HideElement(mainGame->wSurrender);
if(!mainGame->dInfo.isReplay && mainGame->dInfo.player_type < 7) {
mainGame->btnLeaveGame->setText(dataManager.GetSysString(1351));
mainGame->btnLeaveGame->setVisible(true);
......@@ -3143,7 +3124,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->WaitFrameSignal(11);
}
}
if (mainGame->dField.chains.size() > 1) {
if(mainGame->dField.chains.size() > 1 || mainGame->gameConf.draw_single_chain) {
if (mainGame->dField.last_chain)
mainGame->WaitFrameSignal(11);
for(int i = 0; i < 5; ++i) {
......
......@@ -129,13 +129,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = false;
mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->stTip->setVisible(false);
mainGame->wCardImg->setVisible(false);
mainGame->wInfos->setVisible(false);
mainGame->wPhase->setVisible(false);
mainGame->btnLeaveGame->setVisible(false);
mainGame->btnSpectatorSwap->setVisible(false);
mainGame->wChat->setVisible(false);
mainGame->CloseDuelWindow();
mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true);
......@@ -1461,8 +1455,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->chain_when_avail = false;
UpdateChainButtons();
}
if(mainGame->wSurrender->isVisible())
mainGame->HideElement(mainGame->wSurrender);
mainGame->HideElement(mainGame->wSurrender);
mainGame->wCmdMenu->setVisible(false);
if(mainGame->fadingList.size())
break;
......@@ -1907,6 +1900,11 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true;
break;
}
case CHECKBOX_DRAW_SINGLE_CHAIN: {
mainGame->gameConf.draw_single_chain = mainGame->chkDrawSingleChain->isChecked() ? 1 : 0;
return true;
break;
}
case CHECKBOX_PREFER_EXPANSION: {
mainGame->gameConf.prefer_expansion_script = mainGame->chkPreferExpansionScript->isChecked() ? 1 : 0;
return true;
......@@ -2047,6 +2045,46 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
}
break;
}
case irr::EET_MOUSE_INPUT_EVENT: {
switch(event.MouseInput.Event) {
case irr::EMIE_LMOUSE_PRESSED_DOWN: {
IGUIElement* root = mainGame->env->getRootGUIElement();
position2di mousepos = position2di(event.MouseInput.X, event.MouseInput.Y);
if(root->getElementFromPoint(mousepos) == mainGame->stText) {
if(!mainGame->scrCardText->isVisible()) {
break;
}
is_dragging_cardtext = true;
dragging_cardtext_start_pos = mainGame->scrCardText->getPos();
dragging_cardtext_start_y = event.MouseInput.Y;
return true;
}
break;
}
case irr::EMIE_LMOUSE_LEFT_UP: {
is_dragging_cardtext = false;
break;
}
case irr::EMIE_MOUSE_MOVED: {
if(is_dragging_cardtext) {
if(!mainGame->scrCardText->isVisible()) {
is_dragging_cardtext = false;
break;
}
int step = mainGame->guiFont->getDimension(L"A").Height + mainGame->guiFont->getKerningHeight();
int pos = dragging_cardtext_start_pos + (dragging_cardtext_start_y - event.MouseInput.Y) / step;
int max = mainGame->scrCardText->getMax();
if(pos < 0) pos = 0;
if(pos > max) pos = max;
mainGame->scrCardText->setPos(pos);
mainGame->SetStaticText(mainGame->stText, mainGame->stText->getRelativePosition().getWidth() - 25, mainGame->guiFont, mainGame->showingtext, pos);
}
break;
}
default: break;
}
break;
}
default: break;
}
return false;
......
......@@ -345,6 +345,9 @@ bool Game::Initialize() {
chkQuickAnimation = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabHelper, CHECKBOX_QUICK_ANIMATION, dataManager.GetSysString(1299));
chkQuickAnimation->setChecked(gameConf.quick_animation != 0);
posY += 30;
chkDrawSingleChain = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabHelper, CHECKBOX_DRAW_SINGLE_CHAIN, dataManager.GetSysString(1287));
chkDrawSingleChain->setChecked(gameConf.draw_single_chain != 0);
posY += 30;
chkAutoSaveReplay = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabHelper, -1, dataManager.GetSysString(1366));
chkAutoSaveReplay->setChecked(gameConf.auto_save_replay != 0);
elmTabHelperLast = chkAutoSaveReplay;
......@@ -409,7 +412,7 @@ bool Game::Initialize() {
chkMusicMode = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1281));
chkMusicMode->setChecked(gameConf.music_mode != 0);
posY += 30;
chkEnablePScale = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1287));
chkEnablePScale = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1269));
chkEnablePScale->setChecked(gameConf.chkEnablePScale != 0);
posY += 30;
env->addStaticText(dataManager.GetSysString(1288), rect<s32>(posX + 23, posY + 3, posX + 160, posY + 28), false, false, tabSystem);
......@@ -1244,15 +1247,146 @@ void Game::RefreshBot() {
if(botInfo.size() == 0)
SetStaticText(stBotInfo, 200, guiFont, dataManager.GetSysString(1385));
}
void Game::LoadConfig() {
FILE* fp = fopen("system.conf", "r");
#ifndef YGOPRO_COMPAT_MYCARD
FILE* fp_user = fopen("system_user.conf", "r");
#endif //YGOPRO_COMPAT_MYCARD
bool Game::LoadConfigFromFile(const char* file) {
FILE* fp = fopen(file, "r");
if(!fp){
return false;
}
char linebuf[256];
char strbuf[32];
char valbuf[256];
wchar_t wstr[256];
while(fgets(linebuf, 256, fp)) {
sscanf(linebuf, "%s = %s", strbuf, valbuf);
if(!strcmp(strbuf, "antialias")) {
gameConf.antialias = atoi(valbuf);
} else if(!strcmp(strbuf, "use_d3d")) {
gameConf.use_d3d = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "use_image_scale")) {
gameConf.use_image_scale = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "pro_version")) {
PRO_VERSION = atoi(valbuf);
} else if(!strcmp(strbuf, "errorlog")) {
enable_log = atoi(valbuf);
} else if(!strcmp(strbuf, "textfont")) {
BufferIO::DecodeUTF8(valbuf, wstr);
int textfontsize;
sscanf(linebuf, "%s = %s %d", strbuf, valbuf, &textfontsize);
gameConf.textfontsize = textfontsize;
BufferIO::CopyWStr(wstr, gameConf.textfont, 256);
} else if(!strcmp(strbuf, "numfont")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.numfont, 256);
} else if(!strcmp(strbuf, "serverport")) {
gameConf.serverport = atoi(valbuf);
} else if(!strcmp(strbuf, "lasthost")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lasthost, 100);
} else if(!strcmp(strbuf, "lastport")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lastport, 20);
} else if(!strcmp(strbuf, "roompass")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.roompass, 20);
} else if(!strcmp(strbuf, "automonsterpos")) {
gameConf.chkMAutoPos = atoi(valbuf);
} else if(!strcmp(strbuf, "autospellpos")) {
gameConf.chkSTAutoPos = atoi(valbuf);
} else if(!strcmp(strbuf, "randompos")) {
gameConf.chkRandomPos = atoi(valbuf);
} else if(!strcmp(strbuf, "autochain")) {
gameConf.chkAutoChain = atoi(valbuf);
} else if(!strcmp(strbuf, "waitchain")) {
gameConf.chkWaitChain = atoi(valbuf);
} else if(!strcmp(strbuf, "mute_opponent")) {
gameConf.chkIgnore1 = atoi(valbuf);
} else if(!strcmp(strbuf, "mute_spectators")) {
gameConf.chkIgnore2 = atoi(valbuf);
} else if(!strcmp(strbuf, "default_rule")) {
gameConf.default_rule = atoi(valbuf);
if(gameConf.default_rule <= 0)
gameConf.default_rule = DEFAULT_DUEL_RULE;
} else if(!strcmp(strbuf, "hide_setname")) {
gameConf.hide_setname = atoi(valbuf);
} else if(!strcmp(strbuf, "hide_hint_button")) {
gameConf.hide_hint_button = atoi(valbuf);
} else if(!strcmp(strbuf, "control_mode")) {
gameConf.control_mode = atoi(valbuf);
} else if(!strcmp(strbuf, "draw_field_spell")) {
gameConf.draw_field_spell = atoi(valbuf);
} else if(!strcmp(strbuf, "separate_clear_button")) {
gameConf.separate_clear_button = atoi(valbuf);
} else if(!strcmp(strbuf, "auto_search_limit")) {
gameConf.auto_search_limit = atoi(valbuf);
} else if(!strcmp(strbuf, "search_multiple_keywords")) {
gameConf.search_multiple_keywords = atoi(valbuf);
} else if(!strcmp(strbuf, "search_regex")) {
gameConf.search_regex = atoi(valbuf);
} else if(!strcmp(strbuf, "ignore_deck_changes")) {
gameConf.chkIgnoreDeckChanges = atoi(valbuf);
} else if(!strcmp(strbuf, "default_ot")) {
gameConf.defaultOT = atoi(valbuf);
} else if(!strcmp(strbuf, "enable_bot_mode")) {
gameConf.enable_bot_mode = atoi(valbuf);
} else if(!strcmp(strbuf, "quick_animation")) {
gameConf.quick_animation = atoi(valbuf);
} else if(!strcmp(strbuf, "auto_save_replay")) {
gameConf.auto_save_replay = atoi(valbuf);
} else if(!strcmp(strbuf, "draw_single_chain")) {
gameConf.draw_single_chain = atoi(valbuf);
} else if(!strcmp(strbuf, "prefer_expansion_script")) {
gameConf.prefer_expansion_script = atoi(valbuf);
} else if(!strcmp(strbuf, "window_maximized")) {
gameConf.window_maximized = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "window_width")) {
gameConf.window_width = atoi(valbuf);
} else if(!strcmp(strbuf, "window_height")) {
gameConf.window_height = atoi(valbuf);
} else if(!strcmp(strbuf, "resize_popup_menu")) {
gameConf.resize_popup_menu = atoi(valbuf) > 0;
#ifdef YGOPRO_USE_IRRKLANG
} else if(!strcmp(strbuf, "enable_sound")) {
gameConf.enable_sound = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "sound_volume")) {
gameConf.sound_volume = atof(valbuf) / 100;
} else if(!strcmp(strbuf, "enable_music")) {
gameConf.enable_music = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "music_volume")) {
gameConf.music_volume = atof(valbuf) / 100;
} else if(!strcmp(strbuf, "music_mode")) {
gameConf.music_mode = atoi(valbuf);
#endif
} else if(!strcmp(strbuf, "enable_pendulum_scale")) {
gameConf.chkEnablePScale = atoi(valbuf);
} else if (!strcmp(strbuf, "skin_index")) {
gameConf.skin_index = atoi(valbuf);
} else {
// options allowing multiple words
sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf);
if (!strcmp(strbuf, "nickname")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.nickname, 20);
} else if (!strcmp(strbuf, "gamename")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.gamename, 20);
} else if (!strcmp(strbuf, "bot_deck_path")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.bot_deck_path, 64);
} else if (!strcmp(strbuf, "lastcategory")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lastcategory, 64);
} else if (!strcmp(strbuf, "lastdeck")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lastdeck, 64);
} else if (!strcmp(strbuf, "locale")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.locale, 64);
}
}
}
return true;
}
void Game::LoadConfig() {
gameConf.use_d3d = 0;
gameConf.use_image_scale = 1;
gameConf.antialias = 0;
......@@ -1290,6 +1424,7 @@ void Game::LoadConfig() {
gameConf.enable_bot_mode = 1;
gameConf.quick_animation = 0;
gameConf.auto_save_replay = 0;
gameConf.draw_single_chain = 0;
gameConf.prefer_expansion_script = 0;
gameConf.enable_sound = true;
gameConf.sound_volume = 0.5;
......@@ -1302,273 +1437,18 @@ void Game::LoadConfig() {
gameConf.resize_popup_menu = false;
gameConf.chkEnablePScale = 1;
gameConf.skin_index = -1;
if(fp) {
while(fgets(linebuf, 256, fp)) {
sscanf(linebuf, "%s = %s", strbuf, valbuf);
if(!strcmp(strbuf, "antialias")) {
gameConf.antialias = atoi(valbuf);
} else if(!strcmp(strbuf, "use_d3d")) {
gameConf.use_d3d = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "use_image_scale")) {
gameConf.use_image_scale = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "pro_version")) {
PRO_VERSION = atoi(valbuf);
} else if(!strcmp(strbuf, "errorlog")) {
enable_log = atoi(valbuf);
} else if(!strcmp(strbuf, "textfont")) {
BufferIO::DecodeUTF8(valbuf, wstr);
int textfontsize;
sscanf(linebuf, "%s = %s %d", strbuf, valbuf, &textfontsize);
gameConf.textfontsize = textfontsize;
BufferIO::CopyWStr(wstr, gameConf.textfont, 256);
} else if(!strcmp(strbuf, "numfont")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.numfont, 256);
} else if(!strcmp(strbuf, "serverport")) {
gameConf.serverport = atoi(valbuf);
} else if(!strcmp(strbuf, "lasthost")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lasthost, 100);
} else if(!strcmp(strbuf, "lastport")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lastport, 20);
} else if(!strcmp(strbuf, "roompass")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.roompass, 20);
} else if(!strcmp(strbuf, "automonsterpos")) {
gameConf.chkMAutoPos = atoi(valbuf);
} else if(!strcmp(strbuf, "autospellpos")) {
gameConf.chkSTAutoPos = atoi(valbuf);
} else if(!strcmp(strbuf, "randompos")) {
gameConf.chkRandomPos = atoi(valbuf);
} else if(!strcmp(strbuf, "autochain")) {
gameConf.chkAutoChain = atoi(valbuf);
} else if(!strcmp(strbuf, "waitchain")) {
gameConf.chkWaitChain = atoi(valbuf);
} else if(!strcmp(strbuf, "mute_opponent")) {
gameConf.chkIgnore1 = atoi(valbuf);
} else if(!strcmp(strbuf, "mute_spectators")) {
gameConf.chkIgnore2 = atoi(valbuf);
} else if(!strcmp(strbuf, "default_rule")) {
gameConf.default_rule = atoi(valbuf);
if(gameConf.default_rule <= 0)
gameConf.default_rule = DEFAULT_DUEL_RULE;
} else if(!strcmp(strbuf, "hide_setname")) {
gameConf.hide_setname = atoi(valbuf);
} else if(!strcmp(strbuf, "hide_hint_button")) {
gameConf.hide_hint_button = atoi(valbuf);
} else if(!strcmp(strbuf, "control_mode")) {
gameConf.control_mode = atoi(valbuf);
} else if(!strcmp(strbuf, "draw_field_spell")) {
gameConf.draw_field_spell = atoi(valbuf);
} else if(!strcmp(strbuf, "separate_clear_button")) {
gameConf.separate_clear_button = atoi(valbuf);
} else if(!strcmp(strbuf, "auto_search_limit")) {
gameConf.auto_search_limit = atoi(valbuf);
} else if(!strcmp(strbuf, "search_multiple_keywords")) {
gameConf.search_multiple_keywords = atoi(valbuf);
} else if(!strcmp(strbuf, "search_regex")) {
gameConf.search_regex = atoi(valbuf);
} else if(!strcmp(strbuf, "ignore_deck_changes")) {
gameConf.chkIgnoreDeckChanges = atoi(valbuf);
} else if(!strcmp(strbuf, "default_ot")) {
gameConf.defaultOT = atoi(valbuf);
} else if(!strcmp(strbuf, "enable_bot_mode")) {
gameConf.enable_bot_mode = atoi(valbuf);
} else if(!strcmp(strbuf, "quick_animation")) {
gameConf.quick_animation = atoi(valbuf);
} else if(!strcmp(strbuf, "auto_save_replay")) {
gameConf.auto_save_replay = atoi(valbuf);
} else if(!strcmp(strbuf, "prefer_expansion_script")) {
gameConf.prefer_expansion_script = atoi(valbuf);
} else if(!strcmp(strbuf, "window_maximized")) {
gameConf.window_maximized = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "window_width")) {
gameConf.window_width = atoi(valbuf);
} else if(!strcmp(strbuf, "window_height")) {
gameConf.window_height = atoi(valbuf);
} else if(!strcmp(strbuf, "resize_popup_menu")) {
gameConf.resize_popup_menu = atoi(valbuf) > 0;
#ifdef YGOPRO_USE_IRRKLANG
} else if(!strcmp(strbuf, "enable_sound")) {
gameConf.enable_sound = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "sound_volume")) {
gameConf.sound_volume = atof(valbuf) / 100;
} else if(!strcmp(strbuf, "enable_music")) {
gameConf.enable_music = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "music_volume")) {
gameConf.music_volume = atof(valbuf) / 100;
} else if(!strcmp(strbuf, "music_mode")) {
gameConf.music_mode = atoi(valbuf);
#endif
} else if(!strcmp(strbuf, "enable_pendulum_scale")) {
gameConf.chkEnablePScale = atoi(valbuf);
} else if (!strcmp(strbuf, "skin_index")) {
gameConf.skin_index = atoi(valbuf);
} else {
// options allowing multiple words
sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf);
if (!strcmp(strbuf, "nickname")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.nickname, 20);
} else if (!strcmp(strbuf, "gamename")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.gamename, 20);
} else if (!strcmp(strbuf, "bot_deck_path")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.bot_deck_path, 64);
} else if (!strcmp(strbuf, "lastcategory")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lastcategory, 64);
} else if (!strcmp(strbuf, "lastdeck")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lastdeck, 64);
} else if (!strcmp(strbuf, "locale")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.locale, 64);
}
}
}
fclose(fp);
}
#ifndef YGOPRO_COMPAT_MYCARD
if(fp_user) {
while(fgets(linebuf, 256, fp_user)) {
sscanf(linebuf, "%s = %s", strbuf, valbuf);
if(!strcmp(strbuf, "antialias")) {
gameConf.antialias = atoi(valbuf);
} else if(!strcmp(strbuf, "use_d3d")) {
gameConf.use_d3d = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "use_image_scale")) {
gameConf.use_image_scale = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "pro_version")) {
PRO_VERSION = atoi(valbuf);
} else if(!strcmp(strbuf, "errorlog")) {
enable_log = atoi(valbuf);
} else if(!strcmp(strbuf, "textfont")) {
BufferIO::DecodeUTF8(valbuf, wstr);
int textfontsize;
sscanf(linebuf, "%s = %s %d", strbuf, valbuf, &textfontsize);
gameConf.textfontsize = textfontsize;
BufferIO::CopyWStr(wstr, gameConf.textfont, 256);
} else if(!strcmp(strbuf, "numfont")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.numfont, 256);
} else if(!strcmp(strbuf, "serverport")) {
gameConf.serverport = atoi(valbuf);
} else if(!strcmp(strbuf, "lasthost")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lasthost, 100);
} else if(!strcmp(strbuf, "lastport")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lastport, 20);
} else if(!strcmp(strbuf, "roompass")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.roompass, 20);
} else if(!strcmp(strbuf, "automonsterpos")) {
gameConf.chkMAutoPos = atoi(valbuf);
} else if(!strcmp(strbuf, "autospellpos")) {
gameConf.chkSTAutoPos = atoi(valbuf);
} else if(!strcmp(strbuf, "randompos")) {
gameConf.chkRandomPos = atoi(valbuf);
} else if(!strcmp(strbuf, "autochain")) {
gameConf.chkAutoChain = atoi(valbuf);
} else if(!strcmp(strbuf, "waitchain")) {
gameConf.chkWaitChain = atoi(valbuf);
} else if(!strcmp(strbuf, "mute_opponent")) {
gameConf.chkIgnore1 = atoi(valbuf);
} else if(!strcmp(strbuf, "mute_spectators")) {
gameConf.chkIgnore2 = atoi(valbuf);
} else if(!strcmp(strbuf, "default_rule")) {
gameConf.default_rule = atoi(valbuf);
if(gameConf.default_rule <= 0)
gameConf.default_rule = DEFAULT_DUEL_RULE;
} else if(!strcmp(strbuf, "hide_setname")) {
gameConf.hide_setname = atoi(valbuf);
} else if(!strcmp(strbuf, "hide_hint_button")) {
gameConf.hide_hint_button = atoi(valbuf);
} else if(!strcmp(strbuf, "control_mode")) {
gameConf.control_mode = atoi(valbuf);
} else if(!strcmp(strbuf, "draw_field_spell")) {
gameConf.draw_field_spell = atoi(valbuf);
} else if(!strcmp(strbuf, "separate_clear_button")) {
gameConf.separate_clear_button = atoi(valbuf);
} else if(!strcmp(strbuf, "auto_search_limit")) {
gameConf.auto_search_limit = atoi(valbuf);
} else if(!strcmp(strbuf, "search_multiple_keywords")) {
gameConf.search_multiple_keywords = atoi(valbuf);
} else if(!strcmp(strbuf, "search_regex")) {
gameConf.search_regex = atoi(valbuf);
} else if(!strcmp(strbuf, "ignore_deck_changes")) {
gameConf.chkIgnoreDeckChanges = atoi(valbuf);
} else if(!strcmp(strbuf, "default_ot")) {
gameConf.defaultOT = atoi(valbuf);
} else if(!strcmp(strbuf, "enable_bot_mode")) {
gameConf.enable_bot_mode = atoi(valbuf);
} else if(!strcmp(strbuf, "quick_animation")) {
gameConf.quick_animation = atoi(valbuf);
} else if(!strcmp(strbuf, "auto_save_replay")) {
gameConf.auto_save_replay = atoi(valbuf);
} else if(!strcmp(strbuf, "prefer_expansion_script")) {
gameConf.prefer_expansion_script = atoi(valbuf);
} else if(!strcmp(strbuf, "window_maximized")) {
gameConf.window_maximized = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "window_width")) {
gameConf.window_width = atoi(valbuf);
} else if(!strcmp(strbuf, "window_height")) {
gameConf.window_height = atoi(valbuf);
} else if(!strcmp(strbuf, "resize_popup_menu")) {
gameConf.resize_popup_menu = atoi(valbuf) > 0;
#ifdef YGOPRO_USE_IRRKLANG
} else if(!strcmp(strbuf, "enable_sound")) {
gameConf.enable_sound = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "sound_volume")) {
gameConf.sound_volume = atof(valbuf) / 100;
} else if(!strcmp(strbuf, "enable_music")) {
gameConf.enable_music = atoi(valbuf) > 0;
} else if(!strcmp(strbuf, "music_volume")) {
gameConf.music_volume = atof(valbuf) / 100;
} else if(!strcmp(strbuf, "music_mode")) {
gameConf.music_mode = atoi(valbuf);
#endif
} else if(!strcmp(strbuf, "enable_pendulum_scale")) {
gameConf.chkEnablePScale = atoi(valbuf);
} else if (!strcmp(strbuf, "skin_index")) {
gameConf.skin_index = atoi(valbuf);
} else {
// options allowing multiple words
sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf);
if (!strcmp(strbuf, "nickname")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.nickname, 20);
} else if (!strcmp(strbuf, "gamename")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.gamename, 20);
} else if (!strcmp(strbuf, "bot_deck_path")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.bot_deck_path, 64);
} else if (!strcmp(strbuf, "lastcategory")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lastcategory, 64);
} else if (!strcmp(strbuf, "lastdeck")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.lastdeck, 64);
} else if (!strcmp(strbuf, "locale")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.locale, 64);
}
}
}
fclose(fp_user);
} else
#else // YGOPRO_COMPAT_MYCARD
LoadConfigFromFile("system.conf"); //default config
#ifdef YGOPRO_COMPAT_MYCARD
if(!gameConf.locale || wcslen(gameConf.locale) <= 0)
#else // YGOPRO_COMPAT_MYCARD
if(!LoadConfigFromFile("system_user.conf"))
#endif
{
unsigned int lcid = 0;
#ifdef _WIN32
lcid = ((unsigned int)GetSystemDefaultLangID()) & 0xff;
#else
/* temp broken
char* locale_str = getenv("LANG");
if(locale_str) {
if(strstr(locale_str, "zh"))
......@@ -1589,6 +1469,7 @@ void Game::LoadConfig() {
if(strstr(locale_str, "pt"))
lcid = 0x16;
}
*/
#endif
switch(lcid) {
case 0x04: {
......@@ -1616,6 +1497,9 @@ void Game::LoadConfig() {
break;
}
}
#ifndef YGOPRO_COMPAT_MYCARD
SaveConfig();
#endif
}
}
void Game::SaveConfig() {
......@@ -1676,6 +1560,7 @@ void Game::SaveConfig() {
fprintf(fp, "bot_deck_path = %s\n", linebuf);
fprintf(fp, "quick_animation = %d\n", gameConf.quick_animation);
fprintf(fp, "auto_save_replay = %d\n", (chkAutoSaveReplay->isChecked() ? 1 : 0));
fprintf(fp, "draw_single_chain = %d\n", gameConf.draw_single_chain);
fprintf(fp, "prefer_expansion_script = %d\n", gameConf.prefer_expansion_script);
fprintf(fp, "window_maximized = %d\n", (gameConf.window_maximized ? 1 : 0));
fprintf(fp, "window_width = %d\n", gameConf.window_width);
......@@ -1951,7 +1836,17 @@ void Game::ClearTextures() {
}
imageManager.ClearTexture();
}
void Game::CloseDuelWindow() {
void Game::CloseGameButtons() {
btnChainIgnore->setVisible(false);
btnChainAlways->setVisible(false);
btnChainWhenAvail->setVisible(false);
btnCancelOrFinish->setVisible(false);
btnSpectatorSwap->setVisible(false);
btnShuffle->setVisible(false);
wSurrender->setVisible(false);
}
void Game::CloseGameWindow() {
CloseGameButtons();
for(auto wit = fadingList.begin(); wit != fadingList.end(); ++wit) {
if(wit->isFadein)
wit->autoFadeoutFrame = 1;
......@@ -1961,34 +1856,32 @@ void Game::CloseDuelWindow() {
wANCard->setVisible(false);
wANNumber->setVisible(false);
wANRace->setVisible(false);
wCardImg->setVisible(false);
wCardSelect->setVisible(false);
wCardDisplay->setVisible(false);
wCmdMenu->setVisible(false);
wFTSelect->setVisible(false);
wHand->setVisible(false);
wInfos->setVisible(false);
wMessage->setVisible(false);
wOptions->setVisible(false);
wPhase->setVisible(false);
wPosSelect->setVisible(false);
wQuery->setVisible(false);
wSurrender->setVisible(false);
wReplayControl->setVisible(false);
wReplaySave->setVisible(false);
stHintMsg->setVisible(false);
stTip->setVisible(false);
}
void Game::CloseDuelWindow() {
CloseGameWindow();
wCardImg->setVisible(false);
wInfos->setVisible(false);
wChat->setVisible(false);
btnSideOK->setVisible(false);
btnSideShuffle->setVisible(false);
btnSideSort->setVisible(false);
btnSideReload->setVisible(false);
btnLeaveGame->setVisible(false);
btnSpectatorSwap->setVisible(false);
btnChainIgnore->setVisible(false);
btnChainAlways->setVisible(false);
btnChainWhenAvail->setVisible(false);
btnCancelOrFinish->setVisible(false);
btnShuffle->setVisible(false);
wChat->setVisible(false);
lstLog->clear();
logParam.clear();
lstHostList->clear();
......
......@@ -60,6 +60,7 @@ struct Config {
int window_height;
bool resize_popup_menu;
int auto_save_replay;
int draw_single_chain;
int prefer_expansion_script;
bool enable_sound;
bool enable_music;
......@@ -173,6 +174,7 @@ public:
void WaitFrameSignal(int frame);
void DrawThumb(code_pointer cp, position2di pos, const std::unordered_map<int,int>* lflist, bool drag = false);
void DrawDeckBd();
bool LoadConfigFromFile(const char* file);
void LoadConfig();
void SaveConfig();
void ShowCardInfo(int code, bool resize = false);
......@@ -184,6 +186,8 @@ public:
void ErrorLog(const char* msgbuf);
void initUtils();
void ClearTextures();
void CloseGameButtons();
void CloseGameWindow();
void CloseDuelWindow();
int LocalPlayer(int player);
......@@ -327,6 +331,7 @@ public:
irr::gui::IGUICheckBox* chkWaitChain;
irr::gui::IGUICheckBox* chkQuickAnimation;
irr::gui::IGUICheckBox* chkAutoSaveReplay;
irr::gui::IGUICheckBox* chkDrawSingleChain;
irr::gui::IGUIWindow* tabSystem;
irr::gui::IGUIElement* elmTabSystemLast;
irr::gui::IGUIScrollBar* scrTabSystem;
......@@ -831,8 +836,9 @@ extern time_t pre_seed[3];
#define SCROLL_TAB_SYSTEM 371
#define CHECKBOX_MULTI_KEYWORDS 372
#define CHECKBOX_PREFER_EXPANSION 373
#define CHECKBOX_REGEX 374
#define COMBOBOX_LOCALE 375
#define CHECKBOX_DRAW_SINGLE_CHAIN 374
#define CHECKBOX_REGEX 375
#define COMBOBOX_LOCALE 376
#define BUTTON_DECK_CODE 389
#define BUTTON_DECK_CODE_SAVE 390
......
......@@ -21,6 +21,8 @@ bool ImageManager::Initial() {
tUnknown = NULL;
tUnknownFit = NULL;
tUnknownThumb = NULL;
tLoading = NULL;
tThumbLoadingThreadRunning = false;
tAct = GetRandomImage(TEXTURE_ACTIVATE);
tAttack = GetRandomImage(TEXTURE_ATTACK);
if(!tAct)
......@@ -127,12 +129,18 @@ void ImageManager::ClearTexture() {
driver->removeTexture(tit->second);
}
for(auto tit = tThumb.begin(); tit != tThumb.end(); ++tit) {
if(tit->second)
if(tit->second && tit->second != tLoading)
driver->removeTexture(tit->second);
}
tMap[0].clear();
tMap[1].clear();
tThumb.clear();
tThumbLoadingMutex.lock();
tThumbLoading.clear();
while(!tThumbLoadingCodes.empty())
tThumbLoadingCodes.pop();
tThumbLoadingThreadRunning = false;
tThumbLoadingMutex.unlock();
tFields.clear();
}
void ImageManager::RemoveTexture(int code) {
......@@ -174,9 +182,11 @@ void ImageManager::ResizeTexture() {
driver->removeTexture(tUnknown);
driver->removeTexture(tUnknownFit);
driver->removeTexture(tUnknownThumb);
driver->removeTexture(tLoading);
tUnknown = GetTextureFromFile("textures/unknown.jpg", CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
tUnknownFit = GetTextureFromFile("textures/unknown.jpg", imgWidthFit, imgHeightFit);
tUnknownThumb = GetTextureFromFile("textures/unknown.jpg", imgWidthThumb, imgHeightThumb);
tLoading = GetTextureFromFile("textures/cover.jpg", imgWidthThumb, imgHeightThumb);
driver->removeTexture(tBackGround);
tBackGround = GetRandomImage(TEXTURE_DUEL, bgWidth, bgHeight);
if(!tBackGround)
......@@ -342,62 +352,122 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
else
return mainGame->gameConf.use_image_scale ? (fit ? tUnknownFit : tUnknown) : GetTextureThumb(code);
}
irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if(code == 0)
return tUnknownThumb;
auto tit = tThumb.find(code);
int width = CARD_THUMB_WIDTH * mainGame->xScale;
int height = CARD_THUMB_HEIGHT * mainGame->yScale;
if(tit == tThumb.end()) {
int ImageManager::LoadThumbThread() {
while(true) {
imageManager.tThumbLoadingMutex.lock();
int code = imageManager.tThumbLoadingCodes.front();
imageManager.tThumbLoadingCodes.pop();
imageManager.tThumbLoadingMutex.unlock();
char file[256];
sprintf(file, "expansions/pics/thumbnail/%d.png", code);
irr::video::ITexture* img = GetTextureFromFile(file, width, height);
irr::video::IImage* img = imageManager.driver->createImageFromFile(file);
if(img == NULL) {
sprintf(file, "expansions/pics/thumbnail/%d.jpg", code);
img = GetTextureFromFile(file, width, height);
img = imageManager.driver->createImageFromFile(file);
}
if(img == NULL) {
sprintf(file, mainGame->GetLocaleDir("pics/thumbnail/%d.png"), code);
img = GetTextureFromFile(file, width, height);
img = imageManager.driver->createImageFromFile(file);
}
if(img == NULL) {
sprintf(file, mainGame->GetLocaleDir("pics/thumbnail/%d.jpg"), code);
img = GetTextureFromFile(file, width, height);
img = imageManager.driver->createImageFromFile(file);
}
if(img == NULL) {
sprintf(file, "pics/thumbnail/%d.png", code);
img = GetTextureFromFile(file, width, height);
img = imageManager.driver->createImageFromFile(file);
}
if(img == NULL) {
sprintf(file, "pics/thumbnail/%d.jpg", code);
img = GetTextureFromFile(file, width, height);
img = imageManager.driver->createImageFromFile(file);
}
if(img == NULL && mainGame->gameConf.use_image_scale) {
sprintf(file, "expansions/pics/%d.png", code);
img = GetTextureFromFile(file, width, height);
img = imageManager.driver->createImageFromFile(file);
if(img == NULL) {
sprintf(file, "expansions/pics/%d.jpg", code);
img = GetTextureFromFile(file, width, height);
img = imageManager.driver->createImageFromFile(file);
}
if(img == NULL) {
sprintf(file, mainGame->GetLocaleDir("pics/%d.png"), code);
img = GetTextureFromFile(file, width, height);
img = imageManager.driver->createImageFromFile(file);
}
if(img == NULL) {
sprintf(file, mainGame->GetLocaleDir("pics/%d.jpg"), code);
img = GetTextureFromFile(file, width, height);
img = imageManager.driver->createImageFromFile(file);
}
if(img == NULL) {
sprintf(file, "pics/%d.png", code);
img = GetTextureFromFile(file, width, height);
img = imageManager.driver->createImageFromFile(file);
}
if(img == NULL) {
sprintf(file, "pics/%d.jpg", code);
img = GetTextureFromFile(file, width, height);
img = imageManager.driver->createImageFromFile(file);
}
}
tThumb[code] = img;
return (img == NULL) ? tUnknownThumb : img;
if(img != NULL) {
int width = CARD_THUMB_WIDTH * mainGame->xScale;
int height = CARD_THUMB_HEIGHT * mainGame->yScale;
if(img->getDimension() == irr::core::dimension2d<u32>(width, height)) {
img->grab();
imageManager.tThumbLoadingMutex.lock();
if(imageManager.tThumbLoadingThreadRunning)
imageManager.tThumbLoading[code] = img;
imageManager.tThumbLoadingMutex.unlock();
} else {
irr::video::IImage *destimg = imageManager.driver->createImage(img->getColorFormat(), irr::core::dimension2d<u32>(width, height));
imageScaleNNAA(img, destimg);
img->drop();
destimg->grab();
imageManager.tThumbLoadingMutex.lock();
if(imageManager.tThumbLoadingThreadRunning)
imageManager.tThumbLoading[code] = destimg;
imageManager.tThumbLoadingMutex.unlock();
}
} else {
imageManager.tThumbLoadingMutex.lock();
if(imageManager.tThumbLoadingThreadRunning)
imageManager.tThumbLoading[code] = NULL;
imageManager.tThumbLoadingMutex.unlock();
}
imageManager.tThumbLoadingMutex.lock();
imageManager.tThumbLoadingThreadRunning = !imageManager.tThumbLoadingCodes.empty();
if(!imageManager.tThumbLoadingThreadRunning)
break;
imageManager.tThumbLoadingMutex.unlock();
}
imageManager.tThumbLoadingMutex.unlock();
return 0;
}
irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if(code == 0)
return tUnknownThumb;
imageManager.tThumbLoadingMutex.lock();
auto lit = tThumbLoading.find(code);
if(lit != tThumbLoading.end()) {
if(lit->second != NULL) {
char file[256];
sprintf(file, "pics/thumbnail/%d.jpg", code);
irr::video::ITexture* texture = driver->addTexture(file, lit->second); // textures must be added in the main thread due to OpenGL
lit->second->drop();
tThumb[code] = texture;
} else {
tThumb[code] = NULL;
}
tThumbLoading.erase(lit);
}
imageManager.tThumbLoadingMutex.unlock();
auto tit = tThumb.find(code);
if(tit == tThumb.end()) {
tThumb[code] = tLoading;
imageManager.tThumbLoadingMutex.lock();
tThumbLoadingCodes.push(code);
if(!tThumbLoadingThreadRunning) {
tThumbLoadingThreadRunning = true;
std::thread(LoadThumbThread).detach();
}
imageManager.tThumbLoadingMutex.unlock();
return tLoading;
}
if(tit->second)
return tit->second;
......
......@@ -4,6 +4,7 @@
#include "config.h"
#include "data_manager.h"
#include <unordered_map>
#include <queue>
namespace ygo {
......@@ -25,16 +26,22 @@ public:
irr::video::ITexture* GetTexture(int code, bool fit = false);
irr::video::ITexture* GetTextureThumb(int code);
irr::video::ITexture* GetTextureField(int code);
static int LoadThumbThread();
std::unordered_map<int, irr::video::ITexture*> tMap[2];
std::unordered_map<int, irr::video::ITexture*> tThumb;
std::unordered_map<int, irr::video::ITexture*> tFields;
std::unordered_map<int, irr::video::IImage*> tThumbLoading;
std::queue<int> tThumbLoadingCodes;
std::mutex tThumbLoadingMutex;
bool tThumbLoadingThreadRunning;
irr::IrrlichtDevice* device;
irr::video::IVideoDriver* driver;
irr::video::ITexture* tCover[4];
irr::video::ITexture* tUnknown;
irr::video::ITexture* tUnknownFit;
irr::video::ITexture* tUnknownThumb;
irr::video::ITexture* tLoading;
irr::video::ITexture* tAct;
irr::video::ITexture* tAttack;
irr::video::ITexture* tNegated;
......
......@@ -234,8 +234,7 @@ void ReplayMode::EndDuel() {
mainGame->actionSignal.Reset();
mainGame->gMutex.lock();
mainGame->stMessage->setText(dataManager.GetSysString(1501));
if(mainGame->wCardSelect->isVisible())
mainGame->HideElement(mainGame->wCardSelect);
mainGame->HideElement(mainGame->wCardSelect);
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.unlock();
if(auto_watch_mode) {
......
......@@ -317,6 +317,7 @@
!system 1262 大师规则3
!system 1263 新大师规则
!system 1264 大师规则2020
!system 1269 数字灵摆图片
!system 1270 卡片信息
!system 1271 消息记录
!system 1272 清除记录
......@@ -334,7 +335,7 @@
!system 1284
!system 1285
!system 1286 特大
!system 1287 数字灵摆图片
!system 1287 只有连锁1也显示连锁动画
!system 1288 语言(重启后生效)
!system 1289 默认
!system 1290 忽略对方发言
......
......@@ -38,6 +38,7 @@ enable_bot_mode = 1
bot_deck_path = ./windbot/Decks
quick_animation = 1
auto_save_replay = 1
draw_single_chain = 0
window_maximized = 0
window_width = 1024
window_height = 640
......
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