func_button: Add support for the 'OnPressed' output.

This commit is contained in:
Marco Cawthorne 2020-11-27 03:03:39 +01:00
parent a6b192a2c7
commit 2418480af4
5 changed files with 25 additions and 4 deletions

View file

@ -0,0 +1,8 @@
{
diffusemap textures/dev/model_bone.tga
{
map $diffuse
blendFunc blend
}
}

View file

@ -48,5 +48,3 @@ Sound_ParseLoopingEntity(entity sndent, float isNew)
}
sound(new, CHAN_VOICE, new.m_strSample, new.m_flVolume, new.m_flAttn, new.m_flPitch);
}

View file

@ -94,6 +94,9 @@ class func_button:CBaseTrigger
string m_strSndPressed;
string m_strSndUnpressed;
/* input/output */
string m_strOnPressed;
virtual void(void) Respawn;
virtual void(void) Arrived;
virtual void(void) Returned;
@ -214,7 +217,11 @@ func_button::Trigger(entity act, int state)
Sound_Play(this, CHAN_VOICE, m_strSndPressed);
MoveAway();
UseTargets(act, TRIG_TOGGLE, m_flDelay);
if (m_strOnPressed)
UseOutput(act, m_strOnPressed);
else
UseTargets(act, TRIG_TOGGLE, m_flDelay);
}
void
@ -366,6 +373,11 @@ func_button::SpawnKey(string strKey, string strValue)
case "wait":
m_flWait = stof(strValue);
break;
/* input/output */
case "OnPressed":
strValue = strreplace(",", ",_", strValue);
m_strOnPressed = strcat(m_strOnPressed, ",_", strValue);
break;
/* compatibility */
case "sounds":
m_strSndPressed = sprintf("func_button.hlsfx_%i", stoi(strValue) + 1i);
@ -387,4 +399,8 @@ func_button::func_button(void)
if (m_strSndUnpressed)
Sound_Precache(m_strSndUnpressed);
/* input/output */
if (m_strOnPressed)
m_strOnPressed = CreateOutput(m_strOnPressed);
}

View file

@ -16,7 +16,6 @@
/*QUAKED info_intermission (1 0 0) (-8 -8 -8) (8 8 8)
"targetname" Name
"targetname" Target entity to aim towards
An entity that's used to create an 'Intermission' camera.
Some mods use this while displaying the final scores, once a timelimit