Skip to content

Commit

Permalink
function declaration for #887
Browse files Browse the repository at this point in the history
  • Loading branch information
ACyprus committed Aug 8, 2015
1 parent 6e89a6e commit 7b24165
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,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 @@ -100,6 +100,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 @@ -235,15 +238,20 @@ TF_MICRODAGR_CHANNEL_EDIT_ID = IDC_MICRODAGR_CHANNEL_EDIT;
TF_tangent_sw_pressed = false;
TF_tangent_lr_pressed = false;
TF_tangent_dd_pressed = false;
TF_speak_volume_modifier_pressed = true;

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 7b24165

Please sign in to comment.