Commit e2d8dfd1 authored by mercury233's avatar mercury233

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

parents 835896d6 2262dc8e
This diff is collapsed.
......@@ -21,6 +21,14 @@ public:
void ClearSearch();
void SortList();
void RefreshDeckList();
void RefreshReadonly(int catesel);
void ChangeCategory(int catesel);
void ShowDeckManage();
void ShowBigCard(int code, float zoom);
void ZoomBigCard(s32 centerx = -1, s32 centery = -1);
void CloseBigCard();
bool CardNameContains(const wchar_t *haystack, const wchar_t *needle);
bool push_main(code_pointer pointer, int seq = -1);
......@@ -62,10 +70,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;
const std::unordered_map<int, int>* filterList;
std::vector<code_pointer> results;
......
......@@ -192,6 +192,43 @@ bool DeckManager::LoadSide(Deck& deck, int* dbuf, int mainc, int sidec) {
deck = ndeck;
return true;
}
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];
wchar_t* deckname = (wchar_t*)cbDeck->getItem(cbDeck->getSelected());
if(deckname != NULL) {
GetCategoryPath(catepath, cbCategory->getSelected(), cbCategory->getText());
myswprintf(filepath, L"%ls/%ls.ydk", catepath, deckname);
BufferIO::CopyWStr(filepath, ret, 256);
}
else {
BufferIO::CopyWStr(L"", ret, 256);
}
}
bool DeckManager::LoadDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBox* cbDeck) {
wchar_t filepath[256];
GetDeckFile(filepath, cbCategory, cbDeck);
return LoadDeck(filepath);
}
FILE* DeckManager::OpenDeckFile(const wchar_t* file, const char* mode) {
#ifdef WIN32
FILE* fp = _wfopen(file, (wchar_t*)mode);
......@@ -204,11 +241,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;
wchar_t localfile[64];
myswprintf(localfile, L"./deck/%ls.ydk", file);
FILE* fp = OpenDeckFile(localfile, "r");
FILE* fp = OpenDeckFile(file, "r");
if(!fp) {
fp = OpenDeckFile(file, "r");
wchar_t localfile[64];
myswprintf(localfile, L"./deck/%ls.ydk", file);
fp = OpenDeckFile(localfile, "r");
}
if(!fp)
return false;
......@@ -234,11 +271,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;
......@@ -254,9 +289,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;
......@@ -267,4 +300,31 @@ bool DeckManager::DeleteDeck(Deck& deck, const wchar_t* name) {
return result == 0;
#endif
}
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);
}
}
......@@ -42,10 +42,16 @@ 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);
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);
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);
bool SaveDeck(Deck& deck, const wchar_t* file);
bool DeleteDeck(const wchar_t* file);
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;
......
......@@ -143,7 +143,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
cscg.info.start_lp = _wtoi(mainGame->ebStartLP->getText());
cscg.info.draw_count = _wtoi(mainGame->ebDrawCount->getText());
cscg.info.time_limit = _wtoi(mainGame->ebTimeLimit->getText());
cscg.info.lflist = mainGame->cbLFlist->getItemData(mainGame->cbLFlist->getSelected());
cscg.info.lflist = mainGame->cbHostLFlist->getItemData(mainGame->cbHostLFlist->getSelected());
cscg.info.duel_rule = mainGame->cbDuelRule->getSelected() + 1;
cscg.info.no_check_deck = mainGame->chkNoCheckDeck->isChecked();
cscg.info.no_shuffle_deck = mainGame->chkNoShuffleDeck->isChecked();
......@@ -311,6 +311,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;
......@@ -477,7 +478,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);
mainGame->HideElement(mainGame->wCreateHost);
mainGame->HideElement(mainGame->wLanWindow);
......
......@@ -1906,6 +1906,27 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true;
break;
}
case CHECKBOX_LFLIST: {
mainGame->gameConf.use_lflist = mainGame->chkLFlist->isChecked() ? 1 : 0;
mainGame->cbLFlist->setEnabled(mainGame->gameConf.use_lflist);
mainGame->cbLFlist->setSelected(mainGame->gameConf.use_lflist ? mainGame->gameConf.default_lflist : mainGame->cbLFlist->getItemCount() - 1);
mainGame->cbHostLFlist->setSelected(mainGame->gameConf.use_lflist ? mainGame->gameConf.default_lflist : mainGame->cbHostLFlist->getItemCount() - 1);
mainGame->deckBuilder.filterList = &deckManager._lfList[mainGame->cbLFlist->getSelected()].content;
return true;
break;
}
}
break;
}
case irr::gui::EGET_COMBO_BOX_CHANGED: {
switch(id) {
case COMBOBOX_LFLIST: {
mainGame->gameConf.default_lflist = mainGame->cbLFlist->getSelected();
mainGame->cbHostLFlist->setSelected(mainGame->gameConf.default_lflist);
mainGame->deckBuilder.filterList = &deckManager._lfList[mainGame->gameConf.default_lflist].content;
return true;
break;
}
}
break;
}
......
This diff is collapsed.
......@@ -21,10 +21,12 @@ 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 bot_deck_path[64];
//settings
int chkMAutoPos;
int chkSTAutoPos;
......@@ -33,6 +35,8 @@ struct Config {
int chkWaitChain;
int chkIgnore1;
int chkIgnore2;
int use_lflist;
int default_lflist;
int default_rule;
int hide_setname;
int hide_hint_button;
......@@ -93,6 +97,7 @@ struct BotInfo {
bool support_master_rule_3;
bool support_new_master_rule;
bool support_master_rule_2020;
bool select_deckfile;
};
struct FadingUnit {
......@@ -116,7 +121,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();
......@@ -293,6 +300,8 @@ public:
irr::gui::IGUICheckBox* chkAutoSearch;
irr::gui::IGUICheckBox* chkMultiKeywords;
irr::gui::IGUICheckBox* chkPreferExpansionScript;
irr::gui::IGUICheckBox* chkLFlist;
irr::gui::IGUIComboBox* cbLFlist;
irr::gui::IGUICheckBox* chkEnableSound;
irr::gui::IGUICheckBox* chkEnableMusic;
irr::gui::IGUIScrollBar* scrSoundVolume;
......@@ -323,7 +332,7 @@ public:
irr::gui::IGUIButton* btnCreateHost;
//create host
irr::gui::IGUIWindow* wCreateHost;
irr::gui::IGUIComboBox* cbLFlist;
irr::gui::IGUIComboBox* cbHostLFlist;
irr::gui::IGUIComboBox* cbMatchMode;
irr::gui::IGUIComboBox* cbRule;
irr::gui::IGUIEditBox* ebTimeLimit;
......@@ -344,6 +353,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;
......@@ -366,6 +376,8 @@ public:
irr::gui::IGUIStaticText* stBotInfo;
irr::gui::IGUIButton* btnStartBot;
irr::gui::IGUIButton* btnBotCancel;
irr::gui::IGUIComboBox* cbBotDeckCategory;
irr::gui::IGUIComboBox* cbBotDeck;
irr::gui::IGUIComboBox* cbBotRule;
irr::gui::IGUICheckBox* chkBotHand;
irr::gui::IGUICheckBox* chkBotNoCheckDeck;
......@@ -467,8 +479,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;
......@@ -480,7 +493,7 @@ public:
irr::gui::IGUIButton* btnSideSort;
irr::gui::IGUIButton* btnSideReload;
irr::gui::IGUIEditBox* ebDeckname;
irr::gui::IGUIStaticText* stBanlist;
irr::gui::IGUIStaticText* stDBCategory;
irr::gui::IGUIStaticText* stDeck;
irr::gui::IGUIStaticText* stCategory;
irr::gui::IGUIStaticText* stLimit;
......@@ -491,6 +504,25 @@ 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;
//filter
irr::gui::IGUIStaticText* wFilter;
irr::gui::IGUIScrollBar* scrFilter;
......@@ -595,6 +627,7 @@ extern Game* mainGame;
#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
......@@ -614,6 +647,7 @@ extern Game* mainGame;
#define LISTBOX_BOT_LIST 153
#define BUTTON_BOT_START 154
#define COMBOBOX_BOT_RULE 155
#define COMBOBOX_BOT_DECKCATEGORY 156
#define EDITBOX_CHAT 199
#define BUTTON_MSG_OK 200
......@@ -692,7 +726,8 @@ extern Game* mainGame;
#define BUTTON_SURRENDER_YES 297
#define BUTTON_SURRENDER_NO 298
#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
......@@ -717,6 +752,21 @@ extern Game* mainGame;
#define BUTTON_MARKERS_OK 323
#define COMBOBOX_SORTTYPE 324
#define EDITBOX_INPUTS 325
#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 BUTTON_CLEAR_LOG 350
#define LISTBOX_LOG 351
#define SCROLL_CARDTEXT 352
......@@ -735,6 +785,7 @@ extern Game* mainGame;
#define CHECKBOX_MULTI_KEYWORDS 372
#define CHECKBOX_PREFER_EXPANSION 373
#define CHECKBOX_DRAW_SINGLE_CHAIN 374
#define CHECKBOX_LFLIST 375
#define BUTTON_BIG_CARD_CLOSE 380
#define BUTTON_BIG_CARD_ZOOM_IN 381
#define BUTTON_BIG_CARD_ZOOM_OUT 382
......
......@@ -111,6 +111,7 @@ int main(int argc, char* argv[]) {
keep_on_return = true;
} else if(!wcscmp(wargv[i], L"-d")) { // Deck
++i;
ygo::mainGame->gameConf.lastcategory[0] = 0;
if(i + 1 < wargc) { // select deck
wcscpy(ygo::mainGame->gameConf.lastdeck, wargv[i]);
continue;
......
......@@ -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];
......@@ -143,6 +145,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;
......@@ -164,17 +167,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;
}
......@@ -293,9 +298,17 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
si.cb = sizeof(si);
ZeroMemory(&pi, sizeof(pi));
wchar_t cmd[MAX_PATH];
wchar_t arg1[512];
if(mainGame->botInfo[sel].select_deckfile) {
wchar_t botdeck[256];
deckManager.GetDeckFile(botdeck, mainGame->cbBotDeckCategory, mainGame->cbBotDeck);
myswprintf(arg1, L"%ls DeckFile='%ls'", mainGame->botInfo[sel].command, botdeck);
}
else
myswprintf(arg1, L"%ls", mainGame->botInfo[sel].command);
int flag = 0;
flag += (mainGame->chkBotHand->isChecked() ? 0x1 : 0);
myswprintf(cmd, L"Bot.exe \"%ls\" %d %d", mainGame->botInfo[sel].command, flag, mainGame->gameConf.serverport);
myswprintf(cmd, L"Bot.exe \"%ls\" %d %d", arg1, flag, mainGame->gameConf.serverport);
if(!CreateProcessW(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
NetServer::StopServer();
......@@ -304,8 +317,16 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
#else
if(fork() == 0) {
usleep(100000);
wchar_t warg1[512];
if(mainGame->botInfo[sel].select_deckfile) {
wchar_t botdeck[256];
deckManager.GetDeckFile(botdeck, mainGame->cbBotDeckCategory, mainGame->cbBotDeck);
myswprintf(warg1, L"%ls DeckFile='%ls'", mainGame->botInfo[sel].command, botdeck);
}
else
myswprintf(warg1, L"%ls", mainGame->botInfo[sel].command);
char arg1[512];
BufferIO::EncodeUTF8(mainGame->botInfo[sel].command, arg1);
BufferIO::EncodeUTF8(warg1, arg1);
int flag = 0;
flag += (mainGame->chkBotHand->isChecked() ? 0x1 : 0);
char arg2[8];
......@@ -340,7 +361,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'\\');
......@@ -353,18 +374,23 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wcsncpy(deck_name, dash + 1, dot - dash - 1);
deck_name[dot - dash - 1] = L'\0';
mainGame->ebDeckname->setText(deck_name);
mainGame->cbDBCategory->setSelected(-1);
mainGame->cbDBDecks->setSelected(-1);
mainGame->btnManageDeck->setEnabled(false);
mainGame->cbDBCategory->setEnabled(false);
mainGame->cbDBDecks->setEnabled(false);
} else {
for(size_t i = 0; i < mainGame->cbDBDecks->getItemCount(); ++i) {
if(!wcscmp(mainGame->cbDBDecks->getItem(i), open_file_name)) {
wcscpy(mainGame->gameConf.lastdeck, open_file_name);
mainGame->cbDBDecks->setSelected(i);
break;
}
}
}
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);
......@@ -514,6 +540,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
if(sel == -1)
break;
mainGame->SetStaticText(mainGame->stBotInfo, 200, mainGame->guiFont, mainGame->botInfo[sel].desc);
mainGame->cbBotDeckCategory->setVisible(mainGame->botInfo[sel].select_deckfile);
mainGame->cbBotDeck->setVisible(mainGame->botInfo[sel].select_deckfile);
break;
}
}
......@@ -526,16 +554,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;
......@@ -549,6 +579,30 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->RefreshBot();
break;
}
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;
}
case COMBOBOX_BOT_DECKCATEGORY: {
int catesel = mainGame->cbBotDeckCategory->getSelected();
if(catesel == 3) {
catesel = 2;
mainGame->cbBotDeckCategory->setSelected(2);
}
if(catesel >= 0) {
mainGame->RefreshDeck(mainGame->cbBotDeckCategory, mainGame->cbBotDeck);
mainGame->cbBotDeck->setSelected(0);
}
break;
}
}
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,7 +90,8 @@ public:
if(fh == INVALID_HANDLE_VALUE)
return;
do {
cb(fdataw.cFileName, (fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
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;
}
struct file_unit {
std::string filename;
bool is_dir;
......@@ -132,6 +203,8 @@ public:
stat(fname, &fileStat);
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))
continue;
file_list.push_back(funit);
}
closedir(dir);
......
......@@ -288,7 +288,8 @@ void SingleDuel::UpdateDeck(DuelPlayer* dp, void* pdata, unsigned int len) {
int mainc = BufferIO::ReadInt32(deckbuf);
int sidec = BufferIO::ReadInt32(deckbuf);
// verify data
if((unsigned)mainc + (unsigned)sidec > (len - 8) / 4) {
const unsigned int possibleMaxLength = (len - 8) / 4;
if((unsigned)mainc > possibleMaxLength || (unsigned)sidec > possibleMaxLength || (unsigned)mainc + (unsigned)sidec > possibleMaxLength) {
STOC_ErrorMsg scem;
scem.msg = ERRMSG_DECKERROR;
scem.code = 0;
......
......@@ -33,9 +33,9 @@ public:
void WaitforResponse(int playerid);
void RefreshMzone(int player, int flag = 0x881fff, int use_cache = 1);
void RefreshSzone(int player, int flag = 0x681fff, int use_cache = 1);
void RefreshHand(int player, int flag = 0x781fff, int use_cache = 1);
void RefreshHand(int player, int flag = 0x681fff, int use_cache = 1);
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0xe81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static int MessageHandler(long fduel, int type);
......
......@@ -263,7 +263,8 @@ void TagDuel::UpdateDeck(DuelPlayer* dp, void* pdata, unsigned int len) {
int mainc = BufferIO::ReadInt32(deckbuf);
int sidec = BufferIO::ReadInt32(deckbuf);
// verify data
if((unsigned)mainc + (unsigned)sidec > (len - 8) / 4) {
const unsigned int possibleMaxLength = (len - 8) / 4;
if((unsigned)mainc > possibleMaxLength || (unsigned)sidec > possibleMaxLength || (unsigned)mainc + (unsigned)sidec > possibleMaxLength) {
STOC_ErrorMsg scem;
scem.msg = ERRMSG_DECKERROR;
scem.code = 0;
......
......@@ -33,9 +33,9 @@ public:
void WaitforResponse(int playerid);
void RefreshMzone(int player, int flag = 0x881fff, int use_cache = 1);
void RefreshSzone(int player, int flag = 0x681fff, int use_cache = 1);
void RefreshHand(int player, int flag = 0x781fff, int use_cache = 1);
void RefreshHand(int player, int flag = 0x681fff, int use_cache = 1);
void RefreshGrave(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0x81fff, int use_cache = 1);
void RefreshExtra(int player, int flag = 0xe81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static int MessageHandler(long fduel, int type);
......
This diff is collapsed.
Subproject commit 9fd3931ae631015ca02013314f3ae07bdd8f2208
Subproject commit 0ce152512c02c7a3289ae81610d284143860f07b
Subproject commit a12f29bf382defb21043e2b8de967f867477192b
Subproject commit 835acda16b96904753359ad96b795de0d6534e21
......@@ -336,6 +336,7 @@
!system 1285
!system 1286 特大
!system 1287 只有连锁1也显示连锁动画
!system 1288 禁限卡表
!system 1290 禁用聊天功能
!system 1291 忽略观战者发言
!system 1292 忽略时点
......@@ -346,7 +347,7 @@
!system 1297 洗切手卡
!system 1298 辅助功能
!system 1299 加快动画效果
!system 1300 禁限卡表
!system 1300 卡组分类
!system 1301 卡组列表:
!system 1302 保存
!system 1303 另存
......@@ -373,6 +374,7 @@
!system 1325 关键字:
!system 1326 效果
!system 1327 搜索
!system 1328 管理
!system 1329 系列:
!system 1330 主卡组:
!system 1331 额外卡组:
......@@ -398,7 +400,7 @@
!system 1351 投降
!system 1352 主要信息:
!system 1353 播放起始于回合:
!system 1356 是否要放弃对卡组的修改
!system 1356 此操作将放弃对当前卡组的修改,是否继续
!system 1357 不提示保留对卡组的修改
!system 1358 键入关键字后自动进行搜索
!system 1359 是否确定投降?
......@@ -461,6 +463,27 @@
!system 1441 放大
!system 1442 缩小
!system 1443 原始尺寸
!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 连接已断开。
......@@ -603,6 +626,7 @@
!counter 0x58 指示物(祢须三破鸣比)
!counter 0x59 落魂指示物
!counter 0x5a 指示物(岩战之试炼)
!counter 0x5b 指示物(北极天熊北斗星)
#setnames, using tab for comment
!setname 0x1 正义盟军 AOJ
!setname 0x2 次世代 ジェネクス
......@@ -1063,3 +1087,6 @@
!setname 0x15e 降阶魔法 RDM
!setname 0x15f 岩战 War Rock
!setname 0x160 源质兽 Materiactor
!setname 0x161 溟界
!setname 0x162 七音服 ドレミコード
!setname 0x163 北极天熊 ベアルクティ
......@@ -6,6 +6,7 @@ antialias = 2
errorlog = 3
nickname = Player
gamename = Game
lastcategory = 未分类卡组
lastdeck = new
textfont = c:/windows/fonts/simsun.ttc 14
numfont = c:/windows/fonts/arialbd.ttf
......@@ -19,6 +20,8 @@ autochain = 0
waitchain = 0
mute_opponent = 0
mute_spectators = 0
use_lflist = 1
default_lflist = 0
default_rule = 0
hide_setname = 0
hide_hint_button = 0
......@@ -33,6 +36,7 @@ search_multiple_keywords = 1
ignore_deck_changes = 0
default_ot = 1
enable_bot_mode = 0
bot_deck_path = ./botdeck
quick_animation = 0
auto_save_replay = 0
draw_single_chain = 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