Commit 76b7d405 authored by VanillaSalt's avatar VanillaSalt

delete deck

parent a718bfe0
......@@ -43,6 +43,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
switch(event.EventType) {
case irr::EET_GUI_EVENT: {
s32 id = event.GUIEvent.Caller->getID();
if(mainGame->wCategories->isVisible() && id != BUTTON_CATEGORY_OK)
break;
if(mainGame->wQuery->isVisible() && id != BUTTON_YES && id != BUTTON_NO)
break;
switch(event.GUIEvent.EventType) {
case irr::gui::EGET_BUTTON_CLICKED: {
switch(id) {
......@@ -92,6 +96,15 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
break;
}
case BUTTON_DELETE_DECK: {
if(mainGame->cbDBDecks->getSelected() == -1)
break;
mainGame->gMutex.Lock();
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetSysString(1337));
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
break;
}
case BUTTON_DBEXIT: {
mainGame->is_building = false;
mainGame->wDeckEdit->setVisible(false);
......@@ -164,6 +177,26 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
DuelClient::SendBufferToServer(CTOS_UPDATE_DECK, deckbuf, pdeck - deckbuf);
break;
}
case BUTTON_YES: {
mainGame->HideElement(mainGame->wQuery);
int sel = mainGame->cbDBDecks->getSelected();
if(deckManager.DeleteDeck(deckManager.current_deck, mainGame->cbDBDecks->getItem(sel))) {
mainGame->cbDBDecks->removeItem(sel);
int count = mainGame->cbDBDecks->getItemCount();
if(sel >= count)
sel = count - 1;
mainGame->cbDBDecks->setSelected(sel);
if(sel != -1)
deckManager.LoadDeck(mainGame->cbDBDecks->getItem(sel));
mainGame->stACMessage->setText(dataManager.GetSysString(1338));
mainGame->PopupElement(mainGame->wACMessage, 20);
}
break;
}
case BUTTON_NO: {
mainGame->HideElement(mainGame->wQuery);
break;
}
}
break;
}
......@@ -299,7 +332,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
case irr::EET_MOUSE_INPUT_EVENT: {
switch(event.MouseInput.Event) {
case irr::EMIE_LMOUSE_PRESSED_DOWN: {
if(mainGame->wCategories->isVisible())
if(mainGame->wCategories->isVisible() || mainGame->wQuery->isVisible())
break;
if(hovered_pos == 0 || hovered_seq == -1)
break;
......@@ -435,7 +468,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
break;
}
if(mainGame->wCategories->isVisible())
if(mainGame->wCategories->isVisible() || mainGame->wQuery->isVisible())
break;
if(hovered_pos == 0 || hovered_seq == -1)
break;
......
......@@ -232,4 +232,17 @@ 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);
#ifdef WIN32
BOOL result = DeleteFileW(file);
return !!result;
#else
char filefn[256];
BufferIO::EncodeUTF8(file, filefn);
int result = unlink(filefn);
return result == 0;
#endif
}
}
......@@ -42,6 +42,7 @@ public:
bool LoadSide(Deck& deck, int* dbuf, int mainc, int sidec);
bool LoadDeck(const wchar_t* file);
bool SaveDeck(Deck& deck, const wchar_t* name);
bool DeleteDeck(Deck& deck, const wchar_t* name);
};
extern DeckManager deckManager;
......
......@@ -847,7 +847,8 @@ void Game::HideElement(irr::gui::IGUIElement * win, bool set_action) {
}
void Game::PopupElement(irr::gui::IGUIElement * element, int hideframe) {
element->getParent()->bringToFront(element);
dField.panel = element;
if(!mainGame->is_building)
dField.panel = element;
env->setFocus(element);
if(!hideframe)
ShowElement(element);
......
......@@ -388,7 +388,8 @@ bool Game::Initialize() {
cbDBDecks = env->addComboBox(rect<s32>(80, 35, 220, 60), wDeckEdit, COMBOBOX_DBDECKS);
for(unsigned int i = 0; i < deckManager._lfList.size(); ++i)
cbDBLFList->addItem(deckManager._lfList[i].listName);
btnSaveDeck = env->addButton(rect<s32>(225, 35, 290, 60), wDeckEdit, BUTTON_SAVE_DECK, dataManager.GetSysString(1302));
btnSaveDeck = env->addButton(rect<s32>(225, 5, 290, 30), wDeckEdit, BUTTON_SAVE_DECK, dataManager.GetSysString(1302));
btnDeleteDeck = env->addButton(rect<s32>(225, 35, 290, 60), wDeckEdit, BUTTON_DELETE_DECK, dataManager.GetSysString(1308));
ebDeckname = env->addEditBox(L"", rect<s32>(80, 65, 220, 90), true, wDeckEdit, -1);
ebDeckname->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
btnSaveDeckAs = env->addButton(rect<s32>(225, 65, 290, 90), wDeckEdit, BUTTON_SAVE_DECK_AS, dataManager.GetSysString(1303));
......
......@@ -345,6 +345,7 @@ public:
irr::gui::IGUIButton* btnSortDeck;
irr::gui::IGUIButton* btnShuffleDeck;
irr::gui::IGUIButton* btnSaveDeck;
irr::gui::IGUIButton* btnDeleteDeck;
irr::gui::IGUIButton* btnSaveDeckAs;
irr::gui::IGUIButton* btnDBExit;
irr::gui::IGUIButton* btnSideOK;
......@@ -482,22 +483,23 @@ extern Game* mainGame;
#define BUTTON_CLEAR_DECK 303
#define BUTTON_SAVE_DECK 304
#define BUTTON_SAVE_DECK_AS 305
#define BUTTON_DBEXIT 306
#define BUTTON_SORT_DECK 307
#define BUTTON_SIDE_OK 308
#define BUTTON_SHUFFLE_DECK 309
#define COMBOBOX_MAINTYPE 310
#define BUTTON_EFFECT_FILTER 311
#define BUTTON_START_FILTER 312
#define BUTTON_DELETE_DECK 306
#define BUTTON_DBEXIT 307
#define BUTTON_SORT_DECK 308
#define BUTTON_SIDE_OK 309
#define BUTTON_SHUFFLE_DECK 310
#define COMBOBOX_MAINTYPE 311
#define BUTTON_EFFECT_FILTER 312
#define BUTTON_START_FILTER 313
#define SCROLL_FILTER 314
#define EDITBOX_KEYWORD 315
#define BUTTON_CLEAR_FILTER 316
#define BUTTON_REPLAY_START 320
#define BUTTON_REPLAY_PAUSE 321
#define BUTTON_REPLAY_STEP 322
#define BUTTON_REPLAY_EXIT 323
#define BUTTON_REPLAY_SWAP 324
#define BUTTON_REPLAY_UNDO 325
#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 LISTBOX_SINGLEPLAY_LIST 350
......
......@@ -287,6 +287,7 @@
!system 1305 排序
!system 1306 退出编辑
!system 1307 打乱
!system 1308 删除
!system 1310 (无)
!system 1311 种类:
!system 1312 怪兽
......@@ -313,6 +314,8 @@
!system 1334 副卡组更换完成
!system 1335 保存成功
!system 1336 刻度:
!system 1337 是否删除?
!system 1338 删除成功
!system 1340 是否保存录像?
!system 1341 保存
!system 1342 录像文件:
......
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