removed redundant check for the titles file.
This commit is contained in:
parent
b4113b82d2
commit
13f4044481
1 changed files with 87 additions and 72 deletions
|
@ -14,6 +14,13 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* these message titles are used for all sorts of in-game messages.
|
||||
* from beginning/end credits to instructions. they're messy as they do not
|
||||
* support localizations by design. you effectively just swap titles.txt files
|
||||
* out like pokemon cards.
|
||||
*/
|
||||
|
||||
typedef struct titles_s
|
||||
{
|
||||
string m_strName;
|
||||
|
@ -34,6 +41,7 @@ int g_titles_count;
|
|||
void
|
||||
Titles_Init(void)
|
||||
{
|
||||
/* messages in the file inherit the last defined effects etc. */
|
||||
float t_position[2];
|
||||
int t_effect;
|
||||
vector t_color;
|
||||
|
@ -57,80 +65,87 @@ Titles_Init(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (fs_titles >= 0) {
|
||||
while ((temp = fgets(fs_titles))) {
|
||||
c = tokenize_console(temp);
|
||||
if (c < 1) {
|
||||
continue;
|
||||
while ((temp = fgets(fs_titles))) {
|
||||
/* tons of comments/garbage in those files,
|
||||
* so tokenize appropriately */
|
||||
c = tokenize_console(temp);
|
||||
if (c < 1) {
|
||||
continue;
|
||||
}
|
||||
switch(argv(0)) {
|
||||
case "$position":
|
||||
t_position[0] = stof(argv(1));
|
||||
t_position[1] = stof(argv(2));
|
||||
break;
|
||||
case "$effect":
|
||||
t_effect = stoi(argv(1));
|
||||
break;
|
||||
case "$color":
|
||||
if (c == 4) {
|
||||
t_color[0] = stof(argv(1)) / 255;
|
||||
t_color[1] = stof(argv(2)) / 255;
|
||||
t_color[2] = stof(argv(3)) / 255;
|
||||
} else {
|
||||
t_color = stov(argv(1)) / 255;
|
||||
}
|
||||
switch(argv(0)) {
|
||||
case "$position":
|
||||
t_position[0] = stof(argv(1));
|
||||
t_position[1] = stof(argv(2));
|
||||
break;
|
||||
case "$effect":
|
||||
t_effect = stoi(argv(1));
|
||||
break;
|
||||
case "$color":
|
||||
if (c == 4) {
|
||||
t_color[0] = stof(argv(1)) / 255;
|
||||
t_color[1] = stof(argv(2)) / 255;
|
||||
t_color[2] = stof(argv(3)) / 255;
|
||||
} else {
|
||||
t_color = stov(argv(1)) / 255;
|
||||
}
|
||||
break;
|
||||
case "$color2":
|
||||
if (c == 4) {
|
||||
t_color2[0] = stof(argv(1)) / 255;
|
||||
t_color2[1] = stof(argv(2)) / 255;
|
||||
t_color2[2] = stof(argv(3)) / 255;
|
||||
} else {
|
||||
t_color2 = stov(argv(1)) / 255;
|
||||
}
|
||||
break;
|
||||
case "$fxtime":
|
||||
t_fxtime = stof(argv(1));
|
||||
break;
|
||||
case "$holdtime":
|
||||
t_holdtime = stof(argv(1));
|
||||
break;
|
||||
case "$fadein":
|
||||
t_fadein = stof(argv(1));
|
||||
break;
|
||||
case "$fadeout":
|
||||
t_fadeout = stof(argv(1));
|
||||
break;
|
||||
case "{":
|
||||
braced = TRUE;
|
||||
break;
|
||||
case "}":
|
||||
int id = g_titles_count - 1;
|
||||
braced = FALSE;
|
||||
g_titles[id].m_strName = t_name;
|
||||
g_titles[id].m_strMessage = t_message;
|
||||
g_titles[id].m_flPosX = t_position[0];
|
||||
g_titles[id].m_flPosY = t_position[1];
|
||||
g_titles[id].m_iEffect = t_effect;
|
||||
g_titles[id].m_vecColor1 = t_color;
|
||||
g_titles[id].m_vecColor2 = t_color2;
|
||||
g_titles[id].m_flFadeIn = t_fadein;
|
||||
g_titles[id].m_flFadeOut = t_fadeout;
|
||||
g_titles[id].m_flHoldTime = t_holdtime;
|
||||
g_titles[id].m_flFXTime = t_fxtime;
|
||||
t_message = "";
|
||||
t_name = "";
|
||||
break;
|
||||
default:
|
||||
if (braced) {
|
||||
t_message = sprintf("%s%s\n", t_message, temp);
|
||||
} else {
|
||||
t_name = strtoupper(argv(0));
|
||||
g_titles = memrealloc(g_titles, sizeof(titles_t), g_titles_count, ++g_titles_count);
|
||||
dprint(sprintf("[^1TITLES^7] Found ^2%s\n", t_name));
|
||||
}
|
||||
break;
|
||||
case "$color2":
|
||||
if (c == 4) {
|
||||
t_color2[0] = stof(argv(1)) / 255;
|
||||
t_color2[1] = stof(argv(2)) / 255;
|
||||
t_color2[2] = stof(argv(3)) / 255;
|
||||
} else {
|
||||
t_color2 = stov(argv(1)) / 255;
|
||||
}
|
||||
break;
|
||||
case "$fxtime":
|
||||
t_fxtime = stof(argv(1));
|
||||
break;
|
||||
case "$holdtime":
|
||||
t_holdtime = stof(argv(1));
|
||||
break;
|
||||
case "$fadein":
|
||||
t_fadein = stof(argv(1));
|
||||
break;
|
||||
case "$fadeout":
|
||||
t_fadeout = stof(argv(1));
|
||||
break;
|
||||
case "{":
|
||||
braced = TRUE;
|
||||
break;
|
||||
case "}":
|
||||
/* time to dump the info */
|
||||
int id = g_titles_count - 1;
|
||||
g_titles[id].m_strName = t_name;
|
||||
g_titles[id].m_strMessage = t_message;
|
||||
g_titles[id].m_flPosX = t_position[0];
|
||||
g_titles[id].m_flPosY = t_position[1];
|
||||
g_titles[id].m_iEffect = t_effect;
|
||||
g_titles[id].m_vecColor1 = t_color;
|
||||
g_titles[id].m_vecColor2 = t_color2;
|
||||
g_titles[id].m_flFadeIn = t_fadein;
|
||||
g_titles[id].m_flFadeOut = t_fadeout;
|
||||
g_titles[id].m_flHoldTime = t_holdtime;
|
||||
g_titles[id].m_flFXTime = t_fxtime;
|
||||
t_message = "";
|
||||
t_name = "";
|
||||
braced = FALSE;
|
||||
break;
|
||||
default:
|
||||
if (braced) {
|
||||
/* append string entry after another */
|
||||
t_message = sprintf("%s%s\n", t_message, temp);
|
||||
} else {
|
||||
/* name/identifer of our message */
|
||||
t_name = strtoupper(argv(0));
|
||||
g_titles =
|
||||
memrealloc(g_titles, sizeof(titles_t),
|
||||
g_titles_count,
|
||||
++g_titles_count);
|
||||
dprint(sprintf("[^1TITLES^7] Found ^2%s\n",
|
||||
t_name));
|
||||
}
|
||||
}
|
||||
fclose(fs_titles);
|
||||
}
|
||||
fclose(fs_titles);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue