Pass path to startup script as std::filesystem::path

simplify_debugging
elsid 2 years ago
parent 1b3dc232f1
commit 6de335dd77
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

@ -1011,7 +1011,7 @@ void OMW::Engine::setScriptConsoleMode(bool enabled)
mScriptConsoleMode = enabled;
}
void OMW::Engine::setStartupScript(const std::string& path)
void OMW::Engine::setStartupScript(const std::filesystem::path& path)
{
mStartupScript = path;
}

@ -165,7 +165,7 @@ namespace OMW
int mWarningsMode;
std::string mFocusName;
bool mScriptConsoleMode;
std::string mStartupScript;
std::filesystem::path mStartupScript;
int mActivationDistanceOverride;
std::filesystem::path mSaveGameFile;
// Grab mouse?
@ -253,7 +253,7 @@ namespace OMW
void setScriptConsoleMode(bool enabled);
/// Set path for a script that is run on startup in the console.
void setStartupScript(const std::string& path);
void setStartupScript(const std::filesystem::path& path);
/// Override the game setting specified activation distance.
void setActivationDistanceOverride(int distance);

@ -2,6 +2,7 @@
#define GAME_MWBASE_WINDOWMANAGER_H
#include <cstdint>
#include <filesystem>
#include <map>
#include <memory>
#include <set>
@ -275,7 +276,7 @@ namespace MWBase
virtual void processChangedSettings(const std::set<std::pair<std::string, std::string>>& changed) = 0;
virtual void executeInConsole(const std::string& path) = 0;
virtual void executeInConsole(const std::filesystem::path& path) = 0;
virtual void enableRest() = 0;
virtual bool getRestEnabled() = 0;

@ -13,6 +13,7 @@
#include <components/compiler/lineparser.hpp>
#include <components/compiler/locals.hpp>
#include <components/compiler/scanner.hpp>
#include <components/files/conversion.hpp>
#include <components/interpreter/interpreter.hpp>
#include <components/misc/utf8stream.hpp>
#include <components/settings/settings.hpp>
@ -239,19 +240,20 @@ namespace MWGui
}
}
void Console::executeFile(const std::string& path)
void Console::executeFile(const std::filesystem::path& path)
{
std::ifstream stream((std::filesystem::path(path)));
std::ifstream stream(path);
if (!stream.is_open())
printError("failed to open file: " + path);
else
{
std::string line;
while (std::getline(stream, line))
execute(line);
printError("Failed to open script file \"" + Files::pathToUnicodeString(path)
+ "\": " + std::generic_category().message(errno));
return;
}
std::string line;
while (std::getline(stream, line))
execute(line);
}
void Console::clear()

@ -60,7 +60,7 @@ namespace MWGui
void execute(const std::string& command);
void executeFile(const std::string& path);
void executeFile(const std::filesystem::path& path);
void updateSelectedObjectPtr(const MWWorld::Ptr& currentPtr, const MWWorld::Ptr& newPtr);

@ -1459,7 +1459,7 @@ namespace MWGui
return mScalingFactor;
}
void WindowManager::executeInConsole(const std::string& path)
void WindowManager::executeInConsole(const std::filesystem::path& path)
{
mConsole->executeFile(path);
}

@ -296,7 +296,7 @@ namespace MWGui
void watchActor(const MWWorld::Ptr& ptr) override;
MWWorld::Ptr getWatchedActor() const override;
void executeInConsole(const std::string& path) override;
void executeInConsole(const std::filesystem::path& path) override;
void enableRest() override { mRestAllowed = true; }
bool getRestEnabled() override;

Loading…
Cancel
Save