Updated to fix several issues with the new settings menu and allow players to set a custom player info color

This commit is contained in:
ForrestMarkX 2020-01-17 19:54:24 -06:00
parent ae9901ae11
commit 79108a3abd
6 changed files with 203 additions and 151 deletions

Binary file not shown.

View File

@ -1,7 +1,5 @@
class ClassicHUD extends KFMutator;
const GFxListenerPriority = 80000;
var KFPawn LastHitZed;
var int LastHitHP;
var KFPlayerController LastDamageDealer;
@ -15,18 +13,10 @@ struct RepInfoS
};
var array<RepInfoS> DamageReplicationInfos;
var transient KFPlayerController KFPC;
var transient KFGFxHudWrapper HUD;
var transient GFxClikWidget HUDChatInputField, PartyChatInputField;
simulated function PostBeginPlay()
function PostBeginPlay()
{
Super.PostBeginPlay();
if( WorldInfo.NetMode != NM_DedicatedServer )
InitializeHUD();
if( WorldInfo.Game != None )
WorldInfo.Game.HUDType = class'ClassicKFHUD';
WorldInfo.Game.HUDType = class'ClassicKFHUD';
}
function NetDamage(int OriginalDamage, out int Damage, Pawn Injured, Controller InstigatedBy, vector HitLocation, out vector Momentum, class<DamageType> DamageType, Actor DamageCauser)
@ -111,107 +101,6 @@ function DestroyReplicationInfo(KFPlayerController C)
}
}
// Peelz fam, thanks for this
simulated function InitializeHUD()
{
KFPC = KFPlayerController(GetALocalPlayerController());
HUD = KFGFxHudWrapper(KFPC.myHUD);
if( HUD == None )
{
SetTimer(0.5f, false, nameof(InitializeHUD));
return;
}
WriteToChat("<Classic HUD> Initialized!", "FFFF00");
WriteToChat("<Classic HUD> Type !settings or use OpenSettingsMenu in console to configure!", "00FF00");
InitializePartyChatHook();
InitializeHUDChatHook();
}
simulated delegate OnPartyChatInputKeyDown(GFxClikWidget.EventData Data)
{
OnChatKeyDown(PartyChatInputField, Data);
}
simulated delegate OnHUDChatInputKeyDown(GFxClikWidget.EventData Data)
{
if (OnChatKeyDown(HUDChatInputField, Data))
HUD.HUDMovie.HudChatBox.ClearAndCloseChat();
}
simulated function bool OnChatKeyDown(GFxClikWidget InputField, GFxClikWidget.EventData Data)
{
local GFXObject InputDetails;
local int KeyCode;
local string EventType;
local string KeyEvent;
local string Text;
InputDetails = Data._this.GetObject("details");
KeyCode = InputDetails.GetInt("code");
EventType = InputDetails.GetString("type");
KeyEvent = InputDetails.GetString("value");
if (EventType != "key") return false;
if (KeyCode == 13 && (KeyEvent == "keyHold" || KeyEvent == "keyDown"))
{
Text = InputField.GetText();
switch (Locs(Text))
{
case "!settings":
ClassicKFHUD(KFPC.MyHUD).OpenSettingsMenu();
break;
default:
return false;
}
InputField.SetText("");
return true;
}
return false;
}
simulated function InitializePartyChatHook()
{
if (KFPC.MyGFxManager == None || KFPC.MyGFxManager.PartyWidget == None || KFPC.MYGFxManager.PartyWidget.PartyChatWidget == None)
{
SetTimer(1.f, false, nameof(InitializePartyChatHook));
return;
}
KFPC.MyGFxManager.PartyWidget.PartyChatWidget.SetVisible(true);
PartyChatInputField = GFxClikWidget(KFPC.MyGFxManager.PartyWidget.PartyChatWidget.GetObject("ChatInputField", class'GFxClikWidget'));
PartyChatInputField.AddEventListener('CLIK_input', OnPartyChatInputKeyDown, false, GFxListenerPriority, false);
}
simulated function InitializeHUDChatHook()
{
if (HUD == None || HUD.HUDMovie == None || HUD.HUDMovie.HudChatBox == None)
{
SetTimer(1.f, false, nameof(InitializeHUDChatHook));
return;
}
HUDChatInputField = GFxClikWidget(HUD.HUDMovie.HudChatBox.GetObject("ChatInputField", class'GFxClikWidget'));
HUDChatInputField.AddEventListener('CLIK_input', OnHUDChatInputKeyDown, false, GFxListenerPriority, false);;
}
simulated function WriteToChat(string Message, string HexColor)
{
if (KFPC.MyGFxManager.PartyWidget != None && KFPC.MyGFxManager.PartyWidget.PartyChatWidget != None)
KFPC.MyGFxManager.PartyWidget.PartyChatWidget.AddChatMessage(Message, HexColor);
if (HUD != None && HUD.HUDMovie != None && HUD.HUDMovie.HudChatBox != None)
HUD.HUDMovie.HudChatBox.AddChatMessage(Message, HexColor);
}
defaultproperties
{
Role=ROLE_Authority
RemoteRole=ROLE_SimulatedProxy
bAlwaysRelevant=true
}

View File

@ -1,6 +1,8 @@
class ClassicKFHUD extends KFGFxHudWrapper
config(ClassicHUD);
const GFxListenerPriority = 80000;
const MAX_WEAPON_GROUPS = 4;
const HUDBorderSize = 3;
@ -272,8 +274,10 @@ var transient bool bLoadedInitItems;
var array<Color> DamageMsgColors;
var UIP_ColorSettings ColorSettingMenu;
var transient GFxClikWidget HUDChatInputField, PartyChatInputField;
var transient bool bReplicatedColorTextures;
var config Color HudMainColor, HudOutlineColor, FontColor;
var config Color HudMainColor, HudOutlineColor, FontColor, CustomArmorColor, CustomHealthColor;
var config bool bEnableDamagePopups, bLightHUD, bHideWeaponInfo, bHidePlayerInfo, bHideDosh, bDisableHiddenPlayers, bShowSpeed, bDisableLastZEDIcons, bDisablePickupInfo, bDisableLockOnUI, bDisableRechargeUI, bShowXPEarned, bShowDoshEarned, bNewScoreboard, bDisableHUD;
var config int HealthBarFullVisDist, HealthBarCutoffDist;
var config int iConfigVersion;
@ -320,6 +324,28 @@ simulated function PostBeginPlay()
bSaveConfig = true;
}
if( iConfigVersion <= 1 )
{
switch(PlayerInfoType)
{
case INFO_CLASSIC:
CustomArmorColor = BlueColor;
CustomHealthColor = RedColor;
break;
case INFO_LEGACY:
CustomArmorColor = ClassicArmorColor;
CustomHealthColor = ClassicHealthColor;
break;
case INFO_MODERN:
CustomArmorColor = ArmorColor;
CustomHealthColor = HealthColor;
break;
}
iConfigVersion++;
bSaveConfig = true;
}
if( bSaveConfig )
SaveConfig();
@ -348,6 +374,97 @@ simulated function PostBeginPlay()
HUDClass = class'KFGFxHudWrapper'.default.HUDClass;
CreateHUDMovie();
}
SetTimer(0.25f, false, nameof(InitializeHUD));
InitializePartyChatHook();
InitializeHUDChatHook();
}
function InitializeHUD()
{
WriteToChat("<Classic HUD> Initialized!", "FFFF00");
WriteToChat("<Classic HUD> Type !settings or use OpenSettingsMenu in console to configure!", "00FF00");
}
delegate OnPartyChatInputKeyDown(GFxClikWidget.EventData Data)
{
OnChatKeyDown(PartyChatInputField, Data);
}
delegate OnHUDChatInputKeyDown(GFxClikWidget.EventData Data)
{
if (OnChatKeyDown(HUDChatInputField, Data))
HUDMovie.HudChatBox.ClearAndCloseChat();
}
function bool OnChatKeyDown(GFxClikWidget InputField, GFxClikWidget.EventData Data)
{
local GFXObject InputDetails;
local int KeyCode;
local string EventType;
local string KeyEvent;
local string Text;
InputDetails = Data._this.GetObject("details");
KeyCode = InputDetails.GetInt("code");
EventType = InputDetails.GetString("type");
KeyEvent = InputDetails.GetString("value");
if (EventType != "key") return false;
if (KeyCode == 13 && (KeyEvent == "keyHold" || KeyEvent == "keyDown"))
{
Text = InputField.GetText();
switch (Locs(Text))
{
case "!settings":
OpenSettingsMenu();
break;
default:
return false;
}
InputField.SetText("");
return true;
}
return false;
}
function InitializePartyChatHook()
{
if (KFPlayerOwner.MyGFxManager == None || KFPlayerOwner.MyGFxManager.PartyWidget == None || KFPlayerOwner.MYGFxManager.PartyWidget.PartyChatWidget == None)
{
SetTimer(1.f, false, nameof(InitializePartyChatHook));
return;
}
KFPlayerOwner.MyGFxManager.PartyWidget.PartyChatWidget.SetVisible(true);
PartyChatInputField = GFxClikWidget(KFPlayerOwner.MyGFxManager.PartyWidget.PartyChatWidget.GetObject("ChatInputField", class'GFxClikWidget'));
PartyChatInputField.AddEventListener('CLIK_input', OnPartyChatInputKeyDown, false, GFxListenerPriority, false);
}
function InitializeHUDChatHook()
{
if( HUDMovie == None || HUDMovie.HudChatBox == None )
{
SetTimer(1.f, false, nameof(InitializeHUDChatHook));
return;
}
HUDChatInputField = GFxClikWidget(HUDMovie.HudChatBox.GetObject("ChatInputField", class'GFxClikWidget'));
HUDChatInputField.AddEventListener('CLIK_input', OnHUDChatInputKeyDown, false, GFxListenerPriority, false);;
}
function WriteToChat(string Message, string HexColor)
{
if (KFPlayerOwner.MyGFxManager.PartyWidget != None && KFPlayerOwner.MyGFxManager.PartyWidget.PartyChatWidget != None)
KFPlayerOwner.MyGFxManager.PartyWidget.PartyChatWidget.AddChatMessage(Message, HexColor);
if (HUDMovie != None && HUDMovie.HudChatBox != None)
HUDMovie.HudChatBox.AddChatMessage(Message, HexColor);
}
function ResetHUDColors()
@ -472,6 +589,17 @@ function SetupHUDTextures(optional bool bUseColorIcons)
function PostRender()
{
if( !bReplicatedColorTextures && HudOutlineColor != DefaultHudOutlineColor )
{
bReplicatedColorTextures = true;
SetupHUDTextures(true);
}
else if( bReplicatedColorTextures && HudOutlineColor == DefaultHudOutlineColor )
{
bReplicatedColorTextures = false;
SetupHUDTextures();
}
if( KFGRI == None )
KFGRI = KFGameReplicationInfo(WorldInfo.GRI);
@ -3415,21 +3543,8 @@ simulated function bool DrawFriendlyHumanPlayerInfo( KFPawn_Human KFPH )
GUIStyle.DrawTextShadow(KFPRI.PlayerName, ScreenPos.X - (BarLength * 0.5f), ScreenPos.Y - 3.5f, 1, FontScale);
//Info Color
switch(PlayerInfoType)
{
case INFO_CLASSIC:
CurrentArmorColor = BlueColor;
CurrentHealthColor = RedColor;
break;
case INFO_LEGACY:
CurrentArmorColor = ClassicArmorColor;
CurrentHealthColor = ClassicHealthColor;
break;
case INFO_MODERN:
CurrentArmorColor = ArmorColor;
CurrentHealthColor = HealthColor;
break;
}
CurrentArmorColor = CustomArmorColor;
CurrentHealthColor = CustomHealthColor;
CurrentArmorColor.A = FadeAlpha;
CurrentHealthColor.A = FadeAlpha;

View File

@ -1,24 +1,31 @@
Class UIP_ColorSettings extends KFGUI_MultiComponent;
var KFGUI_ComponentList SettingsBox;
var KFGUI_ColorSlider MainHudSlider,OutlineSlider,FontSlider;
var KFGUI_ColorSlider MainHudSlider,OutlineSlider,FontSlider,ArmorSlider,HealthSlider;
var ClassicKFHUD HUD;
function InitMenu()
{
HUD = ClassicKFHUD(GetPlayer().myHUD);
Super.InitMenu();
// Client settings
SettingsBox = KFGUI_ComponentList(FindComponentID('SettingsBox'));
MainHudSlider = AddColorSlider('HUDColorSlider', "Main HUD Color", ClassicKFHUD(GetPlayer().myHUD).HudMainColor);
OutlineSlider = AddColorSlider('OutlineColorSlider', "HUD Outline Color", ClassicKFHUD(GetPlayer().myHUD).HudOutlineColor);
FontSlider = AddColorSlider('FontCSlider', "Font Color", ClassicKFHUD(GetPlayer().myHUD).FontColor);
MainHudSlider = AddColorSlider('HUDColorSlider', "Main HUD Color", HUD.HudMainColor);
OutlineSlider = AddColorSlider('OutlineColorSlider', "HUD Outline Color", HUD.HudOutlineColor);
FontSlider = AddColorSlider('FontCSlider', "Font Color", HUD.FontColor);
ArmorSlider = AddColorSlider('ArmorCSlider', "Player Info Armor Color", HUD.CustomArmorColor);
HealthSlider = AddColorSlider('HealthCSlider', "Player Info Health Color", HUD.CustomHealthColor);
}
function ShowMenu()
{
Super.ShowMenu();
ClassicKFHUD(GetPlayer().myHUD).ColorSettingMenu = self;
HUD.ColorSettingMenu = self;
ArmorSlider.SetDefaultColor(HUD.CustomArmorColor);
HealthSlider.SetDefaultColor(HUD.CustomHealthColor);
}
final function KFGUI_ColorSlider AddColorSlider( name IDN, string Caption, Color DefaultColor )
@ -42,12 +49,6 @@ final function KFGUI_ColorSlider AddColorSlider( name IDN, string Caption, Color
function CheckColorSliderChange(KFGUI_ColorSlider Sender, KFGUI_Slider Slider, int Value)
{
local ClassicKFHUD HUD;
HUD = ClassicKFHUD(GetPlayer().myHUD);
if( HUD == None )
return;
switch(Sender.ID)
{
case 'HUDColorSlider':
@ -104,23 +105,48 @@ function CheckColorSliderChange(KFGUI_ColorSlider Sender, KFGUI_Slider Slider, i
}
HUD.SaveConfig();
break;
case 'ArmorCSlider':
switch( Slider.ID )
{
case 'ColorSliderR':
HUD.CustomArmorColor.R = Value;
break;
case 'ColorSliderG':
HUD.CustomArmorColor.G = Value;
break;
case 'ColorSliderB':
HUD.CustomArmorColor.B = Value;
break;
case 'ColorSliderA':
HUD.CustomArmorColor.A = Value;
break;
}
HUD.SaveConfig();
break;
case 'HealthCSlider':
switch( Slider.ID )
{
case 'ColorSliderR':
HUD.CustomHealthColor.R = Value;
break;
case 'ColorSliderG':
HUD.CustomHealthColor.G = Value;
break;
case 'ColorSliderB':
HUD.CustomHealthColor.B = Value;
break;
case 'ColorSliderA':
HUD.CustomHealthColor.A = Value;
break;
}
HUD.SaveConfig();
break;
}
}
function DrawMenu()
{
Canvas.SetDrawColor(250,250,250,255);
Canvas.SetPos(0.f,0.f);
Canvas.DrawTileStretched(Owner.CurrentStyle.BorderTextures[`BOX_INNERBORDER],CompPos[2],CompPos[3],0,0,128,128);
}
defaultproperties
{
Begin Object Class=KFGUI_ComponentList Name=ClientSettingsBox
XPosition=0.05
YPosition=0.05
XSize=0.95
YSize=0.95
ID="SettingsBox"
ListItemsPerPage=3
End Object

View File

@ -140,6 +140,22 @@ function OnComboChanged(KFGUI_ComboBox Sender)
break;
}
switch(HUD.PlayerInfoType)
{
case INFO_CLASSIC:
HUD.CustomArmorColor = HUD.BlueColor;
HUD.CustomHealthColor = HUD.RedColor;
break;
case INFO_LEGACY:
HUD.CustomArmorColor = HUD.ClassicArmorColor;
HUD.CustomHealthColor = HUD.ClassicHealthColor;
break;
case INFO_MODERN:
HUD.CustomArmorColor = HUD.ArmorColor;
HUD.CustomHealthColor = HUD.HealthColor;
break;
}
HUD.SaveConfig();
}

View File

@ -59,8 +59,14 @@ function ShowMenu()
function CloseMenu()
{
local KFGfxMoviePlayer_Manager MovieManager;
Super.CloseMenu();
Owner.bHideCursor = true;
MovieManager = KFPlayerController(GetPlayer()).MyGFxManager;
MovieManager.SetMovieCanReceiveInput(MovieManager.bMenusActive);
}
function PreDraw()