func_button: Sound shader support, yee. Also cut down on some unnecessary code.
This commit is contained in:
parent
0d38fc1400
commit
f9ee04f6cf
4 changed files with 139 additions and 102 deletions
101
platform/data.pk3dir/sound/func_button.sndshd
Normal file
101
platform/data.pk3dir/sound/func_button.sndshd
Normal file
|
@ -0,0 +1,101 @@
|
|||
func_button.qsfx_1
|
||||
{
|
||||
sample buttons/airbut1.wav
|
||||
}
|
||||
func_button.qsfx_2
|
||||
{
|
||||
sample buttons/switch21.wav
|
||||
}
|
||||
func_button.qsfx_3
|
||||
{
|
||||
sample buttons/switch02.wav
|
||||
}
|
||||
func_button.qsfx_4
|
||||
{
|
||||
sample buttons/switch04.wav
|
||||
}
|
||||
|
||||
func_button.hlsfx_1
|
||||
{
|
||||
sample common/null.wav
|
||||
}
|
||||
func_button.hlsfx_2
|
||||
{
|
||||
sample buttons/button1.wav
|
||||
}
|
||||
func_button.hlsfx_3
|
||||
{
|
||||
sample buttons/button2.wav
|
||||
}
|
||||
func_button.hlsfx_4
|
||||
{
|
||||
sample buttons/button3.wav
|
||||
}
|
||||
func_button.hlsfx_5
|
||||
{
|
||||
sample buttons/button4.wav
|
||||
}
|
||||
func_button.hlsfx_6
|
||||
{
|
||||
sample buttons/button5.wav
|
||||
}
|
||||
func_button.hlsfx_7
|
||||
{
|
||||
sample buttons/button6.wav
|
||||
}
|
||||
func_button.hlsfx_8
|
||||
{
|
||||
sample buttons/button7.wav
|
||||
}
|
||||
func_button.hlsfx_9
|
||||
{
|
||||
sample buttons/button8.wav
|
||||
}
|
||||
func_button.hlsfx_10
|
||||
{
|
||||
sample buttons/button9.wav
|
||||
}
|
||||
func_button.hlsfx_11
|
||||
{
|
||||
sample buttons/button10.wav
|
||||
}
|
||||
func_button.hlsfx_12
|
||||
{
|
||||
sample buttons/button11.wav
|
||||
}
|
||||
func_button.hlsfx_13
|
||||
{
|
||||
sample buttons/latchlocked1.wav
|
||||
}
|
||||
func_button.hlsfx_14
|
||||
{
|
||||
sample buttons/latchunlocked1.wav
|
||||
}
|
||||
func_button.hlsfx_15
|
||||
{
|
||||
sample buttons/lightswitch2.wav
|
||||
}
|
||||
func_button.hlsfx_16
|
||||
{
|
||||
sample buttons/lever1.wav
|
||||
}
|
||||
func_button.hlsfx_17
|
||||
{
|
||||
sample buttons/lever2.wav
|
||||
}
|
||||
func_button.hlsfx_18
|
||||
{
|
||||
sample buttons/lever3.wav
|
||||
}
|
||||
func_button.hlsfx_19
|
||||
{
|
||||
sample buttons/lever4.wav
|
||||
}
|
||||
func_button.hlsfx_20
|
||||
{
|
||||
sample buttons/lever5.wav
|
||||
}
|
||||
func_button.hlsfx_21
|
||||
{
|
||||
sample buttons/button9.wav
|
||||
}
|
|
@ -46,37 +46,6 @@ When SF_BTT_TOUCH_ONLY is set, the use key/button cannot be used to interact
|
|||
with the button, it has to collide against a player.
|
||||
*/
|
||||
|
||||
/* compatibility */
|
||||
string g_q1button_src[4] = {
|
||||
"buttons/airbut1.wav",
|
||||
"buttons/switch21.wav",
|
||||
"buttons/switch02.wav",
|
||||
"buttons/switch04.wav"
|
||||
};
|
||||
string g_hlbutton_sfx[21] = {
|
||||
"common/null.wav",
|
||||
"buttons/button1.wav",
|
||||
"buttons/button2.wav",
|
||||
"buttons/button3.wav",
|
||||
"buttons/button4.wav",
|
||||
"buttons/button5.wav",
|
||||
"buttons/button6.wav",
|
||||
"buttons/button7.wav",
|
||||
"buttons/button8.wav",
|
||||
"buttons/button9.wav",
|
||||
"buttons/button10.wav",
|
||||
"buttons/button11.wav",
|
||||
"buttons/latchlocked1.wav",
|
||||
"buttons/latchunlocked1.wav",
|
||||
"buttons/lightswitch2.wav",
|
||||
"buttons/lever1.wav",
|
||||
"buttons/lever2.wav",
|
||||
"buttons/lever3.wav",
|
||||
"buttons/lever4.wav",
|
||||
"buttons/lever5.wav",
|
||||
"buttons/button9.wav"
|
||||
};
|
||||
|
||||
enumflags
|
||||
{
|
||||
SF_BTT_NOMOVE,
|
||||
|
@ -118,10 +87,7 @@ class func_button:CBaseTrigger
|
|||
float m_flWait;
|
||||
float m_flDelay;
|
||||
vector m_vecMoveDir;
|
||||
virtual void(void) m_pMove = 0;
|
||||
|
||||
/* full-path versus sound-shaders */
|
||||
int m_iSoundCompat;
|
||||
string m_strSndPressed;
|
||||
string m_strSndUnpressed;
|
||||
|
||||
|
@ -138,13 +104,16 @@ class func_button:CBaseTrigger
|
|||
|
||||
virtual void(void) SetMovementDirection;
|
||||
virtual void(vector, void(void)) MoveToDestination;
|
||||
virtual void(void) MoveToDestination_End;
|
||||
virtual void(string, string) SpawnKey;
|
||||
};
|
||||
|
||||
void
|
||||
func_button::Arrived(void)
|
||||
{
|
||||
SetOrigin(m_vecDest);
|
||||
velocity = [0,0,0];
|
||||
nextthink = 0;
|
||||
|
||||
m_iState = STATE_RAISED;
|
||||
|
||||
if (spawnflags & SF_BTT_TOUCH_ONLY) {
|
||||
|
@ -166,6 +135,10 @@ func_button::Arrived(void)
|
|||
void
|
||||
func_button::Returned(void)
|
||||
{
|
||||
SetOrigin(m_vecDest);
|
||||
velocity = [0,0,0];
|
||||
nextthink = 0;
|
||||
|
||||
if (spawnflags & SF_BTT_TOUCH_ONLY) {
|
||||
touch = Touch;
|
||||
}
|
||||
|
@ -182,10 +155,7 @@ func_button::MoveBack(void)
|
|||
m_iValue = 0;
|
||||
|
||||
if (m_strSndUnpressed) {
|
||||
if (m_iSoundCompat)
|
||||
sound(this, CHAN_VOICE, m_strSndUnpressed, 1.0, ATTN_NORM);
|
||||
else
|
||||
Sound_Play(this, CHAN_VOICE, m_strSndUnpressed);
|
||||
Sound_Play(this, CHAN_VOICE, m_strSndUnpressed);
|
||||
}
|
||||
|
||||
if (m_vecPos2 != m_vecPos1) {
|
||||
|
@ -237,12 +207,8 @@ func_button::Trigger(entity act, int state)
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_strSndPressed) {
|
||||
if (m_iSoundCompat)
|
||||
sound(this, CHAN_VOICE, m_strSndPressed, 1.0, ATTN_NORM);
|
||||
else
|
||||
Sound_Play(this, CHAN_VOICE, m_strSndPressed);
|
||||
}
|
||||
if (m_strSndPressed)
|
||||
Sound_Play(this, CHAN_VOICE, m_strSndPressed);
|
||||
|
||||
MoveAway();
|
||||
|
||||
|
@ -307,15 +273,6 @@ func_button::SetMovementDirection(void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
func_button::MoveToDestination_End(void)
|
||||
{
|
||||
SetOrigin(m_vecDest);
|
||||
velocity = [0,0,0];
|
||||
nextthink = -1;
|
||||
m_pMove();
|
||||
}
|
||||
|
||||
void
|
||||
func_button::MoveToDestination(vector vecDest, void(void) func)
|
||||
{
|
||||
|
@ -326,9 +283,8 @@ func_button::MoveToDestination(vector vecDest, void(void) func)
|
|||
objerror("No speed defined for moving entity! Will not divide by zero.");
|
||||
}
|
||||
|
||||
m_pMove = func;
|
||||
m_vecDest = vecDest;
|
||||
think = MoveToDestination_End;
|
||||
think = func;
|
||||
|
||||
if (vecDest == origin) {
|
||||
velocity = [0,0,0];
|
||||
|
@ -417,10 +373,7 @@ func_button::SpawnKey(string strKey, string strValue)
|
|||
break;
|
||||
/* compatibility */
|
||||
case "sounds":
|
||||
int sfx;
|
||||
sfx = stoi(strValue);
|
||||
m_strSndPressed = g_hlbutton_sfx[sfx];
|
||||
m_iSoundCompat = TRUE;
|
||||
m_strSndPressed = sprintf("func_button.hlsfx_%i", stoi(strValue) + 1i);
|
||||
break;
|
||||
default:
|
||||
CBaseTrigger::SpawnKey(strKey, strValue);
|
||||
|
@ -431,18 +384,10 @@ void
|
|||
func_button::func_button(void)
|
||||
{
|
||||
CBaseTrigger::CBaseTrigger();
|
||||
|
||||
if (m_strSndPressed) {
|
||||
if (m_iSoundCompat)
|
||||
precache_sound(m_strSndPressed);
|
||||
else
|
||||
Sound_Precache(m_strSndPressed);
|
||||
}
|
||||
|
||||
if (m_strSndUnpressed) {
|
||||
if (m_iSoundCompat)
|
||||
precache_sound(m_strSndUnpressed);
|
||||
else
|
||||
Sound_Precache(m_strSndUnpressed);
|
||||
}
|
||||
if (m_strSndPressed)
|
||||
Sound_Precache(m_strSndPressed);
|
||||
|
||||
if (m_strSndUnpressed)
|
||||
Sound_Precache(m_strSndUnpressed);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,6 @@ class func_door:CBaseTrigger
|
|||
void(void) func_door;
|
||||
virtual void(void) SetMovementDirection;
|
||||
virtual void(vector, void(void) func) MoveToDestination;
|
||||
virtual void(void) MoveToDestination_End;
|
||||
virtual void(void) MoveAway;
|
||||
virtual void(void) MoveBack;
|
||||
virtual void(void) Arrived;
|
||||
|
@ -103,7 +102,6 @@ class func_door:CBaseTrigger
|
|||
virtual void(void) Touch;
|
||||
virtual void(void) Use;
|
||||
virtual void(string, string) SpawnKey;
|
||||
virtual void(void) m_pMove = 0;
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -116,6 +114,10 @@ func_door::Use(void)
|
|||
void
|
||||
func_door::Arrived(void)
|
||||
{
|
||||
SetOrigin(m_vecDest);
|
||||
velocity = [0,0,0];
|
||||
nextthink = 0.0f;
|
||||
|
||||
m_iState = DOORSTATE_RAISED;
|
||||
|
||||
if (m_strSndStop) {
|
||||
|
@ -148,6 +150,10 @@ func_door::Arrived(void)
|
|||
void
|
||||
func_door::Returned(void)
|
||||
{
|
||||
SetOrigin(m_vecDest);
|
||||
velocity = [0,0,0];
|
||||
nextthink = 0.0f;
|
||||
|
||||
if (m_strSndStop) {
|
||||
Sound_Play(this, CHAN_VOICE, m_strSndStop);
|
||||
} else {
|
||||
|
@ -286,15 +292,6 @@ func_door::SetMovementDirection(void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
func_door::MoveToDestination_End(void)
|
||||
{
|
||||
SetOrigin(m_vecDest);
|
||||
velocity = [0,0,0];
|
||||
nextthink = -1;
|
||||
m_pMove();
|
||||
}
|
||||
|
||||
void
|
||||
func_door::MoveToDestination(vector vecDest, void(void) func)
|
||||
{
|
||||
|
@ -307,9 +304,8 @@ func_door::MoveToDestination(vector vecDest, void(void) func)
|
|||
return;
|
||||
}
|
||||
|
||||
m_pMove = func;
|
||||
m_vecDest = vecDest;
|
||||
think = MoveToDestination_End;
|
||||
think = func;
|
||||
|
||||
if (vecDest == origin) {
|
||||
velocity = [0,0,0];
|
||||
|
@ -353,8 +349,7 @@ func_door::Respawn(void)
|
|||
SetOrigin(m_oldOrigin);
|
||||
blocked = Blocked;
|
||||
think = __NULL__;
|
||||
nextthink = 0;
|
||||
m_pMove = 0;
|
||||
nextthink = 0.0f;
|
||||
|
||||
/* FIXME: Is this correct? */
|
||||
if (m_flWait == -1) {
|
||||
|
|
|
@ -56,7 +56,6 @@ class func_door_rotating:CBaseTrigger
|
|||
vector m_vecPos1;
|
||||
vector m_vecPos2;
|
||||
vector m_vecMoveDir;
|
||||
virtual void(void) m_pMove = 0;
|
||||
|
||||
void(void) func_door_rotating;
|
||||
virtual void(void) Respawn;
|
||||
|
@ -70,7 +69,6 @@ class func_door_rotating:CBaseTrigger
|
|||
virtual void(void) Blocked;
|
||||
virtual void(void) SetMovementDirection;
|
||||
virtual void(vector angle, void(void) func) RotToDest;
|
||||
virtual void(void) RotToDest_End;
|
||||
virtual void(string, string) SpawnKey;
|
||||
|
||||
#ifdef GS_BULLET_PHYSICS
|
||||
|
@ -91,6 +89,10 @@ void func_door_rotating::Unhinge(void)
|
|||
|
||||
void func_door_rotating::Arrived(void)
|
||||
{
|
||||
SetAngles(m_vecDest);
|
||||
avelocity = [0,0,0];
|
||||
nextthink = 0.0f;
|
||||
|
||||
m_iState = STATE_RAISED;
|
||||
|
||||
if (m_strSndStop) {
|
||||
|
@ -112,6 +114,10 @@ void func_door_rotating::Arrived(void)
|
|||
|
||||
void func_door_rotating::Returned(void)
|
||||
{
|
||||
SetAngles(m_vecDest);
|
||||
avelocity = [0,0,0];
|
||||
nextthink = 0.0f;
|
||||
|
||||
if (!(spawnflags & SF_ROT_USE)) {
|
||||
touch = Touch;
|
||||
}
|
||||
|
@ -272,14 +278,6 @@ void func_door_rotating::SetMovementDirection(void)
|
|||
}
|
||||
}
|
||||
|
||||
void func_door_rotating::RotToDest_End(void)
|
||||
{
|
||||
SetAngles(m_vecDest);
|
||||
avelocity = [0,0,0];
|
||||
nextthink = -1;
|
||||
m_pMove();
|
||||
}
|
||||
|
||||
void func_door_rotating::RotToDest(vector vDestAngle, void(void) func)
|
||||
{
|
||||
vector vecAngleDifference;
|
||||
|
@ -296,8 +294,7 @@ void func_door_rotating::RotToDest(vector vDestAngle, void(void) func)
|
|||
flTravelTime = (flTravelLength / m_flSpeed);
|
||||
avelocity = (vecAngleDifference * (1 / flTravelTime));
|
||||
m_vecDest = vDestAngle;
|
||||
m_pMove = func;
|
||||
think = RotToDest_End;
|
||||
think = func;
|
||||
nextthink = (ltime + flTravelTime);
|
||||
}
|
||||
|
||||
|
@ -316,8 +313,7 @@ void func_door_rotating::Respawn(void)
|
|||
SetModel(m_oldModel);
|
||||
SetOrigin(m_oldOrigin);
|
||||
think = __NULL__;
|
||||
nextthink = 0;
|
||||
m_pMove = 0;
|
||||
nextthink = 0.0f;
|
||||
avelocity = [0,0,0];
|
||||
|
||||
blocked = Blocked;
|
||||
|
|
Loading…
Reference in a new issue