Commit d537d3b9 authored by mercury233's avatar mercury233

read pack from expansion ypk

parent 113e0e8b
......@@ -1601,15 +1601,7 @@ void DeckBuilder::RefreshDeckList() {
wchar_t catepath[256];
deckManager.GetCategoryPath(catepath, lstCategories->getSelected(), lstCategories->getListItem(lstCategories->getSelected()));
lstDecks->clear();
FileSystem::TraversalDir(catepath, [lstDecks](const wchar_t* name, bool isdir) {
if(!isdir && wcsrchr(name, '.') && !mywcsncasecmp(wcsrchr(name, '.'), L".ydk", 4)) {
size_t len = wcslen(name);
wchar_t deckname[256];
wcsncpy(deckname, name, len - 4);
deckname[len - 4] = 0;
lstDecks->addItem(deckname);
}
});
mainGame->RefreshDeck(catepath, [lstDecks](const wchar_t* item) { lstDecks->addItem(item); });
}
void DeckBuilder::RefreshReadonly(int catesel) {
bool hasDeck = mainGame->cbDBDecks->getItemCount() != 0;
......@@ -1667,7 +1659,7 @@ void DeckBuilder::ShowDeckManage() {
if(isdir) {
lstCategories->addItem(name);
}
});
});
lstCategories->setSelected(prev_category);
RefreshDeckList();
RefreshReadonly(prev_category);
......
......@@ -84,6 +84,7 @@ public:
const std::unordered_map<int, int>* filterList;
std::vector<code_pointer> results;
wchar_t result_string[8];
std::vector<std::wstring> expansionPacks;
};
}
......
......@@ -272,6 +272,11 @@ bool DeckManager::LoadDeck(const wchar_t* file, bool is_packlist) {
myswprintf(localfile, L"./deck/%ls.ydk", file);
reader = OpenDeckReader(localfile);
}
if(!reader && !mywcsncasecmp(file, L"./pack", 6)) {
wchar_t zipfile[64];
myswprintf(zipfile, L"%ls", file + 2);
reader = OpenDeckReader(zipfile);
}
if(!reader)
return false;
size_t size = reader->getSize();
......@@ -279,6 +284,7 @@ bool DeckManager::LoadDeck(const wchar_t* file, bool is_packlist) {
reader->drop();
return false;
}
memset(deckBuffer, 0, sizeof(deckBuffer));
reader->read(deckBuffer, size);
reader->drop();
std::istringstream deckStream(deckBuffer);
......
......@@ -1141,6 +1141,9 @@ void Game::LoadExpansions() {
#endif
dataManager.LoadStrings(reader);
}
if(wcsrchr(fname, '.') && !mywcsncasecmp(wcsrchr(fname, '.'), L".ydk", 4)) {
deckBuilder.expansionPacks.push_back(fname);
}
}
}
}
......@@ -1182,17 +1185,22 @@ void Game::RefreshDeck(irr::gui::IGUIComboBox* cbCategory, irr::gui::IGUIComboBo
}
wchar_t catepath[256];
deckManager.GetCategoryPath(catepath, cbCategory->getSelected(), cbCategory->getText());
RefreshDeck(catepath, cbDeck);
}
void Game::RefreshDeck(const wchar_t* deckpath, irr::gui::IGUIComboBox* cbDeck) {
cbDeck->clear();
FileSystem::TraversalDir(deckpath, [cbDeck](const wchar_t* name, bool isdir) {
RefreshDeck(catepath, [cbDeck](const wchar_t* item) { cbDeck->addItem(item); });
}
void Game::RefreshDeck(const wchar_t* deckpath, const std::function<void(const wchar_t*)>& additem) {
if(!mywcsncasecmp(deckpath, L"./pack", 6)) {
for(auto pack : deckBuilder.expansionPacks) {
additem(pack.substr(5, pack.size() - 9).c_str());
}
}
FileSystem::TraversalDir(deckpath, [additem](const wchar_t* name, bool isdir) {
if(!isdir && wcsrchr(name, '.') && !mywcsncasecmp(wcsrchr(name, '.'), L".ydk", 4)) {
size_t len = wcslen(name);
wchar_t deckname[256];
wcsncpy(deckname, name, len - 4);
deckname[len - 4] = 0;
cbDeck->addItem(deckname);
additem(deckname);
}
});
}
......
......@@ -123,7 +123,7 @@ public:
void LoadExpansions();
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 RefreshDeck(const wchar_t* deckpath, const std::function<void(const wchar_t*)>& additem);
void RefreshReplay();
void RefreshSingleplay();
void RefreshBot();
......
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