Rename height to scale for openConsole() (#5139)
authorZeno- <kde.psych@gmail.com>
Sun, 29 Jan 2017 09:26:00 +0000 (19:26 +1000)
committerGitHub <noreply@github.com>
Sun, 29 Jan 2017 09:26:00 +0000 (19:26 +1000)
For Game::openConsole() and GUIChatConsole::openConsole() the
parameter name 'height' is misleading because it's actually a
percentage of the screen/window height.

src/game.cpp
src/guiChatConsole.cpp
src/guiChatConsole.h

index 07d429c6b974e09d5fe123a2f4a7c4370c5926f9..4b4597a7a35360e5e517682960853986ee73e09e 100644 (file)
@@ -1372,7 +1372,7 @@ protected:
 
        void dropSelectedItem();
        void openInventory();
-       void openConsole(float height, const wchar_t *line=NULL);
+       void openConsole(float scale, const wchar_t *line=NULL);
        void toggleFreeMove(float *statustext_time);
        void toggleFreeMoveAlt(float *statustext_time, float *jump_timer);
        void toggleFast(float *statustext_time);
@@ -2779,15 +2779,17 @@ void Game::openInventory()
 }
 
 
-void Game::openConsole(float height, const wchar_t *line)
+void Game::openConsole(float scale, const wchar_t *line)
 {
+       assert(scale > 0.0f && scale <= 1.0f);
+
 #ifdef __ANDROID__
        porting::showInputDialog(gettext("ok"), "", "", 2);
        m_android_chat_open = true;
 #else
        if (gui_chat_console->isOpenInhibited())
                return;
-       gui_chat_console->openConsole(height);
+       gui_chat_console->openConsole(scale);
        if (line) {
                gui_chat_console->setCloseOnEnter(true);
                gui_chat_console->replaceAndAddToHistory(line);
index 86757617532fe086e7287c65d01585ae04ae2c47..bea5571f4096b3d2228f20f761874151b77f15ad 100644 (file)
@@ -116,11 +116,13 @@ GUIChatConsole::~GUIChatConsole()
                m_font->drop();
 }
 
-void GUIChatConsole::openConsole(f32 height)
+void GUIChatConsole::openConsole(f32 scale)
 {
+       assert(scale > 0.0f && scale <= 1.0f);
+
        m_open = true;
-       m_desired_height_fraction = height;
-       m_desired_height = height * m_screensize.Y;
+       m_desired_height_fraction = scale;
+       m_desired_height = scale * m_screensize.Y;
        reformatConsole();
        m_animate_time_old = getTimeMs();
        IGUIElement::setVisible(true);
index 3013a1d3134d905d4c0c4424cda38b2d6e30bb72..4e3cae13f23d9e748166a9d318dc85a6335b399d 100644 (file)
@@ -41,7 +41,7 @@ public:
        // Open the console (height = desired fraction of screen size)
        // This doesn't open immediately but initiates an animation.
        // You should call isOpenInhibited() before this.
-       void openConsole(f32 height);
+       void openConsole(f32 scale);
 
        bool isOpen() const;