Commit 5d3a7910 authored by xiaoye's avatar xiaoye

update ServerList

parent 8c8a4b67
......@@ -235,7 +235,8 @@ bool Game::Initialize() {
editbox_list.push_back(ebNickName);
lstHostList = env->addListBox(irr::core::rect<irr::s32>(10, 60, 570, 320), wLanWindow, LISTBOX_LAN_HOST, true);
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>(170, 325, 270, 350), wLanWindow, BUTTON_LAN_REFRESH, dataManager.GetSysString(1217));
btnServerList = env->addButton(irr::core::rect<irr::s32>(310, 325, 410, 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);
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);
......@@ -359,6 +360,16 @@ bool Game::Initialize() {
btnHostPrepNotReady->setVisible(false);
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));
//server list
wServerList = env->addWindow(irr::core::rect<irr::s32>(10, 80, 380, 400), false, dataManager.GetSysString(1428));
wServerList->getCloseButton()->setVisible(false);
wServerList->setVisible(false);
wServerList->setDraggable(false);
lstServerList = env->addListBox(irr::core::rect<irr::s32>(0, 20, 370, 270), wServerList, LISTBOX_SERVER_LIST, true);
lstServerList->setItemHeight(18);
AddServerList(lstServerList);
btnServerSelected = env->addButton(irr::core::rect<irr::s32>(10, 280, 100, 310), wServerList, BUTTON_SERVER_SELECTED, dataManager.GetSysString(1211));
btnServerCancel = env->addButton(irr::core::rect<irr::s32>(280, 280, 370, 310), wServerList, BUTTON_SERVER_CANCEL, dataManager.GetSysString(1212));
//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->setBackgroundColor(0xc0c0c0c0);
......@@ -2171,6 +2182,7 @@ void Game::CloseDuelWindow() {
lstLog->clear();
logParam.clear();
lstHostList->clear();
lstServerList->clear();
DuelClient::hosts.clear();
DuelClient::hosts_srvpro.clear();
ClearTextures();
......@@ -2644,5 +2656,33 @@ void Game::InjectEnvToRegistry(intptr_t pduel) {
}
#endif
}
void Game::AddServerList(irr::gui::IGUIListBox* i) {
i->addItem(L"清空");
serverIP.push_back(L"");
FILE* fp = myfopen("server.conf", "r");
if(!fp){
return ;
}
char buffer[256];
while (fgets(buffer, sizeof(buffer), fp) != NULL) {
buffer[strcspn(buffer, "\n")] = '\0';
char *separator = strchr(buffer, '|');
if (separator != NULL) {
*separator = '\0';
wchar_t wname[256];
wchar_t wip[256];
if (mbstowcs(wname, buffer, 256) != (size_t)-1 && mbstowcs(wip, separator + 1, 256) != (size_t)-1) {
i->addItem(wname);
wchar_t* ip = new wchar_t[256];
wcscpy(ip, wip);
serverIP.push_back(ip);
}
}
}
fclose(fp);
}
}
......@@ -274,6 +274,7 @@ public:
void takeScreenshot();
void SetCursor(irr::gui::ECURSOR_ICON icon);
void InjectEnvToRegistry(intptr_t pduel);
void AddServerList(irr::gui::IGUIListBox* i);
template<typename T>
static void DrawShadowText(irr::gui::CGUITTFont* font, const T& text, const irr::core::rect<irr::s32>& position, const irr::core::rect<irr::s32>& padding,
irr::video::SColor color = 0xffffffff, irr::video::SColor shadowcolor = 0xff000000, bool hcenter = false, bool vcenter = false, const irr::core::rect<irr::s32>* clip = nullptr);
......@@ -692,6 +693,13 @@ public:
irr::gui::IGUIButton* btnBigCardZoomIn;
irr::gui::IGUIButton* btnBigCardZoomOut;
irr::gui::IGUIButton* btnBigCardClose;
//server list
irr::gui::IGUIButton* btnServerList;
irr::gui::IGUIWindow* wServerList;
irr::gui::IGUIListBox* lstServerList;
irr::gui::IGUIButton* btnServerSelected;
irr::gui::IGUIButton* btnServerCancel;
std::vector<const wchar_t*> serverIP;
};
extern Game* mainGame;
......@@ -919,6 +927,11 @@ extern Game* mainGame;
#define BUTTON_DECK_CODE_SAVE 390
#define BUTTON_DECK_CODE_CANCEL 391
#define BUTTON_SERVER_LIST 392
#define LISTBOX_SERVER_LIST 393
#define BUTTON_SERVER_SELECTED 394
#define BUTTON_SERVER_CANCEL 395
#define TEXTURE_DUEL 0
#define TEXTURE_DECK 1
#define TEXTURE_MENU 2
......
......@@ -484,6 +484,24 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
prev_sel = -1;
break;
}
case BUTTON_SERVER_LIST: {
mainGame->ShowElement(mainGame->wServerList);
mainGame->PopupElement(mainGame->wServerList);
break;
}
case BUTTON_SERVER_SELECTED: {
int sel = mainGame->lstServerList->getSelected();
wcscpy(mainGame->gameConf.lasthost, mainGame->serverIP[sel]);
wchar_t buf[256];
myswprintf(buf, L"%s", mainGame->gameConf.lasthost);
mainGame->ebJoinHost->setText(buf);
mainGame->HideElement(mainGame->wServerList);
break;
}
case BUTTON_SERVER_CANCEL: {
mainGame->HideElement(mainGame->wServerList);
break;
}
}
break;
}
......
超先行服|mygo.superpre.pro:888
超先行2服|mygo2.superpre.pro:888
233服|s1.ygo233.com:233
7210服|koishi.momobako.com:7210
决斗编年史|duels.link:2333
222Diy服|finale.momobako.com:222
\ No newline at end of file
......@@ -305,6 +305,7 @@
!system 1236 规则:
!system 1237 每回合时间:
!system 1238 不洗切时回卡组改为回顶端
!system 1239 服务器列表
!system 1244 单局模式
!system 1245 比赛模式
!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