Commit 64003a70 authored by mercury233's avatar mercury233 Committed by GitHub

add hide player name option (#2476)

parent 27e06722
......@@ -564,20 +564,22 @@ void Game::DrawMisc() {
DrawShadowText(numFont, dInfo.strLP[0], Resize(330, 12, 631, 30), Resize(0, 1, 2, 0), 0xffffff00, 0xff000000, true, false, 0);
DrawShadowText(numFont, dInfo.strLP[1], Resize(691, 12, 992, 30), Resize(0, 1, 2, 0), 0xffffff00, 0xff000000, true, false, 0);
recti p1size = Resize(335, 31, 629, 50);
recti p2size = Resize(986, 31, 986, 50);
if(!dInfo.isTag || !dInfo.tag_player[0])
textFont->draw(dInfo.hostname, p1size, 0xffffffff, false, false, 0);
else
textFont->draw(dInfo.hostname_tag, p1size, 0xffffffff, false, false, 0);
if(!dInfo.isTag || !dInfo.tag_player[1]) {
auto cld = textFont->getDimension(dInfo.clientname);
p2size.UpperLeftCorner.X -= cld.Width;
textFont->draw(dInfo.clientname, p2size, 0xffffffff, false, false, 0);
} else {
auto cld = textFont->getDimension(dInfo.clientname_tag);
p2size.UpperLeftCorner.X -= cld.Width;
textFont->draw(dInfo.clientname_tag, p2size, 0xffffffff, false, false, 0);
if(!gameConf.hide_player_name) {
recti p1size = Resize(335, 31, 629, 50);
recti p2size = Resize(986, 31, 986, 50);
if(!dInfo.isTag || !dInfo.tag_player[0])
textFont->draw(dInfo.hostname, p1size, 0xffffffff, false, false, 0);
else
textFont->draw(dInfo.hostname_tag, p1size, 0xffffffff, false, false, 0);
if(!dInfo.isTag || !dInfo.tag_player[1]) {
auto cld = textFont->getDimension(dInfo.clientname);
p2size.UpperLeftCorner.X -= cld.Width;
textFont->draw(dInfo.clientname, p2size, 0xffffffff, false, false, 0);
} else {
auto cld = textFont->getDimension(dInfo.clientname_tag);
p2size.UpperLeftCorner.X -= cld.Width;
textFont->draw(dInfo.clientname_tag, p2size, 0xffffffff, false, false, 0);
}
}
driver->draw2DRectangle(Resize(632, 10, 688, 30), 0x00000000, 0x00000000, 0xffffffff, 0xffffffff);
driver->draw2DRectangle(Resize(632, 30, 688, 50), 0xffffffff, 0xffffffff, 0x00000000, 0x00000000);
......
......@@ -468,8 +468,11 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->stHostPrepDuelist[2]->setVisible(false);
mainGame->stHostPrepDuelist[3]->setVisible(false);
}
for(int i = 0; i < 4; ++i)
for(int i = 0; i < 4; ++i) {
mainGame->chkHostPrepReady[i]->setChecked(false);
mainGame->stHostPrepDuelist[i]->setText(L"");
mainGame->stHostPrepDuelist[i]->setToolTipText(L"");
}
mainGame->btnHostPrepReady->setVisible(true);
mainGame->btnHostPrepNotReady->setVisible(false);
mainGame->dInfo.time_limit = pkt->info.time_limit;
......@@ -478,10 +481,6 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->deckBuilder.filterList = deckManager.GetLFListContent(pkt->info.lflist);
if(mainGame->deckBuilder.filterList == nullptr)
mainGame->deckBuilder.filterList = &deckManager._lfList[0].content;
mainGame->stHostPrepDuelist[0]->setText(L"");
mainGame->stHostPrepDuelist[1]->setText(L"");
mainGame->stHostPrepDuelist[2]->setText(L"");
mainGame->stHostPrepDuelist[3]->setText(L"");
mainGame->stHostPrepOB->setText(L"");
mainGame->SetStaticText(mainGame->stHostPrepRule, 180, mainGame->guiFont, str.c_str());
mainGame->RefreshCategoryDeck(mainGame->cbCategorySelect, mainGame->cbDeckSelect);
......@@ -618,11 +617,11 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnSpectatorSwap->setVisible(true);
}
if(selftype != 1) {
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[0]->getText(), mainGame->dInfo.hostname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[1]->getText(), mainGame->dInfo.clientname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[0]->getToolTipText().c_str(), mainGame->dInfo.hostname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[1]->getToolTipText().c_str(), mainGame->dInfo.clientname, 20);
} else {
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[1]->getText(), mainGame->dInfo.hostname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[0]->getText(), mainGame->dInfo.clientname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[1]->getToolTipText().c_str(), mainGame->dInfo.hostname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[0]->getToolTipText().c_str(), mainGame->dInfo.clientname, 20);
}
} else {
if(selftype > 3) {
......@@ -632,15 +631,15 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->btnSpectatorSwap->setVisible(true);
}
if(selftype > 1 && selftype < 4) {
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[2]->getText(), mainGame->dInfo.hostname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[3]->getText(), mainGame->dInfo.hostname_tag, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[0]->getText(), mainGame->dInfo.clientname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[1]->getText(), mainGame->dInfo.clientname_tag, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[2]->getToolTipText().c_str(), mainGame->dInfo.hostname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[3]->getToolTipText().c_str(), mainGame->dInfo.hostname_tag, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[0]->getToolTipText().c_str(), mainGame->dInfo.clientname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[1]->getToolTipText().c_str(), mainGame->dInfo.clientname_tag, 20);
} else {
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[0]->getText(), mainGame->dInfo.hostname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[1]->getText(), mainGame->dInfo.hostname_tag, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[2]->getText(), mainGame->dInfo.clientname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[3]->getText(), mainGame->dInfo.clientname_tag, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[0]->getToolTipText().c_str(), mainGame->dInfo.hostname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[1]->getToolTipText().c_str(), mainGame->dInfo.hostname_tag, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[2]->getToolTipText().c_str(), mainGame->dInfo.clientname, 20);
BufferIO::CopyWStr(mainGame->stHostPrepDuelist[3]->getToolTipText().c_str(), mainGame->dInfo.clientname_tag, 20);
}
mainGame->dInfo.tag_player[0] = false;
mainGame->dInfo.tag_player[1] = false;
......@@ -802,7 +801,11 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
BufferIO::CopyWStr(pkt->name, mainGame->dInfo.clientname, 20);
}
mainGame->gMutex.lock();
mainGame->stHostPrepDuelist[pkt->pos]->setText(name);
if(mainGame->gameConf.hide_player_name)
mainGame->stHostPrepDuelist[pkt->pos]->setText(L"[********]");
else
mainGame->stHostPrepDuelist[pkt->pos]->setText(name);
mainGame->stHostPrepDuelist[pkt->pos]->setToolTipText(name);
mainGame->gMutex.unlock();
mainGame->FlashWindow();
break;
......@@ -816,9 +819,14 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->gMutex.lock();
if(state < 8) {
soundManager.PlaySoundEffect(SOUND_PLAYER_ENTER);
wchar_t* prename = (wchar_t*)mainGame->stHostPrepDuelist[pos]->getText();
mainGame->stHostPrepDuelist[state]->setText(prename);
wchar_t* prename = (wchar_t*)mainGame->stHostPrepDuelist[pos]->getToolTipText().c_str();
if(mainGame->gameConf.hide_player_name)
mainGame->stHostPrepDuelist[state]->setText(L"[********]");
else
mainGame->stHostPrepDuelist[state]->setText(prename);
mainGame->stHostPrepDuelist[state]->setToolTipText(prename);
mainGame->stHostPrepDuelist[pos]->setText(L"");
mainGame->stHostPrepDuelist[pos]->setToolTipText(L"");
mainGame->chkHostPrepReady[pos]->setChecked(false);
if(pos == 0)
BufferIO::CopyWStr(prename, mainGame->dInfo.hostname, 20);
......@@ -842,12 +850,14 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
}
} else if(state == PLAYERCHANGE_LEAVE) {
mainGame->stHostPrepDuelist[pos]->setText(L"");
mainGame->stHostPrepDuelist[pos]->setToolTipText(L"");
mainGame->chkHostPrepReady[pos]->setChecked(false);
} else if(state == PLAYERCHANGE_OBSERVE) {
watching++;
wchar_t watchbuf[32];
myswprintf(watchbuf, L"%ls%d", dataManager.GetSysString(1253), watching);
mainGame->stHostPrepDuelist[pos]->setText(L"");
mainGame->stHostPrepDuelist[pos]->setToolTipText(L"");
mainGame->chkHostPrepReady[pos]->setChecked(false);
mainGame->stHostPrepOB->setText(watchbuf);
}
......
......@@ -1920,6 +1920,13 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return true;
break;
}
case CHECKBOX_HIDE_PLAYER_NAME: {
mainGame->gameConf.hide_player_name = mainGame->chkHidePlayerName->isChecked() ? 1 : 0;
if(mainGame->gameConf.hide_player_name)
mainGame->ClearChatMsg();
return true;
break;
}
case CHECKBOX_PREFER_EXPANSION: {
mainGame->gameConf.prefer_expansion_script = mainGame->chkPreferExpansionScript->isChecked() ? 1 : 0;
return true;
......
......@@ -399,6 +399,9 @@ bool Game::Initialize() {
chkIgnore2 = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1291));
chkIgnore2->setChecked(gameConf.chkIgnore2 != 0);
posY += 30;
chkHidePlayerName = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, CHECKBOX_HIDE_PLAYER_NAME, dataManager.GetSysString(1289));
chkHidePlayerName->setChecked(gameConf.hide_player_name != 0);
posY += 30;
chkIgnoreDeckChanges = env->addCheckBox(false, rect<s32>(posX, posY, posX + 260, posY + 25), tabSystem, -1, dataManager.GetSysString(1357));
chkIgnoreDeckChanges->setChecked(gameConf.chkIgnoreDeckChanges != 0);
posY += 30;
......@@ -1320,6 +1323,7 @@ void Game::LoadConfig() {
gameConf.quick_animation = 0;
gameConf.auto_save_replay = 0;
gameConf.draw_single_chain = 0;
gameConf.hide_player_name = 0;
gameConf.prefer_expansion_script = 0;
gameConf.enable_sound = true;
gameConf.sound_volume = 0.5;
......@@ -1410,6 +1414,8 @@ void Game::LoadConfig() {
gameConf.auto_save_replay = atoi(valbuf);
} else if(!strcmp(strbuf, "draw_single_chain")) {
gameConf.draw_single_chain = atoi(valbuf);
} else if(!strcmp(strbuf, "hide_player_name")) {
gameConf.hide_player_name = atoi(valbuf);
} else if(!strcmp(strbuf, "prefer_expansion_script")) {
gameConf.prefer_expansion_script = atoi(valbuf);
} else if(!strcmp(strbuf, "window_maximized")) {
......@@ -1511,6 +1517,7 @@ void Game::SaveConfig() {
fprintf(fp, "quick_animation = %d\n", gameConf.quick_animation);
fprintf(fp, "auto_save_replay = %d\n", (chkAutoSaveReplay->isChecked() ? 1 : 0));
fprintf(fp, "draw_single_chain = %d\n", gameConf.draw_single_chain);
fprintf(fp, "hide_player_name = %d\n", gameConf.hide_player_name);
fprintf(fp, "prefer_expansion_script = %d\n", gameConf.prefer_expansion_script);
fprintf(fp, "window_maximized = %d\n", (gameConf.window_maximized ? 1 : 0));
fprintf(fp, "window_width = %d\n", gameConf.window_width);
......@@ -1644,6 +1651,8 @@ void Game::AddChatMsg(const wchar_t* msg, int player) {
chatMsg[0].clear();
chatTiming[0] = 1200;
chatType[0] = player;
if(gameConf.hide_player_name && player < 4)
player = 10;
switch(player) {
case 0: //from host
chatMsg[0].append(dInfo.hostname);
......@@ -1675,6 +1684,9 @@ void Game::AddChatMsg(const wchar_t* msg, int player) {
case 9: //error message
chatMsg[0].append(L"[Script Error]: ");
break;
case 10: //hidden name
chatMsg[0].append(L"[********]: ");
break;
default: //from watcher or unknown
if(player < 11 || player > 19)
chatMsg[0].append(L"[---]: ");
......
......@@ -52,6 +52,7 @@ struct Config {
int quick_animation;
int auto_save_replay;
int draw_single_chain;
int hide_player_name;
int prefer_expansion_script;
bool enable_sound;
bool enable_music;
......@@ -296,6 +297,7 @@ public:
irr::gui::IGUICheckBox* chkQuickAnimation;
irr::gui::IGUICheckBox* chkAutoSaveReplay;
irr::gui::IGUICheckBox* chkDrawSingleChain;
irr::gui::IGUICheckBox* chkHidePlayerName;
irr::gui::IGUIWindow* tabSystem;
irr::gui::IGUIElement* elmTabSystemLast;
irr::gui::IGUIScrollBar* scrTabSystem;
......@@ -793,6 +795,7 @@ extern Game* mainGame;
#define CHECKBOX_PREFER_EXPANSION 373
#define CHECKBOX_DRAW_SINGLE_CHAIN 374
#define CHECKBOX_LFLIST 375
#define CHECKBOX_HIDE_PLAYER_NAME 376
#define BUTTON_BIG_CARD_CLOSE 380
#define BUTTON_BIG_CARD_ZOOM_IN 381
#define BUTTON_BIG_CARD_ZOOM_OUT 382
......
......@@ -339,6 +339,7 @@
!system 1286 特大
!system 1287 只有连锁1也显示连锁动画
!system 1288 禁限卡表
!system 1289 隐藏玩家昵称
!system 1290 禁用聊天功能
!system 1291 忽略观战者发言
!system 1292 忽略时点
......
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