//============================================================================= // The trader menu's list with items for sale //============================================================================= class SRBuyMenuSaleList extends KFBuyMenuSaleList; #exec obj load file="KF_InterfaceArt_tex.utx" var int ActiveCategory,SelectionOffset; var localized string WeaponGroupText; var string FavoriteGroupName; var() Material CategoryTex,CategoryPerkTex,SelectedCatPerkTex,CategoryArrow,CategoryArrowSel; var array ListPerkIcons; event Opened(GUIComponent Sender) { super(GUIVertList).Opened(Sender); // Get localized string FavoriteGroupName = Class'KFBuyMenuFilter'.Default.PerkSelectIcon8.Hint; // Fixed script warnings. UpdateForSaleBuyables(); } final function GUIBuyable GetSelectedBuyable() { if( Index<0 || Index>=CanBuys.Length || CanBuys[Index]>1 || (Index-SelectionOffset)<0 || (Index-SelectionOffset)>=ForSaleBuyables.Length ) return None; return ForSaleBuyables[Index-SelectionOffset]; } final function CopyAllBuyables() { local ClientPerkRepLink L; local int i; L = Class'ClientPerkRepLink'.Static.FindStats(PlayerOwner()); if( L==None ) return; for( i=0; i WC ) { local Inventory I; for( I=PlayerOwner().Pawn.Inventory; I!=None; I=I.Inventory ) { if( Weapon(I)!=None && Weapon(I).DemoReplacement==WC ) return true; } return false; } final function bool IsInInventoryWep( Class WC ) { local Inventory I; for( I=PlayerOwner().Pawn.Inventory; I!=None; I=I.Inventory ) if( I.Class==WC ) return true; return false; } final function bool CheckGoldGunAvailable( class WC ) { local int i; local Inventory Inv; local class WPC; for( Inv=PlayerOwner().Pawn.Inventory; Inv!=None; Inv=Inv.Inventory ) { if( KFWeapon(Inv)==None || Inv.PickupClass==None ) continue; WPC = class(Inv.PickupClass); if( WPC!=None && WPC.Default.VariantClasses.Length>0 ) { for( i=(WC.Default.VariantClasses.Length-1); i>=0; --i ) { if( WC.Default.VariantClasses[i]==Inv.PickupClass ) return true; } for( i=(WPC.Default.VariantClasses.Length-1); i>=0; --i ) { if( WPC.Default.VariantClasses[i]==WC ) return true; } } } return false; } final function KFShopVolume_Story GetCurrentShop() { local KFPlayerController_Story StoryPC; StoryPC = KFPlayerController_Story(PlayerOwner()); if(StoryPC != none) return StoryPC.CurrentShopVolume; return none; } function FilterBuyablesList(); function int PopulateBuyables() { return 0; } function UpdateForSaleBuyables() { local class PlayerVeterancy; local KFPlayerReplicationInfo KFPRI; local ClientPerkRepLink CPRL; local GUIBuyable ForSaleBuyable; local class ForSalePickup; local int j, DualDivider, i, Num, z, PerkSaleOffset; local class ForSaleWeapon,SecType; local class Blocker; local KFShopVolume_Story CurrentShop; local byte DLCLocked; // Clear the ForSaleBuyables array CopyAllBuyables(); ForSaleBuyables.Length = 0; // Grab the items for sale CPRL = Class'ClientPerkRepLink'.Static.FindStats(PlayerOwner()); if( CPRL==None ) return; // Hmmmm? KFPRI = KFPlayerReplicationInfo(PlayerOwner().PlayerReplicationInfo); // Grab Players Veterancy for quick reference if ( KFPRI!=none ) PlayerVeterancy = KFPRI.ClientVeteranSkill; if( PlayerVeterancy==None ) PlayerVeterancy = class'KFVeterancyTypes'; CurrentShop = GetCurrentShop(); // Grab the weapons! if( ActiveCategory>=-1 ) { if( CurrentShop!=None ) Num = CurrentShop.SaleItems.Length; else Num = CPRL.ShopInventory.Length; for ( z=0; z(CurrentShop.SaleItems[z]); if( ForSalePickup==None ) continue; for ( j=(CPRL.ShopInventory.Length-1); j>=CPRL.ShopInventory.Length; --j ) if( CPRL.ShopInventory[j].PC==ForSalePickup ) break; if( j<0 ) continue; } else { ForSalePickup = class(CPRL.ShopInventory[z].PC); j = z; } if ( ForSalePickup==None || class(ForSalePickup.default.InventoryType)==None || class(ForSalePickup.default.InventoryType).default.bKFNeverThrow || IsInInventory(ForSalePickup) ) continue; if( ActiveCategory==-1 ) { if( !Class'SRClientSettings'.Static.IsFavorite(ForSalePickup) ) continue; } else if( ActiveCategory!=CPRL.ShopInventory[j].CatNum ) continue; ForSaleWeapon = class(ForSalePickup.default.InventoryType); // Remove single weld. if( class'DualWeaponsManager'.Static.HasDualies(ForSaleWeapon,PlayerOwner().Pawn.Inventory) || (ForSalePickup.Default.VariantClasses.Length>0 && CheckGoldGunAvailable(ForSalePickup)) ) continue; DualDivider = 1; // Make cheaper. if( ForSaleWeapon!=class'Dualies' && class'DualWeaponsManager'.Static.IsDualWeapon(ForSaleWeapon,SecType) && IsInInventoryWep(SecType) ) DualDivider = 2; Blocker = None; for( i=0; i=-1 ) { for( i=-1; i<(ActiveCategory+1); ++i ) { if( i==-1 ) { PrimaryStrings[j] = FavoriteGroupName; ListPerkIcons[j] = None; } else { PrimaryStrings[j] = CPRL.ShopCategories[i].Name; if( CPRL.ShopCategories[i].PerkIndex PlayerOwner().PlayerReplicationInfo.Score || ForSaleBuyables[i].ItemWeight + KFHumanPawn(PlayerOwner().Pawn).CurrentWeight > KFHumanPawn(PlayerOwner().Pawn).MaxCarryWeight ) { CanBuys[j] = 0; } else { CanBuys[j] = 1; } ++j; } if( ActiveCategory>=-1 ) { for( i=(ActiveCategory+1); i1 ) { bSelected = (ActiveCategory==(CanBuys[CurIndex]-3)); TempHeight = Height - 12; TempY += 6; if( ListPerkIcons[CurIndex]!=None ) { Canvas.SetPos(X, Y+5); if( bSelected ) M = SelectedCatPerkTex; else M = CategoryPerkTex; Canvas.DrawTileStretched(M, Height - 10, Height - 10); TempX += (Height-10); Width -= (Height-10); } Canvas.SetPos(TempX, TempY); Canvas.DrawTileStretched(CategoryTex, Width, Height - 12); // Draw category selection arrow. Canvas.SetPos(TempX+Width-Height+7, Y+8); if( bSelected ) M = CategoryArrowSel; else M = CategoryArrow; Canvas.DrawTile(M, Height - 16, Height - 16, 0, 0, M.MaterialUSize(), M.MaterialVSize()); // Draw perk icon M = ListPerkIcons[CurIndex]; if( M!=None ) { Canvas.SetPos(X + 2, Y + 7); Canvas.DrawTile(M, Height - 14, Height - 14, 0, 0, M.MaterialUSize(), M.MaterialVSize()); } } else { if ( CanBuys[CurIndex]==0 ) { Canvas.DrawTileStretched(DisabledItemBackgroundLeft, Height - ItemSpacing, Height - ItemSpacing); TempX += ((Height - ItemSpacing) - 1); TempHeight = Height - 12; TempY += 6;//(Height - TempHeight) / 2; Canvas.SetPos(TempX, TempY); Canvas.DrawTileStretched(DisabledItemBackgroundRight, Width - (Height - ItemSpacing), Height - 12); } else if ( bSelected ) { Canvas.DrawTileStretched(SelectedItemBackgroundLeft, Height - ItemSpacing, Height - ItemSpacing); TempX += ((Height - ItemSpacing) - 1); TempHeight = Height - 12; TempY += 6;//(Height - TempHeight) / 2; Canvas.SetPos(TempX, TempY); Canvas.DrawTileStretched(SelectedItemBackgroundRight, Width - (Height - ItemSpacing), Height - 12); } else { Canvas.DrawTileStretched(ItemBackgroundLeft, Height - ItemSpacing, Height - ItemSpacing); TempX += ((Height - ItemSpacing) - 1); TempHeight = Height - 12; TempY += 6;//(Height - TempHeight) / 2; Canvas.SetPos(TempX, TempY); Canvas.DrawTileStretched(ItemBackgroundRight, Width - (Height - ItemSpacing), Height - 12); } M = ListPerkIcons[CurIndex]; if( M!=None ) { Canvas.SetPos(X + 4, Y + 4); Canvas.DrawTile(M, Height - 8, Height - 8, 0, 0, M.MaterialUSize(), M.MaterialVSize()); } } // Select Text color if ( CurIndex == MouseOverIndex ) { Canvas.SetDrawColor(255, 255, 255, 255); } else { Canvas.SetDrawColor(0, 0, 0, 255); } // Draw the item's name or category Canvas.TextSize(PrimaryStrings[CurIndex], StringWidth, StringHeight); Canvas.SetPos(TempX + (0.2 * Height), TempY + ((TempHeight - StringHeight) / 2)); Canvas.DrawText(PrimaryStrings[CurIndex]); // Draw the item's price if ( CanBuys[CurIndex] <2 ) { Canvas.TextSize(SecondaryStrings[CurIndex], StringWidth, StringHeight); Canvas.SetPos((TempX - Height) + Width - (StringWidth + (0.2 * Height)), TempY + ((TempHeight - StringHeight) / 2)); Canvas.DrawText(SecondaryStrings[CurIndex]); } /* else { Canvas.TextSize(WeaponGroupText, StringWidth, StringHeight); Canvas.SetPos((TempX - Height) + Width - (StringWidth + (0.2 * Height)), TempY + ((TempHeight - StringHeight) / 2)); Canvas.DrawText(WeaponGroupText); }*/ Canvas.SetDrawColor(255, 255, 255, 255); } function IndexChanged(GUIComponent Sender) { if ( Index>=0 && CanBuys[Index]==0 && (Index-SelectionOffset)>=0 && ForSaleBuyables[Index-SelectionOffset].ItemAmmoCurrent==0 ) { if ( ForSaleBuyables[Index-SelectionOffset].ItemCost > PlayerOwner().PlayerReplicationInfo.Score ) PlayerOwner().Pawn.DemoPlaySound(TraderSoundTooExpensive, SLOT_Interface, 2.0); else if ( ForSaleBuyables[Index-SelectionOffset].ItemWeight + KFHumanPawn(PlayerOwner().Pawn).CurrentWeight > KFHumanPawn(PlayerOwner().Pawn).MaxCarryWeight ) PlayerOwner().Pawn.DemoPlaySound(TraderSoundTooHeavy, SLOT_Interface, 2.0); } Super(GUIVertList).IndexChanged(Sender); } defaultproperties { ActiveCategory=-2 WeaponGroupText="Weapon group" CategoryTex=Texture'KF_InterfaceArt_tex.Menu.Thin_border' CategoryPerkTex=Texture'KF_InterfaceArt_tex.Menu.button_Highlight' SelectedCatPerkTex=Texture'KF_InterfaceArt_tex.Menu.button_pressed' CategoryArrow=Texture'KF_InterfaceArt_tex.Menu.LeftMark' CategoryArrowSel=Texture'KF_InterfaceArt_tex.Menu.DownMark' }