Commit 8f9e5424 authored by mercury233's avatar mercury233

Merge branch 'master' of https://github.com/Fluorohydride/ygopro

parents eb02897e 3aeb7721
...@@ -28,7 +28,7 @@ endif () ...@@ -28,7 +28,7 @@ endif ()
target_link_libraries (ygopro ocgcore clzma) target_link_libraries (ygopro ocgcore clzma)
if (MSVC) if (MSVC)
target_link_libraries (ygopro irrlicht freetype sqlite3 event lua) target_link_libraries (ygopro irrlicht freetype sqlite3 event)
include_directories ( "../irrlicht/include" "../freetype/include" "../event/include" "../sqlite3" ) include_directories ( "../irrlicht/include" "../freetype/include" "../event/include" "../sqlite3" )
else () else ()
target_link_libraries (ygopro target_link_libraries (ygopro
...@@ -36,7 +36,6 @@ else () ...@@ -36,7 +36,6 @@ else ()
${FREETYPE_LIBRARIES} ${FREETYPE_LIBRARIES}
${SQLITE_LIBRARIES} ${SQLITE_LIBRARIES}
${LIBEVENT_LIBRARIES} ${LIBEVENT_LIBRARIES}
${LUA_LIBRARIES}
${OPENGL_gl_LIBRARY} ${OPENGL_gl_LIBRARY}
) )
include_directories ( include_directories (
......
...@@ -457,7 +457,7 @@ void Game::DrawMisc() { ...@@ -457,7 +457,7 @@ void Game::DrawMisc() {
driver->setTransform(irr::video::ETS_WORLD, im); driver->setTransform(irr::video::ETS_WORLD, im);
driver->drawVertexPrimitiveList(matManager.vActivate, 4, matManager.iRectangle, 2); 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) { for(size_t i = 0; i < dField.chains.size(); ++i) {
if(dField.chains[i].solved) if(dField.chains[i].solved)
break; break;
...@@ -992,6 +992,8 @@ void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) { ...@@ -992,6 +992,8 @@ void Game::ShowElement(irr::gui::IGUIElement * win, int autoframe) {
fadingList.push_back(fu); fadingList.push_back(fu);
} }
void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) { void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) {
if(!win->isVisible() && !set_action)
return;
FadingUnit fu; FadingUnit fu;
fu.fadingSize = win->getRelativePosition(); fu.fadingSize = win->getRelativePosition();
for(auto fit = fadingList.begin(); fit != fadingList.end(); ++fit) for(auto fit = fadingList.begin(); fit != fadingList.end(); ++fit)
...@@ -1155,8 +1157,13 @@ void Game::DrawDeckBd() { ...@@ -1155,8 +1157,13 @@ void Game::DrawDeckBd() {
DrawShadowText(numFont, deckBuilder.result_string, Resize(875, 137, 935, 157), Resize(1, 1, 1, 1), 0xffffffff, 0xff000000, false, true); 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->draw2DRectangle(Resize(805, 160, 1020, 630), 0x400000ff, 0x400000ff, 0x40000000, 0x40000000);
driver->draw2DRectangleOutline(Resize(804, 159, 1020, 630)); 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()]; 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) if(deckBuilder.hovered_pos == 4 && deckBuilder.hovered_seq == (int)i)
driver->draw2DRectangle(0x80000000, Resize(806, 164 + i * 66, 1019, 230 + i * 66)); driver->draw2DRectangle(0x80000000, Resize(806, 164 + i * 66, 1019, 230 + i * 66));
DrawThumb(ptr, position2di(810, 165 + i * 66), deckBuilder.filterList); DrawThumb(ptr, position2di(810, 165 + i * 66), deckBuilder.filterList);
......
...@@ -369,24 +369,17 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -369,24 +369,17 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->is_building = true; mainGame->is_building = true;
mainGame->is_siding = true; mainGame->is_siding = true;
mainGame->CloseGameWindow();
mainGame->wChat->setVisible(false); mainGame->wChat->setVisible(false);
mainGame->wPhase->setVisible(false);
mainGame->wDeckEdit->setVisible(false); mainGame->wDeckEdit->setVisible(false);
mainGame->wFilter->setVisible(false); mainGame->wFilter->setVisible(false);
mainGame->wSort->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->btnSideOK->setVisible(true);
mainGame->btnSideShuffle->setVisible(true); mainGame->btnSideShuffle->setVisible(true);
mainGame->btnSideSort->setVisible(true); mainGame->btnSideSort->setVisible(true);
mainGame->btnSideReload->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[0] = L'0';
mainGame->deckBuilder.result_string[1] = 0; mainGame->deckBuilder.result_string[1] = 0;
mainGame->deckBuilder.results.clear(); mainGame->deckBuilder.results.clear();
...@@ -486,12 +479,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -486,12 +479,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->SetStaticText(mainGame->stHostPrepRule, 180, mainGame->guiFont, str.c_str()); mainGame->SetStaticText(mainGame->stHostPrepRule, 180, mainGame->guiFont, str.c_str());
mainGame->RefreshDeck(mainGame->cbDeckSelect); mainGame->RefreshDeck(mainGame->cbDeckSelect);
mainGame->cbDeckSelect->setEnabled(true); mainGame->cbDeckSelect->setEnabled(true);
if(mainGame->wCreateHost->isVisible()) mainGame->HideElement(mainGame->wCreateHost);
mainGame->HideElement(mainGame->wCreateHost); mainGame->HideElement(mainGame->wLanWindow);
else if(mainGame->wLanWindow->isVisible()) mainGame->HideElement(mainGame->wSinglePlay);
mainGame->HideElement(mainGame->wLanWindow);
else if(mainGame->wSinglePlay->isVisible())
mainGame->HideElement(mainGame->wSinglePlay);
mainGame->ShowElement(mainGame->wHostPrepare); mainGame->ShowElement(mainGame->wHostPrepare);
if(!mainGame->chkIgnore1->isChecked()) if(!mainGame->chkIgnore1->isChecked())
mainGame->wChat->setVisible(true); mainGame->wChat->setVisible(true);
...@@ -649,12 +639,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -649,12 +639,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->gMutex.lock(); mainGame->gMutex.lock();
if(mainGame->dInfo.player_type < 7) if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false); mainGame->btnLeaveGame->setVisible(false);
mainGame->btnSpectatorSwap->setVisible(false); mainGame->CloseGameButtons();
mainGame->btnChainIgnore->setVisible(false);
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
mainGame->wSurrender->setVisible(false);
mainGame->stMessage->setText(dataManager.GetSysString(1500)); mainGame->stMessage->setText(dataManager.GetSysString(1500));
mainGame->PopupElement(mainGame->wMessage); mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
...@@ -688,14 +673,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -688,14 +673,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
case STOC_REPLAY: { case STOC_REPLAY: {
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->wPhase->setVisible(false); mainGame->wPhase->setVisible(false);
mainGame->wSurrender->setVisible(false);
if(mainGame->dInfo.player_type < 7) if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false); mainGame->btnLeaveGame->setVisible(false);
mainGame->btnChainIgnore->setVisible(false); mainGame->CloseGameButtons();
mainGame->btnChainAlways->setVisible(false);
mainGame->btnChainWhenAvail->setVisible(false);
mainGame->btnCancelOrFinish->setVisible(false);
mainGame->btnShuffle->setVisible(false);
char* prep = pdata; char* prep = pdata;
Replay new_replay; Replay new_replay;
memcpy(&new_replay.pheader, prep, sizeof(ReplayHeader)); memcpy(&new_replay.pheader, prep, sizeof(ReplayHeader));
...@@ -2390,8 +2370,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2390,8 +2370,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnLeaveGame->setText(dataManager.GetSysString(1351)); mainGame->btnLeaveGame->setText(dataManager.GetSysString(1351));
mainGame->btnLeaveGame->setVisible(true); mainGame->btnLeaveGame->setVisible(true);
} }
if(mainGame->wSurrender->isVisible()) mainGame->HideElement(mainGame->wSurrender);
mainGame->HideElement(mainGame->wSurrender);
if(!mainGame->dInfo.isReplay && mainGame->dInfo.player_type < 7) { if(!mainGame->dInfo.isReplay && mainGame->dInfo.player_type < 7) {
if(mainGame->gameConf.control_mode == 0) { if(mainGame->gameConf.control_mode == 0) {
mainGame->btnChainIgnore->setVisible(true); mainGame->btnChainIgnore->setVisible(true);
...@@ -2906,7 +2885,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2906,7 +2885,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
int ct = BufferIO::ReadInt8(pbuf); int ct = BufferIO::ReadInt8(pbuf);
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping) if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true; return true;
if (mainGame->dField.chains.size() > 1) { if(mainGame->dField.chains.size() > 1 || mainGame->gameConf.draw_single_chain) {
if (mainGame->dField.last_chain) if (mainGame->dField.last_chain)
mainGame->WaitFrameSignal(11); mainGame->WaitFrameSignal(11);
for(int i = 0; i < 5; ++i) { for(int i = 0; i < 5; ++i) {
......
...@@ -129,13 +129,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -129,13 +129,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->dInfo.isStarted = false; mainGame->dInfo.isStarted = false;
mainGame->dInfo.isFinished = false; mainGame->dInfo.isFinished = false;
mainGame->device->setEventReceiver(&mainGame->menuHandler); mainGame->device->setEventReceiver(&mainGame->menuHandler);
mainGame->stTip->setVisible(false); mainGame->CloseDuelWindow();
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->btnCreateHost->setEnabled(true); mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
...@@ -1459,8 +1453,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1459,8 +1453,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->chain_when_avail = false; mainGame->chain_when_avail = false;
UpdateChainButtons(); UpdateChainButtons();
} }
if(mainGame->wSurrender->isVisible()) mainGame->HideElement(mainGame->wSurrender);
mainGame->HideElement(mainGame->wSurrender);
mainGame->wCmdMenu->setVisible(false); mainGame->wCmdMenu->setVisible(false);
if(mainGame->fadingList.size()) if(mainGame->fadingList.size())
break; break;
...@@ -1877,6 +1870,11 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) { ...@@ -1877,6 +1870,11 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true; return true;
break; break;
} }
case CHECKBOX_DRAW_SINGLE_CHAIN: {
mainGame->gameConf.draw_single_chain = mainGame->chkDrawSingleChain->isChecked() ? 1 : 0;
return true;
break;
}
case CHECKBOX_PREFER_EXPANSION: { case CHECKBOX_PREFER_EXPANSION: {
mainGame->gameConf.prefer_expansion_script = mainGame->chkPreferExpansionScript->isChecked() ? 1 : 0; mainGame->gameConf.prefer_expansion_script = mainGame->chkPreferExpansionScript->isChecked() ? 1 : 0;
return true; return true;
......
...@@ -286,6 +286,9 @@ bool Game::Initialize() { ...@@ -286,6 +286,9 @@ bool Game::Initialize() {
chkQuickAnimation = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabHelper, CHECKBOX_QUICK_ANIMATION, dataManager.GetSysString(1299)); 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); chkQuickAnimation->setChecked(gameConf.quick_animation != 0);
posY += 30; 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 = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabHelper, -1, dataManager.GetSysString(1366));
chkAutoSaveReplay->setChecked(gameConf.auto_save_replay != 0); chkAutoSaveReplay->setChecked(gameConf.auto_save_replay != 0);
elmTabHelperLast = chkAutoSaveReplay; elmTabHelperLast = chkAutoSaveReplay;
...@@ -1090,6 +1093,7 @@ void Game::LoadConfig() { ...@@ -1090,6 +1093,7 @@ void Game::LoadConfig() {
gameConf.enable_bot_mode = 0; gameConf.enable_bot_mode = 0;
gameConf.quick_animation = 0; gameConf.quick_animation = 0;
gameConf.auto_save_replay = 0; gameConf.auto_save_replay = 0;
gameConf.draw_single_chain = 0;
gameConf.prefer_expansion_script = 0; gameConf.prefer_expansion_script = 0;
gameConf.enable_sound = true; gameConf.enable_sound = true;
gameConf.sound_volume = 0.5; gameConf.sound_volume = 0.5;
...@@ -1172,6 +1176,8 @@ void Game::LoadConfig() { ...@@ -1172,6 +1176,8 @@ void Game::LoadConfig() {
gameConf.quick_animation = atoi(valbuf); gameConf.quick_animation = atoi(valbuf);
} else if(!strcmp(strbuf, "auto_save_replay")) { } else if(!strcmp(strbuf, "auto_save_replay")) {
gameConf.auto_save_replay = atoi(valbuf); 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")) { } else if(!strcmp(strbuf, "prefer_expansion_script")) {
gameConf.prefer_expansion_script = atoi(valbuf); gameConf.prefer_expansion_script = atoi(valbuf);
} else if(!strcmp(strbuf, "window_maximized")) { } else if(!strcmp(strbuf, "window_maximized")) {
...@@ -1259,6 +1265,7 @@ void Game::SaveConfig() { ...@@ -1259,6 +1265,7 @@ void Game::SaveConfig() {
fprintf(fp, "enable_bot_mode = %d\n", gameConf.enable_bot_mode); fprintf(fp, "enable_bot_mode = %d\n", gameConf.enable_bot_mode);
fprintf(fp, "quick_animation = %d\n", gameConf.quick_animation); fprintf(fp, "quick_animation = %d\n", gameConf.quick_animation);
fprintf(fp, "auto_save_replay = %d\n", (chkAutoSaveReplay->isChecked() ? 1 : 0)); 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, "prefer_expansion_script = %d\n", gameConf.prefer_expansion_script);
fprintf(fp, "window_maximized = %d\n", (gameConf.window_maximized ? 1 : 0)); fprintf(fp, "window_maximized = %d\n", (gameConf.window_maximized ? 1 : 0));
fprintf(fp, "window_width = %d\n", gameConf.window_width); fprintf(fp, "window_width = %d\n", gameConf.window_width);
...@@ -1471,7 +1478,17 @@ void Game::ClearTextures() { ...@@ -1471,7 +1478,17 @@ void Game::ClearTextures() {
} }
imageManager.ClearTexture(); 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) { for(auto wit = fadingList.begin(); wit != fadingList.end(); ++wit) {
if(wit->isFadein) if(wit->isFadein)
wit->autoFadeoutFrame = 1; wit->autoFadeoutFrame = 1;
...@@ -1481,34 +1498,32 @@ void Game::CloseDuelWindow() { ...@@ -1481,34 +1498,32 @@ void Game::CloseDuelWindow() {
wANCard->setVisible(false); wANCard->setVisible(false);
wANNumber->setVisible(false); wANNumber->setVisible(false);
wANRace->setVisible(false); wANRace->setVisible(false);
wCardImg->setVisible(false);
wCardSelect->setVisible(false); wCardSelect->setVisible(false);
wCardDisplay->setVisible(false); wCardDisplay->setVisible(false);
wCmdMenu->setVisible(false); wCmdMenu->setVisible(false);
wFTSelect->setVisible(false); wFTSelect->setVisible(false);
wHand->setVisible(false); wHand->setVisible(false);
wInfos->setVisible(false);
wMessage->setVisible(false); wMessage->setVisible(false);
wOptions->setVisible(false); wOptions->setVisible(false);
wPhase->setVisible(false); wPhase->setVisible(false);
wPosSelect->setVisible(false); wPosSelect->setVisible(false);
wQuery->setVisible(false); wQuery->setVisible(false);
wSurrender->setVisible(false);
wReplayControl->setVisible(false); wReplayControl->setVisible(false);
wReplaySave->setVisible(false); wReplaySave->setVisible(false);
stHintMsg->setVisible(false); stHintMsg->setVisible(false);
stTip->setVisible(false);
}
void Game::CloseDuelWindow() {
CloseGameWindow();
wCardImg->setVisible(false);
wInfos->setVisible(false);
wChat->setVisible(false);
btnSideOK->setVisible(false); btnSideOK->setVisible(false);
btnSideShuffle->setVisible(false); btnSideShuffle->setVisible(false);
btnSideSort->setVisible(false); btnSideSort->setVisible(false);
btnSideReload->setVisible(false); btnSideReload->setVisible(false);
btnLeaveGame->setVisible(false); btnLeaveGame->setVisible(false);
btnSpectatorSwap->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(); lstLog->clear();
logParam.clear(); logParam.clear();
lstHostList->clear(); lstHostList->clear();
......
...@@ -46,6 +46,7 @@ struct Config { ...@@ -46,6 +46,7 @@ struct Config {
int enable_bot_mode; int enable_bot_mode;
int quick_animation; int quick_animation;
int auto_save_replay; int auto_save_replay;
int draw_single_chain;
int prefer_expansion_script; int prefer_expansion_script;
bool enable_sound; bool enable_sound;
bool enable_music; bool enable_music;
...@@ -148,6 +149,8 @@ public: ...@@ -148,6 +149,8 @@ public:
void AddDebugMsg(const char* msgbuf); void AddDebugMsg(const char* msgbuf);
void ErrorLog(const char* msgbuf); void ErrorLog(const char* msgbuf);
void ClearTextures(); void ClearTextures();
void CloseGameButtons();
void CloseGameWindow();
void CloseDuelWindow(); void CloseDuelWindow();
int LocalPlayer(int player); int LocalPlayer(int player);
...@@ -282,6 +285,7 @@ public: ...@@ -282,6 +285,7 @@ public:
irr::gui::IGUICheckBox* chkWaitChain; irr::gui::IGUICheckBox* chkWaitChain;
irr::gui::IGUICheckBox* chkQuickAnimation; irr::gui::IGUICheckBox* chkQuickAnimation;
irr::gui::IGUICheckBox* chkAutoSaveReplay; irr::gui::IGUICheckBox* chkAutoSaveReplay;
irr::gui::IGUICheckBox* chkDrawSingleChain;
irr::gui::IGUIWindow* tabSystem; irr::gui::IGUIWindow* tabSystem;
irr::gui::IGUIElement* elmTabSystemLast; irr::gui::IGUIElement* elmTabSystemLast;
irr::gui::IGUIScrollBar* scrTabSystem; irr::gui::IGUIScrollBar* scrTabSystem;
...@@ -723,6 +727,7 @@ extern Game* mainGame; ...@@ -723,6 +727,7 @@ extern Game* mainGame;
#define SCROLL_TAB_SYSTEM 371 #define SCROLL_TAB_SYSTEM 371
#define CHECKBOX_MULTI_KEYWORDS 372 #define CHECKBOX_MULTI_KEYWORDS 372
#define CHECKBOX_PREFER_EXPANSION 373 #define CHECKBOX_PREFER_EXPANSION 373
#define CHECKBOX_DRAW_SINGLE_CHAIN 374
#define DEFAULT_DUEL_RULE 5 #define DEFAULT_DUEL_RULE 5
......
...@@ -15,6 +15,8 @@ bool ImageManager::Initial() { ...@@ -15,6 +15,8 @@ bool ImageManager::Initial() {
tUnknown = NULL; tUnknown = NULL;
tUnknownFit = NULL; tUnknownFit = NULL;
tUnknownThumb = NULL; tUnknownThumb = NULL;
tLoading = NULL;
tThumbLoadingThreadRunning = false;
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");
...@@ -55,12 +57,18 @@ void ImageManager::ClearTexture() { ...@@ -55,12 +57,18 @@ void ImageManager::ClearTexture() {
driver->removeTexture(tit->second); driver->removeTexture(tit->second);
} }
for(auto tit = tThumb.begin(); tit != tThumb.end(); ++tit) { for(auto tit = tThumb.begin(); tit != tThumb.end(); ++tit) {
if(tit->second) if(tit->second && tit->second != tLoading)
driver->removeTexture(tit->second); driver->removeTexture(tit->second);
} }
tMap[0].clear(); tMap[0].clear();
tMap[1].clear(); tMap[1].clear();
tThumb.clear(); tThumb.clear();
tThumbLoadingMutex.lock();
tThumbLoading.clear();
while(!tThumbLoadingCodes.empty())
tThumbLoadingCodes.pop();
tThumbLoadingThreadRunning = false;
tThumbLoadingMutex.unlock();
tFields.clear(); tFields.clear();
} }
void ImageManager::RemoveTexture(int code) { void ImageManager::RemoveTexture(int code) {
...@@ -96,9 +104,11 @@ void ImageManager::ResizeTexture() { ...@@ -96,9 +104,11 @@ void ImageManager::ResizeTexture() {
driver->removeTexture(tUnknown); driver->removeTexture(tUnknown);
driver->removeTexture(tUnknownFit); driver->removeTexture(tUnknownFit);
driver->removeTexture(tUnknownThumb); driver->removeTexture(tUnknownThumb);
driver->removeTexture(tLoading);
tUnknown = GetTextureFromFile("textures/unknown.jpg", CARD_IMG_WIDTH, CARD_IMG_HEIGHT); tUnknown = GetTextureFromFile("textures/unknown.jpg", CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
tUnknownFit = GetTextureFromFile("textures/unknown.jpg", imgWidthFit, imgHeightFit); tUnknownFit = GetTextureFromFile("textures/unknown.jpg", imgWidthFit, imgHeightFit);
tUnknownThumb = GetTextureFromFile("textures/unknown.jpg", imgWidthThumb, imgHeightThumb); tUnknownThumb = GetTextureFromFile("textures/unknown.jpg", imgWidthThumb, imgHeightThumb);
tLoading = GetTextureFromFile("textures/cover.jpg", imgWidthThumb, imgHeightThumb);
driver->removeTexture(tBackGround); driver->removeTexture(tBackGround);
tBackGround = GetTextureFromFile("textures/bg.jpg", bgWidth, bgHeight); tBackGround = GetTextureFromFile("textures/bg.jpg", bgWidth, bgHeight);
driver->removeTexture(tBackGround_menu); driver->removeTexture(tBackGround_menu);
...@@ -236,30 +246,90 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) { ...@@ -236,30 +246,90 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
else else
return mainGame->gameConf.use_image_scale ? (fit ? tUnknownFit : tUnknown) : GetTextureThumb(code); return mainGame->gameConf.use_image_scale ? (fit ? tUnknownFit : tUnknown) : GetTextureThumb(code);
} }
irr::video::ITexture* ImageManager::GetTextureThumb(int code) { int ImageManager::LoadThumbThread() {
if(code == 0) while(true) {
return tUnknownThumb; imageManager.tThumbLoadingMutex.lock();
auto tit = tThumb.find(code); int code = imageManager.tThumbLoadingCodes.front();
int width = CARD_THUMB_WIDTH * mainGame->xScale; imageManager.tThumbLoadingCodes.pop();
int height = CARD_THUMB_HEIGHT * mainGame->yScale; imageManager.tThumbLoadingMutex.unlock();
if(tit == tThumb.end()) {
char file[256]; char file[256];
sprintf(file, "expansions/pics/thumbnail/%d.jpg", code); sprintf(file, "expansions/pics/thumbnail/%d.jpg", code);
irr::video::ITexture* img = GetTextureFromFile(file, width, height); irr::video::IImage* img = imageManager.driver->createImageFromFile(file);
if(img == NULL) { if(img == NULL) {
sprintf(file, "pics/thumbnail/%d.jpg", code); 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) { if(img == NULL && mainGame->gameConf.use_image_scale) {
sprintf(file, "expansions/pics/%d.jpg", code); sprintf(file, "expansions/pics/%d.jpg", code);
img = GetTextureFromFile(file, width, height); img = imageManager.driver->createImageFromFile(file);
if(img == NULL) { }
sprintf(file, "pics/%d.jpg", code); if(img == NULL && mainGame->gameConf.use_image_scale) {
img = GetTextureFromFile(file, width, height); sprintf(file, "pics/%d.jpg", code);
img = imageManager.driver->createImageFromFile(file);
}
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();
} }
tThumb[code] = img; imageManager.tThumbLoadingMutex.unlock();
return (img == NULL) ? tUnknownThumb : img; return tLoading;
} }
if(tit->second) if(tit->second)
return tit->second; return tit->second;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "config.h" #include "config.h"
#include "data_manager.h" #include "data_manager.h"
#include <unordered_map> #include <unordered_map>
#include <queue>
namespace ygo { namespace ygo {
...@@ -18,16 +19,22 @@ public: ...@@ -18,16 +19,22 @@ public:
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);
irr::video::ITexture* GetTextureField(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*> tMap[2];
std::unordered_map<int, irr::video::ITexture*> tThumb; std::unordered_map<int, irr::video::ITexture*> tThumb;
std::unordered_map<int, irr::video::ITexture*> tFields; 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::IrrlichtDevice* device;
irr::video::IVideoDriver* driver; irr::video::IVideoDriver* driver;
irr::video::ITexture* tCover[4]; irr::video::ITexture* tCover[4];
irr::video::ITexture* tUnknown; irr::video::ITexture* tUnknown;
irr::video::ITexture* tUnknownFit; irr::video::ITexture* tUnknownFit;
irr::video::ITexture* tUnknownThumb; irr::video::ITexture* tUnknownThumb;
irr::video::ITexture* tLoading;
irr::video::ITexture* tAct; irr::video::ITexture* tAct;
irr::video::ITexture* tAttack; irr::video::ITexture* tAttack;
irr::video::ITexture* tNegated; irr::video::ITexture* tNegated;
......
...@@ -230,8 +230,7 @@ void ReplayMode::EndDuel() { ...@@ -230,8 +230,7 @@ void ReplayMode::EndDuel() {
mainGame->actionSignal.Reset(); mainGame->actionSignal.Reset();
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->stMessage->setText(dataManager.GetSysString(1501)); mainGame->stMessage->setText(dataManager.GetSysString(1501));
if(mainGame->wCardSelect->isVisible()) mainGame->HideElement(mainGame->wCardSelect);
mainGame->HideElement(mainGame->wCardSelect);
mainGame->PopupElement(mainGame->wMessage); mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
mainGame->actionSignal.Wait(); mainGame->actionSignal.Wait();
......
Subproject commit 80f1ced5a185d25d6a421f71a28caacc04e564f2 Subproject commit 032b7b22e8b3021f0d67afbec7efb587556630e4
Subproject commit 216c4754fb203fe2f598fee02ace05e54f7cea55 Subproject commit f0a30e61e84259d3b7704a3f3e4560a47a1a5cd8
...@@ -334,6 +334,7 @@ ...@@ -334,6 +334,7 @@
!system 1284 !system 1284
!system 1285 !system 1285
!system 1286 特大 !system 1286 特大
!system 1287 只有连锁1也显示连锁动画
!system 1290 禁用聊天功能 !system 1290 禁用聊天功能
!system 1291 忽略观战者发言 !system 1291 忽略观战者发言
!system 1292 忽略时点 !system 1292 忽略时点
......
#config file #config file
#nickname & gamename should be less than 20 characters #nickname & gamename should be less than 20 characters
use_d3d = 0 use_d3d = 0
use_image_scale = 1 use_image_scale = 1
antialias = 2 antialias = 2
errorlog = 3 errorlog = 3
nickname = Player nickname = Player
gamename = Game gamename = Game
lastdeck = new lastdeck = new
textfont = c:/windows/fonts/msyh.ttf 14 textfont = c:/windows/fonts/simsun.ttc 14
numfont = c:/windows/fonts/arialbd.ttf numfont = c:/windows/fonts/arialbd.ttf
serverport = 7911 serverport = 7911
lasthost = 127.0.0.1 lasthost = 127.0.0.1
lastport = 7911 lastport = 7911
automonsterpos = 0 automonsterpos = 0
autospellpos = 0 autospellpos = 0
randompos = 0 randompos = 0
autochain = 0 autochain = 0
waitchain = 0 waitchain = 0
mute_opponent = 0 mute_opponent = 0
mute_spectators = 0 mute_spectators = 0
default_rule = 0 default_rule = 0
hide_setname = 0 hide_setname = 0
hide_hint_button = 0 hide_hint_button = 0
#control_mode = 0: Key A/S/D/R Chain Buttons. control_mode = 1: MouseLeft/MouseRight/NULL/F9 Without Chain Buttons #control_mode = 0: Key A/S/D/R Chain Buttons. control_mode = 1: MouseLeft/MouseRight/NULL/F9 Without Chain Buttons
control_mode = 0 control_mode = 0
draw_field_spell = 1 draw_field_spell = 1
separate_clear_button = 1 separate_clear_button = 1
#auto_search_limit >= 0: Start search automatically when the user enters N chars #auto_search_limit >= 0: Start search automatically when the user enters N chars
auto_search_limit = -1 auto_search_limit = -1
ignore_deck_changes = 0 #search_multiple_keywords = 0: Disable. 1: Search mutiple keywords with separator " ". 2: with separator "+"
default_ot = 1 search_multiple_keywords = 1
enable_bot_mode = 0 ignore_deck_changes = 0
enable_sound = 1 default_ot = 1
enable_music = 1 enable_bot_mode = 0
#Volume of sound and music, between 0 and 100 quick_animation = 0
sound_volume = 50 auto_save_replay = 0
music_volume = 50 draw_single_chain = 0
music_mode = 1 prefer_expansion_script = 0
window_maximized = 0
window_width = 1280
window_height = 800
resize_popup_menu = 0
enable_sound = 1
enable_music = 1
#Volume of sound and music, between 0 and 100
sound_volume = 50
music_volume = 50
music_mode = 1
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