From ad3195488bb68b7564e11aeb44f4e3dd0ca29a9d Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Mon, 8 May 2023 16:57:57 +0200 Subject: [PATCH 1/2] Remove unimplemented method declaration --- apps/openmw/mwgui/journalbooks.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/openmw/mwgui/journalbooks.hpp b/apps/openmw/mwgui/journalbooks.hpp index 203ded1612..1970830eab 100644 --- a/apps/openmw/mwgui/journalbooks.hpp +++ b/apps/openmw/mwgui/journalbooks.hpp @@ -20,7 +20,6 @@ namespace MWGui Book createEmptyJournalBook(); Book createJournalBook(); Book createTopicBook(uintptr_t topicId); - Book createTopicBook(const std::string& topicId); Book createQuestBook(std::string_view questName); Book createTopicIndexBook(); From f93d41d9ce1096b54c1bd3a7ecab49f5d4b0d789 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Mon, 8 May 2023 17:18:18 +0200 Subject: [PATCH 2/2] Use string_view instead of const char* --- apps/openmw/mwgui/bookpage.cpp | 6 ++-- apps/openmw/mwgui/journalwindow.cpp | 52 ++++++++++++++--------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index 9833dd5729..cd419f8cc9 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -49,8 +49,8 @@ namespace MWGui && partal_match(tstHotColour, tstActiveColour, tstNormalColour, tstInteractiveId); } - bool match(char const* tstFont, const MyGUI::Colour& tstHotColour, const MyGUI::Colour& tstActiveColour, - const MyGUI::Colour& tstNormalColour, intptr_t tstInteractiveId) + bool match(std::string_view tstFont, const MyGUI::Colour& tstHotColour, + const MyGUI::Colour& tstActiveColour, const MyGUI::Colour& tstNormalColour, intptr_t tstInteractiveId) { return (mFont->getResourceName() == tstFont) && partal_match(tstHotColour, tstActiveColour, tstNormalColour, tstInteractiveId); @@ -280,7 +280,7 @@ namespace MWGui fullFontName = "Journalbook " + fullFontName; for (Styles::iterator i = mBook->mStyles.begin(); i != mBook->mStyles.end(); ++i) - if (i->match(fullFontName.c_str(), fontColour, fontColour, fontColour, 0)) + if (i->match(fullFontName, fontColour, fontColour, fontColour, 0)) return &*i; MyGUI::IFont* font = MyGUI::FontManager::getInstance().getByName(fullFontName); diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 1319379e60..dc6ad87f1f 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -24,26 +24,26 @@ namespace { - static char const OptionsOverlay[] = "OptionsOverlay"; - static char const OptionsBTN[] = "OptionsBTN"; - static char const PrevPageBTN[] = "PrevPageBTN"; - static char const NextPageBTN[] = "NextPageBTN"; - static char const CloseBTN[] = "CloseBTN"; - static char const JournalBTN[] = "JournalBTN"; - static char const TopicsBTN[] = "TopicsBTN"; - static char const QuestsBTN[] = "QuestsBTN"; - static char const CancelBTN[] = "CancelBTN"; - static char const ShowAllBTN[] = "ShowAllBTN"; - static char const ShowActiveBTN[] = "ShowActiveBTN"; - static char const PageOneNum[] = "PageOneNum"; - static char const PageTwoNum[] = "PageTwoNum"; - static char const TopicsList[] = "TopicsList"; - static char const QuestsList[] = "QuestsList"; - static char const LeftBookPage[] = "LeftBookPage"; - static char const RightBookPage[] = "RightBookPage"; - static char const LeftTopicIndex[] = "LeftTopicIndex"; - static char const CenterTopicIndex[] = "CenterTopicIndex"; - static char const RightTopicIndex[] = "RightTopicIndex"; + static constexpr std::string_view OptionsOverlay = "OptionsOverlay"; + static constexpr std::string_view OptionsBTN = "OptionsBTN"; + static constexpr std::string_view PrevPageBTN = "PrevPageBTN"; + static constexpr std::string_view NextPageBTN = "NextPageBTN"; + static constexpr std::string_view CloseBTN = "CloseBTN"; + static constexpr std::string_view JournalBTN = "JournalBTN"; + static constexpr std::string_view TopicsBTN = "TopicsBTN"; + static constexpr std::string_view QuestsBTN = "QuestsBTN"; + static constexpr std::string_view CancelBTN = "CancelBTN"; + static constexpr std::string_view ShowAllBTN = "ShowAllBTN"; + static constexpr std::string_view ShowActiveBTN = "ShowActiveBTN"; + static constexpr std::string_view PageOneNum = "PageOneNum"; + static constexpr std::string_view PageTwoNum = "PageTwoNum"; + static constexpr std::string_view TopicsList = "TopicsList"; + static constexpr std::string_view QuestsList = "QuestsList"; + static constexpr std::string_view LeftBookPage = "LeftBookPage"; + static constexpr std::string_view RightBookPage = "RightBookPage"; + static constexpr std::string_view LeftTopicIndex = "LeftTopicIndex"; + static constexpr std::string_view CenterTopicIndex = "CenterTopicIndex"; + static constexpr std::string_view RightTopicIndex = "RightTopicIndex"; struct JournalWindowImpl : MWGui::JournalBooks, MWGui::JournalWindow { @@ -63,7 +63,7 @@ namespace bool mAllQuests; template - T* getWidget(char const* name) + T* getWidget(std::string_view name) { T* widget; WindowBase::getWidget(widget, name); @@ -71,25 +71,25 @@ namespace } template - void setText(char const* name, value_type const& value) + void setText(std::string_view name, value_type const& value) { getWidget(name)->setCaption(MyGUI::utility::toString(value)); } - void setVisible(char const* name, bool visible) { getWidget(name)->setVisible(visible); } + void setVisible(std::string_view name, bool visible) { getWidget(name)->setVisible(visible); } - void adviseButtonClick(char const* name, void (JournalWindowImpl::*handler)(MyGUI::Widget*)) + void adviseButtonClick(std::string_view name, void (JournalWindowImpl::*handler)(MyGUI::Widget*)) { getWidget(name)->eventMouseButtonClick += newDelegate(this, handler); } void adviseKeyPress( - char const* name, void (JournalWindowImpl::*handler)(MyGUI::Widget*, MyGUI::KeyCode, MyGUI::Char)) + std::string_view name, void (JournalWindowImpl::*handler)(MyGUI::Widget*, MyGUI::KeyCode, MyGUI::Char)) { getWidget(name)->eventKeyButtonPressed += newDelegate(this, handler); } - MWGui::BookPage* getPage(char const* name) { return getWidget(name); } + MWGui::BookPage* getPage(std::string_view name) { return getWidget(name); } JournalWindowImpl(MWGui::JournalViewModel::Ptr Model, bool questList, ToUTF8::FromType encoding) : JournalBooks(Model, encoding)