Commit 589682d3 authored by mercury233's avatar mercury233
parents 2148301e 315ef58a
...@@ -670,8 +670,7 @@ void DeckBuilder::FilterCards() { ...@@ -670,8 +670,7 @@ void DeckBuilder::FilterCards() {
continue; continue;
switch(filter_type) { switch(filter_type) {
case 1: { case 1: {
int type2 = data.type & 0xe03ef1; if(!(data.type & TYPE_MONSTER) || (data.type & filter_type2) != filter_type2)
if(!(data.type & TYPE_MONSTER) || (filter_type2 == 0x21 && type2 != 0x21) || (data.type & filter_type2) != filter_type2)
continue; continue;
if(filter_race && data.race != filter_race) if(filter_race && data.race != filter_race)
continue; continue;
......
...@@ -70,6 +70,8 @@ void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) { ...@@ -70,6 +70,8 @@ void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) {
mainGame->btnJoinHost->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
if(!mainGame->wLanWindow->isVisible())
mainGame->ShowElement(mainGame->wLanWindow);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400));
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
} }
...@@ -138,6 +140,8 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) { ...@@ -138,6 +140,8 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame->btnJoinHost->setEnabled(true); mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true); mainGame->btnJoinCancel->setEnabled(true);
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
if(!mainGame->wLanWindow->isVisible())
mainGame->ShowElement(mainGame->wLanWindow);
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400)); mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400));
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
} else if(connect_state == 0x7) { } else if(connect_state == 0x7) {
...@@ -523,7 +527,14 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -523,7 +527,14 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->wPhase->setVisible(false); mainGame->wPhase->setVisible(false);
if(mainGame->dInfo.player_type < 7) if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false); mainGame->btnLeaveGame->setVisible(false);
mainGame->ebRSName->setText(L""); time_t nowtime = time(NULL);
struct tm *localedtime = localtime(&nowtime);
char timebuf[40];
strftime(timebuf, 40, "%Y-%m-%d %H-%M-%S", localedtime);
size_t size = strlen(timebuf) + 1;
wchar_t timetext[80];
mbstowcs(timetext, timebuf, size);
mainGame->ebRSName->setText(timetext);
mainGame->PopupElement(mainGame->wReplaySave); mainGame->PopupElement(mainGame->wReplaySave);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
mainGame->replaySignal.Reset(); mainGame->replaySignal.Reset();
......
...@@ -892,6 +892,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -892,6 +892,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
irr::core::position2di pos(x, y); irr::core::position2di pos(x, y);
if(x < 300) if(x < 300)
break; break;
if(mainGame->gameConf.control_mode == 1)
mainGame->always_chain = event.MouseInput.isLeftPressed();
if(mainGame->wCmdMenu->isVisible() && !mainGame->wCmdMenu->getRelativePosition().isPointInside(pos)) if(mainGame->wCmdMenu->isVisible() && !mainGame->wCmdMenu->getRelativePosition().isPointInside(pos))
mainGame->wCmdMenu->setVisible(false); mainGame->wCmdMenu->setVisible(false);
if(panel && panel->isVisible()) if(panel && panel->isVisible())
...@@ -1239,6 +1241,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1239,6 +1241,8 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case irr::EMIE_RMOUSE_LEFT_UP: { case irr::EMIE_RMOUSE_LEFT_UP: {
if(mainGame->dInfo.isReplay) if(mainGame->dInfo.isReplay)
break; break;
if(mainGame->gameConf.control_mode == 1 && event.MouseInput.X > 300)
mainGame->ignore_chain = event.MouseInput.isRightPressed();
mainGame->wCmdMenu->setVisible(false); mainGame->wCmdMenu->setVisible(false);
if(mainGame->fadingList.size()) if(mainGame->fadingList.size())
break; break;
...@@ -1531,6 +1535,20 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1531,6 +1535,20 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case irr::EMIE_MOUSE_WHEEL: { case irr::EMIE_MOUSE_WHEEL: {
break; break;
} }
case irr::EMIE_LMOUSE_PRESSED_DOWN: {
if(!mainGame->dInfo.isStarted)
break;
if(mainGame->gameConf.control_mode == 1 && event.MouseInput.X > 300)
mainGame->always_chain = event.MouseInput.isLeftPressed();
break;
}
case irr::EMIE_RMOUSE_PRESSED_DOWN: {
if(!mainGame->dInfo.isStarted)
break;
if(mainGame->gameConf.control_mode == 1 && event.MouseInput.X > 300)
mainGame->ignore_chain = event.MouseInput.isRightPressed();
break;
}
default: default:
break; break;
} }
...@@ -1539,15 +1557,18 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1539,15 +1557,18 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
case irr::EET_KEY_INPUT_EVENT: { case irr::EET_KEY_INPUT_EVENT: {
switch(event.KeyInput.Key) { switch(event.KeyInput.Key) {
case irr::KEY_KEY_A: { case irr::KEY_KEY_A: {
mainGame->always_chain = event.KeyInput.PressedDown; if(mainGame->gameConf.control_mode == 0)
mainGame->always_chain = event.KeyInput.PressedDown;
break; break;
} }
case irr::KEY_KEY_S: { case irr::KEY_KEY_S: {
mainGame->ignore_chain = event.KeyInput.PressedDown; if(mainGame->gameConf.control_mode == 0)
mainGame->ignore_chain = event.KeyInput.PressedDown;
break; break;
} }
case irr::KEY_KEY_R: { case irr::KEY_KEY_R: {
if(!event.KeyInput.PressedDown && !mainGame->HasFocus(EGUIET_EDIT_BOX)) if(mainGame->gameConf.control_mode == 0
&& !event.KeyInput.PressedDown && !mainGame->HasFocus(EGUIET_EDIT_BOX))
mainGame->textFont->setTransparency(true); mainGame->textFont->setTransparency(true);
break; break;
} }
...@@ -1621,6 +1642,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1621,6 +1642,12 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
break; break;
} }
case irr::KEY_F9: {
if(mainGame->gameConf.control_mode == 1
&& !event.KeyInput.PressedDown && !mainGame->HasFocus(EGUIET_EDIT_BOX))
mainGame->textFont->setTransparency(true);
break;
}
case irr::KEY_ESCAPE: { case irr::KEY_ESCAPE: {
if(!mainGame->HasFocus(EGUIET_EDIT_BOX)) if(!mainGame->HasFocus(EGUIET_EDIT_BOX))
mainGame->device->minimizeWindow(); mainGame->device->minimizeWindow();
......
...@@ -9,15 +9,13 @@ ...@@ -9,15 +9,13 @@
#include "netserver.h" #include "netserver.h"
//#include "single_mode.h" //#include "single_mode.h"
#ifdef _WIN32 #ifndef _WIN32
#include <io.h>
#else
#include <sys/types.h> #include <sys/types.h>
#include <dirent.h> #include <dirent.h>
#include <unistd.h> #include <unistd.h>
#endif #endif
const unsigned short PRO_VERSION = 0x1338; const unsigned short PRO_VERSION = 0x1339;
namespace ygo { namespace ygo {
...@@ -106,39 +104,7 @@ bool Game::Initialize() { ...@@ -106,39 +104,7 @@ bool Game::Initialize() {
return false; return false;
if(!dataManager.LoadStrings("strings.conf")) if(!dataManager.LoadStrings("strings.conf"))
return false; return false;
#ifdef _WIN32 RefreshExpansionDB();
char fpath[1000];
WIN32_FIND_DATAW fdataw;
HANDLE fh = FindFirstFileW(L"./expansions/*.cdb", &fdataw);
if(fh != INVALID_HANDLE_VALUE) {
do {
if(!(fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
sprintf(fpath, "./expansions/%ls", fdataw.cFileName);
dataManager.LoadDB(fpath);
}
} while(FindNextFileW(fh, &fdataw));
FindClose(fh);
}
#else
DIR * dir;
struct dirent * dirp;
const char *foldername = "./expansions/";
if((dir = opendir(foldername)) != NULL) {
while((dirp = readdir(dir)) != NULL) {
size_t len = strlen(dirp->d_name);
if(len < 5 || strcasecmp(dirp->d_name + len - 4, ".cdb") != 0)
continue;
char *filepath = (char *)malloc(sizeof(char)*(len + strlen(foldername)));
strncpy(filepath, foldername, strlen(foldername)+1);
strncat(filepath, dirp->d_name, len);
std::cout << "Found file " << filepath << std::endl;
if (!dataManager.LoadDB(filepath))
std::cout << "Error loading file" << std::endl;
free(filepath);
}
closedir(dir);
}
#endif
env = device->getGUIEnvironment(); env = device->getGUIEnvironment();
numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16); numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16);
adFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 12); adFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 12);
...@@ -741,6 +707,41 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu ...@@ -741,6 +707,41 @@ void Game::SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gu
dataManager.strBuffer[pbuffer] = 0; dataManager.strBuffer[pbuffer] = 0;
pControl->setText(dataManager.strBuffer); pControl->setText(dataManager.strBuffer);
} }
void Game::RefreshExpansionDB() {
#ifdef _WIN32
char fpath[1000];
WIN32_FIND_DATAW fdataw;
HANDLE fh = FindFirstFileW(L"./expansions/*.cdb", &fdataw);
if(fh != INVALID_HANDLE_VALUE) {
do {
if(!(fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
sprintf(fpath, "./expansions/%ls", fdataw.cFileName);
dataManager.LoadDB(fpath);
}
} while(FindNextFileW(fh, &fdataw));
FindClose(fh);
}
#else
DIR * dir;
struct dirent * dirp;
const char *foldername = "./expansions/";
if((dir = opendir(foldername)) != NULL) {
while((dirp = readdir(dir)) != NULL) {
size_t len = strlen(dirp->d_name);
if(len < 5 || strcasecmp(dirp->d_name + len - 4, ".cdb") != 0)
continue;
char *filepath = (char *)malloc(sizeof(char)*(len + strlen(foldername)));
strncpy(filepath, foldername, strlen(foldername) + 1);
strncat(filepath, dirp->d_name, len);
std::cout << "Found file " << filepath << std::endl;
if(!dataManager.LoadDB(filepath))
std::cout << "Error loading file" << std::endl;
free(filepath);
}
closedir(dir);
}
#endif
}
void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) { void Game::RefreshDeck(irr::gui::IGUIComboBox* cbDeck) {
cbDeck->clear(); cbDeck->clear();
#ifdef _WIN32 #ifdef _WIN32
...@@ -866,6 +867,7 @@ void Game::LoadConfig() { ...@@ -866,6 +867,7 @@ void Game::LoadConfig() {
gameConf.chkIgnore1 = 0; gameConf.chkIgnore1 = 0;
gameConf.chkIgnore2 = 0; gameConf.chkIgnore2 = 0;
gameConf.chkHideSetname = 0; gameConf.chkHideSetname = 0;
gameConf.control_mode = 0;
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
int fsize = ftell(fp); int fsize = ftell(fp);
fseek(fp, 0, SEEK_SET); fseek(fp, 0, SEEK_SET);
...@@ -906,12 +908,14 @@ void Game::LoadConfig() { ...@@ -906,12 +908,14 @@ void Game::LoadConfig() {
gameConf.chkAutoChain = atoi(valbuf); gameConf.chkAutoChain = atoi(valbuf);
} else if(!strcmp(strbuf, "waitchain")) { } else if(!strcmp(strbuf, "waitchain")) {
gameConf.chkWaitChain = atoi(valbuf); gameConf.chkWaitChain = atoi(valbuf);
} else if(!strcmp(strbuf, "ignore1")) { } else if(!strcmp(strbuf, "mute_opponent")) {
gameConf.chkIgnore1 = atoi(valbuf); gameConf.chkIgnore1 = atoi(valbuf);
} else if(!strcmp(strbuf, "ignore2")) { } else if(!strcmp(strbuf, "mute_spectators")) {
gameConf.chkIgnore2 = atoi(valbuf); gameConf.chkIgnore2 = atoi(valbuf);
} else if(!strcmp(strbuf, "hide_setname")) { } else if(!strcmp(strbuf, "hide_setname")) {
gameConf.chkHideSetname = atoi(valbuf); gameConf.chkHideSetname = atoi(valbuf);
} else if(!strcmp(strbuf, "control_mode")) {
gameConf.control_mode = atoi(valbuf);
} else { } else {
// options allowing multiple words // options allowing multiple words
sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf); sscanf(linebuf, "%s = %240[^\n]", strbuf, valbuf);
...@@ -959,9 +963,11 @@ void Game::SaveConfig() { ...@@ -959,9 +963,11 @@ void Game::SaveConfig() {
fprintf(fp, "randompos = %d\n", ((mainGame->chkRandomPos->isChecked()) ? 1 : 0)); fprintf(fp, "randompos = %d\n", ((mainGame->chkRandomPos->isChecked()) ? 1 : 0));
fprintf(fp, "autochain = %d\n", ((mainGame->chkAutoChain->isChecked()) ? 1 : 0)); fprintf(fp, "autochain = %d\n", ((mainGame->chkAutoChain->isChecked()) ? 1 : 0));
fprintf(fp, "waitchain = %d\n", ((mainGame->chkWaitChain->isChecked()) ? 1 : 0)); fprintf(fp, "waitchain = %d\n", ((mainGame->chkWaitChain->isChecked()) ? 1 : 0));
fprintf(fp, "ignore1 = %d\n", ((mainGame->chkIgnore1->isChecked()) ? 1 : 0)); fprintf(fp, "mute_opponent = %d\n", ((mainGame->chkIgnore1->isChecked()) ? 1 : 0));
fprintf(fp, "ignore2 = %d\n", ((mainGame->chkIgnore2->isChecked()) ? 1 : 0)); fprintf(fp, "mute_spectators = %d\n", ((mainGame->chkIgnore2->isChecked()) ? 1 : 0));
fprintf(fp, "hide_setname = %d\n", ((mainGame->chkHideSetname->isChecked()) ? 1 : 0)); fprintf(fp, "hide_setname = %d\n", ((mainGame->chkHideSetname->isChecked()) ? 1 : 0));
fprintf(fp, "#control_mode = 0: Key A/S/R. control_mode = 1: MouseLeft/MouseRight/F9\n");
fprintf(fp, "control_mode = %d\n", gameConf.control_mode);
fclose(fp); fclose(fp);
} }
void Game::ShowCardInfo(int code) { void Game::ShowCardInfo(int code) {
......
...@@ -32,6 +32,7 @@ struct Config { ...@@ -32,6 +32,7 @@ struct Config {
int chkIgnore1; int chkIgnore1;
int chkIgnore2; int chkIgnore2;
int chkHideSetname; int chkHideSetname;
int control_mode;
}; };
struct DuelInfo { struct DuelInfo {
...@@ -81,6 +82,7 @@ public: ...@@ -81,6 +82,7 @@ public:
void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar); void BuildProjectionMatrix(irr::core::matrix4& mProjection, f32 left, f32 right, f32 bottom, f32 top, f32 znear, f32 zfar);
void InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text); void InitStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, u32 cHeight, irr::gui::CGUITTFont* font, const wchar_t* text);
void SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos = 0); void SetStaticText(irr::gui::IGUIStaticText* pControl, u32 cWidth, irr::gui::CGUITTFont* font, const wchar_t* text, u32 pos = 0);
void RefreshExpansionDB();
void RefreshDeck(irr::gui::IGUIComboBox* cbDeck); void RefreshDeck(irr::gui::IGUIComboBox* cbDeck);
void RefreshReplay(); void RefreshReplay();
void RefreshSingleplay(); void RefreshSingleplay();
......
...@@ -62,9 +62,7 @@ int main(int argc, char* argv[]) { ...@@ -62,9 +62,7 @@ int main(int argc, char* argv[]) {
event.EventType = irr::EET_GUI_EVENT; event.EventType = irr::EET_GUI_EVENT;
event.GUIEvent.EventType = irr::gui::EGET_BUTTON_CLICKED; event.GUIEvent.EventType = irr::gui::EGET_BUTTON_CLICKED;
if(!strcmp(argv[i], "-j")) { if(!strcmp(argv[i], "-j")) {
event.GUIEvent.Caller = ygo::mainGame->btnLanMode; ygo::mainGame->HideElement(ygo::mainGame->wMainMenu);
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; event.GUIEvent.Caller = ygo::mainGame->btnJoinHost;
ygo::mainGame->device->postEventFromUser(event); ygo::mainGame->device->postEventFromUser(event);
} else if(!strcmp(argv[i], "-d")) { } else if(!strcmp(argv[i], "-d")) {
......
...@@ -252,7 +252,7 @@ ...@@ -252,7 +252,7 @@
!system 1233 每回合抽卡: !system 1233 每回合抽卡:
!system 1234 主机名称: !system 1234 主机名称:
!system 1235 主机密码: !system 1235 主机密码:
!system 1236 旧规则(先攻抽卡、动效果优先权等) !system 1236 旧规则(先攻抽卡、动效果优先权等)
!system 1237 每回合时间: !system 1237 每回合时间:
!system 1240 OCG !system 1240 OCG
!system 1241 TCG !system 1241 TCG
......
...@@ -15,6 +15,8 @@ autopos = 1 ...@@ -15,6 +15,8 @@ autopos = 1
randompos = 0 randompos = 0
autochain = 0 autochain = 0
waitchain = 0 waitchain = 0
ignore1 = 0 mute_opponent = 0
ignore2 = 0 mute_spectators = 0
hide_setname = 0 hide_setname = 0
#control_mode = 0: Key A/S/R. control_mode = 1: MouseLeft/MouseRight/F9
control_mode = 0
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