Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DancePlayerInteraction extends Interaction;
- const NUM_EMOJI_ANIMS = 53;
- var const name EMAnims[53];
- var const string EMAbbrevs[53];
- var enum EmojiMenuState
- {
- EMS_Main,
- EMS_DancingVol_1,
- EMS_DancingVol_2,
- EMS_GesturingVol_1,
- EMS_GesturingVol_2,
- EMS_GesturingVol_3,
- EMS_Fighting
- } EMState, PreviousStateName;
- var Mutator Mut;
- var float EMLineSpace;
- var bool bIgnoreKeys;
- var int HighlightRow;
- var Sound EMOpenSound, EMAcceptSound, EMDenySound;
- var EInputKey LetterKeys[10];
- var EInputKey NumberKeys[10];
- var int EMOffset;
- var string EMMoreString;
- var name EMAnimArray[10];
- var string EMNameArray[10];
- var int EMIndexArray[10];
- var int EMArraySize;
- var float EMOriginX, EMOriginY, EMMargin, EMTab;
- var string EMStateName[10];
- var bool bEmojiMenuUseLetters, bEmojiMenuUseMouseWheel;
- event NotifyLevelChange()
- {
- Master.RemoveInteraction(self);
- }
- exec function EmojiMenuToggle()
- {
- if(ViewportOwner == none || ViewportOwner.Actor == none || ViewportOwner.Actor.Pawn == none)
- {
- return;
- }
- GotoState('EmojiMenuVisible');
- }
- function PlayConsoleSound(Sound Sound)
- {
- if(ViewportOwner == none || ViewportOwner.Actor == none || ViewportOwner.Actor.Pawn == none)
- return;
- ViewportOwner.Actor.ClientPlaySound(Sound);
- }
- state EmojiMenuVisible
- {
- /* exec function EmojiMenuToggle()
- {
- GotoState('');
- } */
- function bool KeyType(EInputKey Key, optional string Unicode)
- {
- if (bIgnoreKeys)
- return true;
- return false;
- }
- function RebuildEMArray()
- {
- switch(EMState)
- {
- case EMS_Main:
- BuildEMMainArray(7);
- break;
- case EMS_DancingVol_1:
- BuildEMStateArray(0, 9);
- break;
- case EMS_DancingVol_2:
- BuildEMStateArray(9, 9);
- break;
- case EMS_GesturingVol_1:
- BuildEMStateArray(18, 9);
- break;
- case EMS_GesturingVol_2:
- BuildEMStateArray(27, 9);
- break;
- case EMS_GesturingVol_3:
- BuildEMStateArray(36, 9);
- break;
- case EMS_Fighting:
- BuildEMStateArray(45, 8);
- break;
- }
- }
- function BuildEMMainArray(int Length)
- {
- local int i;
- local KFPlayerReplicationInfo KFRepInfo;
- EMOffset = 0;
- EMArraySize = 0;
- KFRepInfo = KFPlayerReplicationInfo(ViewportOwner.Actor.PlayerReplicationInfo);
- for(i=1;i < Length;i++)
- {
- EMNameArray[EMArraySize] = EMStateName[i];
- EMIndexArray[EMArraySize] = i;
- EMArraySize++;
- }
- }
- // Build emojiCommands array
- function BuildEMStateArray(int Index, int Length)
- {
- local int i;
- local KFGameReplicationInfo KFGameRep;
- local KFPlayerReplicationInfo KFPlayerRep;
- if(DancePlayerMut(Mut) == none)
- return;
- KFGameRep = KFGameReplicationInfo(ViewportOwner.Actor.GameReplicationInfo);
- KFPlayerRep = KFPlayerReplicationInfo(ViewportOwner.Actor.PlayerReplicationInfo);
- EMArraySize = 0;
- PreviousStateName = EMS_Main;
- for(i=0;i < Length;i++)
- {
- EMAnimArray[EMArraySize] = DancePlayerMut(Mut).EMAnims[i];
- EMNameArray[EMArraySize] = DancePlayerMut(Mut).EMAbbrevs[i];
- EMIndexArray[EMArraySize] = i;
- EMArraySize++;
- }
- }
- function EnterState(EmojiMenuState NewState, optional bool bNoSound)
- {
- EMState = NewState;
- RebuildEMArray();
- if(!bNoSound)
- {
- PlayConsoleSound(EMAcceptSound);
- }
- }
- function LeaveState()
- {
- PlayConsoleSound(EMDenySound);
- if(EMState == EMS_Main)
- {
- GotoState('');
- }
- else
- {
- EnterState(PreviousStateName, true);
- }
- }
- function HandleInput(int keyIn)
- {
- local int selectIndex;
- local KFPlayerReplicationInfo KFPRI;
- local bool bInVehicle;
- if(keyIn == -1)
- {
- LeaveState();
- HighlightRow = 0;
- return;
- }
- if(EMState == EMS_Main)
- {
- KFPRI = KFPlayerReplicationInfo(ViewportOwner.Actor.PlayerReplicationInfo);
- if((ViewportOwner.Actor.Pawn != none) && ViewportOwner.Actor.Pawn.IsA('KFVehicle') || ViewportOwner.Actor.Pawn.IsA('KFVehicleWeaponPawn'))
- {
- bInVehicle = true;
- }
- else
- {
- bInVehicle = false;
- }
- switch(keyIn)
- {
- case 1:
- // SMType = 'SUPPORT';
- EnterState(EMS_DancingVol_1);
- break;
- case 2:
- EnterState(EMS_DancingVol_2);
- break;
- case 3:
- EnterState(EMS_GesturingVol_1);
- break;
- case 4:
- EnterState(EMS_GesturingVol_2);
- break;
- case 5:
- EnterState(EMS_GesturingVol_3);
- break;
- case 6:
- EnterState(EMS_Fighting);
- break;
- // default:
- // return;
- }
- return;
- }
- if(keyIn == 0)
- {
- if(EMArraySize - EMOffset > 9 && EMArraySize != 10)
- {
- EMOffset += 9;
- return;
- }
- keyIn = 10;
- }
- if(keyIn == -2)
- {
- EMOffset = Max(EMOffset - 9, 0);
- return;
- }
- selectIndex = EMOffset + keyIn - 1;
- if(selectIndex < 0 || selectIndex >= EMArraySize)
- {
- return;
- }
- if(DanceHumanPawn(ViewportOwner.Actor.Pawn) != none)
- {
- DanceHumanPawn(ViewportOwner.Actor.Pawn).EmojiTrigger(EMAnimArray[EMIndexArray[selectIndex]]);
- }
- PlayConsoleSound(EMAcceptSound);
- GotoState('');
- }
- function string NumberToString(int Num)
- {
- local EInputKey Key;
- if((Num < 0) || Num > 9)
- {
- return "";
- }
- if(bEmojiMenuUseLetters)
- {
- Key = LetterKeys[Num];
- }
- else
- {
- Key = NumberKeys[Num];
- }
- return ViewportOwner.Actor.ConsoleCommand("LOCALIZEDKEYNAME" @ string(Key));
- }
- function DrawNumbers(Canvas Canvas, int NumNums, bool bIncZero, bool bSizing, out float XMax, out float YMax)
- {
- local int i;
- local float XPos, YPos, XL, YL;
- XPos = Canvas.ClipX * (EMOriginX + EMMargin);
- YPos = Canvas.ClipY * (EMOriginY + EMMargin);
- Canvas.SetDrawColor(128,255,128,255);
- for(i=0;i < NumNums;i++)
- {
- Canvas.SetPos(XPos, YPos);
- if(!bSizing)
- {
- Canvas.DrawText(NumberToString(i+1)$"-", false);
- }
- else
- {
- Canvas.TextSize(NumberToString(i+1)$"-", XL, YL);
- XMax = Max(XMax, XPos + XL);
- YMax = Max(YMax, YPos + YL);
- }
- YPos += EMLineSpace;
- }
- if(bIncZero)
- {
- Canvas.SetPos(XPos, YPos);
- if(!bSizing)
- {
- Canvas.DrawText(NumberToString(0)$"-", false);
- }
- if(EMArraySize != 10)
- {
- XPos += EMTab;
- Canvas.SetPos(XPos, YPos);
- if(!bSizing)
- {
- Canvas.DrawText(EMMoreString, false);
- }
- else
- {
- Canvas.TextSize(EMMoreString, XL, YL);
- XMax = Max(XMax, XPos + XL);
- YMax = Max(YMax, YPos + YL);
- }
- }
- }
- }
- function DrawCurrentArray(Canvas Canvas, bool bSizing, out float XMax, out float YMax)
- {
- local int i, stopAt;
- local float XPos, YPos, XL, YL;
- XPos = Canvas.ClipX * (EMOriginX + EMMargin) + EMTab;
- YPos = Canvas.ClipY * (EMOriginY + EMMargin);
- Canvas.SetDrawColor(byte(255), byte(255), byte(255), byte(255));
- if(EMArraySize == 10)
- {
- stopAt = Min(EMOffset + 10, EMArraySize);
- }
- else
- {
- stopAt = Min(EMOffset + 9, EMArraySize);
- }
- for(i = EMOffset;i < stopAt;i++)
- {
- Canvas.SetPos(XPos, YPos);
- if(!bSizing)
- {
- Canvas.DrawText(EMNameArray[i], false);
- }
- else
- {
- Canvas.TextSize(EMNameArray[i], XL, YL);
- XMax = Max(XMax, XPos + XL);
- YMax = Max(YMax, YPos + YL);
- }
- YPos += EMLineSpace;
- }
- }
- function int KeyToNumber(EInputKey InKey)
- {
- local int i;
- for(i=0;i < 10;i++)
- {
- if(bEmojiMenuUseLetters)
- {
- if(InKey == LetterKeys[i])
- {
- return i;
- }
- }
- if(InKey == NumberKeys[i])
- {
- return i;
- }
- }
- return -1;
- }
- function bool KeyEvent(EInputKey Key, EInputAction Action, float Delta)
- {
- local int Input, NumNums;
- NumNums = Min(EMArraySize - EMOffset, 10);
- if(Action == IST_Press)
- {
- bIgnoreKeys = false;
- }
- if(Action != IST_Press)
- {
- return false;
- }
- if(Key == IK_Escape)
- {
- HandleInput(-1);
- return true;
- }
- Input = KeyToNumber(Key);
- if(Input != -1)
- {
- HandleInput(Input);
- return true;
- }
- if(!bEmojiMenuUseMouseWheel)
- {
- return false;
- }
- if(Key == IK_MouseWheelUp)
- {
- if((HighlightRow == 0) && EMOffset > 0)
- {
- HandleInput(-2);
- HighlightRow = 9;
- }
- else
- {
- HighlightRow = Max(HighlightRow - 1, 0);
- }
- return true;
- }
- else
- {
- if(Key == IK_MouseWheelDown)
- {
- if((HighlightRow == 9) && EMArraySize != 10)
- {
- HandleInput(0);
- HighlightRow = 0;
- }
- else
- {
- HighlightRow = Min(HighlightRow + 1, NumNums - 1);
- }
- return true;
- }
- else
- {
- if(Key == IK_MiddleMouse)
- {
- Input = HighlightRow + 1;
- if(Input == 10)
- {
- Input = 0;
- }
- HandleInput(Input);
- HighlightRow = 0;
- return true;
- }
- }
- }
- return false;
- }
- function PostRender(Canvas Canvas)
- {
- local float XL, YL;
- local int SelLeft, i;
- local float XMax, YMax;
- Canvas.Font = class'UT2MidGameFont'.static.GetMidGameFont(int(Canvas.ClipX));
- XMax = 0.0;
- YMax = 0.0;
- for(i=0;i < 20;i++)
- {
- Canvas.TextSize(NumberToString(i)$"- ", XL, YL);
- XMax = Max(XMax, XL);
- YMax = Max(YMax, YL);
- }
- EMLineSpace = YMax * 1.10;
- EMTab = XMax;
- SelLeft = EMArraySize - EMOffset;
- XMax = 0.0;
- YMax = 0.0;
- DrawNumbers(Canvas, Min(SelLeft, 9), SelLeft > 9, true, XMax, YMax);
- DrawCurrentArray(Canvas, true, XMax, YMax);
- Canvas.TextSize(EMStateName[EMState], XL, YL);
- XMax = float(Max(int(XMax), int((Canvas.ClipX * (EMOriginX + EMMargin)) + XL)));
- YMax = float(Max(int(YMax), int(((Canvas.ClipY * EMOriginY) - (1.20 * EMLineSpace)) + YL)));
- XMax -= (Canvas.ClipX * EMOriginX);
- YMax -= (Canvas.ClipY * EMOriginY);
- Canvas.SetDrawColor(139, 28, 28, byte(255));
- Canvas.SetPos(Canvas.ClipX * EMOriginX, Canvas.ClipY * EMOriginY);
- Canvas.DrawTileStretched(texture'Thin_border_SlightTransparent', XMax + (EMMargin * Canvas.ClipX), YMax + (EMMargin * Canvas.ClipY));
- if(bEmojiMenuUseMouseWheel)
- {
- Canvas.SetDrawColor(byte(255), 202, 180, 128);
- Canvas.SetPos(Canvas.ClipX * EMOriginX, (Canvas.ClipY * (EMOriginY + EMMargin)) + (EMLineSpace * (float(HighlightRow) - 0.10)));
- Canvas.DrawTileStretched(texture'Thin_border_SlightTransparent', XMax + (EMMargin * Canvas.ClipX), 1.10 * EMLineSpace);
- }
- DrawNumbers(Canvas, Min(SelLeft, 9), SelLeft > 9, false, XMax, YMax);
- DrawCurrentArray(Canvas, false, XMax, YMax);
- Canvas.SetDrawColor(139, 28, 28, byte(255));
- Canvas.SetPos(Canvas.ClipX * EMOriginX, (Canvas.ClipY * EMOriginY) - (1.50 * EMLineSpace));
- Canvas.DrawTileStretched(texture'Thin_border_SlightTransparent', XMax + (EMMargin * Canvas.ClipX), 1.50 * EMLineSpace);
- Canvas.SetDrawColor(byte(255), byte(255), 128, byte(255));
- Canvas.SetPos(Canvas.ClipX * (EMOriginX + EMMargin), (Canvas.ClipY * EMOriginY) - (1.20 * EMLineSpace));
- // Canvas.DrawText(EMStateName(EMState));
- Canvas.DrawText(EMStateName[EMState]);
- }
- function BeginState()
- {
- bVisible = true;
- bIgnoreKeys = true;
- HighlightRow = 0;
- EnterState(EMS_Main, true);
- PlayConsoleSound(EMOpenSound);
- }
- function EndState()
- {
- bVisible = false;
- // bCtrl = false;
- // PRIs.Length = 0;
- }
- event NotifyLevelChange()
- {
- global.NotifyLevelChange();
- GotoState('');
- }
- // stop;
- }
- defaultproperties
- {
- EMOpenSound=Sound'KF_MenuSnd.Generic.msfxEdit'
- EMAcceptSound=Sound'KF_MenuSnd.Generic.msfxMouseClick'
- EMDenySound=Sound'KF_MenuSnd.MainMenu.CharFade'
- LetterKeys(0)=IK_O//81
- LetterKeys(1)=IK_W//87
- LetterKeys(2)=IK_E//69
- LetterKeys(3)=IK_R//82
- LetterKeys(4)=IK_A//65
- LetterKeys(5)=IK_S//83
- LetterKeys(6)=IK_D//68
- LetterKeys(7)=IK_F//70
- LetterKeys(8)=IK_Z//90
- LetterKeys(9)=IK_X//88
- NumberKeys(0)=IK_0//48
- NumberKeys(1)=IK_1//49
- NumberKeys(2)=IK_2//50
- NumberKeys(3)=IK_3//51
- NumberKeys(4)=IK_4//52
- NumberKeys(5)=IK_5//53
- NumberKeys(6)=IK_6//54
- NumberKeys(7)=IK_7//55
- NumberKeys(8)=IK_8//56
- NumberKeys(9)=IK_9//57
- EMMoreString="[MORE]"
- EMOriginX=0.010
- EMOriginY=0.5250
- EMMargin=0.0150
- EMStateName[0]="Emoji Menu"
- EMStateName[1]="Dancing Vol. 1"
- EMStateName[2]="Dancing Vol. 2"
- EMStateName[3]="Gesturing Vol. 1"
- EMStateName[4]="Gesturing Vol. 2"
- EMStateName[5]="Gesturing Vol. 3"
- EMStateName[6]="Fighting"
- EMAnims(0)="Dance_CanCan"
- EMAnims(1)="Dance_Chicken"
- EMAnims(2)="Dance_MaraschinoStep"
- EMAnims(3)="Dance_RunningMan"
- EMAnims(4)="Dance_Twerk"
- EMAnims(5)="Dance_Noodle"
- EMAnims(6)="Dance_Rainbow"
- EMAnims(7)="Dance_Silly"
- EMAnims(8)="Dance_Snake"
- EMAnims(9)="Dance_Tut"
- EMAnims(10)="Dance_Twist"
- EMAnims(11)="Dance_RaiseTheRoof"
- EMAnims(12)="Dance_Quake"
- EMAnims(13)="Dance_RibPops"
- EMAnims(14)="Dance_Macarena"
- EMAnims(15)="Dance_Salsa"
- EMAnims(16)="Dance_Shuffling"
- EMAnims(17)="Dance_YMCA"
- EMAnims(18)="Gesture_Summersault"
- EMAnims(19)="Gesture_Dab"
- EMAnims(20)="Gesture_Agony"
- EMAnims(21)="Gesture_Booty"
- EMAnims(22)="Gesture_Salute"
- EMAnims(23)="Gesture_LookingAround"
- EMAnims(24)="Gesture_Petting"
- EMAnims(25)="Gesture_Patting"
- EMAnims(26)="Gesture_ThroatSlash"
- EMAnims(27)="Gesture_Elbow"
- EMAnims(28)="Gesture_Power"
- EMAnims(29)="Gesture_Victory"
- EMAnims(30)="Gesture_Star"
- EMAnims(31)="Gesture_JoyfulJump"
- EMAnims(32)="Gesture_Waving"
- EMAnims(33)="Gesture_Hello"
- EMAnims(34)="Gesture_Cheering"
- EMAnims(35)="Gesture_Clapping"
- EMAnims(36)="Gesture_Crazy"
- EMAnims(37)="Gesture_Defeated"
- EMAnims(38)="Gesture_HokeyPokey"
- EMAnims(39)="Gesture_No"
- EMAnims(40)="Gesture_Pain"
- EMAnims(41)="Gesture_Pointing"
- EMAnims(42)="Gesture_Shaking"
- EMAnims(43)="Gesture_Strong"
- EMAnims(44)="Gesture_Whatever"
- EMAnims(45)="Fight_ElbowUppercut"
- EMAnims(46)="Fight_HeadButt"
- EMAnims(47)="Fight_Fireball"
- EMAnims(48)="Fight_IllegalElbowPunch"
- EMAnims(49)="Fight_JabToElbowPunch"
- EMAnims(50)="Fight_HighKick"
- EMAnims(51)="Fight_PunchingBag"
- EMAnims(52)="Fight_UppercutJab"
- EMAbbrevs(0)="Can Can"
- EMAbbrevs(1)="Chicken"
- EMAbbrevs(2)="Maraschino Step"
- EMAbbrevs(3)="Running Man"
- EMAbbrevs(4)="Twerk"
- EMAbbrevs(5)="Noodle"
- EMAbbrevs(6)="Rainbow"
- EMAbbrevs(7)="Silly"
- EMAbbrevs(8)="Snake"
- EMAbbrevs(9)="Tut"
- EMAbbrevs(10)="Twist"
- EMAbbrevs(11)="Raise The Roof"
- EMAbbrevs(12)="Quake"
- EMAbbrevs(13)="Rib Pops"
- EMAbbrevs(14)="Macarena"
- EMAbbrevs(15)="Salsa"
- EMAbbrevs(16)="Shuffling"
- EMAbbrevs(17)="YMCA"
- EMAbbrevs(18)="Summersault"
- EMAbbrevs(19)="Dab"
- EMAbbrevs(20)="Agony"
- EMAbbrevs(21)="Booty"
- EMAbbrevs(22)="Salute"
- EMAbbrevs(23)="Looking Around"
- EMAbbrevs(24)="Petting"
- EMAbbrevs(25)="Patting"
- EMAbbrevs(26)="Throat Slash"
- EMAbbrevs(27)="Elbow"
- EMAbbrevs(28)="Power"
- EMAbbrevs(29)="Victory"
- EMAbbrevs(30)="Star"
- EMAbbrevs(31)="Joyful Jump"
- EMAbbrevs(32)="Waving"
- EMAbbrevs(33)="Hello"
- EMAbbrevs(34)="Cheering"
- EMAbbrevs(35)="Clapping"
- EMAbbrevs(36)="Crazy"
- EMAbbrevs(37)="Defeated"
- EMAbbrevs(38)="Hokey Pokey"
- EMAbbrevs(39)="No"
- EMAbbrevs(40)="Pain"
- EMAbbrevs(41)="Pointing"
- EMAbbrevs(42)="Shaking"
- EMAbbrevs(43)="Strong"
- EMAbbrevs(44)="Whatever"
- EMAbbrevs(45)="Elbow Uppercut"
- EMAbbrevs(46)="Head Butt"
- EMAbbrevs(47)="Fireball"
- EMAbbrevs(48)="Illegal Elbow Punch"
- EMAbbrevs(49)="Jab To Elbow Punch"
- EMAbbrevs(50)="High Kick"
- EMAbbrevs(51)="Punching Bag"
- EMAbbrevs(52)="Uppercut Jab"
- bEmojiMenuUseMouseWheel=true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement