Initial titles.txt support. Only env_message works with it right now.
This commit is contained in:
parent
7cc9a73cbd
commit
f4ae48b1b5
3 changed files with 160 additions and 13 deletions
|
@ -104,6 +104,7 @@ CSQC_Init(float apilevel, string enginename, float engineversion)
|
||||||
Client_Init(apilevel, enginename, engineversion);
|
Client_Init(apilevel, enginename, engineversion);
|
||||||
DSP_Init();
|
DSP_Init();
|
||||||
CSQC_RendererRestarted("init");
|
CSQC_RendererRestarted("init");
|
||||||
|
Titles_Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -729,18 +730,15 @@ CSQC_Ent_ParseMapEntity(void)
|
||||||
|
|
||||||
switch (strField) {
|
switch (strField) {
|
||||||
case "classname":
|
case "classname":
|
||||||
print(strcat("[CSQC] Spawnfunc search for ", strValue));
|
|
||||||
eEnt = (CBaseEntity)spawn();
|
eEnt = (CBaseEntity)spawn();
|
||||||
if (isfunction(strcat("spawnfunc_", strValue))) {
|
if (isfunction(strcat("spawnfunc_", strValue))) {
|
||||||
self = eEnt;
|
self = eEnt;
|
||||||
callfunction(strcat("spawnfunc_", strValue));
|
callfunction(strcat("spawnfunc_", strValue));
|
||||||
self = eOld;
|
self = eOld;
|
||||||
iClass = TRUE;
|
iClass = TRUE;
|
||||||
print(" [^2FOUND^7]");
|
|
||||||
} else {
|
} else {
|
||||||
eEnt.classname = strValue;
|
eEnt.classname = strValue;
|
||||||
}
|
}
|
||||||
print("\n");
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
__fullspawndata = sprintf("%s\"%s\" \"%s\" ",
|
__fullspawndata = sprintf("%s\"%s\" \"%s\" ",
|
||||||
|
|
|
@ -70,3 +70,11 @@ const vector VEC_PLAYER_CVIEWPOS = [0,0,12];
|
||||||
|
|
||||||
.float jumptime;
|
.float jumptime;
|
||||||
.float teleport_time;
|
.float teleport_time;
|
||||||
|
|
||||||
|
void* memrealloc( __variant *oldptr, int elementsize, int oldelements, int newelements )
|
||||||
|
{
|
||||||
|
void *n = memalloc( elementsize * newelements );
|
||||||
|
memcpy( n, oldptr, elementsize * min( oldelements, newelements ) );
|
||||||
|
memfree( oldptr );
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
|
@ -106,16 +106,42 @@ void GameText_Parse(void)
|
||||||
g_textchannels[chan].m_flTime = 0.0f;
|
g_textchannels[chan].m_flTime = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct titles_s
|
||||||
|
{
|
||||||
|
string m_strName;
|
||||||
|
string m_strMessage;
|
||||||
|
float m_flPosX;
|
||||||
|
float m_flPosY;
|
||||||
|
int m_iEffect;
|
||||||
|
vector m_vecColor1;
|
||||||
|
vector m_vecColor2;
|
||||||
|
float m_flFadeIn;
|
||||||
|
float m_flFadeOut;
|
||||||
|
float m_flHoldTime;
|
||||||
|
float m_flFXTime;
|
||||||
|
} titles_t;
|
||||||
|
static titles_t *g_titles;
|
||||||
|
static int g_titles_count;
|
||||||
|
|
||||||
void GameMessage_Parse(void)
|
void GameMessage_Parse(void)
|
||||||
{
|
{
|
||||||
string strSound;
|
string strSound;
|
||||||
float flVolume;
|
float flVolume;
|
||||||
int iAttenuation;
|
int iAttenuation;
|
||||||
|
string findme;
|
||||||
|
int findid = -1;
|
||||||
|
|
||||||
/* TODO: Fill in the other string data from titles.txt */
|
findme = readstring();
|
||||||
g_textchannels[0].m_strMessage = readstring();
|
|
||||||
|
for (int i = 0; i < g_titles_count; i++) {
|
||||||
|
if (g_titles[i].m_strName == findme) {
|
||||||
|
findid = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (findid < 0) {
|
||||||
|
g_textchannels[0].m_strMessage = findme;
|
||||||
g_textchannels[0].m_flTime = 0.0f;
|
g_textchannels[0].m_flTime = 0.0f;
|
||||||
|
|
||||||
g_textchannels[0].m_flPosX = -1;
|
g_textchannels[0].m_flPosX = -1;
|
||||||
g_textchannels[0].m_flPosY = 0.75f;
|
g_textchannels[0].m_flPosY = 0.75f;
|
||||||
g_textchannels[0].m_flFadeIn = 0.5f;
|
g_textchannels[0].m_flFadeIn = 0.5f;
|
||||||
|
@ -123,6 +149,17 @@ void GameMessage_Parse(void)
|
||||||
g_textchannels[0].m_flHoldTime = 4.0f;
|
g_textchannels[0].m_flHoldTime = 4.0f;
|
||||||
g_textchannels[0].m_vecColor1 = [1,1,1];
|
g_textchannels[0].m_vecColor1 = [1,1,1];
|
||||||
g_textchannels[0].m_vecColor2 = [1,1,1];
|
g_textchannels[0].m_vecColor2 = [1,1,1];
|
||||||
|
} else {
|
||||||
|
g_textchannels[0].m_strMessage = g_titles[findid].m_strMessage;
|
||||||
|
g_textchannels[0].m_flTime = 0.0f;
|
||||||
|
g_textchannels[0].m_flPosX = g_titles[findid].m_flPosX;
|
||||||
|
g_textchannels[0].m_flPosY = g_titles[findid].m_flPosY;
|
||||||
|
g_textchannels[0].m_flFadeIn = g_titles[findid].m_flFadeIn;
|
||||||
|
g_textchannels[0].m_flFadeOut = g_titles[findid].m_flFadeOut;
|
||||||
|
g_textchannels[0].m_flHoldTime = g_titles[findid].m_flHoldTime;
|
||||||
|
g_textchannels[0].m_vecColor1 = g_titles[findid].m_vecColor1;
|
||||||
|
g_textchannels[0].m_vecColor2 = g_titles[findid].m_vecColor2;
|
||||||
|
}
|
||||||
|
|
||||||
strSound = readstring();
|
strSound = readstring();
|
||||||
flVolume = readfloat();
|
flVolume = readfloat();
|
||||||
|
@ -130,3 +167,107 @@ void GameMessage_Parse(void)
|
||||||
|
|
||||||
sound(self, CHAN_ITEM, strSound, flVolume, iAttenuation);
|
sound(self, CHAN_ITEM, strSound, flVolume, iAttenuation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Titles_Init(void)
|
||||||
|
{
|
||||||
|
float t_position[2];
|
||||||
|
int t_effect;
|
||||||
|
vector t_color;
|
||||||
|
vector t_color2;
|
||||||
|
float t_fxtime;
|
||||||
|
float t_holdtime;
|
||||||
|
float t_fadein;
|
||||||
|
float t_fadeout;
|
||||||
|
string t_name = "";
|
||||||
|
string t_message = "";
|
||||||
|
|
||||||
|
filestream fs_titles;
|
||||||
|
string temp;
|
||||||
|
int c;
|
||||||
|
int braced;
|
||||||
|
|
||||||
|
fs_titles = fopen("titles.txt", FILE_READ);
|
||||||
|
|
||||||
|
if (fs_titles < 0) {
|
||||||
|
print("^1WARNING: ^7Could NOT load titles.lst");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fs_titles >= 0) {
|
||||||
|
while ((temp = fgets(fs_titles))) {
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
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 = argv(0);
|
||||||
|
g_titles = memrealloc(g_titles, sizeof(titles_t), g_titles_count, ++g_titles_count);
|
||||||
|
dprint(sprintf("[TITLES] Found %s\n", t_name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue