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

check lastcategory, lastdeck

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