be more verbose on change reasons

deque
greye 11 years ago
parent 8f9091550e
commit 663d5c314e

@ -41,6 +41,13 @@ private:
std::vector<std::string> args; std::vector<std::string> args;
}; };
/* The only way to pass Unicode on Winodws with CLI is to use wide
characters interface which presents UTF-16 encoding. The rest of
OpenMW application stack assumes UTF-8 encoding, therefore this
conversion.
For boost::filesystem::path::imbue see components/files/windowspath.cpp
*/
int wmain(int argc, wchar_t *wargv[]) { int wmain(int argc, wchar_t *wargv[]) {
utf8argv converter(argc, wargv); utf8argv converter(argc, wargv);
char **argv = converter.get(); char **argv = converter.get();

@ -27,6 +27,13 @@ namespace Files
WindowsPath::WindowsPath(const std::string& application_name) WindowsPath::WindowsPath(const std::string& application_name)
: mName(application_name) : mName(application_name)
{ {
/* Since on Windows boost::path.string() returns string of narrow
characters in local encoding, it is required to path::imbue()
with UTF-8 encoding (generated for empty name from boost::locale)
to handle Unicode in platform-agnostic way using std::string.
See boost::filesystem and boost::locale reference for details.
*/
boost::filesystem::path::imbue(boost::locale::generator().generate("")); boost::filesystem::path::imbue(boost::locale::generator().generate(""));
} }

@ -26,6 +26,13 @@ namespace bfs = boost::filesystem;
namespace namespace
{ {
/** \brief Custom Ogre::LogListener interface implementation being
able to portably handle UTF-8 encoded path.
Effectively this is used in conjunction with default listener,
but since on every message messageLogged() set 'skip' flag to
true, there should be no troubles sharing same file.
*/
class LogListener : public Ogre::LogListener class LogListener : public Ogre::LogListener
{ {
bfs::ofstream file; bfs::ofstream file;
@ -87,6 +94,7 @@ namespace OgreInit
Ogre::Log *log = Ogre::LogManager::getSingleton().createLog(logPath); Ogre::Log *log = Ogre::LogManager::getSingleton().createLog(logPath);
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
// Use custom listener only on Windows
log->addListener(new LogListener(logPath)); log->addListener(new LogListener(logPath));
#endif #endif

@ -32,7 +32,7 @@ distribution.
#include "tinyxml.h" #include "tinyxml.h"
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h> #include <Windows.h> // import MultiByteToWideChar
#endif #endif

@ -6,6 +6,15 @@
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
/*
Almost exact copy of load_file_to_string policy found in
boost::wave headers with the only change that it uses
boost::filesystem facility to handle UTF-8 paths used
throughout OpenMW (bfs::fstream, bfs::path).
Original namespace is used due to required bost::wave
internal symbols.
*/
namespace boost { namespace boost {
namespace wave { namespace wave {
namespace iteration_context_policies { namespace iteration_context_policies {

@ -8,6 +8,8 @@
namespace MyGUI namespace MyGUI
{ {
/// \brief Custom MyGUI::ILogListener interface implementation
/// being able to portably handle UTF-8 encoded path.
class CustomLogListener : public ILogListener class CustomLogListener : public ILogListener
{ {
public: public:

@ -559,6 +559,8 @@ public:
} }
}; };
/// \brief Helper class holding data that required during
/// MyGUI log creation
class LogFacility class LogFacility
{ {
ConsoleLogListener mConsole; ConsoleLogListener mConsole;
@ -615,6 +617,8 @@ void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool
mRenderManager = new MyGUI::OgreRenderManager(); mRenderManager = new MyGUI::OgreRenderManager();
mDataManager = new MyGUI::FixedOgreDataManager(); mDataManager = new MyGUI::FixedOgreDataManager();
// Do not use default log since it don't support Unicode path on Windows.
// Instead, manually create log source using LogFacility and pass it.
mLogFacility = new MyGUI::LogFacility(theLogFile, logging); mLogFacility = new MyGUI::LogFacility(theLogFile, logging);
LogManager::getInstance().addLogSource(mLogFacility->getSource()); LogManager::getInstance().addLogSource(mLogFacility->getSource());

@ -51,6 +51,10 @@ void OgreRenderer::update(float dt)
void OgreRenderer::screenshot(const std::string &file) void OgreRenderer::screenshot(const std::string &file)
{ {
/* Since Ogre uses narrow character interfaces, it does not support
Unicode paths on Windows. Therefore we had to implement screenshot
saving manually.
*/
namespace bfs = boost::filesystem; namespace bfs = boost::filesystem;
bfs::ofstream out(bfs::path(file), std::ios::binary); bfs::ofstream out(bfs::path(file), std::ios::binary);

Loading…
Cancel
Save