Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "window_gui.h"
|
||||
#include "console_gui.h"
|
||||
#include "console_internal.h"
|
||||
#include "guitimer_func.h"
|
||||
#include "window_func.h"
|
||||
#include "string_func.h"
|
||||
#include "strings_func.h"
|
||||
@@ -176,6 +177,7 @@ struct IConsoleWindow : Window
|
||||
static int scroll;
|
||||
int line_height; ///< Height of one line of text in the console.
|
||||
int line_offset;
|
||||
GUITimer truncate_timer;
|
||||
|
||||
IConsoleWindow() : Window(&_console_window_desc)
|
||||
{
|
||||
@@ -184,6 +186,7 @@ struct IConsoleWindow : Window
|
||||
this->line_offset = GetStringBoundingBox("] ").width + 5;
|
||||
|
||||
this->InitNested(0);
|
||||
this->truncate_timer.SetInterval(3000);
|
||||
ResizeWindow(this, _screen.width, _screen.height / 3);
|
||||
}
|
||||
|
||||
@@ -199,7 +202,7 @@ struct IConsoleWindow : Window
|
||||
*/
|
||||
void Scroll(int amount)
|
||||
{
|
||||
int max_scroll = max<int>(0, IConsoleLine::size + 1 - this->height / this->line_height);
|
||||
int max_scroll = std::max(0, IConsoleLine::size + 1 - this->height / this->line_height);
|
||||
IConsoleWindow::scroll = Clamp<int>(IConsoleWindow::scroll + amount, 0, max_scroll);
|
||||
this->SetDirty();
|
||||
}
|
||||
@@ -242,11 +245,13 @@ struct IConsoleWindow : Window
|
||||
this->OnKeyPress(0, WKC_RETURN);
|
||||
}
|
||||
|
||||
void OnHundredthTick() override
|
||||
void OnRealtimeTick(uint delta_ms) override
|
||||
{
|
||||
if (this->truncate_timer.CountElapsed(delta_ms) == 0) return;
|
||||
|
||||
if (IConsoleLine::Truncate() &&
|
||||
(IConsoleWindow::scroll > IConsoleLine::size)) {
|
||||
IConsoleWindow::scroll = max(0, IConsoleLine::size - (this->height / this->line_height) + 1);
|
||||
IConsoleWindow::scroll = std::max(0, IConsoleLine::size - (this->height / this->line_height) + 1);
|
||||
this->SetDirty();
|
||||
}
|
||||
}
|
||||
@@ -356,7 +361,7 @@ struct IConsoleWindow : Window
|
||||
|
||||
Point GetCaretPosition() const override
|
||||
{
|
||||
int delta = min(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0);
|
||||
int delta = std::min<int>(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0);
|
||||
Point pt = {this->line_offset + delta + _iconsole_cmdline.caretxoffs, this->height - this->line_height};
|
||||
|
||||
return pt;
|
||||
@@ -364,7 +369,7 @@ struct IConsoleWindow : Window
|
||||
|
||||
Rect GetTextBoundingRect(const char *from, const char *to) const override
|
||||
{
|
||||
int delta = min(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0);
|
||||
int delta = std::min<int>(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0);
|
||||
|
||||
Point p1 = GetCharPosInString(_iconsole_cmdline.buf, from, FS_NORMAL);
|
||||
Point p2 = from != to ? GetCharPosInString(_iconsole_cmdline.buf, from) : p1;
|
||||
@@ -375,7 +380,7 @@ struct IConsoleWindow : Window
|
||||
|
||||
const char *GetTextCharacterAtPosition(const Point &pt) const override
|
||||
{
|
||||
int delta = min(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0);
|
||||
int delta = std::min<int>(this->width - this->line_offset - _iconsole_cmdline.pixels - ICON_RIGHT_BORDERWIDTH, 0);
|
||||
|
||||
if (!IsInsideMM(pt.y, this->height - this->line_height, this->height)) return nullptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user