author | truelight |
Thu, 21 Jun 2007 16:17:47 +0000 | |
changeset 7494 | 99eac2a2cd8b |
parent 7484 | cdf0450632a1 |
child 7502 | 71f5d2c6a605 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6700
diff
changeset
|
3 |
/** @file texteff.cpp */ |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6700
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1881
diff
changeset
|
6 |
#include "openttd.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2153
diff
changeset
|
7 |
#include "functions.h" |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
8 |
#include "macros.h" |
1309
dab90d4cbf2d
(svn r1813) Declare functions implemented in strings.c in their own shiny new header (though i think some of these function don't belong into strings.c)
tron
parents:
1174
diff
changeset
|
9 |
#include "strings.h" |
0 | 10 |
#include "gfx.h" |
6949
72d11a1e1e60
(svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents:
6918
diff
changeset
|
11 |
#include "landscape.h" |
0 | 12 |
#include "viewport.h" |
13 |
#include "saveload.h" |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
14 |
#include "hal.h" |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
15 |
#include "console.h" |
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
16 |
#include "string.h" |
2153
91e89aa8c299
(svn r2663) Include variables.h only in these files which need it, not globally via openttd.h
tron
parents:
2062
diff
changeset
|
17 |
#include "variables.h" |
2218
abd47ef7d902
(svn r2736) -Codechange: De-mystified GfxDrawFillRect a bit, and used enums from table/sprites.h. You can now change the number of bits used for sprites and switches in the SpriteSetup enum and the rest should work automagically. Can be used to increase the number of active sprites to 2^19 in case there are no colortables (recolor sprites) in any newgrf. We should possibly move the the colortables to an own list, but how to detect them in a newgrf.
celestar
parents:
2186
diff
changeset
|
18 |
#include "table/sprites.h" |
7433
8e410e7ec0d7
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
7374
diff
changeset
|
19 |
#include "blitter/factory.hpp" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
20 |
#include <stdarg.h> /* va_list */ |
4261
2ec8f5a9747b
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
2685
diff
changeset
|
21 |
#include "date.h" |
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
22 |
#include "texteff.hpp" |
0 | 23 |
|
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
24 |
enum { |
6541
ff575414f0d2
(svn r9012) -Fix/Feature (UTF8): When cutting strings into multiple lines also take into consideration whitespace characters of more than 1 byte length (eg IDEOGRAPHIC SPACE, IsWhitespace() function). When trimming such strings, account for multiple-byte long sequences so use *Utf8PrevChar(v) = '\0'.
Darkvater
parents:
5919
diff
changeset
|
25 |
MAX_TEXTMESSAGE_LENGTH = 200, |
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
26 |
INIT_NUM_TEXT_MESSAGES = 20, |
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
27 |
MAX_CHAT_MESSAGES = 10, |
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
28 |
MAX_ANIMATED_TILES = 256, |
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
29 |
}; |
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
30 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
31 |
struct TextEffect { |
0 | 32 |
StringID string_id; |
849
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
33 |
int32 x; |
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
34 |
int32 y; |
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
35 |
int32 right; |
c6223dbdb202
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
tron
parents:
835
diff
changeset
|
36 |
int32 bottom; |
0 | 37 |
uint16 duration; |
38 |
uint32 params_1; |
|
39 |
uint32 params_2; |
|
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
40 |
TextEffectMode mode; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
41 |
}; |
0 | 42 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
43 |
|
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
44 |
struct TextMessage { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
45 |
char message[MAX_TEXTMESSAGE_LENGTH]; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
46 |
uint16 color; |
4363
3a3a2a3dda00
(svn r6078) -Fix: forgot one uint16 -> Date conversion. Tnx to #openttdcoop team for detecting and Rubidium for finding the cause.
truelight
parents:
4261
diff
changeset
|
47 |
Date end_date; |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6573
diff
changeset
|
48 |
}; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
49 |
|
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
50 |
static TextEffect *_text_effect_list = NULL; |
4956
76db5a2689fc
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
51 |
static TextMessage _textmsg_list[MAX_CHAT_MESSAGES]; |
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
52 |
TileIndex _animated_tile_list[MAX_ANIMATED_TILES]; |
0 | 53 |
|
4956
76db5a2689fc
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
54 |
static bool _textmessage_dirty = false; |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2470
diff
changeset
|
55 |
static bool _textmessage_visible = false; |
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
56 |
static uint16 _num_text_effects = INIT_NUM_TEXT_MESSAGES; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
57 |
|
4956
76db5a2689fc
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
58 |
/* The chatbox grows from the bottom so the coordinates are pixels from |
76db5a2689fc
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
59 |
* the left and pixels from the bottom. The height is the maximum height */ |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
60 |
static const Oblong _textmsg_box = {10, 30, 500, 150}; |
7484
cdf0450632a1
(svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents:
7481
diff
changeset
|
61 |
static uint8 _textmessage_backup[150 * 500 * 6]; // (height * width) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
62 |
|
6573 | 63 |
static inline uint GetTextMessageCount() |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
64 |
{ |
4959
828f9223446d
(svn r6958) -Fix (r6956): GCC warning (thx Tron) and a coding style forgotten in r6957
Darkvater
parents:
4958
diff
changeset
|
65 |
uint i; |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
66 |
|
4959
828f9223446d
(svn r6958) -Fix (r6956): GCC warning (thx Tron) and a coding style forgotten in r6957
Darkvater
parents:
4958
diff
changeset
|
67 |
for (i = 0; i < MAX_CHAT_MESSAGES; i++) { |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
68 |
if (_textmsg_list[i].message[0] == '\0') break; |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
69 |
} |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
70 |
|
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
71 |
return i; |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
72 |
} |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
73 |
|
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
74 |
/* Add a text message to the 'chat window' to be shown |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
75 |
* @param color The colour this message is to be shown in |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
76 |
* @param duration The duration of the chat message in game-days |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
77 |
* @param message message itself in printf() style */ |
1022
9ea8ee93d6a9
(svn r1523) -Fix: somehow mousewheel was disabled on windows using SDL; reenabled again
darkvater
parents:
849
diff
changeset
|
78 |
void CDECL AddTextMessage(uint16 color, uint8 duration, const char *message, ...) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
79 |
{ |
2455 | 80 |
char buf[MAX_TEXTMESSAGE_LENGTH]; |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
81 |
const char *bufp; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
82 |
va_list va; |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
83 |
uint msg_count; |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
84 |
uint16 lines; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
85 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
86 |
va_start(va, message); |
2373
f06403621870
(svn r2899) -Fix: Several format string vulnerabilities and buffer overflows in the network code
tron
parents:
2295
diff
changeset
|
87 |
vsnprintf(buf, lengthof(buf), message, va); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
88 |
va_end(va); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
89 |
|
6541
ff575414f0d2
(svn r9012) -Fix/Feature (UTF8): When cutting strings into multiple lines also take into consideration whitespace characters of more than 1 byte length (eg IDEOGRAPHIC SPACE, IsWhitespace() function). When trimming such strings, account for multiple-byte long sequences so use *Utf8PrevChar(v) = '\0'.
Darkvater
parents:
5919
diff
changeset
|
90 |
|
ff575414f0d2
(svn r9012) -Fix/Feature (UTF8): When cutting strings into multiple lines also take into consideration whitespace characters of more than 1 byte length (eg IDEOGRAPHIC SPACE, IsWhitespace() function). When trimming such strings, account for multiple-byte long sequences so use *Utf8PrevChar(v) = '\0'.
Darkvater
parents:
5919
diff
changeset
|
91 |
Utf8TrimString(buf, MAX_TEXTMESSAGE_LENGTH); |
ff575414f0d2
(svn r9012) -Fix/Feature (UTF8): When cutting strings into multiple lines also take into consideration whitespace characters of more than 1 byte length (eg IDEOGRAPHIC SPACE, IsWhitespace() function). When trimming such strings, account for multiple-byte long sequences so use *Utf8PrevChar(v) = '\0'.
Darkvater
parents:
5919
diff
changeset
|
92 |
|
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
93 |
/* Force linebreaks for strings that are too long */ |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
94 |
lines = GB(FormatStringLinebreaks(buf, _textmsg_box.width - 8), 0, 16) + 1; |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
95 |
if (lines >= MAX_CHAT_MESSAGES) return; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
96 |
|
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
97 |
msg_count = GetTextMessageCount(); |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
98 |
/* We want to add more chat messages than there is free space for, remove 'old' */ |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
99 |
if (lines > MAX_CHAT_MESSAGES - msg_count) { |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
100 |
int i = lines - (MAX_CHAT_MESSAGES - msg_count); |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
101 |
memmove(&_textmsg_list[0], &_textmsg_list[i], sizeof(_textmsg_list[0]) * (msg_count - i)); |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
102 |
msg_count = MAX_CHAT_MESSAGES - lines; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
103 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
104 |
|
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
105 |
for (bufp = buf; lines != 0; lines--) { |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
106 |
TextMessage *tmsg = &_textmsg_list[msg_count++]; |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
107 |
ttd_strlcpy(tmsg->message, bufp, sizeof(tmsg->message)); |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
108 |
|
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
109 |
/* The default colour for a message is player colour. Replace this with |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
110 |
* white for any additional lines */ |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
111 |
tmsg->color = (bufp == buf && color & IS_PALETTE_COLOR) ? color : (0x1D - 15) | IS_PALETTE_COLOR; |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
112 |
tmsg->end_date = _date + duration; |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
113 |
|
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
114 |
bufp += strlen(bufp) + 1; // jump to 'next line' in the formatted string |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
115 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
116 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
117 |
_textmessage_dirty = true; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
118 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
119 |
|
6573 | 120 |
void InitTextMessage() |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
121 |
{ |
2639 | 122 |
uint i; |
123 |
||
124 |
for (i = 0; i < MAX_CHAT_MESSAGES; i++) { |
|
4956
76db5a2689fc
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
125 |
_textmsg_list[i].message[0] = '\0'; |
2639 | 126 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
127 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
128 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6700
diff
changeset
|
129 |
/** Hide the textbox */ |
6573 | 130 |
void UndrawTextMessage() |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
131 |
{ |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
132 |
if (_textmessage_visible) { |
7433
8e410e7ec0d7
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
7374
diff
changeset
|
133 |
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); |
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
134 |
/* Sometimes we also need to hide the cursor |
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
135 |
* This is because both textmessage and the cursor take a shot of the |
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
136 |
* screen before drawing. |
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
137 |
* Now the textmessage takes his shot and paints his data before the cursor |
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
138 |
* does, so in the shot of the cursor is the screen-data of the textmessage |
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
139 |
* included when the cursor hangs somewhere over the textmessage. To |
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
140 |
* avoid wrong repaints, we undraw the cursor in that case, and everything |
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
141 |
* looks nicely ;) |
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
142 |
* (and now hope this story above makes sense to you ;)) |
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
143 |
*/ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
144 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
145 |
if (_cursor.visible) { |
4956
76db5a2689fc
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
146 |
if (_cursor.draw_pos.x + _cursor.draw_size.x >= _textmsg_box.x && |
76db5a2689fc
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
147 |
_cursor.draw_pos.x <= _textmsg_box.x + _textmsg_box.width && |
76db5a2689fc
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
148 |
_cursor.draw_pos.y + _cursor.draw_size.y >= _screen.height - _textmsg_box.y - _textmsg_box.height && |
76db5a2689fc
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
149 |
_cursor.draw_pos.y <= _screen.height - _textmsg_box.y) { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
150 |
UndrawMouseCursor(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
151 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
152 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
153 |
|
6692
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
154 |
int x = _textmsg_box.x; |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
155 |
int y = _screen.height - _textmsg_box.y - _textmsg_box.height; |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
156 |
int width = _textmsg_box.width; |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
157 |
int height = _textmsg_box.height; |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
158 |
if (y < 0) { |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
159 |
height = max(height + y, min(_textmsg_box.height, _screen.height)); |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
160 |
y = 0; |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
161 |
} |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
162 |
if (x + width >= _screen.width) { |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
163 |
width = _screen.width - x; |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
164 |
} |
6700
0cee66ecb04a
(svn r9437) -Fix (r9420): dedicated server crashed when the y part of the resolution was less than 10.
rubidium
parents:
6692
diff
changeset
|
165 |
if (width <= 0 || height <= 0) return; |
6692
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
166 |
|
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
167 |
_textmessage_visible = false; |
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
168 |
/* Put our 'shot' back to the screen */ |
7481
699607d457a0
(svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents:
7433
diff
changeset
|
169 |
blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _textmessage_backup, width, height); |
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
170 |
/* And make sure it is updated next time */ |
6692
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
171 |
_video_driver->make_dirty(x, y, width, height); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
172 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
173 |
_textmessage_dirty = true; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
174 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
175 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
176 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6700
diff
changeset
|
177 |
/** Check if a message is expired every day */ |
6573 | 178 |
void TextMessageDailyLoop() |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
179 |
{ |
2639 | 180 |
uint i; |
181 |
||
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
182 |
for (i = 0; i < MAX_CHAT_MESSAGES; i++) { |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
183 |
TextMessage *tmsg = &_textmsg_list[i]; |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
184 |
if (tmsg->message[0] == '\0') continue; |
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
185 |
|
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
186 |
/* Message has expired, remove from the list */ |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
187 |
if (tmsg->end_date < _date) { |
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
188 |
/* Move the remaining messages over the current message */ |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
189 |
if (i != MAX_CHAT_MESSAGES - 1) memmove(tmsg, tmsg + 1, sizeof(*tmsg) * (MAX_CHAT_MESSAGES - i - 1)); |
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
190 |
|
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
191 |
/* Mark the last item as empty */ |
4956
76db5a2689fc
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
192 |
_textmsg_list[MAX_CHAT_MESSAGES - 1].message[0] = '\0'; |
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
193 |
_textmessage_dirty = true; |
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
194 |
|
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
195 |
/* Go one item back, because we moved the array 1 to the left */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
196 |
i--; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
197 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
198 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
199 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
200 |
|
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6700
diff
changeset
|
201 |
/** Draw the textmessage-box */ |
6573 | 202 |
void DrawTextMessage() |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
203 |
{ |
7433
8e410e7ec0d7
(svn r10190) -Codechange: merged renderer and blitter to one single class API: blitter
truelight
parents:
7374
diff
changeset
|
204 |
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); |
2639 | 205 |
if (!_textmessage_dirty) return; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
206 |
|
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
207 |
/* First undraw if needed */ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
208 |
UndrawTextMessage(); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
209 |
|
4959
828f9223446d
(svn r6958) -Fix (r6956): GCC warning (thx Tron) and a coding style forgotten in r6957
Darkvater
parents:
4958
diff
changeset
|
210 |
if (_iconsole_mode == ICONSOLE_FULL) return; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
211 |
|
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
212 |
/* Check if we have anything to draw at all */ |
6692
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
213 |
uint count = GetTextMessageCount(); |
4960
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
214 |
if (count == 0) return; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
215 |
|
6692
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
216 |
int x = _textmsg_box.x; |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
217 |
int y = _screen.height - _textmsg_box.y - _textmsg_box.height; |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
218 |
int width = _textmsg_box.width; |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
219 |
int height = _textmsg_box.height; |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
220 |
if (y < 0) { |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
221 |
height = max(height + y, min(_textmsg_box.height, _screen.height)); |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
222 |
y = 0; |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
223 |
} |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
224 |
if (x + width >= _screen.width) { |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
225 |
width = _screen.width - x; |
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
226 |
} |
6700
0cee66ecb04a
(svn r9437) -Fix (r9420): dedicated server crashed when the y part of the resolution was less than 10.
rubidium
parents:
6692
diff
changeset
|
227 |
if (width <= 0 || height <= 0) return; |
0cee66ecb04a
(svn r9437) -Fix (r9420): dedicated server crashed when the y part of the resolution was less than 10.
rubidium
parents:
6692
diff
changeset
|
228 |
|
7481
699607d457a0
(svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents:
7433
diff
changeset
|
229 |
assert(blitter->BufferSize(width, height) < (int)sizeof(_textmessage_backup)); |
699607d457a0
(svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents:
7433
diff
changeset
|
230 |
|
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
231 |
/* Make a copy of the screen as it is before painting (for undraw) */ |
7481
699607d457a0
(svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents:
7433
diff
changeset
|
232 |
blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _textmessage_backup, width, height); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
233 |
|
4960
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
234 |
_cur_dpi = &_screen; // switch to _screen painting |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
235 |
|
4960
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
236 |
/* Paint a half-transparent box behind the text messages */ |
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
237 |
GfxFillRect( |
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
238 |
_textmsg_box.x, |
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
239 |
_screen.height - _textmsg_box.y - count * 13 - 2, |
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
240 |
_textmsg_box.x + _textmsg_box.width - 1, |
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
241 |
_screen.height - _textmsg_box.y - 2, |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
242 |
PALETTE_TO_TRANSPARENT | (1 << USE_COLORTABLE) // black, but with some alpha for background |
4960
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
243 |
); |
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
244 |
|
4960
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
245 |
/* Paint the messages starting with the lowest at the bottom */ |
6692
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
246 |
for (uint y = 13; count-- != 0; y += 13) { |
4960
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
247 |
DoDrawString(_textmsg_list[count].message, _textmsg_box.x + 3, _screen.height - _textmsg_box.y - y + 1, _textmsg_list[count].color); |
6988
76eba6a9cc6f
(svn r9673) -Cleanup: remove spaces before tabs and replace non-indenting tabs with spaces.
rubidium
parents:
6949
diff
changeset
|
248 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
249 |
|
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
250 |
/* Make sure the data is updated next flush */ |
6692
983dbcb48cac
(svn r9420) -Fix [FS#701]: crashes when the chatbox would be drawn outside of the main window.
rubidium
parents:
6574
diff
changeset
|
251 |
_video_driver->make_dirty(x, y, width, height); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
252 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
253 |
_textmessage_visible = true; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
254 |
_textmessage_dirty = false; |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
255 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
256 |
|
0 | 257 |
static void MarkTextEffectAreaDirty(TextEffect *te) |
258 |
{ |
|
259 |
MarkAllViewportsDirty( |
|
260 |
te->x, |
|
261 |
te->y - 1, |
|
262 |
(te->right - te->x)*2 + te->x + 1, |
|
263 |
(te->bottom - (te->y - 1)) * 2 + (te->y - 1) + 1 |
|
264 |
); |
|
265 |
} |
|
266 |
||
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
267 |
TextEffectID AddTextEffect(StringID msg, int x, int y, uint16 duration, TextEffectMode mode) |
0 | 268 |
{ |
269 |
TextEffect *te; |
|
270 |
int w; |
|
271 |
char buffer[100]; |
|
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
272 |
TextEffectID i; |
0 | 273 |
|
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
274 |
if (_game_mode == GM_MENU) return INVALID_TE_ID; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
275 |
|
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
276 |
/* Look for a free spot in the text effect array */ |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
277 |
for (i = 0; i < _num_text_effects; i++) { |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
278 |
if (_text_effect_list[i].string_id == INVALID_STRING_ID) break; |
0 | 279 |
} |
280 |
||
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
281 |
/* If there is none found, we grow the array */ |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
282 |
if (i == _num_text_effects) { |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
283 |
_num_text_effects += 25; |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
284 |
_text_effect_list = (TextEffect*) realloc(_text_effect_list, _num_text_effects * sizeof(TextEffect)); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
285 |
for (; i < _num_text_effects; i++) _text_effect_list[i].string_id = INVALID_STRING_ID; |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
286 |
i = _num_text_effects - 1; |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
287 |
} |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
288 |
|
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
289 |
te = &_text_effect_list[i]; |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
290 |
|
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
291 |
/* Start defining this object */ |
0 | 292 |
te->string_id = msg; |
293 |
te->duration = duration; |
|
294 |
te->y = y - 5; |
|
295 |
te->bottom = y + 5; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
425
diff
changeset
|
296 |
te->params_1 = GetDParam(0); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
425
diff
changeset
|
297 |
te->params_2 = GetDParam(4); |
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
298 |
te->mode = mode; |
0 | 299 |
|
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4609
diff
changeset
|
300 |
GetString(buffer, msg, lastof(buffer)); |
4609
6c337b3fbf4b
(svn r6462) -Codechange: Have GetStringWidth() return width as well as the height bounding
Darkvater
parents:
4469
diff
changeset
|
301 |
w = GetStringBoundingBox(buffer).width; |
0 | 302 |
|
303 |
te->x = x - (w >> 1); |
|
304 |
te->right = x + (w >> 1) - 1; |
|
305 |
MarkTextEffectAreaDirty(te); |
|
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
306 |
|
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
307 |
return i; |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
308 |
} |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
309 |
|
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
310 |
void UpdateTextEffect(TextEffectID te_id, StringID msg) |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
311 |
{ |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
312 |
assert(te_id < _num_text_effects); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
313 |
TextEffect *te; |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
314 |
|
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
315 |
/* Update details */ |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
316 |
te = &_text_effect_list[te_id]; |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
317 |
te->string_id = msg; |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
318 |
te->params_1 = GetDParam(0); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
319 |
te->params_2 = GetDParam(4); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
320 |
|
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
321 |
MarkTextEffectAreaDirty(te); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
322 |
} |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
323 |
|
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
324 |
void RemoveTextEffect(TextEffectID te_id) |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
325 |
{ |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
326 |
assert(te_id < _num_text_effects); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
327 |
TextEffect *te; |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
328 |
|
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
329 |
te = &_text_effect_list[te_id]; |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
330 |
MarkTextEffectAreaDirty(te); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
331 |
te->string_id = INVALID_STRING_ID; |
0 | 332 |
} |
333 |
||
334 |
static void MoveTextEffect(TextEffect *te) |
|
335 |
{ |
|
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
336 |
/* Never expire for duration of 0xFFFF */ |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
337 |
if (te->duration == 0xFFFF) return; |
0 | 338 |
if (te->duration < 8) { |
2470 | 339 |
te->string_id = INVALID_STRING_ID; |
0 | 340 |
} else { |
2549 | 341 |
te->duration -= 8; |
0 | 342 |
te->y--; |
343 |
te->bottom--; |
|
344 |
} |
|
345 |
MarkTextEffectAreaDirty(te); |
|
346 |
} |
|
347 |
||
6573 | 348 |
void MoveAllTextEffects() |
0 | 349 |
{ |
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
350 |
for (TextEffectID i = 0; i < _num_text_effects; i++) { |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
351 |
TextEffect *te = &_text_effect_list[i]; |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
352 |
if (te->string_id != INVALID_STRING_ID && te->mode == TE_RISING) MoveTextEffect(te); |
0 | 353 |
} |
354 |
} |
|
355 |
||
6573 | 356 |
void InitTextEffects() |
0 | 357 |
{ |
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
358 |
if (_text_effect_list == NULL) _text_effect_list = MallocT<TextEffect>(_num_text_effects); |
0 | 359 |
|
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
360 |
for (TextEffectID i = 0; i < _num_text_effects; i++) _text_effect_list[i].string_id = INVALID_STRING_ID; |
0 | 361 |
} |
362 |
||
363 |
void DrawTextEffects(DrawPixelInfo *dpi) |
|
364 |
{ |
|
4469 | 365 |
switch (dpi->zoom) { |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6988
diff
changeset
|
366 |
case ZOOM_LVL_NORMAL: |
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
367 |
for (TextEffectID i = 0; i < _num_text_effects; i++) { |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
368 |
TextEffect *te = &_text_effect_list[i]; |
4469 | 369 |
if (te->string_id != INVALID_STRING_ID && |
370 |
dpi->left <= te->right && |
|
371 |
dpi->top <= te->bottom && |
|
372 |
dpi->left + dpi->width > te->x && |
|
373 |
dpi->top + dpi->height > te->y) { |
|
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
374 |
if (te->mode == TE_RISING || (_patches.loading_indicators && !HASBIT(_transparent_opt, TO_LOADING))) { |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
375 |
AddStringToDraw(te->x, te->y, te->string_id, te->params_1, te->params_2); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
376 |
} |
4469 | 377 |
} |
378 |
} |
|
379 |
break; |
|
0 | 380 |
|
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6988
diff
changeset
|
381 |
case ZOOM_LVL_OUT_2X: |
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
382 |
for (TextEffectID i = 0; i < _num_text_effects; i++) { |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
383 |
TextEffect *te = &_text_effect_list[i]; |
4469 | 384 |
if (te->string_id != INVALID_STRING_ID && |
385 |
dpi->left <= te->right * 2 - te->x && |
|
386 |
dpi->top <= te->bottom * 2 - te->y && |
|
387 |
dpi->left + dpi->width > te->x && |
|
388 |
dpi->top + dpi->height > te->y) { |
|
7494
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
389 |
if (te->mode == TE_RISING || (_patches.loading_indicators && !HASBIT(_transparent_opt, TO_LOADING))) { |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
390 |
AddStringToDraw(te->x, te->y, (StringID)(te->string_id - 1), te->params_1, te->params_2); |
99eac2a2cd8b
(svn r10254) -Feature: loading indicator, which shows in % how full a vehicle is while loading/unloading (TheJosh)
truelight
parents:
7484
diff
changeset
|
391 |
} |
4469 | 392 |
} |
393 |
} |
|
394 |
break; |
|
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6988
diff
changeset
|
395 |
|
7122
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
396 |
case ZOOM_LVL_OUT_4X: |
7149
ba2798e551a3
(svn r9884) -Feature: 2 new zoom-out levels: 8 times and 16 times
truelight
parents:
7122
diff
changeset
|
397 |
case ZOOM_LVL_OUT_8X: |
7120
e31767effc16
(svn r9844) -Codechange: replace zoomlevel with an enum
truelight
parents:
6988
diff
changeset
|
398 |
break; |
7122
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
399 |
|
0607a15aedc0
(svn r9846) -Codechange: introduced ZOOM_LVL_MIN and ZOOM_LVL_MAX for the obvious reasons
truelight
parents:
7120
diff
changeset
|
400 |
default: NOT_REACHED(); |
0 | 401 |
} |
402 |
} |
|
403 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
404 |
void DeleteAnimatedTile(TileIndex tile) |
0 | 405 |
{ |
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
406 |
TileIndex *ti; |
0 | 407 |
|
2549 | 408 |
for (ti = _animated_tile_list; ti != endof(_animated_tile_list); ti++) { |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
409 |
if (tile == *ti) { |
0 | 410 |
/* remove the hole */ |
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
411 |
memmove(ti, ti + 1, (lastof(_animated_tile_list) - ti) * sizeof(*ti)); |
0 | 412 |
/* and clear last item */ |
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
413 |
*lastof(_animated_tile_list) = 0; |
0 | 414 |
MarkTileDirtyByTile(tile); |
415 |
return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
416 |
} |
0 | 417 |
} |
418 |
} |
|
419 |
||
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
420 |
bool AddAnimatedTile(TileIndex tile) |
0 | 421 |
{ |
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
422 |
TileIndex *ti; |
0 | 423 |
|
2549 | 424 |
for (ti = _animated_tile_list; ti != endof(_animated_tile_list); ti++) { |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
425 |
if (tile == *ti || *ti == 0) { |
0 | 426 |
*ti = tile; |
427 |
MarkTileDirtyByTile(tile); |
|
428 |
return true; |
|
429 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
430 |
} |
0 | 431 |
|
432 |
return false; |
|
433 |
} |
|
434 |
||
6573 | 435 |
void AnimateAnimatedTiles() |
0 | 436 |
{ |
2549 | 437 |
const TileIndex* ti; |
0 | 438 |
|
2549 | 439 |
for (ti = _animated_tile_list; ti != endof(_animated_tile_list) && *ti != 0; ti++) { |
440 |
AnimateTile(*ti); |
|
0 | 441 |
} |
442 |
} |
|
443 |
||
6573 | 444 |
void InitializeAnimatedTiles() |
0 | 445 |
{ |
446 |
memset(_animated_tile_list, 0, sizeof(_animated_tile_list)); |
|
447 |
} |
|
448 |
||
6573 | 449 |
static void SaveLoad_ANIT() |
0 | 450 |
{ |
5679
a478b04c1fd0
(svn r7632) -Codechange: several small code cleanups of texteff, like moving magic values and defines to an enum and fix coding/documentation style.
rubidium
parents:
5678
diff
changeset
|
451 |
/* In pre version 6, we has 16bit per tile, now we have 32bit per tile, convert it ;) */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2639
diff
changeset
|
452 |
if (CheckSavegameVersion(6)) { |
1881
023a134a4b12
(svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents:
1595
diff
changeset
|
453 |
SlArray(_animated_tile_list, lengthof(_animated_tile_list), SLE_FILE_U16 | SLE_VAR_U32); |
2549 | 454 |
} else { |
1174
27e386195965
(svn r1676) Increase the size of TileIndex and TileIndexDiff to 32bits and adapt the save/load data and some other parts of the code to that change
tron
parents:
1093
diff
changeset
|
455 |
SlArray(_animated_tile_list, lengthof(_animated_tile_list), SLE_UINT32); |
2549 | 456 |
} |
0 | 457 |
} |
458 |
||
459 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
460 |
extern const ChunkHandler _animated_tile_chunk_handlers[] = { |
0 | 461 |
{ 'ANIT', SaveLoad_ANIT, SaveLoad_ANIT, CH_RIFF | CH_LAST}, |
462 |
}; |