Commit 9b6f503d authored by nanahira's avatar nanahira

Merge branch 'develop' into server-develop

parents c8e0b04e cbf0ad54
Pipeline #37753 passed with stages
in 8 minutes and 58 seconds
......@@ -103,12 +103,16 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
else
ret = ReadDB(pDB);
sqlite3_close(pDB);
return ret;
#else
#ifdef _WIN32
auto reader = FileSystem->createAndOpenFile(wfile);
#else
auto reader = FileSystem->createAndOpenFile(file);
#endif
return LoadDB(reader);
}
bool DataManager::LoadDB(irr::io::IReadFile* reader) {
if(reader == nullptr)
return false;
spmemvfs_db_t db;
......@@ -120,14 +124,14 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
reader->drop();
(mem->data)[mem->total] = '\0';
bool ret{};
if (spmemvfs_open_db(&db, file, mem) != SQLITE_OK)
if (spmemvfs_open_db(&db, "temp.db", mem) != SQLITE_OK)
ret = Error(db.handle);
else
ret = ReadDB(db.handle);
spmemvfs_close_db(&db);
spmemvfs_env_fini();
#endif //YGOPRO_SERVER_MODE
return ret;
#endif //SERVER_ZIP_SUPPORT
}
#ifndef YGOPRO_SERVER_MODE
bool DataManager::LoadStrings(const char* file) {
......
......@@ -45,6 +45,9 @@ public:
DataManager();
bool ReadDB(sqlite3* pDB);
bool LoadDB(const wchar_t* wfile);
#if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE)
bool LoadDB(irr::io::IReadFile* reader);
#endif
#ifndef YGOPRO_SERVER_MODE
bool LoadStrings(const char* file);
bool LoadStrings(irr::io::IReadFile* reader);
......
......@@ -551,10 +551,7 @@ bool Game::Initialize() {
chkLFlist->setChecked(gameConf.use_lflist);
cbLFlist = env->addComboBox(irr::core::rect<irr::s32>(posX + 115, posY, posX + 250, posY + 25), tabSystem, COMBOBOX_LFLIST);
cbLFlist->setMaxSelectionRows(6);
for(unsigned int i = 0; i < deckManager._lfList.size(); ++i)
cbLFlist->addItem(deckManager._lfList[i].listName.c_str());
cbLFlist->setEnabled(gameConf.use_lflist);
cbLFlist->setSelected(gameConf.use_lflist ? gameConf.default_lflist : cbLFlist->getItemCount() - 1);
RefreshLFList();
posY += 30;
chkEnableSound = env->addCheckBox(gameConf.enable_sound, irr::core::rect<irr::s32>(posX, posY, posX + 120, posY + 25), tabSystem, CHECKBOX_ENABLE_SOUND, dataManager.GetSysString(1279));
chkEnableSound->setChecked(gameConf.enable_sound);
......@@ -1287,6 +1284,7 @@ std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, irr::u32 cW
}
#endif //YGOPRO_SERVER_MODE
void Game::LoadExpansions(const wchar_t* expansions_path) {
bool lflist_changed = false;
FileSystem::TraversalDir(expansions_path, [&](const wchar_t* name, bool isdir) {
if (isdir)
return;
......@@ -1297,9 +1295,10 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
return;
}
if (IsExtension(name, L".conf")) {
if(!std::wcscmp(name, L"lflist.conf"))
if(!std::wcscmp(name, L"lflist.conf")) {
deckManager.LoadLFListSingle(fpath, true);
else {
lflist_changed = true;
} else {
#ifndef YGOPRO_SERVER_MODE
char upath[1024];
BufferIO::EncodeUTF8(fpath, upath);
......@@ -1323,7 +1322,8 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
});
#if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE)
for(irr::u32 i = 0; i < DataManager::FileSystem->getFileArchiveCount(); ++i) {
auto archive = DataManager::FileSystem->getFileArchive(i)->getFileList();
auto archiveObj = DataManager::FileSystem->getFileArchive(i);
auto archive = archiveObj->getFileList();
for(irr::u32 j = 0; j < archive->getFileCount(); ++j) {
#ifdef _WIN32
const wchar_t* fname = archive->getFullFileName(j).c_str();
......@@ -1332,24 +1332,27 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
const char* uname = archive->getFullFileName(j).c_str();
BufferIO::DecodeUTF8(uname, fname);
#endif
auto createReader = [&]() {
#ifdef _WIN32
return archiveObj->createAndOpenFile(fname);
#else
return archiveObj->createAndOpenFile(uname);
#endif
};
if (IsExtension(fname, L".cdb")) {
dataManager.LoadDB(fname);
dataManager.LoadDB(createReader());
continue;
}
if (IsExtension(fname, L".conf")) {
#ifdef _WIN32
auto reader = DataManager::FileSystem->createAndOpenFile(fname);
#else
auto reader = DataManager::FileSystem->createAndOpenFile(uname);
#endif
if(!std::wcscmp(fname, L"lflist.conf"))
auto reader = createReader();
if(!std::wcscmp(fname, L"lflist.conf")) {
deckManager.LoadLFListSingle(reader, true);
else
#ifdef YGOPRO_SERVER_MODE
{}
#else
lflist_changed = true;
} else {
#ifndef YGOPRO_SERVER_MODE
dataManager.LoadStrings(reader);
#endif
}
continue;
}
#ifndef YGOPRO_SERVER_MODE
......@@ -1361,6 +1364,10 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
}
}
#endif //SERVER_ZIP_SUPPORT
#ifndef YGOPRO_SERVER_MODE
if(lflist_changed)
RefreshLFList();
#endif
}
void Game::LoadExpansionsAll() {
#ifdef SERVER_PRO2_SUPPORT
......@@ -1504,6 +1511,13 @@ void Game::RefreshLocales() {
}
}
}
void Game::RefreshLFList() {
cbLFlist->clear();
for(unsigned int i = 0; i < deckManager._lfList.size(); ++i)
cbLFlist->addItem(deckManager._lfList[i].listName.c_str());
cbLFlist->setEnabled(gameConf.use_lflist);
cbLFlist->setSelected(gameConf.use_lflist ? gameConf.default_lflist : cbLFlist->getItemCount() - 1);
}
void Game::RefreshBot() {
if(!gameConf.enable_bot_mode)
return;
......
......@@ -217,6 +217,7 @@ public:
void RefreshSingleplay();
void RefreshBot();
void RefreshLocales();
void RefreshLFList();
void DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, float* cv);
void DrawSelectionLine(irr::gui::IGUIElement* element, int width, irr::video::SColor color);
void DrawBackGround();
......
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