mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-12 19:59:09 +00:00
1
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,83 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef CUSTOM_TEXTURE_CACHE_H
|
||||
#define CUSTOM_TEXTURE_CACHE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifndef GC_CLIENTSYSTEM_H
|
||||
#include "gc_clientsystem.h"
|
||||
#endif
|
||||
|
||||
class IGameSystem;
|
||||
class ITexture;
|
||||
class CEconItemView;
|
||||
|
||||
/// Given a UGC cloud ID of a custom image, return a VGUI texture handle
|
||||
/// that can be used for drawing. Returns 0 on failure
|
||||
int GetCustomTextureGuiHandle( uint64 hCloudId );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Job to do the async work of uploading the file to the CDN (if
|
||||
// necessary) and sending the tool request message
|
||||
//-----------------------------------------------------------------------------
|
||||
class CApplyCustomTextureJob : public GCSDK::CGCClientJob
|
||||
{
|
||||
public:
|
||||
|
||||
CApplyCustomTextureJob( itemid_t nToolItemID, itemid_t nSubjectItemID, const void *pPNGData, int nPNGDataBytes );
|
||||
|
||||
protected:
|
||||
char m_chRemoteStorageName[ MAX_PATH ];
|
||||
|
||||
virtual bool BYieldingRunGCJob();
|
||||
virtual EResult YieldingRunJob();
|
||||
virtual EResult YieldingFindFileIncacheOrUploadFileToCDN();
|
||||
virtual EResult YieldingApplyTool();
|
||||
|
||||
/// The file data, in PNG format
|
||||
CUtlBuffer m_bufPNGData;
|
||||
|
||||
/// Item that we are applying the texture onto
|
||||
itemid_t m_nSubjectItemID;
|
||||
|
||||
/// Tool that is being applied and will be consumed
|
||||
itemid_t m_nToolItemID;
|
||||
|
||||
/// Cloud file ID
|
||||
uint64 m_hCloudID;
|
||||
|
||||
private:
|
||||
void CleanUp();
|
||||
};
|
||||
|
||||
/// get interface to the game system responsible for managing the custom texture cache
|
||||
IGameSystem *CustomTextureToolCacheGameSystem();
|
||||
|
||||
/// A few internal things that really shouldn't be public
|
||||
namespace CustomTextureSystem
|
||||
{
|
||||
|
||||
/// If we're auditioning (while selecting a file to apply on a model),
|
||||
/// what texture should we display?
|
||||
extern ITexture *g_pPreviewCustomTexture;
|
||||
|
||||
/// What is the econ item that is being auditioned and so should
|
||||
/// use the preview texture
|
||||
extern CEconItemView *g_pPreviewEconItem;
|
||||
|
||||
/// Do we need to update the bits in the rendering system?
|
||||
extern bool g_pPreviewCustomTextureDirty;
|
||||
|
||||
extern const char k_rchCustomTextureFilterPreviewImageName[];
|
||||
extern const char k_rchCustomTextureFilterPreviewTextureName[];
|
||||
|
||||
}
|
||||
|
||||
#endif // CUSTOM_TEXTURE_CACHE_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,213 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
#include "vgui_controls/EditablePanel.h"
|
||||
#include "vgui_controls/TextEntry.h"
|
||||
#include "vgui/IInput.h"
|
||||
#include "econ_item_system.h"
|
||||
#include "econ_item_constants.h"
|
||||
#include "econ_gcmessages.h"
|
||||
#include "econ_item_inventory.h"
|
||||
#include "econ_item_tools.h"
|
||||
#include "tool_items.h"
|
||||
#include "decoder_ring_tool.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "econ_controls.h"
|
||||
#include "econ_ui.h"
|
||||
#include "gc_clientsystem.h"
|
||||
#include "collection_crafting_panel.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
enum
|
||||
{
|
||||
CRATETYPE_NORMAL = 0,
|
||||
CRATETYPE_ROBO = 1,
|
||||
};
|
||||
|
||||
#define ROBOCRATE_UNLOCKING_SND "/mvm/mvm_tank_deploy.wav"
|
||||
#define ROBOCRATE_OPENED_SND "/mvm/mvm_tank_explode.wav"
|
||||
|
||||
static int s_iCrateType = CRATETYPE_NORMAL;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Confirm / abort tool application
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmDecodeDialog : public CBaseToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmDecodeDialog, CBaseToolUsageDialog );
|
||||
|
||||
public:
|
||||
CConfirmDecodeDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject );
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *scheme );
|
||||
virtual void Apply( void );
|
||||
virtual void OnCommand( const char *command );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CConfirmDecodeDialog::CConfirmDecodeDialog( vgui::Panel *parent, CEconItemView *pTool, CEconItemView *pToolSubject ) : CBaseToolUsageDialog( parent, "ConfirmApplyDecodeDialog", pTool, pToolSubject )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConfirmDecodeDialog::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/econ/ConfirmApplyDecodeDialog.res" );
|
||||
|
||||
const CEconItemView* pCrate = m_pSubjectModelPanel->GetItem();
|
||||
|
||||
s_iCrateType = CRATETYPE_NORMAL;
|
||||
// Check Crate Type
|
||||
if ( pCrate )
|
||||
{
|
||||
if ( pCrate->GetItemDefIndex() == 5635 ) // Robo Crate items_tools_crafting
|
||||
{
|
||||
s_iCrateType = CRATETYPE_ROBO;
|
||||
}
|
||||
}
|
||||
|
||||
if ( V_strstr( pCrate->GetItemDefinition()->GetDefinitionName(), "Case" ) )
|
||||
{
|
||||
SetDialogVariable( "confirm_text", GLocalizationProvider()->Find("#ToolDecodeConfirmCase") );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDialogVariable( "confirm_text", GLocalizationProvider()->Find("#ToolDecodeConfirm") );
|
||||
}
|
||||
|
||||
const locchar_t *loc_Append = NULL;
|
||||
if ( pCrate && pCrate->GetItemDefinition() && pCrate->GetItemDefinition()->GetHolidayRestriction() )
|
||||
{
|
||||
loc_Append = GLocalizationProvider()->Find( "#ToolDecodeConfirm_OptionalAppend_RestrictedContents" );
|
||||
}
|
||||
if ( !loc_Append )
|
||||
{
|
||||
loc_Append = LOCCHAR( "" );
|
||||
}
|
||||
|
||||
SetDialogVariable( "optional_append", loc_Append );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConfirmDecodeDialog::OnCommand( const char *command )
|
||||
{
|
||||
if ( FStrEq( "cancel", command ) )
|
||||
{
|
||||
InventoryManager()->ShowItemsPickedUp( true );
|
||||
}
|
||||
|
||||
BaseClass::OnCommand( command );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConfirmDecodeDialog::Apply( void )
|
||||
{
|
||||
static CSchemaAttributeDefHandle pAttrDef_SupplyCrateSeries( "set supply crate series" );
|
||||
|
||||
// Tell the GC to unlock the subject item.
|
||||
GCSDK::CGCMsg< MsgGCUnlockCrate_t > msg( k_EMsgGCUnlockCrate );
|
||||
|
||||
msg.Body().m_unToolItemID = m_pToolModelPanel->GetItem()->GetItemID();
|
||||
msg.Body().m_unSubjectItemID = m_pSubjectModelPanel->GetItem()->GetItemID();
|
||||
|
||||
int iSeries = 0;
|
||||
CEconItemView* pCrate = m_pSubjectModelPanel->GetItem();
|
||||
if ( pCrate )
|
||||
{
|
||||
float fSeries;
|
||||
if ( FindAttribute_UnsafeBitwiseCast<attrib_value_t>( pCrate, pAttrDef_SupplyCrateSeries, &fSeries ) )
|
||||
{
|
||||
iSeries = fSeries;
|
||||
}
|
||||
}
|
||||
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pToolModelPanel->GetItem(), "unlocked_supply_crate", iSeries );
|
||||
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
|
||||
CCollectionCraftingPanel *pPanel = EconUI()->GetBackpackPanel()->GetCollectionCraftPanel();
|
||||
if ( pPanel )
|
||||
{
|
||||
pPanel->SetWaitingForItem( kEconItemOrigin_FoundInCrate );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CEconTool_CrateKey::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CConfirmDecodeDialog *dialog = vgui::SETUP_PANEL( new CConfirmDecodeDialog( pParent, pTool, pSubject ) );
|
||||
MakeModalAndBringToFront( dialog );
|
||||
}
|
||||
|
||||
|
||||
class CWaitForCrateDialog : public CGenericWaitingDialog
|
||||
{
|
||||
public:
|
||||
CWaitForCrateDialog( vgui::Panel *pParent ) : CGenericWaitingDialog( pParent )
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void OnTimeout()
|
||||
{
|
||||
// Play an exciting sound!
|
||||
if ( s_iCrateType == CRATETYPE_ROBO )
|
||||
{
|
||||
vgui::surface()->PlaySound( ROBOCRATE_OPENED_SND );
|
||||
}
|
||||
else
|
||||
{
|
||||
vgui::surface()->PlaySound( "misc/achievement_earned.wav" );
|
||||
}
|
||||
|
||||
|
||||
// Show them their loot!
|
||||
InventoryManager()->ShowItemsPickedUp( true );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: GC Msg handler to receive the decoder ring response
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGCUnlockCrateResponse : public GCSDK::CGCClientJob
|
||||
{
|
||||
public:
|
||||
CGCUnlockCrateResponse( GCSDK::CGCClient *pClient ) : GCSDK::CGCClientJob( pClient ) {}
|
||||
|
||||
virtual bool BYieldingRunGCJob( GCSDK::IMsgNetPacket *pNetPacket )
|
||||
{
|
||||
GCSDK::CGCMsg<MsgGCStandardResponse_t> msg( pNetPacket );
|
||||
|
||||
if ( s_iCrateType == CRATETYPE_ROBO )
|
||||
{
|
||||
vgui::surface()->PlaySound( ROBOCRATE_UNLOCKING_SND );
|
||||
}
|
||||
else
|
||||
{
|
||||
vgui::surface()->PlaySound( "ui/item_open_crate_short.wav" );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
GC_REG_JOB( GCSDK::CGCClient, CGCUnlockCrateResponse, "CGCUnlockCrateResponse", k_EMsgGCUnlockCrateResponse, GCSDK::k_EServerTypeGCClient );
|
||||
@@ -0,0 +1,14 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef DECODER_RING_TOOL_H
|
||||
#define DECODER_RING_TOOL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#endif // DECODER_RING_TOOL_H
|
||||
@@ -0,0 +1,241 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
#include "vgui_controls/EditablePanel.h"
|
||||
#include "vgui_controls/TextEntry.h"
|
||||
#include "vgui/IInput.h"
|
||||
#include "econ_item_system.h"
|
||||
#include "econ_item_constants.h"
|
||||
#include "econ_item_tools.h"
|
||||
#include "econ_gcmessages.h"
|
||||
#include "econ_item_inventory.h"
|
||||
#include "tool_items.h"
|
||||
#include "gift_wrap_tool.h"
|
||||
#include "econ_ui.h"
|
||||
#include "vgui/ISurface.h"
|
||||
#include "econ_controls.h"
|
||||
#include "confirm_dialog.h"
|
||||
#include "gc_clientsystem.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Confirm / abort tool application
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmGiftWrapDialog : public CBaseToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmGiftWrapDialog, CBaseToolUsageDialog );
|
||||
|
||||
public:
|
||||
CConfirmGiftWrapDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject );
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *scheme );
|
||||
virtual void Apply( void );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Completed wrapping dialog
|
||||
//-----------------------------------------------------------------------------
|
||||
class CWaitForGiftWrapDialog : public CGenericWaitingDialog
|
||||
{
|
||||
public:
|
||||
CWaitForGiftWrapDialog( vgui::Panel *pParent ) : CGenericWaitingDialog( pParent )
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void OnTimeout()
|
||||
{
|
||||
// Play an exciting sound!
|
||||
vgui::surface()->PlaySound( "misc/achievement_earned.wav" );
|
||||
|
||||
// Show them the result item.
|
||||
InventoryManager()->ShowItemsPickedUp( true );
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CConfirmGiftWrapDialog::CConfirmGiftWrapDialog( vgui::Panel *parent, CEconItemView *pTool, CEconItemView *pToolSubject ) : CBaseToolUsageDialog( parent, "ConfirmApplyGiftWrapDialog", pTool, pToolSubject )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConfirmGiftWrapDialog::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/econ/ConfirmApplyGiftWrapDialog.res" );
|
||||
|
||||
// We might want to change our label text to explicitly call out that we'll reset strange scores
|
||||
// on gift wrap, but only if we're trying to use this gift wrap on a strange item that has scores
|
||||
// that would be affected by it.
|
||||
CEconItemView *pSubjectItemView = GetSubjectItem();
|
||||
CExLabel *pTextLabel = dynamic_cast<CExLabel *>( FindChildByName( "ConfirmLabel" ) );
|
||||
CExLabel *pTextLabelStrange = dynamic_cast<CExLabel *>( FindChildByName( "ConfirmLabelStrange" ) );
|
||||
|
||||
if ( pSubjectItemView && pTextLabel && pTextLabelStrange )
|
||||
{
|
||||
bool bHasNonZeroScore = false;
|
||||
|
||||
for ( int i = 0; i < GetKillEaterAttrCount(); i++ )
|
||||
{
|
||||
uint32 unScore;
|
||||
if ( pSubjectItemView->FindAttribute( GetKillEaterAttr_Score( i ), &unScore ) && unScore > 0 )
|
||||
{
|
||||
bHasNonZeroScore = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( bHasNonZeroScore )
|
||||
{
|
||||
pTextLabel->SetVisible( false );
|
||||
pTextLabelStrange->SetVisible( true );
|
||||
}
|
||||
}
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConfirmGiftWrapDialog::Apply( void )
|
||||
{
|
||||
// Tell the GC to wrap the subject item.
|
||||
GCSDK::CGCMsg< MsgGCGiftWrapItem_t > msg( k_EMsgGCGiftWrapItem );
|
||||
|
||||
msg.Body().m_unToolItemID = m_pToolModelPanel->GetItem()->GetItemID();
|
||||
msg.Body().m_unSubjectItemID = m_pSubjectModelPanel->GetItem()->GetItemID();
|
||||
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pSubjectModelPanel->GetItem(), "gift_wrap_item" );
|
||||
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
|
||||
vgui::surface()->PlaySound( "ui/item_gift_wrap_use.wav" );
|
||||
ShowWaitingDialog( new CWaitForGiftWrapDialog( NULL ), "#ToolGiftWrapInProgress", true, false, 5.0f );
|
||||
}
|
||||
|
||||
// Entry point from the UI.
|
||||
void CEconTool_GiftWrap::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CConfirmGiftWrapDialog *dialog = vgui::SETUP_PANEL( new CConfirmGiftWrapDialog( pParent, pTool, pSubject ) );
|
||||
MakeModalAndBringToFront( dialog );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: GC Msg handler to receive the server response that we've given an item.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGCGiftGivenResponse : public GCSDK::CGCClientJob
|
||||
{
|
||||
public:
|
||||
CGCGiftGivenResponse( GCSDK::CGCClient *pClient ) : GCSDK::CGCClientJob( pClient ) {}
|
||||
|
||||
virtual bool BYieldingRunGCJob( GCSDK::IMsgNetPacket *pNetPacket )
|
||||
{
|
||||
GCSDK::CProtoBufMsg<CMsgDeliverGiftResponseGiver> msg( pNetPacket );
|
||||
|
||||
// Pop up a notification to confirm that the gift has been sent.
|
||||
switch ( msg.Body().response_code() )
|
||||
{
|
||||
case k_EGCMsgResponseOK:
|
||||
if ( msg.Body().has_receiver_account_name() )
|
||||
{
|
||||
KeyValues *pkv = new KeyValues( "GiftReceiverParams" );
|
||||
KeyValuesAD kvad( pkv );
|
||||
|
||||
pkv->SetString( "receiver_account_name", msg.Body().receiver_account_name().c_str() );
|
||||
ShowMessageBox( "#TF_DeliverGiftResultDialog_Title", "#TF_DeliverGiftResultDialog_Success_WithAccount", pkv, "#GameUI_OK" );
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowMessageBox( "#TF_DeliverGiftResultDialog_Title", "#TF_DeliverGiftResultDialog_Success", "#GameUI_OK" );
|
||||
}
|
||||
break;
|
||||
case k_EGCMsgResponseDenied:
|
||||
ShowMessageBox( "#TF_DeliverGiftResultDialog_Title", "#TF_DeliverGiftResultDialog_VAC", "#GameUI_OK" );
|
||||
break;
|
||||
default:
|
||||
ShowMessageBox( "#TF_DeliverGiftResultDialog_Title", "#TF_DeliverGiftResultDialog_Fail", "#GameUI_OK" );
|
||||
break;
|
||||
} // switch
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
GC_REG_JOB( GCSDK::CGCClient, CGCGiftGivenResponse, "CGCGiftGivenResponse", k_EMsgGCDeliverGiftResponseGiver, GCSDK::k_EServerTypeGCClient );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: GC Msg handler to receive the server response that we've received an item.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGCGiftReceivedResponse : public GCSDK::CGCClientJob
|
||||
{
|
||||
public:
|
||||
CGCGiftReceivedResponse( GCSDK::CGCClient *pClient ) : GCSDK::CGCClientJob( pClient ) {}
|
||||
|
||||
virtual bool BYieldingRunGCJob( GCSDK::IMsgNetPacket *pNetPacket )
|
||||
{
|
||||
GCSDK::CGCMsg<MsgGCStandardResponse_t> msg( pNetPacket );
|
||||
|
||||
// If the receiver is online when the gift is sent, they will get this response.
|
||||
InventoryManager()->GetLocalInventory()->NotifyHasNewItems();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
GC_REG_JOB( GCSDK::CGCClient, CGCGiftReceivedResponse, "CGCGiftReceivedResponse", k_EMsgGCDeliverGiftResponseReceiver, GCSDK::k_EServerTypeGCClient );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Completed unwrapping...
|
||||
//-----------------------------------------------------------------------------
|
||||
class CWaitForGiftUnwrapDialog : public CGenericWaitingDialog
|
||||
{
|
||||
public:
|
||||
CWaitForGiftUnwrapDialog( vgui::Panel *pParent ) : CGenericWaitingDialog( pParent )
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void OnTimeout()
|
||||
{
|
||||
// Play an exciting sound!
|
||||
vgui::surface()->PlaySound( "misc/achievement_earned.wav" );
|
||||
|
||||
// Show them the result item.
|
||||
InventoryManager()->ShowItemsPickedUp( true );
|
||||
}
|
||||
};
|
||||
|
||||
static void UnwrapGiftConfirm( bool bConfirmed, void *pContext )
|
||||
{
|
||||
if ( bConfirmed )
|
||||
{
|
||||
vgui::surface()->PlaySound( "ui/item_gift_wrap_unwrap.wav" );
|
||||
ShowWaitingDialog( new CWaitForGiftWrapDialog( NULL ), "#ToolGiftUnwrapInProgress", true, false, 5.0f );
|
||||
|
||||
CEconItemView *pItem = (CEconItemView*) pContext;
|
||||
GCSDK::CGCMsg< MsgGCUnwrapGiftRequest_t > msg( k_EMsgGCUnwrapGiftRequest );
|
||||
msg.Body().m_unItemID = pItem->GetItemID();
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, pItem, "unwrapped_gift" );
|
||||
}
|
||||
}
|
||||
|
||||
void PerformToolAction_UnwrapGift( vgui::Panel* pParent, CEconItemView *pGiftItem )
|
||||
{
|
||||
CTFGenericConfirmDialog *pDialog = ShowConfirmDialog( "#TF_UnwrapGift_Title", "#TF_UnwrapGift_Text",
|
||||
"#GameUI_OK", "#Cancel",
|
||||
&UnwrapGiftConfirm );
|
||||
pDialog->AddStringToken( "item_name", pGiftItem->GetItemName() );
|
||||
pDialog->SetContext( pGiftItem );
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef GIFT_WRAP_TOOL_H
|
||||
#define GIFT_WRAP_TOOL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#endif // GIFT_WRAP_TOOL_H
|
||||
@@ -0,0 +1,205 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
#include "vgui_controls/EditablePanel.h"
|
||||
#include "vgui_controls/TextEntry.h"
|
||||
#include "vgui/IInput.h"
|
||||
#include "econ_item_system.h"
|
||||
#include "econ_item_constants.h"
|
||||
#include "econ_gcmessages.h"
|
||||
#include "econ_item_inventory.h"
|
||||
#include "econ_item_tools.h"
|
||||
#include "tool_items.h"
|
||||
#include "paint_can_tool.h"
|
||||
#include "econ_ui.h"
|
||||
#include "gc_clientsystem.h"
|
||||
|
||||
#ifdef TF_CLIENT_DLL
|
||||
#include "tf_shareddefs.h"
|
||||
#endif // TF_CLIENT_DLL
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
enum
|
||||
{
|
||||
#ifdef TF_CLIENT_DLL
|
||||
kTeamID0 = TF_TEAM_RED,
|
||||
kTeamID1 = TF_TEAM_BLUE,
|
||||
#else // !defined( TF_CLIENT_DLL )
|
||||
kTeamID0 = -1,
|
||||
kTeamID1 = -1,
|
||||
#endif // TF_CLIENT_DLL
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Confirm / abort paint application
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmApplyPaintCanBaseDialog : public CBaseToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmApplyPaintCanBaseDialog, CBaseToolUsageDialog );
|
||||
|
||||
protected:
|
||||
CConfirmApplyPaintCanBaseDialog( vgui::Panel *pParent, const char *szType, CEconItemView *pTool, CEconItemView *pToolSubject )
|
||||
: CBaseToolUsageDialog( pParent, szType, pTool, pToolSubject )
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void Apply( void )
|
||||
{
|
||||
// Send the apply request to the GC
|
||||
GCSDK::CGCMsg< MsgGCPaintItem_t > msg( k_EMsgGCPaintItem );
|
||||
|
||||
msg.Body().m_unToolItemID = m_pToolModelPanel->GetItem()->GetItemID();
|
||||
msg.Body().m_unSubjectItemID = m_pSubjectModelPanel->GetItem()->GetItemID();
|
||||
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pToolModelPanel->GetItem(), "painted_item" );
|
||||
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
}
|
||||
|
||||
protected:
|
||||
// Set up a particular panel for a certain item with a certain preview color.
|
||||
static void SetupPaintModelPanel( CItemModelPanel *pPaintModelPanel, CEconItemView *pToolSubjectView, int iTeam, int iPaintRGB )
|
||||
{
|
||||
static CSchemaAttributeDefHandle pAttrDef_ItemTintRGB( "set item tint RGB" );
|
||||
|
||||
if ( !pAttrDef_ItemTintRGB )
|
||||
return;
|
||||
|
||||
// Fake-paint the demonstration items.
|
||||
pPaintModelPanel->SetItem( pToolSubjectView );
|
||||
pPaintModelPanel->GetItem()->GetAttributeList()->SetRuntimeAttributeValue( pAttrDef_ItemTintRGB, iPaintRGB );
|
||||
|
||||
// Set the appropriate skins for each item given the team and the style selected.
|
||||
int iStyleSkin = pToolSubjectView->GetSkin( iTeam );
|
||||
|
||||
if ( iStyleSkin == -1 )
|
||||
{
|
||||
// Fallback case: rely on default skins.
|
||||
pPaintModelPanel->SetSkin( iTeam == kTeamID0 ? 0 : 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
pPaintModelPanel->SetSkin( iStyleSkin );
|
||||
}
|
||||
|
||||
pPaintModelPanel->SetActAsButton( true, false );
|
||||
pPaintModelPanel->GetItem()->InvalidateColor();
|
||||
pPaintModelPanel->GetItem()->InvalidateOverrideColor();
|
||||
}
|
||||
|
||||
CItemModelPanel *m_pPaintModelPanel;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Preview a single-color paint
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmApplyPaintCanDialog : public CConfirmApplyPaintCanBaseDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmApplyPaintCanDialog, CConfirmApplyPaintCanBaseDialog );
|
||||
|
||||
public:
|
||||
CConfirmApplyPaintCanDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject )
|
||||
: CConfirmApplyPaintCanBaseDialog( pParent, "ConfirmApplyPaintCanDialog", pTool, pToolSubject )
|
||||
{
|
||||
m_pPaintModelPanel = new CItemModelPanel( this, "paint_model" );
|
||||
m_pPaintModelPanel->SetItem( pToolSubject );
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/econ/ConfirmApplyPaintCanDialog.res" );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
SetupPaintModelPanel( m_pPaintModelPanel, m_pSubjectModelPanel->GetItem(), kTeamID0, m_pToolModelPanel->GetItem()->GetModifiedRGBValue( false ) );
|
||||
}
|
||||
|
||||
private:
|
||||
CItemModelPanel *m_pPaintModelPanel;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Preview team-colored paint
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmApplyTeamColorPaintCanDialog : public CConfirmApplyPaintCanBaseDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmApplyTeamColorPaintCanDialog, CConfirmApplyPaintCanBaseDialog );
|
||||
|
||||
public:
|
||||
CConfirmApplyTeamColorPaintCanDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject )
|
||||
: CConfirmApplyPaintCanBaseDialog( pParent, "ConfirmApplyTeamColorPaintCanDialog", pTool, pToolSubject )
|
||||
{
|
||||
m_pPaintModelPanel_Red = new CItemModelPanel( this, "paint_model_red" );
|
||||
m_pPaintModelPanel_Red->SetItem( pToolSubject );
|
||||
m_pPaintModelPanel_Blue = new CItemModelPanel( this, "paint_model_blue" );
|
||||
m_pPaintModelPanel_Blue->SetItem( pToolSubject );
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/econ/ConfirmApplyTeamColorPaintCanDialog.res" );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
SetupPaintModelPanel( m_pPaintModelPanel_Red, m_pSubjectModelPanel->GetItem(), kTeamID0, m_pToolModelPanel->GetItem()->GetModifiedRGBValue( false ) );
|
||||
SetupPaintModelPanel( m_pPaintModelPanel_Blue, m_pSubjectModelPanel->GetItem(), kTeamID1, m_pToolModelPanel->GetItem()->GetModifiedRGBValue( true ) );
|
||||
|
||||
// @note Tom Bui: we need to change the global index so that the material does not get
|
||||
// re-used for each item. Should be ok to change the high bit.
|
||||
Assert( m_pPaintModelPanel_Red->GetItem() );
|
||||
m_pPaintModelPanel_Red->GetItem()->SetItemID( m_pPaintModelPanel_Red->GetItem()->GetItemID() | ( 1LL << 63 ) );
|
||||
}
|
||||
|
||||
private:
|
||||
CItemModelPanel *m_pPaintModelPanel_Red;
|
||||
CItemModelPanel *m_pPaintModelPanel_Blue;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_PaintCan::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
// Bizarro logic: we have no way of finding out whether an item has two different
|
||||
// colors of paint applied so instead we ask whether both colors are
|
||||
// the same.
|
||||
CBaseToolUsageDialog *dialog = NULL;
|
||||
if ( pTool->GetModifiedRGBValue( true ) != pTool->GetModifiedRGBValue( false ) )
|
||||
{
|
||||
dialog = new CConfirmApplyTeamColorPaintCanDialog( pParent, pTool, pSubject );
|
||||
}
|
||||
else
|
||||
{
|
||||
dialog = new CConfirmApplyPaintCanDialog( pParent, pTool, pSubject );
|
||||
}
|
||||
vgui::SETUP_PANEL( dialog );
|
||||
MakeModalAndBringToFront( dialog );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: GC Msg handler to receive the paint can response
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGCPaintItemResponse : public GCSDK::CGCClientJob
|
||||
{
|
||||
public:
|
||||
CGCPaintItemResponse( GCSDK::CGCClient *pClient ) : GCSDK::CGCClientJob( pClient ) {}
|
||||
|
||||
virtual bool BYieldingRunGCJob( GCSDK::IMsgNetPacket *pNetPacket )
|
||||
{
|
||||
GCSDK::CGCMsg<MsgGCStandardResponse_t> msg( pNetPacket );
|
||||
InventoryManager()->ShowItemsPickedUp( true );
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
GC_REG_JOB( GCSDK::CGCClient, CGCPaintItemResponse, "CGCPaintItemResponse", k_EMsgGCPaintItemResponse, GCSDK::k_EServerTypeGCClient );
|
||||
@@ -0,0 +1,15 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef PAINT_CAN_TOOL_H
|
||||
#define PAINT_CAN_TOOL_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#endif // PAINT_CAN_TOOL_H
|
||||
@@ -0,0 +1,306 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
#include "vgui_controls/EditablePanel.h"
|
||||
#include "vgui_controls/TextEntry.h"
|
||||
#include "vgui/IInput.h"
|
||||
#include "vgui//ILocalize.h"
|
||||
#include "econ_item_system.h"
|
||||
#include "econ_item_constants.h"
|
||||
#include "econ_gcmessages.h"
|
||||
#include "econ_item_inventory.h"
|
||||
#include "econ_item_tools.h"
|
||||
#include "tool_items.h"
|
||||
#include "rename_tool_ui.h"
|
||||
#include "econ_ui.h"
|
||||
#include "gc_clientsystem.h"
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
CNameToolUsageDialog::CNameToolUsageDialog( vgui::Panel *pParent, const char* pszName, CEconItemView *pTool, CEconItemView *pToolSubject, bool bDescription )
|
||||
: CBaseToolUsageDialog( pParent, pszName, pTool, pToolSubject )
|
||||
{
|
||||
m_bDescription = bDescription;
|
||||
}
|
||||
|
||||
int CNameToolUsageDialog::GetMaxLength()
|
||||
{
|
||||
if ( m_bDescription )
|
||||
return MAX_ITEM_CUSTOM_DESC_LENGTH;
|
||||
else
|
||||
return MAX_ITEM_CUSTOM_NAME_LENGTH;
|
||||
}
|
||||
|
||||
int CNameToolUsageDialog::GetMaxDBSize()
|
||||
{
|
||||
if ( m_bDescription )
|
||||
return MAX_ITEM_CUSTOM_DESC_DATABASE_SIZE;
|
||||
else
|
||||
return MAX_ITEM_CUSTOM_NAME_DATABASE_SIZE;
|
||||
}
|
||||
|
||||
void CEconTool_NameTag::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CRequestNameDialog *dialog = vgui::SETUP_PANEL( new CRequestNameDialog( pParent, "ItemRenameDialog", pTool, pSubject, false ) );
|
||||
MakeModalAndBringToFront( dialog );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
CRequestNameDialog::CRequestNameDialog( vgui::Panel *parent, const char* pszName, CEconItemView *pTool, CEconItemView *pToolSubject, bool bDescription ) :
|
||||
CNameToolUsageDialog( parent, pszName, pTool, pToolSubject, bDescription )
|
||||
{
|
||||
m_pCustomNameEntry = new vgui::TextEntry( this, "CustomNameEntry" );
|
||||
m_bDescription = bDescription;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CRequestNameDialog::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "resource/UI/ItemRenameDialog.res" );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
m_pOldNameLabel = dynamic_cast<vgui::Label *>( FindChildByName( "OldItemNameDescLabel" ) );
|
||||
if ( m_pOldNameLabel )
|
||||
{
|
||||
if ( m_bDescription )
|
||||
m_pOldNameLabel->SetText( g_pVGuiLocalize->Find( "#ToolItemRenameOldItemDesc" ) );
|
||||
else
|
||||
m_pOldNameLabel->SetText( g_pVGuiLocalize->Find( "#ToolItemRenameOldItemName" ) );
|
||||
}
|
||||
|
||||
m_pNewNameLabel = dynamic_cast<vgui::Label *>( FindChildByName( "NewItemNameDescLabel" ) );
|
||||
if ( m_pNewNameLabel )
|
||||
{
|
||||
if ( m_bDescription )
|
||||
m_pNewNameLabel->SetText( g_pVGuiLocalize->Find( "#ToolItemRenameNewItemDesc" ) );
|
||||
else
|
||||
m_pNewNameLabel->SetText( g_pVGuiLocalize->Find( "#ToolItemRenameNewItemName" ) );
|
||||
}
|
||||
|
||||
m_pOldName = dynamic_cast<vgui::Label *>( FindChildByName( "OldItemNameLabel" ) );
|
||||
if ( m_pOldName )
|
||||
{
|
||||
if ( m_bDescription )
|
||||
{
|
||||
CEconItem *pSOCData = m_pSubjectModelPanel->GetItem()->GetSOCData();
|
||||
if ( pSOCData && pSOCData->GetCustomDesc() )
|
||||
m_pOldName->SetText( pSOCData->GetCustomDesc() );
|
||||
else
|
||||
m_pOldName->SetText( m_pSubjectModelPanel->GetItem()->GetStaticData()->GetItemDesc() );
|
||||
}
|
||||
else
|
||||
{
|
||||
CEconItem *pSOCData = m_pSubjectModelPanel->GetItem()->GetSOCData();
|
||||
if ( pSOCData && pSOCData->GetCustomName() )
|
||||
m_pOldName->SetText( pSOCData->GetCustomName() );
|
||||
else
|
||||
m_pOldName->SetText( m_pSubjectModelPanel->GetItem()->GetStaticData()->GetItemBaseName() );
|
||||
}
|
||||
}
|
||||
|
||||
CExButton *pOKButton = dynamic_cast< CExButton* >( FindChildByName( "OkButton" ) );
|
||||
if ( pOKButton )
|
||||
{
|
||||
if ( m_bDescription )
|
||||
pOKButton->SetText( "#CraftDescribeOk" );
|
||||
}
|
||||
|
||||
m_pCustomNameEntry->SetMaximumCharCount( GetMaxLength() );
|
||||
m_pCustomNameEntry->SetAllowNonAsciiCharacters( true );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CRequestNameDialog::MoveToFront()
|
||||
{
|
||||
BaseClass::MoveToFront();
|
||||
|
||||
// do this after MoveToFront so we can force the text box to have focus instead
|
||||
// of the dialog itself
|
||||
m_pCustomNameEntry->RequestFocus();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CRequestNameDialog::Apply( void )
|
||||
{
|
||||
const int maxNameLength = MAX_ITEM_CUSTOM_DESC_LENGTH + 1;
|
||||
wchar_t inputName[ maxNameLength ];
|
||||
|
||||
m_pCustomNameEntry->GetText( inputName, sizeof(inputName) );
|
||||
|
||||
// pop up modal confirmation dialog
|
||||
CConfirmNameDialog *dialog = vgui::SETUP_PANEL( new CConfirmNameDialog( GetParent(), "ItemRenameConfirmationDialog", m_pToolModelPanel->GetItem(), m_pSubjectModelPanel->GetItem(), inputName, m_bDescription ) );
|
||||
MakeModalAndBringToFront( dialog );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Gives focus back to the name entry field after the mouse enters a
|
||||
// item model panel
|
||||
//-----------------------------------------------------------------------------
|
||||
void CRequestNameDialog::OnItemPanelEntered( vgui::Panel *panel )
|
||||
{
|
||||
CItemModelPanel *pItemPanel = dynamic_cast < CItemModelPanel * > ( panel );
|
||||
|
||||
if ( pItemPanel && IsVisible() )
|
||||
{
|
||||
// The item panel is going to try and steal our focus. Steal it back!
|
||||
m_pCustomNameEntry->RequestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
CConfirmNameDialog::CConfirmNameDialog( vgui::Panel *parent, const char* pszName, CEconItemView *pTool, CEconItemView *pToolSubject, const wchar_t *name, bool bDescription ) :
|
||||
CNameToolUsageDialog( parent, pszName, pTool, pToolSubject, bDescription )
|
||||
{
|
||||
Q_wcsncpy( m_name, name, sizeof(m_name) );
|
||||
m_bDescription = bDescription;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// We're going to want to flesh this out to trim off leading/training spaces, etc
|
||||
//
|
||||
bool CConfirmNameDialog::IsNameValid( void ) const
|
||||
{
|
||||
// legal names are 1 or more alphanumeric values (only)
|
||||
const wchar_t *c = m_name;
|
||||
int length = 0;
|
||||
while( *c )
|
||||
{
|
||||
// no leading spaces
|
||||
if ( length == 0 && *c == ' ' )
|
||||
return false;
|
||||
|
||||
++c;
|
||||
++length;
|
||||
}
|
||||
|
||||
// no trailing spaces
|
||||
if ( length > 0 && m_name[length-1] == ' ' )
|
||||
return false;
|
||||
|
||||
return (length > 0);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConfirmNameDialog::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
if ( !IsNameValid() )
|
||||
{
|
||||
// pop up bad name dialog
|
||||
LoadControlSettings( "resource/UI/ItemRenameInvalidDialog.res" );
|
||||
}
|
||||
else
|
||||
{
|
||||
// pop up "are you sure" dialog
|
||||
LoadControlSettings( "resource/UI/ItemRenameConfirmationDialog.res" );
|
||||
}
|
||||
|
||||
// Set our dialog name, but pre & post pend it with quotes
|
||||
wchar_t tmpname[ MAX_ITEM_CUSTOM_DESC_LENGTH+3 ];
|
||||
V_wcscpy_safe( tmpname, L"\"" );
|
||||
V_wcscat_safe( tmpname, m_name );
|
||||
V_wcscat_safe( tmpname, L"\"" );
|
||||
SetDialogVariable( "name", tmpname );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConfirmNameDialog::Apply( void )
|
||||
{
|
||||
// the GC stores 8-bit chars, so convert Unicode name to UTF8
|
||||
char* utf8Name = new char[ GetMaxDBSize() ];
|
||||
int count = V_UnicodeToUTF8( m_name, utf8Name, GetMaxDBSize() );
|
||||
|
||||
if ( count > GetMaxDBSize() )
|
||||
{
|
||||
// the encoded name exceeds the GC's storage limit
|
||||
return;
|
||||
}
|
||||
|
||||
if ( m_pSubjectModelPanel->GetItem()->GetItemID() != INVALID_ITEM_ID )
|
||||
{
|
||||
// Name has been confirmed - send message to GC to apply name to item
|
||||
GCSDK::CGCMsg< MsgGCNameItem_t > msg( k_EMsgGCNameItem );
|
||||
|
||||
msg.Body().m_unToolItemID = m_pToolModelPanel->GetItem()->GetItemID();
|
||||
msg.Body().m_unSubjectItemID = m_pSubjectModelPanel->GetItem()->GetItemID();
|
||||
msg.AddStrData( utf8Name );
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Name has been confirmed - send message to GC to apply name to item
|
||||
GCSDK::CGCMsg< MsgGCNameBaseItem_t > msg( k_EMsgGCNameBaseItem );
|
||||
|
||||
msg.Body().m_unToolItemID = m_pToolModelPanel->GetItem()->GetItemID();
|
||||
msg.Body().m_unBaseItemDefinitionID = m_pSubjectModelPanel->GetItem()->GetStaticData()->GetDefinitionIndex();
|
||||
msg.AddStrData( utf8Name );
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
}
|
||||
|
||||
if ( m_bDescription )
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pToolModelPanel->GetItem(), "redescription_item" );
|
||||
else
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pToolModelPanel->GetItem(), "renamed_item" );
|
||||
|
||||
delete []utf8Name;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConfirmNameDialog::OnCommand( const char *command )
|
||||
{
|
||||
BaseClass::OnCommand( command );
|
||||
|
||||
if ( !Q_stricmp( command, "backfrominvalid" ) )
|
||||
{
|
||||
// Re-open the name dialog
|
||||
CRequestNameDialog *dialog = vgui::SETUP_PANEL( new CRequestNameDialog( GetParent(), "ItemRenameDialog", m_pToolModelPanel->GetItem(), m_pSubjectModelPanel->GetItem(), m_bDescription ) );
|
||||
MakeModalAndBringToFront( dialog );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: GC Msg handler to receive the name base item response
|
||||
//-----------------------------------------------------------------------------
|
||||
class CGCNameBaseItemResponse : public GCSDK::CGCClientJob
|
||||
{
|
||||
public:
|
||||
CGCNameBaseItemResponse( GCSDK::CGCClient *pClient ) : GCSDK::CGCClientJob( pClient ) {}
|
||||
|
||||
virtual bool BYieldingRunGCJob( GCSDK::IMsgNetPacket *pNetPacket )
|
||||
{
|
||||
GCSDK::CGCMsg<MsgGCStandardResponse_t> msg( pNetPacket );
|
||||
InventoryManager()->ShowItemsPickedUp( true );
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
GC_REG_JOB( GCSDK::CGCClient, CGCNameBaseItemResponse, "CGCNameBaseItemResponse", k_EMsgGCNameBaseItemResponse, GCSDK::k_EServerTypeGCClient );
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: UI Hook for applying a new description to items.
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_DescTag::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CRequestNameDialog *dialog = vgui::SETUP_PANEL( new CRequestNameDialog( pParent, "ItemRenameDialog", pTool, pSubject, true ) );
|
||||
MakeModalAndBringToFront( dialog );
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef RENAME_TOOL_UI_H
|
||||
#define RENAME_TOOL_UI_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "tool_items.h"
|
||||
|
||||
class CNameToolUsageDialog : public CBaseToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CNameToolUsageDialog, CBaseToolUsageDialog );
|
||||
|
||||
public:
|
||||
CNameToolUsageDialog( vgui::Panel *pParent, const char* pszName, CEconItemView *pTool, CEconItemView *pToolSubject, bool bDescription );
|
||||
virtual int GetMaxLength();
|
||||
virtual int GetMaxDBSize();
|
||||
|
||||
protected:
|
||||
bool m_bDescription;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: A dialog used to input a Tool's name payload
|
||||
//-----------------------------------------------------------------------------
|
||||
class CRequestNameDialog : public CNameToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CRequestNameDialog, CNameToolUsageDialog );
|
||||
|
||||
public:
|
||||
CRequestNameDialog( vgui::Panel *pParent, const char* pszName, CEconItemView *pTool, CEconItemView *pToolSubject, bool bDescription );
|
||||
|
||||
virtual void MoveToFront();
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void Apply( void );
|
||||
|
||||
MESSAGE_FUNC_PTR( OnItemPanelEntered, "ItemPanelEntered", panel );
|
||||
|
||||
private:
|
||||
vgui::TextEntry *m_pCustomNameEntry;
|
||||
vgui::Label *m_pOldNameLabel;
|
||||
vgui::Label *m_pOldName;
|
||||
vgui::Label *m_pNewNameLabel;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Confirm name and commit or reject
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmNameDialog : public CNameToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmNameDialog, CNameToolUsageDialog );
|
||||
|
||||
public:
|
||||
CConfirmNameDialog( vgui::Panel *pParent, const char* pszName, CEconItemView *pTool, CEconItemView *pToolSubject, const wchar_t *name, bool bDescription );
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *scheme );
|
||||
virtual void Apply( void );
|
||||
virtual void OnCommand( const char *command );
|
||||
|
||||
private:
|
||||
wchar_t m_name[ MAX_ITEM_CUSTOM_DESC_LENGTH+1 ];
|
||||
|
||||
bool IsNameValid( void ) const;
|
||||
};
|
||||
|
||||
|
||||
#endif // RENAME_TOOL_UI_H
|
||||
@@ -0,0 +1,968 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
|
||||
#include "cbase.h"
|
||||
#include "vgui_controls/EditablePanel.h"
|
||||
#include "vgui_controls/TextEntry.h"
|
||||
#include "vgui_controls/TextImage.h"
|
||||
#include "vgui/IInput.h"
|
||||
#include "econ_item_system.h"
|
||||
#include "econ_item_constants.h"
|
||||
#include "econ_gcmessages.h"
|
||||
#include "econ_ui.h"
|
||||
#include "tool_items.h"
|
||||
#ifdef TF_CLIENT_DLL
|
||||
#include "tf_item_tools.h"
|
||||
#else
|
||||
#include "econ_item_tools.h"
|
||||
#endif
|
||||
#include <vgui/ILocalize.h>
|
||||
#include "gc_clientsystem.h"
|
||||
#include "item_style_select_dialog.h" // for CComboBoxBackpackOverlayDialogBase
|
||||
#include "backpack_panel.h"
|
||||
#include "vgui_controls/Controls.h"
|
||||
#include "vgui/ISurface.h"
|
||||
|
||||
#ifdef TF_CLIENT_DLL
|
||||
#include "character_info_panel.h"
|
||||
#include "c_tf_gamestats.h"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include <tier0/memdbgon.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CBaseToolUsageDialog::CBaseToolUsageDialog( vgui::Panel *parent, const char *panelName, CEconItemView *pTool, CEconItemView *pToolSubject ) : vgui::EditablePanel( parent, panelName )
|
||||
{
|
||||
m_pToolModelPanel = new CItemModelPanel( this, "tool_modelpanel" );
|
||||
m_pToolModelPanel->SetActAsButton( true, true );
|
||||
m_pSubjectModelPanel = new CItemModelPanel( this, "subject_modelpanel" );
|
||||
m_pSubjectModelPanel->SetActAsButton( true, true );
|
||||
m_pMouseOverItemPanel = vgui::SETUP_PANEL( new CItemModelPanel( this, "mouseoveritempanel" ) );
|
||||
|
||||
m_pMouseOverTooltip = new CItemModelPanelToolTip( this );
|
||||
m_pMouseOverTooltip->SetupPanels( this, m_pMouseOverItemPanel );
|
||||
m_pToolModelPanel->SetTooltip( m_pMouseOverTooltip, "" );
|
||||
m_pSubjectModelPanel->SetTooltip( m_pMouseOverTooltip, "" );
|
||||
|
||||
m_pToolModelPanel->SetItem( pTool );
|
||||
m_pToolModelPanel->SetShowEquipped( true );
|
||||
m_pSubjectModelPanel->SetItem( pToolSubject );
|
||||
m_pSubjectModelPanel->SetShowEquipped( true );
|
||||
|
||||
m_pTitleLabel = NULL;
|
||||
m_pszInternalPanelName = panelName ? panelName : "unknown";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseToolUsageDialog::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
SetDialogVariable( "oldname", m_pSubjectModelPanel->GetItem()->GetItemName() );
|
||||
|
||||
m_pTitleLabel = dynamic_cast<vgui::Label*>( FindChildByName("TitleLabel") );
|
||||
if ( m_pTitleLabel )
|
||||
{
|
||||
wchar_t *pszBaseString = g_pVGuiLocalize->Find( "ToolDialogTitle" );
|
||||
if ( pszBaseString )
|
||||
{
|
||||
wchar_t wTemp[256];
|
||||
g_pVGuiLocalize->ConstructString_safe( wTemp, pszBaseString, 2, m_pToolModelPanel->GetItem()->GetItemName(), m_pSubjectModelPanel->GetItem()->GetItemName() );
|
||||
m_pTitleLabel->SetText( wTemp );
|
||||
|
||||
// Now go through the string and find the escape characters telling us where the color changes are
|
||||
m_pTitleLabel->GetTextImage()->ClearColorChangeStream();
|
||||
|
||||
// We change the title's text color to match the colors of the matching model panel backgrounds
|
||||
wchar_t *txt = wTemp;
|
||||
int iWChars = 0;
|
||||
Color colCustom;
|
||||
while ( txt && *txt )
|
||||
{
|
||||
switch ( *txt )
|
||||
{
|
||||
case 0x01: // Normal color
|
||||
m_pTitleLabel->GetTextImage()->AddColorChange( Color(235,226,202,255), iWChars );
|
||||
break;
|
||||
case 0x02: // Item 1 color
|
||||
m_pTitleLabel->GetTextImage()->AddColorChange( Color(112,176,74,255), iWChars );
|
||||
break;
|
||||
case 0x03: // Item 2 color
|
||||
m_pTitleLabel->GetTextImage()->AddColorChange( Color(71,98,145,255), iWChars );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
txt++;
|
||||
iWChars++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vgui::Panel *pToolIcon = FindChildByName( "tool_icon" );
|
||||
if ( pToolIcon )
|
||||
{
|
||||
pToolIcon->SetMouseInputEnabled( false );
|
||||
pToolIcon->SetKeyBoardInputEnabled( false );
|
||||
}
|
||||
vgui::Panel *pSubjectIcon = FindChildByName( "subject_icon" );
|
||||
if ( pSubjectIcon )
|
||||
{
|
||||
pSubjectIcon->SetMouseInputEnabled( false );
|
||||
pSubjectIcon->SetKeyBoardInputEnabled( false );
|
||||
}
|
||||
|
||||
// @note Tom Bui: because the children have already applied their scheme settings and/or performed their layout before
|
||||
// this dialog has had a chance to load its res file, we need to manually invalidate the layout of these children
|
||||
// to make sure that the settings are valid with respect to what the parent wants
|
||||
m_pToolModelPanel->UpdatePanels();
|
||||
m_pSubjectModelPanel->UpdatePanels();
|
||||
m_pMouseOverItemPanel->SetBorder( pScheme->GetBorder("LoadoutItemPopupBorder") );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseToolUsageDialog::PerformLayout()
|
||||
{
|
||||
BaseClass::PerformLayout();
|
||||
// if ( m_pMouseOverItemPanel->IsVisible() )
|
||||
// {
|
||||
// // The mouseover panel was visible. Fake a panel entry into the original panel to get it to show up again properly.
|
||||
// if ( m_pItemPanelBeingMousedOver )
|
||||
// {
|
||||
// OnItemPanelEntered( m_pItemPanelBeingMousedOver );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// HideMouseOverPanel();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseToolUsageDialog::OnCommand( const char *command )
|
||||
{
|
||||
// in any case, our dialog is going away
|
||||
TFModalStack()->PopModal( this );
|
||||
SetVisible( false );
|
||||
MarkForDeletion();
|
||||
|
||||
#ifdef TF_CLIENT_DLL
|
||||
const char *pSubjectBaseName = m_pSubjectModelPanel && m_pSubjectModelPanel->GetItem() && m_pSubjectModelPanel->GetItem()->GetItemDefinition()
|
||||
? m_pSubjectModelPanel->GetItem()->GetItemDefinition()->GetItemBaseName()
|
||||
: "n/a";
|
||||
#endif
|
||||
|
||||
if ( !Q_stricmp( command, "apply" ) )
|
||||
{
|
||||
#ifdef TF_CLIENT_DLL
|
||||
C_CTFGameStats::ImmediateWriteInterfaceEvent( CFmtStr( "tool_usage_proceed(%s)", m_pszInternalPanelName ).Access(),
|
||||
pSubjectBaseName );
|
||||
#endif
|
||||
// Call before Apply() in case it creates new dialogs that wants to handle prevention
|
||||
EconUI()->SetPreventClosure( false );
|
||||
Apply();
|
||||
}
|
||||
else // "cancel"
|
||||
{
|
||||
#ifdef TF_CLIENT_DLL
|
||||
C_CTFGameStats::ImmediateWriteInterfaceEvent( CFmtStr( "tool_usage_cancel(%s)", m_pszInternalPanelName ).Access(),
|
||||
pSubjectBaseName );
|
||||
#endif
|
||||
|
||||
EconUI()->SetPreventClosure( false );
|
||||
|
||||
IGameEvent *event = gameeventmanager->CreateEvent( "inventory_updated" );
|
||||
if ( event )
|
||||
{
|
||||
gameeventmanager->FireEventClientSide( event );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Utility function
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseToolUsageDialog::OnKeyCodeTyped( vgui::KeyCode code )
|
||||
{
|
||||
if( code == KEY_ESCAPE )
|
||||
{
|
||||
OnCommand( "cancel" );
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodeTyped( code );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Utility function
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseToolUsageDialog::OnKeyCodePressed( vgui::KeyCode code )
|
||||
{
|
||||
ButtonCode_t nButtonCode = GetBaseButtonCode( code );
|
||||
|
||||
if (nButtonCode == KEY_XBUTTON_LEFT ||
|
||||
nButtonCode == KEY_XSTICK1_LEFT ||
|
||||
nButtonCode == KEY_XSTICK2_LEFT ||
|
||||
nButtonCode == STEAMCONTROLLER_DPAD_LEFT ||
|
||||
code == KEY_LEFT ||
|
||||
nButtonCode == KEY_XBUTTON_RIGHT ||
|
||||
nButtonCode == KEY_XSTICK1_RIGHT ||
|
||||
nButtonCode == KEY_XSTICK2_RIGHT ||
|
||||
nButtonCode == STEAMCONTROLLER_DPAD_RIGHT ||
|
||||
code == KEY_RIGHT ||
|
||||
nButtonCode == KEY_XBUTTON_UP ||
|
||||
nButtonCode == KEY_XSTICK1_UP ||
|
||||
nButtonCode == KEY_XSTICK2_UP ||
|
||||
nButtonCode == STEAMCONTROLLER_DPAD_UP ||
|
||||
code == KEY_UP ||
|
||||
nButtonCode == KEY_XBUTTON_DOWN ||
|
||||
nButtonCode == KEY_XSTICK1_DOWN ||
|
||||
nButtonCode == KEY_XSTICK2_DOWN ||
|
||||
nButtonCode == STEAMCONTROLLER_DPAD_DOWN ||
|
||||
code == KEY_DOWN )
|
||||
{
|
||||
// eat all the movement keys so the selection doesn't update behind the dialog
|
||||
}
|
||||
else if( nButtonCode == KEY_XBUTTON_A || code == KEY_ENTER || nButtonCode == STEAMCONTROLLER_A )
|
||||
{
|
||||
OnCommand( "apply" );
|
||||
}
|
||||
else if( nButtonCode == KEY_XBUTTON_B || nButtonCode == STEAMCONTROLLER_B )
|
||||
{
|
||||
OnCommand( "cancel" );
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseClass::OnKeyCodePressed( code );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Utility function
|
||||
//-----------------------------------------------------------------------------
|
||||
void MakeModalAndBringToFront( vgui::EditablePanel *dialog )
|
||||
{
|
||||
dialog->SetVisible( true );
|
||||
if ( dialog->GetParent() == NULL )
|
||||
{
|
||||
dialog->MakePopup();
|
||||
}
|
||||
dialog->SetZPos( 10000 );
|
||||
dialog->MoveToFront();
|
||||
dialog->SetKeyBoardInputEnabled( true );
|
||||
dialog->SetMouseInputEnabled( true );
|
||||
TFModalStack()->PushModal( dialog );
|
||||
|
||||
EconUI()->SetPreventClosure( true );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Given a tool and an item to apply the tool's effects upon,
|
||||
// gather required information from the user and
|
||||
// send a change request to the GC.
|
||||
//
|
||||
bool ApplyTool( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject )
|
||||
{
|
||||
if ( !pTool || !pToolSubject )
|
||||
return false;
|
||||
|
||||
if ( !CEconSharedToolSupport::ToolCanApplyTo( pTool, pToolSubject ) )
|
||||
return false;
|
||||
|
||||
// this tool can be applied to this subject item
|
||||
const IEconTool *pEconTool = pTool->GetStaticData()->GetEconTool();
|
||||
if ( !pEconTool )
|
||||
return false;
|
||||
|
||||
pEconTool->OnClientApplyTool( pTool, pToolSubject, pParent );
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: STRANGE COUNT TRANSFER
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmStrangeCountTransferApplicationDialog : public CBaseToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmStrangeCountTransferApplicationDialog, CBaseToolUsageDialog );
|
||||
|
||||
public:
|
||||
CConfirmStrangeCountTransferApplicationDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject )
|
||||
: CBaseToolUsageDialog( pParent, "ConfirmApplyStrangeCountTransferDialog", pTool, pToolSubject )
|
||||
{
|
||||
m_pItemSrc = NULL;
|
||||
m_pItemDest = NULL;
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/econ/ConfirmApplyDuckTokenDialog.res" ); // fix me
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
virtual void Apply( void )
|
||||
{
|
||||
GCSDK::CProtoBufMsg<CMsgApplyStrangeCountTransfer> msg( k_EMsgGCApplyStrangeCountTransfer );
|
||||
|
||||
if ( !m_pItemSrc || !m_pItemDest )
|
||||
return;
|
||||
|
||||
msg.Body().set_tool_item_id( m_pToolModelPanel->GetItem()->GetItemID() );
|
||||
msg.Body().set_item_src_item_id( m_pItemSrc->GetItemID() );
|
||||
msg.Body().set_item_dest_item_id( m_pItemDest->GetItemID() );
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pToolModelPanel->GetItem(), "applied_strangecounttransfer", m_pToolModelPanel->GetItem()->GetItemDefIndex() );
|
||||
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
}
|
||||
|
||||
bool SetItems( CEconItemView *pItemSrc, CEconItemView *pItemDest )
|
||||
{
|
||||
if ( !pItemSrc || !pItemDest )
|
||||
return false;
|
||||
|
||||
if ( CEconTool_StrangeCountTransfer::AreItemsEligibleForStrangeCountTransfer( pItemSrc, pItemDest ) )
|
||||
{
|
||||
m_pItemSrc = pItemSrc;
|
||||
m_pItemDest = pItemDest;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
CEconItemView *m_pItemSrc;
|
||||
CEconItemView *m_pItemDest;
|
||||
};
|
||||
|
||||
/*static */bool CEconTool_StrangeCountTransfer::SetItems( CEconItemView *pItemSrc, CEconItemView *pItemDest )
|
||||
{
|
||||
if ( !pItemSrc || !pItemDest )
|
||||
return false;
|
||||
|
||||
if ( CEconTool_StrangeCountTransfer::AreItemsEligibleForStrangeCountTransfer( pItemSrc, pItemDest ) )
|
||||
{
|
||||
CEconTool_StrangeCountTransfer::m_pItemSrc = pItemSrc;
|
||||
CEconTool_StrangeCountTransfer::m_pItemDest = pItemDest;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_StrangeCountTransfer::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CConfirmStrangeCountTransferApplicationDialog *pDialog = vgui::SETUP_PANEL( new CConfirmStrangeCountTransferApplicationDialog( pParent, pTool, pSubject ) );
|
||||
MakeModalAndBringToFront( pDialog );
|
||||
}
|
||||
|
||||
|
||||
// ****************************************************************************
|
||||
// STRANGE PARTS
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Confirm / abort strange part application
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmStrangePartApplicationDialog : public CBaseToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmStrangePartApplicationDialog, CBaseToolUsageDialog );
|
||||
|
||||
public:
|
||||
CConfirmStrangePartApplicationDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject );
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void Apply( void );
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CConfirmStrangePartApplicationDialog::CConfirmStrangePartApplicationDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject )
|
||||
: CBaseToolUsageDialog( pParent, "ConfirmApplyStrangePartApplicationDialog", pTool, pToolSubject )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConfirmStrangePartApplicationDialog::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/econ/ConfirmApplyStrangePartApplicationDialog.res" );
|
||||
|
||||
int iRemainingStrangePartSlots = 0;
|
||||
for ( int i = 0; i < GetKillEaterAttrCount(); i++ )
|
||||
{
|
||||
if ( !GetKillEaterAttr_IsUserCustomizable( i ) )
|
||||
continue;
|
||||
|
||||
if ( !m_pSubjectModelPanel->GetItem()->FindAttribute( GetKillEaterAttr_Score( i ) ) )
|
||||
++iRemainingStrangePartSlots;
|
||||
}
|
||||
|
||||
SetDialogVariable( "remaining_strange_part_slots", iRemainingStrangePartSlots );
|
||||
SetDialogVariable( "maximum_strange_part_slots", GetKillEaterAttrCount_UserCustomizable() );
|
||||
SetDialogVariable( "subject_item_def_name", GLocalizationProvider()->Find( m_pSubjectModelPanel->GetItem()->GetItemDefinition()->GetItemBaseName() ) );
|
||||
SetDialogVariable( "slot_singular_plural", GLocalizationProvider()->Find( iRemainingStrangePartSlots == 1 ? "#Econ_FreeSlot_Singular" : "#Econ_FreeSlot_Plural" ) );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConfirmStrangePartApplicationDialog::Apply()
|
||||
{
|
||||
GCSDK::CProtoBufMsg<CMsgApplyStrangePart> msg( k_EMsgGCApplyStrangePart );
|
||||
|
||||
msg.Body().set_strange_part_item_id( m_pSubjectModelPanel->GetItem()->GetItemID() );
|
||||
msg.Body().set_item_item_id( m_pToolModelPanel->GetItem()->GetItemID() );
|
||||
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pToolModelPanel->GetItem(), "applied_strange_part", m_pToolModelPanel->GetItem()->GetItemDefIndex() );
|
||||
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_StrangePart::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CConfirmStrangePartApplicationDialog *pDialog = vgui::SETUP_PANEL( new CConfirmStrangePartApplicationDialog( pParent, pTool, pSubject ) );
|
||||
MakeModalAndBringToFront( pDialog );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Confirm / abort strange restriction application
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmStrangeRestrictionApplicationDialog : public CBaseToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmStrangeRestrictionApplicationDialog, CBaseToolUsageDialog );
|
||||
|
||||
public:
|
||||
CConfirmStrangeRestrictionApplicationDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject, int iStrangeSlot, const char *pszStatLocalizationToken );
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme );
|
||||
virtual void Apply( void );
|
||||
|
||||
private:
|
||||
int m_iStrangeSlot;
|
||||
const char *m_pszStatLocalizationToken;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
CConfirmStrangeRestrictionApplicationDialog::CConfirmStrangeRestrictionApplicationDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject, int iStrangeSlot, const char *pszStatLocalizationToken )
|
||||
: CBaseToolUsageDialog( pParent, "ConfirmApplyStrangeRestrictionApplicationDialog", pTool, pToolSubject )
|
||||
, m_iStrangeSlot( iStrangeSlot )
|
||||
, m_pszStatLocalizationToken( pszStatLocalizationToken )
|
||||
{
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConfirmStrangeRestrictionApplicationDialog::ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/econ/ConfirmApplyStrangeRestrictionApplicationDialog.res" );
|
||||
|
||||
SetDialogVariable( "stat_name", GLocalizationProvider()->Find( m_pszStatLocalizationToken ) );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConfirmStrangeRestrictionApplicationDialog::Apply()
|
||||
{
|
||||
GCSDK::CProtoBufMsg<CMsgApplyStrangeRestriction> msg( k_EMsgGCApplyStrangeRestriction );
|
||||
|
||||
msg.Body().set_strange_part_item_id( m_pSubjectModelPanel->GetItem()->GetItemID() );
|
||||
msg.Body().set_item_item_id( m_pToolModelPanel->GetItem()->GetItemID() );
|
||||
msg.Body().set_strange_attr_index( m_iStrangeSlot );
|
||||
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pToolModelPanel->GetItem(), "applied_strange_restriction", m_pToolModelPanel->GetItem()->GetItemDefIndex() );
|
||||
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSelectStrangePartToRestrictDialog : public CComboBoxBackpackOverlayDialogBase
|
||||
{
|
||||
public:
|
||||
DECLARE_CLASS_SIMPLE( CSelectStrangePartToRestrictDialog, CComboBoxBackpackOverlayDialogBase );
|
||||
|
||||
public:
|
||||
CSelectStrangePartToRestrictDialog( vgui::Panel *pParent, CEconItemView *pToolItem, CEconItemView *pSubjectItem )
|
||||
: CComboBoxBackpackOverlayDialogBase( pParent, pSubjectItem )
|
||||
, m_ToolItem( *pToolItem )
|
||||
, m_SubjectItem( *pSubjectItem )
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
private:
|
||||
virtual void PopulateComboBoxOptions()
|
||||
{
|
||||
const wchar_t *pLocBase = GLocalizationProvider()->Find( "#ApplyStrangeRestrictionCombo" );
|
||||
|
||||
const CEconTool_StrangePartRestriction *pToolRestriction = m_ToolItem.GetItemDefinition()->GetTypedEconTool<CEconTool_StrangePartRestriction>();
|
||||
Assert( pToolRestriction );
|
||||
|
||||
KeyValues *pKeyValues = new KeyValues( "data" );
|
||||
for ( int i = 0; i < GetKillEaterAttrCount(); i++ )
|
||||
{
|
||||
uint32 unScoreType;
|
||||
if ( !GetItemSchema()->BCanStrangeFilterApplyToStrangeSlotInItem( pToolRestriction->GetRestrictionType(), pToolRestriction->GetRestrictionValue(), &m_SubjectItem, i, &unScoreType ) )
|
||||
continue;
|
||||
|
||||
const char *pszTypeLocKey = GetItemSchema()->GetKillEaterScoreTypeLocString( unScoreType );
|
||||
if ( !pszTypeLocKey )
|
||||
continue;
|
||||
|
||||
pKeyValues->SetInt( "data", i );
|
||||
pKeyValues->SetString( "token", pszTypeLocKey );
|
||||
|
||||
GetComboBox()->AddItem( CConstructLocalizedString( pLocBase, GLocalizationProvider()->Find( pszTypeLocKey ) ), pKeyValues );
|
||||
}
|
||||
pKeyValues->deleteThis();
|
||||
|
||||
Assert( GetComboBox()->GetItemCount() > 0 );
|
||||
|
||||
GetComboBox()->ActivateItemByRow( 0 );
|
||||
}
|
||||
|
||||
virtual void OnComboBoxApplication()
|
||||
{
|
||||
KeyValues *pKVActiveUserData = GetComboBox()->GetActiveItemUserData();
|
||||
int iIndex = pKVActiveUserData ? pKVActiveUserData->GetInt( "data", -1 ) : -1;
|
||||
if ( iIndex < 0 )
|
||||
return;
|
||||
|
||||
// FIXME: CConfirmStrangePartApplicationDialog is wrong class
|
||||
CConfirmStrangeRestrictionApplicationDialog *pDialog = vgui::SETUP_PANEL( new CConfirmStrangeRestrictionApplicationDialog( GetParent(), &m_ToolItem, &m_SubjectItem, iIndex, pKVActiveUserData ? pKVActiveUserData->GetString( "token", NULL ) : NULL ) );
|
||||
MakeModalAndBringToFront( pDialog );
|
||||
}
|
||||
|
||||
virtual const char *GetTitleLabelLocalizationToken() const { return "#ApplyStrangeRestrictionPartTitle"; }
|
||||
|
||||
private:
|
||||
CEconItemView m_ToolItem;
|
||||
CEconItemView m_SubjectItem;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_StrangePartRestriction::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
if ( EconUI()->GetBackpackPanel() )
|
||||
{
|
||||
EconUI()->GetBackpackPanel()->SetComboBoxOverlaySelectionItem( pSubject );
|
||||
}
|
||||
|
||||
CSelectStrangePartToRestrictDialog *pDialog = vgui::SETUP_PANEL( new CSelectStrangePartToRestrictDialog( pParent, pTool, pSubject ) );
|
||||
MakeModalAndBringToFront( pDialog );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class CWaitingDialog : public CGenericWaitingDialog
|
||||
{
|
||||
public:
|
||||
CWaitingDialog( vgui::Panel *pParent ) : CGenericWaitingDialog( pParent )
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void OnTimeout()
|
||||
{
|
||||
// Play an exciting sound!
|
||||
vgui::surface()->PlaySound( "misc/achievement_earned.wav" );
|
||||
|
||||
// Show them the result item.
|
||||
InventoryManager()->ShowItemsPickedUp( true );
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Confirm / abort card upgrade tool application
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmApplyStrangifierDialog : public CBaseToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmApplyStrangifierDialog, CBaseToolUsageDialog );
|
||||
|
||||
public:
|
||||
CConfirmApplyStrangifierDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject, const char *pszPromptLocToken, const char *pszTransactionReason, const char *pszUpdatingText = "" )
|
||||
: CBaseToolUsageDialog( pParent, "ConfirmApplyStrangifierDialog", pTool, pToolSubject )
|
||||
, m_sPromptLocToken( pszPromptLocToken )
|
||||
, m_sTransactionReason( pszTransactionReason )
|
||||
, m_sUpdatingText( pszUpdatingText )
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/econ/ConfirmApplyStrangifierDialog.res" );
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
|
||||
CExLabel* pTextLabel = dynamic_cast<CExLabel*>( FindChildByName( "ConfirmLabel" ) );
|
||||
if( pTextLabel && m_pToolModelPanel )
|
||||
{
|
||||
wchar_t *pszBaseString = g_pVGuiLocalize->Find( m_sPromptLocToken );
|
||||
wchar_t wTempFinalString[1024] = { 0 };
|
||||
if ( pszBaseString )
|
||||
{
|
||||
V_wcscpy_safe( wTempFinalString, pszBaseString );
|
||||
}
|
||||
|
||||
// If the strangifier is untradable, add an extra warning in the prompt to let the user know
|
||||
if( m_pToolModelPanel->GetItem() && !m_pToolModelPanel->GetItem()->IsTradable() &&
|
||||
m_pSubjectModelPanel && m_pSubjectModelPanel->GetItem() )
|
||||
{
|
||||
wchar_t *pszUntradableString = g_pVGuiLocalize->Find( "ToolStrangifierUntradableWarning" );
|
||||
|
||||
// Stick the names of the items into the string
|
||||
wchar_t wTempUntradable[1024] = { 0 };
|
||||
g_pVGuiLocalize->ConstructString_safe( wTempUntradable, pszUntradableString, 2, m_pToolModelPanel->GetItem()->GetItemName(), m_pSubjectModelPanel->GetItem()->GetItemName() );
|
||||
|
||||
// Concat onto the the original string
|
||||
V_wcscat_safe( wTempFinalString, wTempUntradable, sizeof( wTempUntradable ) );
|
||||
}
|
||||
|
||||
pTextLabel->SetText( wTempFinalString );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
virtual void Apply( void )
|
||||
{
|
||||
if ( m_pSubjectModelPanel->GetItem()->GetItemID() != INVALID_ITEM_ID )
|
||||
{
|
||||
GCSDK::CProtoBufMsg<CMsgApplyToolToItem> msg( k_EMsgGCApplyXifier );
|
||||
msg.Body().set_tool_item_id( m_pToolModelPanel->GetItem()->GetItemID() );
|
||||
msg.Body().set_subject_item_id( m_pSubjectModelPanel->GetItem()->GetItemID() );
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
}
|
||||
else
|
||||
{
|
||||
GCSDK::CProtoBufMsg<CMsgApplyToolToBaseItem> msg( k_EMsgGCApplyBaseItemXifier );
|
||||
msg.Body().set_tool_item_id( m_pToolModelPanel->GetItem()->GetItemID() );
|
||||
msg.Body().set_baseitem_def_index( m_pSubjectModelPanel->GetItem()->GetStaticData()->GetDefinitionIndex() );
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
}
|
||||
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pToolModelPanel->GetItem(), m_sTransactionReason.String() );
|
||||
|
||||
if ( *m_sUpdatingText.String() )
|
||||
{
|
||||
vgui::surface()->PlaySound( "ui/item_gift_wrap_use.wav" );
|
||||
ShowWaitingDialog( new CWaitingDialog( NULL ), m_sUpdatingText.String(), true, false, 5.0f );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
CUtlString m_sPromptLocToken;
|
||||
CUtlString m_sTransactionReason;
|
||||
CUtlString m_sUpdatingText;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_Strangifier::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CConfirmApplyStrangifierDialog *pDialog = vgui::SETUP_PANEL( new CConfirmApplyStrangifierDialog( pParent, pTool, pSubject, "ToolStrangifierConfirm", "strangified_item" ) );
|
||||
MakeModalAndBringToFront( pDialog );
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_KillStreakifier::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CConfirmApplyStrangifierDialog *pDialog = vgui::SETUP_PANEL( new CConfirmApplyStrangifierDialog( pParent, pTool, pSubject, "ToolKillStreakifierConfirm", "killstreakified_item" ) );
|
||||
MakeModalAndBringToFront( pDialog );
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_Festivizer::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CConfirmApplyStrangifierDialog *pDialog = vgui::SETUP_PANEL( new CConfirmApplyStrangifierDialog( pParent, pTool, pSubject, "ToolFestivizerConfirm", "festivized_item", "#ToolFestivizerInProgress" ) );
|
||||
MakeModalAndBringToFront( pDialog );
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_Unusualifier::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CConfirmApplyStrangifierDialog *pDialog = vgui::SETUP_PANEL( new CConfirmApplyStrangifierDialog( pParent, pTool, pSubject, "ToolUnusualifierConfirm", "unusualified_item", "#ToolUnusualifierInProgress" ) );
|
||||
MakeModalAndBringToFront( pDialog );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmUseItemEaterRechargerDialog : public CBaseToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmUseItemEaterRechargerDialog, CBaseToolUsageDialog );
|
||||
|
||||
public:
|
||||
CConfirmUseItemEaterRechargerDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject )
|
||||
: CBaseToolUsageDialog( pParent, "ConfirmUseItemEaterRechargerDialog", pTool, pToolSubject )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/econ/ConfirmUseItemEaterRechargerDialog.res" );
|
||||
|
||||
// Find the number of charges to add by looking at item tool rescritions.
|
||||
const CEconTool_ItemEaterRecharger *pTool = m_pToolModelPanel->GetItem()->GetItemDefinition()->GetTypedEconTool<CEconTool_ItemEaterRecharger>();
|
||||
if ( pTool )
|
||||
{
|
||||
int iCharges = pTool->GetChargesForItemDefId( m_pSubjectModelPanel->GetItem()->GetItemDefIndex() );
|
||||
SetDialogVariable( "charges_added", iCharges );
|
||||
}
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
virtual void Apply( void )
|
||||
{
|
||||
GCSDK::CProtoBufMsg<CMsgApplyToolToItem> msg( k_EMsgGCItemEaterRecharger );
|
||||
msg.Body().set_tool_item_id( m_pToolModelPanel->GetItem()->GetItemID() );
|
||||
msg.Body().set_subject_item_id( m_pSubjectModelPanel->GetItem()->GetItemID() );
|
||||
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pToolModelPanel->GetItem(), "recharging_item" );
|
||||
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_ItemEaterRecharger::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CConfirmUseItemEaterRechargerDialog *pDialog = vgui::SETUP_PANEL( new CConfirmUseItemEaterRechargerDialog( pParent, pTool, pSubject ) );
|
||||
MakeModalAndBringToFront( pDialog );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Confirm / abort card upgrade tool application
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmCardUpgradeApplicationDialog : public CBaseToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmCardUpgradeApplicationDialog, CBaseToolUsageDialog );
|
||||
|
||||
public:
|
||||
CConfirmCardUpgradeApplicationDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject )
|
||||
: CBaseToolUsageDialog( pParent, "ConfirmApplyCardUpgradeApplicationDialog", pTool, pToolSubject )
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/econ/ConfirmApplyCardUpgradeApplicationDialog.res" );
|
||||
|
||||
// See how many card upgrades have already been applied
|
||||
CCountUserGeneratedAttributeIterator countIterator;
|
||||
m_pSubjectModelPanel->GetItem()->IterateAttributes( &countIterator );
|
||||
|
||||
int iRemainingStrangePartSlots = GetMaxCardUpgradesPerItem() - countIterator.GetCount();
|
||||
|
||||
SetDialogVariable( "remaining_upgrade_card_slots", iRemainingStrangePartSlots );
|
||||
SetDialogVariable( "subject_item_def_name", GLocalizationProvider()->Find( m_pSubjectModelPanel->GetItem()->GetItemDefinition()->GetItemBaseName() ) );
|
||||
SetDialogVariable( "slot_singular_plural", GLocalizationProvider()->Find( iRemainingStrangePartSlots == 1 ? "#Econ_FreeSlot_Singular" : "#Econ_FreeSlot_Plural" ) );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
virtual void Apply( void )
|
||||
{
|
||||
GCSDK::CProtoBufMsg<CMsgApplyUpgradeCard> msg( k_EMsgGCApplyUpgradeCard );
|
||||
|
||||
msg.Body().set_upgrade_card_item_id( m_pSubjectModelPanel->GetItem()->GetItemID() );
|
||||
msg.Body().set_subject_item_id( m_pToolModelPanel->GetItem()->GetItemID() );
|
||||
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pToolModelPanel->GetItem(), "applied_upgrade_card", m_pToolModelPanel->GetItem()->GetItemDefIndex() );
|
||||
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_UpgradeCard::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CConfirmCardUpgradeApplicationDialog *pDialog = vgui::SETUP_PANEL( new CConfirmCardUpgradeApplicationDialog( pParent, pTool, pSubject ) );
|
||||
MakeModalAndBringToFront( pDialog );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmTransmogrifyApplicationDialog : public CBaseToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmTransmogrifyApplicationDialog, CBaseToolUsageDialog );
|
||||
|
||||
public:
|
||||
CConfirmTransmogrifyApplicationDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject )
|
||||
: CBaseToolUsageDialog( pParent, "ConfirmTransmogrifyApplicationDialog", pTool, pToolSubject )
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/econ/ConfirmTransmogrifyApplicationDialog.res" );
|
||||
|
||||
const CEconTool_ClassTransmogrifier *pTool = m_pToolModelPanel->GetItem()->GetItemDefinition()->GetTypedEconTool<CEconTool_ClassTransmogrifier>();
|
||||
Assert( pTool );
|
||||
|
||||
if ( pTool )
|
||||
{
|
||||
int iOutputClass = pTool->GetOutputClass();
|
||||
if ( iOutputClass > 0 && iOutputClass < LOADOUT_COUNT )
|
||||
{
|
||||
SetDialogVariable( "output_class", GLocalizationProvider()->Find( g_aPlayerClassNames[ iOutputClass ] ) );
|
||||
}
|
||||
}
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
virtual void Apply( void )
|
||||
{
|
||||
GCSDK::CProtoBufMsg<CMsgApplyToolToItem> msg( k_EMsgGCApplyClassTransmogrifier );
|
||||
|
||||
msg.Body().set_tool_item_id( m_pToolModelPanel->GetItem()->GetItemID() );
|
||||
msg.Body().set_subject_item_id( m_pSubjectModelPanel->GetItem()->GetItemID() );
|
||||
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pToolModelPanel->GetItem(), "applied_transmogrifier", m_pToolModelPanel->GetItem()->GetItemDefIndex() );
|
||||
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_ClassTransmogrifier::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CConfirmTransmogrifyApplicationDialog *pDialog = vgui::SETUP_PANEL( new CConfirmTransmogrifyApplicationDialog( pParent, pTool, pSubject ) );
|
||||
MakeModalAndBringToFront( pDialog );
|
||||
}
|
||||
|
||||
#ifdef TF_CLIENT_DLL
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmSpellbookPageApplicationDialog : public CBaseToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmSpellbookPageApplicationDialog, CBaseToolUsageDialog );
|
||||
|
||||
public:
|
||||
CConfirmSpellbookPageApplicationDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject )
|
||||
: CBaseToolUsageDialog( pParent, "ConfirmSpellbookPageApplicationDialog", pTool, pToolSubject )
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/econ/ConfirmSpellbookPageApplicationDialog.res" );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
virtual void Apply( void )
|
||||
{
|
||||
GCSDK::CProtoBufMsg<CMsgApplyToolToItem> msg( k_EMsgGCApplyHalloweenSpellbookPage );
|
||||
|
||||
msg.Body().set_tool_item_id( m_pToolModelPanel->GetItem()->GetItemID() );
|
||||
msg.Body().set_subject_item_id( m_pSubjectModelPanel->GetItem()->GetItemID() );
|
||||
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pToolModelPanel->GetItem(), "applied_spellbook_page", m_pToolModelPanel->GetItem()->GetItemDefIndex() );
|
||||
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_TFSpellbookPage::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CConfirmSpellbookPageApplicationDialog *pDialog = vgui::SETUP_PANEL( new CConfirmSpellbookPageApplicationDialog( pParent, pTool, pSubject ) );
|
||||
MakeModalAndBringToFront( pDialog );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class CConfirmDuckTokenApplicationDialog : public CBaseToolUsageDialog
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CConfirmDuckTokenApplicationDialog, CBaseToolUsageDialog );
|
||||
|
||||
public:
|
||||
CConfirmDuckTokenApplicationDialog( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject )
|
||||
: CBaseToolUsageDialog( pParent, "ConfirmApplyDuckTokenDialog", pTool, pToolSubject )
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *pScheme )
|
||||
{
|
||||
LoadControlSettings( "Resource/UI/econ/ConfirmApplyDuckTokenDialog.res" );
|
||||
|
||||
BaseClass::ApplySchemeSettings( pScheme );
|
||||
}
|
||||
|
||||
virtual void Apply( void )
|
||||
{
|
||||
GCSDK::CProtoBufMsg<CMsgApplyToolToItem> msg( k_EMsgGCApplyDuckToken );
|
||||
|
||||
msg.Body().set_tool_item_id( m_pToolModelPanel->GetItem()->GetItemID() );
|
||||
msg.Body().set_subject_item_id( m_pSubjectModelPanel->GetItem()->GetItemID() );
|
||||
|
||||
EconUI()->Gamestats_ItemTransaction( IE_ITEM_USED_TOOL, m_pToolModelPanel->GetItem(), "applied_ducktoken", m_pToolModelPanel->GetItem()->GetItemDefIndex() );
|
||||
|
||||
GCClientSystem()->BSendMessage( msg );
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CEconTool_DuckToken::OnClientApplyTool( CEconItemView *pTool, CEconItemView *pSubject, vgui::Panel *pParent ) const
|
||||
{
|
||||
CConfirmDuckTokenApplicationDialog *pDialog = vgui::SETUP_PANEL( new CConfirmDuckTokenApplicationDialog( pParent, pTool, pSubject ) );
|
||||
MakeModalAndBringToFront( pDialog );
|
||||
}
|
||||
#endif // TF_CLIENT_DLL
|
||||
@@ -0,0 +1,58 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef TOOL_ITEMS_H
|
||||
#define TOOL_ITEMS_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "item_model_panel.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBaseToolUsageDialog : public vgui::EditablePanel
|
||||
{
|
||||
DECLARE_CLASS_SIMPLE( CBaseToolUsageDialog, vgui::EditablePanel );
|
||||
|
||||
public:
|
||||
CBaseToolUsageDialog( vgui::Panel *pParent, const char *panelName, CEconItemView *pTool, CEconItemView *pToolSubject );
|
||||
|
||||
virtual void ApplySchemeSettings( vgui::IScheme *scheme );
|
||||
virtual void PerformLayout();
|
||||
virtual void OnCommand( const char *command );
|
||||
virtual void OnKeyCodeTyped( vgui::KeyCode code ) OVERRIDE;
|
||||
virtual void OnKeyCodePressed( vgui::KeyCode code ) OVERRIDE;
|
||||
|
||||
virtual void Apply( void ) { return; }
|
||||
|
||||
inline CEconItemView *GetToolItem() { return m_pToolModelPanel->GetItem(); };
|
||||
inline CEconItemView *GetSubjectItem() { return m_pSubjectModelPanel->GetItem(); };
|
||||
|
||||
protected:
|
||||
CItemModelPanel *m_pToolModelPanel;
|
||||
CItemModelPanel *m_pSubjectModelPanel;
|
||||
CItemModelPanel *m_pMouseOverItemPanel;
|
||||
CItemModelPanelToolTip *m_pMouseOverTooltip;
|
||||
vgui::Label *m_pTitleLabel;
|
||||
|
||||
const char *m_pszInternalPanelName;
|
||||
};
|
||||
|
||||
|
||||
// Utility function for tool dialogs.
|
||||
void MakeModalAndBringToFront( vgui::EditablePanel *dialog );
|
||||
|
||||
bool ToolCanApplyTo( CEconItemView *pTool, CEconItemView *pToolSubject );
|
||||
|
||||
// Given a tool and an item to apply the tool's effects upon,
|
||||
// gather required information from the user and
|
||||
// send a change request to the GC.
|
||||
bool ApplyTool( vgui::Panel *pParent, CEconItemView *pTool, CEconItemView *pToolSubject );
|
||||
|
||||
#endif // TOOL_ITEMS_H
|
||||
Reference in New Issue
Block a user