Mercurial > hg > openttd
annotate src/console_gui.cpp @ 11483:f45b22901ffa draft
(svn r15844) -Codechange: allow text alignment to be forced so the console and ai debug output don't get swapped (those are untranslateable anyways)
author | rubidium <rubidium@openttd.org> |
---|---|
date | Wed, 25 Mar 2009 01:10:24 +0000 (2009-03-25) |
parents | caf4456fbbf3 |
children | 80379bc12cb3 |
rev | line source |
---|---|
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
2 |
10238
12805d675e85
(svn r14466) -Doc: remove some obsolete parameters, fix a few parameter names in comments and add a little more doxygen documentation.
rubidium <rubidium@openttd.org>
parents:
10207
diff
changeset
|
3 /** @file console_gui.cpp Handling the GUI of the in-game console. */ |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
4 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
5 #include "stdafx.h" |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
6 #include "textbuf_gui.h" |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
7 #include "window_gui.h" |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
8 #include "console_gui.h" |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
9 #include "console_internal.h" |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
10 #include "window_func.h" |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
11 #include "string_func.h" |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
12 #include "gfx_func.h" |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
13 #include "core/math_func.hpp" |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
14 #include "settings_type.h" |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
15 #include "rev.h" |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
16 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
17 #include "table/strings.h" |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
18 |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
19 enum { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
20 ICON_HISTORY_SIZE = 20, |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
21 ICON_LINE_HEIGHT = 12, |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
22 ICON_RIGHT_BORDERWIDTH = 10, |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
23 ICON_BOTTOM_BORDERWIDTH = 12, |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
24 }; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
25 |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
26 /** |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
27 * Container for a single line of console output |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
28 */ |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
29 struct IConsoleLine { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
30 static IConsoleLine *front; ///< The front of the console backlog buffer |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
31 static int size; ///< The amount of items in the backlog |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
32 |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
33 IConsoleLine *previous; ///< The previous console message. |
11082
9ec1f7eac0a0
(svn r15425) -Codechange: some color->colour changes and type safety.
rubidium <rubidium@openttd.org>
parents:
11081
diff
changeset
|
34 char *buffer; ///< The data to store. |
9ec1f7eac0a0
(svn r15425) -Codechange: some color->colour changes and type safety.
rubidium <rubidium@openttd.org>
parents:
11081
diff
changeset
|
35 TextColour colour; ///< The colour of the line. |
9ec1f7eac0a0
(svn r15425) -Codechange: some color->colour changes and type safety.
rubidium <rubidium@openttd.org>
parents:
11081
diff
changeset
|
36 uint16 time; ///< The amount of time the line is in the backlog. |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
37 |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
38 /** |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
39 * Initialize the console line. |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
40 * @param buffer the data to print. |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
41 * @param colour the colour of the line. |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
42 */ |
11082
9ec1f7eac0a0
(svn r15425) -Codechange: some color->colour changes and type safety.
rubidium <rubidium@openttd.org>
parents:
11081
diff
changeset
|
43 IConsoleLine(char *buffer, TextColour colour) : |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
44 previous(IConsoleLine::front), |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
45 buffer(buffer), |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
46 colour(colour), |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
47 time(0) |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
48 { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
49 IConsoleLine::front = this; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
50 IConsoleLine::size++; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
51 } |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
52 |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
53 /** |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
54 * Clear this console line and any further ones. |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
55 */ |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
56 ~IConsoleLine() |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
57 { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
58 IConsoleLine::size--; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
59 free(buffer); |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
60 |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
61 delete previous; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
62 } |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
63 |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
64 /** |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
65 * Get the index-ed item in the list. |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
66 */ |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
67 static const IConsoleLine *Get(uint index) |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
68 { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
69 const IConsoleLine *item = IConsoleLine::front; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
70 while (index != 0 && item != NULL) { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
71 index--; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
72 item = item->previous; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
73 } |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
74 |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
75 return item; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
76 } |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
77 |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
78 /** |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
79 * Truncate the list removing everything older than/more than the amount |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
80 * as specified in the config file. |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
81 * As a side effect also increase the time the other lines have been in |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
82 * the list. |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
83 * @return true if and only if items got removed. |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
84 */ |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
85 static bool Truncate() |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
86 { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
87 IConsoleLine *cur = IConsoleLine::front; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
88 if (cur == NULL) return false; |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
89 |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
90 int count = 1; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
91 for (IConsoleLine *item = cur->previous; item != NULL; count++, cur = item, item = item->previous) { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
92 if (item->time > _settings_client.gui.console_backlog_timeout && |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
93 count > _settings_client.gui.console_backlog_length) { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
94 delete item; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
95 cur->previous = NULL; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
96 return true; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
97 } |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
98 |
9915
f0cea4aa2bf6
(svn r14068) -Fix (r14056): MSVC doesn't support typeof.
rubidium <rubidium@openttd.org>
parents:
9906
diff
changeset
|
99 if (item->time != MAX_UVALUE(uint16)) item->time++; |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
100 } |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
101 |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
102 return false; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
103 } |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
104 |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
105 /** |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
106 * Reset the complete console line backlog. |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
107 */ |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
108 static void Reset() |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
109 { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
110 delete IConsoleLine::front; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
111 IConsoleLine::front = NULL; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
112 IConsoleLine::size = 0; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
113 } |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
114 }; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
115 |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
116 /* static */ IConsoleLine *IConsoleLine::front = NULL; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
117 /* static */ int IConsoleLine::size = 0; |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
118 |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
119 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
120 /* ** main console cmd buffer ** */ |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
121 static Textbuf _iconsole_cmdline; |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
122 static char *_iconsole_history[ICON_HISTORY_SIZE]; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
123 static byte _iconsole_historypos; |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
124 IConsoleModes _iconsole_mode; |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
125 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
126 /* *************** * |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
127 * end of header * |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
128 * *************** */ |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
129 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
130 static void IConsoleClearCommand() |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
131 { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
132 memset(_iconsole_cmdline.buf, 0, ICON_CMDLN_SIZE); |
10276
a5286e772120
(svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents:
10238
diff
changeset
|
133 _iconsole_cmdline.size = 1; // only terminating zero |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
134 _iconsole_cmdline.width = 0; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
135 _iconsole_cmdline.caretpos = 0; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
136 _iconsole_cmdline.caretxoffs = 0; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
137 SetWindowDirty(FindWindowById(WC_CONSOLE, 0)); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
138 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
139 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
140 static inline void IConsoleResetHistoryPos() {_iconsole_historypos = ICON_HISTORY_SIZE - 1;} |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
141 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
142 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
143 static void IConsoleHistoryAdd(const char *cmd); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
144 static void IConsoleHistoryNavigate(int direction); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
145 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
146 struct IConsoleWindow : Window |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
147 { |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
148 static int scroll; |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
149 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
150 IConsoleWindow(const WindowDesc *desc) : Window(desc) |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
151 { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
152 _iconsole_mode = ICONSOLE_OPENED; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
153 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
154 this->height = _screen.height / 3; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
155 this->width = _screen.width; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
156 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
157 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
158 ~IConsoleWindow() |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
159 { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
160 _iconsole_mode = ICONSOLE_CLOSED; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
161 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
162 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
163 virtual void OnPaint() |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
164 { |
11436
caf4456fbbf3
(svn r15794) -Codechange: remove the DoDrawString part of the old text drawing API
rubidium <rubidium@openttd.org>
parents:
11373
diff
changeset
|
165 const int max = (this->height / ICON_LINE_HEIGHT) - 1; |
11483
f45b22901ffa
(svn r15844) -Codechange: allow text alignment to be forced so the console and ai debug output don't get swapped (those are untranslateable anyways)
rubidium <rubidium@openttd.org>
parents:
11436
diff
changeset
|
166 const int right = this->width - 5; |
11436
caf4456fbbf3
(svn r15794) -Codechange: remove the DoDrawString part of the old text drawing API
rubidium <rubidium@openttd.org>
parents:
11373
diff
changeset
|
167 |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
168 const IConsoleLine *print = IConsoleLine::Get(IConsoleWindow::scroll); |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
169 GfxFillRect(this->left, this->top, this->width, this->height - 1, 0); |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
170 for (int i = 0; i < max && print != NULL; i++, print = print->previous) { |
11483
f45b22901ffa
(svn r15844) -Codechange: allow text alignment to be forced so the console and ai debug output don't get swapped (those are untranslateable anyways)
rubidium <rubidium@openttd.org>
parents:
11436
diff
changeset
|
171 DrawString(5, right, this->height - (2 + i) * ICON_LINE_HEIGHT, print->buffer, print->colour, SA_LEFT | SA_FORCE); |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
172 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
173 /* If the text is longer than the window, don't show the starting ']' */ |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
174 int delta = this->width - 10 - _iconsole_cmdline.width - ICON_RIGHT_BORDERWIDTH; |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
175 if (delta > 0) { |
11483
f45b22901ffa
(svn r15844) -Codechange: allow text alignment to be forced so the console and ai debug output don't get swapped (those are untranslateable anyways)
rubidium <rubidium@openttd.org>
parents:
11436
diff
changeset
|
176 DrawString(5, right, this->height - ICON_LINE_HEIGHT, "]", (TextColour)CC_COMMAND, SA_LEFT | SA_FORCE); |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
177 delta = 0; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
178 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
179 |
11483
f45b22901ffa
(svn r15844) -Codechange: allow text alignment to be forced so the console and ai debug output don't get swapped (those are untranslateable anyways)
rubidium <rubidium@openttd.org>
parents:
11436
diff
changeset
|
180 DrawString(10 + delta, right, this->height - ICON_LINE_HEIGHT, _iconsole_cmdline.buf, (TextColour)CC_COMMAND, SA_LEFT | SA_FORCE); |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
181 |
11081
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
182 if (_focused_window == this && _iconsole_cmdline.caret) { |
11483
f45b22901ffa
(svn r15844) -Codechange: allow text alignment to be forced so the console and ai debug output don't get swapped (those are untranslateable anyways)
rubidium <rubidium@openttd.org>
parents:
11436
diff
changeset
|
183 DrawString(10 + delta + _iconsole_cmdline.caretxoffs, right, this->height - ICON_LINE_HEIGHT, "_", TC_WHITE, SA_LEFT | SA_FORCE); |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
184 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
185 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
186 |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
187 virtual void OnHundredthTick() |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
188 { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
189 if (IConsoleLine::Truncate() && |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
190 (IConsoleWindow::scroll > IConsoleLine::size)) { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
191 IConsoleWindow::scroll = max(0, IConsoleLine::size - (this->height / ICON_LINE_HEIGHT) + 1); |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
192 this->SetDirty(); |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
193 } |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
194 } |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
195 |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
196 virtual void OnMouseLoop() |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
197 { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
198 if (HandleCaret(&_iconsole_cmdline)) this->SetDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
199 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
200 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
201 virtual EventState OnKeyPress(uint16 key, uint16 keycode) |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
202 { |
11081
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
203 if (_focused_window != this) return ES_NOT_HANDLED; |
0a26df8849a2
(svn r15424) -Codechange: make it possible to have multiple windows with edit box open simultaniously (Zuu).
rubidium <rubidium@openttd.org>
parents:
10960
diff
changeset
|
204 |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
205 const int scroll_height = (this->height / ICON_LINE_HEIGHT) - 1; |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
206 switch (keycode) { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
207 case WKC_UP: |
11361
02313cc6114e
(svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents:
11085
diff
changeset
|
208 IConsoleHistoryNavigate(1); |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
209 this->SetDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
210 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
211 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
212 case WKC_DOWN: |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
213 IConsoleHistoryNavigate(-1); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
214 this->SetDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
215 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
216 |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
217 case WKC_SHIFT | WKC_PAGEDOWN: |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
218 if (IConsoleWindow::scroll - scroll_height < 0) { |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
219 IConsoleWindow::scroll = 0; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
220 } else { |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
221 IConsoleWindow::scroll -= scroll_height; |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
222 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
223 this->SetDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
224 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
225 |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
226 case WKC_SHIFT | WKC_PAGEUP: |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
227 if (IConsoleWindow::scroll + scroll_height > IConsoleLine::size - scroll_height) { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
228 IConsoleWindow::scroll = IConsoleLine::size - scroll_height; |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
229 } else { |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
230 IConsoleWindow::scroll += scroll_height; |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
231 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
232 this->SetDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
233 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
234 |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
235 case WKC_SHIFT | WKC_DOWN: |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
236 if (IConsoleWindow::scroll <= 0) { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
237 IConsoleWindow::scroll = 0; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
238 } else { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
239 --IConsoleWindow::scroll; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
240 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
241 this->SetDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
242 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
243 |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
244 case WKC_SHIFT | WKC_UP: |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
245 if (IConsoleWindow::scroll >= IConsoleLine::size) { |
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
246 IConsoleWindow::scroll = IConsoleLine::size; |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
247 } else { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
248 ++IConsoleWindow::scroll; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
249 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
250 this->SetDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
251 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
252 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
253 case WKC_BACKQUOTE: |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
254 IConsoleSwitch(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
255 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
256 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
257 case WKC_RETURN: case WKC_NUM_ENTER: |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
258 IConsolePrintF(CC_COMMAND, "] %s", _iconsole_cmdline.buf); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
259 IConsoleHistoryAdd(_iconsole_cmdline.buf); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
260 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
261 IConsoleCmdExec(_iconsole_cmdline.buf); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
262 IConsoleClearCommand(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
263 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
264 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
265 case WKC_CTRL | WKC_RETURN: |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
266 _iconsole_mode = (_iconsole_mode == ICONSOLE_FULL) ? ICONSOLE_OPENED : ICONSOLE_FULL; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
267 IConsoleResize(this); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
268 MarkWholeScreenDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
269 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
270 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
271 case (WKC_CTRL | 'V'): |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
272 if (InsertTextBufferClipboard(&_iconsole_cmdline)) { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
273 IConsoleResetHistoryPos(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
274 this->SetDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
275 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
276 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
277 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
278 case (WKC_CTRL | 'L'): |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
279 IConsoleCmdExec("clear"); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
280 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
281 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
282 case (WKC_CTRL | 'U'): |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
283 DeleteTextBufferAll(&_iconsole_cmdline); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
284 this->SetDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
285 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
286 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
287 case WKC_BACKSPACE: case WKC_DELETE: |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
288 if (DeleteTextBufferChar(&_iconsole_cmdline, keycode)) { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
289 IConsoleResetHistoryPos(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
290 this->SetDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
291 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
292 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
293 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
294 case WKC_LEFT: case WKC_RIGHT: case WKC_END: case WKC_HOME: |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
295 if (MoveTextBufferPos(&_iconsole_cmdline, keycode)) { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
296 IConsoleResetHistoryPos(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
297 this->SetDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
298 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
299 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
300 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
301 default: |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
302 if (IsValidChar(key, CS_ALPHANUMERAL)) { |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
303 IConsoleWindow::scroll = 0; |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
304 InsertTextBufferChar(&_iconsole_cmdline, key); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
305 IConsoleResetHistoryPos(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
306 this->SetDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
307 } else { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
308 return ES_NOT_HANDLED; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
309 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
310 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
311 return ES_HANDLED; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
312 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
313 }; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
314 |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
315 int IConsoleWindow::scroll = 0; |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
316 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
317 static const Widget _iconsole_window_widgets[] = { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
318 {WIDGETS_END} |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
319 }; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
320 |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
321 static const WindowDesc _iconsole_window_desc( |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
322 0, 0, 2, 2, 2, 2, |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
323 WC_CONSOLE, WC_NONE, |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
324 WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
11373
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
325 _iconsole_window_widgets |
474ba6cc0946
(svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents:
11361
diff
changeset
|
326 ); |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
327 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
328 void IConsoleGUIInit() |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
329 { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
330 _iconsole_historypos = ICON_HISTORY_SIZE - 1; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
331 _iconsole_mode = ICONSOLE_CLOSED; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
332 |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
333 IConsoleLine::Reset(); |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
334 memset(_iconsole_history, 0, sizeof(_iconsole_history)); |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
335 |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
336 _iconsole_cmdline.buf = CallocT<char>(ICON_CMDLN_SIZE); // create buffer and zero it |
10276
a5286e772120
(svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents:
10238
diff
changeset
|
337 _iconsole_cmdline.maxsize = ICON_CMDLN_SIZE; |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
338 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
339 IConsolePrintF(CC_WARNING, "OpenTTD Game Console Revision 7 - %s", _openttd_revision); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
340 IConsolePrint(CC_WHITE, "------------------------------------"); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
341 IConsolePrint(CC_WHITE, "use \"help\" for more information"); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
342 IConsolePrint(CC_WHITE, ""); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
343 IConsoleClearCommand(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
344 IConsoleHistoryAdd(""); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
345 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
346 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
347 void IConsoleClearBuffer() |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
348 { |
9906
b5cdbf8eadf3
(svn r14056) -Fix [FS#2192]: the console backlog is too small for list_patches. Now it'll only remove backlog items when there are more than a threshold and when they are there longer than (another) threshold.
rubidium <rubidium@openttd.org>
parents:
9339
diff
changeset
|
349 IConsoleLine::Reset(); |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
350 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
351 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
352 void IConsoleGUIFree() |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
353 { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
354 free(_iconsole_cmdline.buf); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
355 IConsoleClearBuffer(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
356 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
357 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
358 void IConsoleResize(Window *w) |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
359 { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
360 switch (_iconsole_mode) { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
361 case ICONSOLE_OPENED: |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
362 w->height = _screen.height / 3; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
363 w->width = _screen.width; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
364 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
365 case ICONSOLE_FULL: |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
366 w->height = _screen.height - ICON_BOTTOM_BORDERWIDTH; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
367 w->width = _screen.width; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
368 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
369 default: return; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
370 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
371 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
372 MarkWholeScreenDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
373 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
374 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
375 void IConsoleSwitch() |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
376 { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
377 switch (_iconsole_mode) { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
378 case ICONSOLE_CLOSED: |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
379 new IConsoleWindow(&_iconsole_window_desc); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
380 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
381 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
382 case ICONSOLE_OPENED: case ICONSOLE_FULL: |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
383 DeleteWindowById(WC_CONSOLE, 0); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
384 break; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
385 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
386 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
387 MarkWholeScreenDirty(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
388 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
389 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
390 void IConsoleClose() {if (_iconsole_mode == ICONSOLE_OPENED) IConsoleSwitch();} |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
391 void IConsoleOpen() {if (_iconsole_mode == ICONSOLE_CLOSED) IConsoleSwitch();} |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
392 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
393 /** |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
394 * Add the entered line into the history so you can look it back |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
395 * scroll, etc. Put it to the beginning as it is the latest text |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
396 * @param cmd Text to be entered into the 'history' |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
397 */ |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
398 static void IConsoleHistoryAdd(const char *cmd) |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
399 { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
400 free(_iconsole_history[ICON_HISTORY_SIZE - 1]); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
401 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
402 memmove(&_iconsole_history[1], &_iconsole_history[0], sizeof(_iconsole_history[0]) * (ICON_HISTORY_SIZE - 1)); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
403 _iconsole_history[0] = strdup(cmd); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
404 IConsoleResetHistoryPos(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
405 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
406 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
407 /** |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
408 * Navigate Up/Down in the history of typed commands |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
409 * @param direction Go further back in history (+1), go to recently typed commands (-1) |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
410 */ |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
411 static void IConsoleHistoryNavigate(int direction) |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
412 { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
413 int i = _iconsole_historypos + direction; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
414 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
415 /* watch out for overflows, just wrap around */ |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
416 if (i < 0) i = ICON_HISTORY_SIZE - 1; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
417 if (i >= ICON_HISTORY_SIZE) i = 0; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
418 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
419 if (direction > 0) { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
420 if (_iconsole_history[i] == NULL) i = 0; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
421 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
422 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
423 if (direction < 0) { |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
424 while (i > 0 && _iconsole_history[i] == NULL) i--; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
425 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
426 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
427 _iconsole_historypos = i; |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
428 IConsoleClearCommand(); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
429 /* copy history to 'command prompt / bash' */ |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
430 assert(_iconsole_history[i] != NULL && IsInsideMM(i, 0, ICON_HISTORY_SIZE)); |
10276
a5286e772120
(svn r14514) -Codechange: use 'size' instead of 'length' for querystring and textbuf, explicitly say it includes the terminating zero
smatz <smatz@openttd.org>
parents:
10238
diff
changeset
|
431 ttd_strlcpy(_iconsole_cmdline.buf, _iconsole_history[i], _iconsole_cmdline.maxsize); |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
432 UpdateTextBufferSize(&_iconsole_cmdline); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
433 } |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
434 |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
435 /** |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
436 * Handle the printing of text entered into the console or redirected there |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
9915
diff
changeset
|
437 * by any other means. Text can be redirected to other clients in a network game |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
438 * as well as to a logfile. If the network server is a dedicated server, all activities |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
439 * are also logged. All lines to print are added to a temporary buffer which can be |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
440 * used as a history to print them onscreen |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
11082
diff
changeset
|
441 * @param colour_code the colour of the command. Red in case of errors, etc. |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
442 * @param string the message entered or output on the console (notice, error, etc.) |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
443 */ |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
11082
diff
changeset
|
444 void IConsoleGUIPrint(ConsoleColour colour_code, char *str) |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
445 { |
11085
8da1855e9f14
(svn r15428) -Codechange: consistently use colour instead of having both color and colour.
rubidium <rubidium@openttd.org>
parents:
11082
diff
changeset
|
446 new IConsoleLine(str, (TextColour)colour_code); |
9339
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
447 SetWindowDirty(FindWindowById(WC_CONSOLE, 0)); |
030274da8619
(svn r13231) -Codechange: split the core console code and the console GUI.
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
448 } |