From 95684834ecb45261da1640a4ad8143653698b192 Mon Sep 17 00:00:00 2001 From: Fedja Beader Date: Thu, 16 May 2024 13:14:34 +0000 Subject: Refactor loadFromLogFile calls into ChatTab contructor This has the side effect that now #Debug history is also loaded. **** mana/plus!84 --- src/game.cpp | 2 -- src/gui/widgets/tabs/chat/battletab.cpp | 2 -- src/gui/widgets/tabs/chat/chattab.cpp | 3 +++ src/gui/windows/chatwindow.cpp | 4 ---- src/net/ea/partyrecv.cpp | 2 -- src/net/eathena/clanrecv.cpp | 2 -- src/net/eathena/guildrecv.cpp | 2 -- src/net/tmwa/guildmanager.cpp | 2 -- 8 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 4e3c399cd..69daa254d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -293,8 +293,6 @@ static void createGuiWindows() localChatTab = new ChatTab(chatWindow, _("General"), GENERAL_CHANNEL, "#General", ChatTabType::INPUT); localChatTab->setAllowHighlight(false); - if (config.getBoolValue("showChatHistory")) - localChatTab->loadFromLogFile("#General"); // TRANSLATORS: chat tab header debugChatTab = new ChatTab(chatWindow, _("Debug"), "", diff --git a/src/gui/widgets/tabs/chat/battletab.cpp b/src/gui/widgets/tabs/chat/battletab.cpp index 5dd5ff987..9fa18e945 100644 --- a/src/gui/widgets/tabs/chat/battletab.cpp +++ b/src/gui/widgets/tabs/chat/battletab.cpp @@ -36,8 +36,6 @@ BattleTab::BattleTab(const Widget2 *const widget) : ChatTab(widget, _("Battle"), "", "#Battle", ChatTabType::BATTLE) { setTabColors(ThemeColorId::BATTLE_CHAT_TAB); - if (config.getBoolValue("showChatHistory")) - loadFromLogFile("#Battle"); } BattleTab::~BattleTab() diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp index ec9042694..9809287d2 100644 --- a/src/gui/widgets/tabs/chat/chattab.cpp +++ b/src/gui/widgets/tabs/chat/chattab.cpp @@ -97,6 +97,9 @@ ChatTab::ChatTab(const Widget2 *const widget, if (chatWindow != nullptr) chatWindow->addTab(this); mTextOutput->updateSize(true); + + if (config.getBoolValue("showChatHistory")) + loadFromLogFile(logName); } ChatTab::~ChatTab() diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index a3b777655..15363883f 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1246,8 +1246,6 @@ WhisperTab *ChatWindow::addWhisperTab(const std::string &caption, if ((gui != nullptr) && !playerRelations.isGoodName(nick)) ret->setLabelFont(gui->getSecureFont()); mWhispers[tempNick] = ret; - if (config.getBoolValue("showChatHistory")) - ret->loadFromLogFile(nick); } if (switchTo) @@ -1330,8 +1328,6 @@ ChatTab *ChatWindow::addChannelTab(const std::string &name, ret = new ChannelTab(this, name); mChannels[tempName] = ret; ret->setAllowHighlight(false); - if (config.getBoolValue("showChatHistory")) - ret->loadFromLogFile(name); } if (switchTo) diff --git a/src/net/ea/partyrecv.cpp b/src/net/ea/partyrecv.cpp index 370cfed9c..53cb0227e 100644 --- a/src/net/ea/partyrecv.cpp +++ b/src/net/ea/partyrecv.cpp @@ -226,8 +226,6 @@ void PartyRecv::processPartyUpdateCoords(Net::MessageIn &msg) void PartyRecv::createTab() { partyTab = new PartyTab(chatWindow); - if (config.getBoolValue("showChatHistory")) - partyTab->loadFromLogFile("#Party"); } } // namespace Ea diff --git a/src/net/eathena/clanrecv.cpp b/src/net/eathena/clanrecv.cpp index 9ecb860a9..c686796dd 100644 --- a/src/net/eathena/clanrecv.cpp +++ b/src/net/eathena/clanrecv.cpp @@ -125,8 +125,6 @@ void ClanRecv::createTab() if (clanTab != nullptr) return; clanTab = new ClanTab(chatWindow); - if (config.getBoolValue("showChatHistory")) - clanTab->loadFromLogFile("#Clan"); } } // namespace EAthena diff --git a/src/net/eathena/guildrecv.cpp b/src/net/eathena/guildrecv.cpp index 74b8d9b8d..3d402c5b9 100644 --- a/src/net/eathena/guildrecv.cpp +++ b/src/net/eathena/guildrecv.cpp @@ -698,8 +698,6 @@ void GuildRecv::processGuildPositionInfo(Net::MessageIn &msg) if ((guildTab == nullptr) && (chatWindow != nullptr)) { guildTab = new GuildTab(chatWindow); - if (config.getBoolValue("showChatHistory")) - guildTab->loadFromLogFile("#Guild"); if (localPlayer != nullptr) localPlayer->addGuild(taGuild); guildHandler->memberList(); diff --git a/src/net/tmwa/guildmanager.cpp b/src/net/tmwa/guildmanager.cpp index f00e444db..52c056de6 100644 --- a/src/net/tmwa/guildmanager.cpp +++ b/src/net/tmwa/guildmanager.cpp @@ -234,8 +234,6 @@ void GuildManager::createTab(Guild *const guild) if (mTab == nullptr) { mTab = new EmulateGuildTab(chatWindow); - if (config.getBoolValue("showChatHistory")) - mTab->loadFromLogFile("#Guild"); if (localPlayer != nullptr) localPlayer->addGuild(guild); } -- cgit v1.2.3-70-g09d2