// // Copyright (c) 2008-2017 the Urho3D project. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // #include "../Precompiled.h" #include "../Core/Context.h" #include "../Core/CoreEvents.h" #include "../Engine/Console.h" #include "../Engine/EngineEvents.h" #include "../Graphics/Graphics.h" #include "../Input/Input.h" #include "../IO/IOEvents.h" #include "../IO/Log.h" #include "../Resource/ResourceCache.h" #include "../UI/DropDownList.h" #include "../UI/Font.h" #include "../UI/LineEdit.h" #include "../UI/ListView.h" #include "../UI/ScrollBar.h" #include "../UI/Text.h" #include "../UI/UI.h" #include "../UI/UIEvents.h" #include "../DebugNew.h" namespace Urho3D { static const int DEFAULT_CONSOLE_ROWS = 16; static const int DEFAULT_HISTORY_SIZE = 16; const char* logStyles[] = { "ConsoleDebugText", "ConsoleInfoText", "ConsoleWarningText", "ConsoleErrorText", "ConsoleText" }; Console::Console(Context* context) : Object(context), autoVisibleOnError_(false), historyRows_(DEFAULT_HISTORY_SIZE), historyPosition_(0), autoCompletePosition_(0), historyOrAutoCompleteChange_(false), printing_(false) { UI* ui = GetSubsystem(); UIElement* uiRoot = ui->GetRoot(); // By default prevent the automatic showing of the screen keyboard focusOnShow_ = !ui->GetUseScreenKeyboard(); background_ = uiRoot->CreateChild(); background_->SetBringToBack(false); background_->SetClipChildren(true); background_->SetEnabled(true); background_->SetVisible(false); // Hide by default background_->SetPriority(200); // Show on top of the debug HUD background_->SetBringToBack(false); background_->SetLayout(LM_VERTICAL); rowContainer_ = background_->CreateChild(); rowContainer_->SetHighlightMode(HM_ALWAYS); rowContainer_->SetMultiselect(true); commandLine_ = background_->CreateChild(); commandLine_->SetLayoutMode(LM_HORIZONTAL); commandLine_->SetLayoutSpacing(1); interpreters_ = commandLine_->CreateChild(); lineEdit_ = commandLine_->CreateChild(); lineEdit_->SetFocusMode(FM_FOCUSABLE); // Do not allow defocus with ESC closeButton_ = uiRoot->CreateChild