Commit d3fb4b86 authored by mycard's avatar mycard

Merge branch 'server' of https://github.com/purerosefallen/ygopro

parents c4974bcd 758e4e1b
......@@ -48,6 +48,7 @@
# ygopro folders
/deck
/pack
/fonts
/replay
/single
......
......@@ -39,9 +39,9 @@ after_build:
- 7z x -y -oredis Redis-x64-3.2.100.zip
# nodejs
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://nodejs.org/dist/v10.15.0/node-v10.15.0-win-x64.zip ; exit 0"
- 7z x -y node-v10.15.0-win-x64.zip
- mv node-v10.15.0-win-x64 node
- bash -c "curl --retry 5 --connect-timeout 30 --location --remote-header-name --remote-name https://nodejs.org/dist/v10.15.3/node-v10.15.3-win-x64.zip ; exit 0"
- 7z x -y node-v10.15.3-win-x64.zip
- mv node-v10.15.3-win-x64 node
# srvpro
- git clone https://github.com/purerosefallen/ygopro-server
......
No preview for this file type
This diff is collapsed.
......@@ -60,10 +60,12 @@ public:
size_t pre_extrac;
size_t pre_sidec;
code_pointer draging_pointer;
int prev_category;
int prev_deck;
s32 prev_operation;
int prev_sel;
bool is_modified;
bool readonly;
std::unordered_map<int, int>* filterList;
std::vector<code_pointer> results;
......
......@@ -59,23 +59,6 @@ void DeckManager::LoadLFList() {
nolimit.content = new std::unordered_map<int, int>;
_lfList.push_back(nolimit);
}
bool DeckManager::RenameDeck(const wchar_t* oldname, const wchar_t* newname) {
wchar_t oldfname[256];
wchar_t newfname[256];
myswprintf(oldfname, L"./deck/%ls.ydk", oldname);
myswprintf(newfname, L"./deck/%ls.ydk", newname);
#ifdef WIN32
BOOL result = MoveFileW(oldfname, newfname);
return !!result;
#else
char oldfilefn[256];
char newfilefn[256];
BufferIO::EncodeUTF8(oldfname, oldfilefn);
BufferIO::EncodeUTF8(newfname, newfilefn);
int result = rename(oldfilefn, newfilefn);
return result == 0;
#endif
}
wchar_t* DeckManager::GetLFListName(int lfhash) {
for(size_t i = 0; i < _lfList.size(); ++i) {
if(_lfList[i].hash == (unsigned int)lfhash) {
......@@ -211,6 +194,39 @@ bool DeckManager::LoadSide(Deck& deck, int* dbuf, int mainc, int sidec) {
*/
return true;
}
#ifndef YGOPRO_SERVER_MODE
void DeckManager::GetCategoryPath(wchar_t* ret, int index, const wchar_t* text) {
wchar_t catepath[256];
switch(index) {
case 0:
myswprintf(catepath, L"./pack");
break;
case 1:
myswprintf(catepath, mainGame->gameConf.bot_deck_path);
break;
case -1:
case 2:
case 3:
myswprintf(catepath, L"./deck");
break;
default:
myswprintf(catepath, L"./deck/%ls", text);
}
BufferIO::CopyWStr(catepath, ret, 256);
}
void DeckManager::GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck) {
wchar_t filepath[256];
wchar_t catepath[256];
GetCategoryPath(catepath, cbCategory->getSelected(), cbCategory->getText());
myswprintf(filepath, L"%ls/%ls.ydk", catepath, cbDeck->getItem(cbDeck->getSelected()));
BufferIO::CopyWStr(filepath, ret, 256);
}
bool DeckManager::LoadDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck) {
wchar_t filepath[256];
GetDeckFile(filepath, cbCategory, cbDeck);
return LoadDeck(filepath);
}
#endif
FILE* DeckManager::OpenDeckFile(const wchar_t* file, const char* mode) {
#ifdef WIN32
FILE* fp = _wfopen(file, (wchar_t*)mode);
......@@ -223,11 +239,11 @@ FILE* DeckManager::OpenDeckFile(const wchar_t* file, const char* mode) {
}
bool DeckManager::LoadDeck(const wchar_t* file) {
int sp = 0, ct = 0, mainc = 0, sidec = 0, code;
FILE* fp = OpenDeckFile(file, "r");
if(!fp) {
wchar_t localfile[64];
myswprintf(localfile, L"./deck/%ls.ydk", file);
FILE* fp = OpenDeckFile(localfile, "r");
if(!fp) {
fp = OpenDeckFile(file, "r");
fp = OpenDeckFile(localfile, "r");
}
if(!fp)
return false;
......@@ -253,11 +269,9 @@ bool DeckManager::LoadDeck(const wchar_t* file) {
LoadDeck(current_deck, cardlist, mainc, sidec);
return true;
}
bool DeckManager::SaveDeck(Deck& deck, const wchar_t* name) {
bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) {
if(!FileSystem::IsDirExists(L"./deck") && !FileSystem::MakeDir(L"./deck"))
return false;
wchar_t file[64];
myswprintf(file, L"./deck/%ls.ydk", name);
FILE* fp = OpenDeckFile(file, "w");
if(!fp)
return false;
......@@ -273,9 +287,7 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* name) {
fclose(fp);
return true;
}
bool DeckManager::DeleteDeck(Deck& deck, const wchar_t* name) {
wchar_t file[64];
myswprintf(file, L"./deck/%ls.ydk", name);
bool DeckManager::DeleteDeck(const wchar_t* file) {
#ifdef WIN32
BOOL result = DeleteFileW(file);
return !!result;
......@@ -320,4 +332,31 @@ int DeckManager::SaveDeckToCode(Deck& deck, char* code) {
Base64::Encode(deckbuf, len, code, encoded_len);
return encoded_len;
}
bool DeckManager::CreateCategory(const wchar_t* name) {
if(!FileSystem::IsDirExists(L"./deck") && !FileSystem::MakeDir(L"./deck"))
return false;
if(name[0] == 0)
return false;
wchar_t localname[256];
myswprintf(localname, L"./deck/%ls", name);
return FileSystem::MakeDir(localname);
}
bool DeckManager::RenameCategory(const wchar_t* oldname, const wchar_t* newname) {
if(!FileSystem::IsDirExists(L"./deck") && !FileSystem::MakeDir(L"./deck"))
return false;
if(newname[0] == 0)
return false;
wchar_t oldlocalname[256];
wchar_t newlocalname[256];
myswprintf(oldlocalname, L"./deck/%ls", oldname);
myswprintf(newlocalname, L"./deck/%ls", newname);
return FileSystem::Rename(oldlocalname, newlocalname);
}
bool DeckManager::DeleteCategory(const wchar_t* name) {
wchar_t localname[256];
myswprintf(localname, L"./deck/%ls", name);
if(!FileSystem::IsDirExists(localname))
return false;
return FileSystem::DeleteDir(localname);
}
}
......@@ -41,15 +41,22 @@ public:
int CheckDeck(Deck& deck, int lfhash, bool allow_ocg, bool allow_tcg);
int LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec);
bool LoadSide(Deck& deck, int* dbuf, int mainc, int sidec);
#ifndef YGOPRO_SERVER_MODE
void GetCategoryPath(wchar_t* ret, int index, const wchar_t* text);
void GetDeckFile(wchar_t* ret, irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck);
bool LoadDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck);
#endif
FILE* OpenDeckFile(const wchar_t * file, const char * mode);
bool LoadDeck(const wchar_t* file);
bool SaveDeck(Deck& deck, const wchar_t* name);
bool DeleteDeck(Deck& deck, const wchar_t* name);
static bool RenameDeck(const wchar_t* oldname, const wchar_t* newname);
bool SaveDeck(Deck& deck, const wchar_t* file);
bool DeleteDeck(const wchar_t* file);
wchar_t DeckFormatBuffer[128];
int TypeCount(std::vector<code_pointer> list, unsigned int ctype);
bool LoadDeckFromCode(Deck& deck, const char *code, int len);
int SaveDeckToCode(Deck &deck, char *code);
bool CreateCategory(const wchar_t* name);
bool RenameCategory(const wchar_t* oldname, const wchar_t* newname);
bool DeleteCategory(const wchar_t* name);
};
extern DeckManager deckManager;
......
......@@ -25,6 +25,9 @@ char DuelClient::duel_client_write[0x2000];
bool DuelClient::is_closing = false;
int DuelClient::select_hint = 0;
int DuelClient::select_unselect_hint = 0;
int DuelClient::last_select_hint = 0;
char DuelClient::last_successful_msg[2048];
unsigned int DuelClient::last_successful_msg_length = 0;
wchar_t DuelClient::event_string[256];
mtrandom DuelClient::rnd;
......@@ -325,6 +328,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
}
soundManager.PlaySoundEffect(SOUND_INFO);
mainGame->env->addMessageBox(L"", msgbuf);
mainGame->cbCategorySelect->setEnabled(true);
mainGame->cbDeckSelect->setEnabled(true);
mainGame->gMutex.Unlock();
break;
......@@ -422,7 +426,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
}
case STOC_SELECT_TP: {
mainGame->gMutex.Lock();
mainGame->ShowElement(mainGame->wFTSelect);
mainGame->PopupElement(mainGame->wFTSelect);
mainGame->gMutex.Unlock();
break;
}
......@@ -552,7 +556,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->stHostPrepDuelist[3]->setText(L"");
mainGame->stHostPrepOB->setText(L"");
mainGame->SetStaticText(mainGame->stHostPrepRule, 180, mainGame->guiFont, str.c_str());
mainGame->RefreshDeck(mainGame->cbDeckSelect);
mainGame->RefreshCategoryDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect);
mainGame->cbCategorySelect->setEnabled(true);
mainGame->cbDeckSelect->setEnabled(true);
if(mainGame->wCreateHost->isVisible())
mainGame->HideElement(mainGame->wCreateHost);
......@@ -953,10 +958,14 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
}
}
}
int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
int DuelClient::ClientAnalyze(char * msg, unsigned int len, bool retry) {
char* pbuf = msg;
wchar_t textBuffer[256];
mainGame->dInfo.curMsg = BufferIO::ReadUInt8(pbuf);
if(mainGame->dInfo.curMsg != MSG_RETRY && !retry) {
memcpy(last_successful_msg, msg, len);
last_successful_msg_length = len;
}
mainGame->wCmdMenu->setVisible(false);
if(!mainGame->dInfo.isReplay && mainGame->dInfo.curMsg != MSG_WAITING && mainGame->dInfo.curMsg != MSG_CARD_SELECTED) {
mainGame->waitFrame = -1;
......@@ -978,6 +987,17 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dInfo.time_player = 2;
switch(mainGame->dInfo.curMsg) {
case MSG_RETRY: {
if(!retry && last_successful_msg_length) {
mainGame->gMutex.Lock();
mainGame->stMessage->setText(dataManager.GetDesc(1422));
mainGame->PopupElement(mainGame->wMessage);
mainGame->gMutex.Unlock();
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
select_hint = last_select_hint;
ClientAnalyze(last_successful_msg, last_successful_msg_length, true);
break;
}
mainGame->gMutex.Lock();
mainGame->stMessage->setText(L"Error occurs.");
mainGame->PopupElement(mainGame->wMessage);
......@@ -1029,12 +1049,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
case HINT_SELECTMSG: {
select_hint = data;
last_select_hint = data;
break;
}
case HINT_OPSELECTED: {
myswprintf(textBuffer, dataManager.GetSysString(1510), dataManager.GetDesc(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->AddLog(textBuffer);
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
......@@ -1051,8 +1071,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
case HINT_RACE: {
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatRace(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->AddLog(textBuffer);
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
......@@ -1062,8 +1081,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
case HINT_ATTRIB: {
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.FormatAttribute(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->AddLog(textBuffer);
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
......@@ -1073,8 +1091,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
case HINT_CODE: {
myswprintf(textBuffer, dataManager.GetSysString(1511), dataManager.GetName(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(data);
mainGame->AddLog(textBuffer, data);
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
......@@ -1084,8 +1101,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
case HINT_NUMBER: {
myswprintf(textBuffer, dataManager.GetSysString(1512), data);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->AddLog(textBuffer);
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->guiFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
......@@ -1222,7 +1238,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dInfo.turn = 0;
mainGame->dInfo.is_shuffling = false;
mainGame->dInfo.is_swapped = false;
if(mainGame->dInfo.isReplaySwapped) {
select_hint = 0;
select_unselect_hint = 0;
last_select_hint = 0;
last_successful_msg_length = 0;
if (mainGame->dInfo.isReplaySwapped)
{
std::swap(mainGame->dInfo.hostname, mainGame->dInfo.clientname);
std::swap(mainGame->dInfo.hostname_tag, mainGame->dInfo.clientname_tag);
mainGame->dInfo.isReplaySwapped = false;
......@@ -2023,14 +2044,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
soundManager.PlaySoundEffect(SOUND_REVEAL);
myswprintf(textBuffer, dataManager.GetSysString(207), count);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->AddLog(textBuffer);
for (int i = 0; i < count; ++i) {
pcard = *(mainGame->dField.deck[player].rbegin() + i);
mainGame->gMutex.Lock();
myswprintf(textBuffer, L"*[%ls]", dataManager.GetName(pcard->code));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(pcard->code);
mainGame->AddLog(textBuffer, pcard->code);
mainGame->gMutex.Unlock();
float shift = -0.15f;
if (player == 1) shift = 0.15f;
......@@ -2063,14 +2082,12 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
soundManager.PlaySoundEffect(SOUND_REVEAL);
myswprintf(textBuffer, dataManager.GetSysString(207), count);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->AddLog(textBuffer);
for (int i = 0; i < count; ++i) {
pcard = *(mainGame->dField.extra[player].rbegin() + i + mainGame->dField.extra_p_count[player]);
mainGame->gMutex.Lock();
myswprintf(textBuffer, L"*[%ls]", dataManager.GetName(pcard->code));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(pcard->code);
mainGame->AddLog(textBuffer, pcard->code);
mainGame->gMutex.Unlock();
if (player == 0)
pcard->dPos = irr::core::vector3df(0, -0.20f, 0);
......@@ -2098,8 +2115,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
soundManager.PlaySoundEffect(SOUND_REVEAL);
myswprintf(textBuffer, dataManager.GetSysString(208), count);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->AddLog(textBuffer);
for (int i = 0; i < count; ++i) {
code = BufferIO::ReadInt32(pbuf);
c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
......@@ -2114,8 +2130,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->SetCode(code);
mainGame->gMutex.Lock();
myswprintf(textBuffer, L"*[%ls]", dataManager.GetName(code));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(code);
mainGame->AddLog(textBuffer, code);
mainGame->gMutex.Unlock();
if (l & 0x41 || l == 0) {
if(count == 1 && l != 0) {
......@@ -3059,8 +3074,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} else
mainGame->WaitFrameSignal(30);
myswprintf(textBuffer, dataManager.GetSysString(1610), dataManager.GetName(pcard->code), dataManager.FormatLocation(l, s), s + 1);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(pcard->code);
mainGame->AddLog(textBuffer, pcard->code);
pcard->is_highlighting = false;
}
return true;
......@@ -3466,8 +3480,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
BufferIO::ReadInt32(pbuf);
unsigned int code = (unsigned int)BufferIO::ReadInt32(pbuf);
myswprintf(textBuffer, dataManager.GetSysString(1622), dataManager.GetName(code));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(code);
mainGame->AddLog(textBuffer, code);
return true;
}
case MSG_TOSS_COIN: {
......@@ -3486,8 +3499,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
soundManager.PlaySoundEffect(SOUND_COIN);
mainGame->gMutex.Lock();
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->AddLog(textBuffer);
mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock();
......@@ -3510,8 +3522,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
return true;
soundManager.PlaySoundEffect(SOUND_DICE);
mainGame->gMutex.Lock();
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->AddLog(textBuffer);
mainGame->stACMessage->setText(textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->gMutex.Unlock();
......
......@@ -31,6 +31,9 @@ private:
static bool is_closing;
static int select_hint;
static int select_unselect_hint;
static int last_select_hint;
static char last_successful_msg[2048];
static unsigned int last_successful_msg_length;
static wchar_t event_string[256];
static mtrandom rnd;
public:
......@@ -46,7 +49,7 @@ public:
static void ClientEvent(bufferevent *bev, short events, void *ctx);
static int ClientThread(void* param);
static void HandleSTOCPacketLan(char* data, unsigned int len);
static int ClientAnalyze(char* msg, unsigned int len);
static int ClientAnalyze(char* msg, unsigned int len, bool retry = false);
static void SetResponseI(int respI);
static void SetResponseB(void* respB, unsigned char len);
static void SendResponse();
......
This diff is collapsed.
......@@ -27,11 +27,13 @@ struct Config {
wchar_t lastport[10];
wchar_t nickname[20];
wchar_t gamename[20];
wchar_t lastcategory[64];
wchar_t lastdeck[64];
wchar_t textfont[256];
wchar_t numfont[256];
wchar_t roompass[20];
wchar_t locale[64];
wchar_t bot_deck_path[64];
//settings
int chkMAutoPos;
int chkSTAutoPos;
......@@ -142,7 +144,9 @@ public:
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 LoadExpansions();
void RefreshDeck(irr::gui::IGUIComboBox* cbDeck);
void RefreshCategoryDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck, bool selectlastused = true);
void RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck);
void RefreshDeck(const wchar_t* deckpath, irr::gui::IGUIComboBox* cbDeck);
void RefreshReplay();
void RefreshSingleplay();
void RefreshBot();
......@@ -171,6 +175,7 @@ public:
void SaveConfig();
void ShowCardInfo(int code, bool resize = false);
void ClearCardInfo(int player = 0);
void AddLog(const wchar_t* msg, int param = 0);
void AddChatMsg(const wchar_t* msg, int player);
void ClearChatMsg();
void AddDebugMsg(const char* msgbuf);
......@@ -376,6 +381,7 @@ public:
irr::gui::IGUIStaticText* stHostPrepDuelist[4];
irr::gui::IGUICheckBox* chkHostPrepReady[4];
irr::gui::IGUIButton* btnHostPrepKick[4];
irr::gui::IGUIComboBox* cbCategorySelect;
irr::gui::IGUIComboBox* cbDeckSelect;
irr::gui::IGUIStaticText* stHostPrepRule;
irr::gui::IGUIStaticText* stHostPrepOB;
......@@ -499,8 +505,9 @@ public:
irr::gui::IGUIButton* btnEP;
//deck edit
irr::gui::IGUIStaticText* wDeckEdit;
irr::gui::IGUIComboBox* cbDBLFList;
irr::gui::IGUIComboBox* cbDBCategory;
irr::gui::IGUIComboBox* cbDBDecks;
irr::gui::IGUIButton* btnManageDeck;
irr::gui::IGUIButton* btnClearDeck;
irr::gui::IGUIButton* btnSortDeck;
irr::gui::IGUIButton* btnShuffleDeck;
......@@ -512,7 +519,6 @@ public:
irr::gui::IGUIButton* btnSideSort;
irr::gui::IGUIButton* btnSideReload;
irr::gui::IGUIEditBox* ebDeckname;
irr::gui::IGUIButton* btnRenameDeck;
irr::gui::IGUIButton* btnDeckCode;
//deck rename
irr::gui::IGUIWindow* wRenameDeck;
......@@ -525,7 +531,7 @@ public:
irr::gui::IGUIButton* btnDeckCodeYes;
irr::gui::IGUIButton* btnDeckCodeNo;
//
irr::gui::IGUIStaticText* stBanlist;
irr::gui::IGUIStaticText* stDBCategory;
irr::gui::IGUIStaticText* stDeck;
irr::gui::IGUIStaticText* stCategory;
irr::gui::IGUIStaticText* stLimit;
......@@ -536,6 +542,26 @@ public:
irr::gui::IGUIStaticText* stStar;
irr::gui::IGUIStaticText* stSearch;
irr::gui::IGUIStaticText* stScale;
//deck manage
irr::gui::IGUIWindow* wDeckManage;
irr::gui::IGUIListBox* lstCategories;
irr::gui::IGUIListBox* lstDecks;
irr::gui::IGUIButton* btnNewCategory;
irr::gui::IGUIButton* btnRenameCategory;
irr::gui::IGUIButton* btnDeleteCategory;
irr::gui::IGUIButton* btnNewDeck;
irr::gui::IGUIButton* btnRenameDeck;
irr::gui::IGUIButton* btnDMDeleteDeck;
irr::gui::IGUIButton* btnMoveDeck;
irr::gui::IGUIButton* btnCopyDeck;
irr::gui::IGUIWindow* wDMQuery;
irr::gui::IGUIStaticText* stDMMessage;
irr::gui::IGUIStaticText* stDMMessage2;
irr::gui::IGUIEditBox* ebDMName;
irr::gui::IGUIComboBox* cbDMCategory;
irr::gui::IGUIButton* btnDMOK;
irr::gui::IGUIButton* btnDMCancel;
irr::gui::IGUIComboBox* cbLFList;
//filter
irr::gui::IGUIStaticText* wFilter;
irr::gui::IGUIScrollBar* scrFilter;
......@@ -639,13 +665,29 @@ extern HostInfo game_info;
#define CHECKBOX_HP_READY 125
#define BUTTON_HP_READY 126
#define BUTTON_HP_NOTREADY 127
#define COMBOBOX_HP_CATEGORY 128
#define LISTBOX_REPLAY_LIST 130
#define BUTTON_LOAD_REPLAY 131
#define BUTTON_CANCEL_REPLAY 132
#define BUTTON_DELETE_REPLAY 133
#define BUTTON_RENAME_REPLAY 134
#define BUTTON_EXPORT_DECK 135
#define EDITBOX_CHAT 140
#define BUTTON_REPLAY_START 140
#define BUTTON_REPLAY_PAUSE 141
#define BUTTON_REPLAY_STEP 142
#define BUTTON_REPLAY_UNDO 143
#define BUTTON_REPLAY_EXIT 144
#define BUTTON_REPLAY_SWAP 145
#define BUTTON_REPLAY_SAVE 146
#define BUTTON_REPLAY_CANCEL 147
#define LISTBOX_SINGLEPLAY_LIST 150
#define BUTTON_LOAD_SINGLEPLAY 151
#define BUTTON_CANCEL_SINGLEPLAY 152
#define LISTBOX_BOT_LIST 153
#define BUTTON_BOT_START 154
#define CHECKBOX_BOT_OLD_RULE 155
#define EDITBOX_CHAT 199
#define BUTTON_MSG_OK 200
#define BUTTON_YES 201
#define BUTTON_NO 202
......@@ -710,10 +752,12 @@ extern HostInfo game_info;
#define BUTTON_DISPLAY_4 294
#define SCROLL_CARD_DISPLAY 295
#define BUTTON_CARD_DISP_OK 296
#define BUTTON_SURRENDER_YES 297
#define BUTTON_SURRENDER_NO 298
#define BUTTON_CATEGORY_OK 300
#define COMBOBOX_DBLFLIST 301
#define BUTTON_MANAGE_DECK 300
#define COMBOBOX_DBCATEGORY 301
#define COMBOBOX_DBDECKS 302
#define BUTTON_CLEAR_DECK 303
#define BUTTON_SAVE_DECK 304
......@@ -732,26 +776,28 @@ extern HostInfo game_info;
#define BUTTON_CLEAR_FILTER 317
#define COMBOBOX_ATTRIBUTE 318
#define COMBOBOX_RACE 319
#define BUTTON_REPLAY_START 320
#define BUTTON_REPLAY_PAUSE 321
#define BUTTON_REPLAY_STEP 322
#define BUTTON_REPLAY_UNDO 323
#define BUTTON_REPLAY_EXIT 324
#define BUTTON_REPLAY_SWAP 325
#define BUTTON_REPLAY_SAVE 330
#define BUTTON_REPLAY_CANCEL 331
#define BUTTON_BOT_START 340
#define LISTBOX_BOT_LIST 341
#define CHECKBOX_BOT_OLD_RULE 342
#define LISTBOX_SINGLEPLAY_LIST 343
#define BUTTON_LOAD_SINGLEPLAY 344
#define BUTTON_CANCEL_SINGLEPLAY 345
#define SCROLL_TAB_HELPER 350
#define SCROLL_TAB_SYSTEM 351
#define COMBOBOX_LIMIT 320
#define BUTTON_CATEGORY_OK 321
#define BUTTON_MARKS_FILTER 322
#define BUTTON_MARKERS_OK 323
#define COMBOBOX_SORTTYPE 324
#define WINDOW_DECK_MANAGE 330
#define BUTTON_NEW_CATEGORY 331
#define BUTTON_RENAME_CATEGORY 332
#define BUTTON_DELETE_CATEGORY 333
#define BUTTON_NEW_DECK 334
#define BUTTON_RENAME_DECK 335
#define BUTTON_DELETE_DECK_DM 336
#define BUTTON_MOVE_DECK 337
#define BUTTON_COPY_DECK 338
#define LISTBOX_CATEGORIES 339
#define LISTBOX_DECKS 340
#define BUTTON_DM_OK 341
#define BUTTON_DM_CANCEL 342
#define COMBOBOX_LFLIST 349
#define CHECKBOX_AUTO_SEARCH 360
#define CHECKBOX_MULTI_KEYWORDS 372
#define CHECKBOX_PREFER_EXPANSION 373
#define CHECKBOX_REGEX 374
#define CHECKBOX_ENABLE_SOUND 361
#define CHECKBOX_ENABLE_MUSIC 362
#define SCROLL_VOLUME 363
......@@ -761,17 +807,12 @@ extern HostInfo game_info;
#define BUTTON_WINDOW_RESIZE_L 367
#define BUTTON_WINDOW_RESIZE_XL 368
#define CHECKBOX_QUICK_ANIMATION 369
#define COMBOBOX_SORTTYPE 370
#define COMBOBOX_LIMIT 371
#define COMBOBOX_LOCALE 372
#define BUTTON_MARKS_FILTER 380
#define BUTTON_MARKERS_OK 381
#define BUTTON_RENAME_DECK 386
#define BUTTON_RENAME_DECK_SAVE 387
#define BUTTON_RENAME_DECK_CANCEL 388
#define SCROLL_TAB_HELPER 370
#define SCROLL_TAB_SYSTEM 371
#define CHECKBOX_MULTI_KEYWORDS 372
#define CHECKBOX_PREFER_EXPANSION 373
#define CHECKBOX_REGEX 374
#define COMBOBOX_LOCALE 375
#define BUTTON_DECK_CODE 389
#define BUTTON_DECK_CODE_SAVE 390
......
......@@ -170,6 +170,7 @@ int main(int argc, char* argv[]) {
} else if(!wcscmp(wargv[i], L"-d")) { // Deck
++i;
if(i + 1 < wargc) { // select deck
ygo::mainGame->gameConf.lastcategory[0] = 0;
wcscpy(ygo::mainGame->gameConf.lastdeck, wargv[i]);
continue;
} else { // open deck
......
......@@ -12,6 +12,8 @@
namespace ygo {
void UpdateDeck() {
BufferIO::CopyWStr(mainGame->cbCategorySelect->getItem(mainGame->cbCategorySelect->getSelected()),
mainGame->gameConf.lastcategory, 64);
BufferIO::CopyWStr(mainGame->cbDeckSelect->getItem(mainGame->cbDeckSelect->getSelected()),
mainGame->gameConf.lastdeck, 64);
char deckbuf[1024];
......@@ -141,6 +143,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_HP_DUELIST: {
mainGame->cbCategorySelect->setEnabled(true);
mainGame->cbDeckSelect->setEnabled(true);
DuelClient::SendPacketToServer(CTOS_HS_TODUELIST);
break;
......@@ -162,17 +165,19 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_HP_READY: {
if(mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadDeck(mainGame->cbDeckSelect->getItem(mainGame->cbDeckSelect->getSelected()))) {
if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) {
break;
}
UpdateDeck();
DuelClient::SendPacketToServer(CTOS_HS_READY);
mainGame->cbCategorySelect->setEnabled(false);
mainGame->cbDeckSelect->setEnabled(false);
break;
}
case BUTTON_HP_NOTREADY: {
DuelClient::SendPacketToServer(CTOS_HS_NOTREADY);
mainGame->cbCategorySelect->setEnabled(true);
mainGame->cbDeckSelect->setEnabled(true);
break;
}
......@@ -321,7 +326,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
NetServer::StopServer();
break;
}
STARTUPINFO si;
STARTUPINFOW si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
......@@ -374,7 +379,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_DECK_EDIT: {
mainGame->RefreshDeck(mainGame->cbDBDecks);
mainGame->RefreshCategoryDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
if(open_file && deckManager.LoadDeck(open_file_name)) {
#ifdef WIN32
wchar_t *dash = wcsrchr(open_file_name, L'\\');
......@@ -397,8 +402,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
}
open_file = false;
} else if(mainGame->cbDBDecks->getSelected() != -1) {
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(mainGame->cbDBDecks->getSelected()));
} else if(mainGame->cbDBCategory->getSelected() != -1 && mainGame->cbDBDecks->getSelected() != -1) {
deckManager.LoadDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
mainGame->ebDeckname->setText(L"");
}
mainGame->HideElement(mainGame->wMainMenu);
......@@ -557,6 +562,23 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
break;
}
case irr::gui::EGET_COMBO_BOX_CHANGED: {
switch(id) {
case COMBOBOX_HP_CATEGORY: {
int catesel = mainGame->cbCategorySelect->getSelected();
if(catesel == 3) {
catesel = 2;
mainGame->cbCategorySelect->setSelected(2);
}
if(catesel >= 0) {
mainGame->RefreshDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect);
mainGame->cbDeckSelect->setSelected(0);
}
break;
}
}
break;
}
case irr::gui::EGET_CHECKBOX_CHANGED: {
switch(id) {
case CHECKBOX_HP_READY: {
......@@ -564,16 +586,18 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break;
mainGame->env->setFocus(mainGame->wHostPrepare);
if(static_cast<irr::gui::IGUICheckBox*>(caller)->isChecked()) {
if(mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadDeck(mainGame->cbDeckSelect->getItem(mainGame->cbDeckSelect->getSelected()))) {
if(mainGame->cbCategorySelect->getSelected() == -1 || mainGame->cbDeckSelect->getSelected() == -1 ||
!deckManager.LoadDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect)) {
static_cast<irr::gui::IGUICheckBox*>(caller)->setChecked(false);
break;
}
UpdateDeck();
DuelClient::SendPacketToServer(CTOS_HS_READY);
mainGame->cbCategorySelect->setEnabled(false);
mainGame->cbDeckSelect->setEnabled(false);
} else {
DuelClient::SendPacketToServer(CTOS_HS_NOTREADY);
mainGame->cbCategorySelect->setEnabled(true);
mainGame->cbDeckSelect->setEnabled(true);
}
break;
......
......@@ -50,6 +50,37 @@ public:
return MakeDir(wdir);
}
static bool Rename(const wchar_t* woldname, const wchar_t* wnewname) {
return MoveFileW(woldname, wnewname);
}
static bool Rename(const char* oldname, const char* newname) {
wchar_t woldname[1024];
wchar_t wnewname[1024];
BufferIO::DecodeUTF8(oldname, woldname);
BufferIO::DecodeUTF8(newname, wnewname);
return Rename(woldname, wnewname);
}
static bool DeleteDir(const wchar_t* wdir) {
wchar_t pdir[256];
BufferIO::CopyWStr(wdir, pdir, 256);
pdir[wcslen(wdir) + 1] = 0;
SHFILEOPSTRUCTW lpFileOp;
lpFileOp.hwnd = NULL;
lpFileOp.wFunc = FO_DELETE;
lpFileOp.pFrom = pdir;
lpFileOp.pTo = 0;
lpFileOp.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT;
return SHFileOperationW(&lpFileOp) == 0;
}
static bool DeleteDir(const char* dir) {
wchar_t wdir[1024];
BufferIO::DecodeUTF8(dir, wdir);
return DeleteDir(wdir);
}
static void TraversalDir(const wchar_t* wpath, const std::function<void(const wchar_t*, bool)>& cb) {
wchar_t findstr[1024];
wcscpy(findstr, wpath);
......@@ -59,6 +90,7 @@ public:
if(fh == INVALID_HANDLE_VALUE)
return;
do {
if(mywcsncasecmp(fdataw.cFileName, L".", 1) && mywcsncasecmp(fdataw.cFileName, L"..", 2))
cb(fdataw.cFileName, (fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
} while(FindNextFileW(fh, &fdataw));
FindClose(fh);
......@@ -111,6 +143,45 @@ public:
return MakeDir(dir);
}
static bool Rename(const wchar_t* woldname, const wchar_t* wnewname) {
char oldname[1024];
char newname[1024];
BufferIO::EncodeUTF8(woldname, oldname);
BufferIO::EncodeUTF8(wnewname, newname);
return Rename(oldname, newname);
}
static bool Rename(const char* oldname, const char* newname) {
return rename(oldname, newname) == 0;
}
static bool DeleteDir(const wchar_t* wdir) {
char dir[1024];
BufferIO::EncodeUTF8(wdir, dir);
return DeleteDir(dir);
}
static bool DeleteDir(const char* dir) {
bool success = true;
TraversalDir(dir, [dir, &success](const char *name, bool isdir) {
char full_path[256];
sprintf(full_path, "%s/%s", dir, name);
if (isdir)
{
if(!DeleteDir(full_path))
success = false;
}
else
{
if(unlink(full_path) != 0)
success = false;
}
});
if (rmdir(dir) != 0)
success = false;
return success;
}
#ifndef YGOPRO_SERVER_MODE
struct file_unit {
std::string filename;
......@@ -138,10 +209,15 @@ public:
strcat(fname, dirp->d_name);
stat(fname, &fileStat);
#ifdef YGOPRO_SERVER_MODE
cb(dirp->d_name, S_ISDIR(fileStat.st_mode));
bool is_dir = S_ISDIR(fileStat.st_mode);
if (is_dir && (strcmp(dirp->d_name, ".") == 0 || strcmp(dirp->d_name, "..") == 0) || strcmp(dirp->d_name, ".git") == 0)
continue;
cb(dirp->d_name, is_dir);
#else
funit.filename = std::string(dirp->d_name);
funit.is_dir = S_ISDIR(fileStat.st_mode);
if(funit.is_dir && (strcmp(dirp->d_name, ".") == 0 || strcmp(dirp->d_name, "..") == 0) || strcmp(dirp->d_name, ".git") == 0)
continue;
file_list.push_back(funit);
#endif
}
......
......@@ -202,6 +202,8 @@ void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wReplaySave) {
PlaySoundEffect(SOUND_QUESTION);
} else if(element == mainGame->wFTSelect) {
PlaySoundEffect(SOUND_QUESTION);
}
}
void SoundManager::PlayMusic(char* song, bool loop) {
......
......@@ -340,7 +340,7 @@
!system 1297 切洗手卡
!system 1298 辅助功能
!system 1299 加快动画效果
!system 1300 禁限卡表
!system 1300 卡组分类
!system 1301 卡组列表:
!system 1302 保存
!system 1303 另存
......@@ -367,6 +367,7 @@
!system 1325 关键字:
!system 1326 效果
!system 1327 搜索
!system 1328 管理
!system 1329 系列:
!system 1330 主卡组:
!system 1331 额外卡组:
......@@ -410,9 +411,6 @@
!system 1372 守备↑
!system 1373 名称↓
!system 1374 连接标记
!system 1375 重命名成功
!system 1376 重命名卡组
!system 1377 卡组文件:
!system 1378 使用多个关键词搜索卡片
!system 1379 启用扩展卡包调试模式
!system 1380 人机模式
......@@ -450,6 +448,28 @@
!system 1419 副卡组数量应不超过15张,当前卡组数量为%d张。
!system 1420 有额外卡组卡片存在于主卡组,可能是额外卡组数量超过15张。
!system 1421 宣言的卡不符合条件,或无法被主机识别。
!system 1422 操作无效,请重试。
!system 1450 卡包展示
!system 1451 人机卡组
!system 1452 未分类卡组
!system 1453 --------
!system 1460 卡组管理
!system 1461 新建分类
!system 1462 重命名分类
!system 1463 删除分类
!system 1464 新建卡组
!system 1465 重命名卡组
!system 1466 删除卡组
!system 1467 移动到分类
!system 1468 复制到分类
!system 1469 请输入分类名:
!system 1470 确实要删除此分类和分类下全部卡组吗?
!system 1471 请输入卡组名:
!system 1472 请选择要移动到的分类:
!system 1473 请选择要复制到的分类:
!system 1474 已存在同名分类
!system 1475 已存在同名卡组
!system 1476 删除失败
!system 1500 决斗结束。
!system 1501 录像结束。
!system 1502 连接已断开。
......
......@@ -34,6 +34,7 @@ search_regex = 0
ignore_deck_changes = 0
default_ot = 1
enable_bot_mode = 1
bot_deck_path = ./windbot/Decks
quick_animation = 1
auto_save_replay = 1
window_maximized = 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