Commit 23be6f4c authored by nanahira's avatar nanahira

Merge branch 'patch-server-list' into develop

parents 35359f0b 5ee546c7
Pipeline #38149 passed with stages
in 6 minutes and 20 seconds
...@@ -6,6 +6,7 @@ source .ci/asset-branch ...@@ -6,6 +6,7 @@ source .ci/asset-branch
apt update && apt -y install wget git libarchive-tools sqlite3 apt update && apt -y install wget git libarchive-tools sqlite3
git clone --depth=1 -b "$ASSET_BRANCH_NAME" https://code.moenext.com/mycard/ygopro-database git clone --depth=1 -b "$ASSET_BRANCH_NAME" https://code.moenext.com/mycard/ygopro-database
cp -rf ./ygopro-database/locales/$TARGET_LOCALE/strings.conf . cp -rf ./ygopro-database/locales/$TARGET_LOCALE/strings.conf .
cp -rf ./ygopro-database/locales/$TARGET_LOCALE/servers.conf .
rm -f cards.cdb rm -f cards.cdb
sqlite3 ./ygopro-database/locales/$TARGET_LOCALE/cards.cdb .dump | sqlite3 cards.cdb sqlite3 ./ygopro-database/locales/$TARGET_LOCALE/cards.cdb .dump | sqlite3 cards.cdb
# ygopro-images # ygopro-images
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro cards.cdb locales fonts sound textures strings.conf system.conf pack) ARCHIVE_FILES=(ygopro cards.cdb locales fonts sound textures strings.conf system.conf servers.conf pack)
if [[ -z "$TARGET_PLATFORM" ]]; then if [[ -z "$TARGET_PLATFORM" ]]; then
TARGET_PLATFORM=linux TARGET_PLATFORM=linux
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro LICENSE README.md lflist.conf strings.conf system.conf cards.cdb script textures deck single pics replay windbot bot bot.conf locales fonts pack) ARCHIVE_FILES=(ygopro LICENSE README.md lflist.conf strings.conf system.conf servers.conf cards.cdb script textures deck single pics replay windbot bot bot.conf locales fonts pack)
# TARGET_LOCALE # TARGET_LOCALE
# ARCHIVE_SUFFIX # ARCHIVE_SUFFIX
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro.app cards.cdb locales fonts sound textures strings.conf system.conf pack) ARCHIVE_FILES=(ygopro.app cards.cdb locales fonts sound textures strings.conf system.conf servers.conf pack)
if [[ -z "$TARGET_PLATFORM" ]]; then if [[ -z "$TARGET_PLATFORM" ]]; then
TARGET_PLATFORM=darwin TARGET_PLATFORM=darwin
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro.app LICENSE README.md lflist.conf strings.conf system.conf cards.cdb script textures deck single pics replay sound windbot bot bot.conf locales fonts pack) ARCHIVE_FILES=(ygopro.app LICENSE README.md lflist.conf strings.conf system.conf servers.conf cards.cdb script textures deck single pics replay sound windbot bot bot.conf locales fonts pack)
# TARGET_LOCALE # TARGET_LOCALE
# ARCHIVE_SUFFIX # ARCHIVE_SUFFIX
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro.exe vcomp140.dll LICENSE README.md lflist.conf strings.conf system.conf cards.cdb script textures deck single pics replay sound bot.conf Bot.exe WindBot locales fonts skin pack) ARCHIVE_FILES=(ygopro.exe vcomp140.dll LICENSE README.md lflist.conf strings.conf system.conf servers.conf cards.cdb script textures deck single pics replay sound bot.conf Bot.exe WindBot locales fonts skin pack)
if [[ "$TARGET_LOCALE" == "zh-CN" ]]; then if [[ "$TARGET_LOCALE" == "zh-CN" ]]; then
ARCHIVE_FILES=("${ARCHIVE_FILES[@]}" update-koishipro) ARCHIVE_FILES=("${ARCHIVE_FILES[@]}" update-koishipro)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro.exe vcomp140.dll cards.cdb locales fonts sound textures strings.conf system.conf skin pack) ARCHIVE_FILES=(ygopro.exe vcomp140.dll cards.cdb locales fonts sound textures strings.conf system.conf servers.conf skin pack)
if [[ -z "$TARGET_PLATFORM" ]]; then if [[ -z "$TARGET_PLATFORM" ]]; then
TARGET_PLATFORM=win32 TARGET_PLATFORM=win32
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
set -x set -x
set -o errexit set -o errexit
ARCHIVE_FILES=(ygopro.exe vcomp140.dll LICENSE README.md lflist.conf strings.conf system.conf cards.cdb script textures deck single pics replay sound bot.conf Bot.exe WindBot locales fonts skin pack) ARCHIVE_FILES=(ygopro.exe vcomp140.dll LICENSE README.md lflist.conf strings.conf system.conf servers.conf cards.cdb script textures deck single pics replay sound bot.conf Bot.exe WindBot locales fonts skin pack)
if [[ "$TARGET_LOCALE" == "zh-CN" && "$ARCHIVE_SUFFIX" != "zst" ]]; then if [[ "$TARGET_LOCALE" == "zh-CN" && "$ARCHIVE_SUFFIX" != "zst" ]]; then
ARCHIVE_FILES=("${ARCHIVE_FILES[@]}" update-koishipro) ARCHIVE_FILES=("${ARCHIVE_FILES[@]}" update-koishipro)
......
...@@ -313,6 +313,7 @@ assets_windows: ...@@ -313,6 +313,7 @@ assets_windows:
- cards.cdb - cards.cdb
- strings.conf - strings.conf
- bot.conf - bot.conf
- servers.conf
only: only:
- tags - tags
- master - master
......
...@@ -178,6 +178,159 @@ void DataManager::ReadStringConfLine(const char* linebuf) { ...@@ -178,6 +178,159 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
_setnameStrings[value] = strBuffer; _setnameStrings[value] = strBuffer;
} }
} }
bool DataManager::LoadServerList(const char* file) {
FILE* fp = myfopen(file, "r");
if(!fp)
return false;
char linebuf[TEXT_LINE_SIZE]{};
while(std::fgets(linebuf, sizeof linebuf, fp)) {
ReadServerConfLine(linebuf);
}
std::fclose(fp);
return true;
}
bool DataManager::LoadServerList(const wchar_t* file) {
FILE* fp = mywfopen(file, "r");
if(!fp)
return false;
char linebuf[TEXT_LINE_SIZE]{};
while(std::fgets(linebuf, sizeof linebuf, fp)) {
ReadServerConfLine(linebuf);
}
std::fclose(fp);
return true;
}
bool DataManager::LoadServerList(irr::io::IReadFile* reader) {
char ch{};
std::string linebuf;
while (reader->read(&ch, 1)) {
if (ch == '\0')
break;
linebuf.push_back(ch);
if (ch == '\n' || linebuf.size() >= TEXT_LINE_SIZE - 1) {
ReadServerConfLine(linebuf.data());
linebuf.clear();
}
}
reader->drop();
return true;
}
void DataManager::ReadServerConfLine(const char* linebuf) {
char buffer[1024];
std::strncpy(buffer, linebuf, sizeof(buffer) - 1);
buffer[sizeof(buffer) - 1] = '\0';
buffer[strcspn(buffer, "\n")] = '\0';
char* sep1 = std::strchr(buffer, '|');
if (sep1 != nullptr) {
*sep1 = '\0';
char* addrPart = sep1 + 1;
wchar_t wname[256], wip[512];
// read the server name
BufferIO::DecodeUTF8(buffer, wname);
// replace the first '|' with ':'
char* sep2 = std::strchr(addrPart, '|');
if (sep2) {
*sep2 = ':';
}
BufferIO::DecodeUTF8(addrPart, wip);
_serverStrings.emplace_back(wname, wip);
}
}
bool DataManager::LoadCorresSrvIni(const char* file) {
FILE* fp = myfopen(file, "r");
if(!fp)
return false;
char linebuf[TEXT_LINE_SIZE]{};
while(std::fgets(linebuf, sizeof linebuf, fp)) {
ReadCorresSrvIniLine(linebuf);
}
std::fclose(fp);
InsertServerList();
return true;
}
bool DataManager::LoadCorresSrvIni(const wchar_t* file) {
FILE* fp = mywfopen(file, "r");
if(!fp)
return false;
char linebuf[TEXT_LINE_SIZE]{};
while(std::fgets(linebuf, sizeof linebuf, fp)) {
ReadCorresSrvIniLine(linebuf);
}
std::fclose(fp);
InsertServerList();
return true;
}
bool DataManager::LoadCorresSrvIni(irr::io::IReadFile* reader) {
char ch{};
std::string linebuf;
while (reader->read(&ch, 1)) {
if (ch == '\0')
break;
linebuf.push_back(ch);
if (ch == '\n' || linebuf.size() >= TEXT_LINE_SIZE - 1) {
ReadCorresSrvIniLine(linebuf.data());
linebuf.clear();
}
}
reader->drop();
InsertServerList();
return true;
}
void DataManager::ReadCorresSrvIniLine(const char* linebuf) {
std::wstring name = GetINIValue(linebuf, "ServerName = ");
std::wstring host = GetINIValue(linebuf, "ServerHost = ");
std::wstring port = GetINIValue(linebuf, "ServerPort = ");
if (name != L"")
iniName = name;
if (host != L"")
iniHost = host;
if (port != L"")
iniPort = port;
}
std::wstring DataManager::GetINIValue(const char* line, const char* key) {
if (!line || !key) {
return L"";
}
const char* keyPos = strstr(line, key);
if (!keyPos) {
return L"";
}
const char* valStart = keyPos + strlen(key);
while (*valStart == ' ')
valStart++;
const char* valEnd = valStart;
while (*valEnd && *valEnd != '\n' && *valEnd != '\r')
valEnd++;
if (valStart == valEnd)
return L"";
std::string narrowStr(valStart, valEnd);
if (narrowStr.empty())
return L"";
wchar_t wbuf[1024];
BufferIO::DecodeUTF8(narrowStr.c_str(), wbuf);
return wbuf;
}
void DataManager::InsertServerList() {
if (iniName != L"" && iniHost != L"") {
std::wstring ip = iniHost;
if (iniPort != L"") {
ip += L":";
ip += iniPort;
}
_serverStrings.emplace_back(iniName, ip);
}
iniName.clear();
iniHost.clear();
iniPort.clear();
}
bool DataManager::Error(sqlite3* pDB, sqlite3_stmt* pStmt) { bool DataManager::Error(sqlite3* pDB, sqlite3_stmt* pStmt) {
std::snprintf(errmsg, sizeof errmsg, "%s", sqlite3_errmsg(pDB)); std::snprintf(errmsg, sizeof errmsg, "%s", sqlite3_errmsg(pDB));
if(pStmt) if(pStmt)
...@@ -530,5 +683,4 @@ bool DataManager::deck_sort_name(code_pointer p1, code_pointer p2) { ...@@ -530,5 +683,4 @@ bool DataManager::deck_sort_name(code_pointer p1, code_pointer p2) {
return res < 0; return res < 0;
return p1->first < p2->first; return p1->first < p2->first;
} }
} }
...@@ -50,6 +50,16 @@ public: ...@@ -50,6 +50,16 @@ public:
bool LoadStrings(const wchar_t* file); bool LoadStrings(const wchar_t* file);
bool LoadStrings(irr::io::IReadFile* reader); bool LoadStrings(irr::io::IReadFile* reader);
void ReadStringConfLine(const char* linebuf); void ReadStringConfLine(const char* linebuf);
bool LoadServerList(const char* file);
bool LoadServerList(const wchar_t* file);
bool LoadServerList(irr::io::IReadFile* reader);
void ReadServerConfLine(const char* linebuf);
bool LoadCorresSrvIni(const char* file);
bool LoadCorresSrvIni(const wchar_t* file);
bool LoadCorresSrvIni(irr::io::IReadFile* reader);
void ReadCorresSrvIniLine(const char* linebuf);
std::wstring GetINIValue(const char* line, const char* key);
void InsertServerList();
bool Error(sqlite3* pDB, sqlite3_stmt* pStmt = nullptr); bool Error(sqlite3* pDB, sqlite3_stmt* pStmt = nullptr);
code_pointer GetCodePointer(unsigned int code) const; code_pointer GetCodePointer(unsigned int code) const;
...@@ -80,6 +90,7 @@ public: ...@@ -80,6 +90,7 @@ public:
std::unordered_map<unsigned int, std::wstring> _victoryStrings; std::unordered_map<unsigned int, std::wstring> _victoryStrings;
std::unordered_map<unsigned int, std::wstring> _setnameStrings; std::unordered_map<unsigned int, std::wstring> _setnameStrings;
std::unordered_map<unsigned int, std::wstring> _sysStrings; std::unordered_map<unsigned int, std::wstring> _sysStrings;
std::vector<std::pair<std::wstring, std::wstring>> _serverStrings;
char errmsg[512]{}; char errmsg[512]{};
static unsigned char scriptBuffer[0x100000]; static unsigned char scriptBuffer[0x100000];
...@@ -104,6 +115,9 @@ private: ...@@ -104,6 +115,9 @@ private:
std::unordered_map<unsigned int, CardDataC> _datas; std::unordered_map<unsigned int, CardDataC> _datas;
std::unordered_map<unsigned int, CardString> _strings; std::unordered_map<unsigned int, CardString> _strings;
std::unordered_map<unsigned int, std::vector<uint16_t>> extra_setcode; std::unordered_map<unsigned int, std::vector<uint16_t>> extra_setcode;
std::wstring iniName;
std::wstring iniHost;
std::wstring iniPort;
}; };
extern DataManager dataManager; extern DataManager dataManager;
......
...@@ -622,6 +622,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) { ...@@ -622,6 +622,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
mainGame->cbDeckSelect->setEnabled(true); mainGame->cbDeckSelect->setEnabled(true);
mainGame->HideElement(mainGame->wCreateHost); mainGame->HideElement(mainGame->wCreateHost);
mainGame->HideElement(mainGame->wLanWindow); mainGame->HideElement(mainGame->wLanWindow);
mainGame->HideElement(mainGame->wServerList);
mainGame->HideElement(mainGame->wSinglePlay); mainGame->HideElement(mainGame->wSinglePlay);
mainGame->ShowElement(mainGame->wHostPrepare); mainGame->ShowElement(mainGame->wHostPrepare);
mainGame->ResizeChatInputWindow(); mainGame->ResizeChatInputWindow();
......
...@@ -124,6 +124,8 @@ bool Game::Initialize() { ...@@ -124,6 +124,8 @@ bool Game::Initialize() {
ErrorLog("Failed to load strings!"); ErrorLog("Failed to load strings!");
return false; return false;
} }
if(dataManager.LoadServerList(GetLocaleDir("servers.conf"))) {} else
dataManager.LoadServerList("servers.conf");
dataManager.LoadDB(L"specials/special.cdb"); dataManager.LoadDB(L"specials/special.cdb");
env = device->getGUIEnvironment(); env = device->getGUIEnvironment();
numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16); numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16);
...@@ -235,7 +237,8 @@ bool Game::Initialize() { ...@@ -235,7 +237,8 @@ bool Game::Initialize() {
editbox_list.push_back(ebNickName); editbox_list.push_back(ebNickName);
lstHostList = env->addListBox(irr::core::rect<irr::s32>(10, 60, 570, 320), wLanWindow, LISTBOX_LAN_HOST, true); lstHostList = env->addListBox(irr::core::rect<irr::s32>(10, 60, 570, 320), wLanWindow, LISTBOX_LAN_HOST, true);
lstHostList->setItemHeight(18); lstHostList->setItemHeight(18);
btnLanRefresh = env->addButton(irr::core::rect<irr::s32>(240, 325, 340, 350), wLanWindow, BUTTON_LAN_REFRESH, dataManager.GetSysString(1217)); btnLanRefresh = env->addButton(irr::core::rect<irr::s32>(150, 325, 250, 350), wLanWindow, BUTTON_LAN_REFRESH, dataManager.GetSysString(1217));
btnServerList = env->addButton(irr::core::rect<irr::s32>(280, 325, 380, 350), wLanWindow, BUTTON_SERVER_LIST, dataManager.GetSysString(1239));
env->addStaticText(dataManager.GetSysString(1221), irr::core::rect<irr::s32>(10, 360, 220, 380), false, false, wLanWindow); env->addStaticText(dataManager.GetSysString(1221), irr::core::rect<irr::s32>(10, 360, 220, 380), false, false, wLanWindow);
ebJoinHost = env->addEditBox(gameConf.lasthost, irr::core::rect<irr::s32>(110, 355, 420, 380), true, wLanWindow); ebJoinHost = env->addEditBox(gameConf.lasthost, irr::core::rect<irr::s32>(110, 355, 420, 380), true, wLanWindow);
ebJoinHost->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER); ebJoinHost->setTextAlignment(irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
...@@ -359,6 +362,15 @@ bool Game::Initialize() { ...@@ -359,6 +362,15 @@ bool Game::Initialize() {
btnHostPrepNotReady->setVisible(false); btnHostPrepNotReady->setVisible(false);
btnHostPrepStart = env->addButton(irr::core::rect<irr::s32>(230, 280, 340, 305), wHostPrepare, BUTTON_HP_START, dataManager.GetSysString(1215)); btnHostPrepStart = env->addButton(irr::core::rect<irr::s32>(230, 280, 340, 305), wHostPrepare, BUTTON_HP_START, dataManager.GetSysString(1215));
btnHostPrepCancel = env->addButton(irr::core::rect<irr::s32>(350, 280, 460, 305), wHostPrepare, BUTTON_HP_CANCEL, dataManager.GetSysString(1210)); btnHostPrepCancel = env->addButton(irr::core::rect<irr::s32>(350, 280, 460, 305), wHostPrepare, BUTTON_HP_CANCEL, dataManager.GetSysString(1210));
//server list
wServerList = env->addWindow(irr::core::rect<irr::s32>(25, 80, 325, 400), false, dataManager.GetSysString(1239));
wServerList->getCloseButton()->setVisible(false);
wServerList->setVisible(false);
wServerList->setDraggable(true);
lstServerList = env->addListBox(irr::core::rect<irr::s32>(10, 20, 290, 270), wServerList, LISTBOX_SERVER_LIST, true);
lstServerList->setItemHeight(18);
RefreshServerList();
btnServerReturn = env->addButton(irr::core::rect<irr::s32>(100, 280, 200, 310), wServerList, BUTTON_SERVER_RETURN, dataManager.GetSysString(1210));
//img //img
wCardImg = env->addStaticText(L"", irr::core::rect<irr::s32>(1, 1, 1 + CARD_IMG_WIDTH + 20, 1 + CARD_IMG_HEIGHT + 18), true, false, 0, -1, true); wCardImg = env->addStaticText(L"", irr::core::rect<irr::s32>(1, 1, 1 + CARD_IMG_WIDTH + 20, 1 + CARD_IMG_HEIGHT + 18), true, false, 0, -1, true);
wCardImg->setBackgroundColor(0xc0c0c0c0); wCardImg->setBackgroundColor(0xc0c0c0c0);
...@@ -1232,6 +1244,7 @@ std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, irr::u32 cW ...@@ -1232,6 +1244,7 @@ std::wstring Game::SetStaticText(irr::gui::IGUIStaticText* pControl, irr::u32 cW
} }
void Game::LoadExpansions(const wchar_t* expansions_path) { void Game::LoadExpansions(const wchar_t* expansions_path) {
bool lflist_changed = false; bool lflist_changed = false;
bool server_list_changed = false;
FileSystem::TraversalDir(expansions_path, [&](const wchar_t* name, bool isdir) { FileSystem::TraversalDir(expansions_path, [&](const wchar_t* name, bool isdir) {
if (isdir) if (isdir)
return; return;
...@@ -1245,11 +1258,19 @@ void Game::LoadExpansions(const wchar_t* expansions_path) { ...@@ -1245,11 +1258,19 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
if(!std::wcscmp(name, L"lflist.conf")) { if(!std::wcscmp(name, L"lflist.conf")) {
deckManager.LoadLFListSingle(fpath, true); deckManager.LoadLFListSingle(fpath, true);
lflist_changed = true; lflist_changed = true;
} else if(!std::wcscmp(name, L"servers.conf")) {
dataManager.LoadServerList(fpath);
server_list_changed = true;
} else { } else {
dataManager.LoadStrings(fpath); dataManager.LoadStrings(fpath);
} }
return; return;
} }
if (!std::wcscmp(name, L"corres_srv.ini")) {
dataManager.LoadCorresSrvIni(fpath);
server_list_changed = true;
return;
}
if (IsExtension(name, L".zip") || IsExtension(name, L".ypk")) { if (IsExtension(name, L".zip") || IsExtension(name, L".ypk")) {
#ifdef _WIN32 #ifdef _WIN32
DataManager::FileSystem->addFileArchive(fpath, true, false, irr::io::EFAT_ZIP); DataManager::FileSystem->addFileArchive(fpath, true, false, irr::io::EFAT_ZIP);
...@@ -1288,11 +1309,18 @@ void Game::LoadExpansions(const wchar_t* expansions_path) { ...@@ -1288,11 +1309,18 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
if(!std::wcscmp(fname, L"lflist.conf")) { if(!std::wcscmp(fname, L"lflist.conf")) {
deckManager.LoadLFListSingle(reader, true); deckManager.LoadLFListSingle(reader, true);
lflist_changed = true; lflist_changed = true;
} else if(!std::wcscmp(fname, L"servers.conf")) {
dataManager.LoadServerList(reader);
server_list_changed = true;
} else { } else {
dataManager.LoadStrings(reader); dataManager.LoadStrings(reader);
} }
continue; continue;
} }
if (!std::wcscmp(fname, L"corres_srv.ini")) {
dataManager.LoadCorresSrvIni(createReader());
server_list_changed = true;
}
if (!mywcsncasecmp(fname, L"pack/", 5) && IsExtension(fname, L".ydk")) { if (!mywcsncasecmp(fname, L"pack/", 5) && IsExtension(fname, L".ydk")) {
deckBuilder.expansionPacks.push_back(fname); deckBuilder.expansionPacks.push_back(fname);
continue; continue;
...@@ -1301,6 +1329,8 @@ void Game::LoadExpansions(const wchar_t* expansions_path) { ...@@ -1301,6 +1329,8 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
} }
if(lflist_changed) if(lflist_changed)
RefreshLFList(); RefreshLFList();
if(server_list_changed)
RefreshServerList();
} }
void Game::LoadExpansionsAll() { void Game::LoadExpansionsAll() {
auto list = GetExpansionsList(); auto list = GetExpansionsList();
...@@ -1496,6 +1526,13 @@ void Game::RefreshBot() { ...@@ -1496,6 +1526,13 @@ void Game::RefreshBot() {
RefreshCategoryDeck(cbBotDeckCategory, cbBotDeck); RefreshCategoryDeck(cbBotDeckCategory, cbBotDeck);
} }
} }
void Game::RefreshServerList() {
lstServerList->clear();
for (const auto& pair : dataManager._serverStrings) {
const wchar_t* key = pair.first.c_str();
lstServerList->addItem(key);
}
}
bool Game::LoadConfigFromFile(const char* file) { bool Game::LoadConfigFromFile(const char* file) {
FILE* fp = myfopen(file, "r"); FILE* fp = myfopen(file, "r");
if(!fp){ if(!fp){
...@@ -2172,6 +2209,7 @@ void Game::CloseDuelWindow() { ...@@ -2172,6 +2209,7 @@ void Game::CloseDuelWindow() {
lstLog->clear(); lstLog->clear();
logParam.clear(); logParam.clear();
lstHostList->clear(); lstHostList->clear();
lstServerList->clear();
DuelClient::hosts.clear(); DuelClient::hosts.clear();
DuelClient::hosts_srvpro.clear(); DuelClient::hosts_srvpro.clear();
ClearTextures(); ClearTextures();
......
...@@ -200,6 +200,7 @@ public: ...@@ -200,6 +200,7 @@ public:
void RefreshBot(); void RefreshBot();
void RefreshLocales(); void RefreshLocales();
void RefreshLFList(); void RefreshLFList();
void RefreshServerList();
void DrawSelectionLine(irr::video::S3DVertex* vec, bool strip, int width, float* cv); 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 DrawSelectionLine(irr::gui::IGUIElement* element, int width, irr::video::SColor color);
void DrawBackGround(); void DrawBackGround();
...@@ -693,6 +694,11 @@ public: ...@@ -693,6 +694,11 @@ public:
irr::gui::IGUIButton* btnBigCardZoomIn; irr::gui::IGUIButton* btnBigCardZoomIn;
irr::gui::IGUIButton* btnBigCardZoomOut; irr::gui::IGUIButton* btnBigCardZoomOut;
irr::gui::IGUIButton* btnBigCardClose; irr::gui::IGUIButton* btnBigCardClose;
//server list
irr::gui::IGUIButton* btnServerList;
irr::gui::IGUIWindow* wServerList;
irr::gui::IGUIListBox* lstServerList;
irr::gui::IGUIButton* btnServerReturn;
}; };
extern Game* mainGame; extern Game* mainGame;
...@@ -920,6 +926,10 @@ extern Game* mainGame; ...@@ -920,6 +926,10 @@ extern Game* mainGame;
#define BUTTON_DECK_CODE_SAVE 390 #define BUTTON_DECK_CODE_SAVE 390
#define BUTTON_DECK_CODE_CANCEL 391 #define BUTTON_DECK_CODE_CANCEL 391
#define BUTTON_SERVER_LIST 392
#define LISTBOX_SERVER_LIST 393
#define BUTTON_SERVER_RETURN 394
#define TEXTURE_DUEL 0 #define TEXTURE_DUEL 0
#define TEXTURE_DECK 1 #define TEXTURE_DECK 1
#define TEXTURE_MENU 2 #define TEXTURE_MENU 2
......
...@@ -91,6 +91,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -91,6 +91,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
} }
case BUTTON_JOIN_CANCEL: { case BUTTON_JOIN_CANCEL: {
mainGame->HideElement(mainGame->wLanWindow); mainGame->HideElement(mainGame->wLanWindow);
mainGame->HideElement(mainGame->wServerList);
mainGame->ShowElement(mainGame->wMainMenu); mainGame->ShowElement(mainGame->wMainMenu);
if(exit_on_return) if(exit_on_return)
mainGame->device->closeDevice(); mainGame->device->closeDevice();
...@@ -104,6 +105,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -104,6 +105,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->btnHostConfirm->setEnabled(true); mainGame->btnHostConfirm->setEnabled(true);
mainGame->btnHostCancel->setEnabled(true); mainGame->btnHostCancel->setEnabled(true);
mainGame->HideElement(mainGame->wLanWindow); mainGame->HideElement(mainGame->wLanWindow);
mainGame->HideElement(mainGame->wServerList);
mainGame->ShowElement(mainGame->wCreateHost); mainGame->ShowElement(mainGame->wCreateHost);
break; break;
} }
...@@ -484,6 +486,15 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -484,6 +486,15 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
prev_sel = -1; prev_sel = -1;
break; break;
} }
case BUTTON_SERVER_LIST: {
mainGame->ShowElement(mainGame->wServerList);
mainGame->PopupElement(mainGame->wServerList);
break;
}
case BUTTON_SERVER_RETURN: {
mainGame->HideElement(mainGame->wServerList);
break;
}
} }
break; break;
} }
...@@ -595,6 +606,13 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { ...@@ -595,6 +606,13 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame->cbBotDeck->setVisible(mainGame->botInfo[sel].select_deckfile); mainGame->cbBotDeck->setVisible(mainGame->botInfo[sel].select_deckfile);
break; break;
} }
case LISTBOX_SERVER_LIST: {
int sel = mainGame->lstServerList->getSelected();
auto target = sel == -1 ? L"" : dataManager._serverStrings[sel].second.c_str();
BufferIO::CopyWideString(target, mainGame->gameConf.lasthost);
mainGame->ebJoinHost->setText(target);
break;
}
} }
break; break;
} }
......
Koishi 主服|koishi.momobako.com:7210
Koishi DL 服|koishi.momobako.com:7373
Koishi 无禁服|koishi.momobako.com:2337
万宁游戏王|koishi.momobako.com:10000
决斗编年史|dc.momobako.com:2333
233 服|s1.ygo233.com:233
2332 区|s2.ygo233.com:233
2333 约战服|s1.ygo233.com:2333
...@@ -305,6 +305,7 @@ ...@@ -305,6 +305,7 @@
!system 1236 规则: !system 1236 规则:
!system 1237 每回合时间: !system 1237 每回合时间:
!system 1238 不洗切时回卡组改为回顶端 !system 1238 不洗切时回卡组改为回顶端
!system 1239 服务器列表
!system 1244 单局模式 !system 1244 单局模式
!system 1245 比赛模式 !system 1245 比赛模式
!system 1246 TAG !system 1246 TAG
......
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