Make NormalizedView constructor from const char* explicit

pull/3235/head
elsid 8 months ago
parent e4c70b7861
commit 82931059fd
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -6,6 +6,7 @@
#include <components/settings/values.hpp>
#include <components/vfs/manager.hpp>
#include <components/vfs/pathutil.hpp>
#include <components/widgets/imagebutton.hpp>
#include "../mwbase/environment.hpp"
@ -37,7 +38,9 @@ namespace MWGui
getWidget(mVersionText, "VersionText");
mVersionText->setCaption(versionDescription);
mHasAnimatedMenu = mVFS->exists("video/menu_background.bik");
constexpr VFS::Path::NormalizedView menuBackgroundVideo("video/menu_background.bik");
mHasAnimatedMenu = mVFS->exists(menuBackgroundVideo);
updateMenu();
}

@ -356,7 +356,8 @@ namespace MWGui
mWindows.push_back(std::move(console));
trackWindow(mConsole, makeConsoleWindowSettingValues());
bool questList = mResourceSystem->getVFS()->exists("textures/tx_menubook_options_over.dds");
constexpr VFS::Path::NormalizedView menubookOptionsOverTexture("textures/tx_menubook_options_over.dds");
const bool questList = mResourceSystem->getVFS()->exists(menubookOptionsOverTexture);
auto journal = JournalWindow::create(JournalViewModel::create(), questList, mEncoding);
mGuiModeStates[GM_Journal] = GuiModeState(journal.get());
mWindows.push_back(std::move(journal));

@ -8,19 +8,22 @@ namespace
TEST(CorrectSoundPath, wav_files_not_overridden_with_mp3_in_vfs_are_not_corrected)
{
std::unique_ptr<VFS::Manager> mVFS = TestingOpenMW::createTestVFS({ { "sound/bar.wav", nullptr } });
EXPECT_EQ(correctSoundPath("sound/bar.wav", *mVFS), "sound/bar.wav");
constexpr VFS::Path::NormalizedView path("sound/bar.wav");
EXPECT_EQ(correctSoundPath(path, *mVFS), "sound/bar.wav");
}
TEST(CorrectSoundPath, wav_files_overridden_with_mp3_in_vfs_are_corrected)
{
std::unique_ptr<VFS::Manager> mVFS = TestingOpenMW::createTestVFS({ { "sound/foo.mp3", nullptr } });
EXPECT_EQ(correctSoundPath("sound/foo.wav", *mVFS), "sound/foo.mp3");
constexpr VFS::Path::NormalizedView path("sound/foo.wav");
EXPECT_EQ(correctSoundPath(path, *mVFS), "sound/foo.mp3");
}
TEST(CorrectSoundPath, corrected_path_does_not_check_existence_in_vfs)
{
std::unique_ptr<VFS::Manager> mVFS = TestingOpenMW::createTestVFS({});
EXPECT_EQ(correctSoundPath("sound/foo.wav", *mVFS), "sound/foo.mp3");
constexpr VFS::Path::NormalizedView path("sound/foo.wav");
EXPECT_EQ(correctSoundPath(path, *mVFS), "sound/foo.mp3");
}
namespace

@ -39,7 +39,7 @@ namespace VFS::Path
TEST(NormalizedTest, shouldSupportConstructorFromNormalizedView)
{
const NormalizedView view = "foo/bar/baz";
const NormalizedView view("foo/bar/baz");
const Normalized value(view);
EXPECT_EQ(value.view(), "foo/bar/baz");
}

@ -865,7 +865,8 @@ namespace Resource
<< ", using embedded marker_error instead";
}
Files::IMemStream file(ErrorMarker::sValue.data(), ErrorMarker::sValue.size());
return loadNonNif("error_marker.osgt", file, mImageManager);
constexpr VFS::Path::NormalizedView errorMarker("error_marker.osgt");
return loadNonNif(errorMarker, file, mImageManager);
}
osg::ref_ptr<osg::Node> SceneManager::cloneErrorMarker()

@ -79,7 +79,7 @@ namespace VFS::Path
public:
constexpr NormalizedView() noexcept = default;
constexpr NormalizedView(const char* value)
constexpr explicit NormalizedView(const char* value)
: mValue(value)
{
if (!isNormalized(mValue))

Loading…
Cancel
Save