Merge branch 'master' into jgrpp
# Conflicts: # cmake/CompileFlags.cmake # src/aircraft_cmd.cpp # src/blitter/32bpp_anim.cpp # src/cargopacket.cpp # src/cheat_gui.cpp # src/company_cmd.cpp # src/company_gui.cpp # src/core/pool_func.hpp # src/date.cpp # src/economy.cpp # src/error_gui.cpp # src/ground_vehicle.cpp # src/ground_vehicle.hpp # src/group_gui.cpp # src/industry_cmd.cpp # src/lang/dutch.txt # src/lang/french.txt # src/lang/german.txt # src/linkgraph/linkgraph_gui.cpp # src/linkgraph/mcf.cpp # src/network/network_content.cpp # src/network/network_server.cpp # src/network/network_udp.cpp # src/newgrf_engine.cpp # src/newgrf_station.cpp # src/order_cmd.cpp # src/order_gui.cpp # src/pathfinder/follow_track.hpp # src/pathfinder/yapf/yapf_common.hpp # src/saveload/saveload.cpp # src/settings_gui.cpp # src/station_cmd.cpp # src/station_kdtree.h # src/string_func.h # src/table/settings.ini # src/tgp.cpp # src/timetable_cmd.cpp # src/timetable_gui.cpp # src/toolbar_gui.cpp # src/town_cmd.cpp # src/train_cmd.cpp # src/train_gui.cpp # src/tree_gui.cpp # src/tunnelbridge_cmd.cpp # src/vehicle.cpp # src/vehicle_gui.cpp # src/video/sdl2_v.cpp # src/video/sdl_v.cpp # src/video/win32_v.cpp # src/viewport.cpp # src/viewport_sprite_sorter_sse4.cpp # src/window.cpp
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"
|
||||
@@ -172,6 +173,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)
|
||||
{
|
||||
@@ -180,6 +182,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);
|
||||
}
|
||||
|
||||
@@ -195,7 +198,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();
|
||||
}
|
||||
@@ -228,11 +231,13 @@ struct IConsoleWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -346,7 +351,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;
|
||||
@@ -354,7 +359,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;
|
||||
@@ -365,7 +370,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