Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Fluorohydride/ygopro
Browse files Browse the repository at this point in the history
  • Loading branch information
mercury233 committed May 26, 2020
2 parents eb02897 + 3aeb772 commit 8f9e542
Show file tree
Hide file tree
Showing 13 changed files with 203 additions and 113 deletions.
3 changes: 1 addition & 2 deletions gframe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ endif ()
target_link_libraries (ygopro ocgcore clzma)

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" )
else ()
target_link_libraries (ygopro
${IRRLICHT_LIBRARIES}
${FREETYPE_LIBRARIES}
${SQLITE_LIBRARIES}
${LIBEVENT_LIBRARIES}
${LUA_LIBRARIES}
${OPENGL_gl_LIBRARY}
)
include_directories (
Expand Down
11 changes: 9 additions & 2 deletions gframe/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,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;
Expand Down Expand Up @@ -992,6 +992,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)
Expand Down Expand Up @@ -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);
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);
Expand Down
41 changes: 10 additions & 31 deletions gframe/duelclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,24 +369,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();
Expand Down Expand Up @@ -486,12 +479,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->SetStaticText(mainGame->stHostPrepRule, 180, mainGame->guiFont, str.c_str());
mainGame->RefreshDeck(mainGame->cbDeckSelect);
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);
Expand Down Expand Up @@ -649,12 +639,7 @@ 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);
mainGame->wSurrender->setVisible(false);
mainGame->CloseGameButtons();
mainGame->stMessage->setText(dataManager.GetSysString(1500));
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.unlock();
Expand Down Expand Up @@ -688,14 +673,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));
Expand Down Expand Up @@ -2390,8 +2370,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnLeaveGame->setText(dataManager.GetSysString(1351));
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->gameConf.control_mode == 0) {
mainGame->btnChainIgnore->setVisible(true);
Expand Down Expand Up @@ -2906,7 +2885,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
int ct = BufferIO::ReadInt8(pbuf);
if(mainGame->dInfo.isReplay && mainGame->dInfo.isReplaySkiping)
return true;
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) {
Expand Down
16 changes: 7 additions & 9 deletions gframe/event_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -1459,8 +1453,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;
Expand Down Expand Up @@ -1877,6 +1870,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;
Expand Down
35 changes: 25 additions & 10 deletions gframe/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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->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;
Expand Down Expand Up @@ -1090,6 +1093,7 @@ void Game::LoadConfig() {
gameConf.enable_bot_mode = 0;
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;
Expand Down Expand Up @@ -1172,6 +1176,8 @@ void Game::LoadConfig() {
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")) {
Expand Down Expand Up @@ -1259,6 +1265,7 @@ void Game::SaveConfig() {
fprintf(fp, "enable_bot_mode = %d\n", gameConf.enable_bot_mode);
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);
Expand Down Expand Up @@ -1471,7 +1478,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;
Expand All @@ -1481,34 +1498,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();
Expand Down
5 changes: 5 additions & 0 deletions gframe/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct Config {
int enable_bot_mode;
int quick_animation;
int auto_save_replay;
int draw_single_chain;
int prefer_expansion_script;
bool enable_sound;
bool enable_music;
Expand Down Expand Up @@ -148,6 +149,8 @@ class Game {
void AddDebugMsg(const char* msgbuf);
void ErrorLog(const char* msgbuf);
void ClearTextures();
void CloseGameButtons();
void CloseGameWindow();
void CloseDuelWindow();

int LocalPlayer(int player);
Expand Down Expand Up @@ -282,6 +285,7 @@ class Game {
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;
Expand Down Expand Up @@ -723,6 +727,7 @@ extern Game* mainGame;
#define SCROLL_TAB_SYSTEM 371
#define CHECKBOX_MULTI_KEYWORDS 372
#define CHECKBOX_PREFER_EXPANSION 373
#define CHECKBOX_DRAW_SINGLE_CHAIN 374

#define DEFAULT_DUEL_RULE 5

Expand Down
Loading

0 comments on commit 8f9e542

Please sign in to comment.