2020-12-13 15:01:13 +00:00
//=============================================================================
// KFGFxWidget_KickVote
//=============================================================================
// HUD Widget that displays when a kick vote has started
//=============================================================================
// Killing Floor 2
// Copyright (C) 2015 Tripwire Interactive LLC
// - Zane Gholson 07/07/2014
//=============================================================================
class KFGFxWidget _KickVote extends GFxObject ;
var localized string VoteKickString ;
var localized string VoteSkipTraderString ;
var localized string VoteSkipTraderDetailString ;
2021-11-16 17:03:42 +00:00
var localized string VotePauseGameString ;
var localized string VotePauseGameDetailString ;
var localized string VoteResumeGameString ;
var localized string VoteResumeGameDetailString ;
2020-12-13 15:01:13 +00:00
var bool bIsVoteActive ;
var bool bShowChoicesOnTimerUpdate ;
var const string GBA _VoteYes ;
var const string GBA _VoteNo ;
var GFxObject KickVoteData ;
2021-11-16 17:03:42 +00:00
enum EVoteType
{
VT _NONE ,
VT _KICK ,
VT _SKIP _TRADER ,
VT _PAUSE _GAME ,
VT _RESUME _GAME
} ;
var EVoteType CurrentActiveVote ;
2020-12-13 15:01:13 +00:00
function InitializeHUD ( )
{
//LocalizeText();
}
2021-11-16 17:03:42 +00:00
function LocalizeText ( EVoteType Type )
2020-12-13 15:01:13 +00:00
{
local GFxObject TempObject ;
local KFPlayerInput KFInput ;
local KeyBind TempKeyBind ;
TempObject = CreateObject ( "Object" ) ;
KFInput = KFPlayerInput ( GetPC ( ) . PlayerInput ) ;
KFInput . GetKeyBindFromCommand ( TempKeyBind , GBA _VoteYes ) ;
TempObject . SetString ( "yesKey" , String ( TempKeyBind . Name ) ) ;
KFInput . GetKeyBindFromCommand ( TempKeyBind , GBA _VoteNo ) ;
TempObject . SetString ( "noKey" , String ( TempKeyBind . Name ) ) ;
TempObject . SetString ( "yes" , Class 'KFCommon_LocalizedStrings' . default . YesString ) ;
TempObject . SetString ( "no" , Class 'KFCommon_LocalizedStrings' . default . NoString ) ;
2021-11-16 17:03:42 +00:00
TempObject . SetString ( "voteKick" , GetVoteString ( Type ) ) ;
2020-12-13 15:01:13 +00:00
SetObject ( "localizedText" , TempObject ) ;
}
function ResetVote ( )
{
bShowChoicesOnTimerUpdate = false ;
ActionScriptVoid ( "onYesReleased" ) ;
ActionScriptVoid ( "onNoReleased" ) ;
}
2021-11-16 17:03:42 +00:00
function ShowVote ( PlayerReplicationInfo PRI , byte VoteDuration , bool bShowChoices , EVoteType Type )
2020-12-13 15:01:13 +00:00
{
if ( PRI != none )
{
2021-11-16 17:03:42 +00:00
LocalizeText ( Type ) ; //Added this here if the user changes their keybind, it will update
2020-12-13 15:01:13 +00:00
bIsVoteActive = true ;
2021-11-16 17:03:42 +00:00
CurrentActiveVote = Type ;
2020-12-13 15:01:13 +00:00
SendVoteToAS3 ( PRI . PlayerName , VoteDuration , bShowChoices ) ;
}
else
{
bIsVoteActive = false ;
2021-11-16 17:03:42 +00:00
CurrentActiveVote = VT _NONE ;
2020-12-13 15:01:13 +00:00
}
}
function SendVoteToAS3 ( string PlayerName , byte VoteDuration , bool bShowChoices )
{
if ( KickVoteData == None )
{
KickVoteData = CreateObject ( "Object" ) ;
}
2021-11-16 17:03:42 +00:00
KickVoteData . SetString ( "playerName" , GetVotePlayerDataString ( PlayerName , CurrentActiveVote ) ) ;
2020-12-13 15:01:13 +00:00
KickVoteData . SetInt ( "voteDuration" , VoteDuration ) ;
KickVoteData . SetBool ( "bShowChoices" , bShowChoices ) ;
bShowChoicesOnTimerUpdate = bShowChoices ;
SetObject ( "kickVoteData" , kickVoteData ) ;
UpdateUsingGamepad ( GetPC ( ) . PlayerInput . bUsingGamepad ) ; // Moved call to here as the initialize seemed to be too early to show controller controls in some cases (orbis mainly) - HSL
}
function UpdateVoteDuration ( byte VoteDuration )
{
if ( kickVoteData != None )
{
KickVoteData . SetInt ( "voteDuration" , VoteDuration ) ;
KickVoteData . SetBool ( "bShowChoices" , bShowChoicesOnTimerUpdate ) ;
SetObject ( "kickVoteData" , kickVoteData ) ;
UpdateUsingGamepad ( GetPC ( ) . PlayerInput . bUsingGamepad ) ;
}
}
function UpdateUsingGamepad ( bool bIsUsingGamepad )
{
SetBool ( "bUsingGamepad" , bIsUsingGamepad ) ;
if ( ! bIsUsingGamepad )
{
//the gamepad text will show on the input so we need to change it back to keyboard, it is simpler to just relocalize
2021-11-16 17:03:42 +00:00
LocalizeText ( CurrentActiveVote ) ;
2020-12-13 15:01:13 +00:00
}
}
function UpdateVoteCount ( byte YesVotes , byte NoVotes )
{
ActionScriptVoid ( "updateKickVoteCount" ) ;
}
function VoteClosed ( )
{
bIsVoteActive = false ;
SetVisible ( false ) ;
}
function OnYesPressed ( )
{
if ( bIsVoteActive )
{
ActionScriptVoid ( "onYesPressed" ) ;
}
}
function OnYesReleased ( )
{
if ( bIsVoteActive )
{
ActionScriptVoid ( "onYesReleased" ) ;
}
}
function OnNoPressed ( )
{
if ( bIsVoteActive )
{
ActionScriptVoid ( "onNoPressed" ) ;
}
}
function OnNoReleased ( )
{
if ( bIsVoteActive )
{
ActionScriptVoid ( "onNoReleased" ) ;
}
}
2021-11-16 17:03:42 +00:00
function string GetVoteString ( EVoteType Type )
{
switch ( Type )
{
case VT _KICK : return VoteKickString ;
case VT _SKIP _TRADER : return VoteSkipTraderString ;
case VT _PAUSE _GAME : return VotePauseGameString ;
case VT _RESUME _GAME : return VoteResumeGameString ;
case VT _NONE : ` Log("None vote type"); return VoteKickString;
default : ` Log("Unkown vote type"); return VoteKickString;
}
}
function string GetVotePlayerDataString ( string PlayerName , EVoteType Type )
{
switch ( Type )
{
case VT _SKIP _TRADER : return PlayerName @ VoteSkipTraderDetailString ;
case VT _PAUSE _GAME : return PlayerName @ VotePauseGameDetailString ;
case VT _RESUME _GAME : return PlayerName @ VoteResumeGameDetailString ;
case VT _KICK : return PlayerName ;
case VT _NONE : ` Log("None vote type"); return PlayerName;
default : ` Log("Unkown vote type"); return PlayerName;
}
}
2020-12-13 15:01:13 +00:00
DefaultProperties
{
//defaults
GBA _VoteYes = "GBA_VoteYes"
GBA _VoteNo = "GBA_VoteNo"
2021-11-16 17:03:42 +00:00
CurrentActiveVote = VT _NONE
2020-12-13 15:01:13 +00:00
}