Commit 0b1e8a8c authored by Chen Bill's avatar Chen Bill

check lastcategory, lastdeck

parent 73565591
...@@ -105,11 +105,11 @@ void DeckBuilder::Terminate() { ...@@ -105,11 +105,11 @@ void DeckBuilder::Terminate() {
mainGame->scrPackCards->setVisible(false); mainGame->scrPackCards->setVisible(false);
mainGame->scrPackCards->setPos(0); mainGame->scrPackCards->setPos(0);
int catesel = mainGame->cbDBCategory->getSelected(); int catesel = mainGame->cbDBCategory->getSelected();
if(catesel >= 0) if (catesel >= 0)
BufferIO::CopyWStr(mainGame->cbDBCategory->getItem(catesel), mainGame->gameConf.lastcategory, 64); BufferIO::CopyWideString(mainGame->cbDBCategory->getItem(catesel), mainGame->gameConf.lastcategory);
int decksel = mainGame->cbDBDecks->getSelected(); int decksel = mainGame->cbDBDecks->getSelected();
if(decksel >= 0) if (decksel >= 0)
BufferIO::CopyWStr(mainGame->cbDBDecks->getItem(decksel), mainGame->gameConf.lastdeck, 64); BufferIO::CopyWideString(mainGame->cbDBDecks->getItem(decksel), mainGame->gameConf.lastdeck);
if(exit_on_return) if(exit_on_return)
mainGame->device->closeDevice(); mainGame->device->closeDevice();
} }
......
...@@ -115,14 +115,14 @@ int main(int argc, char* argv[]) { ...@@ -115,14 +115,14 @@ int main(int argc, char* argv[]) {
++i; ++i;
if(i < wargc) { if(i < wargc) {
deckCategorySpecified = true; deckCategorySpecified = true;
wcscpy(ygo::mainGame->gameConf.lastcategory, wargv[i]); BufferIO::CopyWideString(wargv[i], ygo::mainGame->gameConf.lastcategory);
} }
} else if(!wcscmp(wargv[i], L"-d")) { // Deck } else if(!wcscmp(wargv[i], L"-d")) { // Deck
++i; ++i;
if(!deckCategorySpecified) if(!deckCategorySpecified)
ygo::mainGame->gameConf.lastcategory[0] = 0; ygo::mainGame->gameConf.lastcategory[0] = 0;
if(i + 1 < wargc) { // select deck if(i + 1 < wargc) { // select deck
wcscpy(ygo::mainGame->gameConf.lastdeck, wargv[i]); BufferIO::CopyWideString(wargv[i], ygo::mainGame->gameConf.lastdeck);
continue; continue;
} else { // open deck } else { // open deck
exit_on_return = !keep_on_return; exit_on_return = !keep_on_return;
......
...@@ -13,11 +13,13 @@ ...@@ -13,11 +13,13 @@
namespace ygo { namespace ygo {
void UpdateDeck() { void UpdateDeck() {
BufferIO::CopyWStr(mainGame->cbCategorySelect->getItem(mainGame->cbCategorySelect->getSelected()), auto category = mainGame->cbCategorySelect->getItem(mainGame->cbCategorySelect->getSelected());
mainGame->gameConf.lastcategory, 64); if (category)
BufferIO::CopyWStr(mainGame->cbDeckSelect->getItem(mainGame->cbDeckSelect->getSelected()), BufferIO::CopyWideString(category, mainGame->gameConf.lastcategory);
mainGame->gameConf.lastdeck, 64); auto deckname = mainGame->cbDeckSelect->getItem(mainGame->cbDeckSelect->getSelected());
unsigned char deckbuf[1024]; if (deckname)
BufferIO::CopyWideString(deckname, mainGame->gameConf.lastdeck);
unsigned char deckbuf[1024]{};
auto pdeck = deckbuf; auto pdeck = deckbuf;
BufferIO::WriteInt32(pdeck, deckManager.current_deck.main.size() + deckManager.current_deck.extra.size()); BufferIO::WriteInt32(pdeck, deckManager.current_deck.main.size() + deckManager.current_deck.extra.size());
BufferIO::WriteInt32(pdeck, deckManager.current_deck.side.size()); BufferIO::WriteInt32(pdeck, deckManager.current_deck.side.size());
...@@ -448,7 +450,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -448,7 +450,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
wcsncpy(deck_name, dash + 1, 256); wcsncpy(deck_name, dash + 1, 256);
for(size_t i = 0; i < mainGame->cbDBDecks->getItemCount(); ++i) { for(size_t i = 0; i < mainGame->cbDBDecks->getItemCount(); ++i) {
if(!wcscmp(mainGame->cbDBDecks->getItem(i), deck_name)) { if(!wcscmp(mainGame->cbDBDecks->getItem(i), deck_name)) {
wcscpy(mainGame->gameConf.lastdeck, deck_name); BufferIO::CopyWideString(deck_name, mainGame->gameConf.lastdeck);
mainGame->cbDBDecks->setSelected(i); mainGame->cbDBDecks->setSelected(i);
break; break;
} }
...@@ -456,14 +458,15 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -456,14 +458,15 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} else { // only deck name } else { // only deck name
for(size_t i = 0; i < mainGame->cbDBDecks->getItemCount(); ++i) { for(size_t i = 0; i < mainGame->cbDBDecks->getItemCount(); ++i) {
if(!wcscmp(mainGame->cbDBDecks->getItem(i), open_file_name)) { if(!wcscmp(mainGame->cbDBDecks->getItem(i), open_file_name)) {
wcscpy(mainGame->gameConf.lastdeck, open_file_name); BufferIO::CopyWideString(open_file_name, mainGame->gameConf.lastdeck);
mainGame->cbDBDecks->setSelected(i); mainGame->cbDBDecks->setSelected(i);
break; break;
} }
} }
} }
open_file = false; open_file = false;
} else if(mainGame->cbDBCategory->getSelected() != -1 && mainGame->cbDBDecks->getSelected() != -1) { }
else if(mainGame->cbDBCategory->getSelected() != -1 && mainGame->cbDBDecks->getSelected() != -1) {
deckManager.LoadCurrentDeck(mainGame->cbDBCategory, mainGame->cbDBDecks); deckManager.LoadCurrentDeck(mainGame->cbDBCategory, mainGame->cbDBDecks);
mainGame->ebDeckname->setText(L""); mainGame->ebDeckname->setText(L"");
} }
......
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