author | rubidium |
Fri, 23 Nov 2007 16:59:30 +0000 | |
branch | noai |
changeset 9722 | ebf0ece7d8f6 |
parent 9718 | f82a4facea8b |
child 9723 | eee46cb39750 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9574 | 3 |
/** @file texteff.cpp */ |
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" |
9599 | 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 "console.h" |
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
15 |
#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
|
16 |
#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
|
17 |
#include "table/sprites.h" |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9626
diff
changeset
|
18 |
#include "blitter/factory.hpp" |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
19 |
#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
|
20 |
#include "date.h" |
9629 | 21 |
#include "texteff.hpp" |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
22 |
#include "video/video_driver.hpp" |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
23 |
#include "transparency.h" |
0 | 24 |
|
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
|
25 |
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
|
26 |
MAX_TEXTMESSAGE_LENGTH = 200, |
9629 | 27 |
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
|
28 |
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
|
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; |
9629 | 38 |
uint64 params_1; |
39 |
uint64 params_2; |
|
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 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
44 |
struct ChatMessage { |
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 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
50 |
/* used for text effects */ |
9629 | 51 |
static TextEffect *_text_effect_list = NULL; |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
52 |
static uint16 _num_text_effects = INIT_NUM_TEXT_MESSAGES; |
0 | 53 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
54 |
/* used for chat window */ |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
55 |
static ChatMessage _chatmsg_list[MAX_CHAT_MESSAGES]; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
56 |
static bool _chatmessage_dirty = false; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
57 |
static bool _chatmessage_visible = false; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
58 |
|
4956
76db5a2689fc
(svn r6955) -Codechange: Change some variable names for _textmessage_box, and replace 5 different
Darkvater
parents:
4912
diff
changeset
|
59 |
/* 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
|
60 |
* the left and pixels from the bottom. The height is the maximum height */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
61 |
static const Oblong _chatmsg_box = {10, 30, 500, 150}; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
62 |
static uint8 _chatmessage_backup[150 * 500 * 6]; // (height * width) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
63 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
64 |
static inline uint GetChatMessageCount() |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
65 |
{ |
4959
828f9223446d
(svn r6958) -Fix (r6956): GCC warning (thx Tron) and a coding style forgotten in r6957
Darkvater
parents:
4958
diff
changeset
|
66 |
uint i; |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
67 |
|
4959
828f9223446d
(svn r6958) -Fix (r6956): GCC warning (thx Tron) and a coding style forgotten in r6957
Darkvater
parents:
4958
diff
changeset
|
68 |
for (i = 0; i < MAX_CHAT_MESSAGES; i++) { |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
69 |
if (_chatmsg_list[i].message[0] == '\0') break; |
4957
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 |
|
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
72 |
return i; |
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 |
|
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
75 |
/* 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
|
76 |
* @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
|
77 |
* @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
|
78 |
* @param message message itself in printf() style */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
79 |
void CDECL AddChatMessage(uint16 color, uint8 duration, const char *message, ...) |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
80 |
{ |
2455 | 81 |
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
|
82 |
const char *bufp; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
83 |
va_list va; |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
84 |
uint msg_count; |
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
85 |
uint16 lines; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
86 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
87 |
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
|
88 |
vsnprintf(buf, lengthof(buf), message, va); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
89 |
va_end(va); |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
90 |
|
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
|
91 |
|
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 |
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
|
93 |
|
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
94 |
/* Force linebreaks for strings that are too long */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
95 |
lines = GB(FormatStringLinebreaks(buf, _chatmsg_box.width - 8), 0, 16) + 1; |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
96 |
if (lines >= MAX_CHAT_MESSAGES) return; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
97 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
98 |
msg_count = GetChatMessageCount(); |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
99 |
/* 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
|
100 |
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
|
101 |
int i = lines - (MAX_CHAT_MESSAGES - msg_count); |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
102 |
memmove(&_chatmsg_list[0], &_chatmsg_list[i], sizeof(_chatmsg_list[0]) * (msg_count - i)); |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
103 |
msg_count = MAX_CHAT_MESSAGES - lines; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
104 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
105 |
|
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
106 |
for (bufp = buf; lines != 0; lines--) { |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
107 |
ChatMessage *cmsg = &_chatmsg_list[msg_count++]; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
108 |
ttd_strlcpy(cmsg->message, bufp, sizeof(cmsg->message)); |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
109 |
|
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
110 |
/* 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
|
111 |
* white for any additional lines */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
112 |
cmsg->color = (bufp == buf && color & IS_PALETTE_COLOR) ? color : (0x1D - 15) | IS_PALETTE_COLOR; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
113 |
cmsg->end_date = _date + duration; |
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
114 |
|
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
115 |
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
|
116 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
117 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
118 |
_chatmessage_dirty = true; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
119 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
120 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
121 |
void InitChatMessage() |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
122 |
{ |
2639 | 123 |
uint i; |
124 |
||
125 |
for (i = 0; i < MAX_CHAT_MESSAGES; i++) { |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
126 |
_chatmsg_list[i].message[0] = '\0'; |
2639 | 127 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
128 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
129 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
130 |
/** Hide the chatbox */ |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
131 |
void UndrawChatMessage() |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
132 |
{ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
133 |
if (_chatmessage_visible) { |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9626
diff
changeset
|
134 |
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
|
135 |
/* 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
|
136 |
* 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
|
137 |
* 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
|
138 |
* 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
|
139 |
* 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
|
140 |
* 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
|
141 |
* 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
|
142 |
* 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
|
143 |
* (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
|
144 |
*/ |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
145 |
|
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
146 |
if (_cursor.visible) { |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
147 |
if (_cursor.draw_pos.x + _cursor.draw_size.x >= _chatmsg_box.x && |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
148 |
_cursor.draw_pos.x <= _chatmsg_box.x + _chatmsg_box.width && |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
149 |
_cursor.draw_pos.y + _cursor.draw_size.y >= _screen.height - _chatmsg_box.y - _chatmsg_box.height && |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
150 |
_cursor.draw_pos.y <= _screen.height - _chatmsg_box.y) { |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
151 |
UndrawMouseCursor(); |
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 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
154 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
155 |
int x = _chatmsg_box.x; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
156 |
int y = _screen.height - _chatmsg_box.y - _chatmsg_box.height; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
157 |
int width = _chatmsg_box.width; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
158 |
int height = _chatmsg_box.height; |
9517 | 159 |
if (y < 0) { |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
160 |
height = max(height + y, min(_chatmsg_box.height, _screen.height)); |
9517 | 161 |
y = 0; |
162 |
} |
|
163 |
if (x + width >= _screen.width) { |
|
164 |
width = _screen.width - x; |
|
165 |
} |
|
9545 | 166 |
if (width <= 0 || height <= 0) return; |
9517 | 167 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
168 |
_chatmessage_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
|
169 |
/* Put our 'shot' back to the screen */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
170 |
blitter->CopyFromBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_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
|
171 |
/* And make sure it is updated next time */ |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
172 |
_video_driver->MakeDirty(x, y, width, height); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
173 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
174 |
_chatmessage_dirty = true; |
543
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 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
177 |
|
9574 | 178 |
/** Check if a message is expired every day */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
179 |
void ChatMessageDailyLoop() |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
180 |
{ |
2639 | 181 |
uint i; |
182 |
||
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
183 |
for (i = 0; i < MAX_CHAT_MESSAGES; i++) { |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
184 |
ChatMessage *cmsg = &_chatmsg_list[i]; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
185 |
if (cmsg->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
|
186 |
|
4957
8588d2e7f409
(svn r6956) -Feature: Increase the chatbuffer of chat messages. Messages longer than the allocated
Darkvater
parents:
4956
diff
changeset
|
187 |
/* Message has expired, remove from the list */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
188 |
if (cmsg->end_date < _date) { |
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
189 |
/* Move the remaining messages over the current message */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
190 |
if (i != MAX_CHAT_MESSAGES - 1) memmove(cmsg, cmsg + 1, sizeof(*cmsg) * (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
|
191 |
|
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
192 |
/* Mark the last item as empty */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
193 |
_chatmsg_list[MAX_CHAT_MESSAGES - 1].message[0] = '\0'; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
194 |
_chatmessage_dirty = true; |
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
195 |
|
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
196 |
/* 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
|
197 |
i--; |
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 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
201 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
202 |
/** Draw the chat message-box */ |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
203 |
void DrawChatMessage() |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
204 |
{ |
9628
b5c2449616b5
(svn r10195) [NoAI] -Sync: with trunk r10119:10194.
rubidium
parents:
9626
diff
changeset
|
205 |
Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
206 |
if (!_chatmessage_dirty) return; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
207 |
|
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
|
208 |
/* First undraw if needed */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
209 |
UndrawChatMessage(); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
210 |
|
4959
828f9223446d
(svn r6958) -Fix (r6956): GCC warning (thx Tron) and a coding style forgotten in r6957
Darkvater
parents:
4958
diff
changeset
|
211 |
if (_iconsole_mode == ICONSOLE_FULL) return; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
212 |
|
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
213 |
/* Check if we have anything to draw at all */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
214 |
uint count = GetChatMessageCount(); |
4960
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
215 |
if (count == 0) return; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
216 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
217 |
int x = _chatmsg_box.x; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
218 |
int y = _screen.height - _chatmsg_box.y - _chatmsg_box.height; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
219 |
int width = _chatmsg_box.width; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
220 |
int height = _chatmsg_box.height; |
9517 | 221 |
if (y < 0) { |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
222 |
height = max(height + y, min(_chatmsg_box.height, _screen.height)); |
9517 | 223 |
y = 0; |
224 |
} |
|
225 |
if (x + width >= _screen.width) { |
|
226 |
width = _screen.width - x; |
|
227 |
} |
|
9545 | 228 |
if (width <= 0 || height <= 0) return; |
229 |
||
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
230 |
assert(blitter->BufferSize(width, height) < (int)sizeof(_chatmessage_backup)); |
9629 | 231 |
|
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
|
232 |
/* Make a copy of the screen as it is before painting (for undraw) */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
233 |
blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, x, y), _chatmessage_backup, width, height); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
234 |
|
4960
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
235 |
_cur_dpi = &_screen; // switch to _screen painting |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
236 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
237 |
/* Paint a half-transparent box behind the chat messages */ |
4960
cb06aa866acb
(svn r6959) -Codechange: Move GfxFillRect() out of the chat-message drawing loop since we already
Darkvater
parents:
4959
diff
changeset
|
238 |
GfxFillRect( |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
239 |
_chatmsg_box.x, |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
240 |
_screen.height - _chatmsg_box.y - count * 13 - 2, |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
241 |
_chatmsg_box.x + _chatmsg_box.width - 1, |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
242 |
_screen.height - _chatmsg_box.y - 2, |
5919
2b58160d667d
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5838
diff
changeset
|
243 |
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
|
244 |
); |
1595
b1a8323c1024
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1569
diff
changeset
|
245 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
246 |
/* Paint the chat messages starting with the lowest at the bottom */ |
9517 | 247 |
for (uint y = 13; count-- != 0; y += 13) { |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
248 |
DoDrawString(_chatmsg_list[count].message, _chatmsg_box.x + 3, _screen.height - _chatmsg_box.y - y + 1, _chatmsg_list[count].color); |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
249 |
} |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
250 |
|
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
|
251 |
/* Make sure the data is updated next flush */ |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9629
diff
changeset
|
252 |
_video_driver->MakeDirty(x, y, width, height); |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
253 |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
254 |
_chatmessage_visible = true; |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9631
diff
changeset
|
255 |
_chatmessage_dirty = false; |
543
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
256 |
} |
e3b43338096b
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
534
diff
changeset
|
257 |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
258 |
/* Text Effects */ |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
259 |
/** |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
260 |
* Mark the area of the text effect as dirty. |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
261 |
* |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
262 |
* This function marks the area of a text effect as dirty for repaint. |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
263 |
* |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
264 |
* @param te The TextEffect to mark the area dirty |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
265 |
* @ingroup dirty |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
266 |
*/ |
0 | 267 |
static void MarkTextEffectAreaDirty(TextEffect *te) |
268 |
{ |
|
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
269 |
/* Width and height of the text effect are doubled, so they are correct in both zoom out levels 1x and 2x. */ |
0 | 270 |
MarkAllViewportsDirty( |
271 |
te->x, |
|
272 |
te->y - 1, |
|
273 |
(te->right - te->x)*2 + te->x + 1, |
|
274 |
(te->bottom - (te->y - 1)) * 2 + (te->y - 1) + 1 |
|
275 |
); |
|
276 |
} |
|
277 |
||
9629 | 278 |
TextEffectID AddTextEffect(StringID msg, int x, int y, uint16 duration, TextEffectMode mode) |
0 | 279 |
{ |
280 |
TextEffect *te; |
|
281 |
int w; |
|
282 |
char buffer[100]; |
|
9629 | 283 |
TextEffectID i; |
0 | 284 |
|
9629 | 285 |
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
|
286 |
|
9629 | 287 |
/* Look for a free spot in the text effect array */ |
288 |
for (i = 0; i < _num_text_effects; i++) { |
|
289 |
if (_text_effect_list[i].string_id == INVALID_STRING_ID) break; |
|
0 | 290 |
} |
291 |
||
9629 | 292 |
/* If there is none found, we grow the array */ |
293 |
if (i == _num_text_effects) { |
|
294 |
_num_text_effects += 25; |
|
295 |
_text_effect_list = (TextEffect*) realloc(_text_effect_list, _num_text_effects * sizeof(TextEffect)); |
|
296 |
for (; i < _num_text_effects; i++) _text_effect_list[i].string_id = INVALID_STRING_ID; |
|
297 |
i = _num_text_effects - 1; |
|
298 |
} |
|
299 |
||
300 |
te = &_text_effect_list[i]; |
|
301 |
||
302 |
/* Start defining this object */ |
|
0 | 303 |
te->string_id = msg; |
304 |
te->duration = duration; |
|
305 |
te->y = y - 5; |
|
306 |
te->bottom = y + 5; |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
425
diff
changeset
|
307 |
te->params_1 = GetDParam(0); |
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
425
diff
changeset
|
308 |
te->params_2 = GetDParam(4); |
9629 | 309 |
te->mode = mode; |
0 | 310 |
|
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4609
diff
changeset
|
311 |
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
|
312 |
w = GetStringBoundingBox(buffer).width; |
0 | 313 |
|
314 |
te->x = x - (w >> 1); |
|
315 |
te->right = x + (w >> 1) - 1; |
|
316 |
MarkTextEffectAreaDirty(te); |
|
9629 | 317 |
|
318 |
return i; |
|
319 |
} |
|
320 |
||
321 |
void UpdateTextEffect(TextEffectID te_id, StringID msg) |
|
322 |
{ |
|
323 |
assert(te_id < _num_text_effects); |
|
324 |
TextEffect *te; |
|
325 |
||
326 |
/* Update details */ |
|
327 |
te = &_text_effect_list[te_id]; |
|
328 |
te->string_id = msg; |
|
329 |
te->params_1 = GetDParam(0); |
|
330 |
te->params_2 = GetDParam(4); |
|
331 |
||
9703
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
332 |
/* Update width of text effect */ |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
333 |
char buffer[100]; |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
334 |
GetString(buffer, msg, lastof(buffer)); |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
335 |
int w = GetStringBoundingBox(buffer).width; |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
336 |
|
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
337 |
/* Only allow to make it broader, so it completely covers the old text. That avoids remnants of the old text. */ |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
338 |
int right_new = te->x + w; |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
339 |
if (te->right < right_new) te->right = right_new; |
d2a6acdbd665
(svn r11146) [NoAI] -Sync: with trunk r11035:11045.
rubidium
parents:
9701
diff
changeset
|
340 |
|
9629 | 341 |
MarkTextEffectAreaDirty(te); |
342 |
} |
|
343 |
||
344 |
void RemoveTextEffect(TextEffectID te_id) |
|
345 |
{ |
|
346 |
assert(te_id < _num_text_effects); |
|
347 |
TextEffect *te; |
|
348 |
||
349 |
te = &_text_effect_list[te_id]; |
|
350 |
MarkTextEffectAreaDirty(te); |
|
351 |
te->string_id = INVALID_STRING_ID; |
|
0 | 352 |
} |
353 |
||
354 |
static void MoveTextEffect(TextEffect *te) |
|
355 |
{ |
|
9629 | 356 |
/* Never expire for duration of 0xFFFF */ |
357 |
if (te->duration == 0xFFFF) return; |
|
0 | 358 |
if (te->duration < 8) { |
2470 | 359 |
te->string_id = INVALID_STRING_ID; |
0 | 360 |
} else { |
2549 | 361 |
te->duration -= 8; |
0 | 362 |
te->y--; |
363 |
te->bottom--; |
|
364 |
} |
|
365 |
MarkTextEffectAreaDirty(te); |
|
366 |
} |
|
367 |
||
6573 | 368 |
void MoveAllTextEffects() |
0 | 369 |
{ |
9629 | 370 |
for (TextEffectID i = 0; i < _num_text_effects; i++) { |
371 |
TextEffect *te = &_text_effect_list[i]; |
|
372 |
if (te->string_id != INVALID_STRING_ID && te->mode == TE_RISING) MoveTextEffect(te); |
|
0 | 373 |
} |
374 |
} |
|
375 |
||
6573 | 376 |
void InitTextEffects() |
0 | 377 |
{ |
9629 | 378 |
if (_text_effect_list == NULL) _text_effect_list = MallocT<TextEffect>(_num_text_effects); |
0 | 379 |
|
9629 | 380 |
for (TextEffectID i = 0; i < _num_text_effects; i++) _text_effect_list[i].string_id = INVALID_STRING_ID; |
0 | 381 |
} |
382 |
||
383 |
void DrawTextEffects(DrawPixelInfo *dpi) |
|
384 |
{ |
|
4469 | 385 |
switch (dpi->zoom) { |
9624 | 386 |
case ZOOM_LVL_NORMAL: |
9629 | 387 |
for (TextEffectID i = 0; i < _num_text_effects; i++) { |
388 |
TextEffect *te = &_text_effect_list[i]; |
|
4469 | 389 |
if (te->string_id != INVALID_STRING_ID && |
390 |
dpi->left <= te->right && |
|
391 |
dpi->top <= te->bottom && |
|
392 |
dpi->left + dpi->width > te->x && |
|
393 |
dpi->top + dpi->height > te->y) { |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
394 |
if (te->mode == TE_RISING || (_patches.loading_indicators && !IsTransparencySet(TO_LOADING))) { |
9629 | 395 |
AddStringToDraw(te->x, te->y, te->string_id, te->params_1, te->params_2); |
396 |
} |
|
4469 | 397 |
} |
398 |
} |
|
399 |
break; |
|
0 | 400 |
|
9624 | 401 |
case ZOOM_LVL_OUT_2X: |
9629 | 402 |
for (TextEffectID i = 0; i < _num_text_effects; i++) { |
403 |
TextEffect *te = &_text_effect_list[i]; |
|
4469 | 404 |
if (te->string_id != INVALID_STRING_ID && |
405 |
dpi->left <= te->right * 2 - te->x && |
|
406 |
dpi->top <= te->bottom * 2 - te->y && |
|
407 |
dpi->left + dpi->width > te->x && |
|
408 |
dpi->top + dpi->height > te->y) { |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9718
diff
changeset
|
409 |
if (te->mode == TE_RISING || (_patches.loading_indicators && !IsTransparencySet(TO_LOADING))) { |
9629 | 410 |
AddStringToDraw(te->x, te->y, (StringID)(te->string_id - 1), te->params_1, te->params_2); |
411 |
} |
|
4469 | 412 |
} |
413 |
} |
|
414 |
break; |
|
9624 | 415 |
|
416 |
case ZOOM_LVL_OUT_4X: |
|
417 |
case ZOOM_LVL_OUT_8X: |
|
418 |
break; |
|
419 |
||
420 |
default: NOT_REACHED(); |
|
0 | 421 |
} |
422 |
} |
|
423 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
424 |
/** The table/list with animated tiles. */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
425 |
TileIndex *_animated_tile_list = NULL; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
426 |
/** The number of animated tiles in the current state. */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
427 |
uint _animated_tile_count = 0; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
428 |
/** The number of slots for animated tiles allocated currently. */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
429 |
static uint _animated_tile_allocated = 0; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
430 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
431 |
/** |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
432 |
* Removes the given tile from the animated tile table. |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
433 |
* @param tile the tile to remove |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
434 |
*/ |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
435 |
void DeleteAnimatedTile(TileIndex tile) |
0 | 436 |
{ |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
437 |
for (TileIndex *ti = _animated_tile_list; ti < _animated_tile_list + _animated_tile_count; ti++) { |
1977
4392ae3d8e31
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
438 |
if (tile == *ti) { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
439 |
/* Remove the hole |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
440 |
* The order of the remaining elements must stay the same, otherwise the animation loop |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
441 |
* may miss a tile; that's why we must use memmove instead of just moving the last element. |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
442 |
*/ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
443 |
memmove(ti, ti + 1, (_animated_tile_list + _animated_tile_count - (ti + 1)) * sizeof(*ti)); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
444 |
_animated_tile_count--; |
0 | 445 |
MarkTileDirtyByTile(tile); |
446 |
return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
447 |
} |
0 | 448 |
} |
449 |
} |
|
450 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
451 |
/** |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
452 |
* Add the given tile to the animated tile table (if it does not exist |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
453 |
* on that table yet). Also increases the size of the table if necessary. |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
454 |
* @param tile the tile to make animated |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
455 |
*/ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
456 |
void AddAnimatedTile(TileIndex tile) |
0 | 457 |
{ |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
458 |
MarkTileDirtyByTile(tile); |
0 | 459 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
460 |
for (const TileIndex *ti = _animated_tile_list; ti < _animated_tile_list + _animated_tile_count; ti++) { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
461 |
if (tile == *ti) return; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
0
diff
changeset
|
462 |
} |
0 | 463 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
464 |
/* Table not large enough, so make it larger */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
465 |
if (_animated_tile_count == _animated_tile_allocated) { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
466 |
_animated_tile_allocated *= 2; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
467 |
_animated_tile_list = ReallocT<TileIndex>(_animated_tile_list, _animated_tile_allocated); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
468 |
} |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
469 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
470 |
_animated_tile_list[_animated_tile_count] = tile; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
471 |
_animated_tile_count++; |
0 | 472 |
} |
473 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
474 |
/** |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
475 |
* Animate all tiles in the animated tile list, i.e.\ call AnimateTile on them. |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
476 |
*/ |
6573 | 477 |
void AnimateAnimatedTiles() |
0 | 478 |
{ |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
479 |
const TileIndex *ti = _animated_tile_list; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
480 |
while (ti < _animated_tile_list + _animated_tile_count) { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
481 |
const TileIndex curr = *ti; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
482 |
AnimateTile(curr); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
483 |
/* During the AnimateTile call, DeleteAnimatedTile could have been called, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
484 |
* deleting an element we've already processed and pushing the rest one |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
485 |
* slot to the left. We can detect this by checking whether the index |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
486 |
* in the current slot has changed - if it has, an element has been deleted, |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
487 |
* and we should process the current slot again instead of going forward. |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
488 |
* NOTE: this will still break if more than one animated tile is being |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
489 |
* deleted during the same AnimateTile call, but no code seems to |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
490 |
* be doing this anyway. |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
491 |
*/ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
492 |
if (*ti == curr) ++ti; |
0 | 493 |
} |
494 |
} |
|
495 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
496 |
/** |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
497 |
* Initialize all animated tile variables to some known begin point |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
498 |
*/ |
6573 | 499 |
void InitializeAnimatedTiles() |
0 | 500 |
{ |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
501 |
_animated_tile_list = ReallocT<TileIndex>(_animated_tile_list, 256); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
502 |
_animated_tile_count = 0; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
503 |
_animated_tile_allocated = 256; |
0 | 504 |
} |
505 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
506 |
/** |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
507 |
* Save the ANIT chunk. |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
508 |
*/ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
509 |
static void Save_ANIT() |
0 | 510 |
{ |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
511 |
SlSetLength(_animated_tile_count * sizeof(*_animated_tile_list)); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
512 |
SlArray(_animated_tile_list, _animated_tile_count, SLE_UINT32); |
0 | 513 |
} |
514 |
||
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
515 |
/** |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
516 |
* Load the ANIT chunk; the chunk containing the animated tiles. |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
517 |
*/ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
518 |
static void Load_ANIT() |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
519 |
{ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
520 |
/* Before version 80 we did NOT have a variable length animated tile table */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
521 |
if (CheckSavegameVersion(80)) { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
522 |
/* In pre version 6, we has 16bit per tile, now we have 32bit per tile, convert it ;) */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
523 |
SlArray(_animated_tile_list, 256, CheckSavegameVersion(6) ? (SLE_FILE_U16 | SLE_VAR_U32) : SLE_UINT32); |
0 | 524 |
|
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
525 |
for (_animated_tile_count = 0; _animated_tile_count < 256; _animated_tile_count++) { |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
526 |
if (_animated_tile_list[_animated_tile_count] == 0) break; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
527 |
} |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
528 |
return; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
529 |
} |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
530 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
531 |
_animated_tile_count = SlGetFieldLength() / sizeof(*_animated_tile_list); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
532 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
533 |
/* Determine a nice rounded size for the amount of allocated tiles */ |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
534 |
_animated_tile_allocated = 256; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
535 |
while (_animated_tile_allocated < _animated_tile_count) _animated_tile_allocated *= 2; |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
536 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
537 |
_animated_tile_list = ReallocT<TileIndex>(_animated_tile_list, _animated_tile_allocated); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
538 |
SlArray(_animated_tile_list, _animated_tile_count, SLE_UINT32); |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
539 |
} |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
540 |
|
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
541 |
/** |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
542 |
* "Definition" imported by the saveload code to be able to load and save |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
543 |
* the animated tile table. |
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
544 |
*/ |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
545 |
extern const ChunkHandler _animated_tile_chunk_handlers[] = { |
9718
f82a4facea8b
(svn r11309) [NoAI] -Sync: with trunk r11145:11308.
truelight
parents:
9703
diff
changeset
|
546 |
{ 'ANIT', Save_ANIT, Load_ANIT, CH_RIFF | CH_LAST}, |
0 | 547 |
}; |