Skip to content

Commit

Permalink
Add keybinds for different speech volumes #887 (#992)
Browse files Browse the repository at this point in the history
* function declaration for #887

* Revert "function declaration for #887"

This reverts commit 7b24165.

* function definition for #887

* functions code for #887

* keybind definitions and constants for #887

* scancode definitions for new keybinds in #887

* didn't need to maintain pressed state after all


Former-commit-id: cdc79969b9f492a608da54e2d37be40eda80555e [formerly 51e3f7df4bdd82e5458cdafa1227a4a2293cba1e] [formerly ea6a968a14463b41b6799a25d4cfc03644b927cf [formerly 2269f41c4a0a126ef9eb1300d7a25b327992c9e4]] [formerly 1ead95ae89c6bb52492096c377e0d49e9c45f6d8 [formerly 09bacff7e72dfc248892b7af55fb1f8fa4b5de98] [formerly eb8bbbf5d27d4744010423a337b0932c30424d41 [formerly e1ff1a16053dbd9d83ac9a2cbddc92e7fa512f0e]]]
Former-commit-id: ea7a04203adcf3d7811b18f23ef6dcfe12ecca52 [formerly e115af6322f0dbc73468842ef7f670b610372268] [formerly 89c65d3937eb8951baf0bab33336ae49bb8db9ab [formerly bee8d8e30a089553b692a2a0c9028a6c45f2fb66]]
Former-commit-id: 23c15924c4fcc58df2e329ac16ce94f9be9d6f93 [formerly ca51a2b38bce86db092520d5e765d5c119a57cf2]
Former-commit-id: 48abf138c26b670e0aab1fa453a3ad9a251995e1
  • Loading branch information
ACyprus authored and kavinsky committed Sep 23, 2016
1 parent 391f289 commit dbc78d8
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class CfgFunctions
class onSwTangentPressedHack;
class onSwTangentReleasedHack;
class onSpeakVolumeChange;
class onSpeakVolumeModifierPressed;
class onSpeakVolumeModifierReleased;
class onSwDialogOpen;
class onLRDialogOpen;
class onDDDialogOpen;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ disableSerialization;

["TFAR","ChangeSpeakingVolume",["Change Speaking Volume","Change Speaking Volume"],{call TFAR_fnc_onSpeakVolumeChange},{true},[TF_speak_volume_scancode, TF_speak_volume_modifiers],false] call cba_fnc_addKeybind;

["TFAR", "YellingModifier", ["Yelling Modifier", "Yelling Modifier"], {["yelling"] call TFAR_fnc_onSpeakVolumeModifierPressed}, {call TFAR_fnc_onSpeakVolumeModifierReleased}, [TF_speak_volume_modifier_yelling_scancode, TF_speak_volume_modifier_yelling_modifiers], false] call cba_fnc_addKeybind;
["TFAR", "WhisperingModifier", ["Whispering Modifier", "Whispering Modifier"], {["whispering"] call TFAR_fnc_onSpeakVolumeModifierPressed}, {call TFAR_fnc_onSpeakVolumeModifierReleased}, [TF_speak_volume_modifier_whispering_scancode, TF_speak_volume_modifier_whispering_modifiers], false] call cba_fnc_addKeybind;

["TFAR","CycleSWRadios",["Cycle >> SW Radios","Cycle >> SW Radios"],{true},{["next"] call TFAR_fnc_processSWCycleKeys},[TF_sw_cycle_next_scancode, TF_sw_cycle_next_modifiers],false] call cba_fnc_addKeybind;
["TFAR","CycleSWRadios",["Cycle << SW Radios","Cycle << SW Radios"],{true},{["prev"] call TFAR_fnc_processSWCycleKeys},[TF_sw_cycle_prev_scancode, TF_sw_cycle_prev_modifiers],false] call cba_fnc_addKeybind;
["TFAR","CycleLRRadios",["Cycle >> LR Radios","Cycle >> LR Radios"],{true},{["next"] call TFAR_fnc_processLRCycleKeys},[TF_lr_cycle_next_scancode, TF_lr_cycle_next_modifiers],false] call cba_fnc_addKeybind;
Expand Down Expand Up @@ -223,9 +226,13 @@ TF_dd_frequency = nil;
TF_speakerDistance = 20;
TF_speak_volume_level = "normal";
TF_speak_volume_meters = 20;
TF_min_voice_volume = 5;
TF_max_voice_volume = 60;
TF_sw_dialog_radio = nil;

TF_last_speak_volume_level = TF_speak_volume_level;
TF_last_speak_volume_meters = TF_speak_volume_meters;

TF_lr_dialog_radio = nil;
TF_lr_active_radio = nil;
TF_lr_active_curator_radio = nil;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Name: TFAR_fnc_onSpeakVolumeModifierPressed
Author(s):
ACyprus
Description:
Transiently changes the volume for the player's voice in game to either Yelling or Whisper
Parameters:
0: STRING - Volume level : VALUES ("yelling" or "whispering")
Returns:
BOOLEAN - Whether or not the event was handled
Example:
["yelling"] call TFAR_fnc_onSpeakVolumeModifierPressed;
*/
private ["_modifierMode", "_allowedModes", "_localName", "_hintText"];

_modifierMode = _this select 0;
_allowedModes = ["yelling", "whispering"];

if(!alive TFAR_currentUnit || TF_tangent_sw_pressed || TF_tangent_lr_pressed || TF_tangent_dd_pressed) exitWith {false};
if!(_modifierMode in _allowedModes) exitWith {false};

TF_last_speak_volume_level = TF_speak_volume_level;
TF_last_speak_volume_meters = TF_speak_volume_meters;

TF_speak_volume_level = _modifierMode;
if(_modifierMode == "yelling") then {
TF_speak_volume_meters = TF_max_voice_volume;
} else {
TF_speak_volume_meters = TF_min_voice_volume;
};

_localName = localize format["STR_voice_%1", _modifierMode];
_hintText = format[localize "STR_voice_volume", _localName];
[parseText (_hintText), -1] call TFAR_fnc_showHint;

["OnSpeakVolumeModifierPressed", TFAR_currentUnit, [TFAR_currentUnit, TF_speak_volume_level, TF_speak_volume_meters]] call TFAR_fnc_fireEventHandlers;

true
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Name: TFAR_fnc_onSpeakVolumeModifierReleased
Author(s):
ACyprus
Description:
Restores any transient volume changes for the player's voice in game
Parameters:
NONE
Returns:
BOOLEAN - Whether or not the event was handled
Example:
call TFAR_fnc_onSpeakVolumeModifierReleased;
*/
TF_speak_volume_level = TF_last_speak_volume_level;
TF_speak_volume_meters = TF_last_speak_volume_meters;

call TFAR_fnc_HideHint;

["OnSpeakVolumeModifierReleased", TFAR_currentUnit, [TFAR_currentUnit, TF_speak_volume_level, TF_speak_volume_meters]] call TFAR_fnc_fireEventHandlers;

true
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,9 @@ TF_dialog_dd_modifiers = [true, false, false];

TF_speak_volume_scancode = 15;
TF_speak_volume_modifiers = [false, true, false];

TF_speak_volume_modifier_yelling_scancode = 0;
TF_speak_volume_modifier_yelling_modifiers = [false, false, false];

TF_speak_volume_modifier_whispering_scancode = 0;
TF_speak_volume_modifier_whispering_modifiers = [false, false, false];

0 comments on commit dbc78d8

Please sign in to comment.