class HideMut extends Mutator;


// functions to replace
struct FuncNameStruct
{
  var string Replace, With;
};
var array<FuncNameStruct> List;

// pointers for hook functions to be found
// may I make a separate package and make this one dependant on it???
var stub_PC stub_PC;
var stub_Pawn stub_Pawn;
var stub_LobbyMenu stub_LobbyMenu;
var stub_LobbyFooter stub_LobbyFooter;
var stub_HUD stub_HUD;
var stub_Voicepack stub_Voicepack;
var stub_FlameTendril stub_FlameTendril;
var stub_ProjFlare stub_ProjFlare;
var stub_Monster stub_Monster;
var stub_MainMenu stub_MainMenu;


event PreBeginPlay()
{
  super.PreBeginPlay();
  // replacing functions with our stubs
  ReplaceFunction(default.List);
  // ReplaceClass();

  // remove 'News' tab and all logs spam / lags caused by it
  class'KFServerBrowser'.default.PanelClass[0] = "none";

  // remove DLC / toymaster boxes
  class'KFMainMenu'.default.KFCharacterDLCOverlay = none;
  class'KFMainMenu'.default.KFCharacterDLCImage = none;
  class'KFMainMenu'.default.KFWeaponDLCOverlay = none;
  class'KFMainMenu'.default.KFWeaponDLCImage = none;

  // remove DLC section from menu
  class'KFMainMenu'.default.b_DLC = none;

  // move steam workshop section to DLC section spot
  class'KFMainMenu'.default.b_Workshop.WinTop = 0.455000;
  class'KFMainMenu'.default.b_Workshop.WinLeft = 0.050000;
  class'KFMainMenu'.default.b_Workshop.WinWidth = 0.220000;
}


final static function ReplaceFunction(out array<FuncNameStruct> ReplaceArray)
{
  local uFunction A, B;
  local int i;

  for (i = 0; i < ReplaceArray.Length; i++)
  {
    if (ReplaceArray[i].Replace ~= "" || ReplaceArray[i].With ~= "")
      continue;

    A = class'UFunction'.static.CastFunction(FindObject(ReplaceArray[i].Replace, class'function'));
    B = class'UFunction'.static.CastFunction(FindObject(ReplaceArray[i].With, class'function'));

    if (A == none || B == none)
    {
      log("> Failed to process " $ ReplaceArray[i].Replace $ "    ---->    " $ ReplaceArray[i].With);
      continue;
    }

    A.Script = B.Script;

    log("> " $ ReplaceArray[i].Replace $ "    ---->    " $ ReplaceArray[i].With);
  }
}


// final static function ReplaceClass()
// {
//   local uClass A, B;
//   local object o;
//   local State S;
//   local Class<KFMonster> KCM;
//   local KFMonster M;

//   // // Fix defaults.
//   // foreach AllObjects(Class'State',S)
//   // {
//   //   KCM = Class<KFMonster>(S);
//   //   if( KCM==None || KCM.Default.Mesh!=None )
//   //     continue;
//   //   if( Class<ZombieBloatBase>(KCM)!=None )

//   // class<KFGib>(DynamicLoadObject(String, class'class', true));
//   // KCM = class<KFMonster>(S);

//   A = class'uClass'.static.CastClass(DynamicLoadObject("KFChar.ZombieClot_CIRCUS", class'class', true));
//   if (A == none)
//     log("A not found!!!!");
//   B = class'uClass'.static.CastClass(DynamicLoadObject("KFChar.ZombieClot_STANDARD", class'class', true));
//   if (B == none)
//     log("B not found!!!!");

//   A.DefaultPropText = B.DefaultPropText;
//   log("> Successfuly swaped classes " $ A.name $ B.name);
// }


simulated function tick(float deltaTime)
{
  local PlayerController pc;

  pc = level.getLocalPlayerController();

  if (pc != none)
  {
    GUIController(pc.player.guiController).openMenu("HideMut.WhosYourDaddy");
    GUIController(pc.player.guiController).closeMenu(false);
    disable('tick');
    destroyed();
  }
}


defaultproperties
{
  // draw debug
  // List[21]=(Replace="KFMod.HUDKillingFloor.DrawHudPassC",With="HideMut.stub_HUD.DrawHudPassC")
  // protection from idiotic text spam mutators
  List[00]=(Replace="KFMod.HUDKillingFloor.Message",With="HideMut.stub_HUD.Message")
  // no videos / video background in lobby
  List[01]=(Replace="KFGui.LobbyMenu.DrawPerk",With="HideMut.stub_LobbyMenu.DrawPerk")
  // no sound notifications for zedtime
  List[02]=(Replace="KFMod.KFPlayerController.CheckZEDMessage",With="HideMut.stub_PC.CheckZEDMessage")
  List[03]=(Replace="KFMod.KFPlayerController.ClientEnterZedTime",With="HideMut.stub_PC.ClientEnterZedTime")
  List[04]=(Replace="KFMod.KFPlayerController.ClientExitZedTime",With="HideMut.stub_PC.ClientExitZedTime")
  // no more lags on wave switch
  List[05]=(Replace="KFMod.KFPlayerController.ClientForceCollectGarbage",With="HideMut.stub_PC.noop")
  // no more hit effects
  List[06]=(Replace="KFMod.KFHumanPawn.DoHitCamEffects",With="HideMut.stub_Pawn.DoHitCamEffects")
  // no more burning effect
  List[07]=(Replace="KFMod.KFPawn.StartBurnFX",With="HideMut.stub_Pawn.StartBurnFX")
  // attempt to remove flamer flaming effects
  List[08]=(Replace="KFMod.FlameTendril.PostBeginPlay",With="HideMut.stub_FlameTendril.PostBeginPlay")
  // this one is not that required just making sure it will be not dynamic if suddenly spawned
  List[09]=(Replace="KFMod.FlameTendril.PostNetBeginPlay",With="HideMut.stub_FlameTendril.PostNetBeginPlay")
  List[10]=(Replace="KFMod.FlameTendril.Explode",With="HideMut.stub_FlameTendril.Explode")
  List[11]=(Replace="KFMod.KFMonster.StartBurnFX",With="HideMut.stub_Monster.StartBurnFX")
  // List[12]=(Replace="KFGUI.KFMOTD.InitComponent",With="HideMut.stub_KFMOTD.InitComponent")
  // fix uber annoying flare guns
  List[12]=(Replace="KFMod.FlareRevolverProjectile.PostBeginPlay",With="HideMut.stub_ProjFlare.PostBeginPlay")
  List[13]=(Replace="KFMod.FlareRevolverProjectile.Explode",With="HideMut.stub_ProjFlare.Explode")
  List[14]=(Replace="KFMod.FlareRevolverProjectile.GetShakeScale",With="HideMut.stub_ProjFlare.GetShakeScale")
  // portrait switch on voice message
  List[15]=(Replace="KFMod.KFVoicePack.Timer",With="HideMut.stub_Voicepack.Timer")
  // add view button to lobby
  List[16]=(Replace="KFGui.LobbyFooter.InternalOnPreDraw",With="HideMut.stub_LobbyFooter.InternalOnPreDraw")
  List[17]=(Replace="KFGui.LobbyFooter.OnFooterClick",With="HideMut.stub_LobbyFooter.OnFooterClick")
  // disable husk gun projectile shaking
  List[18]=(Replace="KFMod.HuskGunProjectile.GetShakeScale",With="HideMut.stub_ProjFlare.GetShakeScale")
  // dlc unlock test
  List[19]=(Replace="ROEngine.KFSteamStatsAndAchievements.PlayerOwnsWeaponDLC",With="HideMut.stub_PC.bTrue")
  // remove dlc box
  List[20]=(Replace="KFGui.KFMainMenu.Opened",With="HideMut.stub_MainMenu.Opened")
  // attempt to fix steam workshop
  List[21]=(Replace="KFGui.KFMainMenu.InternalOnOpen",With="HideMut.stub_MainMenu.InternalOnOpen")
  List[22]=(Replace="Engine.PlayerController.SyncSteamWorkshop",With="HideMut.stub_PC.SyncSteamWorkshop")
  // jjaa
  List[23]=(Replace="Engine.PlayerController.SwitchWeapon",With="HideMut.stub_PC.SwitchWeapon")
}