diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index 7a504b5679..be4655e3b5 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -71,8 +71,6 @@ public: void encode(); void decode(); - void setInputCommand(bool b); - private: OpenSpaceEngine(std::string programName); ~OpenSpaceEngine(); @@ -93,7 +91,6 @@ private: SyncBuffer* _syncBuffer; - bool _inputCommand; LuaConsole* _console; }; diff --git a/include/openspace/interaction/luaconsole.h b/include/openspace/interaction/luaconsole.h index c261e92906..7138c46043 100644 --- a/include/openspace/interaction/luaconsole.h +++ b/include/openspace/interaction/luaconsole.h @@ -43,6 +43,10 @@ public: unsigned int commandInputButton(); unsigned int ignoreCodepoint(); + bool isVisible() const; + void setVisible(bool visible); + void toggleVisibility(); + private: void addToCommand(std::string c); std::string UnicodeToUTF8(unsigned int codepoint); @@ -52,6 +56,7 @@ private: size_t _activeCommand; std::vector _commands; + bool _isVisible; }; } // namespace openspace diff --git a/include/openspace/util/constants.h b/include/openspace/util/constants.h index d834e834fe..18bcb36255 100644 --- a/include/openspace/util/constants.h +++ b/include/openspace/util/constants.h @@ -38,7 +38,8 @@ namespace fonts { namespace configurationmanager { const std::string keyPaths = "Paths"; - const std::string keyCachePath = "Paths.CACHE"; + const std::string keyCache = "CACHE"; + const std::string keyCachePath = keyPaths + "." + keyCache; const std::string keyFonts = "Fonts"; const std::string keyConfigSgct = "SGCTConfig"; const std::string keyConfigScene = "Scene"; diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 555380eba4..7000903667 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -85,7 +85,6 @@ OpenSpaceEngine* OpenSpaceEngine::_engine = nullptr; OpenSpaceEngine::OpenSpaceEngine(std::string programName) : _commandlineParser(programName, true) , _syncBuffer(nullptr) - , _inputCommand(false) , _console(nullptr) { // initialize OpenSpace helpers @@ -294,10 +293,7 @@ bool OpenSpaceEngine::create(int argc, char** argv, } // Create the cachemanager - std::string cacheDirectory; - _engine->configurationManager().getValue( - constants::configurationmanager::keyCachePath, cacheDirectory); - FileSys.createCacheManager(cacheDirectory); + FileSys.createCacheManager(absPath("${" + constants::configurationmanager::keyCache + "}")); _engine->_console = new LuaConsole(); _engine->_syncBuffer = new SyncBuffer(1024); @@ -426,7 +422,7 @@ void OpenSpaceEngine::render() { // If currently writing a command, render it to screen sgct::SGCTWindow* w = sgct::Engine::instance()->getActiveWindowPtr(); - if (sgct::Engine::instance()->isMaster() && !w->isUsingFisheyeRendering() && _inputCommand) { + if (sgct::Engine::instance()->isMaster() && !w->isUsingFisheyeRendering() && _console->isVisible()) { _console->render(); } } @@ -441,11 +437,10 @@ void OpenSpaceEngine::postDraw() { void OpenSpaceEngine::keyboardCallback(int key, int action) { if (sgct::Engine::instance()->isMaster()) { - if (key == _console->commandInputButton() && (action == SGCT_PRESS || action == SGCT_REPEAT)) { - _inputCommand = !_inputCommand; - } + if (key == _console->commandInputButton() && (action == SGCT_PRESS || action == SGCT_REPEAT)) + _console->toggleVisibility(); - if (!_inputCommand) { + if (!_console->isVisible()) { _interactionHandler.keyboardCallback(key, action); } else { @@ -455,7 +450,7 @@ void OpenSpaceEngine::keyboardCallback(int key, int action) { } void OpenSpaceEngine::charCallback(unsigned int codepoint) { - if (_inputCommand) { + if (_console->isVisible()) { _console->charCallback(codepoint); } } @@ -485,10 +480,6 @@ void OpenSpaceEngine::decode() _renderEngine.deserialize(_syncBuffer); } -void OpenSpaceEngine::setInputCommand(bool b) { - _inputCommand = b; -} - void OpenSpaceEngine::externalControlCallback(const char* receivedChars, int size, int clientId) { diff --git a/src/interaction/luaconsole.cpp b/src/interaction/luaconsole.cpp index d1da7674c6..71f34eced2 100644 --- a/src/interaction/luaconsole.cpp +++ b/src/interaction/luaconsole.cpp @@ -147,6 +147,7 @@ namespace openspace { LuaConsole::LuaConsole() : _inputPosition(0) , _activeCommand(0) + , _isVisible(false) { std::ifstream file(absPath(_filename), std::ios::binary | std::ios::in); if (file.is_open()) { @@ -279,12 +280,12 @@ void LuaConsole::keyboardCallback(int key, int action) { _commands.push_back(""); _activeCommand = _commands.size() - 1; _inputPosition = 0; - OsEng.setInputCommand(false); + setVisible(false); } else { _commands = _commandsHistory; _commands.push_back(""); - OsEng.setInputCommand(false); + setVisible(false); } } } @@ -394,5 +395,17 @@ std::string LuaConsole::UnicodeToUTF8(unsigned int codepoint) { return out; } +bool LuaConsole::isVisible() const { + return _isVisible; +} + +void LuaConsole::setVisible(bool visible) { + _isVisible = visible; +} + +void LuaConsole::toggleVisibility() { + _isVisible = !_isVisible; +} + } // namespace openspace